dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
PrefixPrinter.h
1
8#pragma once
9
10#include <ios>
11#include <string>
12
13#include "dlinear/symbolic/GenericExpressionVisitor.h"
14#include "dlinear/symbolic/GenericFormulaVisitor.h"
15#include "dlinear/symbolic/symbolic.h"
16
17namespace dlinear {
18
24class PrefixPrinter : public GenericFormulaVisitor<std::ostream &>, public GenericExpressionVisitor<std::ostream &> {
25 public:
32 explicit PrefixPrinter(std::ostream &os, const Config &config = Config{});
33
34 PrefixPrinter(const PrefixPrinter &) = delete;
35 PrefixPrinter(PrefixPrinter &&) = delete;
36 PrefixPrinter &operator=(const PrefixPrinter &) = delete;
37 PrefixPrinter &operator=(PrefixPrinter &&) = delete;
38
40 ~PrefixPrinter() override;
41
47 std::ostream &Print(const Expression &e) const;
48 std::ostream &operator()(const Expression &e) const;
49
55 std::ostream &Print(const Formula &f) const;
56 std::ostream &operator()(const Formula &f) const;
57
58 private:
59 std::ostream &VisitVariable(const Expression &e) const override;
60 std::ostream &VisitConstant(const Expression &e) const override;
61 std::ostream &VisitAddition(const Expression &e) const override;
62 std::ostream &VisitMultiplication(const Expression &e) const override;
63 std::ostream &VisitDivision(const Expression &e) const override;
64 std::ostream &VisitLog(const Expression &e) const override;
65 std::ostream &VisitAbs(const Expression &e) const override;
66 std::ostream &VisitExp(const Expression &e) const override;
67 std::ostream &VisitSqrt(const Expression &e) const override;
68 std::ostream &VisitPow(const Expression &e) const override;
69 std::ostream &VisitSin(const Expression &e) const override;
70 std::ostream &VisitCos(const Expression &e) const override;
71 std::ostream &VisitTan(const Expression &e) const override;
72 std::ostream &VisitAsin(const Expression &e) const override;
73 std::ostream &VisitAcos(const Expression &e) const override;
74 std::ostream &VisitAtan(const Expression &e) const override;
75 std::ostream &VisitAtan2(const Expression &e) const override;
76 std::ostream &VisitSinh(const Expression &e) const override;
77 std::ostream &VisitCosh(const Expression &e) const override;
78 std::ostream &VisitTanh(const Expression &e) const override;
79 std::ostream &VisitMin(const Expression &e) const override;
80 std::ostream &VisitMax(const Expression &e) const override;
81 std::ostream &VisitIfThenElse(const Expression &e) const override;
82 std::ostream &VisitUninterpretedFunction(const Expression &e) const override;
83
84 std::ostream &VisitFalse(const Formula &f) const override;
85 std::ostream &VisitTrue(const Formula &f) const override;
86 std::ostream &VisitVariable(const Formula &f) const override;
87 std::ostream &VisitEqualTo(const Formula &f) const override;
88 std::ostream &VisitNotEqualTo(const Formula &f) const override;
89 std::ostream &VisitGreaterThan(const Formula &f) const override;
90 std::ostream &VisitGreaterThanOrEqualTo(const Formula &f) const override;
91 std::ostream &VisitLessThan(const Formula &f) const override;
92 std::ostream &VisitLessThanOrEqualTo(const Formula &f) const override;
93 std::ostream &VisitConjunction(const Formula &f) const override;
94 std::ostream &VisitDisjunction(const Formula &f) const override;
95 std::ostream &VisitNegation(const Formula &f) const override;
96 std::ostream &VisitForall(const Formula &f) const override;
97
98 std::ostream &VisitUnaryFunction(const std::string &name, const Expression &e) const;
99 std::ostream &VisitBinaryFunction(const std::string &name, const Expression &e) const;
100
101 std::ostream &os_;
102 const std::streamsize old_precision_;
103};
104
110std::string ToPrefix(const Expression &e);
111
117std::string ToPrefix(const Formula &f);
118
119} // namespace dlinear
Simple dataclass used to store the configuration of the program.
Definition Config.h:38
Generic expression visitor implementing the visitor pattern.
Generic formula visitor implementing the visitor pattern.
Print expressions and formulas in prefix-form.
PrefixPrinter(std::ostream &os, const Config &config=Config{})
Constructs a new PrefixPrinter object with os.
std::ostream & os_
Stream to print to.
const std::streamsize old_precision_
Original precision of the stream.
std::ostream & Print(const Expression &e) const
Print the prefix form of the expression e to the ostream.
~PrefixPrinter() override
Restore the original precision of the ostream.
Represents a symbolic form of an expression.
Represents a symbolic form of a first-order logic formula.
Global namespace for the dlinear library.
std::string ToPrefix(const Expression &e)
Produce the prefix-string representation of the expression e.