Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
Spot
Commits
feaae8e2
Commit
feaae8e2
authored
Oct 24, 2003
by
Alexandre Duret-Lutz
Browse files
* src/tgbaalgos/emptinesscheck.cc (emptiness_check::counter_example):
Rewrite initialization.
parent
f54c78a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
feaae8e2
2003-10-24 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbaalgos/emptinesscheck.cc (emptiness_check::counter_example):
Rewrite initialization.
* src/tgbaalgos/emptinesscheck.cc (emptiness_check::print_result):
Fix memory leak.
...
...
src/tgbaalgos/emptinesscheck.cc
View file @
feaae8e2
...
...
@@ -253,63 +253,64 @@ namespace spot
void
emptiness_check
::
counter_example
()
{
std
::
deque
<
pair_state_iter
>
todo_trace
;
typedef
std
::
map
<
const
state
*
,
const
state
*
,
state_ptr_less_than
>
path_state
;
path_state
path_map
;
assert
(
!
root
.
empty
());
int
comp_size
=
root
.
size
();
typedef
std
::
vector
<
connected_component
>
vec_compo
;
vec_compo
vec_component
(
comp_size
);
std
::
vector
<
state_sequence
>
vec_sequence
(
comp_size
);
state_sequence
seq
;
state_sequence
tmp_lst
;
state_sequence
best_lst
;
bdd
tmp_acc
=
bddfalse
;
std
::
stack
<
pair_state_iter
>
todo_accept
;
for
(
int
j
=
comp_size
-
1
;
j
>=
0
;
j
--
)
// Transform the stack of connected component into an array.
connected_component
*
scc
=
new
connected_component
[
comp_size
];
for
(
int
j
=
comp_size
-
1
;
0
<=
j
;
--
j
)
{
vec_component
[
j
]
=
root
.
top
();
scc
[
j
]
=
root
.
top
();
root
.
pop
();
}
assert
(
root
.
empty
());
int
q_index
;
int
tmp_int
=
0
;
// Fill the SCC in the stack root.
for
(
hash_type
::
iterator
iter_map
=
h
.
begin
();
iter_map
!=
h
.
end
();
++
iter_map
)
// Build the set of states for all SCCs.
for
(
hash_type
::
iterator
i
=
h
.
begin
();
i
!=
h
.
end
();
++
i
)
{
q_
index
=
i
ter_map
->
second
;
tmp_int
=
0
;
if
(
q_
index
>
0
)
{
while
((
tmp_int
<
comp_size
)
&&
(
vec_component
[
tmp_int
].
index
<=
q_index
))
tmp_int
=
tmp_int
+
1
;
if
(
tmp_int
<
comp_size
)
vec_component
[
tmp_int
-
1
].
state_set
.
insert
(
iter_map
->
first
);
else
vec_component
[
comp_size
-
1
].
state_set
.
insert
(
iter_map
->
first
)
;
}
int
index
=
i
->
second
;
// Skip states from dead SCCs.
if
(
index
<
0
)
continue
;
assert
(
index
!=
0
);
// Find the SCC this state belongs to.
int
j
;
for
(
j
=
1
;
j
<
comp_size
;
++
j
)
if
(
index
<
scc
[
j
].
index
)
break
;
scc
[
j
-
1
].
state_set
.
insert
(
i
->
first
);
}
// seqs[i] is a sequence between SCC i and SCC i+1.
state_sequence
*
seqs
=
new
state_sequence
[
comp_size
-
1
];
// FIFO for the breadth-first search.
std
::
deque
<
pair_state_iter
>
todo
;
// Record the father of each state, while performing the BFS.
typedef
std
::
map
<
const
state
*
,
const
state
*
,
state_ptr_less_than
>
father_map
;
father_map
father
;
state_sequence
seq
;
state_sequence
tmp_lst
;
state_sequence
best_lst
;
bdd
tmp_acc
=
bddfalse
;
state
*
start_state
=
aut_
->
get_init_state
();
if
(
comp_size
!=
1
)
{
tgba_succ_iterator
*
i
=
aut_
->
succ_iter
(
start_state
);
todo
_trace
.
push_back
(
pair_state_iter
(
start_state
,
i
));
todo
.
push_back
(
pair_state_iter
(
start_state
,
i
));
for
(
int
k
=
0
;
k
<
comp_size
-
1
;
++
k
)
{
// We build a path trought all SCC in the stack: a
// possible prefix for a counter example.
while
(
!
todo
_trace
.
empty
())
while
(
!
todo
.
empty
())
{
pair_state_iter
started_from
=
todo
_trace
.
front
();
todo
_trace
.
pop_front
();
pair_state_iter
started_from
=
todo
.
front
();
todo
.
pop_front
();
for
(
started_from
.
second
->
first
();
!
started_from
.
second
->
done
();
...
...
@@ -317,53 +318,53 @@ namespace spot
{
const
state
*
curr_state
=
started_from
.
second
->
current_state
();
if
(
vec_component
[
k
+
1
].
has_state
(
curr_state
))
if
(
scc
[
k
+
1
].
has_state
(
curr_state
))
{
const
state
*
curr_father
=
started_from
.
first
;
seq
.
push_front
(
curr_state
);
seq
.
push_front
(
curr_father
);
hash_type
::
iterator
i_2
=
h
.
find
(
curr_father
);
assert
(
i_2
!=
h
.
end
());
while
(
vec_component
[
k
].
index
<
i_2
->
second
)
while
(
scc
[
k
].
index
<
i_2
->
second
)
{
assert
(
i_2
->
second
!=
1
);
assert
(
path_map
.
find
(
curr_father
)
!=
path_map
.
end
());
const
state
*
f
=
path_map
[
curr_father
];
assert
(
father
.
find
(
curr_father
)
!=
father
.
end
());
const
state
*
f
=
father
[
curr_father
];
seq
.
push_front
(
f
);
curr_father
=
f
;
i_2
=
h
.
find
(
curr_father
);
assert
(
i_2
!=
h
.
end
());
}
vec_sequence
[
k
]
=
seq
;
seqs
[
k
]
=
seq
;
seq
.
clear
();
todo
_trace
.
clear
();
todo
.
clear
();
break
;
}
else
{
if
(
vec_component
[
k
].
has_state
(
curr_state
))
if
(
scc
[
k
].
has_state
(
curr_state
))
{
p
ath
_state
::
iterator
i_path
=
p
ath
_map
.
find
(
curr_state
);
f
ath
er_map
::
iterator
i_path
=
f
ath
er
.
find
(
curr_state
);
hash_type
::
iterator
i_seen
=
h
.
find
(
curr_state
);
if
(
i_seen
!=
h
.
end
()
&&
i_seen
->
second
>
0
&&
i_path
==
p
ath
_map
.
end
())
&&
i_path
==
f
ath
er
.
end
())
{
todo
_trace
.
todo
.
push_back
(
pair_state_iter
(
curr_state
,
aut_
->
succ_iter
(
curr_state
)));
p
ath
_map
[
curr_state
]
=
started_from
.
first
;
f
ath
er
[
curr_state
]
=
started_from
.
first
;
}
}
}
}
}
todo_trace
.
push_back
(
pair_state_iter
(
vec_sequence
[
k
].
back
(),
aut_
->
succ_iter
(
vec_sequence
[
k
].
back
())));
assert
(
!
seqs
[
k
].
empty
());
todo
.
push_back
(
pair_state_iter
(
seqs
[
k
].
back
(),
aut_
->
succ_iter
(
seqs
[
k
].
back
())));
}
}
else
...
...
@@ -371,12 +372,15 @@ namespace spot
suffix
.
push_front
(
start_state
);
}
for
(
int
n_
=
0
;
n_
<
comp_size
-
1
;
++
n_
)
for
(
state_sequence
::
iterator
it
=
vec_sequence
[
n_
].
begin
();
it
!=
vec_sequence
[
n_
].
end
();
++
it
)
for
(
state_sequence
::
iterator
it
=
seqs
[
n_
].
begin
();
it
!=
seqs
[
n_
].
end
();
++
it
)
suffix
.
push_back
(
*
it
);
suffix
.
unique
();
accepting_path
(
vec_component
[
comp_size
-
1
],
suffix
.
back
(),
vec_component
[
comp_size
-
1
].
condition
);
accepting_path
(
scc
[
comp_size
-
1
],
suffix
.
back
(),
scc
[
comp_size
-
1
].
condition
);
delete
[]
scc
;
delete
[]
seqs
;
}
void
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment