-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* more efficient connections * basic n-type file * void and unit * finish proof of hedberg * file for or * prove nat is a set with hedberg * prove int is a set with hedberg * folder for examples * prove unit & void are props
- Loading branch information
Showing
23 changed files
with
366 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
OPAM=opam | ||
EXEC=${OPAM} config exec | ||
DUNE=${EXEC} dune -- | ||
|
||
all: | ||
${DUNE} exec -- redtt load-file nat.red | ||
${DUNE} exec -- redtt load-file int.red | ||
${DUNE} exec -- redtt load-file bool.red | ||
${DUNE} exec -- redtt load-file omega1s1-wip.red | ||
${DUNE} exec -- redtt load-file torus.red | ||
${DUNE} exec -- redtt load-file modal.red | ||
${DUNE} exec -- redtt load-file isotoequiv.red | ||
${DUNE} exec -- redtt load-file invariance.red | ||
${DUNE} exec -- redtt load-file univalence.red |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import void | ||
import bool | ||
import or | ||
import connection | ||
import ntype | ||
|
||
let stable (A : type) : type = | ||
(neg (neg A)) → A | ||
|
||
let dec (A : type) : type = | ||
or A (neg A) | ||
|
||
let discrete (A : type) : type = | ||
(x,y : A) → dec (Path A x y) | ||
|
||
let dec/to/stable (A : type) (d : dec A) : stable A = | ||
or/elim A (neg A) (stable A) d | ||
(λ a _ → a) | ||
(λ x y → elim (y x) []) | ||
|
||
let neg/is-prop-over (A : dim → type) | ||
: IsPropOver (λ i → neg (A i)) | ||
= | ||
λ c c' i a → | ||
let f : [j] ((A j) → void) [ j=0 ⇒ c | j=1 ⇒ c' ] = | ||
elim (c (coe i 0 a in A)) [] | ||
in | ||
f i a | ||
|
||
; Hedberg's theorem for stable path types | ||
let paths-stable/to/set (A : type) | ||
(st : (x,y : A) → stable (Path A x y)) | ||
: IsSet A | ||
= | ||
λ a b p q i j → | ||
let square : dim → dim → A = | ||
λ k m → | ||
comp 0 k a [ | ||
| m=0 ⇒ p | ||
| m=1 ⇒ q | ||
] | ||
in | ||
let cap : dim → dim → A = | ||
λ k m → st (p k) (q k) (λ c → c (square k)) m | ||
in | ||
comp 0 1 (cap j i) [ | ||
| i=0 ⇒ λ k → | ||
st (p j) (p j) | ||
(neg/is-prop-over (λ j → neg (Path A (p j) (p j))) | ||
(λ c → c (square 0)) | ||
(λ c → c (square 1)) | ||
j) | ||
k | ||
| i=1 ⇒ λ _ → q j | ||
| j=0 ⇒ λ k → connection/or A (cap 0) i k | ||
| j=1 ⇒ λ k → connection/or A (cap 1) i k | ||
] | ||
|
||
; Hedberg's theorem for decidable path types | ||
let discrete/to/set (A : type) (d : discrete A) | ||
: IsSet A | ||
= | ||
paths-stable/to/set A (λ x y → dec/to/stable (Path A x y) (d x y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import path | ||
import void | ||
import unit | ||
import nat | ||
import equivalence | ||
import isotoequiv | ||
|
||
data int where | ||
| pos [n : nat] | ||
| negsuc [n : nat] | ||
|
||
let pred (x : int) : int = | ||
elim x [ | ||
| pos n ⇒ | ||
elim n [ | ||
| zero ⇒ negsuc zero | ||
| suc n ⇒ pos n | ||
] | ||
| negsuc n ⇒ negsuc (suc n) | ||
] | ||
|
||
let isuc (x : int) : int = | ||
elim x [ | ||
| pos n ⇒ pos (suc n) | ||
| negsuc n ⇒ | ||
elim n [ | ||
| zero ⇒ pos zero | ||
| suc n ⇒ negsuc n | ||
] | ||
] | ||
|
||
|
||
let pred-isuc (n : int) : Path int (pred (isuc n)) n = | ||
elim n [ | ||
| pos n ⇒ auto | ||
| negsuc n ⇒ | ||
elim n [ | ||
| zero ⇒ auto | ||
| suc n ⇒ auto | ||
] | ||
] | ||
|
||
let isuc-pred (n : int) : Path int (isuc (pred n)) n = | ||
elim n [ | ||
| pos n ⇒ | ||
elim n [ | ||
| zero ⇒ auto | ||
| suc n' ⇒ auto | ||
] | ||
| negsuc n ⇒ auto | ||
] | ||
|
||
let isuc-equiv : Equiv int int = | ||
Iso/Equiv _ _ <isuc, <pred, <isuc-pred, pred-isuc>>> | ||
|
||
let IntPathCode (x : int) : int → type = | ||
elim x [ | ||
| pos m ⇒ λ y → | ||
elim y [ | ||
| pos n ⇒ NatPathCode m n | ||
| negsuc _ ⇒ void | ||
] | ||
| negsuc m ⇒ λ y → | ||
elim y [ | ||
| pos _ ⇒ void | ||
| negsuc n ⇒ NatPathCode m n | ||
] | ||
] | ||
|
||
let int-refl (x : int) : IntPathCode x x = | ||
elim x [ | ||
| pos m ⇒ nat-refl m | ||
| negsuc m ⇒ nat-refl m | ||
] | ||
|
||
let int-path/encode (x,y : int) (p : Path int x y) | ||
: IntPathCode x y | ||
= | ||
coe 0 1 (int-refl x) in λ i → IntPathCode x (p i) | ||
|
||
let int-repr (x : int) : nat = | ||
elim x [ pos m ⇒ m | negsuc m ⇒ m ] | ||
|
||
let int/discrete : discrete int = | ||
λ x → | ||
elim x [ | ||
| pos m ⇒ λ y → | ||
elim y [ | ||
| pos n ⇒ | ||
or/elim (Path nat m n) (neg (Path nat m n)) | ||
(or (Path int (pos m) (pos n)) (neg (Path int (pos m) (pos n)))) | ||
(nat/discrete m n) | ||
(λ l → <tt, λ i → pos (l i)>) | ||
(λ r → <ff, λ p → r (λ i → int-repr (p i))>) | ||
| negsuc n ⇒ <ff, int-path/encode _ _> | ||
] | ||
| negsuc m ⇒ λ y → | ||
elim y [ | ||
| pos n ⇒ <ff, int-path/encode _ _> | ||
| negsuc n ⇒ | ||
or/elim (Path nat m n) (neg (Path nat m n)) | ||
(or (Path int (negsuc m) (negsuc n)) (neg (Path int (negsuc m) (negsuc n)))) | ||
(nat/discrete m n) | ||
(λ l → <tt, λ i → negsuc (l i)>) | ||
(λ r → <ff, λ p → r (λ i → int-repr (p i))>) | ||
] | ||
] | ||
|
||
let int/set : IsSet int = | ||
discrete/to/set int int/discrete |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import path | ||
import void | ||
import unit | ||
import hedberg | ||
|
||
data nat where | ||
| zero | ||
| suc (x : nat) | ||
|
||
let nat-pred (x : nat) : nat = | ||
elim x [ | ||
| zero ⇒ zero | ||
| suc n ⇒ n | ||
] | ||
|
||
|
||
let nat-pred/suc (x : nat) : Path nat x (nat-pred (suc x)) = | ||
auto | ||
|
||
let plus : nat → nat → nat = | ||
λ m n → | ||
elim m [ | ||
| zero ⇒ n | ||
| suc (m ⇒ plus/m/n) ⇒ suc plus/m/n | ||
] | ||
|
||
let plus/unit/l (n : nat) : Path nat (plus zero n) n = | ||
auto | ||
|
||
let plus/unit/r (n : nat) : Path nat (plus n zero) n = | ||
elim n [ | ||
| zero ⇒ auto | ||
| suc (n ⇒ path/n) ⇒ λ i → suc (path/n i) | ||
] | ||
|
||
let plus/assoc (n : nat) : (m, o : nat) → Path nat (plus n (plus m o)) (plus (plus n m) o) = | ||
elim n [ | ||
| zero ⇒ auto | ||
| suc (n ⇒ plus/assoc/n) ⇒ λ m o i → suc (plus/assoc/n m o i) | ||
] | ||
|
||
let plus/suc/r (n : nat) : (m : nat) → Path nat (plus n (suc m)) (suc (plus n m)) = | ||
elim n [ | ||
| zero ⇒ auto | ||
| suc (n ⇒ plus/n/suc/r) ⇒ λ m i → suc (plus/n/suc/r m i) | ||
] | ||
|
||
|
||
let plus/comm (m : nat) : (n : nat) → Path nat (plus n m) (plus m n) = | ||
elim m [ | ||
| zero ⇒ plus/unit/r | ||
| suc (m ⇒ plus/comm/m) ⇒ λ n → trans _ (plus/suc/r n m) (λ i → suc (plus/comm/m n i)) | ||
] | ||
|
||
let NatPathCode (m : nat) : nat → type = | ||
elim m [ | ||
| zero ⇒ λ n → | ||
elim n [ | ||
| zero ⇒ unit | ||
| suc _ ⇒ void | ||
] | ||
| suc (m' ⇒ Code/m') ⇒ λ n → | ||
elim n [ | ||
| zero ⇒ void | ||
| suc n' ⇒ Code/m' n' | ||
] | ||
] | ||
|
||
let nat-refl (m : nat) : NatPathCode m m = | ||
elim m [ | ||
| zero ⇒ triv | ||
| suc (m' ⇒ nat-refl/m') ⇒ nat-refl/m' | ||
] | ||
|
||
let nat-path/encode (m,n : nat) (p : Path nat m n) | ||
: NatPathCode m n | ||
= | ||
coe 0 1 (nat-refl m) in λ i → NatPathCode m (p i) | ||
|
||
let nat/discrete : discrete nat = | ||
λ m → | ||
elim m [ | ||
| zero ⇒ λ n → | ||
elim n [ | ||
| zero ⇒ <tt, λ _ → zero> | ||
| suc n' ⇒ <ff, nat-path/encode zero (suc n')> | ||
] | ||
| suc (m' ⇒ nat/discrete/m') ⇒ λ n → | ||
elim n [ | ||
| zero ⇒ <ff, nat-path/encode (suc m') zero> | ||
| suc n' ⇒ | ||
or/elim (Path nat m' n') (neg (Path nat m' n')) | ||
(or (Path nat (suc m') (suc n')) (neg (Path nat (suc m') (suc n')))) | ||
(nat/discrete/m' n') | ||
(λ l → <tt, λ i → suc (l i)>) | ||
(λ r → <ff, λ p → r (λ i → nat-pred (p i))>) | ||
] | ||
] | ||
|
||
let nat/set : IsSet nat = | ||
discrete/to/set nat nat/discrete |
Oops, something went wrong.