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