|
|
@ -141,18 +141,29 @@ funext h i x = h x i |
|
|
|
-- The proposition associated with an element of the interval |
|
|
|
------------------------------------------------------------- |
|
|
|
|
|
|
|
Eq_s : {A : Pretype} -> A -> A -> Pretype |
|
|
|
{-# PRIMITIVE Eq_s #-} |
|
|
|
|
|
|
|
refl_s : {A : Pretype} {x : A} -> Eq_s x x |
|
|
|
{-# PRIMITIVE refl_s #-} |
|
|
|
|
|
|
|
J_s : {A : Pretype} {x : A} (P : (y : A) -> Eq_s x y -> Pretype) -> P x (refl_s {A} {x}) -> {y : A} -> (p : Eq_s x y) -> P y p |
|
|
|
{-# PRIMITIVE J_s #-} |
|
|
|
|
|
|
|
K_s : {A : Pretype} {x : A} (P : Eq_s x x -> Pretype) -> P (refl_s {A} {x}) -> (p : Eq_s x x) -> P p |
|
|
|
{-# PRIMITIVE K_s #-} |
|
|
|
|
|
|
|
-- Associated with every element i : I of the interval, we have the type |
|
|
|
-- IsOne i which is inhabited only when i = i1. In the model, this |
|
|
|
-- corresponds to the map [φ] from the interval cubical set to the |
|
|
|
-- subobject classifier. |
|
|
|
|
|
|
|
IsOne : I -> Pretype |
|
|
|
{-# PRIMITIVE IsOne #-} |
|
|
|
IsOne i = Eq_s i i1 |
|
|
|
|
|
|
|
-- The value itIs1 witnesses the fact that i1 = i1. |
|
|
|
itIs1 : IsOne i1 |
|
|
|
|
|
|
|
{-# PRIMITIVE itIs1 #-} |
|
|
|
itIs1 = refl_s |
|
|
|
|
|
|
|
-- Partial elements |
|
|
|
------------------- |
|
|
@ -212,8 +223,11 @@ outS : {A : Type} {phi : I} {u : Partial phi A} -> Sub A phi u -> A |
|
|
|
-- and specifying that an element agrees with a partial cube, |
|
|
|
-- we can describe the composition operation. |
|
|
|
|
|
|
|
primComp : (A : I -> Type) {phi : I} (u : (i : I) -> Partial phi (A i)) -> Sub (A i0) phi (u i0) -> Sub (A i1) phi (u i1) |
|
|
|
{-# PRIMITIVE comp primComp #-} |
|
|
|
|
|
|
|
comp : (A : I -> Type) {phi : I} (u : (i : I) -> Partial phi (A i)) -> Sub (A i0) phi (u i0) -> A i1 |
|
|
|
{-# PRIMITIVE comp #-} |
|
|
|
comp A {phi} u a0 = outS (primComp A {phi} u a0) |
|
|
|
|
|
|
|
-- In particular, when φ is a disjunction of the form |
|
|
|
-- (j = 0) || (j = 1), we can draw u as being a pair of lines forming a |
|
|
@ -259,7 +273,7 @@ transp A x = comp A {i0} (\i [ ]) (inS x) |
|
|
|
-- Since we have the iand operator, we can also derive the *filler* of a cube, |
|
|
|
-- which connects the given face and the output of composition. |
|
|
|
|
|
|
|
fill : (A : I -> Type) {phi : I} (u : (i : I) -> Partial phi (A i)) -> Sub (A i0) phi (u i0) -> (i : I) -> A i |
|
|
|
fill : (A : I -> Type) {phi : I} (u : (i : I) -> Partial phi (A i)) (a0 : Sub (A i0) phi (u i0)) -> PathP A (outS a0) (comp A {phi} u a0) |
|
|
|
fill A {phi} u a0 i = |
|
|
|
comp (\j -> A (iand i j)) |
|
|
|
{ior phi (inot i)} |
|
|
@ -269,7 +283,7 @@ fill A {phi} u a0 i = |
|
|
|
hcomp : {A : Type} {phi : I} (u : (i : I) -> Partial phi A) -> Sub A phi (u i0) -> A |
|
|
|
hcomp {A} {phi} u a0 = comp (\i -> A) {phi} u a0 |
|
|
|
|
|
|
|
hfill : {A : Type} {phi : I} (u : (i : I) -> Partial phi A) -> (a0 : Sub A phi (u i0)) -> I -> A |
|
|
|
hfill : {A : Type} {phi : I} (u : (i : I) -> Partial phi A) -> (a0 : Sub A phi (u i0)) -> Path (outS a0) (hcomp u a0) |
|
|
|
hfill {A} {phi} u a0 i = fill (\i -> A) {phi} u a0 i |
|
|
|
|
|
|
|
-- For instance, the filler of the previous composition square |
|
|
@ -278,8 +292,8 @@ hfill {A} {phi} u a0 i = fill (\i -> A) {phi} u a0 i |
|
|
|
transRefl : {A : Type} {x : A} {y : A} (p : Path x y) -> Path (trans p refl) p |
|
|
|
transRefl p j i = fill (\i -> A) {ior i (inot i)} (\k [ (i = i0) -> x, (i = i1) -> y ]) (inS (p i)) (inot j) |
|
|
|
|
|
|
|
transpFill : {A : Type} (x : A) -> Path x (transp (\i -> A) x) |
|
|
|
transpFill {A} x i = fill (\i -> A) (\k []) (inS x) i |
|
|
|
transpFill : {A : I -> Type} (x : A i0) -> PathP A x (transp (\i -> A i) x) |
|
|
|
transpFill {A} x i = fill (\i -> A i) (\k []) (inS x) i |
|
|
|
|
|
|
|
-- Reduction of composition |
|
|
|
--------------------------- |
|
|
@ -315,7 +329,7 @@ transpDFun f = refl |
|
|
|
-- path f(x) = y. |
|
|
|
|
|
|
|
fiber : {A : Type} {B : Type} -> (A -> B) -> B -> Type |
|
|
|
fiber f y = (x : A) * Path (f x) y |
|
|
|
fiber f y = (x : A) * Path y (f x) |
|
|
|
|
|
|
|
-- An *equivalence* is a function where every fiber is contractible. |
|
|
|
-- That is, for every point in the codomain y : B, there is exactly one |
|
|
@ -327,13 +341,11 @@ isEquiv {A} {B} f = (y : B) -> isContr (fiber {A} {B} f y) |
|
|
|
-- By extracting this point, which must exist because the fiber is contractible, |
|
|
|
-- we can get an inverse of f: |
|
|
|
|
|
|
|
inverse : {A : Type} {B : Type} {f : A -> B} -> isEquiv f -> B -> A |
|
|
|
inverse eqv y = (eqv y) .1 .1 |
|
|
|
invert : {A : Type} {B : Type} {f : A -> B} -> isEquiv f -> B -> A |
|
|
|
invert eqv y = (eqv y) .1 .1 |
|
|
|
|
|
|
|
-- We can prove that «inverse eqv» is a section of f: |
|
|
|
|
|
|
|
section : {A : Type} {B : Type} (f : A -> B) (eqv : isEquiv f) -> Path (\x -> f (inverse eqv x)) id |
|
|
|
section f eqv i y = (eqv y) .1 .2 i |
|
|
|
retract : {A : Type} {B : Type} -> (A -> B) -> (B -> A) -> Type |
|
|
|
retract {A} {B} f g = (a : A) -> Path (g (f a)) a |
|
|
|
|
|
|
|
contr : {A : Type} {phi : I} -> isContr A -> (u : Partial phi A) -> A |
|
|
|
contr {A} {phi} p u = comp (\i -> A) {phi} (\i is1 -> p.2 (u is1) i) (inS (p.1)) |
|
|
@ -348,7 +360,7 @@ Equiv A B = (f : A -> B) * isEquiv {A} {B} f |
|
|
|
-- The identity function is an equivalence between any type A and |
|
|
|
-- itself. |
|
|
|
idEquiv : {A : Type} -> isEquiv (id {A}) |
|
|
|
idEquiv y = ((y, \i -> y), \u i -> (u.2 (inot i), \j -> u.2 (ior (inot i) j))) |
|
|
|
idEquiv y = ((y, \i -> y), \u i -> (u.2 i, \j -> u.2 (iand i j))) |
|
|
|
|
|
|
|
-- The glue operation expresses that "extensibility is invariant under |
|
|
|
-- equivalence". Less concisely, the Glue type and its constructor, |
|
|
@ -377,6 +389,12 @@ prim'glue : {A : Type} {phi : I} {T : Partial phi Type} {e : PartialP phi (\o -> |
|
|
|
|
|
|
|
{-# PRIMITIVE glue prim'glue #-} |
|
|
|
|
|
|
|
glue : {A : Type} {phi : I} {Te : Partial phi ((T : Type) * Equiv T A)} |
|
|
|
-> (t : PartialP phi (\o -> (Te o).1)) |
|
|
|
-> (im : Sub A phi (\o -> (Te o).2.1 (t o))) |
|
|
|
-> primGlue A {phi} (\o -> (Te o).1) (\o -> (Te o).2) |
|
|
|
glue {A} {phi} {Te} t im = prim'glue {A} {phi} {\o -> (Te o).1} {\o -> (Te o).2} t im |
|
|
|
|
|
|
|
-- The unglue operation undoes a glueing. Since when φ = i1, |
|
|
|
-- Glue A [φ -> (T, f)] = T, the argument to primUnglue {A} {i1} ... |
|
|
|
-- will have type T, and so to get back an A we need to apply the |
|
|
@ -387,6 +405,10 @@ primUnglue : {A : Type} {phi : I} {T : Partial phi Type} {e : PartialP phi (\o - |
|
|
|
|
|
|
|
{-# PRIMITIVE unglue primUnglue #-} |
|
|
|
|
|
|
|
unglue : {A : Type} (phi : I) {Te : Partial phi ((T : Type) * Equiv T A)} |
|
|
|
-> primGlue A {phi} (\o -> (Te o).1) (\o -> (Te o).2) -> A |
|
|
|
unglue {A} phi {Te} = primUnglue {A} {phi} {\o -> (Te o).1} {\o -> (Te o).2} |
|
|
|
|
|
|
|
-- Diagramatically, i : I |- Glue A [(i \/ ~i) -> (T, e)] can be drawn |
|
|
|
-- as giving us the dotted line in: |
|
|
|
-- |
|
|
@ -425,6 +447,11 @@ univalence {A} {B} equiv i = |
|
|
|
Glue B (\[ (i = i0) -> (A, equiv), |
|
|
|
(i = i1) -> (B, the B, idEquiv {B}) ]) |
|
|
|
|
|
|
|
lineToEquiv : (A : I -> Type) -> Equiv (A i0) (A i1) |
|
|
|
{-# PRIMITIVE lineToEquiv #-} |
|
|
|
|
|
|
|
idToEquiv : {A : Type} {B : Type} -> Path A B -> Equiv A B |
|
|
|
idToEquiv p = lineToEquiv (\i -> p i) |
|
|
|
|
|
|
|
-- The fact that this diagram has 2 filled-in B sides explains the |
|
|
|
-- complication in the proof below. |
|
|
@ -517,15 +544,15 @@ IsoToEquiv {A} {B} iso = (f, \y -> (fCenter y, fIsCenter y)) where |
|
|
|
s = iso.2.2.1 |
|
|
|
t = iso.2.2.2 |
|
|
|
|
|
|
|
lemIso : (y : B) (x0 : A) (x1 : A) (p0 : Path (f x0) y) (p1 : Path (f x1) y) |
|
|
|
lemIso : (y : B) (x0 : A) (x1 : A) (p0 : Path y (f x0)) (p1 : Path y (f x1)) |
|
|
|
-> PathP (\i -> fiber f y) (x0, p0) (x1, p1) |
|
|
|
lemIso y x0 x1 p0 p1 = |
|
|
|
let |
|
|
|
rem0 : Path x0 (g y) |
|
|
|
rem0 i = comp (\i -> A) (\k [ (i = i0) -> t x0 k, (i = i1) -> g y ]) (inS (g (p0 i))) |
|
|
|
rem0 i = comp (\i -> A) (\k [ (i = i0) -> t x0 k, (i = i1) -> g y ]) (inS (g (p0 (inot i)))) |
|
|
|
|
|
|
|
rem1 : Path x1 (g y) |
|
|
|
rem1 i = comp (\i -> A) (\k [ (i = i0) -> t x1 k, (i = i1) -> g y ]) (inS (g (p1 i))) |
|
|
|
rem1 i = comp (\i -> A) (\k [ (i = i0) -> t x1 k, (i = i1) -> g y ]) (inS (g (p1 (inot i)))) |
|
|
|
|
|
|
|
p : Path x0 x1 |
|
|
|
p i = comp (\i -> A) (\k [ (i = i0) -> rem0 (inot k), (i = i1) -> rem1 (inot k) ]) (inS (g y)) |
|
|
@ -533,15 +560,15 @@ IsoToEquiv {A} {B} iso = (f, \y -> (fCenter y, fIsCenter y)) where |
|
|
|
fill0 : I -> I -> A |
|
|
|
fill0 i j = comp (\i -> A) (\k [ (i = i0) -> t x0 (iand j k) |
|
|
|
, (i = i1) -> g y |
|
|
|
, (j = i0) -> g (p0 i) |
|
|
|
, (j = i0) -> g (p0 (inot i)) |
|
|
|
]) |
|
|
|
(inS (g (p0 i))) |
|
|
|
(inS (g (p0 (inot i)))) |
|
|
|
|
|
|
|
fill1 : I -> I -> A |
|
|
|
fill1 i j = comp (\i -> A) (\k [ (i = i0) -> t x1 (iand j k) |
|
|
|
, (i = i1) -> g y |
|
|
|
, (j = i0) -> g (p1 i) ]) |
|
|
|
(inS (g (p1 i))) |
|
|
|
, (j = i0) -> g (p1 (inot i)) ]) |
|
|
|
(inS (g (p1 (inot i)))) |
|
|
|
|
|
|
|
fill2 : I -> I -> A |
|
|
|
fill2 i j = comp (\i -> A) (\k [ (i = i0) -> rem0 (ior j (inot k)) |
|
|
@ -557,16 +584,16 @@ IsoToEquiv {A} {B} iso = (f, \y -> (fCenter y, fIsCenter y)) where |
|
|
|
(inS (fill2 i j)) |
|
|
|
|
|
|
|
sq1 : I -> I -> B |
|
|
|
sq1 i j = comp (\i -> B) (\k [ (i = i0) -> s (p0 j) k |
|
|
|
, (i = i1) -> s (p1 j) k |
|
|
|
sq1 i j = comp (\i -> B) (\k [ (i = i0) -> s (p0 (inot j)) k |
|
|
|
, (i = i1) -> s (p1 (inot j)) k |
|
|
|
, (j = i0) -> s (f (p i)) k |
|
|
|
, (j = i1) -> s y k |
|
|
|
]) |
|
|
|
(inS (f (sq i j))) |
|
|
|
in \i -> (p i, \j -> sq1 i j) |
|
|
|
in \i -> (p i, \j -> sq1 i (inot j)) |
|
|
|
|
|
|
|
fCenter : (y : B) -> fiber f y |
|
|
|
fCenter y = (g y, s y) |
|
|
|
fCenter y = (g y, sym (s y)) |
|
|
|
|
|
|
|
fIsCenter : (y : B) (w : fiber f y) -> Path (fCenter y) w |
|
|
|
fIsCenter y w = lemIso y (fCenter y).1 w.1 (fCenter y).2 w.2 |
|
|
@ -653,8 +680,12 @@ trueNotFalse p = transp (\i -> if (Bool -> Bool) Bottom (p i)) id |
|
|
|
-- |
|
|
|
-- isHSet A = (x : A) (y : A) -> isHProp (Path x y) |
|
|
|
-- |
|
|
|
|
|
|
|
isProp : Type -> Type |
|
|
|
isProp A = (x : A) (y : A) -> Path x y |
|
|
|
|
|
|
|
isHSet : Type -> Type |
|
|
|
isHSet A = {x : A} {y : A} (p : Path x y) (q : Path x y) -> Path p q |
|
|
|
isHSet A = (x : A) (y : A) -> isProp (Path x y) |
|
|
|
|
|
|
|
-- We can prove *a* contradiction (note: this is a direct proof!) by adversarially |
|
|
|
-- choosing two paths p, q that we know are not equal. Since "equal" paths have |
|
|
@ -665,7 +696,7 @@ isHSet A = {x : A} {y : A} (p : Path x y) (q : Path x y) -> Path p q |
|
|
|
-- of false as the point x is just from the endpoints of trueNotFalse. |
|
|
|
|
|
|
|
universeNotSet : isHSet Type -> Bottom |
|
|
|
universeNotSet itIs = trueNotFalse (\i -> transp (\j -> itIs notp refl i j) false) |
|
|
|
universeNotSet itIs = trueNotFalse (\i -> transp (\j -> itIs Bool Bool notp refl i j) false) |
|
|
|
|
|
|
|
-- Funext is an inverse of happly |
|
|
|
--------------------------------- |
|
|
@ -1048,9 +1079,6 @@ four = multInt two two |
|
|
|
sixteen : Int |
|
|
|
sixteen = multInt four four |
|
|
|
|
|
|
|
isProp : Type -> Type |
|
|
|
isProp A = (x : A) (y : A) -> Path x y |
|
|
|
|
|
|
|
Prop : Type |
|
|
|
Prop = (A : Type) * isProp A |
|
|
|
|
|
|
@ -1059,7 +1087,7 @@ data Sq (A : Type) : Type where |
|
|
|
sq i : (x : Sq A) (y : Sq A) -> Sq A [ (i = i0) -> x, (i = i1) -> y ] |
|
|
|
|
|
|
|
isProp_isSet : {A : Type} -> isProp A -> isHSet A |
|
|
|
isProp_isSet h {a} {b} p q j i = |
|
|
|
isProp_isSet h a b p q j i = |
|
|
|
hcomp {A} |
|
|
|
(\k [ (i = i0) -> h a a k |
|
|
|
, (i = i1) -> h a b k |
|
|
@ -1069,7 +1097,7 @@ isProp_isSet h {a} {b} p q j i = |
|
|
|
(inS a) |
|
|
|
|
|
|
|
isProp_isProp : {A : Type} -> isProp (isProp A) |
|
|
|
isProp_isProp f g i a b = isProp_isSet f {a} {b} (f a b) (g a b) i |
|
|
|
isProp_isProp f g i a b = isProp_isSet f a b (f a b) (g a b) i |
|
|
|
|
|
|
|
Sq_rec : {A : Type} {B : Type} |
|
|
|
-> isProp B |
|
|
@ -1161,15 +1189,6 @@ S3IsSuspS2 = univalence (IsoToEquiv iso) where |
|
|
|
iso : Iso S3 (Susp S2) |
|
|
|
iso = (fromS3, toS3, fromToS3, toFromS3) |
|
|
|
|
|
|
|
Eq_s : {A : Pretype} -> A -> A -> Pretype |
|
|
|
{-# PRIMITIVE Eq_s #-} |
|
|
|
|
|
|
|
refl_s : {A : Pretype} {x : A} -> Eq_s x x |
|
|
|
{-# PRIMITIVE refl_s #-} |
|
|
|
|
|
|
|
J_s : {A : Pretype} {x : A} (P : (y : A) -> Eq_s x y -> Pretype) -> P x (refl_s {A} {x}) -> {y : A} -> (p : Eq_s x y) -> P y p |
|
|
|
{-# PRIMITIVE J_s #-} |
|
|
|
|
|
|
|
ap_s : {A : Pretype} {B : Pretype} (f : A -> B) {x : A} {y : A} -> Eq_s x y -> Eq_s (f x) (f y) |
|
|
|
ap_s {A} {B} f {x} {y} = J_s (\y p -> Eq_s (f x) (f y)) refl_s |
|
|
|
|
|
|
@ -1179,9 +1198,6 @@ subst_s {A} P {x} {z} p px = J_s {A} {x} (\y p -> P x -> P y) id p px |
|
|
|
sym_s : {A : Pretype} {x : A} {y : A} -> Eq_s x y -> Eq_s y x |
|
|
|
sym_s {A} {x} {y} = J_s {A} {x} (\y p -> Eq_s y x) refl_s |
|
|
|
|
|
|
|
K_s : {A : Pretype} {x : A} (P : Eq_s x x -> Pretype) -> P (refl_s {A} {x}) -> (p : Eq_s x x) -> P p |
|
|
|
{-# PRIMITIVE K_s #-} |
|
|
|
|
|
|
|
UIP : {A : Pretype} {x : A} {y : A} (p : Eq_s x y) (q : Eq_s x y) -> Eq_s p q |
|
|
|
UIP {A} {x} {y} p q = J_s (\y p -> (q : Eq_s x y) -> Eq_s p q) (uipRefl A x) p q where |
|
|
|
uipRefl : (A : Pretype) (x : A) (p : Eq_s x x) -> Eq_s refl_s p |
|
|
@ -1217,11 +1233,35 @@ pathToEqS_K {A} {x} p_to_s P pr loop = transp (\i -> P (inv x loop i)) psloop wh |
|
|
|
aux = seq_pathRefl (p_to_s (\i -> x)) |
|
|
|
|
|
|
|
pathToEq_isSet : {A : Type} -> ({x : A} {y : A} -> Path x y -> Eq_s x y) -> isHSet A |
|
|
|
pathToEq_isSet {A} p_to_s {x} {y} p q = axK_to_isSet {A} (\{x} -> pathToEqS_K {A} {x} p_to_s) {x} {y} p q where |
|
|
|
pathToEq_isSet {A} p_to_s = axK_to_isSet {A} (\{x} -> pathToEqS_K {A} {x} p_to_s) where |
|
|
|
axK_to_isSet : {A : Type} -> ({x : A} -> (P : Path x x -> Type) -> P refl -> (p : Path x x) -> P p) -> isHSet A |
|
|
|
axK_to_isSet K {x} {y} p q = J (\y p -> (q : Path x y) -> Path p q) (uipRefl x) p q where |
|
|
|
axK_to_isSet K x y p q = J (\y p -> (q : Path x y) -> Path p q) (uipRefl x) p q where |
|
|
|
uipRefl : (x : A) (p : Path x x) -> Path refl p |
|
|
|
uipRefl x p = K {x} (\q -> Path refl q) refl p |
|
|
|
|
|
|
|
Nat_isSet : isHSet Nat |
|
|
|
Nat_isSet {x} {y} = pathToEq_isSet {Nat} (\{x} {y} -> Path_nat_strict_nat x y) {x} {y} |
|
|
|
Nat_isSet = pathToEq_isSet {Nat} (\{x} {y} -> Path_nat_strict_nat x y) |
|
|
|
|
|
|
|
equivCtr : {A : Type} {B : Type} (e : Equiv A B) (y : B) -> fiber e.1 y |
|
|
|
equivCtr e y = (e.2 y).1 |
|
|
|
|
|
|
|
equivCtrPath : {A : Type} {B : Type} (e : Equiv A B) (y : B) |
|
|
|
-> (v : fiber e.1 y) -> Path (equivCtr e y) v |
|
|
|
equivCtrPath e y = (e.2 y).2 |
|
|
|
|
|
|
|
contr : {A : Type} {phi : I} -> isContr A -> (u : Partial phi A) -> Sub A phi u |
|
|
|
contr {A} {phi} p u = primComp (\i -> A) (\i [ (phi = i1) as c -> p.2 (u c) i ]) (inS p.1) |
|
|
|
|
|
|
|
contr' : {A : Type} -> ({phi : I} -> (u : Partial phi A) -> Sub A phi u) -> isContr A |
|
|
|
contr' {A} contr = (x, \y i -> outS (contr (\ [ (i = i0) -> x, (i = i1) -> y ])) ) where |
|
|
|
x : A |
|
|
|
x = outS (contr (\ [])) |
|
|
|
|
|
|
|
leftIsOne : {a : I} {b : I} -> Eq_s a i1 -> Eq_s (ior a b) i1 |
|
|
|
leftIsOne {a} {b} p = J_s {I} {i1} (\i p -> IsOne (ior i b)) refl_s (sym_s p) |
|
|
|
|
|
|
|
rightIsOne : {a : I} {b : I} -> Eq_s b i1 -> Eq_s (ior a b) i1 |
|
|
|
rightIsOne {a} {b} p = J_s {I} {i1} (\i p -> IsOne (ior a i)) refl_s (sym_s p) |
|
|
|
|
|
|
|
bothAreOne : {a : I} {b : I} -> Eq_s a i1 -> Eq_s b i1 -> Eq_s (iand a b) i1 |
|
|
|
bothAreOne {a} {b} p q = J_s {I} {i1} (\i p -> IsOne (iand i b)) q (sym_s p) |