.. index:: termp
.. _termp/0:

.. rst-class:: right

**protocol**

``termp``
=========

Term utility predicates protocol.

| **Author:** Paulo Moura
| **Version:** 1:33:0
| **Date:** 2021-04-13

| **Compilation flags:**
|    ``static``


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. raw:: html

   <div id="depth/2"> </div>

.. index:: depth/2
.. _termp/0::depth/2:

``depth/2``
^^^^^^^^^^^

True if the depth of ``Term`` is ``Depth``. The depth of atomic terms is zero; the depth of a compound term is one plus the maximum depth of its sub-terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``depth(Term,Depth)``
| **Mode and number of proofs:**
|    ``depth(@term,?integer)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="ground/1"> </div>

.. index:: ground/1
.. _termp/0::ground/1:

``ground/1``
^^^^^^^^^^^^

True if the argument is ground. Deprecated. Use the ``ground/1`` standard predicate instead.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``ground(Term)``
| **Mode and number of proofs:**
|    ``ground(@term)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="new/1"> </div>

.. index:: new/1
.. _termp/0::new/1:

``new/1``
^^^^^^^^^

Creates a new term instance (if meaningful).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``new(Term)``
| **Mode and number of proofs:**
|    ``new(-nonvar)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="occurs/2"> </div>

.. index:: occurs/2
.. _termp/0::occurs/2:

``occurs/2``
^^^^^^^^^^^^

True if the variable occurs in the term.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``occurs(Variable,Term)``
| **Mode and number of proofs:**
|    ``occurs(@var,@term)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="subsumes/2"> </div>

.. index:: subsumes/2
.. _termp/0::subsumes/2:

``subsumes/2``
^^^^^^^^^^^^^^

The first term subsumes the second term. Deprecated. Use the ``subsumes_term/2`` standard predicate instead.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``subsumes(General,Specific)``
| **Mode and number of proofs:**
|    ``subsumes(?term,@term)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="subterm/2"> </div>

.. index:: subterm/2
.. _termp/0::subterm/2:

``subterm/2``
^^^^^^^^^^^^^

The first term is a subterm of the second term.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``subterm(Subterm,Term)``
| **Mode and number of proofs:**
|    ``subterm(?term,+term)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="valid/1"> </div>

.. index:: valid/1
.. _termp/0::valid/1:

``valid/1``
^^^^^^^^^^^

Term is valid.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``valid(Term)``
| **Mode and number of proofs:**
|    ``valid(@nonvar)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="check/1"> </div>

.. index:: check/1
.. _termp/0::check/1:

``check/1``
^^^^^^^^^^^

Checks if a term is valid. Throws an exception if the term is not valid.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``check(Term)``
| **Mode and number of proofs:**
|    ``check(@nonvar)`` - ``one``


------------

.. raw:: html

   <div id="variant/2"> </div>

.. index:: variant/2
.. _termp/0::variant/2:

``variant/2``
^^^^^^^^^^^^^

Each term is a variant of the other (i.e. they are structurally equivalent).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``variant(Term1,Term2)``
| **Mode and number of proofs:**
|    ``variant(@term,@term)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="variables/2"> </div>

.. index:: variables/2
.. _termp/0::variables/2:

``variables/2``
^^^^^^^^^^^^^^^

Returns a list of all term variables (ordered as found when doing a depth-first, left-to-right traversal of ``Term``).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``variables(Term,List)``
| **Mode and number of proofs:**
|    ``variables(@term,-list)`` - ``one``


------------

.. raw:: html

   <div id="singletons/2"> </div>

.. index:: singletons/2
.. _termp/0::singletons/2:

``singletons/2``
^^^^^^^^^^^^^^^^

Returns a list of all term singleton variables (ordered as found when doing a depth-first, left-to-right traversal of ``Term``).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``singletons(Term,Singletons)``
| **Mode and number of proofs:**
|    ``singletons(@term,-list)`` - ``one``


------------

.. raw:: html

   <div id="numbervars/3"> </div>

.. index:: numbervars/3
.. _termp/0::numbervars/3:

``numbervars/3``
^^^^^^^^^^^^^^^^

Grounds a term by replacing all variables with ``'$VAR'(N)`` terms with ``N`` starting at ``From``. The ``Next`` argument is unified with the next value for ``N`` after binding all variables.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``numbervars(Term,From,Next)``
| **Mode and number of proofs:**
|    ``numbervars(?term,+integer,?integer)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="numbervars/1"> </div>

.. index:: numbervars/1
.. _termp/0::numbervars/1:

``numbervars/1``
^^^^^^^^^^^^^^^^

Grounds a term by replacing all variables with ``'$VAR'(N)`` terms with ``N`` starting at ``0``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``numbervars(Term)``
| **Mode and number of proofs:**
|    ``numbervars(?term)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="varnumbers/3"> </div>

.. index:: varnumbers/3
.. _termp/0::varnumbers/3:

``varnumbers/3``
^^^^^^^^^^^^^^^^

Replaces all ``'$VAR'(N)`` sub-terms in a term with fresh variables for all values of ``N`` grater or equal to ``From``. Variables in ``Term`` are shared with ``Copy``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``varnumbers(Term,From,Copy)``
| **Mode and number of proofs:**
|    ``varnumbers(@term,+integer,?term)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="varnumbers/2"> </div>

.. index:: varnumbers/2
.. _termp/0::varnumbers/2:

``varnumbers/2``
^^^^^^^^^^^^^^^^

Replaces all ``'$VAR'(N)`` sub-terms in a term with fresh variables for all values of ``N`` grater or equal to ``0``. Variables in ``Term`` are shared with ``Copy``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``varnumbers(Term,Copy)``
| **Mode and number of proofs:**
|    ``varnumbers(@term,?term)`` - ``zero_or_one``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

.. seealso::

   :ref:`term <term/0>`

