Markdown tweaks and minor spelling/wording tweaks.
catseye
11 years ago
7 | 7 | ------------ |
8 | 8 | |
9 | 9 | Treacle is a programming language based on an extended form of |
10 | term-rewriting which we shall call, somewhat innacurately (or at least | |
11 | arbitrarily,) *context rewriting*. | |
12 | ||
13 | Like Arboretuum, its successor built around *forest-rewriting*, Treacle | |
10 | term-rewriting which we shall call, somewhat inaccurately (or at least | |
11 | arbitrarily,) _context rewriting_. | |
12 | ||
13 | Like Arboretuum, its successor built around _forest-rewriting_, Treacle | |
14 | 14 | was intended as a language for specifying compilers. Treacle is somewhat |
15 | 15 | more successful at pulling it off, however; context rewriting |
16 | 16 | encompasses, and is more expressive than, forest-rewriting. |
17 | 17 | |
18 | 18 | Context rewriting is meant to refer to the fact that Treacle's rewriting |
19 | patterns may contain holes – designated "containers" for subpatterns | |
19 | patterns may contain _holes_ – designated "containers" for subpatterns | |
20 | 20 | which may match not just the *immediate* child of the term which the |
21 | 21 | parent pattern matched (as in conventional term-rewriting) but also *any |
22 | 22 | one of that child's descendents*, no matter how deeply nested. |
30 | 30 | pattern. |
31 | 31 | |
32 | 32 | Context rewriting also deconstructs the conventional concept of the |
33 | variable, splitting it into a name and a wildcard. Any pattern or | |
33 | variable, splitting it into a _name_ and a _wildcard_. Any pattern or | |
34 | 34 | subpattern may be named, not just wildcards. Even holes may be named. At |
35 | 35 | the same time, wildcards, which match arbitrary terms, may occur |
36 | 36 | unnamed. Upon a successful match, only those terms which matched named |
37 | 37 | patterns are recorded in the unifier. |
38 | 38 | |
39 | Further, each rule in Treacle may contain multiple terms (replacements) | |
39 | Further, each rule in Treacle may contain multiple terms (_replacements_) | |
40 | 40 | on the right-hand side of a rewriting rule, and each of these may have |
41 | its own name. When the term undergoing rewriting (called the subject) is | |
41 | its own name. When the term undergoing rewriting (called the _subject_) is | |
42 | 42 | rewritten, each named replacement is substituted into the subject at the |
43 | 43 | position matched by the part of the pattern that is labelled by that |
44 | 44 | same name. |
45 | 45 | |
46 | Lastly, replacements may contain special atomic terms called newrefs. | |
46 | Lastly, replacements may contain special atomic terms called _newrefs_. | |
47 | 47 | When a newref is written into the subject, it takes the form of a new, |
48 | 48 | unique symbol, guaranteed (or at least reasonably assumed) to be |
49 | 49 | different from all other symbols that are in, or could be in, the |
82 | 82 | |
83 | 83 | Now we are ready to give some examples. |
84 | 84 | |
85 | ### Patterns | |
85 | ### Patterns ### | |
86 | 86 | |
87 | 87 | - The pattern `(a b (? X *))` matches `(a b (c (d b)))`, with the |
88 | 88 | unifier `X=(c (d b))`. Also, `(a (? Y *) (c (d (? Y *))))` matches |
110 | 110 | search the contents of the 3rd subterm, for whatever the 2nd subterm |
111 | 111 | is. |
112 | 112 | |
113 | ### Rules | |
113 | ### Rules ### | |
114 | 114 | |
115 | 115 | - Say we have a rule where the pattern is `(a b (:i (? X (d b))))`, |
116 | 116 | and the lone replacement is `X : a`. This rule would match the |
193 | 193 | of information in the tree of terms that relate to the reduction you |
194 | 194 | want to accomplish, they have to be in a bounded distance from, and in a |
195 | 195 | fixed relationship with, each other. If some piece is far away, it will |
196 | have to be brought – *literally* brought! – to bear on the situation, by | |
196 | have to be brought to bear on the situation – *literally* brought, by | |
197 | 197 | moving it through the tree through successive "bubbling" rewrites. |
198 | 198 | |
199 | 199 | Forest-rewriting eases this by having multiple independent trees: some |