Term
- class Term(*args: Any, **kwargs: Any)[source]
Bases:
KIF_ObjectAbstract base class for terms.
- classmethod is_closed(arg: Any) bool[source]
Tests whether argument is a closed term.
- Returns:
Trueif successful;Falseotherwise.
- classmethod is_open(arg: Any) bool[source]
Tests whether argument is an open term.
- Returns:
Trueif successful;Falseotherwise.
- classmethod unify(*eqs: tuple[Term, Term]) Theta | None[source]
Computes an instantiation that unifies term equations.
- Parameters:
eqs – Pairs of terms (potential equations).
- Returns:
A variable instantiation theta if successful;
Noneotherwise.
- get_variables() Set[Variable][source]
Gets the set of variables occurring in term.
- Returns:
Set of variables.
- instantiate(theta: Theta, coerce: bool = True, strict: bool = False) Term | None[source]
Applies variable instantiation theta to term.
- Parameters:
theta – Variable instantiation.
coerce – Whether to consider coercible variables equal.
strict – Whether to adopt stricter coercion rules.
- Returns:
Term or
None.
- match(other: Term) Theta | None[source]
Tests whether term matches other.
If term matches other, returns a variable instantiation theta that can be used to unify both term and other. Otherwise, return
None.- Parameters:
other – Term.
- Returns:
A variable instantiation theta if successful;
Noneotherwise.
- generalize(exclude: Iterable[Term | str] = (), rename: Callable[[str], Iterator[str]] | None = None, prefix: str | None = None) Self[source]
Replaces
Nonevalues occurring in term by fresh variables.Picks name variants not occurring in exclude.
Uses rename (if given) to generate name variants.
Uses prefix (if given) as prefix for name variants.
- Parameters:
exclude – Name variant exclusion list.
rename – Name variant generator.
prefix – Name variant prefix.
- Returns:
Term.
- rename(exclude: Iterable[Term | str] = (), rename: Callable[[str], Iterator[str]] | None = None) Self[source]
Renames all variables occurring in term.
Picks name variants not occurring in exclude.
Uses rename (if given) to generate name variants.
- Parameters:
exclude – Name exclusion list.
rename – Name variant generator.
- Returns:
Term.
- class ClosedTerm(*args: Any, **kwargs: Any)[source]
Bases:
TermAbstract base class for closed (ground) terms.
- instantiate(theta: Theta, coerce: bool = True, strict: bool = False) Term[source]
Applies variable instantiation theta to term.
- Parameters:
theta – Variable instantiation.
coerce – Whether to consider coercible variables equal.
strict – Whether to adopt stricter coercion rules.
- Returns:
Term or
None.
- class OpenTerm(*args: Any, **kwargs: Any)[source]
Bases:
TermAbstract base class for open terms.
- object_class: ClassVar[type[ClosedTerm]]
Closed-term class associated with this open-term class.
- class Template(*args: Any, **kwargs: Any)[source]
Bases:
OpenTermAbstract base class for templates.
- object_class: ClassVar[type[ClosedTerm]]
Object class associated with this template class.
- instantiate(theta: Mapping[Variable, Term | None], coerce: bool = True, strict: bool = False) Term[source]
Applies variable instantiation theta to term.
- Parameters:
theta – Variable instantiation.
coerce – Whether to consider coercible variables equal.
strict – Whether to adopt stricter coercion rules.
- Returns:
Term or
None.
- class Variable(name: str | None = None, variable_class: type[Variable] | type[Term] | None = None)[source]
Bases:
OpenTermBase class for variables.
- Parameters:
name – Name or
None(fresh name).variable_class – Variable class.
- classmethod check(arg: Any, function: Callable[[...], Any] | str | None = None, name: str | None = None, position: int | None = None) Self[source]
Coerces arg into an instance of this class.
If arg cannot be coerced, raises an error.
- Parameters:
arg – Value.
function – Function or function name.
name – Argument name.
position – Argument position.
- Returns:
Object.
- property name: str
The name of variable.