#ifndef _TERM_
#define _TERM_ 
#include "symbol.h"
#include <inttypes.h>
typedef struct TERMSTATE_HELP {
  SYMBSTATE symbstate;
  unsigned stamp;
#ifdef SPASS_CHECK
  BOOL stampblocked;
#endif
  unsigned stampusers;
  unsigned maxstampusers;
  BOOL stampoverflow[];
} TERMSTATE_NODE,*TERMSTATE;
typedef intptr_t *TERM;
TERM term_Null(void);
SYMBOL term_TopSymbol(TERM);
void term_RplacTop(TERM, SYMBOL);
ARRAY term_SupertermArray(TERM);
void term_RplacSupertermArray(TERM, ARRAY);
ARRAY term_AtomsLiterals(TERM);
TERM term_Superterm(TERM);
void term_RplacSuperterm(TERM, TERM);
BOOL term_IsVariable(TERMSTATE, TERM);
#if defined(SPASS_SYMBOL_INDEXVARS)
BOOL term_IsStandardVariable(TERMSTATE, TERM);
BOOL term_IsIndexVariable(TERMSTATE, TERM);
#endif
unsigned term_GetArity(TERM);
void term_SetArity(TERM, unsigned);
TERM term_GetArgument(TERM, unsigned);
void term_SetArgument(TERM, unsigned, TERM);
BOOL term_IsComplex(TERM);
BOOL term_IsValueConstant(TERMSTATE, TERM);
intptr_t term_GetValue(TERMSTATE, TERM);
void term_SetValue(TERMSTATE, TERM, intptr_t);
intptr_t term_GetProperty(TERM);
void term_SetProperty(TERM, intptr_t);
void term_ResetPropertyRec(TERM);
BOOL term_IsConstant(TERMSTATE, TERM);
BOOL term_IsAtom(TERM);
TERM term_FirstArgument(TERM);
void term_RplacFirstArgument(TERM, TERM);
TERM term_SecondArgument(TERM);
TERM term_ThirdArgument(TERM);
void term_RplacSecondArgument(TERM, TERM);
void term_SwapArguments(TERM, unsigned, unsigned);
void term_Free(TERMSTATE, TERM);
void term_FreeNoValueConstants(MEMORY, TERM);
BOOL term_EqualTopSymbols(TERM, TERM);
void term_EqualitySwap(TERM);
BOOL term_CompareSizeSortingFunc(POINTER*, POINTER*);
void term_StopStamp(TERMSTATE);
void term_StartStamp(TERMSTATE);
NAT term_TermStamp(TERM);
void term_SetTermStamp(TERMSTATE, TERM);
NAT term_Size(TERM);
void term_SetSize(TERM, NAT);
BOOL term_AlreadyVisited(TERMSTATE, TERM);
BOOL term_HasTermStamp(TERMSTATE, TERM);
void term_ResetTermStamp(TERM);
BOOL term_StampAlreadyReset(TERM);
intptr_t term_Index(TERM);
void term_SetIndex(TERM, intptr_t);
TERMSTATE term_Init(SYMBSTATE, unsigned);
SYMBSTATE term_GetSymbstate(TERMSTATE);
MEMORY term_GetMemory(TERMSTATE);
void term_TermstateFree(TERMSTATE);
TERM term_Create(TERMSTATE, SYMBOL, ARRAY);
TERM term_CreateArity(TERMSTATE, SYMBOL, unsigned);
TERM term_CreateArityNullInit(TERMSTATE, SYMBOL, unsigned);
TERM term_CreateValueConstant(TERMSTATE, SYMBOL, intptr_t);
TERM term_CreateAddFather(TERMSTATE, SYMBOL, ARRAY);
TERM term_GetNextStandardVar(TERMSTATE);
void term_Delete(TERMSTATE, TERM);
void term_DeleteNoValueConstants(MEMORY, TERM);
void term_DeleteIterative(TERMSTATE, TERM);
BOOL term_Equal(TERMSTATE, TERM, TERM);
BOOL term_EqualIterative(TERMSTATE, TERM, TERM);
BOOL term_EqualNoValues(TERM, TERM);
BOOL term_VariableEqual(TERM, TERM);
BOOL term_IsGround(TERMSTATE, TERM);
BOOL term_IsTerm(TERMSTATE, TERM);
BOOL term_IsTermArray(TERMSTATE, ARRAY);
BOOL term_AllArgsAreVar(TERMSTATE, TERM);
int term_CompareBySymbolOccurences(TERMSTATE, TERM, TERM);
int term_CompareAbstract(TERMSTATE, TERM, TERM);
int term_CompareTotal(TERMSTATE, TERM, TERM);
BOOL term_CompareAbstractLEQ(TERMSTATE, TERM, TERM);
TERM term_CopyShallow(TERMSTATE, TERM);
TERM term_Copy(TERMSTATE, TERM);
TERM term_CopyIterative(TERMSTATE, TERM);
TERM term_CopyWithEmptyArgArrayNode(TERM, ARRAY, ARRAY*);
void term_PrintWithEmptyArgArrayNode(TERMSTATE, TERM);
BOOL term_ReplaceSubtermBy(TERMSTATE, TERM, TERM, TERM);
void term_ReplaceSymbol(TERMSTATE, TERM, SYMBOL, SYMBOL);
TERM term_ReplaceVariable(TERMSTATE, TERM, SYMBOL, TERM);
void term_ExchangeVariable(TERMSTATE, TERM, SYMBOL, SYMBOL);
TERM term_SubstituteVariable(TERMSTATE, SYMBOL, TERM, TERM);
NAT term_ComputeSize(TERMSTATE, TERM);
void term_InstallSize(TERMSTATE, TERM);
NAT term_Depth(TERMSTATE, TERM);
BOOL term_ContainsSymbol(TERMSTATE, TERM, SYMBOL);
BOOL term_Sharing(TERMSTATE,TERM);
BOOL term_IsLinear(TERMSTATE, TERM);
void term_AddFatherLinks(TERM);
BOOL term_FatherLinksEstablished(TERM);
TERM term_TopLevelTerm(TERM);
BOOL term_HasPointerSubterm(TERM, TERM);
BOOL term_HasProperSuperterm(TERM, TERM);
BOOL term_HasSubterm(TERMSTATE, TERM, TERM);
TERM term_FindSubterm(TERMSTATE, TERM, SYMBOL);
ARRAY term_FindAllAtoms(TERMSTATE, TERM, SYMBOL);
BOOL term_CheckTerm(TERMSTATE, TERM);
NAT term_RootDistance(TERM);
BOOL term_RootDistanceSmaller(TERM,TERM);
ARRAY term_CopyTermArray(TERMSTATE, ARRAY ar);
void term_CopyTermsInArray(TERMSTATE,ARRAY);
void term_DeleteTermArray(TERMSTATE, ARRAY);
BOOL term_ArrayContainsTerm(TERMSTATE,ARRAY, TERM);
ARRAY term_DeleteDuplicatesFromArray(TERMSTATE, ARRAY);
ARRAY term_DestroyDuplicatesInArray(TERMSTATE, ARRAY);
void term_Print(TERMSTATE, TERM);
void term_PrettyPrint(TERMSTATE, TERM);
void term_FPrint(FILE*, TERMSTATE, TERM);
void term_TermArrayPrint(TERMSTATE, ARRAY);
void term_TermArrayFPrint(FILE*, TERMSTATE, ARRAY);
void term_PrintPrefix(TERMSTATE, TERM);
void term_PrintPrefixI(TERMSTATE, TERM);
void term_PrintPrefixDatalog(TERMSTATE, TERM);
void term_FPrintPrefix(FILE*, TERMSTATE, TERM, BOOL);
void term_TermArrayPrintPrefix(TERMSTATE, ARRAY);
void term_TermArrayFPrintPrefix(FILE*, TERMSTATE, ARRAY);
void term_FPrintPosition(FILE*,TERM,TERM);
void term_PrintPosition(TERM, TERM);
void term_FPrintSMT(FILE*, TERMSTATE, TERM);
void term_FPrintSMTI(FILE*, TERMSTATE, TERM);
void term_FPrintSMTGC(FILE*, TERMSTATE, TERM, const char*);
void term_FPrintSMTIGC(FILE*, TERMSTATE, TERM, const char*);
void term_FPrintCHCI(FILE*, TERMSTATE, TERM);
void term_FPrintCHCIGC(FILE*, TERMSTATE, TERM, const char*);
void term_ToCoVariables(TERM);
NAT term_Bytes(TERMSTATE,TERM);
void term_MarkVariables(TERMSTATE, TERM, NAT);
ARRAY term_ArrayOfVariables(TERMSTATE, TERM);
ARRAY term_VariableSymbols(TERMSTATE, TERM);
unsigned term_NumberOfVariableSymbols(TERMSTATE, TERM);
NAT term_CountSymbolOccurrences(TERMSTATE, TERM);
void term_GroundTermConstant(TERMSTATE, TERM, SYMBOL);
void term_GroundTermConstants(TERMSTATE, TERM, ARRAY);
ARRAY term_ArrayOfAtoms(TERMSTATE, TERM,SYMBOL);
NAT term_NumberOfVarOccs(TERMSTATE, TERM);
ARRAY term_ArrayOfConstants(TERMSTATE, TERM);
ARRAY term_ArrayOfFunctions(TERMSTATE, TERM);
BOOL term_ContainsFunctions(TERMSTATE, TERM);
BOOL term_ContainsVariable(TERMSTATE, TERM, SYMBOL);
SYMBOL term_MaxVar(TERMSTATE, TERM);
TERM term_Rename(TERMSTATE, TERM);
SYMBOL term_GetRenamedVarSymbol(TERMSTATE, SYMBOL);
TERM term_RenameVariablesInTerm(TERMSTATE, TERM, unsigned);
void term_ReplaceVarsWithConsts(TERMSTATE, TERM, ARRAY);
void term_SetTermSubtermStamp(TERMSTATE, TERM);
void term_SetPropagatable(TERM, BOOL);
BOOL term_IsPropagatable(TERM);
void term_SetActive(TERM, BOOL);
BOOL term_IsActive(TERM);
BOOL term_IsPersAtom(TERM);
void term_SetPersAtom(TERM, BOOL);
void term_SetPrLitIndex(TERM, int);
int term_GetPrLitIndex(TERM);
void term_SetProfit(TERM, unsigned);
void term_IncreaseProfit(TERM, unsigned);
void term_ShiftProfit(TERM);
unsigned term_GetProfit(TERM);
unsigned term_QueryProfit(TERM, unsigned);
void term_SetPropertyPhasePositive(TERM);
void term_SetPropertyPhaseNegative(TERM);
void term_PropertySetPhase(TERM, BOOL);
BOOL term_PropertyPhasePositive(TERM);
void term_SetHasPhase(TERM, BOOL);
BOOL term_HasPhase(TERM);
void term_SetPropVar(TERM, unsigned);
unsigned term_GetPropVar(TERM);
BOOL term_PropVarSet(TERM);
unsigned term_GetStampID(TERMSTATE);
BOOL term_StampOverflow(TERMSTATE, unsigned);
extern const unsigned term_EXTRA;
#endif
