-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproof.pl
More file actions
346 lines (295 loc) · 8.31 KB
/
proof.pl
File metadata and controls
346 lines (295 loc) · 8.31 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/* File @(#) proof.pl 1.20 (01/08/99) for reduced version of ILF 2016
Behandlung und Konvertierung des Praedikates proof/3
enthalten sind alle proof-related Funktionalitaeten von ILF
Modul ist Bestandteil des Vordergrundes
Autoren: Allner, Dahn, Wolf, Wernhard
*/
:- module(proof).
:- export
get_proof/1,
select_proof/0,
present_proof/0,
proof2ilf/0,
put_proof/1,
show_proof/0,
undo/0,
undo_enable/0.
/*
:- import ilf_serv.
*/
:- import ilfsys.
:- import proof/3 from situation.
:- export
access_mode/1,
current_access_mode/1,
line_id/2,
line_proof/2,
line_status/2,
line_subproof/2,
line_predecessors/2,
line_successor/2,
line_contents/2,
line_control/2,
line_name/2,
line_declaration/2,
line_supers/2,
proof_id/2,
proof_lines/2,
proof_line/2,
proof_superline/2,
proof_firstline/2.
:-export %% for now this is here
install_p3_dynamic/1,
install_p3_module/1,
install_p3_compile/1,
install_p3_compile_term/1,
p3_assert/1,
p3_asserta/1,
p3_retract/1,
p3_retract_all/1,
p3_listing/1.
?- begin_module(proof).
proof_top :- ilf_debug(write("ProofManager 1.20 (01/08/99) installed\n")).
/* Lesen und schreiben von proof/3 */
undo_enable :-
get_flag(toplevel_module,Top),
call(current_predicate(proof/3),Top),
get_uih_file("tmp/undo.pro",F),
tell(F),
call(listing(proof/3),Top),
told,!.
undo_enable :- write("ILF ERROR: proof/3 not found!\n").
undo :- get_uih_file("tmp/undo.pro",F),
exists(F),
get_flag(toplevel_module,Top),
call((
dynamic(proof/3),
compile(F),
(
get_flag(proof/3,visibility,exported)
;
export(proof/3)
)
),Top),
!.
undo :- ilf_serv_error(write("ILF: ERROR: No undo information available.\n")),!,fail.
get_proof(Job) :-
sprintf(F, "tmp/ilf.%w.out", Job),
get_uih_file(F,File),
get_proof0(File),
!.
get_proof(File) :-
(atom(File) ; string(File)),
get_proof0(File),
!.
get_proof(Job) :-
sprintf(Name, "%w", Job),
(is_filename(Name) ->
FileName=Name
;
sprintf(FileName, "ilf.%w.out", Job)
),
ilf_error("File %w not found!", [FileName]),
!, fail.
/* Fuer die Fehlermeldung von get_proof/1 wird versucht zu erraten, ob
das Argument eine Jobnummer oder ein Filename war. */
is_filename(Name) :- substring(Name, ".", _), !.
is_filename(Name) :- substring(Name, "/", _), !.
get_proof0(File) :-
exists(File),
get_flag(toplevel_module,Top),
install_p3_dynamic(Top),
call((
% dynamic(proof/3),
compile_with_failure(File),
(
get_flag(proof/3,visibility,exported)
;
export(proof/3)
)
),Top).
put_proof(Job) :-
sprintf(F, "tmp/ilf.%w.out", Job),
get_uih_file(F,File),
get_flag(toplevel_module,Top),
call((
current_predicate(proof/3),
get_flag(proof/3,stability,dynamic)
),Top),
tell(File),
call(listing(proof/3),Top),
told,!.
put_proof(_) :- get_flag(toplevel_module,Mod),
ilf_warning("Could not save proof in module %w (does not exist or is not dynamic\n",[Mod]).
select_proof :- get_uih_file("/tmp/Prover.Name.out",F),
write("Enter >Name.< to select file "),writeln(F),
read(Name),
make_ilf_state(current_proof,Name),
printf("ilf_state current_proof set to %w\n",[Name]),
!.
proof2ilf :- ilf_state(current_prover,System),
ilf_state(current_proof,Nr),
term_string(Nr,NrS),
concat_string(["tmp/",System,".",NrS],InS),
get_uih_file(InS,InFile),
concat_string([InFile,".tmp"],InFileTmp),
(exists(InFileTmp) -> delete(InFileTmp);true),
concat_string(["cp ",InFile,".out ",InFileTmp],Copy),
exec(Copy,[nil,nil,nil]),!,
get_right_file("bin/toilf",ToIlf),
concat_string([ToIlf,".",System," ",InFile],Cmd),
exec(Cmd,[nil,nil,nil]),!,
ini_system(System,InS),
concat_string(["tmp/ilf.",NrS,".out"],Target),
get_uih_file(Target,TargetFile),
(exists(TargetFile) -> delete(TargetFile);true),
concat_string(["mv ",InFile,".out ",TargetFile],TargetCmd),
exec(TargetCmd,[nil,nil,nil]),
concat_string(["mv ",InFileTmp," ",InFile,".out"],EndCmd),
exec(EndCmd,[nil,nil,nil]),
change_xa_vres,
put_proof(Nr),
ilf_state(current_prover,_,ilf),
writeln("Conversion successful. Current prover set to ilf"),
write(TargetFile),writeln(" generated."),!.
change_xa_vres :- get_flag(toplevel_module,Top),
call((
retract(proof(H,status,axiom(xa_vres_fli(_)))),
assert(proof(H,status,axiom([]))),
fail
),Top).
change_xa_vres.
show_proof :-
ilf_state(current_proof,Proof),
term_string(Proof,ProofS),
concat_string(["tmp/ilf.",ProofS,".out"],Out),
get_uih_file(Out,File),
exists(File),!,
tv_proof(Proof),!.
show_proof :-
ilf_state(current_proof,Proof),
term_string(Proof,ProofS),
concat_string(["tmp/ilf.",ProofS,".out"],Out),
get_uih_file(Out,File),
!,
printf("ILF ERROR: File %w not found.\n",[File]).
show_proof :- writeln("ILF ERROR: ilf_state current_proof not set").
present_proof :-
ilf_state(current_proof,Proof),
get_right_file("bin/make_mail",Mail),
concat_string([Mail," ",Proof],Cmd),
exec(Cmd,[nil,S,nil]),
read_string(S,"\n",_,N),
writeln(N),
close(S),!.
present_proof :- writeln("ILF ERROR: No proof selected.").
/* Ende Lesen und schreiben von proof/3 */
?- proof_top.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% ACCESSORS
%%%%
%%%% Access predicates for proofs.
%%%%
%%%% Author: Wernhard
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% Depending on the concrete data structures used to represent proofs,
%%% several implementations (called "access modes") for these predicates
%%% can be installed by compiling their definitions. Therefore this file
%%% contains only the module interface and installation routines.
%%%
%%% The default implementation, working on the proof/3 predicate defined
%%% in the module p3 is contained in std_accessors.pl, which is compiled
%%% when compiling this file. std_accessors.pl [for now] also contains some
%%% documentation about the semantics of the accessor predicates.
%%%
:- (
get_flag(library_path, Path1),
ilf_state(ilfhome, IH),
concat_string([IH, "/pl"], IHpl),
set_flag(library_path, [IHpl | Path1])
;
true
),
(
get_flag(library_path, Path2),
ilf_state(userilfhome, UIH),
concat_string([UIH, "/pl"], UIHpl),
set_flag(library_path, [UIHpl | Path2])
;
true
).
:- make_local_array(current_access_mode).
:- setval(current_access_mode, none).
:- compile(std_accessors).
/*
:- compile(library(std_accessors)).
:- open_right_module("pl/std_accessors").
*/
%%%%
%%%% current_access_mode(--AccessMode)
%%%%
%%%% Returns an atom specifying the current access mode.
%%%%
current_access_mode(X) :-
getval(current_access_mode, X).
%%%%
%%%% access_mode(++AccessMode)
%%%%
%%%% Compile the files necessary to ensure that the implementation of
%%%% the proof accessor predicates is the one specified by AccessMode.
%%%%
access_mode(X) :-
current_access_mode(X),
!.
access_mode(std) :-
% compile('~ilf/pl/std_accessors').
compile(library(std_accessors)).
access_mode(db) :-
access_mode(std),
% compile('~ilf/pl/db_accessors'),
compile(library(db_accessors)),
install_p3_compile_term(
[proof(X,Y,Z) :- call(db_proof(X,Y,Z), article)]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% install_p3...
%%%%
install_p3(Module) :-
reset_p3,
call(compile_term([proof(X,Y,Z) :- call(proof(X,Y,Z), Module)]), p3).
install_p3_compile(File) :-
reset_p3,
call(compile(File), p3).
install_p3_compile_term(Term) :-
reset_p3,
call(compile_term(Term), p3).
reset_p3 :-
call(
( is_predicate(proof/3) ->
abolish(proof/3),
export(proof/3)
; true
),
p3).
install_p3_dynamic(Module) :-
reset_p3,
( Module \= p3 ->
call(
( is_predicate(proof/3) ->
abolish(proof/3)
; true
),
Module),
call(compile_term([proof(X,Y,Z) :- call(proof(X,Y,Z), Module)]), p3)
; true
),
call(dynamic(proof/3), Module),
compile_term(
[p3_assert(X) :- call(assert(X), Module),
p3_asserta(X) :- call(asserta(X), Module),
p3_retract(X) :- call(retract(X), Module),
p3_retract_all(X) :- call(retract_all(X), Module),
p3_listing(X) :- call(listing(X), Module)]).