1 (**** HOL examples -- process using Doc/tout HOL-eg.txt ****)
3 Pretty.setmargin 72; (*existing macros just allow this margin*)
7 (*** Conjunction rules ***)
9 val prems = goal HOL_Rule.thy "[| P; Q |] ==> P&Q";
10 by (resolve_tac [and_def RS ssubst] 1);
11 by (resolve_tac [allI] 1);
12 by (resolve_tac [impI] 1);
13 by (eresolve_tac [mp RS mp] 1);
14 by (REPEAT (resolve_tac prems 1));
17 val prems = goal HOL_Rule.thy "[| P & Q |] ==> P";
18 prths (prems RL [and_def RS subst]);
19 prths (prems RL [and_def RS subst] RL [spec] RL [mp]);
20 by (resolve_tac it 1);
21 by (REPEAT (ares_tac [impI] 1));
22 val conjunct1 = result();
25 (*** Cantor's Theorem: There is no surjection from a set to its powerset. ***)
27 goal Set.thy "~ ?S : range(f :: 'a=>'a set)";
28 by (resolve_tac [notI] 1);
29 by (eresolve_tac [rangeE] 1);
30 by (eresolve_tac [equalityCE] 1);
31 by (dresolve_tac [CollectD] 1);
33 by (swap_res_tac [CollectI] 1);
37 by (best_tac (set_cs addSEs [equalityCE]) 1);
40 goal Set.thy "! f:: 'a=>'a set. ! x. ~ f(x) = ?S(f)";
41 by (REPEAT (resolve_tac [allI,notI] 1));
42 by (eresolve_tac [equalityCE] 1);
43 by (dresolve_tac [CollectD] 1);
45 by (swap_res_tac [CollectI] 1);
49 by (best_tac (set_cs addSEs [equalityCE]) 1);
52 goal Set.thy "~ (? f:: 'a=>'a set. ! S. ? a. f(a) = S)";
53 by (best_tac (set_cs addSEs [equalityCE]) 1);
58 > val prems = goal HOL_Rule.thy "[| P; Q |] ==> P&Q";
62 > by (resolve_tac [and_def RS ssubst] 1);
65 1. ! R. (P --> Q --> R) --> R
66 > by (resolve_tac [allI] 1);
69 1. !!R. (P --> Q --> R) --> R
70 > by (resolve_tac [impI] 1);
73 1. !!R. P --> Q --> R ==> R
74 > by (eresolve_tac [mp RS mp] 1);
79 > by (REPEAT (resolve_tac prems 1));
86 > val prems = goal HOL_Rule.thy "[| P & Q |] ==> P";
90 > prths (prems RL [and_def RS subst]);
91 ! R. (P --> Q --> R) --> R [P & Q]
94 > prths (prems RL [and_def RS subst] RL [spec] RL [mp]);
95 P --> Q --> ?Q ==> ?Q [P & Q]
97 > by (resolve_tac it 1);
101 > by (REPEAT (ares_tac [impI] 1));
109 > goal Set.thy "~ ?S : range(f :: 'a=>'a set)";
113 > by (resolve_tac [notI] 1);
116 1. ?S : range(f) ==> False
117 > by (eresolve_tac [rangeE] 1);
120 1. !!x. ?S = f(x) ==> False
121 > by (eresolve_tac [equalityCE] 1);
124 1. !!x. [| ?c3(x) : ?S; ?c3(x) : f(x) |] ==> False
125 2. !!x. [| ~?c3(x) : ?S; ~?c3(x) : f(x) |] ==> False
126 > by (dresolve_tac [CollectD] 1);
128 ~{x. ?P7(x)} : range(f)
129 1. !!x. [| ?c3(x) : f(x); ?P7(?c3(x)) |] ==> False
130 2. !!x. [| ~?c3(x) : {x. ?P7(x)}; ~?c3(x) : f(x) |] ==> False
133 ~{x. ~x : f(x)} : range(f)
134 1. !!x. [| ~x : {x. ~x : f(x)}; ~x : f(x) |] ==> False
135 > by (swap_res_tac [CollectI] 1);
137 ~{x. ~x : f(x)} : range(f)
138 1. !!x. [| ~x : f(x); ~False |] ==> ~x : f(x)
141 ~{x. ~x : f(x)} : range(f)
148 > by (best_tac (set_cs addSEs [equalityCE]) 1);
150 ~{x. ~x : f(x)} : range(f)