2
* File: TARReachability.h
3
* Author: Peter G. Jensen
5
* Created on January 2, 2018, 8:36 AM
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef TARREACHABILITY_H
22
#define TARREACHABILITY_H
24
#include "ReachabilitySearch.h"
25
#include "../TAR/TARAutomata.h"
26
namespace PetriEngine {
27
namespace Reachability {
28
class TARReachabilitySearch {
30
ResultPrinter& printer;
35
TARReachabilitySearch(ResultPrinter& printer, PetriNet& net, Reducer* reducer, int kbound = 0)
36
: printer(printer), _net(net), _reducer(reducer) {
40
~TARReachabilitySearch()
45
std::vector<std::shared_ptr<PQL::Condition > >& queries,
46
std::vector<ResultPrinter::Result>& results,
47
bool printstats, bool printtrace);
49
virtual void addNonChanging(state_t& state, std::vector<size_t>& maximal, std::vector<size_t>& nextinter);
50
virtual std::vector<size_t> expandSimulation(std::vector<size_t>& from);
51
virtual bool followSymbol(std::vector<size_t>& from, std::vector<size_t>& nextinter, size_t symbol);
52
z3::expr computeParameters(
53
z3::context& context, std::vector<z3::expr>& encoded, z3::expr& param_reach,
54
const std::vector<uint32_t>&, const std::vector<bool>& inq, const std::vector<bool>& read);
56
typedef std::vector<state_t> waiting_t;
57
void printTrace(waiting_t& stack);
58
bool tryReach( const std::shared_ptr<PQL::Condition>& query,
59
std::vector<ResultPrinter::Result>& results,
60
bool printstats, bool printtrace, Structures::State& initial);
61
size_t computeSimulation(size_t index, size_t sim_hint = 1, size_t simed_hint = 0);
62
bool popDone(waiting_t& waiting, size_t& stepno);
63
bool checkInclussion(state_t& state, std::vector<size_t>& nextinter, z3::context& ctx);
65
void handleInvalidTrace(waiting_t& waiting, int nvalid);
66
std::pair<int,bool> isValidTrace(waiting_t& trace, z3::context& context, bool probe, Structures::State& initial, z3::expr& query, const std::vector<bool>& inq, z3::expr& param);
67
bool findValidRange( int& from,
70
z3::expr_vector& interpolant,
71
std::vector<z3::expr>& encoded);
72
int constructAutomata(int from, waiting_t& trace, z3::expr_vector& inter, z3::context& context);
73
std::pair<bool, size_t> stateForPredicate(int type, z3::expr pred, z3::context& context, size_t sim_hint = 1, size_t simed_hint = 0);
75
bool checkQueries( std::vector<std::shared_ptr<PQL::Condition > >&,
76
std::vector<ResultPrinter::Result>&,
77
Structures::State&, bool);
78
ResultPrinter::Result printQuery(std::shared_ptr<PQL::Condition>& query, size_t i, ResultPrinter::Result);
87
el_t(z3::expr e, size_t s) : expr(e), state(s) {};
89
std::unordered_map<size_t, std::vector<el_t>> intmap;
90
std::vector<AutomataState> states;
91
std::vector<size_t> simorder;
92
std::map<size_t, std::vector<size_t>> edge_interpolants;
98
#endif /* TARREACHABILITY_H */