-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hedberg #245
Merged
Hedberg #245
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
13c726f
more efficient connections
ecavallo fa0d2b0
basic n-type file
ecavallo 24840ed
void and unit
ecavallo efc5376
finish proof of hedberg
ecavallo f506dff
file for or
ecavallo f11441c
prove nat is a set with hedberg
ecavallo 2aea3ce
prove int is a set with hedberg
ecavallo 1949af0
folder for examples
ecavallo 250e202
prove unit & void are props
ecavallo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to consider if you take partial elements seriously would be to allow sharing of branches in systems. That way the two last cases could be written:
This happens quite often and it might help with memory consumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be so cool! Let's talk about it at dagstuhl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i see how to make that work...