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
/*
* This file is part of the source code of the software program
* Vampire. It is protected by applicable
* copyright laws.
*
* This source code is distributed under the licence found here
* https://vprover.github.io/license.html
* and in the source directory
*/
/**
* @file LiteralSelector.hpp
* Defines class LiteralSelector and its descendants implementing literal selection
* @since 05/01/2008 Torrevieja
*/
#ifndef __LiteralSelector__
#define __LiteralSelector__
#include "Forwards.hpp"
namespace Kernel {
using namespace Lib;
using namespace Shell;
/**
* Class LiteralSelector is base class for
* literal selector objects
*/
class LiteralSelector
{
public:
LiteralSelector(const Ordering& ordering, const Options& options)
: _ord(ordering), _opt(options), _reversePolarity(false)
{
}
virtual ~LiteralSelector()
{
}
/** if eligible is 0, all literals are eligible */
void select(Clause* c, unsigned eligible=0);
static LiteralSelector* getSelector(const Ordering& ordering, const Options& options, int selectorNumber);
static void ensureSomeColoredSelected(Clause* c, unsigned eligible);
/**
* Return true if literal @b l is positive for the purpose of
* literal selection
*
* This function is to allow for easy implementation of
* selection functions with negative numbers. Those functions
* consider all literals except for equality to be of
* opposite polarity.
*/
bool isPositiveForSelection(Literal* l) const;
/**
* Return true if literal @b l is negative for the purpose of
* literal selection
*
* @see isPositiveForSelection
*/
bool isNegativeForSelection(Literal* l) const
{
return !isPositiveForSelection(l);
}
int getSelectionPriority(Literal* l) const;
/**
* Does the selection maintain completeness in the Bachmair-Ganzinger sense?
*/
virtual bool isBGComplete() const = 0;
/**
* Should this selector treat polarity (of non-equational literals) as reversed?
*
* Preferably do not call this once the LiteralSelector has already been used.
*
* This method is virtual as Lookahead selector with delayed function contains another selector
* which needs to get in sync.
*/
virtual void setReversePolarity(bool newVal) { _reversePolarity = newVal; }
protected:
/**
* Perform selection on the first @b eligible literals of clause @b c
*
* @b eligible has to be greater than 1. (Trivial cases should be taken
* care of separately.)
*
* It is a responsibility of this function to ensure that at least one
* colored literal is selected if there is some in the clause.
*/
virtual void doSelection(Clause* c, unsigned eligible) = 0;
const Ordering& _ord;
const Options& _opt;
private:
/**
* If true, the polarity of all literals except for equality ones is
* considered to be reversed for the purposes of literal selection.
*
* @see isPositiveForSelection
*/
bool _reversePolarity;
};
/**
* Class EagerLiteralSelection implements literal
* selector that selects all literals
*/
class TotalLiteralSelector
: public LiteralSelector
{
public:
TotalLiteralSelector(const Ordering& ordering, const Options& options)
: LiteralSelector(ordering, options) {}
bool isBGComplete() const override {
// this is on purpose; we don't want any extra checks with total selection
return false;
}
protected:
void doSelection(Clause* c, unsigned eligible) override;
};
}
#endif /* __LiteralSelector__ */