Documentation

CslibFrontier.Tactic.UpdateSimp

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:

Main definitions #

theorem Cslib.Tactic.UpdateSimp.ite_update_of_ne {α : Sort u} {β : Sort v} [DecidableEq α] {p : Prop} [Decidable p] (f : α → β) (a : α) (v : β) (k : α) (h : p → k ≠ a) :
(if p then Function.update f a v else f) k = f k

Collapse (if p then Function.update f a v else f) k to f k when p → k ≠ a, without splitting on p.

theorem Cslib.Tactic.UpdateSimp.ite_update_else_same_of_ne {α : Sort u} {β : Sort v} [DecidableEq α] {p : Prop} [Decidable p] (f : α → β) (a : α) (v : β) (k : α) (h : ¬p → k ≠ a) :
(if p then f else Function.update f a v) k = f k

Collapse (if p then f else Function.update f a v) k to f k when ¬p → k ≠ a, without splitting on p.

theorem Cslib.Tactic.UpdateSimp.ite_update_then_of_ne {α : Sort u} {β : Sort v} [DecidableEq α] {p : Prop} [Decidable p] (f g : α → β) (a : α) (v : β) (k : α) (h : p → k ≠ a) :
(if p then Function.update f a v else g) k = (if p then f else g) k

Peel Function.update in the then branch of (if p then ... else g) k when p → k ≠ a.

theorem Cslib.Tactic.UpdateSimp.ite_update_else_of_ne {α : Sort u} {β : Sort v} [DecidableEq α] {p : Prop} [Decidable p] (f g : α → β) (a : α) (v : β) (k : α) (h : ¬p → k ≠ a) :
(if p then f else Function.update g a v) k = (if p then f else g) k

Peel Function.update in the else branch of (if p then f else ...) k when ¬p → k ≠ a.

theorem Cslib.Tactic.UpdateSimp.ite_update_then_of_eq {α : Sort u} {β : Sort v} [DecidableEq α] {p : Prop} [Decidable p] (f g : α → β) (a : α) (v : β) (k : α) (h : p → k = a) :
(if p then Function.update f a v else g) k = if p then v else g k

Reduce (if p then Function.update f a v else g) k to if p then v else g k when p → k = a.

theorem Cslib.Tactic.UpdateSimp.ite_update_else_of_eq {α : Sort u} {β : Sort v} [DecidableEq α] {p : Prop} [Decidable p] (f g : α → β) (a : α) (v : β) (k : α) (h : ¬p → k = a) :
(if p then f else Function.update g a v) k = if p then f k else v

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_simp peels Function.update f a v k and (if p then Function.update f a v else g) k in the goal using local facts, decide, omega (with @[wram_arith] unfolding), and stride_omega (strided injectivity and bounds), automatically closing trivial equalities lhs = rhs when lhs and rhs become definitionally equal.
  • update_simp [d₁, d₂, h₁] additionally unfolds head definitions d₁, d₂ (such as gmPushSlab, gmCompactSlab, gmUnlinkTopSlab) when applied to an index, and supplies local or global hints h₁ 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.