@@ -80,20 +80,38 @@ def State.get (σ : State) (x : Var) : Val :=
80
80
section
81
81
attribute [local grind] State.update State.find? State.get State.erase
82
82
83
- @[simp, grind =] theorem State.find?_update_self (σ : State) (x : Var) (v : Val) : (σ.update x v).find? x = some v := by
83
+ @[simp, grind =] theorem State.find?_nil (x : Var) : find? [] x = none := by
84
+ grind
85
+
86
+ @[simp] theorem State.find?_update_self (σ : State) (x : Var) (v : Val) : (σ.update x v).find? x = some v := by
84
87
induction σ, x, v using State.update.induct <;> grind
85
88
86
- @[simp, grind = ] theorem State.find?_update (σ : State) (v : Val) (h : x ≠ z) : (σ.update x v).find? z = σ.find? z := by
89
+ @[simp] theorem State.find?_update (σ : State) (v : Val) (h : x ≠ z) : (σ.update x v).find? z = σ.find? z := by
87
90
induction σ, x, v using State.update.induct <;> grind
88
91
92
+ @[grind =] theorem State.find?_update_eq (σ : State) (v : Val)
93
+ : (σ.update x v).find? z = if x = z then some v else σ.find? z := by
94
+ grind only [= find?_update_self, = find?_update, cases Or]
95
+
89
96
@[grind] theorem State.get_of_find? {σ : State} (h : σ.find? x = some v) : σ.get x = v := by
90
97
grind
91
98
92
- @[simp, grind = ] theorem State.find?_erase_self (σ : State) (x : Var) : (σ.erase x).find? x = none := by
99
+ @[simp] theorem State.find?_erase_self (σ : State) (x : Var) : (σ.erase x).find? x = none := by
93
100
induction σ, x using State.erase.induct <;> grind
94
101
95
- @[simp, grind = ] theorem State.find?_erase (σ : State) (h : x ≠ z) : (σ.erase x).find? z = σ.find? z := by
102
+ @[simp] theorem State.find?_erase (σ : State) (h : x ≠ z) : (σ.erase x).find? z = σ.find? z := by
96
103
induction σ, x using State.erase.induct <;> grind
104
+
105
+ @[simp, grind =] theorem State.find?_erase_eq (σ : State)
106
+ : (σ.erase x).find? z = if x = z then none else σ.find? z := by
107
+ grind only [= find?_erase_self, = find?_erase, cases Or]
108
+
109
+ @[grind] theorem State.length_erase_le (σ : State) (x : Var) : (σ.erase x).length ≤ σ.length := by
110
+ induction σ, x using erase.induct <;> grind
111
+
112
+ def State.length_erase_lt (σ : State) (x : Var) : (σ.erase x).length < σ.length.succ := by
113
+ grind
114
+
97
115
end
98
116
99
117
syntax ident " ↦ " term : term
@@ -206,9 +224,7 @@ def evalExpr (e : Expr) : EvalM Val := do
206
224
| c' => .while c' b.simplify
207
225
208
226
theorem Stmt.simplify_correct (h : (σ, s) ⇓ σ') : (σ, s.simplify) ⇓ σ' := by
209
- -- TODO: we need a mechanism for saying we just want the intro rules
210
- induction h <;> grind [=_ Expr.eval_simplify, Bigstep.skip, Bigstep.assign,
211
- Bigstep.seq, Bigstep.whileFalse, Bigstep.whileTrue, Bigstep.ifTrue, Bigstep.ifFalse]
227
+ induction h <;> grind [=_ Expr.eval_simplify, intro Bigstep]
212
228
213
229
@[simp, grind =] def Expr.constProp (e : Expr) (σ : State) : Expr :=
214
230
match e with
@@ -220,13 +236,7 @@ theorem Stmt.simplify_correct (h : (σ, s) ⇓ σ') : (σ, s.simplify) ⇓ σ' :
220
236
| una op arg => una op (arg.constProp σ)
221
237
222
238
@[simp, grind =] theorem Expr.constProp_nil (e : Expr) : e.constProp [] = e := by
223
- induction e <;> grind [State.find?] -- TODO add missing theorem(s) to avoid unfolding `find?`
224
-
225
- @[grind] theorem State.length_erase_le (σ : State) (x : Var) : (σ.erase x).length ≤ σ.length := by
226
- induction σ, x using erase.induct <;> grind [State.erase] -- TODO add missing theorem(s)
227
-
228
- def State.length_erase_lt (σ : State) (x : Var) : (σ.erase x).length < σ.length.succ := by
229
- grind
239
+ induction e <;> grind
230
240
231
241
@[simp, grind =] def State.join (σ₁ σ₂ : State) : State :=
232
242
match σ₁ with
@@ -308,25 +318,11 @@ theorem State.erase_le_of_le_cons (h : σ' ≼ (x, v) :: σ) : σ'.erase x ≼
308
318
grind
309
319
310
320
@[grind] theorem State.erase_le_update (h : σ' ≼ σ) : σ'.erase x ≼ σ.update x v := by
311
- intro y w hf'
312
- -- TODO: can we avoid this hint?
313
- by_cases hxy : x = y <;> grind
321
+ grind
314
322
315
323
@[grind] theorem State.update_le_update (h : σ' ≼ σ) : σ'.update x v ≼ σ.update x v := by
316
- intro y w hf
317
- induction σ generalizing σ' hf with
318
- | nil => grind
319
- | cons zw' σ ih =>
320
- have (z, w') := zw'; simp
321
- have : σ'.erase z ≼ σ := erase_le_of_le_cons h
322
- have ih := ih this
323
- revert ih hf
324
- split <;> simp [*] <;> by_cases hyz : y = z <;> simp (config := { contextual := true }) [*]
325
- next => grind
326
- next => grind
327
- sorry
324
+ grind
328
325
329
- -- TODO: we are missing theorems here, and cannot seal State functions
330
326
@[grind] theorem Expr.eval_constProp_of_sub (e : Expr) (h : σ' ≼ σ) : (e.constProp σ').eval σ = e.eval σ := by
331
327
induction e <;> grind
332
328
0 commit comments