#ifndef _DISTRN_
#define _DISTRN_ 
#include "array.h"
#include "clause.h"
#include "ohash.h"
#include "folsubst.h"
#include "symbol.h"
#include "term.h"
typedef struct DISTRN_HELP {
  struct DISTRN_HELP *nextvar;
  intptr_t rmap;
} DISTRN_NODE;
typedef DISTRN_NODE *DISTRNP;
typedef struct DISTR_ROOT_HELP {
  ARRAY stack;
  ARRAY flat;
  ARRAY skip;
  DISTRNP root;
} DISTRN_ROOT, *DISTRN;
DISTRN distrn_Create(MEMORY);
void distrn_Delete(MEMORY, DISTRN);
void distrn_DeleteIter(MEMORY, DISTRN);
void distrn_DeleteWithEntries(MEMORY, DISTRN, void (*)(MEMORY, intptr_t));
void distrn_DeleteWithEntriesIter(MEMORY, DISTRN, void (*)(MEMORY, intptr_t));
void distrn_Insert(MEMORY, DISTRN, TERMSTATE, TERM, SUBST, intptr_t);
void distrn_InsertDataHash(MEMORY, DISTRN, TERMSTATE, TERM, SUBST, intptr_t, uint32_t (*)(const OHASH_KEY_TYPE));
void distrn_Remove(DISTRN, TERMSTATE, TERM, SUBST, intptr_t);
void distrn_RemoveIf(DISTRN, TERMSTATE, TERM, SUBST, BOOL (*)(intptr_t, intptr_t), intptr_t, void (*)(MEMORY, intptr_t));
void distrn_RemoveIfTrue(MEMORY, DISTRN, SYMBSTATE, BOOL (*)(intptr_t, intptr_t), intptr_t, void (*)(MEMORY, intptr_t));
ARRAY distrn_SearchGeneralizations(MEMORY, DISTRN, TERMSTATE, TERM, ARRAY *);
ARRAY distrn_SearchInstances(MEMORY, DISTRN, TERMSTATE, TERM, ARRAY *);
ARRAY distrn_SearchUnifiables(MEMORY, DISTRN, TERMSTATE, TERM, ARRAY *);
ARRAY distrn_ContainsTermCandidates(DISTRN, TERMSTATE, TERM);
void distrn_Print(DISTRN, TERMSTATE, void (*) (TERMSTATE, intptr_t));
#endif
