This file is indexed.

/usr/include/ladr/unify.h is in libladr-dev 0.0.200911a-2.1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*  Copyright (C) 2006, 2007 William McCune

    This file is part of the LADR Deduction Library.

    The LADR Deduction Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License,
    version 2.

    The LADR Deduction Library is distributed in the hope that it will be
    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with the LADR Deduction Library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef TP_UNIFY_H
#define TP_UNIFY_H

#include "listterm.h"
#include "termflag.h"

/* INTRODUCTION
This package handles ordinary <GL>unification</GL> and <GL>matching</GL>
of terms.
The methods are probably different from what you learned in your
logic course, so pay close attention.
<P>
In situations where you consider instantiating the variables of a term
t, you will have an associated Context c.  The Context
keeps track of the terms that are substituted for the variables---
think of it as a substitution table indexed by the variable number.
<P>
Contexts allow you to separate variables of two terms without
creating a renamed copy of one of the terms.  Say we have
two terms with different Contexts: (t1,c1) and (t2,c2).
If t1 and t2 share a variable, say v3, occurrences in
t1 are a different variable from occurrences in t2, because
the contexts are different.
Think of the those variables as (v3,c1) and (v3,c2).
In fact, when an instantiation is recorded in a Context,
the variable in question is set to a pair, say (t4,c4) rather
than just t4, because we have to know how to interpret the
variables of t4.
<P>
There are situations where the terms being unified really do
share variables, for example when factoring the literals of
a clause; in those cases, you simply use the same context
for both terms.
<P>
When you call unify(), match(), or any other routine that
tries to make terms identical by instantiation, the terms you
give are not changed---all of the action happens in their contexts
(and in the trail, see below).
So you do not have to copy terms before calling the routine.
<P>
When a unify or match routine succeeds, the Contexts are updated
to reflect the common instance of the terms.  Also, a Trail is
returned.  A Trail is a linked list of (variable,context)
pairs telling exactly which variables were instantiated during
the operation.  Its purpose is to quickly restore the Contexts to 
their previous states.
<P>
You must explicitly allocate and free Contexts.
To save time, we don't initialize the arrays each
time a Context is re-allocated, and we don't check that Contexts
are clear when they are freed.  Therefore, <I>you must make
sure that a Context is clear before freeing it</I>.
See undo_subst().  Also, if you forget to clear the Context with
undo_subst(), you will have a memory leak, because the Trail will be
lost.
(If you suspect that you have a bug which causes a non-empty
context to be freed, you can enable a run-time check in free_context()
and recompile unify.c.)
<P>
When you wish to find out what a context does to a term t, you can
call apply(), which builds a new copy of the term with all of
the instantiations of the context applied to the term t.
But I wrote above that (v3,c1) is a different variable 
from (v3,c2)---what does apply do with uninstantiated variables?
Each context has a unique multiplier (a small natural number);
When apply() gets to an uninstantiated variable v, it returns
a variable with index (multiplier*MAX_VARS)+VARNUM(v).
Of course, this can give you VARNUMs > MAX_VARS, so you may
have to rename variables of the result before calling a unification
routine on the result.
<P>
Unification and matching can be used incrementally.  For example,
you can all unify() with a context which has entries from a
previous call to unify().  Hyperresolution can be implemented by
backtracking through the negative literals of a nucleus
and the satellites that unify with a given literal of the nucleus,
constructing and undoing partial substitutions along the way.
Another example is subsumption.
Checking whether one clause subsumes another can be done by
incremental matching, backtracking through the literals of the
potential subsumer, trying to map them to the literals of the
other clause.
<P>
Associative-commutative unification and matching, and commutative
unification and matching, use different unification code, because they
have to deal with multiple unifiers for a pair of terms.  (These other
kinds of unification and matching may use the Context data
type defined here.)
*/

/* Public definitions */

/* Dereference a variable. */

#define DEREFERENCE(t, c) { int i; \
    while (c!=NULL && VARIABLE(t) && c->terms[i=VARNUM(t)]) \
    { t = c->terms[i]; c = c->contexts[i]; } } 

/* A Context records a substitution of terms for variables. */

typedef struct context * Context;

struct context {
  Term    terms[MAX_VARS];    /* terms substituted for variables */
  Context contexts[MAX_VARS]; /* Contexts corresponding to terms */
  int     multiplier;         /* for getting separate vars in apply */
  Term    partial_term;       /* for AC matching */
};

typedef struct trail * Trail;

/* The following type is for backtrack unification and matching. */

typedef enum { NO_ALT = 0,
	       AC_ALT,
	       COMM_ALT
             } Unif_alternative;

/* End of public definitions */

/* Public function prototypes from unify.c */

Context get_context(void);

void free_context(Context p);

void fprint_unify_mem(FILE *fp, BOOL heading);

void p_unify_mem();

BOOL unify(Term t1, Context c1,
	   Term t2, Context c2, Trail *trp);

BOOL variant(Term t1, Context c1,
	    Term t2, Trail *trp);

BOOL occur_check(int vn, Context vc, Term t, Context c);

BOOL match(Term t1, Context c1, Term t2, Trail *trp);

Term apply(Term t, Context c);

Term apply_substitute(Term t, Term beta, Context c_from,
		      Term into_term, Context c_into);

Term apply_substitute2(Term t, Term beta, Context c_from,
		       Ilist into_pos, Context c_into);

Term apply_demod(Term t, Context c, int flag);

void undo_subst(Trail tr);

void undo_subst_2(Trail tr, Trail sub_tr);

void fprint_context(FILE *fp, Context c);

void p_context(Context c);

void fprint_trail(FILE *fp, Trail t);

void p_trail(Trail t);

BOOL match_weight(Term t1, Context c1, Term t2, Trail *trp, int var_sn);

Ilist vars_in_trail(Trail tr);

Plist context_to_pairs(Ilist varnums, Context c);

BOOL empty_substitution(Context s);

BOOL variable_substitution(Context s);

BOOL subst_changes_term(Term t, Context c);

#endif  /* conditional compilation of whole file */