#ifdef DOC_BUILD_INTERNAL
#endif
#include "order.h"
unsigned order_GetSizeSubstContext(TERMSTATE Termstate, SYMBSTATE Symbstate, SUBSTSTATE SState, TERM Term, SUBST Subst)
 {
   unsigned size,i;
   SYMBOL top;
   size = 1;
   top = term_TopSymbol(Term);
   if (Subst != NULL && symbol_IsVariable(Symbstate, top) && subst_VarDefined(Subst, top)) {
     Term = subst_GetValue(Subst,top);
     top = term_TopSymbol(Term);
   }
   if (symbol_IsVariable(Symbstate, top) && subst_ContextValueIsMarked(SState, top))
     return (term_ComputeSize(Termstate,subst_ContextGetTermValueFollowSymbolChain(SState, Symbstate, Term)));
   for (i=0; i<term_GetArity(Term);i++)
     size += order_GetSizeSubstContext(Termstate, Symbstate, SState, (TERM)Term[i], Subst);
   return size;
 }
 unsigned order_GetSizeSubst(TERMSTATE Termstate, SYMBSTATE Symbstate, SUBSTSTATE SState, TERM Term, SUBST Subst)
 {
   unsigned size,i;
   SYMBOL top;
   size = 1;
   top = term_TopSymbol(Term);
   if (Subst != NULL && symbol_IsVariable(Symbstate, top) && subst_VarDefined(Subst, top))
     return term_ComputeSize(Termstate,subst_GetValue(Subst,top));
   for (i=0; i<term_GetArity(Term);i++)
     size += order_GetSizeSubst(Termstate, Symbstate, SState, (TERM)Term[i], Subst);
   return size;
 }
BOOL order_SmallerEqualSubst(TERMSTATE Termstate, SYMBSTATE Symbstate, SUBSTSTATE SState, SUBST Subst, TERM Term1, TERM Term2)
{
  return (order_GetSizeSubst(Termstate, Symbstate, SState, Term1, Subst) <= term_ComputeSize(Termstate,Term2));
}
BOOL order_SmallerEqual(TERMSTATE Termstate, TERM Term1, TERM Term2)
{
  return (term_ComputeSize(Termstate,Term1) <= term_ComputeSize(Termstate,Term2));
}
BOOL order_SmallerEqualSubstContext(TERMSTATE Termstate, SYMBSTATE Symbstate, SUBSTSTATE SState, SUBST Subst, TERM Term1, TERM Term2)
{
  return (order_GetSizeSubstContext(Termstate, Symbstate, SState, Term1, Subst) <= term_ComputeSize(Termstate,Term2));
}
