Elm Exactly

TheoremsoundAt

StandardElmMech/Sound.lean:121 · tactic proof

Statement

theorem soundAt (o : Oracle) : ∀ n, SoundAt o n

Proof

by
  intro n
  induction n with
  | zero =>
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
      intros <;> simp_all [evAtExp, evExpOpt, evExpRow, evExpRowOpt, evExp, appVal, evMatch,
        evMRule, evDec, evValBind, evValBindOpt, matchAtPat, matchPatOpt, matchPatRow,
        matchPatRowOpt, matchPat, matchAtPats]
  | succ n ih =>
    obtain ⟨i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17⟩ := ih
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
    · intro E a k v l k' h; cases a <;> simp only [evAtExp] at h <;> sound_fin
    · intro E x k r l k' h; cases x <;> simp only [evExpOpt] at h <;> sound_fin
    · intro E row k r l k' h; cases row <;> simp only [evExpRow] at h <;> sound_fin
    · intro E x k r l k' h; cases x <;> simp only [evExpRowOpt] at h <;> sound_fin
    · intro E e k v l k' h; cases e <;> simp only [evExp] at h <;> sound_fin
    · intro f v k r l k' h; cases f <;> simp only [appVal] at h <;> sound_fin
    · intro E v m k r l k' h; cases m <;> simp only [evMatch] at h <;> sound_fin
    · intro E v mr k r l k' h; cases mr <;> simp only [evMRule] at h <;> sound_fin
    · intro E d k VE l k' h; cases d <;> simp only [evDec] at h <;> sound_fin
    · intro E vb k VE l k' h; cases vb <;> simp only [evValBind] at h <;> sound_fin
    · intro E x k VE l k' h; cases x <;> simp only [evValBindOpt] at h <;> sound_fin
    · intro E v a k r l k' h; cases a <;> simp only [matchAtPat] at h <;> sound_fin
    · intro E v p k r l k' h; cases v <;> cases p <;> simp only [matchPatOpt] at h <;> sound_fin
    · intro E rc row k VE l k' h; cases row <;> simp only [matchPatRow] at h <;> sound_fin
    · intro E rc x k VE l k' h; cases x <;> simp only [matchPatRowOpt] at h <;> sound_fin
    · intro E v p k r l k' h; cases p <;> simp only [matchPat] at h <;> sound_fin
    · intro E vs as k r l k' h; cases vs <;> cases as <;> simp only [matchAtPats] at h <;> sound_fin

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

Tactics it calls

sound_fin (StandardElmMech/Sound.lean:67): Split the evaluator's matches in h, then close the goal from the logged rule constructors, the induction hypotheses and the helper lemmas.

macro "sound_fin" : tactic => `(tactic| (
  (repeat' (first | (split at h) | (split at *)))
  all_goals (try simp only [Res.mk.injEq, Outcome.value.injEq, reduceCtorEq, Bool.not_eq_true,
    and_true, true_and] at *)
  all_goals (try obtain ⟨⟨⟩, ⟨⟩, ⟨⟩⟩ := h)
  all_goals (try subst_vars)
  all_goals (solve_by_elim (maxDepth := 8) [
    EvalAtExpL.r_d_atexp_scon_l, EvalAtExpL.r_d_atexp_var_l, EvalAtExpL.r_d_atexp_con_l,
    EvalAtExpL.r_d_atexp_op_l, EvalAtExpL.r_d_atexp_unit_l, EvalAtExpL.r_d_atexp_tuple_l,
    EvalAtExpL.r_d_atexp_nil_l, EvalAtExpL.r_d_atexp_record_l, EvalAtExpL.r_d_atexp_update_l,
    EvalAtExpL.r_d_atexp_paren_l, EvalAtExpL.r_d_atexp_let_l,
    EvalExpRowL.r_d_exprow_field_l,
    EvalExpL.r_d_exp_atexp_l, EvalExpL.r_d_exp_app_l, EvalExpL.r_d_exp_lambda_l, EvalExpL.r_d_exp_case_l,
    AppValL.r_d_app_closure_l, AppValL.r_d_app_con_l, AppValL.r_d_app_basic_partial_l,
    AppValL.r_d_app_basic_apply_l,
    EvalMatchL.r_d_match_first_l, EvalMatchL.r_d_match_fail_l, EvalMatchL.r_d_match_next_l,
    EvalMRuleL.r_d_mrule_match_l, EvalMRuleL.r_d_mrule_fail_l,
    EvalDecL.r_d_dec_nonrec_l, EvalDecL.r_d_dec_rec_l,
    EvalValBindL.r_d_valbind_var_l, EvalValBindL.r_d_valbind_pat_l,
    MatchAtPatL.r_d_atpat_wild_l, MatchAtPatL.r_d_atpat_scon_l, MatchAtPatL.r_d_atpat_scon_fail_l,
    MatchAtPatL.r_d_atpat_var_l, MatchAtPatL.r_d_atpat_con_l, MatchAtPatL.r_d_atpat_con_fail_l,
    MatchAtPatL.r_d_atpat_unit_l, MatchAtPatL.r_d_atpat_tuple_l, MatchAtPatL.r_d_atpat_nil_l,
    MatchAtPatL.r_d_atpat_nil_fail_l, MatchAtPatL.r_d_atpat_record_l, MatchAtPatL.r_d_atpat_paren_l,
    MatchPatRowL.r_d_patrow_field_l,
    MatchPatL.r_d_pat_atpat_l, MatchPatL.r_d_pat_con_l, MatchPatL.r_d_pat_con_fail_l,
    MatchPatL.r_d_pat_cons_l, MatchPatL.r_d_pat_cons_fail_l, MatchPatL.r_d_pat_as_l,
    EvalExpOptL.opt_none_l, EvalExpOptL.opt_some_l, EvalExpRowOptL.opt_none_l,
    EvalExpRowOptL.opt_some_l, EvalValBindOptL.opt_none_l, EvalValBindOptL.opt_some_l,
    MatchPatOptL.opt_none_l, MatchPatOptL.opt_some_l, MatchPatRowOptL.opt_none_l,
    MatchPatRowOptL.opt_some_l, MatchAtPatsL.seq_nil_l, MatchAtPatsL.seq_cons_l,
    atpat_tuple_l', app_basic_choice_l, applySet_single, applySet_first, applySet_second,
    sconTest_true, sconTest_false, conIs_true, conIs_false, conArgs_some, conArgs_none,
    i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17])))

Rules of the book it uses

Theorems it uses

Used by

In StandardElmMech/Sound.lean: soundAt, evExp_sound_l, evExp_sound: every value of the evaluator, with its log, is derivable in the logged relation, and so in the book's.

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.