spot 2.13.0.dev
Loading...
Searching...
No Matches
backprop.hh
1// -*- coding: utf-8 -*-
2// Copyright (C) by the Spot authors, see the AUTHORS file for details.
3//
4// This file is part of Spot, a model checking library.
5//
6// Spot is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 3 of the License, or
9// (at your option) any later version.
10//
11// Spot is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14// License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19#pragma once
20
21#include <iosfwd>
22#include <unordered_map>
23#include <spot/misc/common.hh>
24#include <spot/misc/trival.hh>
25#include <spot/graph/adjlist.hh>
26
27namespace spot
28{
29
30 struct SPOT_API backprop_state
31 {
32 int counter; // number of unknown successors
33 bool owner;
34 bool frozen;
35 trival status; // satisfiable, unstatisfiable, unknown
36
37 backprop_state(bool owner)
38 : counter(0),
39 owner(owner),
40 frozen(false)
41 {
42 }
43 };
44
45 struct SPOT_API backprop_graph final
46 {
47 backprop_graph(bool stop_asap = true)
48 : stop_asap_(stop_asap)
49 {
50 }
51
52 int new_state(bool owner)
53 {
54 return reverse_.new_state(owner);
55 }
56
57 void set_name(unsigned state, const std::string& s)
58 {
59 names_.emplace(state, s);
60 }
61
62 const backprop_state& operator[](unsigned state) const
63 {
64 return reverse_.state_data(state);
65 }
66
67 // return true if the status of src is now known
68 bool new_edge(unsigned src, unsigned dst);
69
70 // call once the successors of a state have all been declared to
71 // see if the status of that state can be determined already
72 bool freeze_state(unsigned state);
73
74 bool is_frozen(unsigned state) const
75 {
76 return (*this)[state].frozen;
77 }
78
79 trival status_of(unsigned state) const
80 {
81 return (*this)[state].status;
82 }
83
84 bool set_status(unsigned state, bool status);
85
86 std::ostream& print_dot(std::ostream& os) const;
87
88 unsigned num_edges() const
89 {
90 return reverse_.num_edges();
91 }
92
93 private:
95 bool stop_asap_;
96 std::unordered_map<unsigned, std::string> names_;
97
98 backprop_state& operator[](unsigned state)
99 {
100 return reverse_.state_data(state);
101 }
102 };
103
104
105}
Definition adjlist.hh:37
Abstract class for states.
Definition twa.hh:47
A class implementing Kleene's three-valued logic.
Definition trival.hh:33
Definition automata.hh:26
Definition backprop.hh:46
Definition backprop.hh:31

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.8