1 :- module(ta,[main/0,main/1]).
3 :- use_module(library(chr)).
4 :- use_module(library(lists)).
8 Timed automaton => Constraints
22 n > 1, 1 ------> v fincl(Xv,X1),
27 n >= 1, v ------> 1 bincl(Xv,X1),
29 \----> n bincl(Xv,X1),
37 fincl/2, % expresses that clock 1 includes clock 2 (union)
38 % in the sense that clock 2 is forward of clock 1
40 bincl/2, % expresses that clock 1 includes clock 2 (union)
41 % in the sense that clock 1 is forward of clock 2
43 leq/2, % expresses that clock 1 =< number 2
45 geq/2, % expresses that clock 1 >= number 2
47 fub_init/2, % collects the inital upper bounds
48 % from incoming arrows for clock 1 in list 2
50 fub/2, % collects the upper bounds for clock 1
51 % from incoming arrows in list 2
53 flb_init/2, % collects the inital lower bounds
54 % from incoming arrows for clock 1 in list 2
56 flb/2, % collects the lower bounds for clock 1
57 % from incoming arrows in list 2
59 bub_init/2, % collects the inital upper bounds
60 % from backward arrows for clock 1 in list 2
62 bub/2, % collects the upper bounds for clock 1
63 % from outgoing arrows in list 2
64 % values of clock 1 cannot exceed all
65 % values of the clocks in list 2
67 blb_init/2, % collects the inital lower bounds
68 % from backward arrows for clock 1 in list 2
70 blb/2, % collects the lower bounds for clock 1
71 % from outgoing arrows in list 2
72 % not all values of clock 1 can exceed any
73 % values of the clocks in list 2
75 compl/1, % indicate that all incoming arrows for clock 1
78 dist/3, % indicates that clock 1 - clock 2 =< number 3
80 fdist_init/3, % records initial distances for clock 1 and clock 2 from
81 % incoming arrows in list 3
83 fdist/3, % records distances for clock 1 and clock 2 from
84 % incoming arrows in list 3
86 setdist/3. % sets distance between clock 1 and clock 2, where
87 % clock 1 is reset to value 3
93 leq(X,N1) \ leq(X,N2) <=> N1 =< N2 | true.
95 geq(X,N1) \ geq(X,N2) <=> N2 =< N1 | true.
97 dist(X,Y,D1) \ dist(X,Y,D2) <=> D1 =< D2 | true.
99 dist(X,Y,D), leq(Y,MY) \ leq(X,MX1) <=>
100 MX2 is MY + D, MX2 < MX1 | leq(X,MX2).
102 dist(X,Y,D), geq(X,MX) \ geq(Y,MY1) <=>
103 MY2 is MX - D, MY2 > MY1 | geq(Y,MY2).
105 fincl(X,Y), leq(Y,N) \ fub_init(X,L)
106 <=> \+ memberchk_eq(N-Y,L) |
110 fincl(X,Y), geq(Y,N) \ flb_init(X,L)
111 <=> \+ memberchk_eq(N-Y,L) |
115 dist(X1,Y1,D), fincl(X2,X1), fincl(Y2,Y1) \ fdist_init(X2,Y2,L)
117 \+ memberchk_eq(D-X1,L) |
118 insert_ub(L,X1,D,NL),
119 fdist_init(X2,Y2,NL).
121 bincl(X,Y), leq(Y,N) \ bub_init(X,L)
123 \+ memberchk_eq(N-Y,L) |
127 compl(X) \ fub_init(X,L) # ID
134 compl(X) \ flb_init(X,L) # ID
141 compl(X), compl(Y) \ fdist_init(X,Y,L) # ID
148 compl(X) \ bub_init(X,L) # ID
155 fincl(X,Y), leq(Y,N) \ fub(X,L)
157 \+ memberchk_eq(N-Y,L) |
163 fincl(X,Y), geq(Y,N) \ flb(X,L)
165 \+ memberchk_eq(N-Y,L) |
171 bincl(X,Y), leq(Y,N) \ bub(X,L)
173 \+ memberchk_eq(N-Y,L) |
179 fincl(X2,X1), fincl(Y2,Y1), dist(X1,Y1,D) \ fdist(X2,Y2,L)
181 \+ memberchk_eq(D-X1,L) |
182 insert_ub(L,X1,D,NL),
187 fincl(X,Y), leq(X,N) ==> leq(Y,N).
189 fincl(X,Y), geq(X,N) ==> geq(Y,N).
191 bincl(X,Y), geq(X,N) ==> geq(Y,N).
193 bincl(X1,X2), bincl(Y1,Y2), dist(X1,Y1,D1) \ dist(X2,Y2,D2) <=> D1 < D2 | dist(X2,Y2,D1).
195 setdist(X,Y,N), leq(Y,D1) ==> D2 is D1 - N, dist(Y,X,D2).
196 setdist(X,Y,N), geq(Y,D1) ==> D2 is N - D1, dist(X,Y,D2).
200 insert_ub([],X,N,[N-X]).
201 insert_ub([M-Y|R],X,N,NL) :-
211 insert_lb([],X,N,[N-X]).
212 insert_lb([M-Y|R],X,N,NL) :-
227 giri([x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8,x9,y9,x10,y10]).
230 L = [X1,Y1,X2,Y2,X3,Y3,X4,Y4,X5,Y5,X6,Y6,X7,Y7,X8,Y8,X9,Y9,X10,Y10],
265 fdist_init(X2,Y2,[]),
266 fdist_init(Y2,X2,[]),
282 %fdist_init(X3,Y3,[]),
283 %fdist_init(Y3,X3,[]),
314 fdist_init(X6,Y6,[]),
315 fdist_init(Y6,X6,[]),
371 write(bench(ta ,N , T,0,hprolog)),write('.'),nl.
378 ( giri, fail ; true),