Cedille - ionathanch/ionathanch.github.io GitHub Wiki
These can be entered in Emacs using \β
, replacing the hole with the bolded, underlined character of the mnemonic.
Mnemonic | Character |
---|---|
hole | β |
period. | Β· |
lambda | Ξ» |
Lambda | Ξ |
right, β> | β |
-β³ | βΎ |
Pi | Ξ |
forall | β |
star | β |
Box | β‘ |
forward (?) | β |
k | π |
= | β |
beta | Ξ² |
Rho | Ο |
Fi | Ο |
delta | Ξ΄ |
why | Ο |
intersection | ΞΉ |
mu | ΞΌ |
case | Ο |
theta | ΞΈ |
x | Ο |
M-s
toggles Cedille navigation mode.
See cedille-main-info for more commands and detailed explanations.
Command | Effect |
---|---|
f /b
|
Sibling node (forward/backward) |
a /e
|
Sibling node (first/last) |
p /n
|
Parent/child node (prev. visited or first) |
r /R
|
Next/previous error |
t /T
|
First/last error |
i |
Toggle node info |
c |
Toggle node context |
s |
Toggle file summary |
The below are interactive commands on nodes prefixed by C-i
.
Command | Effect |
---|---|
n /h
|
Normalize (head normal) |
u |
Reduce |
e |
Erase |
r /R
|
Clear (all) |
Function shape | Dependent | Nondependent | Abstraction | Application |
---|---|---|---|---|
Type to type | Ξ x: π. π |
π β π |
Ξ» X: π. U |
T Β·U |
Term to type | Ξ x: T. π |
T β π |
Ξ» x: T. U |
T e |
Type to term (erased) | β X: π. U |
βΈ» | Ξ X: π. e |
t Β·U |
Term to term (erased) | β x: T. U |
T βΎ U |
Ξ x: T. e |
t -e |
Term to term | Ξ x: T. U |
T β U |
Ξ» x: T. e |
t e |
Note: It appears that type applications can be left out and inferred, but not implicit term applications.
-- Declare type with kind
Unit β β
= β X: β
. X β X.
-- Declare term with type
unit : Unit
= Ξ X. Ξ» x. x.
-- Declare abstracted kind (pattern-matching style)
-- With the β‘ sort, this would be equivalent to
-- π : (Unit β β
) β Unit β β‘
-- = Ξ» F: Unit β β
. Ξ» u: Unit. F u β β
.
π (F: Unit β β
) (u: Unit) = F u β β
.
-- Local definitions
true : β X: β
. X β X β X
= Ξ X. Ξ» x.
-- Erased definition
{Y: β
= X} - Ξ» y: Y. x.
false : β X: β
. X β X β X
= Ξ X. Ξ» x.
-- Non-erased definition
-- Ο T - t asserts t has type T
[id = Ο (X β X) - Ξ» y. y] - id.
-- Trivial equality proof
refl : β X: β
. β x: X. {x β x}
= Ξ X. Ξ x. Ξ².
-- Rewriting via an equality
-- Given a goal type T and an equality p: {e β e'},
-- Ο p - u will rewrite T containing e to T' containing e'
-- in place of e, proving T' with u.
-- The term e of a trivial reflexive proof {e β e}
-- can be specified using Ξ²<e>.
sym : β X: β
. β x: X. β y: X. {x β y} β {y β x}
= Ξ X. Ξ x. Ξ y. Ξ» p. Ο p - Ξ²<y>.
-- Equality with explicit erasure term
-- The erasure of an equality proof Ξ²{|t|} is t;
-- since the erasure of equalities could be anything,
-- the induction hypothesis must cover all erasures.
-- Note the missing type argument of d that was inferred.
J : β X: β
. β x: X. β P: (Ξ y: X. {x β y} β β
).
Ξ d: β T: β
. β t: T. P x Ξ²{|t|}.
β y: X. β p: {x β y}. P y p
= Ξ X. Ξ x. Ξ P. Ξ» d. Ξ y. Ξ p. Ο (sym -x -y p) - d -p.
-- Subst via J with automatic motive inference
-- In the below where the ΞΈ term is, the desired type is P x β P y.
-- We wish to use J to prove this, and J requires a motive P'.
-- ΞΈ<y p> then abstracts the desired type over these variables,
-- creating the motive (Ξ» y: X. Ξ» p: {x β y}. P x β P y) (p is unused),
-- then applies the motive to (J -x).
-- Without ΞΈ, this would be written as J -x Β·P' (Ξ T. Ξ t. Ξ» px. px) -y -p,
-- which would be a lot more tedious to write with P' explicitly stated,
-- especially since the abstracted types X and {x β y}
-- syntactically need to be written out in full.
subst : β X: β
. β x: X. β y: X. β P: X β β
. β p: {x β y}. P x β P y
= Ξ X. Ξ x. Ξ y. Ξ P. Ξ p. ΞΈ<y p> (J -x) (Ξ T. Ξ t. Ξ» px. px) -y -p.
-- Casting via an equality
-- Given terms e: T, e', and equality p: {e β e'},
-- Ο p - e {|e'|} erases to e' but has type T.
Omega : {unit β Ξ» x. x x} βΎ Unit
= Ξ p. [omega = Ο p - unit {|Ξ» x. x x|}] - omega omega.
-- Ex falso quodlibet
-- Given an equality p: {e β e'} of BΓΆhm-separable terms,
-- i.e. terms with distinct closed head-normal forms,
-- Ξ΄ - p can be assigned any type (although it erases to Ξ» x. x).
-- Then Ο can be used to construct an X that erases to any term;
-- in the below example it erases to p, just for fun.
absurd : {true β false} β β X: β
. X
= Ξ» p. [void: β X: β
. X = Ξ΄ - p] -
Ξ X. Ο (void Β·{void β p}) - (void Β·X) {|p|}.
-- Declaring a datatype
-- Parameters are elided in all recursive references.
data Acc (X: β
) (R: X β X β β
) : X β β
=
| acc : β x: X. (β y: X. R y x β Acc y) β Acc x.
-- Case destruction with motive
-- Given a construction c, Ο c @P { | C aβ¦ β e } deconstructs c
-- into a constructor C and arguments aβ¦, producing e
-- (where a⦠may be types ·X or implicits -x, but not parameters)
-- with optional explicit motive P abstracting over indices and target.
-- Supposing inductive I and P = Ξ» iβ¦. Ξ» x. P', in Coq this would be
-- case c as x in I _β¦ iβ¦ return P' of | C aβ¦ β e end.
accessible : β X: β
. β R: X β X β β
.
β x: X. β y: X. R y x β Acc Β·X Β·R x β Acc Β·X Β·R y
= Ξ X. Ξ R. Ξ x. Ξ y. Ξ» r. Ξ» accx.
Ο accx @(Ξ» x': X. Ξ» accx': Acc Β·X Β·R x'. {x' β x} β Acc Β·X Β·R y) {
| acc -x accy β Ξ» p. accy -y (Ο p - r)
} Ξ²<x>.
-- Note that destructing something with an index doesn't unify
-- the index outside of the destruction and inside of it,
-- so using the convoy pattern may be necessary.
-- Well-founded induction
-- If all X are accessible and the predicate P holding for all y R x
-- means that it holds for x, then P holds for all x.
-- Given a construction c, ΞΌ f. c @P { | C aβ¦ β e } is a fixed point
-- recurring on c, again with optional explicit motive P.
-- Supposing inductive I, in Coq this would be an applied fixpoint
-- (fix f (x: I) : P x := case x of | C aβ¦ β e end) c
-- (omitting inductive parameters and indices).
-- Notably, the type of f abstracts over the indices as well.
wfind : β X: β
. β R: X β X β β
. (β x: X. Acc Β·X Β·R x) β
β P: X β β
. (β x: X. (β y: X. R y x β P y) β P x) β
β x: X. P x
= Ξ X. Ξ R. Ξ» accessible. Ξ P. Ξ» ih. Ξ x.
ΞΌ wfind. (accessible -x) @(Ξ» x: X. Ξ» accx: Acc Β·X Β·R x. P x) {
| acc -x accy β ih -x (Ξ y. Ξ» r. wfind -y (accy -y r))
}.
Given a data definition (using Acc
above as an example), three additional definitions are generated.
Name | Type | Description |
---|---|---|
Is/Acc |
Ξ X: β
. Ξ R: X β X β β
. (X β β
) β β
|
X β β
that can be used as Acc
|
is/Acc |
β X: β
. β R: X β X β β
. Is/Acc Β·X Β·R (Acc Β·X Β·R) |
Trivial proof of Is/Acc
|
to/Acc |
β X: β
. β R: X β X β β
. β A: X β β
. Is/Acc Β·X Β·R Β·A β β x: X. Acc Β·X Β·R x
|
Casts A to Acc Β·X Β·R
|
Inside of a ΞΌ f. acc @P { ... }
(again using induction on an Acc Β·X Β·R
as an example), another three definitions are generated.
Name | Type | Description |
---|---|---|
Type/f |
X β β
|
Type of recursive arguments to f
|
isType/f |
Is/Acc Β·X Β·R Type/f |
Type/f is an Acc Β·X Β·R
|
f |
β x: X . β acc: Type/f x β P x (to/Acc Β·X Β·R Β·Type/f -isType/f -x acc)
|
Type of fixpoint |
The most common use case is changing an acc : Type/f x
into an Acc Β·X Β·R x
proper with to/Acc -isType/f -x acc
.
(Note that type applications to definitions can be omitted when inferrable but are included above for clarity.)
- Given a falsehood
void: β X: β . X
, any term that erases tot
can be assigned any typeX
byΟ (void Β·{void β t}) - (void Β·X) {|t|}
. - Given
t: T
,u: P t
, andp: {t β u}
, an element of the intersection typeΞΉ x: T. P x
is constructible despite having a propositional rather than definitional equality by[t, Ο (Ο p) - u {|t|}]
. - When casing on an inductive
e: I i
with indexi
, the deconstructionC i' a
for constructorC
with argumenta
does not definitionally equatei
toi'
. To have the propositional equality available, use a convoy pattern:ΞΌ fix. e @P { C i a β body }
(doesn't type check) becomesΞΌ fix. e @(Ξ» i'. Ξ» e'. {i β i'} β P i' e') { C i' a β Ξ» p. Ο p - body } Ξ²<i>
.
Erased term | Erases to |
---|---|
βxβ |
x |
βΞ» x. tβ |
Ξ» x. βtβ |
βt uβ |
βtβ βuβ |
βΞ x. tβ |
βtβ |
βt Β·Uβ |
βtβ |
βt -uβ |
βtβ |
βΟ T - tβ |
βtβ |
βΞ²{|t|}β |
βtβ |
βΟ p - tβ |
βtβ |
βΟ p - u {|t|}β |
βtβ |
βΞ΄ - pβ |
Ξ» x. x |
β[t, u]β |
βtβ |
βt.1β , βt.2β
|
βtβ |
Sorting, kinding, typing: Ξ β’ π : β‘
β Ξ β’ T : π
β Ξ β’ t : T
Well-scopedness: Ξ β’ π
β Ξ β’ T
β Ξ β’ t
The below are only the kinding and typing rules for equality and intersection.
Ξ β’ t : T
βββββββββββββββ
Ξ β’ Ο T - t : T
Ξ β’ tβ Ξ β’ tβ
ββββββββββββββββ
Ξ β’ tβ β tβ : β
Ξ β’ u βtββ β
βtββ
ββββββββββββββββββββ
Ξ β’ Ξ²{|u|} : tβ β tβ
Ξ β’ p : {tβ β tβ} Ξ β’ u : T[x β¦ tβ]
ββββββββββββββββββββββββββββββββββββββ
Ξ β’ Ο p - u : T[x β¦ tβ]
Ξ β’ p : {tβ β tβ} Ξ β’ tβ : T
βββββββββββββββββββββββββββββββ
Ξ β’ Ο p - tβ {|tβ|} : T
Ξ β’ p : {tβ β tβ} βtββ β βtββ
ββββββββββββββββββββββββββββββββ
Ξ β’ Ξ΄ - p : T
Ξ β’ T : β
Ξ, x: T β’ U : β
ββββββββββββββββββββββββββββ
Ξ β’ ΞΉ x: T. U : β
Ξ β’ t : T Ξ β’ u : U[x β¦ t] βtβ β
βuβ
ββββββββββββββββββββββββββββββββββββββββββ
Ξ β’ [t, u] : ΞΉ x: T. U
Ξ β’ t : ΞΉ x: T. U
βββββββββββββββββββββββββββββββββββ
Ξ β’ t.1 : T Ξ β’ t.2 : U[x β¦ t.1]