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 thatis a context. asserts thatis a type (in context ). , presupposing and, asserts that is a term of type in context . , presupposing and , asserts thatis 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 thatand are equal substitutions from to . , presupposing and , asserts thatand are equal types in context . , presupposing and , asserts thatand are equal terms of type in context .
We will also sometimes consider
, presupposing and , asserts thatand 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; - For
, the meta-set of types over; - For
and , the meta-set of terms of typeover ; - For
, the meta-set of substitutions fromto .
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 holds.
or what is the same
Given a variables of each type
, the judgement thesis holds.
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
; ; .
^PB1 and ^PB3 can be combined to give
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 we have a bijectionnatural in so that for any 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