Content deleted Content added
added short description, links Tags: Mobile edit Mobile app edit iOS app edit |
→Reduction semantics: Matthias Felleisen here. The existing description was fundamentally wrong. An upset reader shared this link with me so I decided to put in 10 minutes to eliminate the worst conceptual mistakes. |
||
Line 85:
==== Reduction semantics ====
'''Reduction semantics'''
For example, an assignment statement can be reduced if it sits next to its variable declaration:
let rec x = v_1 in x <- v_2; e ---> let rec x = v_2 in e
The contexts <math>C</math> include a hole <math>\left[\,\right]</math> where a term can be plugged in. The shape of the contexts indicate where reduction can occur (i.e., a term can be plugged into a term). To describe a semantics for this language, axioms or reduction rules are provided:▼
To get an assignment statement into such a position it is "bubbled up" through function applications and the right-hand side of assignment statements until it reaches the proper point. Since intervening let expressions may declare distinct variables, the calculus also demands an extrusion rule for let expressions.
Most published formulations of the calculus show "bubble rules" with the convenience of evaluation contexts. For example, the grammar of the contexts in a simple [[call-by-value]] language (based on lambda syntax) and its evaluation contexts can be given as:
E = [] | v E | E e | x <- E | let rec x = v in E | E; e
The technique is useful for the ease in which reduction contexts can model state or control constructs (e.g., [[continuations]]). In addition, reduction semantics have been used to model [[object-oriented]] languages,<ref>{{cite book|title=A Theory of Objects|last1=Abadi|first1=M.|last2=Cardelli|first2=L.|date=8 September 2012|isbn=9781441985989|url=https://books.google.com/books?id=AgzSBwAAQBAJ&q=%22operational+semantics%22}}</ref> [[design by contract|contract systems]], and other language features.▼
▲The evaluation contexts
E[ x <- v; e ] ---> x <- v; E[e] (lift assignments)
This single axiom is the lift axion from Felleisen and Hieb's lambda calculus for assignment statements. The evaluation contexts restricts this redex to certain terms but it is freely applicable in any term, including below lambdas.
Following Plotkin, showing the usefulness of such a calculus demands: (1) a Church-Rosser lemma for the single-step relation, which induces an evaluation function; (2) a Curry-Feys standardization lemma for the transitive-reflexive closure of the singe-step relation, which replaces the non-deterministic search in the evaluation function with a deterministic left-most/outermost search. Felleisen showed that imperative extensions of this calculus satisfy these theorems. Consequences of these theorems are that the equational theory---the symmetric-transitive-reflexive closure---is a sound reasoning principle for these languages. Most application of reduction semantics dispense with the calculus and use the standard reduction only.
▲The technique is useful for the ease in which reduction contexts can model state or control constructs (e.g., [[continuations]]). In addition, reduction semantics have been used to model [[object-oriented]] languages,<ref>{{cite book|title=A Theory of Objects|last1=Abadi|first1=M.|last2=Cardelli|first2=L.|date=8 September 2012|isbn=9781441985989|url=https://books.google.com/books?id=AgzSBwAAQBAJ&q=%22operational+semantics%22}}</ref> [[design by contract|contract systems]], exceptions, futures, call-by-need, and many other language features.
===Big-step semantics===
|