indexsource

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism renaming (Iso to _≃_)
open import Cubical.Foundations.Univalence
open import Cubical.Data.Unit renaming (Unit to )
open import Cubical.Data.Sigma
open import Cubical.Data.Int
open import Cubical.Relation.Nullary

-- —
data Interval : Type where
  l : Interval
  r : Interval
  seg : l  r

Interval-isContr : isContr Interval
Interval-isContr = l , paths where
  paths : (x : Interval)  l  x
  paths l = refl
  paths r = seg
  paths (seg i) j = seg (i  j)

Interval-loops : (x : Interval)  x  x
Interval-loops l = refl
Interval-loops r = refl
Interval-loops (seg i) j = seg i

-- ○
data  : Type where
  base : 
  loop : base  base

S¹→⊤ :   
S¹→⊤ base = tt
S¹→⊤ (loop i) = tt
⊤→S¹ :   
⊤→S¹ tt = base
⊤→S¹→⊤ : (t : )  S¹→⊤ (⊤→S¹ t)  t
⊤→S¹→⊤ tt = refl
-- S¹→⊤→S¹ : (x : S¹) → ⊤→S¹ (S¹→⊤ x) ≡ x
-- S¹→⊤→S¹ base = refl
-- S¹→⊤→S¹ (loop i) j = {! IMPOSSIBLE the point doesn't retract onto the circle! !}

always-loop : (x : )  x  x
always-loop base = loop
always-loop (loop i) j =
  hcomp  where k (i = i0)  loop (j  ~ k)
                 k (i = i1)  loop (j  k)
                 k (j = i0)  loop (i  ~ k)
                 k (j = i1)  loop (i  k))
        base

loop-induction : { : Level} {P : base  base  Type }
                (pprop :  p  isProp (P p))
                (prefl : P refl)
                (ploop :  p  P p  P (p  loop))
                (ppool :  p  P p  P (p  sym loop))
                (p : base  base)  P p
loop-induction {} {P} pprop prefl ploop ppool = J Q prefl
  where
    bridge : PathP  i  base  loop i  Type ) P P
    bridge = toPathP (funExt λ p  isoToPath
      (iso  x  subst P (compPathr-cancel _ _) (ploop _ x))
           (ppool p)
            _  pprop _ _ _)
            _  pprop _ _ _)))
    Q : (x : )  base  x  Type 
    Q base p = P p
    Q (loop i) p = bridge i p

data Bool₁ : Type₁ where
  false true : Bool₁

S¹⋆ : Σ Type  A  A)
S¹⋆ =  , base

flip :   
flip base = base
flip (loop i) = loop (~ i)
flip≡ :   
flip≡ = isoToPath (iso flip flip inv inv) where
  inv : section flip flip
  inv base = refl
  inv (loop i) = refl
flip⋆ : S¹⋆  S¹⋆
flip⋆ i = flip≡ i , base≡base i where
  base≡base : PathP  i  flip≡ i) base base
  base≡base = ua-gluePath _ refl

Cover :   Type
Cover base = 
Cover (loop i) = sucPathℤ i

S¹⋆-auto : (S¹⋆  S¹⋆)  Bool₁
S¹⋆-auto = isoToPath (iso to from sec ret) where
  isPos :   Bool₁
  isPos (pos _) = true
  isPos _ = false
  to : S¹⋆  S¹⋆  Bool₁
  to p = isPos (transport  i  Cover (loop' i)) 0) where
    loop' : base  base
    loop' i = comp  j  p j .fst)
                    where j (i = i0)  p j .snd
                            j (i = i1)  p j .snd)
                   (loop i)
  from : Bool₁  S¹⋆  S¹⋆
  from false = flip⋆
  from true = refl
  sec : section to from
  sec false = refl
  sec true = refl
  ret : retract to from
  ret p = {!   !}

-- ●
data  : Type where
  base² : 
  loop² : base²  base²
  disk : refl  loop²

D²-isContr : isContr 
D²-isContr = base² , paths where
  paths : (x : )  base²  x
  paths base² = refl
  paths (loop² i) j = disk j i
  paths (disk i j) k = disk (i  k) j

D²-isProp : isProp 
D²-isProp x y = sym (D²-isContr .snd x)  D²-isContr .snd y

data coeq (X : Type) : Type where
  inc : X  coeq X
  eq :  x  inc x  inc x

lemma :  X  coeq X  (X × )
lemma X = iso to from to-from from-to where
  to : coeq X  X × 
  to (inc x) = x , base
  to (eq x i) = x , loop i
  from : X ×   coeq X
  from (x , base) = inc x
  from (x , loop i) = eq x i
  to-from :  x  to (from x)  x
  to-from (_ , base) = refl
  to-from (_ , loop i) = refl
  from-to :  x  from (to x)  x
  from-to (inc x) = refl
  from-to (eq x i) = refl