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
|
15
|
13 A set of `more' looping states represents infinite
|
6
|
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) :-
|
10
|
34 write('satisfiable in infinite interval:'),nl,
|
12
|
35 write_infinite_seq1(L).
|
|
36 write_infinite_seq1([L]) :-!, % odd case.
|
|
37 make_hist([L,L],L1),
|
|
38 write_ce(L1,0),nl.
|
|
39 write_infinite_seq1(L) :-
|
10
|
40 make_hist(L,L1),
|
|
41 write_ce(L1,0),nl.
|
6
|
42
|
|
43 retract_all(X) :-
|
|
44 retract(X),fail.
|
|
45 retract_all(_).
|
|
46
|
9
|
47 infinite(L) :-
|
11
|
48 % 1 seems like original ITL formula that is root.
|
15
|
49 setof(S,links(S,1),Children),
|
9
|
50 more_only_node(1,Children,L,[],[1]).
|
6
|
51 infinite([]) :-
|
|
52 found_infinite.
|
|
53
|
13
|
54 % more_only(S) :-
|
|
55 % state(S,[empty|_],true),!,fail.
|
|
56 % more_only(S) :- number(S).
|
|
57
|
15
|
58 more_only(true) :- !.
|
6
|
59 more_only(S) :-
|
13
|
60 number(S),
|
|
61 state(S,[more|_],_).
|
6
|
62
|
9
|
63 more_only_node(S,[S1|Children],[S|L],L1,Hist) :-
|
11
|
64 % write('checking '),write(S),nl,
|
15
|
65 more_only(S),
|
10
|
66 % starting false loop
|
9
|
67 more_only_loop(S1,Children,L,L1,[S|Hist],[S]).
|
15
|
68 more_only_node(S,Children,L,L1,Hist) :- % goto one depth deeper
|
|
69 more_only_node1(Children,L,L1,[S|Hist]).
|
8
|
70
|
15
|
71 more_only_node1([H|_],_L,_L1,Hist) :-
|
|
72 member(H,Hist),
|
|
73 !,
|
|
74 fail.
|
9
|
75 more_only_node1([H|_],L,L1,Hist) :-
|
15
|
76 setof(S,links(S,H),Children),
|
8
|
77 more_only_node(H,Children,L,L1,Hist).
|
|
78 more_only_node1([_|T],L,L1,Hist) :-
|
15
|
79 more_only_node1(T,L,L1,Hist).
|
8
|
80
|
15
|
81 more_only_loop(true,_,[true|L],L,_Hist,_Seq) :-
|
|
82 assert(found_infinite).
|
12
|
83 more_only_loop(S,_,[S|L],L,_Hist,Seq) :-
|
9
|
84 member(S,Seq),!,
|
|
85 assert(found_infinite).
|
8
|
86 % we find the one
|
9
|
87 more_only_loop(S,_,L,L,Hist,_Seq) :-
|
8
|
88 member(S,Hist),!,
|
|
89 fail.
|
|
90 % end of this branch
|
9
|
91 more_only_loop(H,_,[H|L],L1,Hist,Seq) :-
|
8
|
92 more_only(H),!,
|
|
93 % still in the false interval
|
15
|
94 setof(S,links(S,H),Children),
|
9
|
95 more_only_loop1(Children,L,L1,[H|Hist],[H|Seq]).
|
|
96 more_only_loop(H,[S|_],[H|L],L1,Hist,_) :-
|
|
97 % false interval ends, start new search in depth first way
|
15
|
98 setof(S,links(S,H),Children),
|
8
|
99 % we already know S i not more_only
|
9
|
100 more_only_node1(Children,L,L1,[H|Hist]).
|
8
|
101
|
9
|
102 more_only_loop1([H|_],L,L1,Hist,Seq) :-
|
15
|
103 setof(S,links(S,H),Children),
|
8
|
104 more_only_loop(H,Children,L,L1,Hist,Seq).
|
|
105 more_only_loop1([_|T],L,L1,Hist,Seq) :-
|
10
|
106 more_only_loop1(T,L,L1,Hist,Seq).
|
6
|
107
|
|
108 /* end */
|