CBMC
Loading...
Searching...
No Matches
trace_automaton.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Loop Acceleration
4
5Author: Matt Lewis
6
7\*******************************************************************/
8
11
12#ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H
13#define CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H
14
15#include "path.h"
16
18
19#include <map>
20#include <vector>
21#include <set>
22#include <iosfwd>
23
24typedef unsigned int statet;
25typedef std::set<statet> state_sett;
26
28{
29 public:
32 num_states(0)
33 {
34 }
35
38
40 {
41 return accept_states.find(s)!=accept_states.end();
42 }
43
45 {
46 accept_states.insert(s);
47 }
48
51
52 void reverse(goto_programt::targett epsilon);
53 void trim();
54
55 std::size_t count_transitions();
56
57 void output(std::ostream &str) const;
58
59 void clear()
60 {
63 num_states=0;
64 }
65
67 {
68 transitions.swap(that.transitions);
69 accept_states.swap(that.accept_states);
70 num_states=that.num_states;
71 init_state=that.init_state;
72 }
73
74 static const statet no_state;
75
76// protected:
77 typedef std::
78 multimap<goto_programt::targett, statet, goto_programt::target_less_than>
80 typedef std::pair<transitionst::iterator, transitionst::iterator>
82 typedef std::vector<transitionst> transition_tablet;
83
85 unsigned num_states;
88};
89
91{
92 public:
95 {
97 init_nta();
98
100 epsilon++; // TODO: This is illegal.
101 }
102
103 void add_path(patht &path);
104
105 void build();
106
108 {
109 return dta.init_state;
110 }
111
113 {
114 states.insert(dta.accept_states.begin(), dta.accept_states.end());
115 }
116
117 typedef std::pair<statet, statet> state_pairt;
118 typedef std::multimap<
123 typedef std::pair<sym_mapt::iterator, sym_mapt::iterator> sym_range_pairt;
124
125 void get_transitions(sym_mapt &transitions);
126
127 unsigned num_states()
128 {
129 return dta.num_states;
130 }
131
132 typedef std::set<goto_programt::targett, goto_programt::target_less_than>
135
136 protected:
137 void build_alphabet(goto_programt &program);
138 void init_nta();
139
141 {
142 return alphabet.find(t)!=alphabet.end();
143 }
144
146
147 void determinise();
149
150 void minimise();
151 void reverse();
152
156
157 typedef std::map<state_sett, statet> state_mapt;
158
161 std::vector<state_sett> unmarked_dstates;
163
166};
167
168#endif // CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H
virtual void clear()
Reset the abstract state.
Definition ai.h:265
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
bool is_accepting(statet s)
unsigned num_states
std::vector< transitionst > transition_tablet
static const statet no_state
void set_accepting(statet s)
transition_tablet transitions
std::pair< transitionst::iterator, transitionst::iterator > transition_ranget
void output(std::ostream &str) const
void move(statet s, goto_programt::targett a, state_sett &t)
void swap(automatont &that)
void reverse(goto_programt::targett epsilon)
statet init_state
void add_trans(statet s, goto_programt::targett a, statet t)
state_sett accept_states
std::size_t count_transitions()
std::multimap< goto_programt::targett, statet, goto_programt::target_less_than > transitionst
A generic container class for the GOTO intermediate representation of one function.
instructionst instructions
The list of instructions in the goto program.
instructionst::iterator targett
bool in_alphabet(goto_programt::targett t)
goto_programt::targett epsilon
void get_transitions(sym_mapt &transitions)
statet find_dstate(state_sett &s)
void add_dtrans(state_sett &s, goto_programt::targett a, state_sett &t)
statet add_dstate(state_sett &s)
trace_automatont(goto_programt &_goto_program)
void accept_states(state_sett &states)
void build_alphabet(goto_programt &program)
std::pair< sym_mapt::iterator, sym_mapt::iterator > sym_range_pairt
std::multimap< goto_programt::targett, state_pairt, goto_programt::target_less_than > sym_mapt
std::vector< state_sett > unmarked_dstates
std::map< state_sett, statet > state_mapt
std::pair< statet, statet > state_pairt
void add_path(patht &path)
std::set< goto_programt::targett, goto_programt::target_less_than > alphabett
void epsilon_closure(state_sett &s)
goto_programt & goto_program
void pop_unmarked_dstate(state_sett &s)
Concrete Goto Program.
Loop Acceleration.
std::list< path_nodet > patht
Definition path.h:44
A total order over targett and const_targett.
std::set< statet > state_sett
unsigned int statet