This is an implementation of Observational Type Theory. It is "simplified" because the definitions of equality of types and terms do not reduce as in the original definition. Instead, the theory provides ways to construct proofs of equality, and to project out consequences of an equality (e.g., equal pairs implies the components are equal). Not reducing equality propositions stops (this source of) explosion of the sizes of types.
- Make sure you have opam installed.
- Install dependencies locally
opam switch create . --deps-only
- Update shell environment:
eval $(opam env)
dune build
dune exec cmd/sott.exe typecheck <file.sott>
-
test1.sott Derivation of
transport
fromcoerce
; and a demonstration that Hofmann's counterexample to canonicity in the presence of a functional extensionality axiom fails in OTT. -
test1.5.sott Shortened version of test1.sott.
-
test2.sott An equality-proof irrelevance test; transivity and symmetry; coherence.
-
test3.sott Encoding of sum types via booleans and sigma types; demonstration that the counterexample to canonicity involving constructors when adding functional extensionality fails in OTT [https://coq.inria.fr/cocorico/extensional_equality].
-
arith.sott Construction of and some proofs for the integers constructed as a quotient of pairs of natural numbers.
-
Type equalities, written
[A = B]
, whereA
andB
are proper types. All proofs of the same equality are definitionally equal. -
Heterogeneous term equality, written
[a : A = b : B]
, whereA
andB
are types. As a shorthand, ifA
is the same asB
, then this can be written as[a = b : A]
. All proofs of the same equality are definitionally equal. -
Reflexivity for both type and term equality, written
refl
. -
Coercion, written as
coerce(a,A,B,p)
, whereA
andB
are types,a : A
, andp : [A = B]
. IfA
andB
are in normal form, then the coercion will compute as appropriate to the type. This is how we maintain canonicity even when the equality type is arbitrarily extended. -
Coherence,
coherence(e)
wheree : [A = B]
, has type[x : A = coerce(x,A,B,e) : B]
(thex
is inferred from the type being pushed in). -
Pi types:
(x : A) -> B
,\x -> e
ande1 e2
. Function extensionality is witnessed byfunext(x1 x2 x_e. XXX) : [f1 : (x : A1) -> B1 = f2 : (x : A2) -> B2]
, wherex1 : A1
,x2 : A2
,x_e : [x1 : A1 = x2 : A2]
andXXX : [f1 x1 : B1[x1] = f2 x2 : B2[x2]]
. -
Sigma types
(x : A) * B
,(x,y)
andx #fst
,x #snd
. -
Booleans:
Bool
,True
,False
andx for x. T { True -> e1; False -> e2 }
. -
Natural numbers:
Nat
,Zero
,Succ n
andx for y. T { Zero -> e1; Succ n p -> e2 }
. -
A Russell-style universe
Set
, which includes equalities, booleans, naturals, Pi, Sigma. -
Quotient types:
-
Formation:
A / R
, whereA
is a type andR : A -> A -> Set
-
Introduction:
[a] : A / R
, wherea : A
-
Elimination:
x for z. T { [z] -> e1; z1 z2 zr -> e2 }
. The expressione1
computes the answer, ande2
is a proof thate1
doesn't depend on the equivalence class. -
Propositional equality:
same-class(e) : [[a1] : A/R = [a2] : A/R]
whene : R a1 a2
.
-
-
The parser reports a line number on error, but otherwise the error messages are useless. One day, I hope to use Menhir's fancy error message support.
-
Not every useful combinator for equalities is present. This is a matter of implementing them in the lexer/parser/typechecker.
-
The normaliser is a bit too keen and unfolds all definitions whether it needs to for equality checking or not. This leads to massive terms during type checking. Error messages are now reported without unfolded definitions though, which makes them a bit easier to read.
-
Type error messages don't include the context, and may output names that shadow names in the context, leading to incorrect terms.