Terms¶
Terms are the fundamental building blocks of the deductive system. This page explains the different types of terms and how to work with them.
Term Types¶
The deductive system supports three basic types of terms:
Variables¶
Variables are placeholders that can be unified with other terms during inference. They are prefixed with a backtick (`).
1 2 3 4 | |
Variables are used in rules to represent any term that can match during unification. During the inference process, variables can be bound to specific terms through unification.
Variable Naming
Variable names can contain any characters except backtick, whitespace and parentheses. By convention, single uppercase letters like `X, `P, `Q are often used for simple logic, while descriptive names like `person or `result improve readability in complex rules.
Items¶
Items represent constants or functors. They are atomic values without any special prefix.
1 2 3 4 5 | |
Items can represent:
- Constants: Atomic values like
john,mary,42 - Functors: Symbols that combine other terms, like
father,->,! - Operators: Special symbols used in logical expressions, like
->for implication or!for negation
Item Characters
Items can contain any characters except backtick, whitespace and parentheses. Special symbols like ->, !, <-, &&, || are commonly used as logical operators.
Lists¶
Lists are ordered sequences of terms enclosed in parentheses. They can contain any combination of variables, items, and nested lists.
1 2 3 4 | |
Lists are the primary way to build complex structures in the deductive system. They can represent:
- Relations:
(father john mary)- "John is the father of Mary" - Logical expressions:
(P -> Q)- "P implies Q" - Nested structures:
(! (! X))- "not not X" (double negation) - Data collections:
(1 2 3 4 5)- a list of numbers
List Nesting
Lists can be nested to any depth:
1 2 | |
Creating Terms¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Term Operations¶
Grounding¶
Grounding substitutes variables in a term with values from a dictionary. The dictionary is a list of key-value pairs where each key is a variable and each value is its substitution.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
1 2 3 4 5 6 7 8 9 10 11 12 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Matching¶
Matching unifies two terms and returns a dictionary of variable bindings. The dictionary contains the substitutions needed to make the two terms equal.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Renaming¶
Renaming adds prefixes and/or suffixes to all variables in a term. This is useful for avoiding variable name collisions during unification.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
1 2 3 4 5 6 7 8 9 10 11 12 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Buffer Size¶
Operations like grounding and renaming require buffer space for intermediate results in TypeScript/Javascript and Python. You can control this using buffer size functions.
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
See Also¶
- Rules - How to create and work with inference rules
- Search Engine - Performing logical inference