author | berghofe |
Fri, 16 Jul 1999 14:06:13 +0200 | |
changeset 7020 | 75ff179df7b7 |
parent 5152 | 5b63f591678b |
child 9205 | f171fa6a0989 |
permissions | -rw-r--r-- |
1459 | 1 |
(* Title: FOL/ex/if |
0 | 2 |
ID: $Id$ |
1459 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
0 | 4 |
Copyright 1991 University of Cambridge |
5 |
||
3141 | 6 |
First-Order Logic: the 'if' example |
0 | 7 |
*) |
8 |
||
9 |
open If; |
|
2601
b301958c465d
Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
paulson
parents:
2486
diff
changeset
|
10 |
open Cla; (*in case structure IntPr is open!*) |
0 | 11 |
|
5152 | 12 |
val prems = Goalw [if_def] |
0 | 13 |
"[| P ==> Q; ~P ==> R |] ==> if(P,Q,R)"; |
4091 | 14 |
by (blast_tac (claset() addIs prems) 1); |
725 | 15 |
qed "ifI"; |
0 | 16 |
|
5152 | 17 |
val major::prems = Goalw [if_def] |
0 | 18 |
"[| if(P,Q,R); [| P; Q |] ==> S; [| ~P; R |] ==> S |] ==> S"; |
19 |
by (cut_facts_tac [major] 1); |
|
4091 | 20 |
by (blast_tac (claset() addIs prems) 1); |
725 | 21 |
qed "ifE"; |
0 | 22 |
|
23 |
||
5152 | 24 |
Goal "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"; |
1459 | 25 |
by (rtac iffI 1); |
26 |
by (etac ifE 1); |
|
27 |
by (etac ifE 1); |
|
28 |
by (rtac ifI 1); |
|
29 |
by (rtac ifI 1); |
|
0 | 30 |
|
31 |
choplev 0; |
|
2469 | 32 |
AddSIs [ifI]; |
33 |
AddSEs [ifE]; |
|
3141 | 34 |
by (Blast_tac 1); |
755 | 35 |
qed "if_commute"; |
0 | 36 |
|
37 |
||
5050 | 38 |
Goal "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"; |
3141 | 39 |
by (Blast_tac 1); |
755 | 40 |
qed "nested_ifs"; |
0 | 41 |
|
42 |
choplev 0; |
|
1459 | 43 |
by (rewtac if_def); |
3141 | 44 |
by (blast_tac FOL_cs 1); |
0 | 45 |
result(); |
46 |
||
47 |
||
48 |
(*An invalid formula. High-level rules permit a simpler diagnosis*) |
|
5050 | 49 |
Goal "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"; |
3141 | 50 |
by (Blast_tac 1) handle ERROR => writeln"Failed, as expected"; |
0 | 51 |
(*Check that subgoals remain: proof failed.*) |
52 |
getgoal 1; |
|
2469 | 53 |
by (REPEAT (Step_tac 1)); |
0 | 54 |
|
55 |
choplev 0; |
|
1459 | 56 |
by (rewtac if_def); |
3141 | 57 |
by (blast_tac FOL_cs 1) handle ERROR => writeln"Failed, as expected"; |
0 | 58 |
(*Check that subgoals remain: proof failed.*) |
59 |
getgoal 1; |
|
60 |
by (REPEAT (step_tac FOL_cs 1)); |
|
61 |
||
62 |
||
63 |
||
64 |
writeln"Reached end of file."; |