~ubuntu-branches/ubuntu/saucy/ladr/saucy

« back to all changes in this revision

Viewing changes to ladr/discrim.h.bak

  • Committer: Package Import Robot
  • Author(s): Frank Lichtenheld
  • Date: 2013-05-25 11:43:32 UTC
  • mfrom: (5.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20130525114332-lkzco1dti2hwrf7v
Tags: 0.0.200911a-2
* QA upload.
* Upload to unstable.
* Change maintainer to QA group.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  Copyright (C) 2006, 2007 William McCune
2
 
 
3
 
    This file is part of the LADR Deduction Library.
4
 
 
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,
7
 
    version 2.
8
 
 
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.
13
 
 
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.
17
 
*/
18
 
 
19
 
#ifndef TP_DISCRIM_H
20
 
#define TP_DISCRIM_H
21
 
 
22
 
#include "unify.h"
23
 
#include "index.h"
24
 
 
25
 
/* INTRODUCTION
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).
29
 
<P>
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 *).
41
 
<P>
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.
47
 
<P>
48
 
There is probably a higher-level package (mindex ?) which
49
 
provides a uniform interface to these and other indexing methods.
50
 
*/
51
 
/* Public definitions */
52
 
 
53
 
typedef struct discrim * Discrim;
54
 
 
55
 
struct discrim {       /* node in a discrimination tree */
56
 
  Discrim   next;      /* sibling */
57
 
  union {
58
 
    Discrim kids;      /* for internal nodes */
59
 
    Plist data;        /* for leaves */
60
 
  } u;
61
 
  short symbol;        /* variable number or symbol number */
62
 
  char type;           /* term type and for ac indexing type */
63
 
};
64
 
 
65
 
typedef struct discrim_pos * Discrim_pos;
66
 
 
67
 
struct discrim_pos {  /* to save position in set of answers */
68
 
  void    *query;
69
 
  Context subst;        /* substitution */
70
 
  Plist   data;         /* identical terms from leaf of discrim tree */
71
 
  void    *backtrack;   /* data for backtracking */
72
 
};
73
 
 
74
 
/* type of discrimination tree node */
75
 
 
76
 
enum { DVARIABLE, DRIGID, AC_ARG_TYPE, AC_NV_ARG_TYPE };
77
 
 
78
 
#define DVAR(d)  ((d)->type == DVARIABLE)
79
 
 
80
 
/* End of public definitions */
81
 
 
82
 
/* Public function prototypes from discrim.c */
83
 
 
84
 
Discrim get_discrim(void);
85
 
 
86
 
void free_discrim(Discrim p);
87
 
 
88
 
Discrim_pos get_discrim_pos(void);
89
 
 
90
 
void free_discrim_pos(Discrim_pos p);
91
 
 
92
 
void fprint_discrim_mem(FILE *fp, BOOL heading);
93
 
 
94
 
void p_discrim_mem(void);
95
 
 
96
 
Discrim discrim_init(void);
97
 
 
98
 
void discrim_dealloc(Discrim d);
99
 
 
100
 
void destroy_discrim_tree(Discrim d);
101
 
 
102
 
BOOL discrim_empty(Discrim d);
103
 
 
104
 
#endif  /* conditional compilation of whole file */