Theoremiter_props
Statement
theorem iter_props (n : Nat) (r : Nat → Nat → Bool) : ∀ (k : Nat) (s : List Nat), Shape n s →
Shape n (iter n r k s) ∧ (∀ j ∈ s, j ∈ iter n r k s) ∧
(Closed n r (iter n r k s) ∨ s.length + k ≤ (iter n r k s).length)
| 0, s, hs => ⟨hs, fun _ h => h, .inr (by simp [iter])⟩
| k + 1, s, hs => by
unfold iter
split
· rename_i he
exact ⟨hs, fun _ h => h, .inl (closed_of_len hs (by simpa using he))⟩
· rename_i hne
have hge : s.length + 1 ≤ (grow n r s).lengthProof
by
have hm : s.length ≤ (grow n r s).length := by
have hm' := len_filter_mono (l := List.range n) (p := fun j => s.contains j)
(q := fun j => s.contains j || s.any fun k => r k j)
(fun x _ hx => by simp only [Bool.or_eq_true]; exact .inl hx)
calc s.length = ((List.range n).filter fun j => s.contains j).length := congrArg List.length (shape_self hs)
_ ≤ _ := hm'
have : (grow n r s).length ≠ s.length := by simpa using hne
omega
obtain ⟨h1, h2, h3⟩ := iter_props n r k (grow n r s) (shape_grow n r s)
refine ⟨h1, fun j hj => h2 j (grow_ge hs j hj), ?_⟩
rcases h3 with h | h
· exact .inl h
· exact .inr (by omega)Proved with tactics, which Lean expands into a proof term that its kernel checks.
Theorems it uses
Used by
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.