Documentation

Strata.Transform.WP.WPOverFacts

Facts about WP walk results #

Facts relating the result of a WP walk (wpList, wpStmt, wpIteLaid, wpIteReal) to the walk state and to the loop-free runs of the walked fragment:

A successful walk of a laid-out ite has the steps of LaidSteps (wpIteLaid_inv), stated as an elimination principle so that each proof about such a walk starts from its steps.

The facts about runs and dead names need the names marked dead to have counters below the state's counter (DeadBelow, defined with the walk facts), which every walk keeps (wpList_deadBelow) and a state without dead names has (deadBelow_of_dead_empty).

Key theorems: wpStmt_drop, wpList_drop, wpList_hit_hasObl, noObl_claim, wpStmt_ax_normal, wpList_regs, wpList_regs_live, body_snaps_regs, wpList_regs_one_label, pending_regs, wpList_deadBelow, wpStmt_carries, body_carries, body_carries_names, wpIteLaid_inv.

Key definitions: NewIn, wsimple, wvars, LaidSteps.

State changes of walks #

def Imperative.WP.NewIn {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] (s s' : WSt P) (n : P.Ident) :

n is a fresh name drawn between the states s and s': not avoided, with a counter from s.next on and below s'.next.

Equations
Instances For
    theorem Imperative.WP.NewIn.widen {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] {s0 s1 s2 s3 : WSt P} {n : P.Ident} (h : NewIn s1 s2 n) (ha : s1.avoid = s0.avoid) (h0 : s0.next ≤ s1.next) (h3 : s2.next ≤ s3.next) :
    NewIn s0 s3 n

    A name drawn between two states is drawn between any wider pair of states.

    Runs of the state primitives #

    Closes the result goal of a pure step of a Good decomposition.

    Equations
    Instances For

      A one-element rope is not empty.

      theorem Imperative.WP.wfSt_blk {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] {st : WSt P} (hwf : WFSt st) (l : String) (d c : Nat) :
      WFSt { next := st.next, avoid := st.avoid, nm := st.nm, taken := st.taken, back := st.back, tys := st.tys, tyOf := st.tyOf, live := st.live, clock := st.clock, pending := st.pending.insert l [], labelDepth := st.labelDepth.insert l (d + 1), stampAt := st.stampAt.insert (d + 1) c, carries := st.carries.insert (d + 1) [], dead := st.dead }

      The walk state a block's body is walked from is well formed when the block's is.

      theorem Imperative.WP.foldl_insert_fst {P : PureExpr} [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHa : Hashable P.Ident] {L : List (P.Ident × WExpr P × P.Ident)} {g : Std.HashSet P.Ident → P.Ident × WExpr P × P.Ident → Std.HashSet P.Ident} (hg : ∀ (s : Std.HashSet P.Ident) (e : P.Ident × WExpr P × P.Ident), g s e = s.insert e.fst) {A : Std.HashSet P.Ident} {x : P.Ident} (h : (List.foldl g A L).contains x = true) :

      A name is in a hash set after inserting the first components of a list exactly when it was before or is the first component of an element.

      theorem Imperative.WP.fold_filter_mem {P : PureExpr} [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHa : Hashable P.Ident] {A : Std.HashSet P.Ident} {c : P.Ident → Bool} {t : Bool} {x : P.Ident} (h : x ∈ if t = true then Std.HashSet.fold (fun (l : List P.Ident) (y : P.Ident) => if c y = true then y :: l else l) [] A else []) :

      An element of a filtering fold over a hash set is an element of the set.

      theorem Imperative.WP.foldl_insert_contains {P : PureExpr} [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHa : Hashable P.Ident] (L : List P.Ident) (D : Std.HashSet P.Ident) (e : P.Ident) :
      (List.foldl (fun (x1 : Std.HashSet P.Ident) (x2 : P.Ident) => x1.insert x2) D L).contains e = true ↔ D.contains e = true ∨ e ∈ L

      A name is in a hash set after inserting the names of a list exactly when it was before or is in the list.

      theorem Imperative.WP.unionSet_contains {P : PureExpr} [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHa : Hashable P.Ident] (a b : Std.HashSet P.Ident) (x : P.Ident) :

      A name is in the union of two hash sets exactly when it is in one of them.

      The variables of an expression of the guarded program built without loop-free expressions.

      Equations
      Instances For

        A concatenation fold is empty exactly when its start and all its operands are.

        def Imperative.WP.OptDraw {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] (b : String) (s s' : WSt P) :

        An optionally drawn name: none leaves the state unchanged, some x is drawn by wFreshBool b.

        Equations
        Instances For

          The variable of an optional guard name, false without one.

          Equations
          Instances For
            def Imperative.WP.carryOf {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] (st : WSt P) (cps : List (P.Ident × P.Ident)) :

            The copy pairs of cps whose carried merges an arm registers when o is the largest target depth of its exits: the pairs whose variable is live in st before the clock at which the walk entered the block at that depth.

            Equations
            Instances For

              The carried merges C after registering at the depth o (if any) the merges (x, ite(e, xB, x), xB) of the copy pairs (x, xB) of cps.

              Equations
              Instances For
                def Imperative.WP.elseGuard {P : PureExpr} (κ : RE P) (gm qm rEm : Option P.Ident) :

                The guard of the carried merges of the else arm of a laid-out ite under the context κ, with the optional merge guard gm and the optional else-arm carry guards qm, rEm.

                Equations
                Instances For
                  def Imperative.WP.LaidElseCtx {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] (κ : RE P) (g : P.Ident) (s3 : WSt P) (κE : RE P) (rE : Option P.Ident) (s4 : WSt P) :

                  The context of the else arm of a laid-out ite under κ, with guard g, drawn from s3 to s4: neg g under top, andNeg q g under name q, otherwise name x for a reach x drawn for it, recorded in rE.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Imperative.WP.LaidSteps {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] (κ : RE P) (d : Nat) (c : P.Expr) (tss ess : BigStep.PStmts P) (s : WSt P) (r : WRes P) (s' : WSt P) :

                    The steps of a successful run of a laid-out ite from s to s' with result r, as an elimination principle (every Q that follows from the steps holds): the renaming of the condition, the draws of the guard g and of the then-arm reach rT, the else-arm context κE (LaidElseCtx), the runs of the arms, the three save/restore steps, the optional draws of the merge guard gm (drawn exactly when needGm holds) and of the else-arm carry guards qm (drawn exactly under name q when the else arm carries merges) and rEm (drawn exactly when the else arm has a reach rE and carries merges), the registrations of the carried merges, and the result.

                    Instances For
                      theorem Imperative.WP.wpIteLaid_inv {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {c : P.Expr} {tss ess : BigStep.PStmts P} {s s' : WSt P} {r : WRes P} (h : StateT.run (wpIteLaid κ d c tss ess) s = Except.ok (r, s')) :
                      LaidSteps κ d c tss ess s r s'

                      Every successful run of a laid-out ite has the steps of LaidSteps.

                      theorem Imperative.WP.carryOf_sub {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] {st : WSt P} {cps : List (P.Ident × P.Ident)} {o : Option Nat} {p : P.Ident × P.Ident} (h : p ∈ carryOf st cps o) :
                      p ∈ cps

                      The registered copy pairs are copy pairs.

                      theorem Imperative.WP.carryIns_getD {P : PureExpr} (e : WExpr P) (cps : List (P.Ident × P.Ident)) (C : Std.HashMap Nat (List (P.Ident × WExpr P × P.Ident))) (o : Option Nat) (k : Nat) :
                      ∃ (new : List (P.Ident × WExpr P × P.Ident)), (carryIns e cps C o).getD k [] = new ++ C.getD k [] ∧ ∀ (q : P.Ident × WExpr P × P.Ident), q ∈ new → o = some k ∧ ∃ (p : P.Ident × P.Ident), p ∈ cps ∧ q = (p.fst, e.ite (WExpr.var p.snd) (WExpr.var p.fst), p.snd)

                      The carried merges at depth k after carryIns e cps C o are new merges in front of those of C, the merges (x, ite(e, xB, x), xB) of copy pairs (x, xB) of cps, when o is some k.

                      theorem Imperative.WP.wpList_run_cons {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {s : BigStep.PStmt P} {rest : BigStep.PStmts P} {st st' : WSt P} {R : WRes P} (h : StateT.run (wpList κ d fEnd (s :: rest)) st = Except.ok (R, st')) :
                      ∃ (r : WRes P), ∃ (st1 : WSt P), ∃ (a : WRes P), ∃ (st2 : WSt P), StateT.run (wpList κ d fEnd rest) st = Except.ok (r, st1) ∧ StateT.run (wpStmt κ d (r.hasObl || fEnd && !r.drop) s) st1 = Except.ok (a, st2) ∧ (a.drop = true ∧ a = R ∧ st2 = st' ∨ a.drop = false ∧ a.ax = true ∧ a = R ∧ { next := st2.next, avoid := st2.avoid, nm := st2.nm, taken := st2.taken, back := st2.back, tys := st2.tys, tyOf := st2.tyOf, live := st2.live, clock := st2.clock, pending := st2.pending, labelDepth := st2.labelDepth, stampAt := st2.stampAt, carries := st2.carries, dead := List.foldl (fun (x1 : Std.HashSet P.Ident) (x2 : P.Ident) => x1.insert x2) st2.dead r.regs.toList } = st' ∨ a.drop = false ∧ a.ax = false ∧ a.combine r = R ∧ st2 = st')

                      A successful walk of s :: rest walks rest, then s with the obligation bit of the rest, and returns the result of s alone (after a drop, or after marking the registrations of the rest dead when s always exits) or the combination of both results.

                      Drops #

                      theorem Imperative.WP.wpStmt_drop {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {f : Bool} {s : BigStep.PStmt P} {st st' : WSt P} {a : WRes P} (h : StateT.run (wpStmt κ d f s) st = Except.ok (a, st')) (hd : a.drop = true) :

                      Only a main-list exit (under the reach context top) drops the rest of its list.

                      theorem Imperative.WP.wpList_drop {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hd : r.drop = true) :

                      A list walk that drops the rest of an enclosing list is under the reach context top.

                      The walk facts #

                      theorem Imperative.WP.DeadBelow.of_le {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] {st st' : WSt P} (hd : DeadBelow st) (h1 : st'.dead = st.dead) (h2 : st.next ≤ st'.next) :

                      DeadBelow holds after a change keeping the dead names and not decreasing the counter.

                      Runs: normal ends, exit snapshots and reachable failures #

                      An outcome projected to an exit is an exit to the same label.

                      A body outcome that a block labelled l' turns into an exit to l is an exit to l ≠ l'.

                      The facts as stated for the users #

                      theorem Imperative.WP.deadBelow_of_dead_empty {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] {st : WSt P} (h : st.dead = ∅) :

                      A walk state with no dead name has DeadBelow.

                      theorem Imperative.WP.wpList_deadBelow {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hD : DeadBelow st) :

                      A list walk keeps DeadBelow.

                      theorem Imperative.WP.wpStmt_regs {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {f : Bool} {s : BigStep.PStmt P} {st st' : WSt P} {a : WRes P} (h : StateT.run (wpStmt κ d f s) st = Except.ok (a, st')) (e : P.Ident) :

                      The registrations of a statement walk's result are fresh names drawn by the walk: not avoided, with counters from the input counter on and below the output counter.

                      theorem Imperative.WP.wpList_regs {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (e : P.Ident) :

                      The registrations of a list walk's result are fresh names drawn by the walk: not avoided, with counters from the input counter on and below the output counter.

                      theorem Imperative.WP.wpList_pending_new {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) {l : String} {e : P.Ident} (he : e ∈ st'.pending.getD l []) :

                      An exit snapshot registered for a label after a list walk was registered before it or is a fresh name drawn by the walk.

                      theorem Imperative.WP.pending_regs {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd f : Bool} {s : BigStep.PStmt P} {rest : BigStep.PStmts P} {st st1 st2 : WSt P} {r a : WRes P} (h1 : StateT.run (wpList κ d fEnd rest) st = Except.ok (r, st1)) (h2 : StateT.run (wpStmt κ d f s) st1 = Except.ok (a, st2)) {l : String} {e : P.Ident} (he : e ∈ r.regs.toList) (hp : e ∈ st2.pending.getD l []) :
                      e ∈ st1.pending.getD l []

                      After the walks of rest and then of s, a registration of rest registered for a label was registered for it before the walk of s.

                      theorem Imperative.WP.wpStmt_dead {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {f : Bool} {s : BigStep.PStmt P} {st st' : WSt P} {a : WRes P} (h : StateT.run (wpStmt κ d f s) st = Except.ok (a, st')) (e : P.Ident) :

                      A statement walk keeps the names marked dead, and marks dead only fresh names it draws.

                      theorem Imperative.WP.wpStmt_ax_normal {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {s : BigStep.PStmt P} {st st' : WSt P} {a : WRes P} (h : StateT.run (wpStmt κ d true s) st = Except.ok (a, st')) (hD : DeadBelow st) {F : P.Factory} {X : BigStep.Outcome P → Prop} {σ σ1 : SemanticStore P} {evs : List (Event P)} (hr : DRunS F X s σ evs (BigStep.Outcome.normal σ1)) :

                      A statement walked with an obligation following it (from a state with DeadBelow) that has a normal run does not always exit.

                      theorem Imperative.WP.wpStmt_hit_hasObl {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {f : Bool} {s : BigStep.PStmt P} {st st' : WSt P} {a : WRes P} (h : StateT.run (wpStmt κ d f s) st = Except.ok (a, st')) (hD : DeadBelow st) {F : P.Factory} {σ : SemanticStore P} {tr : List (Event P)} {t : AssertId P} {e : P.Expr} (hr : DReachS F s σ tr) (hc : BigStep.Claim t e tr) :

                      A statement walk (from a state with DeadBelow) of a statement with a reach of a failing target has an obligation.

                      theorem Imperative.WP.wpList_hit_hasObl {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hD : DeadBelow st) {F : P.Factory} {σ : SemanticStore P} {tr : List (Event P)} {t : AssertId P} {e : P.Expr} (hr : DReach F ss σ tr) (hc : BigStep.Claim t e tr) :

                      A list walk (from a state with DeadBelow) of a list with a reach of a failing target has an obligation.

                      theorem Imperative.WP.noObl_claim {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hD : DeadBelow st) (hobl : r.hasObl = false) {F : P.Factory} {σ : SemanticStore P} {tr : List (Event P)} {t : AssertId P} {e : P.Expr} (hr : DReach F ss σ tr) (hc : BigStep.Claim t e tr) :

                      A list walk (from a state with DeadBelow) whose result has no obligation reaches no failing target of the list.

                      Registrations, snapshots and dead names #

                      theorem Imperative.WP.wpList_regs_live {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hD : DeadBelow st) (e : P.Ident) :

                      The registrations of a list walk's result (from a state with DeadBelow) are not dead after the walk.

                      theorem Imperative.WP.body_snaps_regs {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} (hκ : κ ≠ RE.top) {d : Nat} {fEnd : Bool} {l : String} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (hp : st.pending.getD l [] = []) (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (e : P.Ident) :
                      e ∈ (List.filter (fun (e : P.Ident) => !st'.dead.contains e) (st'.pending.getD l [])).reverse → e ∈ r.regs.toList

                      For the walk of a block's body under a variable context, from a state with no snapshot for the block's label: the snapshots for the label that are not dead after the walk are registrations of the body.

                      Snapshots under one label #

                      theorem Imperative.WP.wpList_regs_one_label {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hP : ∀ (l : String) (e : P.Ident), e ∈ st.pending.getD l [] → ∀ (b : String) (j : Nat), e = freshName b j → j < st.next) (e : P.Ident) :
                      e ∈ r.regs.toList → ∀ (l1 l2 : String), e ∈ st'.pending.getD l1 [] → e ∈ st'.pending.getD l2 [] → l1 = l2

                      A registration of a list walk's result, from a state whose snapshots of fresh-name form have counters below its counter, is registered after the walk for at most one label.

                      Carried merges #

                      theorem Imperative.WP.arm_exitTgt {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d true ss) st = Except.ok (r, st')) (hκ : κ ≠ RE.top) (hD : DeadBelow st) (hL : ∀ (l : String) (t : Nat), st.labelDepth[l]? = some t → t ≤ d) {F : P.Factory} {X : BigStep.Outcome P → Prop} {σ : SemanticStore P} {evs : List (Event P)} {l : String} {σ1 : SemanticStore P} (hr : DRun F X ss σ evs (BigStep.Outcome.exit l σ1)) {t : Nat} (ht : st.labelDepth[l]? = some t) :

                      An exit of an arm walk under a variable context with an obligation following (from a state with DeadBelow whose label depths are at most d) to a label of the region at depth t gives the walk a largest exit target K at least t, the depth of a label of the walk's input state.

                      theorem Imperative.WP.arm_carryDepth {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hwf : WFSt st) (hD : DeadBelow st) (hL : ∀ (l : String) (t : Nat), st.labelDepth[l]? = some t → t ≤ d) (hT : κ = RE.top → ∀ (l : String), st.labelDepth[l]? = none) {k i : Nat} {n : P.Ident} {v : WExpr P} {xB : P.Ident} (hi : (st'.carries.getD k [])[i]? = some (n, v, xB)) (hx : xB ∈ r.regs.toList) :

                      A carried merge registered by a list walk (from a well-formed state with DeadBelow whose label depths are at most d, with no label under top) lies at a depth at most the walk's largest exit target.

                      theorem Imperative.WP.wpStmt_carries {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd f : Bool} {s : BigStep.PStmt P} {rest : BigStep.PStmts P} {st st1 st2 : WSt P} {r a : WRes P} (hwf : WFSt st) (hL : ∀ (l : String) (t : Nat), st.labelDepth[l]? = some t → t ≤ d) (h1 : StateT.run (wpList κ d fEnd rest) st = Except.ok (r, st1)) (h2 : StateT.run (wpStmt κ d f s) st1 = Except.ok (a, st2)) (k : Nat) :
                      ∃ (pre : List (P.Ident × WExpr P × P.Ident)), (∀ (q : P.Ident × WExpr P × P.Ident), q ∈ pre → q.snd.snd ∈ a.regs.toList ∨ st2.dead.contains q.snd.snd = true) ∧ (st2.carries.getD k [] = pre ++ st1.carries.getD k [] ∨ ∀ (q : P.Ident × WExpr P × P.Ident), q ∈ st1.carries.getD k [] ++ st2.carries.getD k [] → ¬q.snd.snd ∈ r.regs.toList)

                      After the walks of rest and then of s at depth d (from a well-formed state whose label depths are at most d), at each block depth, the carried merges of the output state of s are new merges, with copies registered by s or dead, followed by those of its input state, or neither state has a carried merge registered by rest at that depth.

                      theorem Imperative.WP.body_carries {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} (hκ : κ ≠ RE.top) {d : Nat} {f : Bool} {body : BigStep.PStmts P} {stB st1 : WSt P} {B : WRes P} (hL : ∀ (l : String) (t : Nat), stB.labelDepth[l]? = some t → t ≤ d + 1) (hst : stB.carries.getD (d + 1) [] = []) (hB : StateT.run (wpList κ (d + 1) f body) stB = Except.ok (B, st1)) :
                      (∀ (e : P.Ident × WExpr P × P.Ident), e ∈ List.filter (fun (e : P.Ident × WExpr P × P.Ident) => !st1.dead.contains e.snd.snd) (st1.carries.getD (d + 1) []) → e.snd.snd ∈ B.regs.toList) ∧ ((∀ (k : Nat) (e : P.Ident × WExpr P × P.Ident), e ∈ stB.carries.getD k [] → ∃ (b : String), ∃ (j : Nat), e.snd.snd = freshName b j ∧ j < stB.next) → ∀ (k i : Nat) (n : P.Ident) (v : WExpr P) (xB : P.Ident), (st1.carries.getD k [])[i]? = some (n, v, xB) → xB ∈ B.regs.toList → k ≤ d + 1)

                      For the walk of a block's body at depth d + 1 under a variable context, from a state with no carried merge at depth d + 1 and label depths at most d + 1: the carried merges at depth d + 1 that are not dead after the walk have copies registered by the body; and, when the carried copies of the input state have counters below its counter, a carried merge whose copy is registered by the body is at a depth at most d + 1.

                      theorem Imperative.WP.wpIteReal_carries_eq {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {c : P.Expr} {tss ess : BigStep.PStmts P} {st st' : WSt P} {a : WRes P} (h : StateT.run (wpIteReal κ d c tss ess) st = Except.ok (a, st')) (k : Nat) (q : P.Ident × WExpr P × P.Ident) :
                      q ∈ st'.carries.getD k [] → q ∈ st.carries.getD k []

                      The carried merges after the walk of a real branch are those before it.

                      Assigned names, merge targets and selector variables #

                      theorem Imperative.WP.body_carries_names {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {f : Bool} {body : BigStep.PStmts P} {stB st1 : WSt P} {B : WRes P} {D : List P.Ident} (hw : WFSt stB) (hav : ∀ (x : P.Ident), x ∈ D → AvoidedIfFresh stB x) (hD : ∀ (x : P.Ident), x ∈ Block.idents body → x ∈ D) (hκ : ∀ (z : P.Ident), z ∈ κ.vars → (∃ (b : String), ∃ (j : Nat), z = freshName b j ∧ j < stB.next) ∧ stB.avoid.contains z = false ∧ stB.back[z]? = none) (hst : stB.carries.getD (d + 1) [] = []) (hB : StateT.run (wpList κ (d + 1) f body) stB = Except.ok (B, st1)) :
                      (∀ (e : P.Ident × WExpr P × P.Ident), e ∈ List.filter (fun (e : P.Ident × WExpr P × P.Ident) => !st1.dead.contains e.snd.snd) (st1.carries.getD (d + 1) []) → ¬e.fst ∈ B.regs.toList) ∧ (∀ (k i : Nat) (n : P.Ident) (v : WExpr P) (xB : P.Ident) (c : WExpr P), (st1.carries.getD k [])[i]? = some (n, v, xB) → xB ∈ B.regs.toList → v = c.ite (WExpr.var xB) (WExpr.var n) → wsimple c ∧ ∀ (y : P.Ident), y ∈ wvars c → ¬y ∈ List.map (fun (x : P.Ident × WExpr P × P.Ident) => x.fst) (List.filter (fun (e : P.Ident × WExpr P × P.Ident) => !st1.dead.contains e.snd.snd) (st1.carries.getD (d + 1) [])) ∧ ¬y ∈ κ.vars) ∧ ∀ (k i : Nat) (n : P.Ident) (v : WExpr P) (xB : P.Ident), (st1.carries.getD k [])[i]? = some (n, v, xB) → xB ∈ B.regs.toList → ¬n ∈ κ.vars

                      For the walk of a block's body at depth d + 1 from a well-formed state with no carried merge at depth d + 1, whose names of D (holding the body's identifiers) are avoided if they have the form of a fresh name, and whose reach context's variables are fresh names drawn before, not avoided and no renamings: the targets of the merges at depth d + 1 not dead after the walk are no registrations of the body; a carried merge whose copy is registered by the body has a selector built from variables, literals and conditionals, reading no such target and no variable of the context, and targets no variable of the context.

                      theorem Imperative.WP.wpList_carries_high {P : PureExpr} [iDE : DecidableEq P.Ident] [iBE : BEq P.Ident] [iLB : LawfulBEq P.Ident] [iHB : HasBool P] [iHF : HasFvar P] [iHS : HasSubstFvar P] [iHI : HasIdent P] [iL : LawfulHasIdent P] [iHa : Hashable P.Ident] [iHV : HasFvars P] [iW : WPOps P] {κ : RE P} {d : Nat} {fEnd : Bool} {ss : BigStep.PStmts P} {st st' : WSt P} {r : WRes P} (h : StateT.run (wpList κ d fEnd ss) st = Except.ok (r, st')) (hL : ∀ (l : String) (t : Nat), st.labelDepth[l]? = some t → t ≤ d) (k : Nat) :
                      d < k → ∀ (q : P.Ident × WExpr P × P.Ident), q ∈ st'.carries.getD k [] → q ∈ st.carries.getD k []

                      A list walk at depth d, from a state whose label depths are at most d, adds no carried merge at a depth below d.