open import HoTT
open import groups.Exactness
open import groups.HomSequence
module groups.ExactSequence where
is-exact-seq : ∀ {i} {G H : Group i}
→ HomSequence G H → Type i
is-exact-seq (_ ⊣|ᴳ) = Lift ⊤
is-exact-seq (_ →⟨ φ ⟩ᴳ _ ⊣|ᴳ) = Lift ⊤
is-exact-seq (_ →⟨ φ ⟩ᴳ _ →⟨ ψ ⟩ᴳ seq) =
is-exact φ ψ × is-exact-seq (_ →⟨ ψ ⟩ᴳ seq)
ExactSequence : ∀ {i} (G H : Group i) → Type (lsucc i)
ExactSequence G H = Σ (HomSequence G H) is-exact-seq
abstract
seq-equiv-preserves-exact : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ HomSeqEquiv seq₀ seq₁ ξG ξH
→ is-exact-seq seq₀ → is-exact-seq seq₁
seq-equiv-preserves-exact ((_ ↓|ᴳ) , _) _ = lift tt
seq-equiv-preserves-exact ((_ ↓⟨ _ ⟩ᴳ _ ↓|ᴳ) , _) _ = lift tt
seq-equiv-preserves-exact
( (ξG ↓⟨ φ□ ⟩ᴳ _↓⟨_⟩ᴳ_ ξH {ξK} ψ□ seq-map)
, (ξG-ise , ξH-ise , seq-map-ise))
(φ₀-ψ₀-is-exact , ψ₀-seq₀-is-exact-seq) =
equiv-preserves-exact
φ□ ψ□ ξG-ise ξH-ise (is-seqᴳ-equiv.head seq-map-ise)
φ₀-ψ₀-is-exact ,
seq-equiv-preserves-exact
((ξH ↓⟨ ψ□ ⟩ᴳ seq-map) , (ξH-ise , seq-map-ise))
ψ₀-seq₀-is-exact-seq
seq-equiv-preserves'-exact : ∀ {i} {G₀ G₁ H₀ H₁ : Group i}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ HomSeqEquiv seq₀ seq₁ ξG ξH
→ is-exact-seq seq₁ → is-exact-seq seq₀
seq-equiv-preserves'-exact seq-equiv =
seq-equiv-preserves-exact (HomSeqEquiv-inverse seq-equiv)
private
exact-seq-index-type : ∀ {i} {G H : Group i} → ℕ → HomSequence G H → Type i
exact-seq-index-type _ (G ⊣|ᴳ) = Lift ⊤
exact-seq-index-type _ (G →⟨ φ ⟩ᴳ H ⊣|ᴳ) = Lift ⊤
exact-seq-index-type O (G →⟨ φ ⟩ᴳ H →⟨ ψ ⟩ᴳ s) = is-exact φ ψ
exact-seq-index-type (S n) (_ →⟨ _ ⟩ᴳ s) = exact-seq-index-type n s
abstract
exact-seq-index : ∀ {i} {G H : Group i}
→ (n : ℕ) (seq : ExactSequence G H)
→ exact-seq-index-type n (fst seq)
exact-seq-index _ ((G ⊣|ᴳ) , _) = lift tt
exact-seq-index _ ((G →⟨ φ ⟩ᴳ H ⊣|ᴳ) , _) = lift tt
exact-seq-index O ((G →⟨ φ ⟩ᴳ H →⟨ ψ ⟩ᴳ seq) , ise-seq) = fst ise-seq
exact-seq-index (S n) ((G →⟨ φ ⟩ᴳ H →⟨ ψ ⟩ᴳ seq) , ise-seq) =
exact-seq-index n ((H →⟨ ψ ⟩ᴳ seq) , snd ise-seq)