Elm Exactly

Theoremtrace_take_prefix

StandardElmMech/Prog/Exec.lean:145 · tactic proof

Statement

theorem trace_take_prefix : ∀ (π : Path) (tr' : List Event), tr' <+: trace π →
    ∃ n, trace (π.take n) = tr'
  | [], tr', h => ⟨0, by simp [trace] at h ⊢; exact h⟩
  | (a, K) :: π, tr', h => by
    cases ha : a.filter Event.observable with
    | none =>
      have hπ : trace ((a, K) :: π) = trace π

Proof

by simp [trace, ha]
      rw [hπ] at h
      obtain ⟨n, hn⟩ := trace_take_prefix π tr' h
      refine ⟨n + 1, ?_⟩
      simp only [List.take_succ_cons, trace, List.filterMap_cons, ha] at hn ⊢
      exact hn
    | some e =>
      have hπ : trace ((a, K) :: π) = e :: trace π := by simp [trace, ha]
      rw [hπ] at h
      cases tr' with
      | nil => exact ⟨0, by simp [trace]⟩
      | cons e' tr'' =>
        rw [List.cons_prefix_cons] at h
        obtain ⟨rfl, h'⟩ := h
        obtain ⟨n, hn⟩ := trace_take_prefix π tr'' h'
        refine ⟨n + 1, ?_⟩
        simp only [List.take_succ_cons, trace, List.filterMap_cons, ha] at hn ⊢
        rw [hn]

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

Used by

In StandardElmMech/Prog/Exec.lean: Hosts (any, none, the test runner's echo), executions with and without logs, a worker's executions (WorkerExec, its log as D9 defines it), traces and Tr (tr_nil, tr_prefix, tr_empty_iff_no_start).

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.