A subterm of a first-order term is a term appearing at a node of its syntactic tree, including the whole term. Recursively, a variable or constant has only itself as a subterm; the subterms of are the full term together with every subterm of every . A proper subterm excludes the full term.
For , the distinct subterms are , and . The subterm occurs twice, so a subterm value and a subterm occurrence are different notions. Replacing a particular occurrence requires its position in the tree, not only its text.
The subterm relation organizes structural induction, recursive evaluation and term rewriting. Every proper subterm has smaller syntactic size in the usual finite term grammar, so recursive definitions can terminate by descending through the tree. A substring of printed notation is not automatically a subterm: the tree structure determines which expressions are complete terms.
New to topics? Read the docs here!