Cartesian calculus of substitutions
The (cartesian) calculus of substitutions is one way of presenting a (dependent, cartesian) type theory as a formal system which is naturally viewed as having semantics in a cartesian category. It can be viewed as an extension of the linear calculus of substitutions, but here we give a full presentation following Principles of dependent type theory.
Notes on this presentation
We use De Brujin indices, and describe Syntax sugar for named variables.
Following Principles, βimplicitβ arguments are made explicit in grey, for example we have
Judgements
We have the following basic judgements:
asserts thatΞ β’ is a context.Ξ asserts thatΞ β’ π΄ is a type (in contextπ΄ ).Ξ , presupposingΞ β’ π : π΄ andΞ β’ , asserts thatβ’ π΄ is a term of typeπ in contextπ΄ .Ξ , presupposingΞ β’ πΎ : Ξ andΞ β’ , asserts thatΞ β’ is a substitution fromπΎ toΞ , that is,Ξ fills all the hypotheses ofπΎ with terms inΞ .Ξ
We also have the following manifestations of judgemental equality:
, presupposingΞ β’ πΎ = πΎ β² : Ξ andΞ β’ πΎ : Ξ , asserts thatΞ β’ πΎ β² : Ξ andπΎ are equal substitutions fromπΎ β² toΞ .Ξ , presupposingΞ β’ π΄ = π΄ β² andΞ β’ π΄ , asserts thatΞ β’ π΄ β² andπ΄ are equal types in contextπ΄ β² .Ξ , presupposingΞ β’ π = π β² : π΄ andΞ β’ π : π΄ , asserts thatΞ β’ π β² : π΄ andπ are equal terms of typeπ β² in contextπ΄ .Ξ
We will also sometimes consider
, presupposingΞ = Ξ β’ andΞ β’ , asserts thatΞ β’ andΞ are equal contexts,Ξ
although this is redundant as it reduces to equality of types. Judgemental structure suggests the following meta-sets:
- The meta-set
of contexts;C x = { Ξ : β£ : Ξ β’ } - For
, the meta-setΞ β C x of types overT y β‘ ( Ξ ) = { π : β£ : Ξ β’ π } ;Ξ - For
andΞ β C x , the meta-setπ β T y β‘ ( Ξ ) of terms of typeT m β‘ ( Ξ , π ) = { π‘ : β£ : Ξ β’ π‘ : π } overπ ;Ξ - For
, the meta-setΞ , Ξ β C x of substitutions fromS b β‘ ( Ξ , Ξ ) = { πΎ : β£ : Ξ β’ πΎ : Ξ } toΞ .Ξ
In practice these may be thought of as equivalence classes of derivation trees with the appropriate judgement at the root.
Inference rules
Context formation
The creation of contexts is governed by
giving the empty context and context extension respectively.
Since these are the only way contexts are formed, they establish that every context is a list of types
For a judgement thesis
Assuming hypotheses
, the judgement thesis π΄ 1 , β¦ , π΄ π holds. J
or what is the same
Given a variables of each type
, the judgement thesis π΄ 1 , β¦ , π΄ π holds. J
Judgemental equality of contexts
We can define equality of contexts recursively by
which is why this judgement is considered redundant.
Substitutions form a category
The βalgebraβ of substitutions is governed by the following inference rules:
In concert these ensure that the meta-set of contexts
Substitutions act on types and terms from the right
Substitutions act on both types and terms on the right, so:
Moreover, this action respects the categorical structure of substitutions:
Given a substitution
;πΎ β : π β¦ π β πΎ : S b β‘ ( Ξ , Ξ ) β S b β‘ ( Ξ , Ξ ) ;πΎ β : π΄ β¦ π΄ [ πΎ ] : T y β‘ ( Ξ ) β T y β‘ ( Ξ ) .πΎ β : π β¦ π [ πΎ ] : T m β‘ ( Ξ , π΄ ) β T m β‘ ( Ξ , πΎ β π΄ )
^PB1 and ^PB3 can be combined to give
β πΏ β πΏ β : ( πΎ , π ) β¦ ( πΏ β πΎ , πΏ β π ) : β πΎ β S b β‘ ( Ξ 1 , Ξ ) T m β‘ ( Ξ 1 , π΄ [ πΎ ] ) β β πΎ β S b β‘ ( Ξ 0 , Ξ ) T m β‘ ( Ξ 0 , π΄ [ πΎ ] )
Cartesian contexts
First we establish
We now establish that
Notation
To reduce proliferation of parentheses,
The left projection
The right projection
Finally, we have β
We can use these to define the auxiliary operation of Substitution extension by a type.
Syntax sugar for named variables
While the above presentation has nice formal properties, its use of De Brujin indices has a negative effect on human readability. Note that by the variable and weakening rules,
so we can see
for the same judgement. These should be viewed as syntax sugar reducing to judgements of the form given above, so for example
is the same judgement. When applying substitutions into named contexts, we are explicit about which named variable is being substituted into, for example we have
which in the formal syntax is
Elementary properties
- Terms
are in bijection with substitutionsΞ β’ π : π΄ satisfyingΞ β’ πΎ : Ξ . π΄ .π© β πΎ = π’ π - For
,Ξ β’ πΎ : Ξ , andΞ β’ πΏ : Ξ we haveΞ β’ π : π΄ [ πΎ ] .Ξ β’ πΎ . π β πΏ = ( πΎ β πΏ ) . π [ πΏ ] : Ξ . π΄ - For
andΞ , Ξ β C x we have a bijectionπ΄ β T y β‘ ( Ξ ) natural inπ Ξ , Ξ , π΄ : S b β‘ ( Ξ , Ξ . π΄ ) β β πΎ β S b β‘ ( Ξ , Ξ ) T m β‘ ( Ξ , π΄ [ πΎ ] ) so that for anyΞ Ξ 0 β’ πΏ : Ξ 1 commutes.
Proof of 1β3
For ^P1, first suppose we have
and
which completes the proof of ^P1.
For ^P2, first note
proving ^P2.
For ^P3, first suppose we have
and
so
so
and
it follows
This completes the proof of ^P3.
#state/tidy | #lang/en | #SemBr