1
/* Copyright (C) 2006, 2007 William McCune
3
This file is part of the LADR Deduction Library.
5
The LADR Deduction Library is free software; you can redistribute it
6
and/or modify it under the terms of the GNU General Public License,
9
The LADR Deduction Library is distributed in the hope that it will be
10
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with the LADR Deduction Library; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26
This package implements two kinds of discrimination indexing
27
for first-order terms. Both kinds support GENERALIZATION retrieval
28
only (e.g., for forward demodulation and forward subsumption).
30
The "wild" kind is an imperfect filter, and it does not bind variables.
31
The caller must also call a routine, say match(), to check if
32
the answers are really more general than the query term and to
33
construct the substitution.
34
Wild indexing supports associative-commutative (AC) and
35
commutative (C) symbols.
36
Indexing terms with AC symbols works by considering the number
37
of arguments and the number of nonvariable arguments of
38
AC terms that do not occur in other AC terms.
39
(The term "wild" is used because all variables in the discrimination
40
tree are treated as the the wildcard symbol *).
42
With the "bind" kind, every answer is more general than the query term,
43
and the matching substitution is constructed during the retrieval.
44
Wild indexing supports commutative (C) symbols,
45
but it <I>does not support</I> associative-commutative (AC) symbols.
46
Retrieval with C symbols can produce duplicate answers.
48
There is probably a higher-level package (mindex ?) which
49
provides a uniform interface to these and other indexing methods.
51
/* Public definitions */
53
typedef struct discrim * Discrim;
55
struct discrim { /* node in a discrimination tree */
56
Discrim next; /* sibling */
58
Discrim kids; /* for internal nodes */
59
Plist data; /* for leaves */
61
short symbol; /* variable number or symbol number */
62
char type; /* term type and for ac indexing type */
65
typedef struct discrim_pos * Discrim_pos;
67
struct discrim_pos { /* to save position in set of answers */
69
Context subst; /* substitution */
70
Plist data; /* identical terms from leaf of discrim tree */
71
void *backtrack; /* data for backtracking */
74
/* type of discrimination tree node */
76
enum { DVARIABLE, DRIGID, AC_ARG_TYPE, AC_NV_ARG_TYPE };
78
#define DVAR(d) ((d)->type == DVARIABLE)
80
/* End of public definitions */
82
/* Public function prototypes from discrim.c */
84
Discrim get_discrim(void);
86
void free_discrim(Discrim p);
88
Discrim_pos get_discrim_pos(void);
90
void free_discrim_pos(Discrim_pos p);
92
void fprint_discrim_mem(FILE *fp, BOOL heading);
94
void p_discrim_mem(void);
96
Discrim discrim_init(void);
98
void discrim_dealloc(Discrim d);
100
void destroy_discrim_tree(Discrim d);
102
BOOL discrim_empty(Discrim d);
104
#endif /* conditional compilation of whole file */