You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| (case _ (𝑀*, 𝜌)) A case expression awaiting the scrutinee
46
46
```
47
47
48
48
The CEK machine has two main kinds of states:
49
49
-`𝑠; 𝜌 ⊳ 𝑀` denotes evaluating term `𝑀` with environment `𝜌` and stack `𝑠`.
50
50
-`𝑠 ⊲ 𝑉` denotes returning a value `𝑉` to stack `𝑠`.
51
51
52
-
A value is a fully evaluated term, and an environment is a map binding variables to values.
52
+
A value is a fully evaluated term, plus environments necessary for further computation.
53
+
An environment is a map binding variables to values.
53
54
A stack frame contains a hole to represent a pending value, and the context needed to continue evaluation once the value is received.
55
+
A builtin argument `𝜄` is either a term or a type argument.
54
56
55
57
To evaluate a Plutus program containing a term `𝑀`, the machine starts from state `[]; [] ⊳ 𝑀`, and based on the following transition table, proceeds as follows:
56
58
- If the current CEK machine state matches the From State, and the associated condition (if exists) is met, then the CEK machine transitions into the To State.
57
-
- If the machine arrives at state `◻𝑉`, the machine terminates with success, yielding `𝑉` as final result.
59
+
- If the machine arrives at state `◻𝑉`, the machine terminates with success, yielding the Plutus term corresponding to `𝑉` (which is essentially `𝑉` but with the environments removed) as final result.
58
60
- If the machine gets stuck (i.e., no rule applies) or arrives at state `⬥`, the evaluation terminates with a failure.
59
61
60
62
|Rule|From State | To State | Condition |
@@ -83,7 +85,7 @@ To evaluate a Plutus program containing a term `𝑀`, the machine starts from s
83
85
| 22 |`(force _)⋅𝑠 ⊲ 〈builtin 𝑏 𝑉* [𝜄]〉`|`𝖤𝗏𝖺𝗅𝖢𝖤𝖪 (𝑠, 𝑏, 𝑉*)`|`𝜄` is a type argument |
The symbol `⋅` denotes either the cons or snoc operator on lists.
@@ -132,5 +134,5 @@ Explanation of the transition rules:
132
134
23. When a value `𝑉` is returned to a stack whose top frame is a constructor application, with the hole in any argument position except the last (in other words, there is at least one more argument to be evaluated), the machine replaces the frame with one where the hole is moved to the next argument, and proceeds to evaluate the next argument `𝑀` in the captured environment.
133
135
24. Like Rule 23, except that the hole is in the position of the last argument.
134
136
In this case, all arguments have been evaluated, so the machine pops the frame and returns a `constr` value.
135
-
25. If the returned value is a constructor application with index `𝑖`, and the top stack frame is a `case` frame, the machine will evaluate the `𝑖`th branch - `𝑀𝑖` - applied to arguments `𝑉𝑚 … 𝑉1` (it is important to note that arguments under `constr` are reversed when passing to a `case` branch - this is done for performance reasons).
136
-
To do so, it pops the frame, and pushes `𝑚` frames, each representing an application, with the top frame corresponding to `𝑉𝑚` (the first argument).
137
+
25. If the returned value is a constructor application with index `𝑖`, and the top stack frame is a `case` frame, the machine will evaluate the `𝑖`th branch - `𝑀𝑖` - applied to arguments `𝑉ₘ … 𝑉₁` (it is important to note that arguments under `constr` are reversed when passing to a `case` branch - this is done for performance reasons).
138
+
To do so, it pops the frame, and pushes `m` frames, each representing an application, with the top frame corresponding to `𝑉ₘ` (the first argument).
0 commit comments