File: che_proofcontrol.c

package info (click to toggle)
eprover 2.6%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 21,288 kB
  • sloc: ansic: 331,111; csh: 12,026; python: 10,178; awk: 5,825; makefile: 461; sh: 389
file content (323 lines) | stat: -rw-r--r-- 10,262 bytes parent folder | download
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*-----------------------------------------------------------------------

File  : che_proofcontrol.c

Author: Stephan Schulz

Contents

  Basic functions for proof control objects.

  Copyright 1998, 1999 by the author.
  This code is released under the GNU General Public Licence and
  the GNU Lesser General Public License.
  See the file COPYING in the main E directory for details..
  Run "eprover -h" for contact information.

Changes

<1> Fri Oct 16 16:20:00 MET DST 1998
    Salvaged from cco_proofstate.h, forked control and state.
<2> Wed Dec 16 18:45:14 MET 1998
    Moved from cco to che

-----------------------------------------------------------------------*/

#include "che_proofcontrol.h"


/*---------------------------------------------------------------------*/
/*                        Global Variables                             */
/*---------------------------------------------------------------------*/

#define CHE_PROOFCONTROL_INTERNAL

char* DefaultWeightFunctions =
"\n"
"weight21_ugg  = Clauseweight(PreferUnitGroundGoals,2,1,1)      \n"
"rweight21_g   = Refinedweight(PreferGoals,    2,1,1.5,1.1,1) \n"
"rweight11_g   = Refinedweight(PreferGoals,    1,1,1.5,1.1,1.1) \n"
"rweight21_a   = Refinedweight(PreferNonGoals, 2,1,1.5,1.1,1.1) \n"
"rweight21_ugg = Refinedweight(PreferUnitGroundGoals, 2,1,1.5,1.1,1.1) \n"
"fifo_f        = FIFOWeight(ConstPrio)                      \n"
"lifo_f        = LIFOWeight(ConstPrio)                      \n"
"weight11_f    = Clauseweight(ConstPrio,1,1,1)              \n"
"weight11_ugg  = Clauseweight(PreferUnitGroundGoals,1,1,1)  \n"
"weight21_f    = Clauseweight(ConstPrio,2,1,1)              \n"
"TSMRDefault   = TSMWeight(ConstPrio, 1, 1, 2, flat, E_KNOWLEDGE,"
                 "100000,1.0,1.0,Flat,IndexIdentity,100000,-20,20,-2,-1,0,2)\n"
;

char* DefaultHeuristics=
"Weight     = (1*weight21_ugg)                       \n"
"WeightC1   = (1*weight11_ugg)                       \n"
"StandardWeight = (1*weight21_f)                     \n"
"StandardPG = (5*weight21_f,1*fifo_f)                \n"
"RWeight    = (1*rweight21_ugg)                      \n"
"FIFO       = (1*fifo_f)                             \n"
"LIFO       = (1*lifo_f)                             \n"
"Default    = (3*rweight21_a, 1*rweight21_g)         \n"
"Uniq       = (1*Uniqweight(ConstPrio))\n"
"UseWatchlist = \n"
"(10*Refinedweight(PreferGoals,1,2,2,2,0.5),"
" 10*Refinedweight(PreferNonGoals,2,1,2,2,2),"
" 5*OrientLMaxWeight(PreferWatchlist,2,1,2,1,1),"
" 1*FIFOWeight(PreferWatchlist))\n"
"UseWatchlistPure=\n"
"(1*Defaultweight(PreferWatchlist))\n"
"UseWatchlistPG10=\n"
"(10*Defaultweight(PreferWatchlist),\n"
" 1*FIFOWeight(ConstPrio))\n"
"UseWatchlistEvo=\n"
"(1*ConjectureRelativeSymbolWeight(SimulateSOS,0.5, 100, 100,\n"
"                                  100, 100, 1.5, 1.5, 1),\n"
" 4*ConjectureRelativeSymbolWeight(PreferWatchlist,0.1, 100, \n"
"                                  100, 100, 100, 1.5, 1.5, 1.5),\n"
" 1*FIFOWeight(PreferProcessed),\n"
" 1*ConjectureRelativeSymbolWeight(PreferWatchlist,0.5, 100, 100, \n"
"                                  100, 100, 1.5, 1.5, 1),\n"
" 4*Refinedweight(SimulateSOS,3,2,2,1.5,2))\n"
"UseTSM1 = \n"
"(10*Refinedweight(PreferGoals,1,2,2,2,0.5),"
" 10*Refinedweight(PreferNonGoals,2,1,2,2,2),"
" 5*TSMRDefault,"
" 1*FIFOWeight(PreferWatchlist))\n"
"UseTSM2 = \n"
"(20*TSMRDefault,"
" 5*OrientLMaxWeight(PreferWatchlist,2,1,2,1,1),"
" 1*FIFOWeight(PreferWatchlist))\n"


"/* Here start the auto-mode-heuristics*/            \n"
#include "che_X_____auto.c"
#include "che_X_____auto_casc.c"
#include "che_X_____auto_dev.c"
#include "che_X_auto_sched0.c"
#include "che_X_auto_sched1.c"
#include "che_X_auto_sched2.c"
#include "che_X_auto_sched3.c"
#include "che_X_auto_sched4.c"
#include "che_X_auto_sched5.c"
#include "che_X_auto_sched6.c"
#include "che_X_auto_sched7.c"
#include "che_X_auto_sched8.c"
#include "che_X_auto_sched9.c"
   "."  /* End marker to warn against incomplete parsing */
;


/*---------------------------------------------------------------------*/
/*                      Forward Declarations                           */
/*---------------------------------------------------------------------*/


/*---------------------------------------------------------------------*/
/*                         Internal Functions                          */
/*---------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
//
// Function: select_inherited_literal()
//
//   If there is at least one negative literal with EPIsPMIntoLit,
//   select all literals with this property, return true. Otherwise
//   return false.
//
// Global Variables: -
//
// Side Effects    : Changes literal properties.
//
/----------------------------------------------------------------------*/

static bool select_inherited_literal(Clause_p clause)
{
   Eqn_p handle;
   bool  found  = false;

   if(clause->neg_lit_no == 0)
   {
      return false;
   }
   for(handle = clause->literals; handle; handle = handle->next)
   {
      if(EqnIsNegative(handle)&&EqnQueryProp(handle,EPIsPMIntoLit))
      {
         found = true;
         break;
      }
   }
   if(!found)
   {
      return false;
   }
   for(handle = clause->literals; handle; handle = handle->next)
   {
      if(EqnQueryProp(handle,EPIsPMIntoLit))
      {
         EqnSetProp(handle, EPIsSelected);
      }
   }
   return true;
}

/*-----------------------------------------------------------------------
//
// Function: sat_solver_init()
//
//   Create and initialize the SAT solver in the ProofControl object.
//
// Global Variables: -
//
// Side Effects    : Via PicoSAT interface
//
/----------------------------------------------------------------------*/

void sat_solver_init(ProofControl_p ctrl)
{
   ctrl->solver = picosat_init();
#ifndef NDEBUG
   int status =
#endif
   picosat_enable_trace_generation(ctrl->solver);
   assert(status);
}


/*---------------------------------------------------------------------*/
/*                         Exported Functions                          */
/*---------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
//
// Function: ProofControlAlloc()
//
//   Allocate an empty, initialized ProofControlCell.
//
// Global Variables: -
//
// Side Effects    : Memory operations
//
/----------------------------------------------------------------------*/

ProofControl_p ProofControlAlloc(void)
{
   ProofControl_p handle = ProofControlCellAlloc();
   handle->ocb                           = NULL;
   handle->wfcbs                         = WFCBAdminAlloc();
   handle->hcbs                          = HCBAdminAlloc();
   handle->hcb                           = NULL;
   handle->ac_handling_active            = false;
   HeuristicParmsInitialize(&handle->heuristic_parms);

   sat_solver_init(handle);

   return handle;
}


/*-----------------------------------------------------------------------
//
// Function: ProofControlFree()
//
//   Free a ProofControlCell.
//
// Global Variables: -
//
// Side Effects    : Memory operations
//
/----------------------------------------------------------------------*/

void ProofControlFree(ProofControl_p junk)
{
   assert(junk);
   if(junk->ocb)
   {
      OCBFree(junk->ocb);
   }
   WFCBAdminFree(junk->wfcbs);
   HCBAdminFree(junk->hcbs);
   /* hcb is always freed in junk->hcbs */

   if(junk->solver)
   {
      picosat_reset(junk->solver);
   }
   ProofControlCellFree(junk);
}


/*-----------------------------------------------------------------------
//
// Function: ProofContrlResetSATSolver()
//
//   Resets SAT solver state to make it ready for the next attempt.
//
// Global Variables: -
//
// Side Effects    : Output
//
/----------------------------------------------------------------------*/

void ProofControlResetSATSolver(ProofControl_p ctrl)
{
   picosat_reset(ctrl->solver);
   sat_solver_init(ctrl);
}



/*-----------------------------------------------------------------------
//
// Function: DoLiteralSelection()
//
//   Based on control, select a literal selection strategy and apply
//   it to clause.
//
// Global Variables: -
//
// Side Effects    : Changes properties in clause
//
/----------------------------------------------------------------------*/

void DoLiteralSelection(ProofControl_p control, Clause_p clause)
{
   EqnListDelProp(clause->literals, EPIsSelected);
   assert(EqnListQueryPropNumber(clause->literals, EPIsSelected)==0);
   ClauseDelProp(clause, CPIsOriented);
   assert(EqnListQueryPropNumber(clause->literals, EPIsSelected)==0);

   if(control->heuristic_parms.inherit_paramod_lit||
      (control->heuristic_parms.inherit_goal_pm_lit&&ClauseIsGoal(clause))||
      (control->heuristic_parms.inherit_conj_pm_lit&&ClauseIsConjecture(clause))
      )
   {
      if(select_inherited_literal(clause))
      {
    return;
      }
   }
   if(clause->neg_lit_no &&
      (clause->pos_lit_no >= control->heuristic_parms.pos_lit_sel_min) &&
      (clause->pos_lit_no <= control->heuristic_parms.pos_lit_sel_max) &&
      (clause->neg_lit_no >= control->heuristic_parms.neg_lit_sel_min) &&
      (clause->neg_lit_no <= control->heuristic_parms.neg_lit_sel_max) &&
      (ClauseLiteralNumber(clause) >= control->heuristic_parms.all_lit_sel_min) &&
      (ClauseLiteralNumber(clause) <= control->heuristic_parms.all_lit_sel_max) &&
      ((control->heuristic_parms.weight_sel_min==0) || /* Efficiency hack - only
                 compute clause weight if this
                 option is activated */
       (control->heuristic_parms.weight_sel_min<=ClauseStandardWeight(clause))))
   {
      assert(EqnListQueryPropNumber(clause->literals, EPIsSelected)==0);
      control->heuristic_parms.selection_strategy(control->ocb,clause);
   }
   else
   {
      assert(EqnListQueryPropNumber(clause->literals, EPIsSelected)==0);
      SelectNoLiterals(control->ocb,clause);
   }
}

/*---------------------------------------------------------------------*/
/*                        End of File                                  */
/*---------------------------------------------------------------------*/