From 0535989e30fd52bfdb00fb9c683a60fb878f0bb5 Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Tue, 6 Dec 2022 09:08:58 +0000 Subject: Define helper functions for extend. --- src/Soat/SecondOrder/Algebra.idr | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/Soat/SecondOrder/Algebra.idr b/src/Soat/SecondOrder/Algebra.idr index d3e1f4c..6f7cb4a 100644 --- a/src/Soat/SecondOrder/Algebra.idr +++ b/src/Soat/SecondOrder/Algebra.idr @@ -19,6 +19,11 @@ extendRel : {U : a -> List a -> Type} -> (rel : IRel (uncurry U)) -> (ctx : List a) -> IRel (extend U ctx) extendRel rel ctx ty = rel (snd ty, fst ty ++ ctx) +public export +extendFunc : {0 U, V : a -> List a -> Type} -> (f : (t : a) -> IFunc (U t) (V t)) -> (ctx : List a) + -> IFunc (extend U ctx) (extend V ctx) +extendFunc f ctx ty = f (snd ty) (fst ty ++ ctx) + public export 0 algebraOver : (sig : Signature) -> (U : sig.T -> List sig.T -> Type) -> Type algebraOver sig x = (ctx : List sig.T) -> {t : sig.T} -> (op : Op sig t) @@ -34,6 +39,16 @@ record RawAlgebra (0 sig : Signature) where subst : (t : sig.T) -> (ctx : List sig.T) -> forall ctx' . U t ctx' -> (\t => U t ctx) ^ ctx' -> U t ctx +public export +(.extendSubst) : (a : RawAlgebra sig) -> (ctx : List sig.T) -> {ctx' : List sig.T} + -> (tms : (\t => a.U t ctx) ^ ctx') -> IFunc (extend a.U ctx') (extend a.U ctx) +a .extendSubst ctx tms ty tm = a.subst + (snd ty) + (fst ty ++ ctx) + tm + (tabulate {is = fst ty} (a.var . Sublist.elemJoinL {ys = ctx}) ++ + map (\t => a.rename t ([] {ys = fst ty} ++ Relation.reflexive {x = ctx})) tms) + public export record IsAlgebra (0 sig : Signature) (0 a : RawAlgebra sig) where constructor MkIsAlgebra -- cgit v1.2.3