Clingo
Loading...
Searching...
No Matches
condlit.hh
1#pragma once
2
3#include <clingo/ground/matcher.hh>
4#include <clingo/ground/statement.hh>
5
6#include <clingo/util/enumerate.hh>
7
8namespace CppClingo::Ground {
9
12
14enum class LitCondLitType : uint8_t {
15 empty = 0,
16 premise = 1,
17 lit = 2,
18};
20auto operator<<(std::ostream &out, LitCondLitType type) -> std::ostream &;
21
23// NOLINTNEXTLINE(performance-enum-size)
24enum class TruthConclusion : uint64_t {
25 true_ = 0,
26 false_ = 1,
27 derived = 2,
28 unknown = 3,
29};
30
33 public:
35 StateCondLitElem(size_t premise, bool premise_is_fact, bool has_conclusion)
36 : premise_{premise}, conclusion_truth_{has_conclusion ? TruthConclusion::unknown : TruthConclusion::false_},
37 premise_is_fact_{static_cast<uint8_t>(premise_is_fact)} {}
39 void set_conclusion(size_t conclusion, bool fact) {
40 conclusion_ = conclusion;
41 assert(conclusion_truth_ == TruthConclusion::unknown);
43 }
45 [[nodiscard]] auto is_fact() const -> bool { return conclusion_truth_ == TruthConclusion::true_; }
50 [[nodiscard]] auto is_blocked() const -> bool {
51 return premise_is_fact_ != 0 &&
52 (conclusion_truth_ == TruthConclusion::false_ || conclusion_truth_ == TruthConclusion::unknown);
53 }
57 [[nodiscard]] auto is_false() const {
58 return premise_is_fact_ != 0 && conclusion_truth_ == TruthConclusion::false_;
59 }
61 [[nodiscard]] auto has_offset() const -> bool { return offset_ > 0; }
63 void set_offset(size_t offset) { offset_ = offset + 1; }
67 [[nodiscard]] auto offset() const -> size_t { return offset_ - 1; }
68
70 [[nodiscard]] auto premise() const -> size_t { return premise_; }
72 [[nodiscard]] auto conclusion() const -> std::optional<size_t> {
73 return conclusion_ != invalid_offset ? std::make_optional(conclusion_) : std::nullopt;
74 }
75
76 private:
77 size_t conclusion_ = invalid_offset;
78 size_t premise_;
79 uint64_t offset_ : 61 = 1;
80 TruthConclusion conclusion_truth_ : 2;
81 uint64_t premise_is_fact_ : 1;
82};
83
88
93 public:
94 StateAtomCondLit() = default;
96 void add_elem(size_t index) { elems_.emplace_back(index); }
101 [[nodiscard]] auto enqueue(MapElemCondLit const &elems) -> bool;
103 [[nodiscard]] auto propagate(MapElemCondLit const &elems) -> bool;
108 [[nodiscard]] auto is_fact(MapElemCondLit const &elems) const -> bool;
110 [[nodiscard]] auto is_false() const -> bool { return false_ != 0; }
112 [[nodiscard]] auto has_offset() const -> bool { return offset_ > 0; }
114 void set_offset(size_t offset) { offset_ = offset + 1; }
118 [[nodiscard]] auto offset() const -> size_t { return offset_ - 1; }
119
123 [[nodiscard]] auto uid() const -> std::optional<size_t> {
124 return uid_ != invalid_offset ? std::make_optional(uid_) : std::nullopt;
125 }
127 void uid(size_t uid) {
128 assert(uid_ == invalid_offset || uid_ == uid);
129 uid_ = uid;
130 }
132 [[nodiscard]] auto elems() const -> std::span<size_t const> { return elems_; }
133
134 private:
135 std::vector<size_t> elems_;
136 uint64_t elems_propagated_ : 61 = 0;
137 uint64_t propagated_ : 1 = 0;
138 uint64_t enqueued_ : 1 = 0;
139 uint64_t false_ : 1 = 0;
140 size_t uid_ = invalid_offset;
141 size_t offset_ = 0;
142};
145
147class BaseCondLitEmpty : public BaseImpl<Symbol const *, BaseCondLitEmpty> {
148 public:
153 BaseCondLitEmpty(MapAtomCondLit &atoms) : atoms_{&atoms} {}
154
156 [[nodiscard]] auto index(Key const &key) const -> size_t {
157 return std::distance(atoms_->begin(), atoms_->find(key));
158 }
160 [[nodiscard]] auto size() const -> size_t { return atoms_->size(); }
161
163 [[nodiscard]] auto nth(size_t i) const -> MapAtomCondLit::const_iterator { return atoms_->nth(i); }
165 [[nodiscard]] auto nth(size_t i) -> MapAtomCondLit::iterator { return atoms_->nth(i); }
166
167 private:
168 MapAtomCondLit *atoms_;
169};
170
172class BaseCondLitPremise : public BaseImpl<Symbol const *, BaseCondLitPremise> {
173 public:
175 using Key = Symbol const *;
176
182 BaseCondLitPremise(MapElemCondLit &elems) : elems_{&elems} {}
183
185 void add(MapElemCondLit::iterator it) {
186 // Note: see note in add_premise
187 // assert(it.value().is_blocked());
188 it.value().set_offset(base_.size());
189 base_.emplace_back(std::distance(elems_->begin(), it));
190 }
191
193 [[nodiscard]] auto index(Key const &key) const -> size_t {
194 if (auto it = elems_->find(key); it != elems_->end() && it->second.has_offset()) {
195 return it->second.offset();
196 }
197 return size();
198 }
200 [[nodiscard]] auto size() const -> size_t { return base_.size(); }
201
203 [[nodiscard]] auto nth(size_t i) const -> MapElemCondLit::const_iterator { return elems_->nth(base_[i]); }
205 [[nodiscard]] auto nth(size_t i) -> MapElemCondLit::iterator { return elems_->nth(base_[i]); }
206
207 private:
208 MapElemCondLit *elems_;
209 std::vector<size_t> base_;
210};
211
213class BaseCondLit : public BaseImpl<Symbol const *, BaseCondLit> {
214 public:
220 BaseCondLit(MapAtomCondLit &atoms) : atoms_{&atoms} {}
221
223 void add(MapAtomCondLit::iterator it) {
224 it.value().set_offset(base_.size());
225 base_.emplace_back(std::distance(atoms_->begin(), it));
226 }
227
229 [[nodiscard]] auto index(Key const &key) const -> size_t {
230 if (auto it = atoms_->find(key); it != atoms_->end() && it->second.has_offset()) {
231 return it->second.offset();
232 }
233 return size();
234 }
236 [[nodiscard]] auto size() const -> size_t { return base_.size(); }
237
239 [[nodiscard]] auto nth(size_t i) const -> MapAtomCondLit::const_iterator { return atoms_->nth(base_[i]); }
241 [[nodiscard]] auto nth(size_t i) -> MapAtomCondLit::iterator { return atoms_->nth(base_[i]); }
242
243 private:
244 MapAtomCondLit *atoms_;
245 std::vector<size_t> base_;
246};
247
249class StateCondLit : public State {
250 public:
252 StateCondLit(std::pmr::monotonic_buffer_resource &mbr, VariableVec local, VariableVec global, size_t index,
253 bool has_conclusion, bool sp_premise, bool domain)
254 : local_{std::move(local)}, global_{std::move(global)}, mbr_{&mbr},
255 atoms_{0, Util::array_hash{global_.size()}, Util::array_equal_to{global_.size()}},
256 elems_{0, Util::array_hash{local_.size() + 1}, Util::array_equal_to{local_.size() + 1}}, base_empty_{atoms_},
257 base_premise_{elems_}, base_lit_{atoms_}, index_{index}, has_conclusion_{has_conclusion},
258 sp_premise_{sp_premise}, domain_{domain} {
259 temp_syms_.reserve(std::max(global_.size(), local_.size() + 1));
260 }
261
263 void vars(VariableSet &res, bool all) const;
264
266 [[nodiscard]] auto vars(bool all) const -> VariableSet;
267
269 [[nodiscard]] auto vars_global() const -> VariableVec const &;
270
272 [[nodiscard]] auto vars_local() const -> VariableVec const &;
273
275 [[nodiscard]] auto index() const -> size_t;
276
278 auto add_empty(Assignment const &ass) -> std::pair<MapAtomCondLit::iterator, bool>;
279
283 auto add_premise(EvalContext const &ctx, ULitVec const &premise) -> bool;
284
286 void add_conclusion(Assignment const &ass, MapAtomCondLit::iterator it, size_t conclusion, bool fact);
287
289 [[nodiscard]] auto propagate() -> bool;
290
292 [[nodiscard]] auto domain() const -> bool;
293
295 [[nodiscard]] auto base_empty() -> BaseCondLitEmpty &;
297 [[nodiscard]] auto base_premise() -> BaseCondLitPremise &;
301 [[nodiscard]] auto base_lit() -> BaseCondLit &;
302
307 [[nodiscard]] auto atom_find(Assignment const &ass) -> MapAtomCondLit::iterator;
308
312 [[nodiscard]] auto atom_index(Assignment const &ass) -> std::optional<size_t>;
313
315 [[nodiscard]] auto atom_index(MapAtomCondLit::const_iterator it) const -> size_t;
316
318 [[nodiscard]] auto atom_nth(size_t index) -> MapAtomCondLit::iterator;
319
323 [[nodiscard]] auto atom_is_fact(MapAtomCondLit::iterator it) -> bool;
324
330 [[nodiscard]] auto elem_find(Assignment const &ass, MapAtomCondLit::iterator it) -> MapElemCondLit::iterator;
331
333 [[nodiscard]] auto elem_index(MapElemCondLit::const_iterator it) const -> size_t;
334
336 void output(Logger &log, SymbolStore &store, OutputStm &out) override;
337
338 private:
339 VariableVec local_;
340 VariableVec global_;
341 std::vector<Symbol> mutable temp_syms_;
342 std::pmr::monotonic_buffer_resource *mbr_;
343 Symbol *syms_atom_ = nullptr;
344 MapAtomCondLit atoms_;
345 MapElemCondLit elems_;
346 std::vector<size_t> propagate_;
347 BaseCondLitEmpty base_empty_;
348 BaseCondLitPremise base_premise_;
349 BaseCondLit base_lit_;
350 size_t index_;
351 bool has_conclusion_;
352 bool sp_premise_;
353 bool domain_;
354};
355
358 public:
360 using Key = Symbol const *;
361
363 MatchCondLit(StateCondLit &state, LitCondLitType type) : state_{&state}, type_{type} {
364 eval_.reserve(type_ == LitCondLitType::premise
365 ? std::max(state_->vars_global().size(), state_->vars_local().size() + 1)
366 : state_->vars_global().size());
367 }
368
370 [[nodiscard]] auto vars() const -> VariableSet;
371
373 [[nodiscard]] auto signature(VariableSet const &bound, [[maybe_unused]] VariableSet const &bind) const
374 -> VariableVec;
375
377 [[nodiscard]] auto match(EvalContext const &ctx, Symbol const *sym) const -> bool;
378
380 [[nodiscard]] auto eval(EvalContext const &ctx) const -> std::optional<Symbol const *>;
381
383 friend auto operator<<(std::ostream &out, MatchCondLit const &m) -> std::ostream &;
384
386 [[nodiscard]] auto state() const -> StateCondLit &;
388 [[nodiscard]] auto type() const -> LitCondLitType;
389
390 private:
391 [[nodiscard]] static auto match_(Assignment &ass, Symbol const *sym, VariableVec const &vars) -> bool;
392
393 std::vector<Symbol> mutable eval_;
394 StateCondLit *state_;
395 LitCondLitType type_;
396};
397
399class LitCondLit : public Lit, private MatchCondLit {
400 public:
402 LitCondLit(LitCondLitType type, StateCondLit &state, size_t index) : MatchCondLit{state, type}, index_{index} {}
403
404 private:
405 void do_vars(VariableSet &vars, VarSelectMode mode) const override;
406 [[nodiscard]] auto do_domain() const -> bool override;
407 [[nodiscard]] auto do_single_pass() const -> bool override;
408 [[nodiscard]] auto do_matcher(std::pmr::monotonic_buffer_resource &mbr, MatcherType type,
409 std::vector<bool> const &bound)
410 -> std::pair<UMatcher, std::optional<size_t>> override;
411 [[nodiscard]] auto do_score(std::vector<bool> const &bound) const -> double override;
412 void do_print(std::ostream &out) const override;
413 [[nodiscard]] auto do_output(EvalContext const &ctx, OutputLit &out) const -> bool override;
414 [[nodiscard]] auto do_copy() const -> ULit override;
415 [[nodiscard]] auto do_hash() const -> size_t override;
416 [[nodiscard]] auto do_equal_to(Lit const &other) const -> bool override;
417 [[nodiscard]] auto do_compare_to(Lit const &other) const -> std::weak_ordering override;
418
419 size_t index_;
420 size_t offset_ = 0;
421};
422
424class LitCondLitStrat : public Lit, private InstanceCallback {
425 public:
427 LitCondLitStrat(StateCondLit &state, ULitVec premise) : state_{&state}, premise_{std::move(premise)} {}
428
429 private:
430 // lit interface
431 void do_vars(VariableSet &vars, VarSelectMode mode) const override;
432 [[nodiscard]] auto do_domain() const -> bool override;
433 [[nodiscard]] auto do_single_pass() const -> bool override;
434 [[nodiscard]] auto do_matcher(std::pmr::monotonic_buffer_resource &mbr, MatcherType type,
435 std::vector<bool> const &bound)
436 -> std::pair<UMatcher, std::optional<size_t>> override;
437 [[nodiscard]] auto do_score(std::vector<bool> const &bound) const -> double override;
438 void do_print(std::ostream &out) const override;
439 [[nodiscard]] auto do_output(EvalContext const &ctx, OutputLit &out) const -> bool override;
440 [[nodiscard]] auto do_copy() const -> ULit override;
441 [[nodiscard]] auto do_hash() const -> size_t override;
442 [[nodiscard]] auto do_equal_to(Lit const &other) const -> bool override;
443 [[nodiscard]] auto do_compare_to(Lit const &other) const -> std::weak_ordering override;
444
445 // cb interface
446 void do_init(size_t gen) override;
447 [[nodiscard]] auto do_report(EvalContext const &ctx) -> bool override;
448 void do_propagate(SymbolStore &store, OutputStm &out, Queue &queue) override;
449 [[nodiscard]] auto do_priority() const -> size_t override;
450 void do_print_head(std::ostream &out) const override;
451
452 StateCondLit *state_;
453 ULitVec premise_;
454};
455
457enum class StmCondLitType : uint8_t {
458 empty = 0,
459 premise = 1,
460 conclusion = 2,
461};
463auto operator<<(std::ostream &out, StmCondLitType type) -> std::ostream &;
464
466class StmCondLit : public Stm {
467 public:
469 StmCondLit(StmCondLitType type, StateCondLit &base, ULitVec body, size_t prio, size_t index)
470 : state_{&base}, body_{std::move(body)}, prio_{prio}, index_{index}, type_{type} {}
471
472 private:
473 // statement interface
474 void do_print(std::ostream &out) const override;
475 [[nodiscard]] auto do_body() const -> ULitVec const & override;
476 [[nodiscard]] auto do_important() const -> VariableSet override;
477
478 // solution callback interface
479 void do_print_head(std::ostream &out) const override;
480 void do_init(size_t gen) override;
481 [[nodiscard]] auto do_report(EvalContext const &ctx) -> bool override;
482 void do_propagate(SymbolStore &store, OutputStm &out, Queue &queue) override;
483 [[nodiscard]] auto do_priority() const -> size_t override;
484
485 StateCondLit *state_;
486 ULitVec body_;
487 size_t prio_;
488 size_t index_;
489 StmCondLitType type_;
490};
491
493
494} // namespace CppClingo::Ground
A base for not yet propagated conditional literals.
Definition condlit.hh:147
auto nth(size_t i) const -> MapAtomCondLit::const_iterator
Get the n-th atom in the base.
Definition condlit.hh:163
auto size() const -> size_t
Get the number of atoms in the base.
Definition condlit.hh:160
auto index(Key const &key) const -> size_t
Map a key to its index in the base.
Definition condlit.hh:156
auto nth(size_t i) -> MapAtomCondLit::iterator
Get the n-th atom in the base.
Definition condlit.hh:165
BaseCondLitEmpty(MapAtomCondLit &atoms)
Construct the base.
Definition condlit.hh:153
A base for premises of conditional literals.
Definition condlit.hh:172
auto size() const -> size_t
Get the number of atoms in the base.
Definition condlit.hh:200
void add(MapElemCondLit::iterator it)
Add a blocked element to the base.
Definition condlit.hh:185
auto nth(size_t i) const -> MapElemCondLit::const_iterator
Get the n-th atom in the base.
Definition condlit.hh:203
auto nth(size_t i) -> MapElemCondLit::iterator
Get the n-th atom in the base.
Definition condlit.hh:205
Symbol const * Key
Key to identify atoms.
Definition condlit.hh:175
BaseCondLitPremise(MapElemCondLit &elems)
Construct the base.
Definition condlit.hh:182
auto index(Key const &key) const -> size_t
Map a key to its index in the base.
Definition condlit.hh:193
A base for conditional literals.
Definition condlit.hh:213
void add(MapAtomCondLit::iterator it)
Add a propagated atom to the base.
Definition condlit.hh:223
BaseCondLit(MapAtomCondLit &atoms)
Construct the base.
Definition condlit.hh:220
auto nth(size_t i) -> MapAtomCondLit::iterator
Get the n-th atom in the base.
Definition condlit.hh:241
auto index(Key const &key) const -> size_t
Map a key to its index in the base.
Definition condlit.hh:229
auto size() const -> size_t
Get the number of atoms in the base.
Definition condlit.hh:236
auto nth(size_t i) const -> MapAtomCondLit::const_iterator
Get the n-th atom in the base.
Definition condlit.hh:239
The base implementation of an atom base.
Definition base.hh:148
Symbol const * Key
The key identifies an atom and is usually associated with further state.
Definition base.hh:151
Context object to capture state used during instantiation.
Definition instantiator.hh:35
Callbacks to notify statements during instantiations.
Definition instantiator.hh:107
Helper literal to ground stratified conditional literals.
Definition condlit.hh:424
LitCondLitStrat(StateCondLit &state, ULitVec premise)
Construct the literal.
Definition condlit.hh:427
Helper literals to ground conditional literals.
Definition condlit.hh:399
LitCondLit(LitCondLitType type, StateCondLit &state, size_t index)
Construct the literal.
Definition condlit.hh:402
The base class for groundable literals.
Definition literal.hh:34
A term like object used to match conditional literals and their elements.
Definition condlit.hh:357
Symbol const * Key
The key to match against.
Definition condlit.hh:360
MatchCondLit(StateCondLit &state, LitCondLitType type)
Construct the matcher.
Definition condlit.hh:363
auto vars() const -> VariableSet
Get the variables of the matcher.
A queue to process instantiators.
Definition instantiator.hh:206
Capture (the state of) a conditional literal.
Definition condlit.hh:92
auto is_fact(MapElemCondLit const &elems) const -> bool
Check if all elements of the atom are facts.
void set_offset(size_t offset)
Mark the atom as derived setting its derived index.
Definition condlit.hh:114
auto elems() const -> std::span< size_t const >
Get the elements of the conditional literal.
Definition condlit.hh:132
auto is_false() const -> bool
Check if the atom has been marked false.
Definition condlit.hh:110
auto uid() const -> std::optional< size_t >
Get the unique id of the atom.
Definition condlit.hh:123
auto enqueue(MapElemCondLit const &elems) -> bool
Enqueue the atom for grounding.
void uid(size_t uid)
Set the unique id of the atom.
Definition condlit.hh:127
void add_elem(size_t index)
Add an element with the given index to the atom.
Definition condlit.hh:96
auto has_offset() const -> bool
Check if the atom has been derived.
Definition condlit.hh:112
auto propagate(MapElemCondLit const &elems) -> bool
Propagate a previously enqueued atom.
auto offset() const -> size_t
The index of the atom in the vector of derived atoms.
Definition condlit.hh:118
State to capture a set of conditional literals.
Definition condlit.hh:249
auto add_premise(EvalContext const &ctx, ULitVec const &premise) -> bool
Add a new cond lit element with the given premise.
auto add_empty(Assignment const &ass) -> std::pair< MapAtomCondLit::iterator, bool >
Add a new cond lit atom.
void add_conclusion(Assignment const &ass, MapAtomCondLit::iterator it, size_t conclusion, bool fact)
Add a conclusion to an element.
auto vars(bool all) const -> VariableSet
Get the variables occurring in the conditional literal.
auto atom_index(Assignment const &ass) -> std::optional< size_t >
Find an atom given an assignment and return its index.
void vars(VariableSet &res, bool all) const
Get the variables occurring in the conditional literal.
auto vars_local() const -> VariableVec const &
Get the local variables of the literal.
auto propagate() -> bool
Propagate enqueued conditional literals whose elements are not blocked.
auto elem_index(MapElemCondLit::const_iterator it) const -> size_t
Turn an iterator into an element index.
auto base_premise() -> BaseCondLitPremise &
Get the base containing all premises of conditional literals.
auto elem_find(Assignment const &ass, MapAtomCondLit::iterator it) -> MapElemCondLit::iterator
Get an iterator to an element given an assignment.
auto base_empty() -> BaseCondLitEmpty &
Get the base containing all conditional literals encountered during grounding.
auto atom_is_fact(MapAtomCondLit::iterator it) -> bool
Check if the given atom is a fact.
auto atom_nth(size_t index) -> MapAtomCondLit::iterator
Turn an atom index into an iterator.
auto index() const -> size_t
Get the update index of the conditional literal.
auto atom_find(Assignment const &ass) -> MapAtomCondLit::iterator
Find an atom given an assignment and return an iterator to it.
auto base_lit() -> BaseCondLit &
Get the base containing all conditional literals that have been derived.
auto domain() const -> bool
Return true if all contained literals are domain.
StateCondLit(std::pmr::monotonic_buffer_resource &mbr, VariableVec local, VariableVec global, size_t index, bool has_conclusion, bool sp_premise, bool domain)
Construct an empty state.
Definition condlit.hh:252
void output(Logger &log, SymbolStore &store, OutputStm &out) override
Output the now complete conditional literal.
auto vars_global() const -> VariableVec const &
Get the global variables of the literal.
Class to store state for grounding.
Definition base.hh:438
Helper statement to ground conditional literals.
Definition condlit.hh:466
StmCondLit(StmCondLitType type, StateCondLit &base, ULitVec body, size_t prio, size_t index)
Construct the statement.
Definition condlit.hh:469
Base class for groundable statements.
Definition statement.hh:17
Simple logger to report message to stderr or via a callback.
Definition logger.hh:63
Interface to output literals.
Definition output.hh:61
Interface to output statements.
Definition output.hh:90
A store for symbols.
Definition symbol.hh:454
Variant-like class to store symbols stored in a symbol store.
Definition symbol.hh:225
std::vector< std::optional< Symbol > > Assignment
Assignment mapping variables to symbols.
Definition symbol.hh:222
VariableSet::values_container_type VariableVec
A vector of variables.
Definition base.hh:21
Util::ordered_set< size_t > VariableSet
A set of variables.
Definition base.hh:19
@ derived
Indicates that the atom is derived by some rule but not a fact.
@ unknown
Indicates that the atom has not yet been derived by a rule.
@ fact
Indicates that the atom is derived by a fact.
Util::ordered_map< Symbol const *, StateAtomCondLit, Util::array_hash, Util::array_equal_to > MapAtomCondLit
A map from the global variables to a conditional literal.
Definition condlit.hh:144
LitCondLitType
The type of the literals involved in grounding conditional literals.
Definition condlit.hh:14
Util::ordered_map< Symbol const *, StateCondLitElem, Util::array_hash, Util::array_equal_to > MapElemCondLit
A map from an atom + local variables to an element of a conditional literal.
Definition condlit.hh:87
auto operator<<(std::ostream &out, LitCondLitType type) -> std::ostream &
Print the type of a conditional literal grounding literal.
StmCondLitType
Type of the helper statement to ground conditional literals.
Definition condlit.hh:457
TruthConclusion
The 4-valued truth value of a conclusion.
Definition condlit.hh:24
@ empty
Literals encountered during grounding.
@ premise
Premises encountered during grounding.
@ lit
Conditional literals derived during grounding.
@ conclusion
Gather conclusions of conditional literals.
@ derived
There is rule that can derived the conclusion.
@ true_
The conclusion is true.
@ unknown
There is no rule yet that could derive the conclusion.
@ false_
The conclusion is false.
MatcherType
Enumeration of matcher types.
Definition instantiator.hh:48
std::unique_ptr< Matcher > UMatcher
A unique pointer to a matcher.
Definition instantiator.hh:100
std::unique_ptr< Lit > ULit
A unique pointer holding a literal.
Definition literal.hh:29
VarSelectMode
Available variable selection modes.
Definition literal.hh:21
std::vector< ULit > ULitVec
A vector of literals.
Definition literal.hh:31
@ all
Get all variables in a literal.
tsl::ordered_map< Key, T, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType > ordered_map
Alias for ordered maps.
Definition ordered_map.hh:16
Capture (the state of) an element of a conditional literal.
Definition condlit.hh:32
auto premise() const -> size_t
Get the premise of the element.
Definition condlit.hh:70
auto offset() const -> size_t
The index of the element in the vector of derived elements.
Definition condlit.hh:67
auto is_blocked() const -> bool
Check if the element is blocked.
Definition condlit.hh:50
auto is_fact() const -> bool
Check if the element is true, i.e., its conclusion is true.
Definition condlit.hh:45
auto is_false() const
Check if an element is false.
Definition condlit.hh:57
void set_conclusion(size_t conclusion, bool fact)
Mark a previously unknown conclusion either as derived or fact.
Definition condlit.hh:39
void set_offset(size_t offset)
Set the index of the element.
Definition condlit.hh:63
StateCondLitElem(size_t premise, bool premise_is_fact, bool has_conclusion)
Initialize the element.
Definition condlit.hh:35
auto has_offset() const -> bool
Check if the index of the element has already been set.
Definition condlit.hh:61
auto conclusion() const -> std::optional< size_t >
Get the conclusion index of the literal if there is one.
Definition condlit.hh:72