1464
|
1 |
(* Title: FOLP/ex/foundn.ML
|
0
|
2 |
ID: $Id$
|
1459
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
0
|
4 |
Copyright 1991 University of Cambridge
|
|
5 |
|
|
6 |
Intuitionistic FOL: Examples from The Foundation of a Generic Theorem Prover
|
|
7 |
*)
|
|
8 |
|
1464
|
9 |
writeln"File FOLP/ex/foundn.ML";
|
0
|
10 |
|
|
11 |
goal IFOLP.thy "?p : A&B --> (C-->A&C)";
|
1459
|
12 |
by (rtac impI 1);
|
|
13 |
by (rtac impI 1);
|
|
14 |
by (rtac conjI 1);
|
0
|
15 |
by (assume_tac 2);
|
1459
|
16 |
by (rtac conjunct1 1);
|
0
|
17 |
by (assume_tac 1);
|
|
18 |
result();
|
|
19 |
|
|
20 |
(*A form of conj-elimination*)
|
|
21 |
val prems =
|
|
22 |
goal IFOLP.thy "p : A&B ==> (!!x y.[| x:A; y:B |] ==> f(x,y):C) ==> ?p:C";
|
|
23 |
by (resolve_tac prems 1);
|
1459
|
24 |
by (rtac conjunct1 1);
|
0
|
25 |
by (resolve_tac prems 1);
|
1459
|
26 |
by (rtac conjunct2 1);
|
0
|
27 |
by (resolve_tac prems 1);
|
|
28 |
result();
|
|
29 |
|
|
30 |
|
|
31 |
val prems =
|
|
32 |
goal IFOLP.thy "(!!A x. x:~ ~A ==> cla(x):A) ==> ?p:B | ~B";
|
|
33 |
by (resolve_tac prems 1);
|
1459
|
34 |
by (rtac notI 1);
|
0
|
35 |
by (res_inst_tac [ ("P", "~B") ] notE 1);
|
1459
|
36 |
by (rtac notI 2);
|
0
|
37 |
by (res_inst_tac [ ("P", "B | ~B") ] notE 2);
|
|
38 |
by (assume_tac 2);
|
1459
|
39 |
by (rtac disjI1 2);
|
0
|
40 |
by (assume_tac 2);
|
1459
|
41 |
by (rtac notI 1);
|
0
|
42 |
by (res_inst_tac [ ("P", "B | ~B") ] notE 1);
|
|
43 |
by (assume_tac 1);
|
1459
|
44 |
by (rtac disjI2 1);
|
0
|
45 |
by (assume_tac 1);
|
|
46 |
result();
|
|
47 |
|
|
48 |
|
|
49 |
val prems =
|
|
50 |
goal IFOLP.thy "(!!A x. x:~ ~A ==> cla(x):A) ==> ?p:B | ~B";
|
|
51 |
by (resolve_tac prems 1);
|
1459
|
52 |
by (rtac notI 1);
|
|
53 |
by (rtac notE 1);
|
|
54 |
by (rtac notI 2);
|
|
55 |
by (etac notE 2);
|
|
56 |
by (etac disjI1 2);
|
|
57 |
by (rtac notI 1);
|
|
58 |
by (etac notE 1);
|
|
59 |
by (etac disjI2 1);
|
0
|
60 |
result();
|
|
61 |
|
|
62 |
|
|
63 |
val prems =
|
|
64 |
goal IFOLP.thy "[| p:A | ~A; q:~ ~A |] ==> ?p:A";
|
1459
|
65 |
by (rtac disjE 1);
|
0
|
66 |
by (resolve_tac prems 1);
|
|
67 |
by (assume_tac 1);
|
1459
|
68 |
by (rtac FalseE 1);
|
0
|
69 |
by (res_inst_tac [ ("P", "~A") ] notE 1);
|
|
70 |
by (resolve_tac prems 1);
|
|
71 |
by (assume_tac 1);
|
|
72 |
result();
|
|
73 |
|
|
74 |
|
|
75 |
writeln"Examples with quantifiers";
|
|
76 |
|
|
77 |
val prems =
|
|
78 |
goal IFOLP.thy "p : ALL z. G(z) ==> ?p:ALL z. G(z)|H(z)";
|
1459
|
79 |
by (rtac allI 1);
|
|
80 |
by (rtac disjI1 1);
|
0
|
81 |
by (resolve_tac (prems RL [spec]) 1);
|
|
82 |
(*can use instead
|
1459
|
83 |
by (rtac spec 1); by (resolve_tac prems 1); *)
|
0
|
84 |
result();
|
|
85 |
|
|
86 |
|
|
87 |
goal IFOLP.thy "?p : ALL x. EX y. x=y";
|
1459
|
88 |
by (rtac allI 1);
|
|
89 |
by (rtac exI 1);
|
|
90 |
by (rtac refl 1);
|
0
|
91 |
result();
|
|
92 |
|
|
93 |
|
|
94 |
goal IFOLP.thy "?p : EX y. ALL x. x=y";
|
1459
|
95 |
by (rtac exI 1);
|
|
96 |
by (rtac allI 1);
|
|
97 |
by (rtac refl 1) handle ERROR => writeln"Failed, as expected";
|
0
|
98 |
getgoal 1;
|
|
99 |
|
|
100 |
|
|
101 |
(*Parallel lifting example. *)
|
|
102 |
goal IFOLP.thy "?p : EX u.ALL x.EX v.ALL y.EX w. P(u,x,v,y,w)";
|
|
103 |
by (resolve_tac [exI, allI] 1);
|
|
104 |
by (resolve_tac [exI, allI] 1);
|
|
105 |
by (resolve_tac [exI, allI] 1);
|
|
106 |
by (resolve_tac [exI, allI] 1);
|
|
107 |
by (resolve_tac [exI, allI] 1);
|
|
108 |
|
|
109 |
|
|
110 |
val prems =
|
|
111 |
goal IFOLP.thy "p : (EX z.F(z)) & B ==> ?p:(EX z. F(z) & B)";
|
1459
|
112 |
by (rtac conjE 1);
|
0
|
113 |
by (resolve_tac prems 1);
|
1459
|
114 |
by (rtac exE 1);
|
0
|
115 |
by (assume_tac 1);
|
1459
|
116 |
by (rtac exI 1);
|
|
117 |
by (rtac conjI 1);
|
0
|
118 |
by (assume_tac 1);
|
|
119 |
by (assume_tac 1);
|
|
120 |
result();
|
|
121 |
|
|
122 |
|
|
123 |
(*A bigger demonstration of quantifiers -- not in the paper*)
|
|
124 |
goal IFOLP.thy "?p : (EX y. ALL x. Q(x,y)) --> (ALL x. EX y. Q(x,y))";
|
1459
|
125 |
by (rtac impI 1);
|
|
126 |
by (rtac allI 1);
|
|
127 |
by (rtac exE 1 THEN assume_tac 1);
|
|
128 |
by (rtac exI 1);
|
|
129 |
by (rtac allE 1 THEN assume_tac 1);
|
0
|
130 |
by (assume_tac 1);
|
|
131 |
result();
|
|
132 |
|
|
133 |
|
|
134 |
writeln"Reached end of file.";
|