Elm Exactly

Theoremnot_twoCycle

StandardElmMech/Src/SynSet.lean:50, Refusals whatever the order · tactic proof

Statement

theorem not_twoCycle {q : SProgram} (hio : ImportOrder q) (hd : ModulesDistinct q) : ¬ TwoCycle q

Proof

by
  rintro ⟨a, ha, b, hb, hne, hab, hba, hna, hnb⟩
  obtain ⟨i, hi, rfl⟩ := List.getElem_of_mem ha
  obtain ⟨j, hj, rfl⟩ := List.getElem_of_mem hb
  have hnames := List.pairwise_iff_getElem.mp hd.1
  -- the module named n is at the index where n stands
  have uniq : ∀ k l (hk : k < q.modules.length) (hl : l < q.modules.length),
      q.modules[k].header.name = q.modules[l].header.name → k = l := by
    intro k l hk hl he
    apply Classical.byContradiction
    intro hkl
    rcases Nat.lt_or_gt_of_ne hkl with h | h
    · exact hnames k l (by simpa using hk) (by simpa using hl) h (by simpa using he)
    · exact hnames l k (by simpa using hl) (by simpa using hk) h (by simpa using he.symm)
  obtain ⟨j', hj', hj'e⟩ := import_before hio hi hab hnb
  obtain ⟨i', hi', hi'e⟩ := import_before hio hj hba hna
  have hj'l : j' < q.modules.length := by omega
  have hi'l : i' < q.modules.length := by omega
  simp only [List.getElem?_eq_getElem hj'l, List.getElem?_eq_getElem hi'l, Option.map_some,
    Option.some.injEq] at hj'e hi'e
  have := uniq _ _ hj'l hj hj'e
  have := uniq _ _ hi'l hi hi'e
  omega

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

Theorems it uses

Used by

In StandardElmMech/Src/SynSet.lean: The restrictions of the set of a program's modules (SynOKSet) and the refusals of every order.

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.