Professional Documents
Culture Documents
SeriesTitle:ProofsasProcesses
RobertL.Constable
CornellUniversity
Department of Computer
DepartmentofComputer
Science
2.Looktowardwhatmightcomenext intypetheory.
Amazing Times
AmazingTimes
ConsiderthebroadinternationaluptakeofCoq!
p
q
FourColorTheoremofGonthier
MSRinvestinginGonthiersunitprovingFeitThompson
FundamentalTheoremofAlgebra
TheCompCert CLight compilerofLeroy
FieldsmedalistVoevodskys HomotopyTheory
SoftwareFoundationstextbookbyPierceetal
DARPA heavily using proof assistants mainly Coq
DARPAheavilyusingproofassistants,mainlyCoq
Severalkeyindustrialapplications(Javacard,AirBus,)
Many thousands of Coq users over10Kusedit?
ManythousandsofCoqusers
over 10K used it?
Andmore
A Poll
APoll
I dliketothinkthatpropositions
Id
like to think that propositionsastypes
as types
realizability isoneofthoseideasfamiliartomany
OPLSSparticipantsandthatitwilleventuallybe
p
p
y
knownbyallcomputerscientists thewaysets,
opensets,continuousfunctions,vectorspaces,
etc.areknowntoallmathematicians.
Howmanypeopleherecouldteachthisideatoa
nd y
computerscience2
p
yearstudent?
BriefReview:PropositionalEvidence
p
Supposethatwehaveevidencetypesfortheatomic
propositions A,B,C,
propositions
A B C Hereishowtodefineevidencefor
Here is how to define evidence for
compoundformulasusingtypes(orsets).
A & B == A x B
A B == A B
A B == A B
A == A
[Ex B(x)]
[Ex.B(x)]==x:D
x:D [B(x)]dependentproduct
[B(x)] dependent product
[Allx.B(x)]==x:D[B(x)]dependentfunctions
Theexistentialquantifierisalsoregardedasa
type,adisjointsumofafamilyofevidencetypes.
EvidenceforQuantifiedStatements
x : A.Bx == x : A x Bx
x : A.Bx == x : A Bx
Theexistentialquantifierisalsoregardedasa
type a disjoint sum of a family of evidence types
type,adisjointsumofafamilyofevidencetypes.
Simple Example
SimpleExample
Considerthemeaningofthispropositioninthe
Consider
the meaning of this proposition in the
realizabilitysemantics:
(A&B =>>C)
(A&B
C) =>>(A
(A =>>(B
(B =>>C))
C))
ItsrealizerinCTTisthisuntypedappliedterm
Its
realizer in CTT is this untyped applied term
f. x. y.f(<x,y>)or
f,x,y.f(<x,y>)
Simple Example
SimpleExample
Considerthemeaningofthispropositioninthe
Consider
the meaning of this proposition in the
realizabilitysemantics:
(A&B =>>C)
(A&B
C) =>>(A
(A =>>(B
(B =>>C))
C))
Here is the typing judgment a la CTT
HereisthetypingjudgmentalaCTT
f: (A&B) => C x:A y:B | f(<x,y>)
f:(A&B)=>C,x:A,y:B|
f(<x y>) C
Thi i th
ThisisthespecificationfortheCurryingtask.
ifi ti f th C
i t k
UnCurrying
Un
CurryingTask
Task
(A=>(B=>C))=>(A&B=>C)
(A
=> (B => C)) => (A&B => C)
theuntypedrealizeris
f.
f p.f(p.
p f(p 1)(p.
)(p 2)
p.1 andp.2 projectfromthepair,
e.g.p.1 Aandp.
A d 2B
thetypingjudgmentis
h
i j d
i
f:(A=>(B=>C)),p:A&B| f(p.1)(p.2) C
Here is a challenge
Hereisachallenge
Ourcolleaguesfinallyunderstandthatconstructive
Our
colleagues finally understand that constructive
logicisnaturalandeasytounderstand,directlytied
tospecifyingprogrammingproblemsandallthat.
Theylearnsomelogic,getexcitedandwanttoknow
theconsistency andcompleteness theoremsforthis
id i
ideainpurefirstorderlogic
fi t d l i FOL.
FOL
Wegivethemproofrulesandconsistency,then
WegivethembackKripkesemantics andpossibly
aclassicalcompletenessproofaswell!!Andthenwe
give them excuses
givethemexcuses.
Lecture Plan
LecturePlan
1. Lookataconstructivecompletenessprooffor
i i i i i fi
intuitionisticfirstorderlogic(iFOL)withrespectto
d l i (iFOL) i h
itsintendedrealizabilitysemantics.
2 IInjectdiscussionoftypetheorydesignissuesand
2.
j di
i
f
h
d i i
d
possiblefuturedirections,andfollowupin
subsequent lectures as appropriate and suited your
subsequentlecturesasappropriateandsuitedyour
interests.
GdelsPhDThesiswasCompleteness
ofFOL
f
OnJuly6,1929Gdel
On
July 6 1929 GdelssPhDdissertationwas
PhD dissertation was
approvedbyhisadvisorHansHahn.Itwastitled:On
thecompletenessofthecalculusoflogic.
p
f
f g
In1930itwaspublishedas:Thecompletenessofthe
In
1930 it was published as: The completeness of the
axiomsofthefunctionalcalculusoflogic.Heused
theaxiomsofPrincipiaMathematica.
Another Poll
AnotherPoll
How many of you have seen a proof of this theorem?
Howmanyofyouhaveseenaproofofthistheorem?
How many of you could teach the proof?
Howmanyofyoucouldteachtheproof?
IIthinkthesimplestandclearestproofisfrom
thi k th i l t d l
t
fi f
SmullyansFirstOrderLogic,Springer1968,Dover
1993 using tableaux pp 5761
1993,usingtableaux,pp57
61.
GdelssCompletenessTheorem
Gdel
Completeness Theorem
Thistheoremsaysthatthereisasetofinference
s t eo e says t at t e e s a set o
e e ce
rulesandaxiomssuchthateveryformulaofFOL
thatistrueineverymodel(valid)isprovable
usingtheserules.
h
l
Thesearethecompletesetofrules.
ThistheoremsetsusupforGdelsmorefamous
incompletenesstheoremforarithmetic.
Intuitionistic Validity
IntuitionisticValidity
Thevaliditysemanticscarriesovertheclassical
y
notionofamodel andusesBHKsemanticsforthe
logicaloperatorsonpropositionsandtypesforthe
domain of discourse, e.g. D is a type in the first
domainofdiscourse,e.g.Disatypeinthefirst
universe,Type1.
WesaythatformulaGisvalidiffitisrealizableinall
modelsofthedomainandtheatomicpropositions.
So modern constructive type theories like CIC ITT
SomodernconstructivetypetheorieslikeCIC,ITT,
andCTTmakethissemanticsprecise.Thatisabig
stepsince1988.
SomeUnifyingBasicConceptsfrom
TypeTheory
h
Computability,e.g.partialcomputablefunctionsin
all types (Turing complete)
alltypes(Turingcomplete)
Polymorphism and intersection types
Polymorphismandintersectiontypes
Uniform validity and constructive completeness
Uniformvalidityandconstructivecompleteness
Grounded in computation
Groundedincomputation
Constructivetypetheoryderivesitsmeaning
Co
st uct e type t eo y de es ts ea g
fromanunderlyingcomputationsystem,usually
definedbyreductionrulesinthestyleofPlotkins
structuredoperationalsemantics.
d
l
Forexample,untypedlambdaterms,(x.b),are
consideredirreduciblevalues,andapplications
ap(f;a) are evaluated by reducing f to a function
ap(f;a)areevaluatedbyreducingftoafunction
value,thenapplyingthefunctionvaluetothe
argumenta(eitherbynameorvalue).
g
(
y
)
Openended
Open
endedComputationSystem
Computation System
InCTT,ITT,andCICthecomputationsystemisleft
In
CTT, ITT, and CIC the computation system is left
openended,itisnotpossibletoproveunsolvability
byenumeratingallpossiblecomputationalforms.In
particular,ChurchsThesis(CT)isnotpostulated.
InbuildingtheNuprlproofassistantforCTT84,we
anticipatedextendingthecomputationalmodelto
concurrentsystemsandtophysicaldevices.ThusCT
wasnottheappropriatenotion.
A Computational Metatheory
AComputationalMeta
theory
Edinburgh
g LCF showedthepowerofhavinga
p
g
computationalmetatheorybasedonaclean
functionalprogrammingmodelasthebasisfor
automatingreasoning.Agda,HOL,Coq,Nuprl,and
g
g g ,
, q, p ,
MetaPRLarealldescendentsoftheLCFproof
assistantarchitecture.
KeytoMilnersLCFistheideathatprogramsare
polymorphic
p
y
p andthecompilerattemptstoinferthe
p
p
typeincontextgivensomebasetypessuchas
integersandlists.Thetypecheckerwasasmall
proof assistant.
proofassistant.
APictureofProofTrees
G
H1 G1
H2 G2
pf
44
ProofStructurewithExtracts
G by op(op1(lt,md,rt) ; op2(lt,rt) )
H1 G1 by
b op1(lt,md,rt)
op1(lt md rt)
H2 G2 by op2(lt,rt)
op2(lt rt)
pf
45
AnalyzingProofStructure
y g
key insights
clever step
filled in by machine
humans ignore
humans need
experts needed
routine
learners need
obvious
Trivial
well known
minor variant of pf
46
Type Polymorphism
TypePolymorphism
Thetermx.x istheidentityfunctiononalltypes,
y
yp ,
i.e.x.x A>AforanytypeA.
Thetermx.y.pair(x;y))denotesapairing
( ))
functionoftype(A>(B>(A B))foranytypes
A and B. We also used x.y. <x,y>
AandB.Wealsousedx.y.
x,y earlier.
earlier.
Wesaythatsuchtermsarepolymorphic.
y
p y
p
Note,thefunctionscomputedbythesetermsare
toobigtoexistinSetTheories.
Intersection Types
IntersectionTypes
Thebinaryintersectiontypewasusedasalogical
y
yp
g
{
connectiveforpropositionallogicbyCoppo and
Dezani in1978.
A B
ThesearetheelementsinbothtypesAandBwith
xx=yyintheintersectioniffx
in the intersection iff x=yyinA&x
in A & x=yyinB.
in B.
aA
denotethetypeofelementsthatbelongtoBa for
everyainType.Thisintersectionoperatoractsasa
uniformquantifieroverA.
q
A:Type
A => A
containsexactlyx.x.
Cumulative Impact
CumulativeImpact
Ourworkonintersectionanduniontypesrevealed
Our
work on intersection and union types revealed
thebenefitsofpolymorphismanditsexplanatory
powerinunderstandingalgebraicstructure,classes,
andobjects.Thisledustomakethesenewtype
d bj t Thi l d t
k th
t
constructorsessentialtoCTTafter2003.
Webegantosystematicallyexploittheseideasand
applythemheavilyinourpracticalworkandin
pp y
y
p
lookingatlogicalquestions.Imadeanobservationin
a2010classthatfascinatedme.Hereitis.
u1:A1,,un:An | G
moresuccinctly:H| G
1,,x,
, 2.g(ap(x;a)/y)
g( p( ; )/y)
1,u,v,2.spread(x;u,v.g(u,v))
On Notation
OnNotation
realizer
1,u,v,
u v 2.spread(x;u,v.g(u,v))
spread(x;u v g(u v) )
ThespreadnotationisfromITT82andworks
h
d
i i f
82 d
k
wellasaproofterm,tellingushowtoname
thehypothesesusinglabelsuandv.
h h
h
i l b l d
Givenapairp,u=p.1andv=p.2.Wecan
alsosayletp=u,v
y
p
, ing,anMLlikenotation.
g,
.<d,g(d)>
H| PvPbymagic(P)
Thisrealizermakessenseinaclassicalaccountof
oraclecomputability,givenanoracleforP.This
realizerisnotpolymorphic.
Polymorphic Realizers
PolymorphicRealizers
Noticethatalloftherealizersexceptformagic(P)are
polymorphic Thus a notion of uniform validity will
polymorphic.Thusanotionofuniformvaliditywill
ruleoutExcludedMiddle.
More Examples
MoreExamples
Here is another simple realizer
Hereisanothersimplerealizer.
(Ex P(x) & Allx (P(x) => Q(x))) => Ey Q(y) by
(Ex.P(x)&Allx.(P(x)=>Q(x)))=>Ey.Q(y)by
h
h.spread(h;e,f.spread(e;d,p.<d,f(d)(p)>)).
d(h f
d( d
d f(d)( ) ))
Exercise:Buildtheprooffromthisrealizer.
ld h
ff
h
l
Exercises
Findtherealizersfortheseformulas.Inthe
Find
the realizers for these formulas. In the
nextlecturewewillbuildaprooffromthem
usingtheproofprocedureforcompleteness.
3.(~(P&Q)&(Pv~P)&(Qv~Q))=>~Pv~Q.
( (
) (
) (
))
4. Ex.(P(x)=>C)=>((Allx.P(x))=>C)whereChasno
freeoccurrencesofx.
Mycolleague,LironCohen,andRobbertKrebbers
bothstudentsintheschoolwillhelpyouunderstand
theexercises.
Lecture 2 Plan
Lecture2Plan
Questions about Lecture 1?
QuestionsaboutLecture1?
Wewilllookmorecloselyatthecompleteness
theorem its formulation and proof I will use the
theorem,itsformulationandproof.Iwillusethe
solutiontoexercisethreeasamotivator.
How many people got the solution?
Howmanypeoplegotthesolution?
Ifthereistime,Iwilldiscussotherusesofthe
If
there is time I will discuss other uses of the
intersectiontypeinCTT,thetypetheoryofNuprle.g.
itsuseindefiningdependentrecords.
Seeadditionalexercisesonthelastslides.
Consistency Theorem
ConsistencyTheorem
Noticethatfromouranalysisofproofsandtheir
Notice
that from our analysis of proofs and their
associatedextractedrealizers,wecanseebyasimple
inductionontheproofstructurethatiFOLis
consistent,everyprovableformulais(uniformly)
it t
bl f
l i ( if
l )
valid.
Wewillalsoseethatourcompletenesstheorem
p
providesanalternativeproofofcutelimination.
p
Completeness Theorems
CompletenessTheorems
Theorem:AformulaGofmFOL
Theorem:
A formula G of mFOL isprovableiffitis
is provable iff it is
uniformlyvalid.
Corollary:AformulaGofiFOLisprovableiffitis
uniformly valid.
uniformlyvalid.
ConstableandBickford2010:Intuitionistic
Constable
and Bickford 2010: Intuitionistic
completenessoffirstorderlogic,arXiv2011.
Intersection Types
IntersectionTypes
Thebinaryintersectiontypewasusedasalogical
y
yp
g
{
connectiveforpropositionallogicbyCoppo and
Dezani in1978.
A B
ThesearetheelementsinbothtypesAandBwith
xx=yyintheintersectioniffx
in the intersection iff x=yyinA&x
in A & x=yyinB.
in B.
aA
denotethetypeofelementsthatbelongtoBa for
everyainType.Thisintersectionoperatoractsasa
uniformquantifieroverA.
q
A:Type
A => A
containsexactlyx.x.
We have a conjecture
Wehaveaconjecture
AformulaGofiFOLisprovableifandonlyifitis
uniformly true with respect to any domain D and
uniformlytruewithrespecttoanydomainDand
atomicrelationsRi.
Letstryitonlysomesimpleexamplesandseeifit
holds up.
holdsup.
Trying on exercise
Tryingonexercise
Istheresomethingeasierthanonemorecasespliton
Is
there something easier than one more case split on
Q?YES,howaboutthisevidencefor~Q?
p.inr(q.na(<p,q>)
Thisisalmostright,butitonlyprovesFalse,weneed
to prove ~Q
toprove
Q.ButfromFalseanything!Soweuse
But from False anything! So we use
p.inr(q.any(na(<p,q>)))
Evidence structures
Evidencestructures
h:(~(P&Q)&(Pv~P)&(Qv~Q))|=
( (
) (
) (
) ) | ~Pv~Q,
spread(h;na,dp,dq.decide(dp;
p.inr(q.any(na(<p,q>)));
(
( (
)))
np.Inl(np)))
Continuing
This tells us to create a new evidence structure:
Thistellsustocreateanewevidencestructure:
na:~(P&Q),dp:(Pv~P),dq:(Qv~Q)|=~Pv~Q,decide(dp;
p.inr(q.any(na(<p,q>)));
np.inl(np)))
Continuing
na:~(P&Q)
na:
(P&Q),p:P,dq:(Qv
p:P dq:(Qv~Q)
Q)|=
|= ~P
Pv
v ~Q
Q,
inr(q.any(na(<p,q>)))
na:~(P&Q),p:P,dq:(Qv~Q)|= ~Q,
q.any(na(<p,q>))
( (< >))
na:~(P&Q),p:P,dq:(Qv~Q),q:Q|= ~Q,ap(na;<p,q>)
A Nasty Case
ANastyCase
Whataboutthisverysimplecase?
y
p
|=(False=>A),f.any(f)
Italsoworkslikeacharm!Butsodoesthis!
| ( l
|=(False=>A),f.17
) f
Thisisdisconcerting
h
d
b
becauseoncewehaveFalseasa
h
l
hypothesis,welooseallevidence.
H |= G,evd
H|=
G evd
G1 &G2 <g1,g2>
G1vG2 inl(g1),inr(g2)
G1 =>G2 x.g2(x)
Allx G
Allx.G
x g(x)
x.g(x)
A hard case
Ahardcase
H,f:A=>B,H|= G,ap(f;a)
Howdowejustifytheclaim
H f:A =>B
H,f:A
>B,H
H|=
|= A,a
A a ?
Finitary models
Finitarymodels
Wejustifythisimplicationeliminationcaseby
looking at a subset of the models that we call finitary
lookingatasubsetofthemodelsthatwecallfinitary.
OnthesemodelsforAwecanensurethatiffisgiven
anargumentnotinA,thenitwilldiverge.Herewe
g
,
g
dependonhavingpartialtypes,whichwedenoteas
.
Wesaythata belongsto ifitbelongstoA ifit
converges.
Constant functions
Constantfunctions
Itisalsoimportantinthecaseoffunctionsffrom
It
is also important in the case of functions f from
A=>Bthatwemakesurewereturnthesameresult
ifwecallthefunctionf twiceonthesameargument.
g
Wedothisbynotingthatwecanalwaysassign
constantfunctionstothesewitnessesforA=>B
becauseoncewehaveanyelementofB,that
suffices.
Universal witnesses
Universalwitnesses
Inthecaseofevidencefunctionsforuniversally
quantified formulas f: Allx G(x) we need to
quantifiedformulasf:Allx.G(x),weneedto
remembertheapplicationsofthefunctionandstore
itsgraphondomainelements.Thefunctionsneedto
g p
beequalonlyonidenticalelements,d.
Hard Exercise
HardExercise
SShowthatthefollowingtypetheorytermisevidencefor
o t at t e o o g type t eo y te
s e de ce o
(((A&B)=>(A&B))=>(CvD))=>(C=>E)=>E
h,f,g.letn=gcd(10,5)in
letm=last(factorization(111))in
let I1 =(x.x)
letI
(x x)n in
letI2 =(p.<p.1,p.2>)m in
(if isl(h(I1))thenfelseg)
(ifisl(h(I
)) then f else g)
letx=h(I2)inifisl(x)thenoutl(x)else
outr(x))
Partial Types
PartialTypes
Wewillnowexaminesometypesusedintheproof
that distinguish NuprlssCTTfromCoq
thatdistinguishNuprl
CTT from CoqssCICand
CIC and
reflectonthefutureoftypetheory.Wealsoseea
significantdifferencefromthesettheoryapproach
g
y pp
totheseideas.
Alternative Syntax
AlternativeSyntax
f =function(x.ifx=0then1
elseifeven(x)thenf(x/2)
l if
( ) th f( /2)
elsef(3x+1))
Recursion in General
RecursioninGeneral
f(x)=F(f,x)isarecursivedefinition,also
( ) (, )
,
f=(x.F(f,x))isanotherexpressionofit,andthe
CTTdefinitionis:
fix((f.(x.F(f,x)))
whichreducesinonestepto:
(x.F(fix((f.(x.F(f,x)))),x))
bysubstitutingthefixtermforfin(x.F(f,x)).
Nonterminating
Non
terminatingComputations
Computations
CTTdefinesallpartialrecursivefunctions,andpartial
CTT
defines all partial recursive functions, and partial
elementsoftypeshencenonterminatingonessuch
asthis
fix((x.x))
whichinonereductionstepreducestoitself!SoCTT
is a Turing complete programming language
isaTuringcompleteprogramminglanguage.
Thissystemofcomputationisasimplefunctional
This
system of computation is a simple functional
programminglanguage.InCTTitisessentiallythe
programminglanguagealsousedinthemetatheory,
ML.
Partial Functions
PartialFunctions
Theconceptofapartialfunctionisanotherexample
The
concept of a partial function is another example
ofwheretypetheoryandsettheorydiffer
substantiallyy andwhereCTTdiffersfromCIC.Itisan
importantdifferencebecausethehaltingproblem
andrelatedconceptsarefundamentallyabout
whethercomputationsconverge,andintypetheory
thisistheessenceofpartiality.Forexample,wedo
not know that the 3x+1 function belongs to the type
notknowthatthe3x+1functionbelongstothetype
N>N.
Partial Functions
PartialFunctions
Wedohoweverknowthatthe3x+1function,callitf
We
do however know that the 3x+1 function call it f
inthisslide,isapartialfunction fromnumbersto
numbers,thusforanyn,f(n)isanumberifit
,
y , ( )
converges(halts).
InCTTwesaythatavalueabelongstothebartype
providedthatitbelongstoAifitconverges.Sof
belongstoAfor=N.
Unsolvable Problems
UnsolvableProblems
Itisremarkablethatwecanprovethatthereisno
It
is remarkable that we can prove that there is no
functioninCTTthatcansolvetheconvergence
p
problemforelementsofbasicbartypes.
yp
Wewillshowthisfornonemptytypewith
We
will show this for non empty type with
elementthatconvergesinAforbasictypessuch
as Z, N, list(A), etc. We rely on the typing that if F
asZ,N,list(A),etc.WerelyonthetypingthatifF
mapsto,thenfix(F)isin.
Unsolvable Problems
UnsolvableProblems
Supposethereisafunctionh thatdecideshalting,e.g.
h:Bool.
Definethefollowingelementofforin
A:
d=fix((x.ifh(x)thenelsefi))
whereisadivergingelement,sayfix((x.x)).
Notedisinbythetypingruleforfix.
Nowweaskforthevalueofh(d)andfinda
contradictionasfollows:
d=fix((x.ifh(x)thenelsefi))
d=ifh(d)thenelsefi
bysubstitutingthefix()forxinthebody.
Ifhd(d)=f,
f thenweseethatdconvergesto,again
g
g
acontradictiontothemeaningofh.
ENDOFLECTURETWO
O
C
O
Subtyping andPolymorphism
and Polymorphism
Thereisaprimitivesubtyping relationinCTT.
means that the elements of A are
are
A B meansthattheelementsofA
elementsofB anda=binA impliesa=binB.
Here are some basic facts about subtyping:
Herearesomebasicfactsaboutsubtyping:
{x : Z
| x > 0} Z
( A A & B B ) A B A B
( A A & B B ) A + B A + B
( A A & B B ) A B A B
Applications of Polymorphism
ApplicationsofPolymorphism
Polymorphismallowsanelegantformaltreatmentof
Polymorphism
allows an elegant formal treatment of
recordtypes,objects,andinheritance.Wewilllook
atrecordsandprovideasimplesemanticsforthem
p
p
andasimplebinaryoperationtobuildthem.
Thisaccountalsoallowsustodefinedependent
records,asignificantextensionoftherecord
concept.
Dependent Records
DependentRecords
{x1:A1;x2:A1(x1);x3:A(x1,x2);;xn:An(x1,,xn1)}
functionsr fromLabels{x1,,xn}tovalues
wherer(x1)A1,r(x2)A2(r(x1)),etc.
G roup M onoid
id
i:{op,id,inv}Sig(i)i:{op,id}Sig(i)
A B
ThesearetheelementsinbothtypesAandBwith
x=yintheintersectioniffx=yinA&x=yinB.
Topisthetypeofallclosedtermswiththetrivial
equality,x=yforallx,yinTop.Noteforanytype
A,wehaveand.
A Top
ATop = A
{x:A ; y:B} if xy
{x:A;y:B}ifxy
x:A y:B=
{x:AB}ifx=y.
Axiomatizing Coinductive
AxiomatizingCo
inductiveTypes
Types
In1988beforeweaddedintersectiontypestoCTT,
In
1988 before we added intersection types to CTT
weaxiomatizedcoinductivetypesandimplemented
theminNuprlasprimitive.
p
p
NowwithintersectiontypesandtheToptype,we
Now
with intersection types and the Top type, we
candefinethemandintroducevariants.
Defining Corecursive
DefiningCo
recursiveTypesinCTT
Types in CTT
LetFbeafunctionfromtypestotypessuchas
Let
F be a function from types to types such as
F(T)=N xTorF(T)=St>In>StxT.Define
objects of the corecursive
objectsoftheco
recursivetypecorec(T.F(T))
type corec(T F(T))
astheintersectionoftheiteratesofFapplied
to Top
toTop.
n
F (T o p )
n :N
TTobuildelements,wetakethefixedpointofa
b ild l
k h fi d i
f
functionfinthefollowingtype.
T F(T )
T:Type
Elements of Coinductive
ElementsofCo
inductiveTypes
Types
Forexampletobuildelementsoftheco
For
example to build elements of the co
recursivetypeforthefunctionF(T)givenby
St >In
St
In >StxT
St x T
weusefix((t.(s,i.<update(s,i),t>))).
Itiseasytoshowbyinductionthatthis
belongs to the corecursive type If the
belongstothecorecursivetype.Ifthe
functionFiscontinuous,thetypeisafixed
point of F, F(corec(T.F(T)) corec(T.F(T)).
pointofF,F(corec(T.F(T))
Future Directions
FutureDirections
IIthinkwewillcontinuetoseeconstructivetype
think we will continue to see constructive type
theoryunifyconceptsfromlogic,mathematics,and
computerscience.Homotopytypetheoryisa
p
py yp
y
currentexampleasaregamesemantics.
Wewillseeappliedformaltheoriessupport
importantdeployedsystems.Thesetheorieswillbe
asdynamicasthesystems.
Future Directions
FutureDirections
Amoreinternalandspecializeddevelopmentwill
A
more internal and specialized development will
betheerosionofthebarrierbetween
mathematicsandmetamathematics asBrouwer
desired thereisonemathematics.
IalreadyseeNuprlappliedtoitselftoverifythe
optimizations to the evaluators for distributed
optimizationstotheevaluatorsfordistributed
protocols.Theseimplementedtheoriesandtheir
p
proofassistantsareautocatalytic.
y
Exercises
1. (P
(P=>>Q)
Q) =>>~Q
Q=>>~P
P
where~Pmeans(P=>False),notP.
Inminimallogic,wetakeaspecialconstantfor
False, say Any. While (False =>>P)holds,inminimal
False,sayAny.While(False
P) holds, in minimal
logic,(Any=>P)doesnotholdforarbitraryP.Show
2.(P=>Q)=>((Q=>Any)=>(P=>Any))
(
Q) ( (Q
y) (
y) )
Exercises continued
Exercisescontinued
3.((~(P
(P&Q)&(Pv
& Q) & (P v ~P)
P)&(Qv
& (Q v ~Q)
Q))=>
) => ~P
Pv
v ~Q
Q.
4 Ex
4.
Ex.(P(x)=>C)=>((Allx.P(x))=>C)whereChasno
(P(x) => C) => ( (Allx P(x)) => C ) where C has no
freeoccurrencesofx.
5 Ey.
5.
Ey ~Q(y)
Q(y)=>Allx.(P(x)=>Q(x))=>
=> Allx (P(x) => Q(x)) => ~Allx
Allx.P(x).
P(x)
6 (Ey
6.
(Ey.Allx.P(x,y)=>Eu.Allv.Q(u,v))=>
Allx P(x y) => Eu Allv Q(u v)) =>
(Ally.(Allx.P(x,y)=>Eu.Allv.Q(u,v)).
Hard Exercise
HardExercise
Recalltheexample:
p
(((A&B)=>(A&B))=>(CvD))=>(C=>E)=>E
Arethesebothcorrectrealizers?
h f g.decide(h(id
h.f.
d id (h(id1);c.f(c);d.g(d))
) f( ) d (d))
h f g.ap(decide(h(id
h.f.
g ap(decide(h(id1);c
);c.f;d
f;d.g);ap(decide(h(id
g);ap(decide(h(id2);c.c;d.d))
);c c;d d))
whereid1 =x.x ,,id2=x.spread(x;x
p
( ; 1,,x2.<x1,,x2>))
Formoreinformation,articles,and
,
,
examplesofverifiedcodesee
www nurpl org
www.nurpl.org
THE END
THEEND
Questions?
Alsoseewww.nuprl.org
l
l