Allocating a list of arrays #
allocAll l allocates the arrays of l in turn, each with the capacity its expression gives.
When the expressions read only locals (Expr.noLoad), they evaluate the same throughout, and
the result is exact (exec_allocAll): each listed array has its capacity and reads 0, every other
array is unchanged, and so are the locals.
The expression reads no array.
Equations
Instances For
The static instruction cost of allocating the listed arrays.
Equations
- OrderMaintenance.Machine.allocCost l = (List.map (fun (ae : OrderMaintenance.Machine.Arr × OrderMaintenance.Machine.Expr) => 1 + ae.snd.cost) l).sum + 1
Instances For
theorem
OrderMaintenance.Machine.exec_allocAll
(l : List (Arr × Expr))
(s : State)
:
(∀ (ae : Arr × Expr), ae ∈ l → ae.snd.noLoad = true ∧ (Expr.eval s ae.snd).isSome = true) →
(List.map Prod.fst l).Nodup →
(exec (allocAll l) s).status = Status.ok ∧ (exec (allocAll l) s).cost = allocCost l ∧ (exec (allocAll l) s).st.loc = s.loc ∧ (∀ (ae : Arr × Expr),
ae ∈ l →
(exec (allocAll l) s).st.cap ae.fst = (Expr.eval s ae.snd).getD 0 ∧ ∀ (i : Nat), (exec (allocAll l) s).st.mem ae.fst i = 0) ∧ ∀ (b : Arr), ¬b ∈ List.map Prod.fst l → Same b s (exec (allocAll l) s).st
Allocating a list of arrays.
The cost of straight-line code #
The cost of straight-line code, read off its syntax (none for branches, loops, calls).
Equations
- OrderMaintenance.Machine.Stmt.skip.slCost = some 1
- (x_1 ::= e).slCost = some (1 + e.cost)
- (OrderMaintenance.Machine.Stmt.store a i e).slCost = some (1 + i.cost + e.cost)
- (OrderMaintenance.Machine.Stmt.alloc a n).slCost = some (1 + n.cost)
- (c;; d).slCost = c.slCost.bind fun (a : Nat) => Option.map (fun (x : Nat) => a + x) d.slCost
- x✝.slCost = none
Instances For
Storing a list of values into one array #
theorem
OrderMaintenance.Machine.exec_storeAll
(a : Arr)
(l : List (Nat × Expr))
(s : State)
:
(∀ (ie : Nat × Expr), ie ∈ l → ie.snd.noLoad = true ∧ (Expr.eval s ie.snd).isSome = true ∧ ie.fst < s.cap a) →
(exec (storeAll a l) s).status = Status.ok ∧ (exec (storeAll a l) s).st.loc = s.loc ∧ (exec (storeAll a l) s).st.cap = s.cap ∧ (exec (storeAll a l) s).st.mem a = storeFold s (s.mem a) l ∧ ∀ (b : Arr), b ≠ a → (exec (storeAll a l) s).st.mem b = s.mem b
Storing a list of values into one array.