feat(hott/nat): add characterization of equality in nat

This commit is contained in:
Floris van Doorn 2015-08-06 17:52:49 +02:00 committed by Leonardo de Moura
parent 189293b5d4
commit 3d2a6a08a4
2 changed files with 36 additions and 6 deletions

View file

@ -16,7 +16,7 @@ The rows indicate the chapters, the columns the sections.
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|-------|---|---|---|---|---|---|---|---|---|----|----|----|----|----|----| |-------|---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|
| Ch 1 | . | . | . | . | + | + | + | + | + | . | + | + | | | | | Ch 1 | . | . | . | . | + | + | + | + | + | . | + | + | | | |
| Ch 2 | + | + | + | + | . | + | + | + | + | + | + | - | - | + | + | | Ch 2 | + | + | + | + | . | + | + | + | + | + | + | - | + | + | + |
| Ch 3 | + | - | + | + | ½ | + | + | - | ½ | . | + | | | | | | Ch 3 | + | - | + | + | ½ | + | + | - | ½ | . | + | | | | |
| Ch 4 | - | + | - | + | . | + | - | - | + | | | | | | | | Ch 4 | - | + | - | + | . | + | - | - | + | | | | | | |
| Ch 5 | - | . | - | - | - | . | . | ½ | | | | | | | | | Ch 5 | - | . | - | - | - | . | . | ½ | | | | | | | |
@ -62,7 +62,7 @@ Chapter 2: Homotopy type theory
- 2.10 (Universes and the univalence axiom): [init.ua](init/ua.hlean) - 2.10 (Universes and the univalence axiom): [init.ua](init/ua.hlean)
- 2.11 (Identity type): [init.equiv](init/equiv.hlean) (ap is equivalence), [types.eq](types/eq.hlean) and [types.cubical.square](types/cubical/square.hlean) (characterization of pathovers in equality types) - 2.11 (Identity type): [init.equiv](init/equiv.hlean) (ap is equivalence), [types.eq](types/eq.hlean) and [types.cubical.square](types/cubical/square.hlean) (characterization of pathovers in equality types)
- 2.12 (Coproducts): not formalized - 2.12 (Coproducts): not formalized
- 2.13 (Natural numbers): not formalized - 2.13 (Natural numbers): [types.nat.hott](types/nat/hott.hlean)
- 2.14 (Example: equality of structures): algebra formalized in [algebra.group](algebra/group.hlean). - 2.14 (Example: equality of structures): algebra formalized in [algebra.group](algebra/group.hlean).
- 2.15 (Universal properties): in the corresponding file in the [types](types/types.md) folder. - 2.15 (Universal properties): in the corresponding file in the [types](types/types.md) folder.

View file

@ -30,10 +30,6 @@ namespace nat
definition le_succ_equiv_pred_le (n m : ) : (n ≤ succ m) ≃ (pred n ≤ m) := definition le_succ_equiv_pred_le (n m : ) : (n ≤ succ m) ≃ (pred n ≤ m) :=
equiv_of_is_hprop pred_le_pred le_succ_of_pred_le equiv_of_is_hprop pred_le_pred le_succ_of_pred_le
set_option pp.beta false
set_option pp.implicit true
set_option pp.coercions true
theorem lt_by_cases_lt {a b : } {P : Type} (H1 : a < b → P) (H2 : a = b → P) theorem lt_by_cases_lt {a b : } {P : Type} (H1 : a < b → P) (H2 : a = b → P)
(H3 : a > b → P) (H : a < b) : lt.by_cases H1 H2 H3 = H1 H := (H3 : a > b → P) (H : a < b) : lt.by_cases H1 H2 H3 = H1 H :=
begin begin
@ -81,4 +77,38 @@ namespace nat
exfalso, apply lt.irrefl, apply lt_of_le_of_lt H H'} exfalso, apply lt.irrefl, apply lt_of_le_of_lt H H'}
end end
definition code [reducible] [unfold 1 2] : → Type₀
| code 0 0 := unit
| code (succ n) 0 := empty
| code 0 (succ m) := empty
| code (succ n) (succ m) := code n m
definition refl : Πn, code n n
| refl 0 := star
| refl (succ n) := refl n
definition encode [unfold 3] {n m : } (p : n = m) : code n m :=
p ▸ refl n
definition decode : Π(n m : ), code n m → n = m
| decode 0 0 := λc, idp
| decode 0 (succ l) := λc, empty.elim c _
| decode (succ k) 0 := λc, empty.elim c _
| decode (succ k) (succ l) := λc, ap succ (decode k l c)
definition nat_eq_equiv (n m : ) : (n = m) ≃ code n m :=
equiv.MK encode
!decode
begin
revert m, induction n, all_goals (intro m;induction m;all_goals intro c),
all_goals try contradiction,
induction c, reflexivity,
xrewrite [↑decode,-tr_compose,v_0],
end
begin
intro p, induction p, esimp, induction n,
reflexivity,
rewrite [↑decode,↑refl,v_0]
end
end nat end nat