Skip to content

Commit 218a3df

Browse files
committed
Eval notation
1 parent 324f85c commit 218a3df

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Juvix/Core/Main.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
import Juvix.Core.Main.Language
33
import Juvix.Core.Main.Semantics
4+
import Juvix.Core.Main.Evaluator

Juvix/Core/Main/Semantics.lean

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ inductive Eval (P : Program) : Context → Expr → Value → Prop where
5454
| eval_unit {ctx} :
5555
Eval P ctx Expr.unit Value.unit
5656

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
5861
induction h₁ generalizing v₂ with
5962
| eval_var =>
6063
cases h₂ <;> cc
@@ -112,19 +115,19 @@ inductive Value.Terminating (P : Program) : Value → Prop where
112115
Value.Terminating P (Value.constr_app ctr_name args_rev)
113116
| closure {ctx body} :
114117
(∀ v v',
115-
Eval P (v :: ctx) body v' →
118+
[P] (v :: ctx) body v' →
116119
Value.Terminating P v') →
117120
Value.Terminating P (Value.closure ctx body)
118121
| unit : Value.Terminating P Value.unit
119122

120123
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)
122125

123126
def Program.Terminating (P : Program) : Prop :=
124127
Expr.Terminating P [] P.main
125128

126129
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
128131
intro h₁ h₂
129132
rcases h₁ with ⟨v', hval, hterm⟩
130133
rewrite [Eval.deterministic h₂ hval]

0 commit comments

Comments
 (0)