Idris2Doc : Frex.Algebra

Frex.Algebra

Algebras for a `Frex.Signature` and associated definitions

Reexports

importpublic Notation
importpublic Notation.Semantic
importpublic Data.Vect
importpublic Data.Vect.Elem
importpublic Data.Vect.Properties
importpublic Data.Rel

Definitions

(^) : Type->Nat->Type
  N-ary tuples

Totality: total
Visibility: public export
Fixity Declaration: infix operator, level 10
curry : (a^n->a) ->aryna
  Curry a function from n-tuples to an n-ary function

Totality: total
Visibility: public export
uncurry : aryna->a^n->a
  Uncurry an n-ary function into a function from n-tuples

Totality: total
Visibility: public export
uncurryCurryId : (f : (a^n->a)) -> (xs : a^n) ->uncurry (curryf) xs=fxs
Totality: total
Visibility: export
algebraOver : Signature->Type->Type
  States: each operation has an interpretation

Totality: total
Visibility: public export
algebraOver' : Signature->Type->Type
Totality: total
Visibility: public export
recordAlgebra : Signature->Type
  An algebra for a signature Sig consists of:
@U : A type called the carrier
@Sem : a semantic interpretation for each Sig-operation
The smart constructor `MkAlgebra` is more usable in concrete cases

Totality: total
Visibility: public export
Constructor: 
MakeAlgebra : {0Sig : Signature} -> (0U : Type) ->algebraOverSigU->AlgebraSig

Projections:
.Semantics : {0Sig : Signature} -> ({rec:0} : AlgebraSig) ->algebraOverSig (U{rec:0})
0.U : {0Sig : Signature} ->AlgebraSig->Type

Hints:
Cast (Algebrasig) (SetoidAlgebrasig)
Semantic (Algebrasig) (Opsig)
Semantic (Algebrasig) (Termsigx)
0.U : {0Sig : Signature} ->AlgebraSig->Type
Totality: total
Visibility: public export
0U : {0Sig : Signature} ->AlgebraSig->Type
Totality: total
Visibility: public export
.Semantics : {0Sig : Signature} -> ({rec:0} : AlgebraSig) ->algebraOverSig (U{rec:0})
Totality: total
Visibility: public export
Semantics : {0Sig : Signature} -> ({rec:0} : AlgebraSig) ->algebraOverSig (U{rec:0})
Totality: total
Visibility: public export
MkAlgebra : (0U : Type) ->algebraOver'sigU->Algebrasig
  Smart constructor for an algebra for a signature Sig:
@U : A type called the carrier
@Sem : a semantic interpretation for each Sig-operation

Totality: total
Visibility: public export
dataTerm : (0_ : Signature) ->Type->Type
  Algebraic terms of this signature with variables in the given type

Totality: total
Visibility: public export
Constructors:
Done : a->Termsiga
  A variable with the given index
Call : (f : Opsig) ->Vect (arityf) (Termsiga) ->Termsiga
  An operator, applied to a vector of sub-terms

Hints:
Applicative (Termsig)
(DecEq (Opsig), DecEqa) =>DecEq (Termsiga)
(Eq (Opsig), Eqa) =>Eq (Termsiga)
Functor (Termsig)
Monad (Termsig)
(Ord (Opsig), Orda) =>Ord (Termsiga)
pres.signature=sig=>Semantic (a<~.~>b) (Termsigy)
pres.signature=sig=>Semantic (Coproductab) (Termsigy)
pres.signature=sig=>Semantic (Extensionax) (Termsigy)
pres.signature=sig=>Semantic (Frexax) (Termsigy)
pres.signature=sig=>Semantic (Modelpres) (Termsigx)
pres.signature=sig=>Semantic (ModelOverpresx) (Termsigy)
pres.signature=sig=>Semantic (Freepresx) (Termsigy)
Semantic (Algebrasig) (Termsigx)
Semantic (SetoidAlgebrasig) (Termsigx)
Show (FreePresetoidsigxuv)
Uninhabited (Donex=Callfxs)
Uninhabited (Callfxs=Donex)
withParens : Printersiga->Printersiga
  Print parens (but not at the toplevel)

Totality: total
Visibility: export
withNames : Printersig () ->Printersig (Finn)
Totality: total
Visibility: export
withFocus : String->Printersiga->Printersig (Maybea)
Totality: total
Visibility: export
withVal : Printersiga->Printersiga
Totality: total
Visibility: export
displayPrec : Printersiga->Prec->Termsiga->Doc ()
Totality: total
Visibility: export
display : Printersiga->Termsiga->Doc ()
Totality: total
Visibility: export
withNesting : Printersiga->Printersig (Termsiga)
  This printer assumes there's at least one layer of term above
the nested one i.e. you can't have just `Done t`.

Totality: total
Visibility: export
bindTerm : {autoa : Algebrasig} ->Termsigx-> (x->Ua) ->Ua
Totality: total
Visibility: public export
bindTerms : {autoa : Algebrasig} ->Vectn (Termsigx) -> (x->Ua) ->Vectn (Ua)
Totality: total
Visibility: public export
bindTermsIsMap : {autoa : Algebrasig} -> (xs : Vectn (Termsigx)) -> (env : (x->Ua)) ->bindTermsxsenv=map (flip (a.Sem) env) xs
  Specifies `bindTerms` specialises `map bindTerm`.

Totality: total
Visibility: export
Free : (0sig : Signature) -> (0_ : Type) ->Algebrasig
  The free `sig`-algebra over over a given type

Totality: total
Visibility: public export
call : sig.OpWithArityn->aryn (Termsigx)
  The corresponding  n-ary operation over the term algebra

Totality: total
Visibility: public export
X : Fink->Termsig (Fink)
  Smart constructor for variables

Totality: total
Visibility: public export
cast : Termsig (Maybea) ->Termsig (Eithera (Fin1))
  Converting a focus to a term with one free variable

Totality: total
Visibility: public export
TermAlgebra : (0sig : Signature) ->Nat->Algebrasig
  Free `sig`-algebra over `n`-variables.

Totality: total
Visibility: public export
bindTermsPureRightUnit : (ts : Vectn (Termsigx)) ->bindTermstspure=ts
Totality: total
Visibility: export
bindPureRightUnit : (t : Termsigx) ->t>>=pure=t
  Monad law corresponding to right unit law of monoids

Totality: total
Visibility: export
0CongruenceWRT : (a : Setoid) -> (Ua^n->Ua) ->Type
  The equivalence relation on `a` is a congruence w.r.t. the operation `f`.

Totality: total
Visibility: public export
EqualCongruence : (f : (a^n->a)) ->CongruenceWRT (casta) f
  Equality is always a congruence

Totality: total
Visibility: export
recordSetoidAlgebra : Signature->Type
  A setoid algebra: an algebra over a setoid whose equivalence
relation respects all the algebraic operations

Totality: total
Visibility: public export
Constructor: 
MkSetoidAlgebra : {0Sig : Signature} -> (algebra : AlgebraSig) -> (equivalence : Equivalence (Ualgebra)) -> ((f : OpSig) ->CongruenceWRT (MkSetoid (Ualgebra) equivalence) (algebra.Semf)) ->SetoidAlgebraSig

Projections:
.algebra : {0Sig : Signature} ->SetoidAlgebraSig->AlgebraSig
  Underlying algebra
.congruence : {0Sig : Signature} -> ({rec:0} : SetoidAlgebraSig) -> (f : OpSig) ->CongruenceWRT (MkSetoid (U (algebra{rec:0})) (equivalence{rec:0})) ((algebra{rec:0}) .Semf)
  All algebraic operations respect the equivalence relation
.equivalence : {0Sig : Signature} -> ({rec:0} : SetoidAlgebraSig) ->Equivalence (U (algebra{rec:0}))
  Equivalence relation making the carrier a setoid

Hints:
Cast (SetoidAlgebrasig) Setoid
Cast (Algebrasig) (SetoidAlgebrasig)
Cast (a<~>b) (a~>b)
Cast (SetoidAlgebrasig) (PresetoidAlgebrasig)
Semantic (SetoidAlgebrasig) (Opsig)
Semantic (SetoidAlgebrasig) (Termsigx)
.algebra : {0Sig : Signature} ->SetoidAlgebraSig->AlgebraSig
  Underlying algebra

Totality: total
Visibility: public export
algebra : {0Sig : Signature} ->SetoidAlgebraSig->AlgebraSig
  Underlying algebra

Totality: total
Visibility: public export
.equivalence : {0Sig : Signature} -> ({rec:0} : SetoidAlgebraSig) ->Equivalence (U (algebra{rec:0}))
  Equivalence relation making the carrier a setoid

Totality: total
Visibility: public export
equivalence : {0Sig : Signature} -> ({rec:0} : SetoidAlgebraSig) ->Equivalence (U (algebra{rec:0}))
  Equivalence relation making the carrier a setoid

Totality: total
Visibility: public export
.congruence : {0Sig : Signature} -> ({rec:0} : SetoidAlgebraSig) -> (f : OpSig) ->CongruenceWRT (MkSetoid (U (algebra{rec:0})) (equivalence{rec:0})) ((algebra{rec:0}) .Semf)
  All algebraic operations respect the equivalence relation

Totality: total
Visibility: public export
congruence : {0Sig : Signature} -> ({rec:0} : SetoidAlgebraSig) -> (f : OpSig) ->CongruenceWRT (MkSetoid (U (algebra{rec:0})) (equivalence{rec:0})) ((algebra{rec:0}) .Semf)
  All algebraic operations respect the equivalence relation

Totality: total
Visibility: public export
0U : SetoidAlgebrasig->Type
Totality: total
Visibility: public export
cast : (a : SetoidAlgebrasig) ->Preorder (Ua) ((a.equivalence) .relation)
Totality: total
Visibility: public export
cast : (f : Opsig) ->VectSetoid (arityf) (casta) ~>casta
Totality: total
Visibility: public export
0Preserves : (a : SetoidAlgebrasig) -> (b : SetoidAlgebrasig) -> (Ua->Ub) ->Opsig->Type
  States: the function `h : U a -> U b` preserves the `sig`-operation `f`

Totality: total
Visibility: public export
0Homomorphism : (a : SetoidAlgebrasig) -> (b : SetoidAlgebrasig) -> (Ua->Ub) ->Type
  States: the function `h : U a -> U b` preserves all `sig`-operations

Totality: total
Visibility: public export
record(~>) : {Sig : Signature} ->SetoidAlgebraSig->SetoidAlgebraSig->Type
  Homomorphisms between Setoid `Sig`-algebras
@H : setoid morphism between the carriers
@preserves : satisfying the homomorphism property

Totality: total
Visibility: public export
Constructor: 
MkSetoidHomomorphism : {0Sig : Signature} -> (H : casta~>castb) ->Homomorphismab (H.H) ->a~>b

Projections:
.H : {0Sig : Signature} ->a~>b->casta~>castb
  Underlying Setoid homomorphism
.preserves : {0Sig : Signature} -> ({rec:0} : a~>b) ->Homomorphismab ((H{rec:0}) .H)
  Preservation of `Sig`-operations up to the setoid's equivalence

Hint: 
Cast (a<~>b) (a~>b)

Fixity Declarations:
infix operator, level 5
infix operator, level 5
infix operator, level 5
.H : {0Sig : Signature} ->a~>b->casta~>castb
  Underlying Setoid homomorphism

Totality: total
Visibility: public export
H : {0Sig : Signature} ->a~>b->casta~>castb
  Underlying Setoid homomorphism

Totality: total
Visibility: public export
.preserves : {0Sig : Signature} -> ({rec:0} : a~>b) ->Homomorphismab ((H{rec:0}) .H)
  Preservation of `Sig`-operations up to the setoid's equivalence

Totality: total
Visibility: public export
preserves : {0Sig : Signature} -> ({rec:0} : a~>b) ->Homomorphismab ((H{rec:0}) .H)
  Preservation of `Sig`-operations up to the setoid's equivalence

Totality: total
Visibility: public export
id : (a : SetoidAlgebrasig) ->a~>a
Totality: total
Visibility: public export
(.) : b~>c->a~>b->a~>c
Totality: total
Visibility: public export
Fixity Declaration: infixr operator, level 9
0(~>) : Algebrasig->Algebrasig->Type
Totality: total
Visibility: public export
Fixity Declarations:
infix operator, level 5
infix operator, level 5
infix operator, level 5
bindHom : (env : (x->Ua)) ->Homomorphism (cast (Freesigx)) (casta) (flipbindTermenv)
  States: `(>>= f) : Free sig x -> a` is an algebra homomorphism

Totality: total
Visibility: export
eval : {autoa : Algebrasig} -> (x->Ua) ->Freesigx~>a
  Like Algebra.(>>=), but pack the `sig`-homomorphism structure

Totality: total
Visibility: public export
bindAssociative : {autoa : Algebrasig} -> (t : Termsigx) -> (f : (x->Termsigy)) -> (g : (y->Ua)) ->bindTerm (bindTermtf) g=bindTermt (\i=>bindTerm (fi) g)
Totality: total
Visibility: public export
bindTermsAssociative : {autoa : Algebrasig} -> (ts : Vectn (Termsigx)) -> (f : (x->Termsigy)) -> (g : (y->Ua)) ->bindTerms (bindTermstsf) g=bindTermsts (\x=>bindTerm (fx) g)
Totality: total
Visibility: public export
bindCongruence : (t : Termsig (Ux)) ->SetoidHomomorphism (x~~>casta) (casta) (\u=>bindTermt (u.H))
  The setoid equivalence is a congruence wrt. all algebraic terms

Totality: total
Visibility: export
bindTermsCongruence : (ts : Vectn (Termsig (Ux))) ->SetoidHomomorphism (x~~>casta) (VectSetoidn (casta)) (\u=>bindTermsts (u.H))
  Auxiliary function used in the inductive argument for `bindCongruence`

Totality: total
Visibility: export
eval : Termsig (Ux) -> (x~~>casta) ~>casta
  Evaluation of algebraic terms in a SetoidAlgebra is a setoid homomorphism

Totality: total
Visibility: public export
0Preserves : (a : SetoidAlgebrasig) -> (b : SetoidAlgebrasig) -> (Ua->Ub) ->Termsigx->Type
  Every term over x induces an `x`-ary operation.
States: `h` preserves the this operation.

Totality: total
Visibility: public export
homoPreservesSem : (h : a~>b) -> (t : Termsigx) ->Preservesab ((h.H) .H) t
  Homomorphism preserve all algebraic operations

Totality: total
Visibility: public export
homoPreservesSemMap : (h : a~>b) -> (ts : Vectn (Termsigx)) -> (env : (x->Ua)) -> ((VectSetoidn (castb)) .equivalence) .relation (map ((h.H) .H) (bindTermstsenv)) (bindTermsts ((h.H) .H.env))
  Auxiliary generalisation to prove `homoPreservesSem`.

Totality: total
Visibility: public export
record(<~>) : SetoidAlgebrasig->SetoidAlgebrasig->Type
Totality: total
Visibility: public export
Constructor: 
MkIsomorphism : (Iso : casta<~>castb) ->Homomorphismab ((Iso.Fwd) .H) ->a<~>b

Projections:
.FwdHomo : ({rec:0} : a<~>b) ->Homomorphismab (((Iso{rec:0}) .Fwd) .H)
.Iso : a<~>b->casta<~>castb

Hint: 
Cast (a<~>b) (a~>b)

Fixity Declarations:
infix operator, level 5
infix operator, level 5
.Iso : a<~>b->casta<~>castb
Totality: total
Visibility: public export
Iso : a<~>b->casta<~>castb
Totality: total
Visibility: public export
.FwdHomo : ({rec:0} : a<~>b) ->Homomorphismab (((Iso{rec:0}) .Fwd) .H)
Totality: total
Visibility: public export
FwdHomo : ({rec:0} : a<~>b) ->Homomorphismab (((Iso{rec:0}) .Fwd) .H)
Totality: total
Visibility: public export
BwdHomo : (a : SetoidAlgebrasig) -> (b : SetoidAlgebrasig) -> (iso : a<~>b) ->Homomorphismba (((iso.Iso) .Bwd) .H)
Totality: total
Visibility: public export
sym : a<~>b->b<~>a
  Reverse an isomorphism

Totality: total
Visibility: public export
(~~>) : SetoidAlgebrasig->SetoidAlgebrasig->Setoid
  The setoid of homomorphisms between algebras with pointwise equivalence.

Totality: total
Visibility: public export
Fixity Declaration: infix operator, level 5
.sem : (a : SetoidAlgebrasig) ->sig.OpWithArityn->aryn (Ua)
  nary interpretation of an operator in an algebra

Totality: total
Visibility: public export
callEqSem : (a : Algebrasig) -> (op : Opsig) -> (xs : Vect (arityop) (Ua)) ->bindTerm (Callop (tabulateDone)) (\i=>indexixs) =a.Semopxs
  Each operation in the signature is an algebraic operation

Totality: total
Visibility: public export
record(~>) : Signature->Signature->Type
Totality: total
Visibility: public export
Constructor: 
MkSignatureMorphism : (sig1.OpWithArityn->Termsig2 (Finn)) ->sig1~>sig2

Projection: 
.H : sig1~>sig2->sig1.OpWithArityn->Termsig2 (Finn)

Hint: 
sig1~>sig2=>Cast (Equationsig1) (Equationsig2)

Fixity Declarations:
infix operator, level 5
infix operator, level 5
infix operator, level 5
.H : sig1~>sig2->sig1.OpWithArityn->Termsig2 (Finn)
Totality: total
Visibility: public export
H : sig1~>sig2->sig1.OpWithArityn->Termsig2 (Finn)
Totality: total
Visibility: public export
OpTranslation : (sig1.OpWithArityn->sig2.OpWithArityn) ->sig1~>sig2
Totality: total
Visibility: public export
cast : sig1~>sig2=>Termsig1a->Termsig2a
Totality: total
Visibility: public export
castTerms : sig1~>sig2->Vectk (Termsig1a) ->Vectk (Termsig2a)
Totality: total
Visibility: public export