Theoremperm_two
Statement
theorem perm_two {α : Type} {L : List α} {c c' : α} (h : L.Perm [c, c']) : L = [c, c'] ∨ L = [c', c]Proof
by
have hl : L.length = 2 := by simpa using h.length_eq
match L, hl with
| [a, b], _ =>
have hm : ∀ x, x ∈ [a, b] ↔ x ∈ [c, c'] := fun x => h.mem_iff
by_cases hac : a = c
· subst hac
have : [b].Perm [c'] := (List.perm_cons a).mp h
left; rw [List.perm_singleton.mp this]
· have ha : a = c' := by
have := (hm a).mp (by simp)
simp only [List.mem_cons, List.not_mem_nil, or_false] at this
exact this.resolve_left hac
subst ha
have h2 : [a, b].Perm [a, c] := h.trans (List.Perm.swap a c [])
have : [b].Perm [c] := (List.perm_cons a).mp h2
right; rw [List.perm_singleton.mp this]Proved with tactics, which Lean expands into a proof term that its kernel checks.
In StandardElmMech/Prog/Invariant.lean: CHECK-NOT as a statement about every execution (WorkerTest.HoldsNot), per-test invariants (TestInv, TestInv.sound, holdsNot_any), and the determinism and inversion lemmas they use.
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.