Linear-time simplification for chained and conditional Function.update #
Word-RAM specifications frequently evaluate deep chains of Function.update (and conditional
updates if p then Function.update f a v else f) at a query address k. Simplifying such terms
with split_ifs <;> repeat rw [Function.update_of_ne (by omega)] triggers an exponential 2^n
case split on unrelated conditional writes and generates dozens of redundant omega proofs.
update_simp peels both unconditional and conditional Function.update layers in a single
linear top-down pass without splitting if branches:
Function.update f a v k: rewrites tovifk = aholds, and tof kifk ≠ aholds.(if p then Function.update f a v else f) k: under the branch assumptionhp : p, checksk ≠ aand collapses directly tof kwithout splitting onp(essential whenpguards an in-bounds address check such asq_b < dirSlabsPerBucket n_max).(if p then Function.update f a v else g) k: drops the update inside thethenbranch whenp → k ≠ a(leaving(if p then f else g) k), or simplifies directly whenpis provably true/false, or collapsesif p then f else ftof. Symmetric rule handles theelsebranch.- Preserves
let-sharing for nested maps (let gm₁ := ...; let gm₂ := ...) by peeling one head binding at a time instead of eagerly zeta-reducing, keeping proof and term sizesO(depth). - Silently discharges index equality/disequality and guard truth/falsity via local hypotheses,
isDefEq,decide,omegawith@[wram_arith]unfolding, andStrideOmega.prove?(which handles strided 2D bounds and injectivityb' * S + s ≠ b * S + q₀), without triggeringlinter.unnecessaryWramOmega. - Supports
Data.write/Data.setprojections ((d.write a v).mem,(d.set i v).regs,(d.write a v).regs,(d.set i v).mem) whenever those declarations are in the environment.
Main definitions #
update_simp: tactic simplifying chained/conditionalFunction.updateapplications in the goal and/or specified hypotheses (update_simp [def₁, h₁, ...] at loc).Cslib.Tactic.UpdateSimp.reduceUpdate:simpprocedure simplifyingFunction.update f a v k.
Collapse (if p then Function.update f a v else f) k to f k when p → k ≠ a,
without splitting on p.
Collapse (if p then f else Function.update f a v) k to f k when ¬p → k ≠ a,
without splitting on p.
Peel Function.update in the then branch of (if p then ... else g) k
when p → k ≠ a.
Peel Function.update in the else branch of (if p then f else ...) k
when ¬p → k ≠ a.
Reduce (if p then Function.update f a v else g) k to if p then v else g k
when p → k = a.
Reduce (if p then f else Function.update g a v) k to if p then f k else v
when ¬p → k = a.
Reduce a single Function.update f a v k expression as a simp procedure.
Simplify chained and conditional Function.update applications without splitting if guards.
update_simppeelsFunction.update f a v kand(if p then Function.update f a v else g) kin the goal using local facts,decide,omega(with@[wram_arith]unfolding), andstride_omega(strided injectivity and bounds), automatically closing trivial equalitieslhs = rhswhenlhsandrhsbecome definitionally equal.update_simp [d₁, d₂, h₁]additionally unfolds head definitionsd₁, d₂(such asgmPushSlab,gmCompactSlab,gmUnlinkTopSlab) when applied to an index, and supplies local or global hintsh₁to the arithmetic solver.update_simp [...] at h₁ h₂ ⊢rewrites in the named hypotheses and/or the goal.
simp procedure reducing chained/conditional Function.update f a v k applications via
update_simp.