Theorem W, option (A), stage A1: the peak of machine code #
Tools for the machine-only code (WrapM, RebuildM, OpsM, InitM, NewCore, Params,
Fresh), which runs outside the core language and so outside sim_peak.
- The peak is ghost (
exec_raise): raising the initial peak raises the final one and changes nothing else. So(exec c s).st.peak = max s.peak (dpk c s), wheredpk c sis the peak of the run fromswith the peak reset to 0: the largest value the run computes (peak_exec). This is how a statement about one operation is separated from the history (docs/WORD.md, option (A): status). wpB B c Q s:wpwith a peak budget:cterminates normally,Qholds, and every value the run computes is at mostB(precisely: the final peak is at mostmax s.peak B). Its rules mirror those ofwp(Logic.lean) and of the state-forgetting ruleswp_*_gused by the machine-only proofs; each adds one side condition per evaluated expression,maxv ≤ B.- The machine expression lemma (
Expr.wdM_sound): the analogue ofExp.wd_soundfor machine expressions, with a width per local and per array, stated only for the leaves the expression actually reads (Expr.LeafB), so that it applies to states with arbitrary other locals (the initial state oftheoremAB_Mis arbitrary).
Nothing here is used by Theorems A and B.
The peak is ghost #
The peak of a run from s with the peak reset: the largest value the run computes.
Equations
- OrderMaintenance.Machine.dpk c s = (OrderMaintenance.Machine.exec c { mem := s.mem, cap := s.cap, loc := s.loc, peak := 0 }).st.peak
Instances For
c terminates normally from s, Q holds, and every value it computes is at most B.
Equations
- OrderMaintenance.Machine.wpB B c Q s = OrderMaintenance.Machine.wp c (fun (s' : OrderMaintenance.Machine.State) (n : ℕ) => s'.peak ≤ max s.peak B ∧ Q s' n) s
Instances For
The loop rule with a budget: the bound's peak and every iteration's within B. The invariant
carries the peak bound of the states it describes.
Widths of machine expressions #
The width of a machine expression's value: Γ x for a local, A a for a cell of array a,
n for a literal, the operations as in Exp.wv.
Equations
- One or more equations did not get rendered due to their size.
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.lit n) = n
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.var x_1) = Γ x_1
- OrderMaintenance.Machine.Expr.wvM Γ A S a[[i]] = A a
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.sub a b) = OrderMaintenance.Machine.Expr.wvM Γ A S a
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.div a b) = OrderMaintenance.Machine.Expr.wvM Γ A S a
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.mod a b) = OrderMaintenance.Machine.Expr.wvM Γ A S a
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.shr a b) = OrderMaintenance.Machine.Expr.wvM Γ A S a
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.shl a b) = OrderMaintenance.Machine.Expr.wvM Γ A S a + S
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.lt a b) = 1
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.le a b) = 1
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.eq a b) = 1
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.and a b) = 1
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.bin OrderMaintenance.Machine.BinOp.or a b) = 1
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.un OrderMaintenance.Machine.UnOp.not a) = 1
- OrderMaintenance.Machine.Expr.wvM Γ A S (OrderMaintenance.Machine.Expr.un OrderMaintenance.Machine.UnOp.msb a) = OrderMaintenance.Machine.Expr.wvM Γ A S a
Instances For
The width of a machine expression's peak (maxv).
Equations
- One or more equations did not get rendered due to their size.
- OrderMaintenance.Machine.Expr.wpM Γ A S (OrderMaintenance.Machine.Expr.lit n) = n
- OrderMaintenance.Machine.Expr.wpM Γ A S (OrderMaintenance.Machine.Expr.var x_1) = Γ x_1
- OrderMaintenance.Machine.Expr.wpM Γ A S a[[i]] = max (OrderMaintenance.Machine.Expr.wpM Γ A S i) (A a)
Instances For
The leaves an expression reads are small in s: each local it reads below 2^(Γ x), each
cell it loads below 2^(A a), and each shift amount at most S.
Equations
- One or more equations did not get rendered due to their size.
- OrderMaintenance.Machine.Expr.LeafB s Γ A S (OrderMaintenance.Machine.Expr.lit n) = True
- OrderMaintenance.Machine.Expr.LeafB s Γ A S (OrderMaintenance.Machine.Expr.var x_1) = (s.loc x_1 < 2 ^ Γ x_1)
- OrderMaintenance.Machine.Expr.LeafB s Γ A S (OrderMaintenance.Machine.Expr.un op a) = OrderMaintenance.Machine.Expr.LeafB s Γ A S a