From: coquand Date: Tue, 22 Dec 2015 13:52:11 +0000 (+0100) Subject: some lemmas about contractible types X-Git-Url: https://git.ak3n.com/?a=commitdiff_plain;h=78fe643ed40ccd4b673f34b23ddea39158801c52;p=cubicaltt.git some lemmas about contractible types --- diff --git a/examples/testContr.ctt b/examples/testContr.ctt new file mode 100644 index 0000000..dbef957 --- /dev/null +++ b/examples/testContr.ctt @@ -0,0 +1,78 @@ +module testContr where + +import prelude + +retIsContr (A B :U) (f:A->B) (g:B->A) (h : (x:A) -> Id A (g (f x)) x) (v:isContr B) + : isContr A = (g b,p) + where + b : B = v.1 + q : (y:B) -> Id B b y = v.2 + p (x:A) : Id A (g b) x = comp (A) (g (q (f x)@i)) [(i=0) -> g b,(i=1) -> h x] + +sigIsContr (A:U) (B:A->U) (u:isContr A) (q:(x:A) -> isContr (B x)) + : isContr ((x:A)*B x) = ((a,g a),r) + where + a : A = u.1 + p : (x:A) -> Id A a x = u.2 + g (x:A) : B x = (q x).1 + h (x:A) : (y:B x) -> Id (B x) (g x) y = (q x).2 + C : U = (x:A) * B x + r (z:C) : Id C (a,g a) z = + (p z.1@i,h (p z.1@i) (comp (B (p z.1@i\/-j)) z.2 [(i=1)->z.2])@i) + +isPathContr (A:U) (cA:isContr A) (x y:A) : isContr (Id A x y) = (p0,q) + where + a : A = cA.1 + f : (x:A) -> Id A a x = cA.2 + p0 : Id A x y = comp (A) a [(i=0) -> f x,(i=1) -> f y] + q (p:Id A x y) : Id (Id A x y) p0 p = + comp (A) a [(i=0) -> f x,(i=1) -> f y, + (j=0) -> comp (A) a [(k=0) -> a,(i=0) -> f x@k/\l,(i=1) -> f y@k/\l], + (j=1) -> f (p@i)] + +fiber (A B : U) (f : A -> B) (y : B) : U = + (x : A) * Id B y (f x) + +isEquiv (A B : U) (f : A -> B) : U = (y:B) -> isContr (fiber A B f y) + +equiv (A B : U) : U = (f : A -> B) * isEquiv A B f + +isEquivContr (A B:U) (cA:isContr A) (cB:isContr B) (f:A->B) : isEquiv A B f = + \ (y:B) -> sigIsContr A (\ (x:A) -> Id B y (f x)) cA (\ (x:A) -> isPathContr B cB y (f x)) + +sig (A:U) (B:A->U) : U = (x:A) * B x + +totalFun (A:U) (B C : A->U) (f : (x:A) -> B x -> C x) (w:sig A B) : sig A C = + (w.1,f (w.1) (w.2)) + +funFib1 (A:U) (B C : A->U) (f : (x:A) -> B x -> C x) (x0:A) (z0:C x0) (u:fiber (B x0) (C x0) (f x0) z0) : + fiber (sig A B) (sig A C) (totalFun A B C f) (x0,z0) = ((x0,u.1),(x0,u.2@i)) + +funFib2 (A:U) (B C : A->U) (f : (x:A) -> B x -> C x) (x0:A) (z0:C x0) + (w : fiber (sig A B) (sig A C) (totalFun A B C f) (x0,z0)) : fiber (B x0) (C x0) (f x0) z0 = (b0,s) + where + x : A = w.1.1 + b : B x = w.1.2 + p : Id A x0 x = (w.2@i).1 + q : IdP (C (p@i)) z0 (f x b) = (w.2@i).2 + b0 : B x0 = comp (B (p@-i)) b [] + r : IdP (B (p@-i)) b b0 = comp (B (p@-j\/-i)) b [(i=0) -> b] + s : Id (C x0) z0 (f x0 b0) = comp (C (p@(i/\-j))) (q@i) [(i=0) -> z0,(i=1) -> f (p@-k) (r@k)] + +compFunFib (A:U) (B C : A->U) (f : (x:A) -> B x -> C x) (x0:A) (z0:C x0) (u:fiber (B x0) (C x0) (f x0) z0) : + fiber (B x0) (C x0) (f x0) z0 = funFib2 A B C f x0 z0 (funFib1 A B C f x0 z0 u) + +retFunFib (A:U) (B C : A->U) (f : (x:A) -> B x -> C x) (x0:A) (z0:C x0) (u:fiber (B x0) (C x0) (f x0) z0) : + Id (fiber (B x0) (C x0) (f x0) z0) (funFib2 A B C f x0 z0 (funFib1 A B C f x0 z0 u)) u = + (comp ( B x0) u.1 [(l=1) -> u.1], + comp ( C x0) (u.2 @ i) [ (l=1) -> u.2 @ i, + (i = 0) -> z0, + (i = 1) -> f x0 (comp ( B x0) u.1 [ (j = 0) -> u.1, (l=1) -> u.1 ]) ]) + +equivFunFib (A:U) (B C : A->U) (f : (x:A) -> B x -> C x) (cB : isContr (sig A B)) (cC : isContr (sig A C)) (x:A) + : isEquiv (B x) (C x) (f x) = + \ (z:C x) -> retIsContr (fiber (B x) (C x) (f x) z) (fiber (sig A B) (sig A C) (totalFun A B C f) (x,z)) + (funFib1 A B C f x z) + (funFib2 A B C f x z) + (retFunFib A B C f x z) + (isEquivContr (sig A B) (sig A C) cB cC (totalFun A B C f) (x,z))