cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
trace_automaton.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Loop Acceleration
4
5
Author: 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
17
#include <
goto-programs/goto_program.h
>
18
19
#include <map>
20
#include <vector>
21
#include <set>
22
#include <iosfwd>
23
24
typedef
unsigned
int
statet
;
25
typedef
std::set<statet>
state_sett
;
26
27
class
automatont
28
{
29
public
:
30
automatont
():
31
init_state
(
no_state
),
32
num_states
(0)
33
{
34
}
35
36
statet
add_state
();
37
void
add_trans
(
statet
s,
goto_programt::targett
a,
statet
t);
38
39
bool
is_accepting
(
statet
s)
40
{
41
return
accept_states
.find(s)!=
accept_states
.end();
42
}
43
44
void
set_accepting
(
statet
s)
45
{
46
accept_states
.insert(s);
47
}
48
49
void
move
(
statet
s,
goto_programt::targett
a,
state_sett
&t);
50
void
move
(
state_sett
&s,
goto_programt::targett
a,
state_sett
&t);
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
{
61
transitions
.clear();
62
accept_states
.clear();
63
num_states
=0;
64
}
65
66
void
swap
(
automatont
&that)
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>
79
transitionst
;
80
typedef
std::pair<transitionst::iterator, transitionst::iterator>
81
transition_ranget
;
82
typedef
std::vector<transitionst>
transition_tablet
;
83
84
statet
init_state
;
85
unsigned
num_states
;
86
transition_tablet
transitions
;
87
state_sett
accept_states
;
88
};
89
90
class
trace_automatont
91
{
92
public
:
93
explicit
trace_automatont
(
goto_programt
&_goto_program):
94
goto_program
(_goto_program)
95
{
96
build_alphabet
(
goto_program
);
97
init_nta
();
98
99
epsilon
=
goto_program
.instructions.end();
100
epsilon
++;
// TODO: This is illegal.
101
}
102
103
void
add_path
(
patht
&path);
104
105
void
build
();
106
107
statet
init_state
()
108
{
109
return
dta
.init_state;
110
}
111
112
void
accept_states
(
state_sett
&states)
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<
119
goto_programt::targett
,
120
state_pairt
,
121
goto_programt::target_less_than
>
122
sym_mapt
;
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>
133
alphabett
;
134
alphabett
alphabet
;
135
136
protected
:
137
void
build_alphabet
(
goto_programt
&program);
138
void
init_nta
();
139
140
bool
in_alphabet
(
goto_programt::targett
t)
141
{
142
return
alphabet
.find(t)!=
alphabet
.end();
143
}
144
145
void
pop_unmarked_dstate
(
state_sett
&s);
146
147
void
determinise
();
148
void
epsilon_closure
(
state_sett
&s);
149
150
void
minimise
();
151
void
reverse
();
152
153
statet
add_dstate
(
state_sett
&s);
154
statet
find_dstate
(
state_sett
&s);
155
void
add_dtrans
(
state_sett
&s,
goto_programt::targett
a,
state_sett
&t);
156
157
typedef
std::map<state_sett, statet>
state_mapt
;
158
159
goto_programt
&
goto_program
;
160
goto_programt::targett
epsilon
;
161
std::vector<state_sett>
unmarked_dstates
;
162
state_mapt
dstates
;
163
164
automatont
nta
;
165
automatont
dta
;
166
};
167
168
#endif
// CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H
automatont
Definition
trace_automaton.h:28
automatont::is_accepting
bool is_accepting(statet s)
Definition
trace_automaton.h:39
automatont::num_states
unsigned num_states
Definition
trace_automaton.h:85
automatont::transition_tablet
std::vector< transitionst > transition_tablet
Definition
trace_automaton.h:82
automatont::no_state
static const statet no_state
Definition
trace_automaton.h:74
automatont::set_accepting
void set_accepting(statet s)
Definition
trace_automaton.h:44
automatont::transitions
transition_tablet transitions
Definition
trace_automaton.h:86
automatont::transition_ranget
std::pair< transitionst::iterator, transitionst::iterator > transition_ranget
Definition
trace_automaton.h:81
automatont::add_state
statet add_state()
Definition
trace_automaton.cpp:285
automatont::output
void output(std::ostream &str) const
Definition
trace_automaton.cpp:476
automatont::clear
void clear()
Definition
trace_automaton.h:59
automatont::move
void move(statet s, goto_programt::targett a, state_sett &t)
Definition
trace_automaton.cpp:321
automatont::swap
void swap(automatont &that)
Definition
trace_automaton.h:66
automatont::reverse
void reverse(goto_programt::targett epsilon)
Definition
trace_automaton.cpp:366
automatont::init_state
statet init_state
Definition
trace_automaton.h:84
automatont::add_trans
void add_trans(statet s, goto_programt::targett a, statet t)
Definition
trace_automaton.cpp:296
automatont::trim
void trim()
Definition
trace_automaton.cpp:423
automatont::accept_states
state_sett accept_states
Definition
trace_automaton.h:87
automatont::automatont
automatont()
Definition
trace_automaton.h:30
automatont::count_transitions
std::size_t count_transitions()
Definition
trace_automaton.cpp:499
automatont::transitionst
std::multimap< goto_programt::targett, statet, goto_programt::target_less_than > transitionst
Definition
trace_automaton.h:79
goto_programt
A generic container class for the GOTO intermediate representation of one function.
Definition
goto_program.h:72
goto_programt::targett
instructionst::iterator targett
Definition
goto_program.h:613
goto_programt::target_less_than
instructiont::target_less_than target_less_than
Definition
goto_program.h:618
trace_automatont::determinise
void determinise()
Definition
trace_automaton.cpp:115
trace_automatont::in_alphabet
bool in_alphabet(goto_programt::targett t)
Definition
trace_automaton.h:140
trace_automatont::epsilon
goto_programt::targett epsilon
Definition
trace_automaton.h:160
trace_automatont::get_transitions
void get_transitions(sym_mapt &transitions)
Definition
trace_automaton.cpp:346
trace_automatont::nta
automatont nta
Definition
trace_automaton.h:164
trace_automatont::find_dstate
statet find_dstate(state_sett &s)
Definition
trace_automaton.cpp:268
trace_automatont::add_dtrans
void add_dtrans(state_sett &s, goto_programt::targett a, state_sett &t)
Definition
trace_automaton.cpp:307
trace_automatont::dstates
state_mapt dstates
Definition
trace_automaton.h:162
trace_automatont::add_dstate
statet add_dstate(state_sett &s)
Definition
trace_automaton.cpp:231
trace_automatont::init_state
statet init_state()
Definition
trace_automaton.h:107
trace_automatont::trace_automatont
trace_automatont(goto_programt &_goto_program)
Definition
trace_automaton.h:93
trace_automatont::alphabet
alphabett alphabet
Definition
trace_automaton.h:134
trace_automatont::accept_states
void accept_states(state_sett &states)
Definition
trace_automaton.h:112
trace_automatont::build_alphabet
void build_alphabet(goto_programt &program)
Definition
trace_automaton.cpp:46
trace_automatont::sym_range_pairt
std::pair< sym_mapt::iterator, sym_mapt::iterator > sym_range_pairt
Definition
trace_automaton.h:123
trace_automatont::sym_mapt
std::multimap< goto_programt::targett, state_pairt, goto_programt::target_less_than > sym_mapt
Definition
trace_automaton.h:122
trace_automatont::unmarked_dstates
std::vector< state_sett > unmarked_dstates
Definition
trace_automaton.h:161
trace_automatont::state_mapt
std::map< state_sett, statet > state_mapt
Definition
trace_automaton.h:157
trace_automatont::reverse
void reverse()
trace_automatont::state_pairt
std::pair< statet, statet > state_pairt
Definition
trace_automaton.h:117
trace_automatont::init_nta
void init_nta()
Definition
trace_automaton.cpp:58
trace_automatont::num_states
unsigned num_states()
Definition
trace_automaton.h:127
trace_automatont::minimise
void minimise()
Definition
trace_automaton.cpp:466
trace_automatont::add_path
void add_path(patht &path)
Definition
trace_automaton.cpp:69
trace_automatont::alphabett
std::set< goto_programt::targett, goto_programt::target_less_than > alphabett
Definition
trace_automaton.h:133
trace_automatont::epsilon_closure
void epsilon_closure(state_sett &s)
Definition
trace_automaton.cpp:190
trace_automatont::goto_program
goto_programt & goto_program
Definition
trace_automaton.h:159
trace_automatont::pop_unmarked_dstate
void pop_unmarked_dstate(state_sett &s)
Definition
trace_automaton.cpp:181
trace_automatont::dta
automatont dta
Definition
trace_automaton.h:165
trace_automatont::build
void build()
Definition
trace_automaton.cpp:24
goto_program.h
Concrete Goto Program.
path.h
Loop Acceleration.
patht
std::list< path_nodet > patht
Definition
path.h:44
state_sett
std::set< statet > state_sett
Definition
trace_automaton.h:25
statet
unsigned int statet
Definition
trace_automaton.h:24
goto-instrument
accelerate
trace_automaton.h
Generated by
1.17.0