Term

class Term(*args, **kwargs)[source]

Bases: KIF_Object

Abstract base class for terms.

classmethod is_closed(arg: Any) bool[source]

Tests whether argument is a closed term.

Returns:

True if successful; False otherwise.

classmethod is_open(arg: Any) bool[source]

Tests whether argument is an open term.

Returns:

True if successful; False otherwise.

class ClosedTerm(*args, **kwargs)[source]

Bases: Term

Abstract base class for closed (ground) terms.

template_class: ClassVar[type[Template]]

Template class associated with this closed-term class.

variable_class: ClassVar[type[Variable]]

Variable class associated with this closed-term class.

class OpenTerm(*args, **kwargs)[source]

Bases: Term

Abstract base class for open terms.

object_class: ClassVar[type[ClosedTerm]]

Closed-term class associated with this open-term class.

exception InstantiationError[source]

Bases: ValueError

Bad instantiation attempt.

property variables: Set[Variable]

The set of variables occurring in open term.

get_variables() Set[Variable][source]

Gets the set of variables occurring in open term.

Returns:

Set of variables.

instantiate(theta: Theta, coerce: bool = True) Term | None[source]

Applies variable instantiation theta to open term.

Parameters:
  • theta – Variable instantiation.

  • coerce – Whether to consider coercible variables equal.

Returns:

Term or None.

class Template(*args, **kwargs)[source]

Bases: OpenTerm

Abstract 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) Term[source]

Applies variable instantiation theta to open term.

Parameters:
  • theta – Variable instantiation.

  • coerce – Whether to consider coercible variables equal.

Returns:

Term or None.

class Variable(name: str, variable_class: type[Variable] | type[Term] | None = None)[source]

Bases: OpenTerm

Base class for variables.

Parameters:
  • name – 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.

__init__(name: str, object_class: type[Term] | None = None) None[source]
property name: str

The name of variable.

get_name() str[source]

Gets the name of variable.

Returns:

Name.

object_class: ClassVar[type[ClosedTerm]]

Closed-term class associated with this open-term class.