6
|
1 /*
|
|
2 Copyright (C) 2001, Shinji Kono, University of the Ryukyus
|
|
3
|
|
4 Everyone is permitted to copy and distribute verbatim copies
|
|
5 of this license, but changing it is not allowed. You can also
|
|
6 use this wording to make the terms for other programs.
|
|
7
|
|
8 send your comments to kono@ie.u-ryukyu.ac.jp
|
|
9 $Header$
|
|
10
|
|
11 Infinite satisfiability/validity checker
|
|
12
|
|
13 A set of non-empty-exit looping states represents infinite
|
|
14 interval in ITL. The loop can contains deterministic state
|
|
15 choice. This should correspond Rabin/Strreet Automaton
|
|
16 that is non-deterministic Buchi automaton.
|
|
17
|
|
18 The algorith works in depth first way.
|
|
19
|
|
20 */
|
|
21
|
|
22 :-dynamic found_infinite/0.
|
|
23
|
|
24 infinite:-
|
|
25 retract_all(found_infinite),
|
|
26 infinite(L),
|
|
27 write_infinite_seq(L).
|
|
28 infinite:-
|
|
29 found_infinite,!.
|
|
30 infinite:-
|
|
31 write('unsatisfiable in infinite interval.'),nl.
|
|
32
|
|
33 write_infinite_seq(L) :-
|
|
34 write('satisfiable in infinite interval: '),
|
|
35 write(L),nl.
|
|
36
|
|
37 retract_all(X) :-
|
|
38 retract(X),fail.
|
|
39 retract_all(_).
|
|
40
|
|
41 infinite([S|L]) :-
|
8
|
42 setof(S,(links(S,0),integer(S)),Children),
|
|
43 more_only_node(0,Children,L,[],[0]).
|
6
|
44 infinite([]) :-
|
|
45 found_infinite.
|
|
46
|
|
47 more_only(S) :-
|
|
48 state(S,[empty|_],true),!,fail.
|
|
49 more_only(S) :- number(S).
|
|
50
|
8
|
51 more_only_node(S,Children,L,L1,Hist) :-
|
|
52 more_only(S),!,
|
|
53 more_only_loop(S,Children,[S|L],L1,Hist,[S]).
|
|
54 more_only_node(_,Children,L,L1,Hist) :- % goto one depth deeper
|
|
55 more_only_node1(Children,L,L1,Hist).
|
|
56
|
|
57 more_only_node1([H|T],L,L1,Hist) :-
|
|
58 setof(S,(links(S,H),integer(S)),Children),
|
|
59 more_only_node(H,Children,L,L1,Hist).
|
|
60 more_only_node1([_|T],L,L1,Hist) :-
|
|
61 more_only_node(T,L,L1,Hist).
|
|
62
|
6
|
63
|
8
|
64 more_only_loop(S,_,L,L,Hist,Seq) :-
|
|
65 member(S,Seq),!.
|
|
66 % we find the one
|
|
67 more_only_loop(S,_,L,L,Hist,Seq) :-
|
|
68 member(S,Hist),!,
|
|
69 fail.
|
|
70 % end of this branch
|
|
71 more_only_loop(H,Children,L,L1,Hist,Seq) :-
|
|
72 more_only(H),!,
|
|
73 % still in the false interval
|
|
74 more_only_loop1(Children,L,L1,Hist,Seq).
|
|
75 more_only_loop(_,[S|_],L,L1,Hist,_) :-
|
|
76 % false interval end start new search in depth first way
|
|
77 setof(S,(links(S,H),integer(S)),Children),
|
|
78 % we already know S i not more_only
|
|
79 more_only_node1(Children,L,L1,Hist).
|
|
80
|
|
81 more_only_loop1([H|T],L,L1,Hist,Seq) :-
|
|
82 setof(S,(links(S,H),integer(S)),Children),
|
|
83 more_only_loop(H,Children,L,L1,Hist,Seq).
|
|
84 more_only_loop1([_|T],L,L1,Hist,Seq) :-
|
|
85 more_only_loop(T,L,L1,Hist,Seq).
|
6
|
86
|
|
87 /* end */
|