Documentation

CslibFrontier.DataStructure.StateTransition.Module

Compositional semantic implementations #

A module implements one interface using operations of another. Linking uses the upstream free-monad interpreter. Behavior proofs neither choose a computational model nor assign costs. Module.realize composes representation relations and hides intermediate states existentially. Linking uses the upstream interpreter's common universe for operation answers and client results. Native execution itself permits an independent universe for client results.

Main definitions #

Main results #

References #

@[reducible, inline]

Interface methods are programs over another interface.

Instances For
    structure Cslib.DataStructure.Module (D E : StateTransitionSpec) :
    Type (max (max u v) w)

    Purely semantic module correctness over relational specifications; neither an execution model nor a cost appears.

    • methods : Methods D E

      Bodies implementing the upper interface using lower-interface calls.

    • rep : D.State → E.State → Prop

      The relation between upper and lower mathematical states.

    • valid {s : D.State} {e : E.State} (o : D.Op) : self.rep s e → D.valid s o → E.DemonicValid e (self.methods o)

      Demonic admissibility of each method body from related states.

    • correct {s : D.State} {e : E.State} (o : D.Op) {a : D.Result o} {e' : E.State} {tr : E.Transcript} : self.rep s e → D.valid s o → E.ClientRun e (self.methods o) a e' tr → ∃ (s' : D.State), D.step s o s' a ∧ self.rep s' e'

      Angelic correctness of each method body: every lower ClientRun realizes some permitted upper step D.step s o s' a maintaining rep s' e'.

    Instances For
      @[reducible, inline]
      abbrev Cslib.DataStructure.Module.ofFn {D E : StateTransitionSpec} {fD : D.State → (o : D.Op) → D.State × D.Result o} {fE : E.State → (o : E.Op) → E.State × E.Result o} [D.HasStepFn fD] [E.HasStepFn fE] (methods : Methods D E) (rep : D.State → E.State → Prop) (valid : ∀ {s : D.State} {e : E.State} (o : D.Op), rep s e → D.valid s o → E.ValidHistory e (E.clientHistory e (methods o))) (correct : ∀ {s : D.State} {e : E.State} (o : D.Op), rep s e → D.valid s o → E.clientResult e (methods o) = (D.stepFn s o).2 ∧ rep (D.stepFn s o).1 (E.clientState e (methods o))) :
      Module D E

      Construct a Module D E for deterministic specifications ([D.HasStepFn fD], [E.HasStepFn fE]) from functional ValidHistory and runClient obligations.

      Instances For
        def Cslib.DataStructure.Module.realize {D E : StateTransitionSpec} {C τ : Type x} (M : Module D E) {exec : Execution E.signature C τ} (R : StateTransitionImpl E exec) :
        StateTransitionImpl D fun (c : C) (o : D.signature.A) (a : D.signature.B o) (c' : C) (ts : List τ) => Executes exec (M.methods o) c a c' ts

        Module implementation hides the intermediate representation and composes at any backend.

        Instances For