{-# OPTIONS --safe --cubical --postfix-projections #-} open import Cubical.Algebra.Group module Groups.Reasoning {β} (π : Group β) where open import Cubical.Foundations.Prelude open import Groups.Symmetric.Representable open import Cubical.Foundations.Structure private variable ββ² : Level open GroupStr (RSymGroup π .snd) using () renaming (_Β·_ to _β_; 1g to e; inv to _β»ΒΉ; Β·InvR to Β·InvRβ²; Β·InvL to Β·InvLβ²) public record Expr : Type β where field before : β¨ RSymGroup π β© focus : β¨ RSymGroup π β© after : β¨ RSymGroup π β© eval : β¨ RSymGroup π β© eval = before β focus β after open Expr _βΌ_ : (x : β¨ RSymGroup π β©) β (y : Expr) β Type β x βΌ y = x β‘ eval y infix 6 _ββ_ββ_ β_β _ββ_β β_ββ_ _ββββ_ ββ _βββ βββ_ infix 3 _ββ² _ββ_ββ_ : β¨ RSymGroup π β© β β¨ RSymGroup π β© β β¨ RSymGroup π β© β Expr (g ββ f ββ h) .before = g (g ββ f ββ h) .focus = f (g ββ f ββ h) .after = h β_β : β¨ RSymGroup π β© β Expr β f β = e ββ f ββ e _ββ_β : β¨ RSymGroup π β© β β¨ RSymGroup π β© β Expr g ββ f β = g ββ f ββ e β_ββ_ : β¨ RSymGroup π β© β β¨ RSymGroup π β© β Expr β f ββ g = e ββ f ββ g ββ : Expr ββ = β e β _βββ : β¨ RSymGroup π β© β Expr g βββ = g ββ e β βββ_ : β¨ RSymGroup π β© β Expr βββ g = β e ββ g _ββββ_ : β¨ RSymGroup π β© β β¨ RSymGroup π β© β Expr g ββββ h = g ββ e ββ h data _IsRelatedTo_ (x : β¨ RSymGroup π β©) (y : Expr) : Type β where relTo : x βΌ y β x IsRelatedTo y infix 1 begin_ begin_ : β {x y} β x IsRelatedTo y β x β‘ eval y begin relTo p = p step-β : β x {y z} β y IsRelatedTo z β x β‘ y β x IsRelatedTo z step-β _ (relTo yβΌz) xβΌy = relTo (xβΌy β yβΌz) step-βΛ : β x {y z} β y IsRelatedTo z β y β‘ x β x IsRelatedTo z step-βΛ _ p q = step-β _ p (sym q) _ββ² : β x β x IsRelatedTo β x β x ββ² = relTo refl replaceFocus : (x : Expr) β (y : β¨ RSymGroup π β©) β Expr replaceFocus x y .before = x .before replaceFocus x y .focus = y replaceFocus x y .after = x .after congExpr : (x : Expr) β {y : β¨ RSymGroup π β©} β focus x β‘ y β eval x βΌ (replaceFocus x y) congExpr x p = cong (Ξ» a β before x β a β after x) p step-cong-β : β x {y z} β (eval (replaceFocus x y)) IsRelatedTo z β focus x β‘ y β eval x IsRelatedTo z step-cong-β x (relTo p) q = relTo (congExpr x q β p) step-cong-βΛ : β x {y z} β (eval (replaceFocus x y)) IsRelatedTo z β y β‘ focus x β eval x IsRelatedTo z step-cong-βΛ x (relTo p) q = relTo (congExpr x (sym q) β p) infixr 2 step-β syntax step-β x rest p = x ββ¨ p β© rest infixr 2 step-βΛ syntax step-βΛ x rest p = x ββ¨ p β© rest infixr 2 step-cong-β syntax step-cong-β x rest p = x ββ p β rest infixr 2 step-cong-βΛ syntax step-cong-βΛ x rest p = x βΛβ p β rest strictify : (P : Group β β Type ββ²) β P (RSymGroup π) β P π strictify P p = transport (sym (cong P (incβ‘ π))) p