RulesTreeCopy to clipboard.
✖
RulesTree
gives a tree whose root contains data and that has children specified by the rulei.
Details and Options

- RulesTree gives a Tree object.
- The children of RulesTree[data{rule1,rule2,…}] are given by the list {RulesTree[rule1],RulesTree[rule2],…}.
- The children of RulesTree[data<key1rule1,key2rule2,… >] are given by the association <key1RulesTree[rule1],key2RulesTree[rules2],… >.
- RulesTree[data] for data not of the form …{…}, …<… > or …None is equivalent to RulesTree[dataNone]. »
- RulesTree takes the same options as Tree.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Construct a tree with three leaves:

https://wolfram.com/xid/0cg49mzfw-by4nss

Construct a tree with several levels:

https://wolfram.com/xid/0cg49mzfw-bnyksz

Construct a tree with named edges:

https://wolfram.com/xid/0cg49mzfw-dp54us

Scope (4)Survey of the scope of standard use cases
Construct a leaf with no child:

https://wolfram.com/xid/0cg49mzfw-ehthw0

Construct an inner node with no children:

https://wolfram.com/xid/0cg49mzfw-imf82i


https://wolfram.com/xid/0cg49mzfw-lsrqz6


https://wolfram.com/xid/0cg49mzfw-kj42p9

Specify an association of children:

https://wolfram.com/xid/0cg49mzfw-8hbu8x

Options (9)Common values & functionality for each option
Styling Individual Tree Elements (2)
Specify the label for the generated tree element:

https://wolfram.com/xid/0cg49mzfw-xl5r69

Specify labels and styles for subtrees by position:

https://wolfram.com/xid/0cg49mzfw-x143u1

Styling Entire Tree (4)
Specify labels and styles for all subtrees:

https://wolfram.com/xid/0cg49mzfw-corr7


https://wolfram.com/xid/0cg49mzfw-xdirf9

Specify the styles for both the edges and the edges of the tree elements:

https://wolfram.com/xid/0cg49mzfw-s5hou5

Specify the base style and styles for individual tree elements:

https://wolfram.com/xid/0cg49mzfw-ifl4r4

Tree Layout and Graphics Options (3)
Specify the orientation for the root:

https://wolfram.com/xid/0cg49mzfw-dis7x2


https://wolfram.com/xid/0cg49mzfw-i8q32r

Specify Graphics options:

https://wolfram.com/xid/0cg49mzfw-dbhiu5

Applications (1)Sample problems that can be solved with this function
Properties & Relations (2)Properties of the function, and connections to other functions
RulesTree constructs a tree associated with the given rules:

https://wolfram.com/xid/0cg49mzfw-k5b8dz

Use TreeRules on the result to recover the original rules:

https://wolfram.com/xid/0cg49mzfw-1xgvfd

RulesTree can be computed with NestTree:

https://wolfram.com/xid/0cg49mzfw-5bkfq

https://wolfram.com/xid/0cg49mzfw-c7ramd

https://wolfram.com/xid/0cg49mzfw-3kqsjo


https://wolfram.com/xid/0cg49mzfw-q0zg48

Possible Issues (1)Common pitfalls and unexpected behavior
RulesTree[exprNone] is generally equivalent to RulesTree[expr]:

https://wolfram.com/xid/0cg49mzfw-noy2dk


https://wolfram.com/xid/0cg49mzfw-g9mc1h

However, the None is necessary to specify a tree with data of the form lhs{e1,e2,…} or lhsNone:

https://wolfram.com/xid/0cg49mzfw-mzap99

Without the None, this would be treated as a tree whose root contains lhs with children {RulesTree[e1],RulesTree[e2],…}:

https://wolfram.com/xid/0cg49mzfw-lvbte4

Wolfram Research (2021), RulesTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RulesTree.html (updated 2022).
Text
Wolfram Research (2021), RulesTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RulesTree.html (updated 2022).
Wolfram Research (2021), RulesTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RulesTree.html (updated 2022).
CMS
Wolfram Language. 2021. "RulesTree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/RulesTree.html.
Wolfram Language. 2021. "RulesTree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/RulesTree.html.
APA
Wolfram Language. (2021). RulesTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RulesTree.html
Wolfram Language. (2021). RulesTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RulesTree.html
BibTeX
@misc{reference.wolfram_2025_rulestree, author="Wolfram Research", title="{RulesTree}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/RulesTree.html}", note=[Accessed: 26-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_rulestree, organization={Wolfram Research}, title={RulesTree}, year={2022}, url={https://reference.wolfram.com/language/ref/RulesTree.html}, note=[Accessed: 26-March-2025
]}