Elm Exactly

TheoremdatBind_facts

StandardElmMech/Stat/RefuseTypes.lean:798, Type declarations · term proof

Statement

theorem datBind_facts (C : Ctx) (names : String → Option TyName) :
    ∀ (d : BDatBind) (VE' : ValEnv) (TE' : TyEnv), elabDatBind C names d = some (VE', TE') → (d.map (·.1)).Nodup →
    (∀ c, c ∉ d.map (·.1) → FMap.find? TE' c = none) ∧
    (∀ x ∈ d, ∃ (t : TyName) (VEc : ValEnv), FMap.find? TE' x.1 = some (t.toFcn, VEc) ∧ t.arity = x.2.1.length ∧
      ∀ y ∈ x.2.2, (elabTyList (C.plusU (seqVars x.2.1 (conBindExtNames x.2.2))) y.2).isSome = true)
  | [], VE', TE', h, _ => by
    simp only [elabDatBind, Option.some.injEq, Prod.mk.injEq] at h
    obtain ⟨rfl, rfl⟩

Proof

h
    simp [FMap.find?]
  | (c, ps, cb) :: rest, VE', TE', h, hnd => by
    simp only [elabDatBind] at h
    split at h
    · cases h
    · rename_i t _
      split at h
      · rename_i τs VE'' TE'' h1 h2
        split at h
        · rename_i VEc h3
          split at h
          · rename_i hc
            simp only [Option.some.injEq, Prod.mk.injEq] at h
            obtain ⟨rfl, rfl⟩ := h
            simp only [List.map_cons, List.nodup_cons] at hnd
            have ih := datBind_facts C names rest VE'' TE'' h2 hnd.2
            refine ⟨fun k hk => ?_, fun x hx => ?_⟩
            · simp only [List.map_cons, List.mem_cons, not_or] at hk
              rw [FMap.find?_modify, ih.1 k hk.2]
              simp [FMap.find?, Ne.symm hk.1]
            · rcases List.mem_cons.mp hx with rfl | hx
              · refine ⟨t, closVE C.tyvars VEc, ?_, hc.2.1, conBind_ok _ _ cb VEc h3⟩
                rw [FMap.find?_modify, ih.1 c hnd.1]
                simp [FMap.find?]
              · obtain ⟨t', VEc', h1', h2', h3'⟩ := ih.2 x hx
                exact ⟨t', VEc', by rw [FMap.find?_modify, h1']; rfl, h2', h3'⟩
          · cases h
        · cases h
      · cases h

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

Theorems it uses

Used by

In StandardElmMech/Stat/RefuseTypes.lean: Refusals by type expressions (aliases, constructor arguments, annotations, ports) and by the type of main (typesFailB, mainFailB), for every choice of generated names and variable sorts.

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.