src/HOL/ex/set.thy
author paulson
Tue, 01 Feb 2005 18:01:57 +0100
changeset 15481 fc075ae929e4
parent 15306 51f3d31e8eea
child 15488 7c638a46dcbb
permissions -rw-r--r--
the new subst tactic, by Lucas Dixon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
     1
(*  Title:      HOL/ex/set.thy
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
     2
    ID:         $Id$
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
     3
    Author:     Tobias Nipkow and Lawrence C Paulson
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
     4
    Copyright   1991  University of Cambridge
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
     5
*)
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
     6
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
     7
header {* Set Theory examples: Cantor's Theorem, Schröder-Berstein Theorem, etc. *}
9100
9e081c812338 fixed deps;
wenzelm
parents:
diff changeset
     8
9e081c812338 fixed deps;
wenzelm
parents:
diff changeset
     9
theory set = Main:
9e081c812338 fixed deps;
wenzelm
parents:
diff changeset
    10
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    11
text{*
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    12
  These two are cited in Benzmueller and Kohlhase's system description
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    13
  of LEO, CADE-15, 1998 (pages 139-143) as theorems LEO could not
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    14
  prove.
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    15
*}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    16
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    17
lemma "(X = Y \<union> Z) =
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    18
    (Y \<subseteq> X \<and> Z \<subseteq> X \<and> (\<forall>V. Y \<subseteq> V \<and> Z \<subseteq> V \<longrightarrow> X \<subseteq> V))"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    19
  by blast
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    20
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    21
lemma "(X = Y \<inter> Z) =
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    22
    (X \<subseteq> Y \<and> X \<subseteq> Z \<and> (\<forall>V. V \<subseteq> Y \<and> V \<subseteq> Z \<longrightarrow> V \<subseteq> X))"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    23
  by blast
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    24
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    25
text {*
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    26
  Trivial example of term synthesis: apparently hard for some provers!
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    27
*}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    28
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    29
lemma "a \<noteq> b \<Longrightarrow> a \<in> ?X \<and> b \<notin> ?X"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    30
  by blast
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    31
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    32
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    33
subsection {* Examples for the @{text blast} paper *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    34
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    35
lemma "(\<Union>x \<in> C. f x \<union> g x) = \<Union>(f ` C)  \<union>  \<Union>(g ` C)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    36
  -- {* Union-image, called @{text Un_Union_image} in Main HOL *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    37
  by blast
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    38
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    39
lemma "(\<Inter>x \<in> C. f x \<inter> g x) = \<Inter>(f ` C) \<inter> \<Inter>(g ` C)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    40
  -- {* Inter-image, called @{text Int_Inter_image} in Main HOL *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    41
  by blast
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    42
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    43
lemma "\<And>S::'a set set. \<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    44
  -- {* Singleton I.  Nice demonstration of @{text blast}--and its limitations. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    45
  -- {* For some unfathomable reason, @{text UNIV_I} increases the search space greatly. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    46
  by (blast del: UNIV_I)
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    47
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    48
lemma "\<forall>x \<in> S. \<Union>S \<subseteq> x \<Longrightarrow> \<exists>z. S \<subseteq> {z}"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    49
  -- {*Singleton II.  Variant of the benchmark above. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    50
  by (blast del: UNIV_I)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    51
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    52
lemma "\<exists>!x. f (g x) = x \<Longrightarrow> \<exists>!y. g (f y) = y"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    53
  -- {* A unique fixpoint theorem --- @{text fast}/@{text best}/@{text meson} all fail. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    54
  apply (erule ex1E, rule ex1I, erule arg_cong)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    55
  apply (rule subst, assumption, erule allE, rule arg_cong, erule mp)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    56
  apply (erule arg_cong)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    57
  done
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    58
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    59
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    60
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    61
subsection {* Cantor's Theorem: There is no surjection from a set to its powerset *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    62
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    63
lemma cantor1: "\<not> (\<exists>f:: 'a \<Rightarrow> 'a set. \<forall>S. \<exists>x. f x = S)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    64
  -- {* Requires best-first search because it is undirectional. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    65
  by best
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    66
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    67
lemma "\<forall>f:: 'a \<Rightarrow> 'a set. \<forall>x. f x \<noteq> ?S f"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    68
  -- {*This form displays the diagonal term. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    69
  by best
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    70
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    71
lemma "?S \<notin> range (f :: 'a \<Rightarrow> 'a set)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    72
  -- {* This form exploits the set constructs. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    73
  by (rule notI, erule rangeE, best)
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    74
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    75
lemma "?S \<notin> range (f :: 'a \<Rightarrow> 'a set)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    76
  -- {* Or just this! *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    77
  by best
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    78
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    79
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    80
subsection {* The Schröder-Berstein Theorem *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    81
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    82
lemma disj_lemma: "- (f ` X) = g ` (-X) \<Longrightarrow> f a = g b \<Longrightarrow> a \<in> X \<Longrightarrow> b \<in> X"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    83
  by blast
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    84
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    85
lemma surj_if_then_else:
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    86
  "-(f ` X) = g ` (-X) \<Longrightarrow> surj (\<lambda>z. if z \<in> X then f z else g z)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    87
  by (simp add: surj_def) blast
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    88
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    89
lemma bij_if_then_else:
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    90
  "inj_on f X \<Longrightarrow> inj_on g (-X) \<Longrightarrow> -(f ` X) = g ` (-X) \<Longrightarrow>
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    91
    h = (\<lambda>z. if z \<in> X then f z else g z) \<Longrightarrow> inj h \<and> surj h"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    92
  apply (unfold inj_on_def)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    93
  apply (simp add: surj_if_then_else)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    94
  apply (blast dest: disj_lemma sym)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    95
  done
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
    96
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    97
lemma decomposition: "\<exists>X. X = - (g ` (- (f ` X)))"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    98
  apply (rule exI)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
    99
  apply (rule lfp_unfold)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   100
  apply (rule monoI, blast)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   101
  done
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   102
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   103
theorem Schroeder_Bernstein:
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   104
  "inj (f :: 'a \<Rightarrow> 'b) \<Longrightarrow> inj (g :: 'b \<Rightarrow> 'a)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   105
    \<Longrightarrow> \<exists>h:: 'a \<Rightarrow> 'b. inj h \<and> surj h"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   106
  apply (rule decomposition [THEN exE])
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   107
  apply (rule exI)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   108
  apply (rule bij_if_then_else)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   109
     apply (rule_tac [4] refl)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   110
    apply (rule_tac [2] inj_on_inv)
15306
51f3d31e8eea fixed proof
nipkow
parents: 14353
diff changeset
   111
    apply (erule subset_inj_on [OF _ subset_UNIV])
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   112
   txt {* Tricky variable instantiations! *}
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15306
diff changeset
   113
   apply (erule ssubst, simplesubst double_complement)
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   114
   apply (rule subsetI, erule imageE, erule ssubst, rule rangeI)
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15306
diff changeset
   115
  apply (erule ssubst, simplesubst double_complement, erule inv_image_comp [symmetric])
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   116
  done
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   117
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   118
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   119
subsection {* Set variable instantiation examples *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   120
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   121
text {*
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   122
  From W. W. Bledsoe and Guohui Feng, SET-VAR. JAR 11 (3), 1993, pages
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   123
  293-314.
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   124
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   125
  Isabelle can prove the easy examples without any special mechanisms,
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   126
  but it can't prove the hard ones.
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   127
*}
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   128
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   129
lemma "\<exists>A. (\<forall>x \<in> A. x \<le> (0::int))"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   130
  -- {* Example 1, page 295. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   131
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   132
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   133
lemma "D \<in> F \<Longrightarrow> \<exists>G. \<forall>A \<in> G. \<exists>B \<in> F. A \<subseteq> B"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   134
  -- {* Example 2. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   135
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   136
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   137
lemma "P a \<Longrightarrow> \<exists>A. (\<forall>x \<in> A. P x) \<and> (\<exists>y. y \<in> A)"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   138
  -- {* Example 3. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   139
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   140
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   141
lemma "a < b \<and> b < (c::int) \<Longrightarrow> \<exists>A. a \<notin> A \<and> b \<in> A \<and> c \<notin> A"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   142
  -- {* Example 4. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   143
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   144
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   145
lemma "P (f b) \<Longrightarrow> \<exists>s A. (\<forall>x \<in> A. P x) \<and> f s \<in> A"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   146
  -- {*Example 5, page 298. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   147
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   148
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   149
lemma "P (f b) \<Longrightarrow> \<exists>s A. (\<forall>x \<in> A. P x) \<and> f s \<in> A"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   150
  -- {* Example 6. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   151
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   152
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   153
lemma "\<exists>A. a \<notin> A"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   154
  -- {* Example 7. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   155
  by force
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   156
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   157
lemma "(\<forall>u v. u < (0::int) \<longrightarrow> u \<noteq> abs v)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   158
    \<longrightarrow> (\<exists>A::int set. (\<forall>y. abs y \<notin> A) \<and> -2 \<in> A)"
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 13107
diff changeset
   159
  -- {* Example 8 now needs a small hint. *}
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 13107
diff changeset
   160
  by (simp add: abs_if, force)
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 13107
diff changeset
   161
    -- {* not @{text blast}, which can't simplify @{text "-2 < 0"} *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   162
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   163
text {* Example 9 omitted (requires the reals). *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   164
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   165
text {* The paper has no Example 10! *}
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   166
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   167
lemma "(\<forall>A. 0 \<in> A \<and> (\<forall>x \<in> A. Suc x \<in> A) \<longrightarrow> n \<in> A) \<and>
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   168
  P 0 \<and> (\<forall>x. P x \<longrightarrow> P (Suc x)) \<longrightarrow> P n"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   169
  -- {* Example 11: needs a hint. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   170
  apply clarify
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   171
  apply (drule_tac x = "{x. P x}" in spec)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   172
  apply force
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   173
  done
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   174
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   175
lemma
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   176
  "(\<forall>A. (0, 0) \<in> A \<and> (\<forall>x y. (x, y) \<in> A \<longrightarrow> (Suc x, Suc y) \<in> A) \<longrightarrow> (n, m) \<in> A)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   177
    \<and> P n \<longrightarrow> P m"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   178
  -- {* Example 12. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   179
  by auto
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   180
13107
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   181
lemma
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   182
  "(\<forall>x. (\<exists>u. x = 2 * u) = (\<not> (\<exists>v. Suc x = 2 * v))) \<longrightarrow>
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   183
    (\<exists>A. \<forall>x. (x \<in> A) = (Suc x \<notin> A))"
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   184
  -- {* Example EO1: typo in article, and with the obvious fix it seems
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   185
      to require arithmetic reasoning. *}
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   186
  apply clarify
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   187
  apply (rule_tac x = "{x. \<exists>u. x = 2 * u}" in exI, auto)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   188
   apply (case_tac v, auto)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   189
  apply (drule_tac x = "Suc v" and P = "\<lambda>x. ?a x \<noteq> ?b x" in spec, force)
8743cc847224 tuned presentation;
wenzelm
parents: 13058
diff changeset
   190
  done
13058
ad6106d7b4bb converted theory "set" to Isar and added some SET-VAR examples
paulson
parents: 9100
diff changeset
   191
9100
9e081c812338 fixed deps;
wenzelm
parents:
diff changeset
   192
end