Elm Exactly

TheoremdefaultM_fwd

StandardElmMech/Stat/PatternsProof.lean:524, Specialisation and the default matrix · term proof

A row of P covering h :: hr whose first pattern is not a wildcard covers h by a head the node h does not match; so a row of the default matrix covers hr.

Statement

theorem defaultM_fwd (h : Inh) (hr : List Inh) : ∀ (P : List (List PatN)),
    (∀ r ∈ P, ∀ p rest, r = p :: rest → p.isWild = false → ¬ p.covers h) →
    (∃ r ∈ P, RowCovers r (h :: hr)) → ∃ r' ∈ defaultM P, RowCovers r' hr
  | [], _, ⟨_, hm, _⟩ => by cases hm
  | r :: P, hP, ⟨r0, hm, hc⟩ => by
    rcases List.mem_cons.mp hm with rfl | hm
    · match r0, hc with
      | .wild :: rest, hc => exact ⟨rest, by simp [defaultM], hc.2⟩
      | .den d :: rest, hc => exact absurd hc.1 (hP _ List.mem_cons_self _ rest rfl rfl)
      | .con k args :: rest, hc => exact absurd hc.1 (hP _ List.mem_cons_self _ rest rfl rfl)
      | [], hc => simp [RowCovers] at hc
    · obtain ⟨r', hm', hc'⟩

Proof

defaultM_fwd h hr P (fun r hr' => hP r (List.mem_cons_of_mem _ hr')) ⟨r0, hm, hc⟩
      refine ⟨r', ?_, hc'⟩
      match r with
      | .wild :: _ => simp only [defaultM]; exact List.mem_cons_of_mem _ hm'
      | .den _ :: _ => simpa [defaultM] using hm'
      | .con _ _ :: _ => simpa [defaultM] using hm'
      | [] => simpa [defaultM] using hm'

Proved by a term, which Lean's kernel checks directly.

Used by

In StandardElmMech/Stat/PatternsProof.lean: The pattern decider is correct: every type is inhabited (inhabited), useful_spec, exhDec_sound, irrDec_sound.

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.