dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
symbolic_formula_visitor.h
1#pragma once
2
3#include <utility>
4
5#include "dlinear/symbolic/symbolic_formula.h"
6
7namespace dlinear::drake::symbolic {
8
18template<typename Result, typename Visitor, typename... Args>
19Result VisitFormula(Visitor *v, const Formula &f, Args &&... args) {
20 switch (f.get_kind()) {
21 case FormulaKind::False:return v->VisitFalse(f, std::forward<Args>(args)...);
22 case FormulaKind::True:return v->VisitTrue(f, std::forward<Args>(args)...);
23 case FormulaKind::Var:return v->VisitVariable(f, std::forward<Args>(args)...);
24 case FormulaKind::Eq:return v->VisitEqualTo(f, std::forward<Args>(args)...);
25 case FormulaKind::Neq:return v->VisitNotEqualTo(f, std::forward<Args>(args)...);
26 case FormulaKind::Gt:return v->VisitGreaterThan(f, std::forward<Args>(args)...);
27 case FormulaKind::Geq:return v->VisitGreaterThanOrEqualTo(f, std::forward<Args>(args)...);
28 case FormulaKind::Lt:return v->VisitLessThan(f, std::forward<Args>(args)...);
29 case FormulaKind::Leq:return v->VisitLessThanOrEqualTo(f, std::forward<Args>(args)...);
30 case FormulaKind::And:return v->VisitConjunction(f, std::forward<Args>(args)...);
31 case FormulaKind::Or:return v->VisitDisjunction(f, std::forward<Args>(args)...);
32 case FormulaKind::Not:return v->VisitNegation(f, std::forward<Args>(args)...);
33 case FormulaKind::Forall:return v->VisitForall(f, std::forward<Args>(args)...);
34 }
35 // Should not be reachable. But we need the following to avoid "control
36 // reaches end of non-void function" gcc-warning.
37 throw std::runtime_error("Should not be reachable.");
38}
39
40} // namespace dlinear::drake::symbolic
41
42