Cedille - ionathanch/ionathanch.github.io GitHub Wiki

Unicode shortcuts

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 Ο‡

Cedille navigation mode (Emacs)

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)

Basic syntax

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.

Constructs and examples

-- 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))
}.

Generated definitions

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.)

Tips and tricks

  • Given a falsehood void: βˆ€ X: β˜…. X, any term that erases to t can be assigned any type X by
    Ο† (void Β·{void ≃ t}) - (void Β·X) {|t|}.
  • Given t: T, u: P t, and p: {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 index i, the deconstruction C i' a for constructor C with argument a does not definitionally equate i to i'. 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>.

Erasures

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β€–

Typing rules

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]
⚠️ **GitHub.com Fallback** ⚠️