@@ -54,7 +54,10 @@ inductive Eval (P : Program) : Context → Expr → Value → Prop where
54
54
| eval_unit {ctx} :
55
55
Eval P ctx Expr.unit Value.unit
56
56
57
- theorem Eval.deterministic {P ctx e v₁ v₂} (h₁ : Eval P ctx e v₁) (h₂ : Eval P ctx e v₂) : v₁ = v₂ := by
57
+ notation "[" P "] " ctx " ⊢ " e " ↦ " v:40 => Eval P ctx e v
58
+
59
+ -- The evaluation relation is deterministic.
60
+ theorem Eval.deterministic {P ctx e v₁ v₂} (h₁ : [P] ctx ⊢ e ↦ v₁) (h₂ : [P] ctx ⊢ e ↦ v₂) : v₁ = v₂ := by
58
61
induction h₁ generalizing v₂ with
59
62
| eval_var =>
60
63
cases h₂ <;> cc
@@ -112,19 +115,19 @@ inductive Value.Terminating (P : Program) : Value → Prop where
112
115
Value.Terminating P (Value.constr_app ctr_name args_rev)
113
116
| closure {ctx body} :
114
117
(∀ v v',
115
- Eval P (v :: ctx) body v' →
118
+ [P] (v :: ctx) ⊢ body ↦ v' →
116
119
Value.Terminating P v') →
117
120
Value.Terminating P (Value.closure ctx body)
118
121
| unit : Value.Terminating P Value.unit
119
122
120
123
def Expr.Terminating (P : Program) (ctx : Context) (e : Expr) : Prop :=
121
- (∃ v, Eval P ctx e v ∧ Value.Terminating P v)
124
+ (∃ v, [P] ctx ⊢ e ↦ v ∧ Value.Terminating P v)
122
125
123
126
def Program.Terminating (P : Program) : Prop :=
124
127
Expr.Terminating P [] P.main
125
128
126
129
lemma Eval.Expr.Terminating {P ctx e v} :
127
- Expr.Terminating P ctx e → Eval P ctx e v → Value.Terminating P v := by
130
+ Expr.Terminating P ctx e → [P] ctx ⊢ e ↦ v → Value.Terminating P v := by
128
131
intro h₁ h₂
129
132
rcases h₁ with ⟨v', hval, hterm⟩
130
133
rewrite [Eval.deterministic h₂ hval]
0 commit comments