YAP 7.1.0
Term Manipulation

Detailed Description

Modules

 Inlined Tests and Term Manipulation
 
 Term Visit and Manipulation
 

Class Documentation

◆ att_rec

struct att_rec

routine to locate attributed variables

Definition at line 625 of file terms.c.

Public Attributes

CELL * beg
 
CELL * end
 
CELL d0
 

Member Data Documentation

◆ beg

CELL* beg

Definition at line 626 of file terms.c.

◆ d0

CELL d0

Definition at line 626 of file terms.c.

◆ end

CELL * end

Definition at line 626 of file terms.c.

◆ cyclic_term/1

class cyclic_term/1

cyclic_term( + T )

cyclic_term(? Term)

Succeeds if the graph representation of the term has loops Say, The representation of a term X that obeys the equation X=[X] term has a loop from the list to its head

Succeed if the argument Term is a cyclic term

◆ ground/1

class ground/1

ground( T)

defined in the ISO standard

Succeeds if there are no free variables in the term T

◆ variables_in_term/3

class variables_in_term/3

variables_in_term( +_t, +_SetOfVariables_, +_ExtendedSetOfVariables_ )

SetOfVariables must be a list of unbound variables If so, ExtendedSetOfVariables will include all te variables in the union of vars(_T_) and SetOfVariables

◆ term_variables/3

class term_variables/3

term_variables(? Term, - Variables, +_ExternalVars_)

defined in the ISO standard

Unify the difference list between Variables and ExternaVars with the list of all variables of term Term The variables occur in the order of their first appearance when traversing the term depth-first, left-to-right

◆ term_variables_union/3

class term_variables_union/3

term_variables_union(? Term1, - Term2, +_Vars_)

defined in the ISO standard

Unify Vars with all variables in either term

◆ term_variables_difference/3

class term_variables_difference/3

term_variables_difference(? Term1, - Term2, +_Vars_)

defined in the ISO standard

Unify Vars with all variables in Term1 and not in Term2

◆ term_variables/2

class term_variables/2

term_variables(? Term, - Variables)

defined in the ISO standard

Unify Variables with the list of all variables of term Term The variables occur in the order of their first appearance when traversing the term depth-first, left-to-right

◆ new_variables_in_term/3

class new_variables_in_term/3

new_variables_in_term(+_CurrentVariables_, ? Term, -_Variables_)

new_variables_in_term(+ Variables,? Term, - OutputVariables)

Unify Variables with the list of all variables of term Term that do not occur in CurrentVariables That is:

Variables = vars(Term) - CurrentVariables = The variables occur in the order of their first appearance when traversing the term depth-first, left-to-right

Unify OutputVariables with all variables occurring in Term that are not in the list Variables

◆ term_attvars/2

class term_attvars/2

term_attvars(+ Term,- AttVars)

AttVars is a list of all attributed variables in Term and its attributes I.e., term_attvars/2 works recursively through attributes This predicate is Cycle-safe

◆ numbervars/3

class numbervars/3

numbervars( t,+ _N1,- Nn)

Instantiates each variable in term  _T_ to a term of the form:

$VAR( _I_), with I increasing from N1 to Nn

◆ singleton_vs_numbervars/3

class singleton_vs_numbervars/3

singleton_vs_numbervars( t,+ _N1,- Nn)

Instantiates each variable in term T to a term of the form:

  • $VAR( _I_), with I increasing from N1 to Nn
  • or of the form 'S_JifJ is abs(I)`

YAP also accepts atoms and strings

◆ unnumbervars/1

class unnumbervars/1

unnumbervars(+ Term)

Replace all terms of the form $VAR(_) by unbound variables

◆ varnumbers/2

class varnumbers/2

varnumbers(+ Term, Term)

Replace all terms of the form $VAR(_) by unbound variables

Macro Definition Documentation

◆ ATOMIC_HOOK_CODE [1/2]

#define ATOMIC_HOOK_CODE   if (d0==TermNone) mSET(ptd0,(CELL)ptd0);

Definition at line 439 of file terms.c.

◆ ATOMIC_HOOK_CODE [2/2]

#define ATOMIC_HOOK_CODE
Value:
\
if (d0 == TermNone) {\
if (HR + 1024 > ASP) {\
stt->err = RESOURCE_ERROR_STACK;\
continue;\
}\
if (end == NULL) {\
first = AbsPair(HR);\
} else {\
end[0] = AbsPair(HR);\
}\
/* next make sure noone will see this, *start = HRs as a variable again */\
RESET_VARIABLE(ptd0);\
HR[0] = (CELL)ptd0;\
HR[1] = tail;\
end = HR + 1;\
HR += 2;\
}

Definition at line 439 of file terms.c.

◆ COMPOUND_HOOK_CODE [1/2]

#define COMPOUND_HOOK_CODE   if (IS_VISIT_MARKER(ptd1[0])) { goto found;}

Definition at line 887 of file terms.c.

◆ COMPOUND_HOOK_CODE [2/2]

#define COMPOUND_HOOK_CODE
Value:
if ( f == FunctorNumberVars ) { \
if ( ptd1[1] == TermUnderscore ) {\
mMaBind(ptd0,(CELL)ptd0); \
goto loop; \
}\
HR[0] = AbsPair(HR+2); \
HR[1] = *bp; \
*bp = AbsPair(HR);\
HR[2] = ptd1[1]; /* key */ \
HR[3] = (CELL) ptd0; /* variable */ \
mMaBind(ptd0,(CELL)ptd0); \
bp = HR+1; \
HR+= 4;\
goto loop; \
}

Definition at line 887 of file terms.c.

◆ DEB_DOOB

#define DEB_DOOB (   S,
  sp 
)

Definition at line 50 of file terms.c.

◆ DEB_DOOBIN

#define DEB_DOOBIN (   d0)

Definition at line 49 of file terms.c.

◆ DEB_DOOBOUT

#define DEB_DOOBOUT (   d0)    \

Definition at line 47 of file terms.c.

◆ LIST_HOOK_CODE

#define LIST_HOOK_CODE   if (IS_VISIT_MARKER(ptd1[0])) { goto found;}

Definition at line 174 of file terms.c.

◆ pop_sub_term

#define pop_sub_term (   A,
  B,
 
)    ( DEB_DOOB("-",A) pop_sub_term__(A,B,C))

Definition at line 61 of file terms.c.

◆ push_sub_term

#define push_sub_term (   A,
  B,
  C,
  D,
  E 
)
Value:
if (A->pt + 2 >= A->max && realloc_stack(stt) == 0) { \
A->err = RESOURCE_ERROR_AUXILIARY_STACK;\
continue;\
}\
push_sub_term__(A,B,C,D,E);
no_error E(DOMAIN_ERROR_ABSOLUTE_FILE_NAME_OPTION, DOMAIN_ERROR, "absolute_file_name_option") E(DOMAIN_ERROR_ARRAY_OVERFLOW
default state

Definition at line 55 of file terms.c.

◆ RESET_TERM_VISITOR_0

#define RESET_TERM_VISITOR_0 ( )
Value:
if (stt->err){ Term* pt0,*pt0_end;\
while ((pop_sub_term(stt, &pt0, &pt0_end))){} ; \
stt->arenap= NULL; \
stt->bindp = NULL; \
HR = stt->hlow; \
t = term_error_handler(stt->bindp,t,stt); \
stt->err = 0; \
}

Definition at line 87 of file terms.c.

◆ RESET_TERM_VISITOR_1

#define RESET_TERM_VISITOR_1 (   v,
  v0 
)
Value:
if (stt->err){ Term* pt0,*pt0_end;\
while ((pop_sub_term(stt, &pt0, &pt0_end))){} ; \
stt->arenap= NULL; \
stt->bindp = NULL; \
HR = stt->hlow;\
yhandle_t yv = Yap_InitHandle(v0); \
t = term_error_handler(stt->bindp,t,stt); \
stt->err = 0;\
v = v0=Yap_PopHandle(yv); \
}

Definition at line 97 of file terms.c.

◆ RESET_TERM_VISITOR_3

#define RESET_TERM_VISITOR_3 (   first,
  tail,
  tail0,
  end 
)
Value:
if (stt->err){ Term* pt0,*pt0_end;\
while ((pop_sub_term(stt, &pt0, &pt0_end))){}; \
stt->arenap= NULL; \
stt->bindp = NULL; \
HR = stt->hlow; \
yhandle_t yv = Yap_InitHandle(tail0);\
t = term_error_handler(stt->bindp,t,stt); \
tail0 = Yap_PopHandle(yv);\
tail = tail0;\
first = tail;\
end = NULL; \
stt->err = 0; \
}

Definition at line 111 of file terms.c.

◆ VAR_HOOK_CODE [1/6]

#define VAR_HOOK_CODE
Value:
while (pop_sub_term(stt, NULL, NULL)) ;\
stt->pt0=stt->pt=stt->max=NULL;\
return false;

routine to locate all variables in a term, and its application s

Definition at line 699 of file terms.c.

◆ VAR_HOOK_CODE [2/6]

#define VAR_HOOK_CODE
Value:
if (v == d0) {\
while (pop_sub_term(stt, NULL, NULL)) ;\
stt->pt0=stt->pt=stt->max=NULL;\
return true;\
}

routine to locate all variables in a term, and its application s

Definition at line 699 of file terms.c.

◆ VAR_HOOK_CODE [3/6]

#define VAR_HOOK_CODE
Value:
if (HR + 1024 > ASP) {\
stt->err = RESOURCE_ERROR_STACK;\
continue;\
}\
if (end == NULL) {\
first = AbsPair(HR);\
} else {\
end[0] = AbsPair(HR);\
}\
HR[0] = (CELL)ptd0;\
HR[1] = tail;\
end = (HR + 1); \
HR += 2;\

routine to locate all variables in a term, and its application s

Definition at line 699 of file terms.c.

◆ VAR_HOOK_CODE [4/6]

#define VAR_HOOK_CODE   mSET(ptd0, TermNone);

routine to locate all variables in a term, and its application s

Definition at line 699 of file terms.c.

◆ VAR_HOOK_CODE [5/6]

#define VAR_HOOK_CODE
Value:
mSET(pt0, TermNone); \
if (HR + 1024 > ASP) {\
stt->err = RESOURCE_ERROR_STACK;\
continue;\
}\
if (end == NULL) {\
first = AbsPair(HR);\
} else {\
end[0] = AbsPair(HR);\
}\
HR[0] = (CELL)ptd0;\
HR[1] = tail;\
end = (HR + 1); \
HR += 2;\

routine to locate all variables in a term, and its application s

Definition at line 699 of file terms.c.

◆ VAR_HOOK_CODE [6/6]

#define VAR_HOOK_CODE
Value:
if (!IS_VISIT_MARKER(*ptd0) && GlobalIsAttVar(ptd0)) {\
if (HR + 1024 > ASP) { \
stt->err = RESOURCE_ERROR_STACK;\
continue;\
}\
if (end == NULL) {\
first = AbsPair(HR);\
} else {\
end[0] = AbsPair(HR);\
}\
/* next make sure noone will see this, *start = HRs as a variable again */\
HR[0] = (CELL)ptd0;HR[1] = tail; \
end = HR + 1;\
HR += 2;\
ptd0[0] = TermNone;\
ptd0 += 2; \
dd0 = *ptd0;\
mderef_head(d0, dd0, var_in_term_unk); /*DEB_DOOB();*/\
goto var_in_term_nvar;\
}

routine to locate all variables in a term, and its application s

Definition at line 699 of file terms.c.

Function Documentation

◆ mksingleton()

void mksingleton ( Term  v,
Functor  FunctorNumberVars 
)

Definition at line 756 of file terms.c.

◆ Yap_InitTermCPreds()

void Yap_InitTermCPreds ( void  )

Definition at line 983 of file terms.c.

◆ Yap_IsCyclicTerm()

bool Yap_IsCyclicTerm ( Term t  USES_REGS)

Definition at line 194 of file terms.c.

◆ Yap_IsGroundTerm()

bool Yap_IsGroundTerm ( Term  t)

Definition at line 248 of file terms.c.

◆ Yap_NumberVars()

int Yap_NumberVars ( Term  t,
int  numbv,
bool handle_singles  USES_REGS 
)

numbervariables in term t

Definition at line 770 of file terms.c.

◆ Yap_TermVariables()

Term Yap_TermVariables ( Term  t,
Term t0  USES_REGS 
)

Extends list with all the variables in a term.

Parameters
[t]the term
[list]the original list
[USES_REGS]threading

Definition at line 581 of file terms.c.

◆ Yap_UnNumberTerm()

Int Yap_UnNumberTerm ( Term  t,
CELL *HLow  USES_REGS 
)

Definition at line 953 of file terms.c.

Macros

#define DEB_DOOBOUT(d0)   \
 
#define DEB_DOOBIN(d0)
 
#define DEB_DOOB(S, sp)
 
#define push_sub_term(A, B, C, D, E)
 
#define pop_sub_term(A, B, C)   ( DEB_DOOB("-",A) pop_sub_term__(A,B,C))
 
#define RESET_TERM_VISITOR_0()
 
#define RESET_TERM_VISITOR_1(v, v0)
 
#define RESET_TERM_VISITOR_3(first, tail, tail0, end)
 
#define LIST_HOOK_CODE   if (IS_VISIT_MARKER(ptd1[0])) { goto found;}
 
#define COMPOUND_HOOK_CODE   if (IS_VISIT_MARKER(ptd1[0])) { goto found;}
 
#define COMPOUND_HOOK_CODE
 
#define VAR_HOOK_CODE
 routine to locate all variables in a term, and its application s More...
 
#define VAR_HOOK_CODE
 routine to locate all variables in a term, and its application s More...
 
#define VAR_HOOK_CODE
 routine to locate all variables in a term, and its application s More...
 
#define VAR_HOOK_CODE   mSET(ptd0, TermNone);
 routine to locate all variables in a term, and its application s More...
 
#define VAR_HOOK_CODE
 routine to locate all variables in a term, and its application s More...
 
#define VAR_HOOK_CODE
 routine to locate all variables in a term, and its application s More...
 
#define ATOMIC_HOOK_CODE   if (d0==TermNone) mSET(ptd0,(CELL)ptd0);
 
#define ATOMIC_HOOK_CODE
 

Typedefs

typedef struct att_rec att_rec_t
 routine to locate attributed variables
 

Functions

bool Yap_IsCyclicTerm (Term t USES_REGS)
 
bool Yap_IsGroundTerm (Term t)
 
Term Yap_TermVariables (Term t, Term t0 USES_REGS)
 Extends list with all the variables in a term. More...
 
void mksingleton (Term v, Functor FunctorNumberVars)
 
int Yap_NumberVars (Term t, int numbv, bool handle_singles USES_REGS)
 numbervariables in term t
More...
 
Int Yap_UnNumberTerm (Term t, CELL *HLow USES_REGS)
 
void Yap_InitTermCPreds (void)