{-# OPTIONS --without-K --safe #-} open import Algebra.Bundles using (Group) module Algebra.Group.Reasoning.Reflection {gβ gβ} (π : Group gβ gβ) where open Group π open import Algebra.Group.Symmetric π open import Algebra.Group.Symmetric.Equality π open import Algebra.Group.Symmetric.Inclusion π open import Algebra.Group.Symmetric.PartialEquality π using (_β£'_; peq) open import Algebra.Morphism.Group open import Function open import Tactic.Homomorphism.Group public open import Data.Bool as Bool using (Bool; _β¨_; if_then_else_) open import Data.Maybe as Maybe using (Maybe; just; nothing; maybe) open import Data.List as List using (List; _β·_; []) open import Data.Nat as β using (β; suc; zero) open import Data.Product as Product using (_Γ_; _,_) open import Agda.Builtin.Reflection open import Reflection.TypeChecking.MonadSyntax open import Reflection.Argument open import Reflection.Term using (getName; _β―β β·β_) begin-helper : β {g h} β β¦ g β§ β£ β¦ h β§ β g β h begin-helper {g} {h} p = β¦β§-injective p begin-helper2 : β {g h} β g β£' h β g β£ h begin-helper2 p .eq = peq p constructBackSoln : Term β Term β Term β Term β Term constructBackSoln f eq lhs rhs = let domgrp = quote GroupMorphism.from-group β¨ def β© f β¨β·β© [] in let grp = quote GroupMorphism.to-group β¨ def β© f β¨β·β© [] in quote begin-helper β¨ def β© domgrp β¨β·β© (quote Group.trans β¨ def β© grp β¨β·β© (quote Group.trans β¨ def β© grp β¨β·β© (quote proof β¨ def β© f β¨β·β© buildExpr lhs β¨β·β© []) β¨β·β© (quote begin-helper2 β¨ def β© domgrp β¨β·β© eq β¨β·β© []) β¨β·β© [] ) β¨β·β© (quote Group.sym β¨ def β© grp β¨β·β© (quote proof β¨ def β© f β¨β·β© buildExpr rhs β¨β·β© []) β¨β·β© []) β¨β·β© []) β¨β·β© [] begin-macro : Term β Term β Term β TC _ begin-macro f proof hole = do hole' β inferType hole >>= normalise just (lhs , rhs) β returnTC (getArgs hole') where nothing β typeError (termErr hole' β· []) let soln = constructBackSoln f proof lhs rhs unify hole soln macro beginβ¨_β©_ : Term β Term β Term β TC _ beginβ¨_β©_ = begin-macro