3#ifndef __PERCEMON_AST_TQTL_HPP__
4#define __PERCEMON_AST_TQTL_HPP__
6#include "percemon/ast/ast.hpp"
10namespace percemon::ast {
16 std::optional<Var_x> x;
17 std::optional<Var_f> f;
19 Expr phi = Expr{
Const{
false}};
21 Pin(
const std::optional<Var_x>& x_,
const std::optional<Var_f>& f_) : x{x_}, f{f_} {
22 if (!x_.has_value() and !f_.has_value()) {
23 throw std::invalid_argument(
24 "Either time variable or frame variable must be specified when a frame is pinned.");
28 Pin(
const std::optional<Var_x>& x_) :
Pin{x_, {}} {};
29 Pin(
const std::optional<Var_f>& f_) :
Pin{{}, f_} {};
32 Pin& operator=(
const Pin&) =
default;
34 Pin& operator=(
Pin&&) =
default;
36 PinPtr dot(
const Expr& e) {
37 auto ret = std::make_shared<Pin>(x, f);
47 std::vector<Var_id> ids;
48 std::optional<Pin> pinned_at = {};
49 std::optional<Expr> phi = {};
51 Exists(std::vector<Var_id> id_list) : ids{std::move(id_list)}, pinned_at{}, phi{} {};
53 ExistsPtr at(
const Pin& pin) {
54 auto ret = std::make_shared<Exists>(ids);
59 ExistsPtr at(
Pin&& pin) {
60 auto ret = std::make_shared<Exists>(ids);
61 ret->pinned_at = std::move(pin);
65 ExistsPtr dot(
const Expr& e) {
66 auto ret = std::make_shared<Exists>(ids);
67 if (
auto& pin = this->pinned_at) {
69 ret->pinned_at->phi = e;
81 std::vector<Var_id> ids;
82 std::optional<Pin> pinned_at = {};
83 std::optional<Expr> phi = {};
85 Forall(std::vector<Var_id> id_list) : ids{std::move(id_list)}, pinned_at{}, phi{} {};
87 ForallPtr at(
const Pin& pin) {
88 auto ret = std::make_shared<Forall>(ids);
93 ForallPtr at(
Pin&& pin) {
94 auto ret = std::make_shared<Forall>(ids);
95 ret->pinned_at = std::move(pin);
99 ForallPtr dot(
const Expr& e) {
100 auto ret = std::make_shared<Forall>(ids);
101 if (
auto& pin = this->pinned_at) {
102 ret->pinned_at = pin;
103 ret->pinned_at->phi = e;
115 Not(Expr arg_) : arg{std::move(arg_)} {};
119 std::vector<Expr> args;
120 std::vector<TemporalBoundExpr> temporal_bound_args;
123 And(
const std::vector<Expr>& args_) {
124 if (args_.size() < 2) {
125 throw std::invalid_argument(
126 "It doesn't make sense to have an And operator with < 2 operands");
128 for (
auto&& e : args_) {
129 if (
auto tb_ptr = std::get_if<TimeBound>(&e)) {
130 temporal_bound_args.emplace_back(*tb_ptr);
131 }
else if (
auto fb_ptr = std::get_if<FrameBound>(&e)) {
132 temporal_bound_args.emplace_back(*fb_ptr);
141 std::vector<Expr> args;
142 std::vector<TemporalBoundExpr> temporal_bound_args;
145 Or(
const std::vector<Expr>& args_) {
146 if (args_.size() < 2) {
147 throw std::invalid_argument(
148 "It doesn't make sense to have an Or operator with < 2 operands");
150 for (
auto&& e : args_) {
151 if (
auto tb_ptr = std::get_if<TimeBound>(&e)) {
152 temporal_bound_args.emplace_back(*tb_ptr);
153 }
else if (
auto fb_ptr = std::get_if<FrameBound>(&e)) {
154 temporal_bound_args.emplace_back(*fb_ptr);
166 Previous(Expr arg_) : arg{std::move(arg_)} {};
173 Always(Expr arg_) : arg{std::move(arg_)} {};
180 Sometimes(Expr arg_) : arg{std::move(arg_)} {};
184 std::pair<Expr, Expr> args;
187 Since(
const Expr& arg0,
const Expr& arg1) : args{std::make_pair(arg0, arg1)} {};
191 std::pair<Expr, Expr> args;
194 BackTo(
const Expr& arg0,
const Expr& arg1) : args{std::make_pair(arg0, arg1)} {};
Definition: primitives.hpp:21