Construct the free extension of a model over a setoid Small print: the setoid's equivalence relation may not be decidable The frex `a[s]` of a `pres`-model `a` over a setoid `s` is given by the free model `F s` of the following presentation over the setoid `s`. First, we add all the elements `x : U a` as constants `Constant x : 0`. Then, we add the following evaluation equations to the `pres` axioms: f (Constant x1, ..., Constant xn) = Constant $ a.Sem f (x1,..., xn)
import public Frex.Free.Constructiondata EvaluationSigOperation : Signature -> (0 _ : Type) -> Nat -> TypeOp : sig .OpWithArity n -> EvaluationSigOperation sig a nConstant : a -> EvaluationSigOperation sig a 0EvaluationSig : Signature -> (0 _ : Type) -> SignaturewithEvaluation : Show c => Printer sig a -> Printer (EvaluationSig sig c) aEvalEmbed : (sig : Signature) -> sig ~> EvaluationSig sig adata EvaluationAxiom : Signature -> Type -> Setoid -> TypeAxiom : axioms -> EvaluationAxiom sig axioms aEvaluation : sig .OpWithArity n -> Vect n (U a) -> EvaluationAxiom sig axioms aAssumption : (a .equivalence) .relation x y -> EvaluationAxiom sig axioms aEvaluationTheory : (pres : Presentation) -> (a : SetoidAlgebra (pres .signature)) -> EvaluationAxiom (pres .signature) (pres .Axiom) (cast a) -> Equation (EvaluationSig (pres .signature) (U a))EvaluationPresentation : (pres : Presentation) -> SetoidAlgebra (pres .signature) -> PresentationcastEval : SetoidAlgebra (EvaluationSig sig a) -> SetoidAlgebra siglemma : {auto a : Algebra sig} -> (n : Nat) -> (f : (Fin n -> x)) -> (env : (x -> U a)) -> bindTerms (map Done (tabulate f)) env = tabulate (env . f)lemma2 : {auto a : Algebra sig} -> (i : Fin n) -> (ts : Vect n (Term sig x)) -> (env : (x -> U a)) -> index i (bindTerms ts env) = bindTerm (index i ts) envcoherence : (a : SetoidAlgebra (EvaluationSig sig s)) -> (t : Term sig x) -> (env : (x -> U a)) -> a .Sem (cast t) env = (castEval a) .Sem t envcoherenceTerms : (a : SetoidAlgebra (EvaluationSig sig s)) -> (ts : Vect n (Term sig x)) -> (env : (x -> U a)) -> bindTerms (castTerms (EvalEmbed sig) ts) env = bindTerms ts envcastEval : Model (EvaluationPresentation pres a) -> Model prescastEval : b ~> c -> castEval b ~> castEval cfreeAsExtension : Free (EvaluationPresentation pres (a .Algebra)) s -> Extension a s.OverAlgebra : Extension a s -> SetoidAlgebra ((EvaluationPresentation pres (a .Algebra)) .signature).OverAlgebraCoherence : (other : Extension a s) -> (env : (x -> U (other .Model))) -> (t : Term (pres .signature) x) -> (castEval (other .OverAlgebra)) .Sem t env = (other .Model) .Sem t envOverAlgebraCoherenceAux : (other : Extension a s) -> (env : (x -> U (other .Model))) -> (ts : Vect n (Term (pres .signature) x)) -> bindTerms ts env = bindTerms ts envOverAlgebraNop : (other : Extension a s) -> (xs : Vect n (U a)) -> (env : (x -> U (other .Model))) -> bindTerms (map (\x => Call (MkOp (Constant x)) []) xs) env = map (((other .Embed) .H) .H) xs.Over : Extension a s -> ModelOver (EvaluationPresentation pres (a .Algebra)) sExtender : (fs : Free (EvaluationPresentation pres (a .Algebra)) s) -> Extender (freeAsExtension fs)Uniqueness : (fs : Free (EvaluationPresentation pres (a .Algebra)) s) -> Uniqueness (freeAsExtension fs)FrexByFree : Free (EvaluationPresentation pres (a .Algebra)) s -> Frex a sFrex : (a : Model pres) -> (s : Setoid) -> Frex a s