Elm Exactly

Theoremclosed_of_len

StandardElmMech/Src/Graph.lean:124, Facts about growing · tactic proof

A shaped set that does not grow is closed.

Statement

theorem closed_of_len {n : Nat} {r : Nat → Nat → Bool} {s : List Nat} (hs : Shape n s)
    (he : (grow n r s).length = s.length) : Closed n r s

Proof

by
  intro a ha b hb hr
  have hself := shape_self hs
  have hmono : ∀ x ∈ List.range n, (fun j => s.contains j) x = true →
      (fun j => s.contains j || s.any fun k => r k j) x = true := by
    intro x _ hx; simp only [Bool.or_eq_true]; exact .inl hx
  have heq : ((List.range n).filter fun j => s.contains j).length =
      ((List.range n).filter fun j => s.contains j || s.any fun k => r k j).length := by
    rw [← hself]; exact he.symm
  have := len_filter_eq hmono heq b (List.mem_range.mpr hb)
    (by simp only [Bool.or_eq_true, List.any_eq_true]; exact .inr ⟨a, ha, hr⟩)
  simpa using this

Proved with tactics, which Lean expands into a proof term that its kernel checks.

Theorems it uses

In StandardElmMech/Src/Graph.lean: Reachability on graphs over 0 .. n-1 (Plus, Reach) and its decider, proved correct (plusB_iff, reachB_iff).

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.