dReal4
symbolic_formula_cell.h
1 #pragma once
2 
3 #include <atomic>
4 #include <functional>
5 #include <ostream>
6 #include <set>
7 #include <string>
8 #include <utility>
9 
10 #include "dreal/symbolic/hash.h"
11 #include "dreal/symbolic/symbolic_environment.h"
12 #include "dreal/symbolic/symbolic_expression.h"
13 #include "dreal/symbolic/symbolic_formula.h"
14 #include "dreal/symbolic/symbolic_variable.h"
15 #include "dreal/symbolic/symbolic_variables.h"
16 
17 namespace dreal {
18 namespace drake {
19 namespace symbolic {
20 
21 /** Represents an abstract class which is the base of concrete symbolic-formula
22  * classes (i.e. symbolic::FormulaAnd, symbolic::FormulaEq).
23  *
24  * \note It provides virtual function, FormulaCell::Display,
25  * because operator<< is not allowed to be a virtual function.
26  */
27 class FormulaCell {
28  public:
29  /** Default constructor (DELETED). */
30  FormulaCell() = delete;
31 
32  /** Move-assign (DELETED). */
33  FormulaCell& operator=(FormulaCell&& f) = delete;
34 
35  /** Copy-construct a formula from an lvalue. (DELETED) */
36  FormulaCell(const FormulaCell& f) = delete;
37 
38  /** Move-construct a formula from an rvalue (DELETED). */
39  FormulaCell(FormulaCell&& f) = delete;
40 
41  /** Copy-assign (DELETED). */
42  FormulaCell& operator=(const FormulaCell& f) = delete;
43 
44  /** Returns kind of formula. */
45  FormulaKind get_kind() const { return kind_; }
46  /** Returns hash of formula. */
47  size_t get_hash() const { return hash_; }
48  /** Returns set of free variables in formula. */
49  const Variables& GetFreeVariables() const;
50  /** Checks structural equality. */
51  virtual bool EqualTo(const FormulaCell& c) const = 0;
52  /** Checks ordering. */
53  virtual bool Less(const FormulaCell& c) const = 0;
54  /** Evaluates under a given environment. */
55  virtual bool Evaluate(const Environment& env) const = 0;
56  /** Returns a Formula obtained by replacing all occurrences of the
57  * variables in @p s in the current formula cell with the corresponding
58  * expressions in @p s.
59  */
60  virtual Formula Substitute(const ExpressionSubstitution& expr_subst,
61  const FormulaSubstitution& formula_subst) = 0;
62  /** Outputs string representation of formula into output stream @p os. */
63  virtual std::ostream& Display(std::ostream& os) const = 0;
64 
65  /** Returns the reference count of this cell. */
66  unsigned use_count() const {
67  return atomic_load_explicit(&rc_, std::memory_order_acquire);
68  }
69 
70  /// Returns true if this symbolic formula includes an ITE (If-Then-Else)
71  /// expression.
72  bool include_ite() const;
73 
74  protected:
75  /** Construct FormulaCell of kind @p k with @p hash. */
76  FormulaCell(FormulaKind k, size_t hash, bool include_ite,
77  Variables variables);
78  /** Default destructor. */
79  virtual ~FormulaCell() = default;
80  /** Returns a Formula pointing to this FormulaCell. */
82 
83  private:
84  const FormulaKind kind_{};
85  const size_t hash_{};
86  const bool include_ite_{false};
87  const Variables variables_;
88 
89  // Reference counter.
90  mutable std::atomic<unsigned> rc_{0};
91  void increase_rc() const {
92  atomic_fetch_add_explicit(&rc_, 1U, std::memory_order_relaxed);
93  }
94  void decrease_rc() const {
95  if (atomic_fetch_sub_explicit(&rc_, 1U, std::memory_order_acq_rel) == 1U) {
96  delete this;
97  }
98  }
99 
100  // So that Expression can call {increase,decrease}_rc.
101  friend Formula;
102 };
103 
104 /** Represents the base class for relational operators (==, !=, <, <=, >, >=).
105  */
107  public:
108  /** Default constructor (deleted). */
109  RelationalFormulaCell() = delete;
110  /** Default destructor (deleted). */
111  ~RelationalFormulaCell() override = default;
112  /** Move-construct a formula from an rvalue (DELETED). */
114  /** Copy-construct a formula from an lvalue (DELETED). */
115  RelationalFormulaCell(const RelationalFormulaCell& f) = delete;
116  /** Move-assign (DELETED). */
118  /** Copy-assign (DELETED). */
120  /** Construct RelationalFormulaCell of kind @p k with @p lhs and @p rhs. */
121  RelationalFormulaCell(FormulaKind k, const Expression& lhs,
122  const Expression& rhs);
123  bool EqualTo(const FormulaCell& f) const override;
124  bool Less(const FormulaCell& f) const override;
125 
126  /** Returns the expression on left-hand-side. */
127  const Expression& get_lhs_expression() const { return e_lhs_; }
128  /** Returns the expression on right-hand-side. */
129  const Expression& get_rhs_expression() const { return e_rhs_; }
130 
131  private:
132  const Expression e_lhs_;
133  const Expression e_rhs_;
134 };
135 
136 /** Represents the base class for N-ary logic operators (∧ and ∨).
137  *
138  * @note Internally this class maintains a set of symbolic formulas to avoid
139  * duplicated elements (i.e. f1 ∧ ... ∧ f1).
140  */
141 class NaryFormulaCell : public FormulaCell {
142  public:
143  /** Default constructor (deleted). */
144  NaryFormulaCell() = delete;
145  /** Default destructor (deleted). */
146  ~NaryFormulaCell() override = default;
147  /** Move-construct a formula from an rvalue (DELETED). */
148  NaryFormulaCell(NaryFormulaCell&& f) = delete;
149  /** Copy-construct a formula from an lvalue (DELETED). */
150  NaryFormulaCell(const NaryFormulaCell& f) = delete;
151  /** Move-assign (DELETED). */
153  /** Copy-assign (DELETED). */
154  NaryFormulaCell& operator=(const NaryFormulaCell& f) = delete;
155  /** Construct NaryFormulaCell of kind @p k with @p formulas. */
156  NaryFormulaCell(FormulaKind k, std::set<Formula> formulas);
157  bool EqualTo(const FormulaCell& f) const override;
158  bool Less(const FormulaCell& f) const override;
159  /** Returns the formulas. */
160  const std::set<Formula>& get_operands() const { return formulas_; }
161 
162  /** Returns the formulas. */
163  std::set<Formula>& get_mutable_operands() { return formulas_; }
164 
165  protected:
166  std::ostream& DisplayWithOp(std::ostream& os, const std::string& op) const;
167 
168  private:
169  static Variables ExtractFreeVariables(const std::set<Formula>& formulas);
170 
171  std::set<Formula> formulas_;
172 };
173 
174 /** Symbolic formula representing true. */
175 class FormulaTrue : public FormulaCell {
176  public:
177  /** Default Constructor. */
178  FormulaTrue();
179  bool EqualTo(const FormulaCell& f) const override;
180  bool Less(const FormulaCell& f) const override;
181  bool Evaluate(const Environment& env) const override;
182  Formula Substitute(const ExpressionSubstitution& expr_subst,
183  const FormulaSubstitution& formula_subst) override;
184  std::ostream& Display(std::ostream& os) const override;
185 };
186 
187 /** Symbolic formula representing false. */
188 class FormulaFalse : public FormulaCell {
189  public:
190  /** Default Constructor. */
191  FormulaFalse();
192  bool EqualTo(const FormulaCell& f) const override;
193  bool Less(const FormulaCell& f) const override;
194  bool Evaluate(const Environment& env) const override;
195  Formula Substitute(const ExpressionSubstitution& expr_subst,
196  const FormulaSubstitution& formula_subst) override;
197  std::ostream& Display(std::ostream& os) const override;
198 };
199 
200 /** Symbolic formula representing a Boolean variable. */
201 class FormulaVar : public FormulaCell {
202  public:
203  /** Constructs a formula from @p var.
204  * @pre @p var is of BOOLEAN type and not a dummy variable.
205  */
206  explicit FormulaVar(const Variable& v);
207  bool EqualTo(const FormulaCell& f) const override;
208  bool Less(const FormulaCell& f) const override;
209  bool Evaluate(const Environment& env) const override;
210  Formula Substitute(const ExpressionSubstitution& expr_subst,
211  const FormulaSubstitution& formula_substubst) override;
212  std::ostream& Display(std::ostream& os) const override;
213  const Variable& get_variable() const;
214 
215  private:
216  const Variable var_;
217 };
218 
219 /** Symbolic formula representing equality (e1 = e2). */
221  public:
222  /** Constructs from @p e1 and @p e2. */
223  FormulaEq(const Expression& e1, const Expression& e2);
224  bool Evaluate(const Environment& env) const override;
225  Formula Substitute(const ExpressionSubstitution& expr_subst,
226  const FormulaSubstitution& formula_subst) override;
227  std::ostream& Display(std::ostream& os) const override;
228 };
229 
230 /** Symbolic formula representing disequality (e1 ≠ e2). */
232  public:
233  /** Constructs from @p e1 and @p e2. */
234  FormulaNeq(const Expression& e1, const Expression& e2);
235  bool Evaluate(const Environment& env) const override;
236  Formula Substitute(const ExpressionSubstitution& expr_subst,
237  const FormulaSubstitution& formula_subst) override;
238  std::ostream& Display(std::ostream& os) const override;
239 };
240 
241 /** Symbolic formula representing 'greater-than' (e1 > e2). */
243  public:
244  /** Constructs from @p e1 and @p e2. */
245  FormulaGt(const Expression& e1, const Expression& e2);
246  bool Evaluate(const Environment& env) const override;
247  Formula Substitute(const ExpressionSubstitution& expr_subst,
248  const FormulaSubstitution& formula_subst) override;
249  std::ostream& Display(std::ostream& os) const override;
250 };
251 
252 /** Symbolic formula representing 'greater-than-or-equal-to' (e1 ≥ e2). */
254  public:
255  /** Constructs from @p e1 and @p e2. */
256  FormulaGeq(const Expression& e1, const Expression& e2);
257  bool Evaluate(const Environment& env) const override;
258  Formula Substitute(const ExpressionSubstitution& expr_subst,
259  const FormulaSubstitution& formula_subst) override;
260  std::ostream& Display(std::ostream& os) const override;
261 };
262 
263 /** Symbolic formula representing 'less-than' (e1 < e2). */
265  public:
266  /** Constructs from @p e1 and @p e2. */
267  FormulaLt(const Expression& e1, const Expression& e2);
268  bool Evaluate(const Environment& env) const override;
269  Formula Substitute(const ExpressionSubstitution& expr_subst,
270  const FormulaSubstitution& formula_subst) override;
271  std::ostream& Display(std::ostream& os) const override;
272 };
273 
274 /** Symbolic formula representing 'less-than-or-equal-to' (e1 ≤ e2). */
276  public:
277  /** Constructs from @p e1 and @p e2. */
278  FormulaLeq(const Expression& e1, const Expression& e2);
279  bool Evaluate(const Environment& env) const override;
280  Formula Substitute(const ExpressionSubstitution& expr_subst,
281  const FormulaSubstitution& formula_subst) override;
282  std::ostream& Display(std::ostream& os) const override;
283 };
284 
285 /** Symbolic formula representing conjunctions (f1 ∧ ... ∧ fn). */
286 class FormulaAnd : public NaryFormulaCell {
287  public:
288  /** Constructs from @p formulas. */
289  explicit FormulaAnd(std::set<Formula> formulas);
290  /** Constructs @p f1 ∧ @p f2. */
291  FormulaAnd(const Formula& f1, const Formula& f2);
292  bool Evaluate(const Environment& env) const override;
293  Formula Substitute(const ExpressionSubstitution& expr_subst,
294  const FormulaSubstitution& formula_subst) override;
295  std::ostream& Display(std::ostream& os) const override;
296 };
297 
298 /** Symbolic formula representing disjunctions (f1 ∨ ... ∨ fn). */
299 class FormulaOr : public NaryFormulaCell {
300  public:
301  /** Constructs from @p formulas. */
302  explicit FormulaOr(std::set<Formula> formulas);
303  /** Constructs @p f1 ∨ @p f2. */
304  FormulaOr(const Formula& f1, const Formula& f2);
305  bool Evaluate(const Environment& env) const override;
306  Formula Substitute(const ExpressionSubstitution& expr_subst,
307  const FormulaSubstitution& formula_subst) override;
308  std::ostream& Display(std::ostream& os) const override;
309 };
310 
311 /** Symbolic formula representing negations (¬f). */
312 class FormulaNot : public FormulaCell {
313  public:
314  /** Constructs from @p f. */
315  explicit FormulaNot(const Formula& f);
316  bool EqualTo(const FormulaCell& f) const override;
317  bool Less(const FormulaCell& f) const override;
318  bool Evaluate(const Environment& env) const override;
319  Formula Substitute(const ExpressionSubstitution& expr_subst,
320  const FormulaSubstitution& formula_subst) override;
321  std::ostream& Display(std::ostream& os) const override;
322  /** Returns the operand. */
323  const Formula& get_operand() const { return f_; }
324 
325  private:
326  const Formula f_;
327 };
328 
329 /** Symbolic formula representing universal quantifications
330  * (∀ x₁, ..., * xn. F).
331  */
332 class FormulaForall : public FormulaCell {
333  public:
334  /** Constructs from @p vars and @p f. */
335  FormulaForall(const Variables& vars, Formula f);
336  bool EqualTo(const FormulaCell& f) const override;
337  bool Less(const FormulaCell& f) const override;
338  bool Evaluate(const Environment& env) const override;
339  Formula Substitute(const ExpressionSubstitution& expr_subst,
340  const FormulaSubstitution& formula_subst) override;
341  std::ostream& Display(std::ostream& os) const override;
342  /** Returns the quantified variables. */
343  const Variables& get_quantified_variables() const { return vars_; }
344  /** Returns the quantified formula. */
345  const Formula& get_quantified_formula() const { return f_; }
346 
347  private:
348  const Variables vars_; // Quantified variables.
349  const Formula f_; // Quantified formula.
350 };
351 
352 /** Checks if @p f is structurally equal to False formula. */
353 bool is_false(const FormulaCell& f);
354 /** Checks if @p f is structurally equal to True formula. */
355 bool is_true(const FormulaCell& f);
356 /** Checks if @p f is a variable formula. */
357 bool is_variable(const FormulaCell& f);
358 /** Checks if @p f is a formula representing equality (==). */
359 bool is_equal_to(const FormulaCell& f);
360 /** Checks if @p f is a formula representing disequality (!=). */
361 bool is_not_equal_to(const FormulaCell& f);
362 /** Checks if @p f is a formula representing greater-than (>). */
363 bool is_greater_than(const FormulaCell& f);
364 /** Checks if @p f is a formula representing greater-than-or-equal-to (>=). */
365 bool is_greater_than_or_equal_to(const FormulaCell& f);
366 /** Checks if @p f is a formula representing less-than (<). */
367 bool is_less_than(const FormulaCell& f);
368 /** Checks if @p f is a formula representing less-than-or-equal-to (<=). */
369 bool is_less_than_or_equal_to(const FormulaCell& f);
370 /** Checks if @p f is a relational formula ({==, !=, >, >=, <, <=}). */
371 bool is_relational(const FormulaCell& f);
372 /** Checks if @p f is a conjunction (∧). */
373 bool is_conjunction(const FormulaCell& f);
374 /** Checks if @p f is a disjunction (∨). */
375 bool is_disjunction(const FormulaCell& f);
376 /** Checks if @p f is a negation (¬). */
377 bool is_negation(const FormulaCell& f);
378 /** Checks if @p f is a Forall formula (∀). */
379 bool is_forall(const FormulaCell& f);
380 
381 /** Casts @p f_ptr to @c const FormulaFalse*.
382  * @pre @c is_false(*f_ptr) is true.
383  */
384 const FormulaFalse* to_false(const FormulaCell* f_ptr);
385 /** Casts @p f to @c const FormulaFalse*.
386  * @pre @c is_false(f) is true.
387  */
388 const FormulaFalse* to_false(const Formula& f);
389 
390 /** Casts @p f_ptr to @c const FormulaTrue*.
391  * @pre @c is_true(*f_ptr) is true.
392  */
393 const FormulaTrue* to_true(const FormulaCell* f_ptr);
394 /** Casts @p f to @c const FormulaTrue*.
395  * @pre @c is_true(f) is true.
396  */
397 const FormulaTrue* to_true(const Formula& f);
398 
399 /** Casts @p f_ptr to @c const FormulaVar*.
400  * @pre @c is_variable(*f_ptr) is true.
401  */
402 const FormulaVar* to_variable(const FormulaCell* f_ptr);
403 /** Casts @p f to @c const FormulaVar*.
404  * @pre @c is_variable(f) is true.
405  */
406 const FormulaVar* to_variable(const Formula& f);
407 
408 /** Casts @p f_ptr to @c const RelationalFormulaCell*.
409  * @pre @c is_relational(*f_ptr) is true.
410  */
411 const RelationalFormulaCell* to_relational(const FormulaCell* f_ptr);
412 
413 /** Casts @p f to @c const RelationalFormulaCell*.
414  * @pre @c is_relational(f) is true.
415  */
416 const RelationalFormulaCell* to_relational(const Formula& f);
417 
418 /** Casts @p f_ptr to @c const FormulaEq*.
419  * @pre @c is_equal_to(*f_ptr) is true.
420  */
421 const FormulaEq* to_equal_to(const FormulaCell* f_ptr);
422 
423 /** Casts @p f to @c const FormulaEq*.
424  * @pre @c is_equal_to(f) is true.
425  */
426 const FormulaEq* to_equal_to(const Formula& f);
427 
428 /** Casts @p f_ptr to @c const FormulaNeq*.
429  * @pre @c is_not_equal_to(*f_ptr) is true.
430  */
431 const FormulaNeq* to_not_equal_to(const FormulaCell* f_ptr);
432 
433 /** Casts @p f to @c const FormulaNeq*.
434  * @pre @c is_not_equal_to(f) is true.
435  */
436 const FormulaNeq* to_not_equal_to(const Formula& f);
437 
438 /** Casts @p f_ptr to @c const FormulaGt*.
439  * @pre @c is_greater_than(*f_ptr) is true.
440  */
441 const FormulaGt* to_greater_than(const FormulaCell* f_ptr);
442 
443 /** Casts @p f to @c const FormulaGt*.
444  * @pre @c is_greater_than(f) is true.
445  */
446 const FormulaGt* to_greater_than(const Formula& f);
447 
448 /** Casts @p f_ptr to @c const FormulaGeq*.
449  * @pre @c is_greater_than_or_equal_to(*f_ptr) is true.
450  */
451 const FormulaGeq* to_greater_than_or_equal_to(const FormulaCell* f_ptr);
452 
453 /** Casts @p f to @c const FormulaGeq*.
454  * @pre @c is_greater_than_or_equal_to(f) is true.
455  */
456 const FormulaGeq* to_greater_than_or_equal_to(const Formula& f);
457 
458 /** Casts @p f_ptr to @c const FormulaLt*.
459  * @pre @c is_less_than(*f_ptr) is true.
460  */
461 const FormulaLt* to_less_than(const FormulaCell* f_ptr);
462 
463 /** Casts @p f to @c const FormulaLt*.
464  * @pre @c is_less_than(f) is true.
465  */
466 const FormulaLt* to_less_than(const Formula& f);
467 
468 /** Casts @p f_ptr to @c const FormulaLeq*.
469  * @pre @c is_less_than_or_equal_to(*f_ptr) is true.
470  */
471 const FormulaLeq* to_less_than_or_equal_to(const FormulaCell* f_ptr);
472 
473 /** Casts @p f to @c const FormulaLeq*.
474  * @pre @c is_less_than_or_equal_to(f) is true.
475  */
476 const FormulaLeq* to_less_than_or_equal_to(const Formula& f);
477 
478 /** Casts @p f_ptr to @c const FormulaAnd*.
479  * @pre @c is_conjunction(*f_ptr) is true.
480  */
481 const FormulaAnd* to_conjunction(const FormulaCell* f_ptr);
482 
483 /** Casts @p f to @c const FormulaAnd*.
484  * @pre @c is_conjunction(f) is true.
485  */
486 const FormulaAnd* to_conjunction(const Formula& f);
487 
488 /** Casts @p f_ptr to @c const FormulaOr*.
489  * @pre @c is_disjunction(*f_ptr) is true.
490  */
491 const FormulaOr* to_disjunction(const FormulaCell* f_ptr);
492 
493 /** Casts @p f to @c const FormulaOr*.
494  * @pre @c is_disjunction(f) is true.
495  */
496 const FormulaOr* to_disjunction(const Formula& f);
497 
498 /** Casts @p f_ptr to @c const NaryFormulaCell*.
499  * @pre @c is_nary(*f_ptr) is true.
500  */
501 const NaryFormulaCell* to_nary(const FormulaCell* f_ptr);
502 
503 /** Casts @p f to @c const NaryFormulaCell*.
504  * @pre @c is_nary(f) is true.
505  */
506 const NaryFormulaCell* to_nary(const Formula& f);
507 
508 /** Casts @p f_ptr to `NaryFormulaCell*`.
509  * @pre `is_nary(*f_ptr)` is true.
510  */
511 NaryFormulaCell* to_nary(FormulaCell* f_ptr);
512 
513 /** Casts @p f to `NaryFormulaCell*`.
514  * @pre `is_nary(f)` is true.
515  */
516 NaryFormulaCell* to_nary(Formula& f);
517 
518 /** Casts @p f_ptr to @c const FormulaNot*.
519  * @pre @c is_negation(*f_ptr) is true.
520  */
521 const FormulaNot* to_negation(const FormulaCell* f_ptr);
522 
523 /** Casts @p f to @c const FormulaNot*.
524  * @pre @c is_negation(f) is true.
525  */
526 const FormulaNot* to_negation(const Formula& f);
527 
528 /** Casts @p f_ptr to @c const FormulaForall*.
529  * @pre @c is_forall(*f_ptr) is true.
530  */
531 const FormulaForall* to_forall(const FormulaCell* f_ptr);
532 
533 /** Casts @p f to @c const FormulaForall*.
534  * @pre @c is_forall(f) is true.
535  */
536 const FormulaForall* to_forall(const Formula& f);
537 
538 } // namespace symbolic
539 } // namespace drake
540 } // namespace dreal
virtual Formula Substitute(const ExpressionSubstitution &expr_subst, const FormulaSubstitution &formula_subst)=0
Returns a Formula obtained by replacing all occurrences of the variables in s in the current formula ...
const Expression & get_rhs_expression() const
Returns the expression on right-hand-side.
Definition: symbolic_formula_cell.h:129
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
Symbolic formula representing &#39;less-than-or-equal-to&#39; (e1 ≤ e2).
Definition: symbolic_formula_cell.h:275
Symbolic formula representing disequality (e1 ≠ e2).
Definition: symbolic_formula_cell.h:231
const std::set< Formula > & get_operands() const
Returns the formulas.
Definition: symbolic_formula_cell.h:160
Symbolic formula representing &#39;greater-than-or-equal-to&#39; (e1 ≥ e2).
Definition: symbolic_formula_cell.h:253
bool include_ite() const
Returns true if this symbolic formula includes an ITE (If-Then-Else) expression.
Definition: symbolic_formula_cell.cc:44
const Formula & get_operand() const
Returns the operand.
Definition: symbolic_formula_cell.h:323
std::shared_ptr< ContractorForall< ContextType > > to_forall(const Contractor &contractor)
Converts contractor to ContractorForall.
Definition: contractor_forall.h:331
Represents a symbolic variable.
Definition: symbolic_variable.h:16
size_t get_hash() const
Returns hash of formula.
Definition: symbolic_formula_cell.h:47
Symbolic formula representing equality (e1 = e2).
Definition: symbolic_formula_cell.h:220
FormulaCell & operator=(FormulaCell &&f)=delete
Move-assign (DELETED).
FormulaCell()=delete
Default constructor (DELETED).
Symbolic formula representing &#39;less-than&#39; (e1 < e2).
Definition: symbolic_formula_cell.h:264
Represents an abstract class which is the base of concrete symbolic-formula classes (i...
Definition: symbolic_formula_cell.h:27
Symbolic formula representing disjunctions (f1 ∨ ...
Definition: symbolic_formula_cell.h:299
std::set< Formula > & get_mutable_operands()
Returns the formulas.
Definition: symbolic_formula_cell.h:163
FormulaKind get_kind() const
Returns kind of formula.
Definition: symbolic_formula_cell.h:45
Represents the base class for N-ary logic operators (∧ and ∨).
Definition: symbolic_formula_cell.h:141
Symbolic formula representing false.
Definition: symbolic_formula_cell.h:188
const Formula & get_quantified_formula() const
Returns the quantified formula.
Definition: symbolic_formula_cell.h:345
const Expression & get_lhs_expression() const
Returns the expression on left-hand-side.
Definition: symbolic_formula_cell.h:127
Represents a symbolic environment (mapping from a variable to a value).
Definition: symbolic_environment.h:52
Symbolic formula representing true.
Definition: symbolic_formula_cell.h:175
const Variables & GetFreeVariables() const
Returns set of free variables in formula.
Definition: symbolic_formula_cell.cc:42
Symbolic formula representing negations (¬f).
Definition: symbolic_formula_cell.h:312
const Variables & get_quantified_variables() const
Returns the quantified variables.
Definition: symbolic_formula_cell.h:343
Represents the base class for relational operators (==, !=, <, <=, >, >=).
Definition: symbolic_formula_cell.h:106
Symbolic formula representing &#39;greater-than&#39; (e1 > e2).
Definition: symbolic_formula_cell.h:242
virtual bool Evaluate(const Environment &env) const =0
Evaluates under a given environment.
Symbolic formula representing a Boolean variable.
Definition: symbolic_formula_cell.h:201
Symbolic formula representing universal quantifications (∀ x₁, ..., * xn.
Definition: symbolic_formula_cell.h:332
Symbolic formula representing conjunctions (f1 ∧ ...
Definition: symbolic_formula_cell.h:286
virtual ~FormulaCell()=default
Default destructor.
bool is_forall(const Contractor &contractor)
Returns true if contractor is forall contractor.
Definition: contractor.cc:221
Represents a set of variables.
Definition: symbolic_variables.h:25
Represents a symbolic form of an expression.
Definition: symbolic_expression.h:164
virtual bool Less(const FormulaCell &c) const =0
Checks ordering.
Formula GetFormula()
Returns a Formula pointing to this FormulaCell.
Definition: symbolic_formula_cell.cc:40
virtual std::ostream & Display(std::ostream &os) const =0
Outputs string representation of formula into output stream os.
Represents a symbolic form of a first-order logic formula.
Definition: symbolic_formula.h:101
virtual bool EqualTo(const FormulaCell &c) const =0
Checks structural equality.
unsigned use_count() const
Returns the reference count of this cell.
Definition: symbolic_formula_cell.h:66