Draft:Definitional tree
Submission declined on 14 July 2025 by S0091 (talk). This submission is not adequately supported by reliable sources. Reliable sources are required so that information can be verified. If you need help with referencing, please see Referencing for beginners and Citing sources. This submission reads more like an essay than an encyclopedia article. Submissions should summarise information in secondary, reliable sources and not contain opinions or original research. Please write about the topic from a neutral point of view in an encyclopedic manner.
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
| ![]() |
Comment: You are writing this backwards, meaning you writing with what you know then trying to fill in sources that might support your knowledge. See WP:BACKWARD. Start over. You need to use reliable sources that have no affiliation with you and summarize what they say with no editiorizing. S0091 (talk) 21:06, 14 July 2025 (UTC)
![]() | A major contributor to this article appears to have a close connection with its subject. (July 2025) |
In mathematics and computer science, a definitional tree is a
tree data structure
used in the evaluation of expressions by
rewriting.
Definitional trees are instrumental in finding
needed[1]
evaluation steps.
This is notable because
unless every needed step of an expression is eventually executed,
the value of the expression cannot be obtained.
Background
[edit]The rewriting systems considered in this note follow the constructor discipline.[2] The signature of a system is partitioned into two sets: the data constructors (constructors for short) and the defined operations (operations or functions for short). The intuition is that expressions made only of constructors represent data whereas operations represent functions. Rewriting systems that obey the constructor discipline are also called constructor systems.
In constructor systems, the rewrite rules of an operation define the behavior of the operation applied to data values. More formally, the constructor discipline requires the left-hand side of a rewrite rule to be a pattern, i.e., an expression in which the root is an operation symbol, and the children of the root are expressions consisting of constructor symbols and/or variables only. Patterns are linear, i.e., any variable has at most one occurrence in a pattern.
Types are marginal to the definitional trees. Without further consideration, we establish that all the expressions discussed in this article are well-typed.
Example 1
[edit]
The following rewrite rules define a rewrite system. The system implicitly assumes the existence of a type, Nat. The system's signature consists of three symbols whose types are inferred from the context. 0 is a constructor of type Nat, s is a constructor from Nat to Nat and + is an operation (denoted infix) from NatNat to Nat:
0 + y -> y s(x) + y -> s(x + y)
The intuition is that an expression consisting of 0 and s stands for a natural number in unary notation, e.g., s(s(0)) stands for 2, and + is the familiar addition operator, e.g., s(s(0))+s(s(0)) evaluates, in a few steps, to s(s(s(s(0)))), i.e., 4.
Definition
[edit]We assume an arbitrary, but fixed, ordering among the constructors of any type.
The nodes of a definitional tree come in three variants called branch, rule, and exempt. Any node, regardless of the variant, contains a pattern denoted by and possibly other information as follows:
- , no other information beside the pattern;
- , where is a rule and and are equal except for a renaming of the variables;
- , where is a variable of called inductive, and is a definitional tree with a pattern such that is equal to except that is replaced by , where is the constructor of the type of , is its arity, and is a fresh variable, for all appropriate .
A definitional tree of an operation is a definitional tree with the following requirements:
- The pattern in the root of is where, for all appropriate , is a fresh variable;
- The rule nodes of contain all and only the rules of ;
- Below every branch node of there is a rule node.
Exempt nodes occur in the definitional trees of incompletely defined operations, e.g., the operation that computes the head of a list. Such operation is not defined when the argument is the empty list.
Example 2
[edit]The textual representation of the definitional tree of the operation + presented in Example 1 is:
Definitional trees have a graphical representation that eases understanding. The names of the variables in a pattern are irrelevant. Hence all the variables are denoted by the same symbol, , with the convention that each occurrence is unique. The inductive variable contained in any branch node is represented by in the pattern. We assume an arbitrary, but fixed, ordering among the rewrite rules of an operation. The rule in a rule node is represented by the rule index in this ordering.
Evaluation
[edit]
An operation is called inductively sequential if there exists a definitional tree of . There are operations that do not have any definitional tree, e.g., the parallel or, and operations that have more than one. In this case, any tree can be used by the evaluation algorithm discussed below.
Rewriting systems in which every operation is inductively sequential are called inductively sequential as well and support the optimal, sequential evaluation strategy presented below.
Procedure needed, presented in annotated, Algol-like pseudo-code below, implements the algorithm to compute a needed redex of an expression . Without loss of generality assume that is an expression rooted by an operation. The call needed either finds both a needed redex of , if one there exists, and a rule to reduce it, or determines that has no value. A value of an expression, , is a expression derived from and consisting of constructor symbols only.
procedure needed(): assumption: is an expression rooted by an operation procedure traverse(): let be the pattern of invariant: is an instance of case of: : output is a needed redex reducible by : output has no value : if is an instance of the pattern of , for some : then traverse() else needed(), where is the match of traverse(), where is a definitional tree of the root of |
Procedure traverse, nested within procedure needed, has access to its local variable, . Informally, the algorithm works as follows. Given an expression of the form , where is a function symbol of arity and is some expression for all appropriate , find in the definitional tree of a deepest node, say , whose pattern matches . There always exists exactly one such node. If is a branch node, then the match of the inductive variable is a subexpression of , say , rooted by a function symbol. Unless this expression is reduced to an expression rooted by a constructor symbol, no rule can be applied to . Hence, the recursive call. If is a rule node, then is a needed redex reducible by the rule of . If is an exempt node, then has no value.
Properties
[edit]Definitional trees have been invented by S. Antoy in 1992.
The inductively sequential rewriting systems are the intersection[3] of the constructor systems and the strongly sequential systems.[1] Hence, the inductively sequential systems are the largest constructor class in which needed redexes are computable.
Definitional trees define the operational semantics of the functional logic programming languages [4]: Sect. G and Curry.[5]: Sect. D
References
[edit]- ^ a b Huet, Gérard; Lévy, Jean-Jacques (1991). Computations in orthogonal term rewriting systems. Computational Logic: Essays in honor of Alan Robinson. Cambridge, MA: MIT Press. pp. 395–443. Retrieved June 23, 2025.
- ^
O'Donnell, Michael J. (1985). Equational Logic as a Programming Language. Cambridge, MA 02142: The MIT Press. p. 250. ISBN 978-0-262-15028-6. Retrieved June 23, 2025.
{{cite book}}
: CS1 maint: location (link) - ^ Hanus, Michael; Lucas, Salvador; Middeldorp, Aart (1998). "Strongly Sequential and Inductively Sequential Term Rewriting Systems". Inf. Process. Lett. 67: 1–8. doi:10.1016/S0020-0190(98)00016-7.
- ^ Caballero, Rafael; Sánchez, Jaime, eds. (October 2011). : A Multiparadigm Declarative Language (Report). 2.3.2. Universidad Complutense de Madrid. Retrieved June 23, 2023.
- ^ Hanus, Michael, ed. (2016). Curry: An Integrated Functional Logic Language (Vers. 0.9.0) (Report). Retrieved June 23, 2023.