Skip to content

Term

Term

Bases: KIF_Object[Unpack[Ts]]

Abstract base class for terms.

variables property

The set of variables occurring in term.

InstantiationError

Bases: ValueError

Bad instantiation attempt.

generalize(exclude=(), rename=None, prefix=None)

Replaces None values 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 (Iterable[Term | str], default: () ) –

    Name variant exclusion list.

  • rename (Callable[[str], Iterator[str]] | None, default: None ) –

    Name variant generator.

  • prefix (str | None, default: None ) –

    Name variant prefix.

Returns:

  • Self

    Term.

get_variables()

Gets the set of variables occurring in term.

Returns:

instantiate(theta, coerce=True, strict=False)

Applies variable instantiation theta to term.

Parameters:

  • theta (Theta) –

    Variable instantiation.

  • coerce (bool, default: True ) –

    Whether to consider coercible variables equal.

  • strict (bool, default: False ) –

    Whether to adopt stricter coercion rules.

Returns:

  • Term | None

    Term or None.

is_closed(arg) classmethod

Tests whether argument is a closed term.

Returns:

  • bool

    True if successful; False otherwise.

is_open(arg) classmethod

Tests whether argument is an open term.

Returns:

  • bool

    True if successful; False otherwise.

match(other)

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) –

    Term.

Returns:

  • Theta | None

    A variable instantiation theta if successful; None otherwise.

rename(exclude=(), rename=None)

Renames all variables occurring in term.

Picks name variants not occurring in exclude.

Uses rename (if given) to generate name variants.

Parameters:

  • exclude (Iterable[Term | str], default: () ) –

    Name exclusion list.

  • rename (Callable[[str], Iterator[str]] | None, default: None ) –

    Name variant generator.

Returns:

  • Self

    Term.

unify(*eqs) classmethod

Computes an instantiation that unifies term equations.

Parameters:

  • eqs (tuple[Term, Term], default: () ) –

    Pairs of terms (potential equations).

Returns:

  • Theta | None

    A variable instantiation theta if successful; None otherwise.

Theta = Mapping['Variable', Optional['Term']] module-attribute