Documentation

DY.Trace.Manipulation

class DY.WP [ExecTraceTypes] [ProofTraceTypes] (m : Type u → Type v) :
Type (max (u + 1) v)
Instances
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations
    • One or more equations did not get rendered due to their size.
    @[instance_reducible]
    Equations
    • One or more equations did not get rendered due to their size.
    def DY.hoareTriple {m : Type u_1 → Type u_2} {a : Type u_1} [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] [WP m] (f : m a) (pre : ProofTraceProp) (post : aProofTraceProp) :
    Equations
    Instances For
      class DY.HasGhostArgumentType {a : Sort u_1} (x : a) (g : outParam (Type u_g)) :

      This typeclass notifies the step tactic that the hoare triple for x expects a ghost parameter of type g. Knowing this type is crucial to provide useful error message when a user provides a ghost parameter with the wrong type.

      Instances

        Some ghost parameters can be found automatically by looking into the context. This structure holds a metaprogram which is called with a metavariable for the ghost parameter, and the expression corresponding to the hoare triple that requires the ghost parameter. It is expected to assign the ghost parameter metavariable.

        Instances For
          class DY.HasGhostMetaprogram {a : Sort u_1} (x : a) (metaprog : outParam GhostParameterFinder) :

          This typeclass notifies the step tactic that metaprog can automatically find the ghost parameter of the the hoare triple associated with x. For technical reasons, metaprog must be a top-level declaration, it cannot be written inline in the declaration. This is to prevent it to depend on local variables specific to this instance.

          Instances
            class DY.HasIndirectGhostMetaprogram {a : Sort u_1} {b : outParam (Sort u_2)} (x : a) (metaprog : outParam GhostParameterFinder) (y : outParam b) :

            Some hoare triples are derived from others, for example we can create a hoare triple for lift x given a hoare triple for x. In this case, both hoare triple use the same ghost parameter, but the metaprogram that finds the ghost parameter for x won't work if we feed it lift x instead of x. To solve this issue, HasIndirectGhostMetaprogram x metaprog y notifies the step tactic that metaprog is expected to be called with the expression of y instead of the expression of x.

            Instances
              class DY.HoareTripleGhost {m : Type u_1 → Type u_2} {a : Type u_1} {g : Type u_3} [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] [WP m] (f : m a) [HasGhostArgumentType f g] (ghost : g) (pre : outParam (ProofTraceProp)) (post : outParam (aProofTraceProp)) :
              Instances
                class DY.HoareTriple {m : Type u_1 → Type u_2} {a : Type u_1} [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] [WP m] (f : m a) (pre : outParam (ProofTraceProp)) (post : outParam (aProofTraceProp)) :
                Instances
                  @[instance_reducible]
                  instance DY.instHasGhostArgumentTypeUnitOfHoareTriple [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {m : Type u → Type v} [WP m] {a : Type u} (f : m a) (pre : ProofTraceProp) (post : aProofTraceProp) [HoareTriple f pre post] :
                  Equations
                  instance DY.instHoareTripleGhostUnitUnit [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {m : Type u → Type v} [WP m] {a : Type u} (f : m a) (pre : ProofTraceProp) (post : aProofTraceProp) [HoareTriple f pre post] :
                  HoareTripleGhost f () pre post
                  class DY.WPLift [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] (m : Type u → Type v) (n : Type u → Type w) [MonadLift m n] [WP m] [WP n] :
                  Instances
                    @[instance_reducible]
                    instance DY.instHasGhostArgumentTypeLiftM {m : Type u → Type v} {n : Type u → Type w} [MonadLift m n] {a : Type u} {g : Type u_g} (x : m a) [HasGhostArgumentType x g] :
                    Equations
                    @[instance_reducible]
                    instance DY.instHasIndirectGhostMetaprogramLiftM {metaprog : GhostParameterFinder} {m : Type u → Type v} {n : Type u → Type w} [MonadLift m n] {a : Type u} {b : Type z} (x : m a) (y : b) [HasIndirectGhostMetaprogram x metaprog y] :
                    Equations
                    instance DY.instHoareTripleGhostLiftMOfWPLift [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {m : Type u → Type v} {n : Type u → Type w} [MonadLift m n] [WP m] [WP n] [wplift : WPLift m n] {a : Type u} {g : Type u_g} (x : m a) (ghost : g) (pre : ProofTraceProp) (post : aProofTraceProp) [HasGhostArgumentType x g] [ht : HoareTripleGhost x ghost pre post] :
                    HoareTripleGhost (liftM x) ghost pre post
                    theorem DY.Traceful.bind_wp [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {a b : Type} {g : Type u_1} (ghost : g) (x : Traceful a) (f : aTraceful b) (post_f : bProofTraceProp) (tr : ProofTrace) {pre_x : ProofTraceProp} {post_x : aProofTraceProp} [HasGhostArgumentType x g] [ht : HoareTripleGhost x ghost pre_x post_x] (pf_tr_inv : Trace.Invariant tr) (pf_pre_x : pre_x tr) (pf_next : ∀ (tr_mid : ProofTrace) (x' : a), post_x x' tr_midTrace.Invariant tr_midtr tr_midwp (f x') post_f tr_mid) :
                    wp (x >>= f) post_f tr
                    theorem DY.Traceful.finish_wp [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {a : Type} {g : Type u_1} (ghost : g) (x : Traceful a) (post : aProofTraceProp) (tr : ProofTrace) {pre_x : ProofTraceProp} {post_x : aProofTraceProp} [HasGhostArgumentType x g] [ht : HoareTripleGhost x ghost pre_x post_x] (pf_tr_inv : Trace.Invariant tr) (pf_pre_x : pre_x tr) (pf_next : ∀ (tr_mid : ProofTrace) (x' : a), post_x x' tr_midTrace.Invariant tr_midtr tr_midpost x' tr_mid) :
                    wp x post tr
                    class DY.HoareTriplePureGhost {a : Sort u_1} {g : Type u_2} [ExecTraceTypes] [ProofTraceTypes] (x : a) [HasGhostArgumentType x g] (ghost : g) (pre : outParam (ProofTraceProp)) (post : outParam (aProofTraceProp)) :
                    Instances
                      class DY.HoareTriplePure {a : Sort u_1} [ExecTraceTypes] [ProofTraceTypes] (x : a) (pre : outParam (ProofTraceProp)) (post : outParam (aProofTraceProp)) :
                      Instances
                        @[instance_reducible]
                        Equations
                        instance DY.instHoareTriplePureGhostUnitUnit {a : Sort u_1} [ExecTraceTypes] [ProofTraceTypes] (x : a) (pre : ProofTraceProp) (post : aProofTraceProp) [HoareTriplePure x pre post] :
                        theorem DY.apply_hoare_triple_pure [ExecTraceTypes] [ProofTraceTypes] {a : Sort u_1} {g : Type u_2} (ghost : g) (x : a) {pre : ProofTraceProp} {post : aProofTraceProp} [HasGhostArgumentType x g] [ht : HoareTriplePureGhost x ghost pre post] (tr : ProofTrace) (p : pre tr) :
                        post x tr
                        instance DY.instHoareTripleGhostTracefulUnitGuardEqBoolTrueOfHoareTriplePureGhost {g : Type u_1} {ghost : g} [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] (b : Bool) (pre : ProofTraceProp) (post : BoolProofTraceProp) [HasGhostArgumentType b g] [ht : HoareTriplePureGhost b ghost pre post] :
                        HoareTripleGhost (guard (b = true)) ghost (fun (tr : ProofTrace) => pre tr) fun (x : Unit) (tr : ProofTrace) => post true tr
                        instance DY.instHoareTripleTracefulPureTrueEq {a : Type} {x : a} [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] :
                        HoareTriple (pure x) (fun (x : ProofTrace) => True) fun (res : a) (x_1 : ProofTrace) => res = x
                        def DY.appendEntry [ExecTraceTypes] {EntryT : Type} [ExecTraceTypes.Has EntryT] (entry : EntryT) :
                        Equations
                        Instances For
                          instance DY.appendEntry.spec [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {ExecEntryT ProofEntryT : Type} [ExecEntryAssociatedWithProofEntry ExecEntryT ProofEntryT] [ErasableProofEntry ExecEntryT ProofEntryT] [SubTraceInvariant ProofEntryT] [ExecTraceTypes.Has ExecEntryT] [ProofTraceTypes.Has ProofEntryT] [TraceInvariant.Has ProofEntryT] (execEntry : ExecEntryT) (mkProofEntry : NatProofEntryT) :
                          HoareTripleGhost (appendEntry execEntry) mkProofEntry (fun (tr : ProofTrace) => ∀ (time : Nat), ErasableProofEntry.erase (mkProofEntry time) = execEntry SubTraceInvariant.invariant tr (mkProofEntry time)) fun (time : Nat) (tr : ProofTrace) => Trace.at? tr time = some (mkProofEntry time)
                          def DY.getEntry [ExecTraceTypes] {EntryT : Type} [ExecTraceTypes.Has EntryT] (timestamp : Nat) :
                          Traceful EntryT
                          Equations
                          Instances For
                            instance DY.getEntry.spec [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {ExecEntryT ProofEntryT : Type} [ExecEntryAssociatedWithProofEntry ExecEntryT ProofEntryT] [ErasableProofEntry ExecEntryT ProofEntryT] [SubTraceInvariant ProofEntryT] [ExecTraceTypes.Has ExecEntryT] [ProofTraceTypes.Has ProofEntryT] [TraceInvariant.Has ProofEntryT] (timestamp : Nat) :
                            HoareTriple (getEntry timestamp) (fun (x : ProofTrace) => True) fun (entry : ExecEntryT) (tr : ProofTrace) => (proofEntry : ProofEntryT), entry = ErasableProofEntry.erase proofEntry SubTraceInvariant.invariant (Trace.prefix tr timestamp) proofEntry
                            theorem DY.getEntry.preservesReachability [ExecTraceTypes] {ExecEntryT : Type} [ExecTraceTypes.Has ExecEntryT] (config : ReachabilityConfig) (timestamp : Nat) :
                            Traceful.PreservesReachability config (getEntry timestamp) (fun (x : ExecTrace) => True) fun (entry : ExecEntryT) (tr : ExecTrace) => Trace.at? tr timestamp = some entry
                            structure DY.LoopInvariantAndProof' [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {α : Type} {xs : List α} {β : Type} (f : (a : α) → a xsβTraceful (ForInStep β)) :
                            Instances For
                              instance DY.forIn'.spec [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {α β : Type} (xs : List α) (init : β) {f : (a : α) → a xsβTraceful (ForInStep β)} (invAndProof : LoopInvariantAndProof' f) :
                              HoareTripleGhost (forIn' xs init f) invAndProof (invAndProof.inv ({ «prefix» := [], suffix := xs, property := }, init)) fun (b : β) => invAndProof.inv ({ «prefix» := xs, suffix := [], property := }, b)
                              structure DY.LoopInvariantAndProof [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {α : Type} (xs : List α) {β : Type} (f : αβTraceful (ForInStep β)) :
                              Instances For
                                instance DY.forIn.spec [ExecTraceTypes] [ProofTraceTypes] [TraceInvariant] {α β : Type} (xs : List α) (init : β) {f : αβTraceful (ForInStep β)} (invAndProof : LoopInvariantAndProof xs f) :
                                HoareTripleGhost (forIn xs init f) invAndProof (invAndProof.inv ({ «prefix» := [], suffix := xs, property := }, init)) fun (b : β) => invAndProof.inv ({ «prefix» := xs, suffix := [], property := }, b)