File: done3.pro

package info (click to toggle)
spark 2012.0.deb-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 29,260 kB
  • ctags: 3,098
  • sloc: ada: 186,243; cpp: 13,497; makefile: 685; yacc: 440; lex: 176; ansic: 119; sh: 16
file content (232 lines) | stat: -rw-r--r-- 6,981 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
% -----------------------------------------------------------------------------
%  (C) Altran Praxis Limited
% -----------------------------------------------------------------------------
% 
%  The SPARK toolset is free software; you can redistribute it and/or modify it
%  under terms of the GNU General Public License as published by the Free
%  Software Foundation; either version 3, or (at your option) any later
%  version. The SPARK toolset is distributed in the hope that it will be
%  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
%  Public License for more details. You should have received a copy of the GNU
%  General Public License distributed with the SPARK toolset; see file
%  COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
%  the license.
% 
% =============================================================================


/******** DONE: top-level checker command ********/
done :-
        \+ command_arg(to_do, _),                               /* CFR024 */
        nl,
        max_conc_no(MAX),
        done_range(1,MAX),
        fail.
done :-
        command_arg(expression, CONCS),
        (
           CONCS=c#N,
           done(N)
        ;
           CONCS=c#N-M,
           done_range(N,M)
        ),
        fail.
done :-
        all_done,
        fail.
done :-
   logfact(proved, _),
   !,
   retractall(do_not_issue_failure_message).
done :-
   retract(do_not_issue_failure_message),
   !,
   retractall(do_not_issue_failure_message).
done :-
   write('*** Cannot eliminate any conclusions at present'),
   nl,
   fail.


done(N) :-
   conc(N,X),
   infer(X),
   write('*** PROVED C'),
   print(N),
   write(': '),
   print(X),
   assertz(logfact(proved, conc(N,X))),
   retract(conc(N,X)),
   case_pointer(CP),
   (
      on_case(CP,CN,_),
      write(' FOR CASE '),
      print(CN)
   ;
      true
   ),
   !,
   nl,                                                          /* CFR024 */
   (                                                            /* CFR024 */
      \+ conc(_, _),                                            /* CFR024 */
      auto_done(on),                                            /* CFR024 */
      all_done                                                  /* CFR024 */
   ;                                                            /* CFR024 */
      true                                                      /* CFR024 */
   ),                                                           /* CFR024 */
   !.                                                           /* CFR024 */



/*** ALL_DONE - see if all conclusions at present depth done & act if so ***/
all_done :-
   \+ conc(_,_),
   case_pointer(CP),
   (
      CP=0,                                                     /* CFR024 */
      logfact(proved, vc(_)),                                   /* CFR024 */
      !                                                         /* CFR024 */
   ;                                                            /* CFR024 */
      CP=0,
      !,
      write('*** VC PROVED -- Well done!'),
      nl,
      assertz(logfact(proved, all)),
      current_vc(VCNAME, _),
      assertz(logfact(proved, vc(VCNAME))),
      update_vcs_to_prove,
      nl,                                                       /* CFR025 */
      assertz(time_for_new_vc)                                  /* CFR025 */
   ;
      CP>0,
      (
         on_case(CP, CASE, _),
         maybe_add(proved_for_case(CP, CASE)),
         fail
      ;
         case(CP, N, F),
         \+ proved_for_case(CP, N),
         !,
         maybe_add(do_not_issue_failure_message),
         case(N)
      ;
         subgoal_formula(CP, F, N, METHOD),
         write('*** PROVED '),
         print(F),
         write(' BY '),
         print(METHOD),
         nl,
         CP1 is CP-1,
         retractall(case_pointer(_)),
         asserta(case_pointer(CP1)),
         case_restore(CP),                      /* ??? */
         assertz(logfact(exitframe, CP)),
         write('[Exiting depth '),                              /* CFR024 */
         print(CP),                                             /* CFR024 */
         write(' proof frame]'),                                /* CFR024 */
         nl,                                                    /* CFR024 */
         retractall(proved_for_case(CP,_)),
         retractall(case(CP,_,_)),
         retractall(subgoal_formula(CP,_,_,_)),
         clear_up_could_facts,
         add_new_hyp(F,1),
         (
            integer(N),
            !,
            (
               auto_done(on),
               !,
               done
            ;
               done(N)
            )
         ;
            maybe_add(do_not_issue_failure_message)
         )
      )
   ), !.


done_range(N,N) :-
        done(N),
        !.
done_range(N,M) :-
        N<M,
        ( done(N) ; true ),
        !,
        N1 is N+1,
        done_range(N1,M),
        !.


update_vcs_to_prove :-
        current_vc(VCNAME, VCNUM),
        retractall(is_vc(VCNAME)),
        retractall(vc(VCNAME,_)),
        vcs_to_prove(OLDVCLIST),
        delete_number(VCNUM, OLDVCLIST, NEWVCLIST),
        retractall(vcs_to_prove(_)),
        asserta(vcs_to_prove(NEWVCLIST)),
        update_vcs_proved(VCNUM),
        !.


delete_number(N, [[N]|REST], REST) :- !.
delete_number(N, [LIST|REST], NEWLIST) :-
        append(FRONT, [N|BACK], LIST),
        (
           FRONT=[],
           !,
           NEWLIST=[BACK|REST]
        ;
           BACK=[],
           !,
           NEWLIST=[FRONT|REST]
        ;
           NEWLIST=[FRONT,BACK|REST]
        ),
        !.
delete_number(N, [LIST|REST], [LIST|NEWREST]) :-
        (\+ is_in(N, LIST)),
        delete_number(N, REST, NEWREST),
        !.


update_vcs_proved(NUM) :-
        \+ vcs_proved_this_session(_),
        !,
        asserta(vcs_proved_this_session([[NUM]])),
        !.
update_vcs_proved(NUM) :-
        vcs_proved_this_session(LIST),
        !,
        insert_in_vc_list(NUM, LIST, NEW_LIST),
        !,
        asserta(vcs_proved_this_session(NEW_LIST)),
        retract(vcs_proved_this_session(LIST)),
        !.


insert_in_vc_list(N, [ListNm1, [Np1|List] | REST], [NewList | REST]) :-
        Np1 is N+1,
        Nm1 is N-1,
        last(ListNm1, Nm1),
        append(ListNm1, [N,Np1|List], NewList),
        !.
insert_in_vc_list(N, [[Np1|List] | REST], [[N,Np1|List] | REST]) :-
        Np1 is N+1,
        !.
insert_in_vc_list(N, [ListNm1 | REST], [ListN | REST]) :-
        Nm1 is N-1,
        last(ListNm1, Nm1),
        append(ListNm1, [N], ListN),
        !.
insert_in_vc_list(N, [List | REST], [List | NEW_REST]) :-
        last(List, HI),
        HI < N,
        insert_in_vc_list(N, REST, NEW_REST), !.
insert_in_vc_list(N, LIST, [[N]|LIST]) :- !.
%###############################################################################
%END-OF-FILE