src/ZF/upair.thy
author boehmes
Tue, 07 Dec 2010 14:54:31 +0100
changeset 41061 492f8fd35fc0
parent 32960 69916a850301
child 45602 2a858377c3d2
permissions -rw-r--r--
centralized handling of built-in types and constants for bitvectors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 124
diff changeset
     1
(*  Title:      ZF/upair.thy
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 124
diff changeset
     2
    Author:     Lawrence C Paulson and Martin D Coen, CU Computer Laboratory
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 124
diff changeset
     3
    Copyright   1993  University of Cambridge
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
     4
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
     5
Observe the order of dependence:
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
     6
    Upair is defined in terms of Replace
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
     7
    Un is defined in terms of Upair and Union (similarly for Int)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
     8
    cons is defined in terms of Upair and Un
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
     9
    Ordered pairs and descriptions are defined using cons ("set notation")
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 124
diff changeset
    10
*)
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 124
diff changeset
    11
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
    12
header{*Unordered Pairs*}
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
    13
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15091
diff changeset
    14
theory upair imports ZF
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15091
diff changeset
    15
uses "Tools/typechk.ML" begin
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 3924
diff changeset
    16
9907
473a6604da94 tuned ML code (the_context, bind_thms(s));
wenzelm
parents: 9570
diff changeset
    17
setup TypeCheck.setup
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 3924
diff changeset
    18
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    19
lemma atomize_ball [symmetric, rulify]:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    20
     "(!!x. x:A ==> P(x)) == Trueprop (ALL x:A. P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    21
by (simp add: Ball_def atomize_all atomize_imp)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    22
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    23
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
    24
subsection{*Unordered Pairs: constant @{term Upair}*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    25
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    26
lemma Upair_iff [simp]: "c : Upair(a,b) <-> (c=a | c=b)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    27
by (unfold Upair_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    28
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    29
lemma UpairI1: "a : Upair(a,b)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    30
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    31
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    32
lemma UpairI2: "b : Upair(a,b)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    33
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    34
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    35
lemma UpairE: "[| a : Upair(b,c);  a=b ==> P;  a=c ==> P |] ==> P"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    36
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    37
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
    38
subsection{*Rules for Binary Union, Defined via @{term Upair}*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    39
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    40
lemma Un_iff [simp]: "c : A Un B <-> (c:A | c:B)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    41
apply (simp add: Un_def)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    42
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    43
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    44
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    45
lemma UnI1: "c : A ==> c : A Un B"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    46
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    47
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    48
lemma UnI2: "c : B ==> c : A Un B"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    49
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    50
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13259
diff changeset
    51
declare UnI1 [elim?]  UnI2 [elim?]
c9cfe1638bf2 improved presentation markup
paulson
parents: 13259
diff changeset
    52
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    53
lemma UnE [elim!]: "[| c : A Un B;  c:A ==> P;  c:B ==> P |] ==> P"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    54
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    55
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    56
(*Stronger version of the rule above*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    57
lemma UnE': "[| c : A Un B;  c:A ==> P;  [| c:B;  c~:A |] ==> P |] ==> P"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    58
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    59
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    60
(*Classical introduction rule: no commitment to A vs B*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    61
lemma UnCI [intro!]: "(c ~: B ==> c : A) ==> c : A Un B"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
    62
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    63
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
    64
subsection{*Rules for Binary Intersection, Defined via @{term Upair}*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    65
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    66
lemma Int_iff [simp]: "c : A Int B <-> (c:A & c:B)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    67
apply (unfold Int_def)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    68
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    69
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    70
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    71
lemma IntI [intro!]: "[| c : A;  c : B |] ==> c : A Int B"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    72
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    73
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    74
lemma IntD1: "c : A Int B ==> c : A"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    75
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    76
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    77
lemma IntD2: "c : A Int B ==> c : B"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    78
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    79
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    80
lemma IntE [elim!]: "[| c : A Int B;  [| c:A; c:B |] ==> P |] ==> P"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    81
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    82
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    83
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
    84
subsection{*Rules for Set Difference, Defined via @{term Upair}*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    85
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    86
lemma Diff_iff [simp]: "c : A-B <-> (c:A & c~:B)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    87
by (unfold Diff_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    88
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    89
lemma DiffI [intro!]: "[| c : A;  c ~: B |] ==> c : A - B"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    90
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    91
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    92
lemma DiffD1: "c : A - B ==> c : A"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    93
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    94
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    95
lemma DiffD2: "c : A - B ==> c ~: B"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    96
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    97
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    98
lemma DiffE [elim!]: "[| c : A - B;  [| c:A; c~:B |] ==> P |] ==> P"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
    99
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   100
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   101
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   102
subsection{*Rules for @{term cons}*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   103
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   104
lemma cons_iff [simp]: "a : cons(b,A) <-> (a=b | a:A)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   105
apply (unfold cons_def)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   106
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   107
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   108
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   109
(*risky as a typechecking rule, but solves otherwise unconstrained goals of
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   110
the form x : ?A*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   111
lemma consI1 [simp,TC]: "a : cons(a,B)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   112
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   113
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   114
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   115
lemma consI2: "a : B ==> a : cons(b,B)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   116
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   117
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   118
lemma consE [elim!]: "[| a : cons(b,A);  a=b ==> P;  a:A ==> P |] ==> P"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   119
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   120
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   121
(*Stronger version of the rule above*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   122
lemma consE':
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   123
    "[| a : cons(b,A);  a=b ==> P;  [| a:A;  a~=b |] ==> P |] ==> P"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   124
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   125
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   126
(*Classical introduction rule*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   127
lemma consCI [intro!]: "(a~:B ==> a=b) ==> a: cons(b,B)"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   128
by (simp, blast)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   129
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   130
lemma cons_not_0 [simp]: "cons(a,B) ~= 0"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   131
by (blast elim: equalityE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   132
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   133
lemmas cons_neq_0 = cons_not_0 [THEN notE, standard]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   134
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   135
declare cons_not_0 [THEN not_sym, simp]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   136
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   137
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   138
subsection{*Singletons*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   139
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   140
lemma singleton_iff: "a : {b} <-> a=b"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   141
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   142
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   143
lemma singletonI [intro!]: "a : {a}"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   144
by (rule consI1)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   145
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   146
lemmas singletonE = singleton_iff [THEN iffD1, elim_format, standard, elim!]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   147
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   148
14883
ca000a495448 Groups, Rings and supporting lemmas
paulson
parents: 14153
diff changeset
   149
subsection{*Descriptions*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   150
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   151
lemma the_equality [intro]:
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   152
    "[| P(a);  !!x. P(x) ==> x=a |] ==> (THE x. P(x)) = a"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   153
apply (unfold the_def) 
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   154
apply (fast dest: subst)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   155
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   156
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   157
(* Only use this if you already know EX!x. P(x) *)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   158
lemma the_equality2: "[| EX! x. P(x);  P(a) |] ==> (THE x. P(x)) = a"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   159
by blast
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   160
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   161
lemma theI: "EX! x. P(x) ==> P(THE x. P(x))"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   162
apply (erule ex1E)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   163
apply (subst the_equality)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   164
apply (blast+)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   165
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   166
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   167
(*the_cong is no longer necessary: if (ALL y.P(y)<->Q(y)) then 
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   168
  (THE x.P(x))  rewrites to  (THE x. Q(x))  *)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   169
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   170
(*If it's "undefined", it's zero!*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   171
lemma the_0: "~ (EX! x. P(x)) ==> (THE x. P(x))=0"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   172
apply (unfold the_def)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   173
apply (blast elim!: ReplaceE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   174
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   175
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   176
(*Easier to apply than theI: conclusion has only one occurrence of P*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   177
lemma theI2:
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   178
    assumes p1: "~ Q(0) ==> EX! x. P(x)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   179
        and p2: "!!x. P(x) ==> Q(x)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   180
    shows "Q(THE x. P(x))"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   181
apply (rule classical)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   182
apply (rule p2)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   183
apply (rule theI)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   184
apply (rule classical)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   185
apply (rule p1)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   186
apply (erule the_0 [THEN subst], assumption)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   187
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   188
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   189
lemma the_eq_trivial [simp]: "(THE x. x = a) = a"
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   190
by blast
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   191
13544
895994073bdf various new lemmas for Constructible
paulson
parents: 13357
diff changeset
   192
lemma the_eq_trivial2 [simp]: "(THE x. a = x) = a"
895994073bdf various new lemmas for Constructible
paulson
parents: 13357
diff changeset
   193
by blast
895994073bdf various new lemmas for Constructible
paulson
parents: 13357
diff changeset
   194
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   195
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   196
subsection{*Conditional Terms: @{text "if-then-else"}*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   197
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   198
lemma if_true [simp]: "(if True then a else b) = a"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   199
by (unfold if_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   200
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   201
lemma if_false [simp]: "(if False then a else b) = b"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   202
by (unfold if_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   203
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   204
(*Never use with case splitting, or if P is known to be true or false*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   205
lemma if_cong:
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   206
    "[| P<->Q;  Q ==> a=c;  ~Q ==> b=d |]  
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   207
     ==> (if P then a else b) = (if Q then c else d)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   208
by (simp add: if_def cong add: conj_cong)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   209
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   210
(*Prevents simplification of x and y: faster and allows the execution
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   211
  of functional programs. NOW THE DEFAULT.*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   212
lemma if_weak_cong: "P<->Q ==> (if P then x else y) = (if Q then x else y)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   213
by simp
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   214
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   215
(*Not needed for rewriting, since P would rewrite to True anyway*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   216
lemma if_P: "P ==> (if P then a else b) = a"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   217
by (unfold if_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   218
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   219
(*Not needed for rewriting, since P would rewrite to False anyway*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   220
lemma if_not_P: "~P ==> (if P then a else b) = b"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   221
by (unfold if_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   222
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   223
lemma split_if [split]:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   224
     "P(if Q then x else y) <-> ((Q --> P(x)) & (~Q --> P(y)))"
14153
76a6ba67bd15 new case_tac
paulson
parents: 13780
diff changeset
   225
by (case_tac Q, simp_all)
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   226
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   227
(** Rewrite rules for boolean case-splitting: faster than 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 24893
diff changeset
   228
        addsplits[split_if]
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   229
**)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   230
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   231
lemmas split_if_eq1 = split_if [of "%x. x = b", standard]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   232
lemmas split_if_eq2 = split_if [of "%x. a = x", standard]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   233
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   234
lemmas split_if_mem1 = split_if [of "%x. x : b", standard]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   235
lemmas split_if_mem2 = split_if [of "%x. a : x", standard]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   236
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   237
lemmas split_ifs = split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   238
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   239
(*Logically equivalent to split_if_mem2*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   240
lemma if_iff: "a: (if P then x else y) <-> P & a:x | ~P & a:y"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   241
by simp
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   242
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   243
lemma if_type [TC]:
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   244
    "[| P ==> a: A;  ~P ==> b: A |] ==> (if P then a else b): A"
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   245
by simp
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   246
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   247
(** Splitting IFs in the assumptions **)
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   248
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   249
lemma split_if_asm: "P(if Q then x else y) <-> (~((Q & ~P(x)) | (~Q & ~P(y))))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   250
by simp
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   251
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   252
lemmas if_splits = split_if split_if_asm
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   253
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   254
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   255
subsection{*Consequences of Foundation*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   256
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   257
(*was called mem_anti_sym*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   258
lemma mem_asym: "[| a:b;  ~P ==> b:a |] ==> P"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   259
apply (rule classical)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   260
apply (rule_tac A1 = "{a,b}" in foundation [THEN disjE])
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   261
apply (blast elim!: equalityE)+
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   262
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   263
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   264
(*was called mem_anti_refl*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   265
lemma mem_irrefl: "a:a ==> P"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   266
by (blast intro: mem_asym)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   267
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   268
(*mem_irrefl should NOT be added to default databases:
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   269
      it would be tried on most goals, making proofs slower!*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   270
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   271
lemma mem_not_refl: "a ~: a"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   272
apply (rule notI)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   273
apply (erule mem_irrefl)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   274
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   275
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   276
(*Good for proving inequalities by rewriting*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   277
lemma mem_imp_not_eq: "a:A ==> a ~= A"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   278
by (blast elim!: mem_irrefl)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   279
13357
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   280
lemma eq_imp_not_mem: "a=A ==> a ~: A"
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   281
by (blast intro: elim: mem_irrefl)
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   282
6f54e992777e Removal of mono.thy
paulson
parents: 13356
diff changeset
   283
subsection{*Rules for Successor*}
13259
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   284
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   285
lemma succ_iff: "i : succ(j) <-> i=j | i:j"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   286
by (unfold succ_def, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   287
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   288
lemma succI1 [simp]: "i : succ(i)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   289
by (simp add: succ_iff)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   290
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   291
lemma succI2: "i : j ==> i : succ(j)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   292
by (simp add: succ_iff)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   293
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   294
lemma succE [elim!]: 
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   295
    "[| i : succ(j);  i=j ==> P;  i:j ==> P |] ==> P"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   296
apply (simp add: succ_iff, blast) 
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   297
done
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   298
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   299
(*Classical introduction rule*)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   300
lemma succCI [intro!]: "(i~:j ==> i=j) ==> i: succ(j)"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   301
by (simp add: succ_iff, blast)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   302
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   303
lemma succ_not_0 [simp]: "succ(n) ~= 0"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   304
by (blast elim!: equalityE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   305
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   306
lemmas succ_neq_0 = succ_not_0 [THEN notE, standard, elim!]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   307
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   308
declare succ_not_0 [THEN not_sym, simp]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   309
declare sym [THEN succ_neq_0, elim!]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   310
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   311
(* succ(c) <= B ==> c : B *)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   312
lemmas succ_subsetD = succI1 [THEN [2] subsetD]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   313
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   314
(* succ(b) ~= b *)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   315
lemmas succ_neq_self = succI1 [THEN mem_imp_not_eq, THEN not_sym, standard]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   316
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   317
lemma succ_inject_iff [simp]: "succ(m) = succ(n) <-> m=n"
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   318
by (blast elim: mem_asym elim!: equalityE)
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   319
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   320
lemmas succ_inject = succ_inject_iff [THEN iffD1, standard, dest!]
01fa0c8dbc92 conversion of many files to Isar format
paulson
parents: 11770
diff changeset
   321
13780
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   322
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   323
subsection{*Miniscoping of the Bounded Universal Quantifier*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   324
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   325
lemma ball_simps1:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   326
     "(ALL x:A. P(x) & Q)   <-> (ALL x:A. P(x)) & (A=0 | Q)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   327
     "(ALL x:A. P(x) | Q)   <-> ((ALL x:A. P(x)) | Q)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   328
     "(ALL x:A. P(x) --> Q) <-> ((EX x:A. P(x)) --> Q)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   329
     "(~(ALL x:A. P(x))) <-> (EX x:A. ~P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   330
     "(ALL x:0.P(x)) <-> True"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   331
     "(ALL x:succ(i).P(x)) <-> P(i) & (ALL x:i. P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   332
     "(ALL x:cons(a,B).P(x)) <-> P(a) & (ALL x:B. P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   333
     "(ALL x:RepFun(A,f). P(x)) <-> (ALL y:A. P(f(y)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   334
     "(ALL x:Union(A).P(x)) <-> (ALL y:A. ALL x:y. P(x))" 
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   335
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   336
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   337
lemma ball_simps2:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   338
     "(ALL x:A. P & Q(x))   <-> (A=0 | P) & (ALL x:A. Q(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   339
     "(ALL x:A. P | Q(x))   <-> (P | (ALL x:A. Q(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   340
     "(ALL x:A. P --> Q(x)) <-> (P --> (ALL x:A. Q(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   341
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   342
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   343
lemma ball_simps3:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   344
     "(ALL x:Collect(A,Q).P(x)) <-> (ALL x:A. Q(x) --> P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   345
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   346
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   347
lemmas ball_simps [simp] = ball_simps1 ball_simps2 ball_simps3
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   348
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   349
lemma ball_conj_distrib:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   350
    "(ALL x:A. P(x) & Q(x)) <-> ((ALL x:A. P(x)) & (ALL x:A. Q(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   351
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   352
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   353
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   354
subsection{*Miniscoping of the Bounded Existential Quantifier*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   355
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   356
lemma bex_simps1:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   357
     "(EX x:A. P(x) & Q) <-> ((EX x:A. P(x)) & Q)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   358
     "(EX x:A. P(x) | Q) <-> (EX x:A. P(x)) | (A~=0 & Q)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   359
     "(EX x:A. P(x) --> Q) <-> ((ALL x:A. P(x)) --> (A~=0 & Q))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   360
     "(EX x:0.P(x)) <-> False"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   361
     "(EX x:succ(i).P(x)) <-> P(i) | (EX x:i. P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   362
     "(EX x:cons(a,B).P(x)) <-> P(a) | (EX x:B. P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   363
     "(EX x:RepFun(A,f). P(x)) <-> (EX y:A. P(f(y)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   364
     "(EX x:Union(A).P(x)) <-> (EX y:A. EX x:y.  P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   365
     "(~(EX x:A. P(x))) <-> (ALL x:A. ~P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   366
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   367
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   368
lemma bex_simps2:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   369
     "(EX x:A. P & Q(x)) <-> (P & (EX x:A. Q(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   370
     "(EX x:A. P | Q(x)) <-> (A~=0 & P) | (EX x:A. Q(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   371
     "(EX x:A. P --> Q(x)) <-> ((A=0 | P) --> (EX x:A. Q(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   372
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   373
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   374
lemma bex_simps3:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   375
     "(EX x:Collect(A,Q).P(x)) <-> (EX x:A. Q(x) & P(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   376
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   377
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   378
lemmas bex_simps [simp] = bex_simps1 bex_simps2 bex_simps3
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   379
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   380
lemma bex_disj_distrib:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   381
    "(EX x:A. P(x) | Q(x)) <-> ((EX x:A. P(x)) | (EX x:A. Q(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   382
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   383
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   384
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   385
(** One-point rule for bounded quantifiers: see HOL/Set.ML **)
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   386
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   387
lemma bex_triv_one_point1 [simp]: "(EX x:A. x=a) <-> (a:A)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   388
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   389
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   390
lemma bex_triv_one_point2 [simp]: "(EX x:A. a=x) <-> (a:A)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   391
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   392
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   393
lemma bex_one_point1 [simp]: "(EX x:A. x=a & P(x)) <-> (a:A & P(a))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   394
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   395
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   396
lemma bex_one_point2 [simp]: "(EX x:A. a=x & P(x)) <-> (a:A & P(a))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   397
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   398
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   399
lemma ball_one_point1 [simp]: "(ALL x:A. x=a --> P(x)) <-> (a:A --> P(a))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   400
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   401
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   402
lemma ball_one_point2 [simp]: "(ALL x:A. a=x --> P(x)) <-> (a:A --> P(a))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   403
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   404
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   405
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   406
subsection{*Miniscoping of the Replacement Operator*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   407
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   408
text{*These cover both @{term Replace} and @{term Collect}*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   409
lemma Rep_simps [simp]:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   410
     "{x. y:0, R(x,y)} = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   411
     "{x:0. P(x)} = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   412
     "{x:A. Q} = (if Q then A else 0)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   413
     "RepFun(0,f) = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   414
     "RepFun(succ(i),f) = cons(f(i), RepFun(i,f))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   415
     "RepFun(cons(a,B),f) = cons(f(a), RepFun(B,f))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   416
by (simp_all, blast+)
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   417
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   418
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   419
subsection{*Miniscoping of Unions*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   420
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   421
lemma UN_simps1:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   422
     "(UN x:C. cons(a, B(x))) = (if C=0 then 0 else cons(a, UN x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   423
     "(UN x:C. A(x) Un B')   = (if C=0 then 0 else (UN x:C. A(x)) Un B')"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   424
     "(UN x:C. A' Un B(x))   = (if C=0 then 0 else A' Un (UN x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   425
     "(UN x:C. A(x) Int B')  = ((UN x:C. A(x)) Int B')"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   426
     "(UN x:C. A' Int B(x))  = (A' Int (UN x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   427
     "(UN x:C. A(x) - B')    = ((UN x:C. A(x)) - B')"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   428
     "(UN x:C. A' - B(x))    = (if C=0 then 0 else A' - (INT x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   429
apply (simp_all add: Inter_def) 
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   430
apply (blast intro!: equalityI )+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   431
done
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   432
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   433
lemma UN_simps2:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   434
      "(UN x: Union(A). B(x)) = (UN y:A. UN x:y. B(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   435
      "(UN z: (UN x:A. B(x)). C(z)) = (UN  x:A. UN z: B(x). C(z))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   436
      "(UN x: RepFun(A,f). B(x))     = (UN a:A. B(f(a)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   437
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   438
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   439
lemmas UN_simps [simp] = UN_simps1 UN_simps2
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   440
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   441
text{*Opposite of miniscoping: pull the operator out*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   442
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   443
lemma UN_extend_simps1:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   444
     "(UN x:C. A(x)) Un B   = (if C=0 then B else (UN x:C. A(x) Un B))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   445
     "((UN x:C. A(x)) Int B) = (UN x:C. A(x) Int B)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   446
     "((UN x:C. A(x)) - B) = (UN x:C. A(x) - B)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   447
apply simp_all 
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   448
apply blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   449
done
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   450
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   451
lemma UN_extend_simps2:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   452
     "cons(a, UN x:C. B(x)) = (if C=0 then {a} else (UN x:C. cons(a, B(x))))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   453
     "A Un (UN x:C. B(x))   = (if C=0 then A else (UN x:C. A Un B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   454
     "(A Int (UN x:C. B(x))) = (UN x:C. A Int B(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   455
     "A - (INT x:C. B(x))    = (if C=0 then A else (UN x:C. A - B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   456
     "(UN y:A. UN x:y. B(x)) = (UN x: Union(A). B(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   457
     "(UN a:A. B(f(a))) = (UN x: RepFun(A,f). B(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   458
apply (simp_all add: Inter_def) 
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   459
apply (blast intro!: equalityI)+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   460
done
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   461
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   462
lemma UN_UN_extend:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   463
     "(UN  x:A. UN z: B(x). C(z)) = (UN z: (UN x:A. B(x)). C(z))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   464
by blast
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   465
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   466
lemmas UN_extend_simps = UN_extend_simps1 UN_extend_simps2 UN_UN_extend
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   467
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   468
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   469
subsection{*Miniscoping of Intersections*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   470
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   471
lemma INT_simps1:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   472
     "(INT x:C. A(x) Int B) = (INT x:C. A(x)) Int B"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   473
     "(INT x:C. A(x) - B)   = (INT x:C. A(x)) - B"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   474
     "(INT x:C. A(x) Un B)  = (if C=0 then 0 else (INT x:C. A(x)) Un B)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   475
by (simp_all add: Inter_def, blast+)
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   476
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   477
lemma INT_simps2:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   478
     "(INT x:C. A Int B(x)) = A Int (INT x:C. B(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   479
     "(INT x:C. A - B(x))   = (if C=0 then 0 else A - (UN x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   480
     "(INT x:C. cons(a, B(x))) = (if C=0 then 0 else cons(a, INT x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   481
     "(INT x:C. A Un B(x))  = (if C=0 then 0 else A Un (INT x:C. B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   482
apply (simp_all add: Inter_def) 
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   483
apply (blast intro!: equalityI)+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   484
done
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   485
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   486
lemmas INT_simps [simp] = INT_simps1 INT_simps2
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   487
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   488
text{*Opposite of miniscoping: pull the operator out*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   489
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   490
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   491
lemma INT_extend_simps1:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   492
     "(INT x:C. A(x)) Int B = (INT x:C. A(x) Int B)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   493
     "(INT x:C. A(x)) - B = (INT x:C. A(x) - B)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   494
     "(INT x:C. A(x)) Un B  = (if C=0 then B else (INT x:C. A(x) Un B))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   495
apply (simp_all add: Inter_def, blast+)
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   496
done
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   497
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   498
lemma INT_extend_simps2:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   499
     "A Int (INT x:C. B(x)) = (INT x:C. A Int B(x))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   500
     "A - (UN x:C. B(x))   = (if C=0 then A else (INT x:C. A - B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   501
     "cons(a, INT x:C. B(x)) = (if C=0 then {a} else (INT x:C. cons(a, B(x))))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   502
     "A Un (INT x:C. B(x))  = (if C=0 then A else (INT x:C. A Un B(x)))"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   503
apply (simp_all add: Inter_def) 
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   504
apply (blast intro!: equalityI)+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   505
done
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   506
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   507
lemmas INT_extend_simps = INT_extend_simps1 INT_extend_simps2
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   508
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   509
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   510
subsection{*Other simprules*}
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   511
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   512
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   513
(*** Miniscoping: pushing in big Unions, Intersections, quantifiers, etc. ***)
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   514
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   515
lemma misc_simps [simp]:
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   516
     "0 Un A = A"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   517
     "A Un 0 = A"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   518
     "0 Int A = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   519
     "A Int 0 = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   520
     "0 - A = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   521
     "A - 0 = A"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   522
     "Union(0) = 0"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   523
     "Union(cons(b,A)) = b Un Union(A)"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   524
     "Inter({b}) = b"
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   525
by blast+
af7b79271364 more new-style theories
paulson
parents: 13544
diff changeset
   526
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 3924
diff changeset
   527
end