|
| 1 | +module hsw where |
| 2 | +import library/foundations/univalent/path |
| 3 | +import library/foundations/univalent/extensionality |
| 4 | +import library/foundations/mltt/inductive |
| 5 | +import library/foundations/mltt/either |
| 6 | +import library/mathematics/homotopy/coequalizer |
| 7 | + |
| 8 | +{- Hub and Spoke HIT Encoded via W-types and Coequalizers. |
| 9 | + This formalization avoids high-level HIT and core Disc primitive, instead implementing |
| 10 | + the MLTT rules via an underlying inductive-algebra framework. -} |
| 11 | + |
| 12 | +def W_hs_B (S A : U) : U := + A 𝟏 -- Points container: B = A + 1 |
| 13 | +def W_hs_C (S A : U) : W_hs_B S A → U := +-rec A 𝟏 U (λ (_ : A), 𝟎) (λ (_ : 𝟏), S) -- Subtrees: C (inl a) = 0, C (inr *) = S |
| 14 | +def W_hs (S A : U) : U := W (x : W_hs_B S A), W_hs_C S A x -- Raw constructors via W-types |
| 15 | +def W_center (S A : U) (a : A) : W_hs S a := sup (+ A 𝟏) (W_hs_C S A) (inl A 𝟏 a) (λ (z : 𝟎), ind₀ (W_hs S A) z) |
| 16 | +def W_hub (S A : U) (f : S → W_hs S A) : W_hs S A := sup (+ A 𝟏) (W_hs_C S A) (inr A 𝟏 ★) f |
| 17 | + |
| 18 | +def Rel_hs (S A : U) : U := Σ (f : S → W_hs S A), S |
| 19 | +def Rel_lhs (S A : U) (r : Rel_hs S A) : W_hs S A := W_hub S A r.1 |
| 20 | +def Rel_rhs (S A : U) (r : Rel_hs S A) : W_hs S A := r.1 r.2 |
| 21 | + |
| 22 | +-- 1) Formation Rule |
| 23 | +def hs (S A : U) : U |
| 24 | + := coequ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) |
| 25 | + |
| 26 | +-- 2) Introduction Rules |
| 27 | +def center (S A : U) (a : A) : hs S A |
| 28 | + := ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (W_center S A a) |
| 29 | + |
| 30 | +def hub (S A : U) (f : S → W_hs S A) : hs S A |
| 31 | + := ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (W_hub S A f) |
| 32 | + |
| 33 | +def spoke (S A : U) (f : S → W_hs S A) (s : S) |
| 34 | + : Path (hs S A) (hub S A f) (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s)) |
| 35 | + := resp (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f, s) |
| 36 | + |
| 37 | +-- The algebra map for the W-type induction |
| 38 | +def hs-algebra-map (S A : U) (X : hs S A → U) |
| 39 | + (nCenter : Π (a : A), X (center S A a)) |
| 40 | + (nHub : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))), X (hub S A f)) |
| 41 | + : Π (w : W_hs S A), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) w) |
| 42 | + := W-ind (+ A 𝟏) (W_hs_C S A) (λ (w : W_hs S A), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) w)) |
| 43 | + (+-ind A 𝟏 (λ (b : + A 𝟏), Π (f : W_hs_C S A b → W_hs S A), (Π (c : W_hs_C S A b), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f c))) → X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (sup (+ A 𝟏) (W_hs_C S A) b f))) |
| 44 | + (λ (a : A) (f : 𝟎 → W_hs S A) (nF : Π (c : 𝟎), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f c))), nCenter a) |
| 45 | + (λ (b : 𝟏) (f : S → W_hs S A) (nF : Π (c : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f c))), nHub f nF)) |
| 46 | + |
| 47 | +-- 3) Dependent Elimination Rule |
| 48 | +def hs-ind (S A : U) (X : hs S A → U) |
| 49 | + (nCenter : Π (a : A), X (center S A a)) |
| 50 | + (nHub : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))), X (hub S A f)) |
| 51 | + (nSpoke : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))) (s : S), |
| 52 | + PathP (<i> X (spoke S A f s @ i)) (nHub f nF) (nF s)) |
| 53 | + (z : hs S A) : X z |
| 54 | + := coequ-ind (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) X |
| 55 | + (hs-algebra-map S A X nCenter nHub) |
| 56 | + (λ (r : Rel_hs S A), nSpoke r.1 (λ (s : S), hs-algebra-map S A X nCenter nHub (r.1 s)) r.2) z |
| 57 | + |
| 58 | +-- 4) Computational Rules |
| 59 | +def hs-β₁ (S A : U) (X : hs S A → U) |
| 60 | + (nCenter : Π (a : A), X (center S A a)) |
| 61 | + (nHub : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))), X (hub S A f)) |
| 62 | + (nSpoke : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))) (s : S), |
| 63 | + PathP (<i> X (spoke S A f s @ i)) (nHub f nF) (nF s)) (a : A) |
| 64 | + : Path (X (center S A a)) (hs-ind S A X nCenter nHub nSpoke (center S A a)) (nCenter a) |
| 65 | + := idp (X (center S A a)) (nCenter a) |
| 66 | + |
| 67 | +def hs-β₂ (S A : U) (X : hs S A → U) |
| 68 | + (nCenter : Π (a : A), X (center S A a)) |
| 69 | + (nHub : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))), X (hub S A f)) |
| 70 | + (nSpoke : Π (f : S → W_hs S A) (nF : Π (s : S), X (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) (f s))) (s : S), |
| 71 | + PathP (<i> X (spoke S A f s @ i)) (nHub f nF) (nF s)) (f : S → W_hs S A) |
| 72 | + : Path (X (hub S A f)) (hs-ind S A X nCenter nHub nSpoke (hub S A f)) (nHub f (λ (s : S), hs-algebra-map S A X nCenter nHub (f s))) |
| 73 | + := idp (X (hub S A f)) (nHub f (λ (s : S), hs-algebra-map S A X nCenter nHub (f s))) |
| 74 | + |
| 75 | +-- 5) Uniqueness Rule |
| 76 | +def hs-η (S A : U) (X : hs S A → U) (h : Π (z : hs S A), X z) |
| 77 | + : Path (Π (z : hs S A), X z) h |
| 78 | + (λ (z : hs S A), coequ-ind (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) X |
| 79 | + (λ (w : W_hs S A), h (ι₂ (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) w)) |
| 80 | + (λ (r : Rel_hs S A), <i> h (spoke S A r.1 r.2 @ i)) z) |
| 81 | + := coequ-η (Rel_hs S A) (W_hs S A) (Rel_lhs S A) (Rel_rhs S A) X h |
0 commit comments