#include #include #include #include "Operator.hpp" #include "Expression.hpp" #include "EquationSystem.hpp" #include "MaxStrategy.hpp" using namespace std; typedef std::vector*> Args; typedef Expression E; typedef Constant C; typedef Addition A; typedef Minimum Min; std::vector< Expression* > empty; int main () { EquationSystem sys; Variable* x = sys.newVariable("x"); Variable* y = sys.newVariable("y"); Variable* z = sys.newVariable("z"); Args xPlusArgs; xPlusArgs.push_back(new E(x, empty)); Args xMinArgs; xMinArgs.push_back(new E(new A(-1), xPlusArgs)); xMinArgs.push_back(new E(y, empty)); Args xMaxArgs; xMaxArgs.push_back(new E(new C(0), empty)); xMaxArgs.push_back(new E(new Min(), xMinArgs)); sys[*x] = sys.newMaxExpression(xMaxArgs); // x = max(0, min(x-1, y)) Args yPlusArgs; yPlusArgs.push_back(new E(x, empty)); Args yMaxArgs; yMaxArgs.push_back(new E(new C(0), empty)); yMaxArgs.push_back(new E(new A(5), yPlusArgs)); yMaxArgs.push_back(new E(x, empty)); sys[*y] = sys.newMaxExpression(yMaxArgs); // y = max(0, x+5, x) Args zPlusArgs1; zPlusArgs1.push_back(new E(z, empty)); Args zPlusArgs2; zPlusArgs2.push_back(new E(x, empty)); Args zMaxArgs; zMaxArgs.push_back(new E(new C(0), empty)); zMaxArgs.push_back(new E(new A(1), zPlusArgs1)); zMaxArgs.push_back(new E(new A(0), zPlusArgs2)); sys[*z] = sys.newMaxExpression(zMaxArgs); // z = max(0, z+1, x) // x = max(0, min(x-1, y)) // y = max(0, x+5, x) // z = max(0, z+1, x) // => x: 0, y: 5, z: inf VariableAssignment fixpoint = sys.minFixpoint(); cout << "x = " << fixpoint[*x] << endl; cout << "y = " << fixpoint[*y] << endl; cout << "z = " << fixpoint[*z] << endl; return 0; }