Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Graph reduction
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Motivation == A simple example of evaluating an arithmetic expression follows: :<math> \begin{align} & {} & &((2+2)+(2+2))+(3+3) \\ & {} &=&((2+2)+(2+2))+ 6 \\ & {} &=&((2+2)+ 4)+6 \\ & {} &=&(4+4)+6 \\ & {} &=&8+6 \\ & {} &=&14 \end{align} </math> The above reduction sequence employs a strategy known as [[outermost tree reduction]]. The same expression can be evaluated using [[innermost tree reduction]], yielding the reduction sequence: :<math> \begin{align} & {} & &((2+2)+(2+2))+(3+3) \\ & {} &= &((2+2)+4)+(3+3) \\ & {} &= &(4+4)+(3+3) \\ & {} &= &(4+4)+6 \\ & {} &= &8+6 \\ & {} &= &14 \end{align} </math> Notice that the reduction order is made explicit by the addition of parentheses. This expression could also have been simply evaluated right to left, because addition is an [[associative]] operation. Represented as a [[Tree data structure|tree]], the expression above looks like this: [[Image:Expression Tree.svg|300px]] This is where the term tree reduction comes from. When represented as a tree, we can think of innermost reduction as working from the bottom up, while outermost works from the top down. The expression can also be represented as a [[directed acyclic graph]], allowing sub-expressions to be shared: [[Image:Expression Graph.svg|300px]] As for trees, outermost and innermost reduction also applies to graphs. Hence we have '''graph reduction'''. Now evaluation with outermost graph reduction can proceed as follows: [[Image:Expression Graph Reduction.svg|200px]] Notice that evaluation now only requires four steps. Outermost graph reduction is referred to as [[lazy evaluation]] and innermost graph reduction is referred to as [[eager evaluation]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)