Elm Exactly

TheoremspecializeCon_fwd

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

Statement

theorem specializeCon_fwd (k : String) (cs : List Inh) (hr : List Inh) : ∀ (P : List (List PatN)),
    (∃ r ∈ P, RowCovers r (Inh.mkCon k cs :: hr)) → ∃ r' ∈ specializeCon k cs.length P, RowCovers r' (cs ++ hr)
  | [], ⟨_, hm, _⟩ => by cases hm
  | r :: P, ⟨r0, hm, hc⟩ => by
    rcases List.mem_cons.mp hm with rfl | hm
    · match r0, hc with
      | .wild :: rest, hc =>
        simp only [RowCovers] at hc
        refine ⟨List.replicate cs.length .wild ++ rest, by simp [specializeCon], ?_⟩
        rw [RowCovers.append (by simp)]
        exact ⟨RowCovers.wilds cs, hc.2⟩
      | .con k' args :: rest, hc =>
        simp only [RowCovers] at hc
        obtain ⟨hk, hl, hcs⟩

Proof

(covers_mkCon_iff _ _ _ _).mp hc.1
        subst hk
        refine ⟨args ++ rest, by simp [specializeCon], ?_⟩
        rw [RowCovers.append hl]
        exact ⟨hcs, hc.2⟩
      | .den d :: rest, hc =>
        simp only [RowCovers] at hc
        exact absurd hc.1 (not_covers_mkCon_den d k cs)
      | [], hc => simp [RowCovers] at hc
    · obtain ⟨r', hm', hc'⟩ := specializeCon_fwd k cs hr P ⟨r0, hm, hc⟩
      refine ⟨r', ?_, hc'⟩
      match r with
      | .wild :: _ => simp only [specializeCon]; exact List.mem_cons_of_mem _ hm'
      | .con k' _ :: _ =>
        simp only [specializeCon]
        split
        · exact List.mem_cons_of_mem _ hm'
        · exact hm'
      | .den _ :: _ => simpa [specializeCon] using hm'
      | [] => simpa [specializeCon] using hm'

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

Theorems it uses

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.