src/ZF/Bool.ML
author nipkow
Tue, 12 Jan 1999 15:48:59 +0100
changeset 6099 d4866f6ff2f9
parent 6053 8a1059aa01f0
child 6153 bff90585cce5
permissions -rw-r--r--
verbatim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
     1
(*  Title:      ZF/bool
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 760
diff changeset
     3
    Author:     Martin D Coen, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
     6
Booleans in Zermelo-Fraenkel Set Theory 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
open Bool;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
14
1c0926788772 ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents: 6
diff changeset
    11
val bool_defs = [bool_def,cond_def];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    13
Goalw [succ_def] "{0} = 1";
2493
bdeb5024353a Removal of sum_cs and eq_cs
paulson
parents: 2469
diff changeset
    14
by (rtac refl 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    15
qed "singleton_0";
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    16
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
(* Introduction rules *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    19
Goalw bool_defs "1 : bool";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
by (rtac (consI1 RS consI2) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    21
qed "bool_1I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    23
Goalw bool_defs "0 : bool";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
by (rtac consI1 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    25
qed "bool_0I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    27
Addsimps [bool_1I, bool_0I];
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    28
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    29
Goalw bool_defs "1~=0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
by (rtac succ_not_0 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    31
qed "one_not_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
(** 1=0 ==> R **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
val one_neq_0 = one_not_0 RS notE;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    36
val major::prems = Goalw bool_defs
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
    37
    "[| c: bool;  c=1 ==> P;  c=0 ==> P |] ==> P";
129
dc50a4b96d7b expandshort and other trivial changes
lcp
parents: 119
diff changeset
    38
by (rtac (major RS consE) 1);
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
    39
by (REPEAT (eresolve_tac (singletonE::prems) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    40
qed "boolE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
(** cond **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
(*1 means true*)
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    45
Goalw bool_defs "cond(1,c,d) = c";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
by (rtac (refl RS if_P) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    47
qed "cond_1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
(*0 means false*)
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    50
Goalw bool_defs "cond(0,c,d) = d";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
by (rtac (succ_not_0 RS not_sym RS if_not_P) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    52
qed "cond_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    54
Addsimps [cond_1, cond_0];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    55
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2493
diff changeset
    56
fun bool_tac i = fast_tac (claset() addSEs [boolE] addss (simpset())) i;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    57
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    58
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    59
Goal "[| b: bool;  c: A(1);  d: A(0) |] ==> cond(b,c,d): A(b)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    60
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    61
qed "cond_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    63
(*For Simp_tac and Blast_tac*)
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    64
Goal "[| b: bool;  c: A;  d: A |] ==> cond(b,c,d): A";
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    65
by (bool_tac 1);
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    66
qed "cond_simple_type";
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    67
Addsimps [cond_simple_type];
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
    68
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    69
val [rew] = Goal "[| !!b. j(b)==cond(b,c,d) |] ==> j(1) = c";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
by (rtac cond_1 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    72
qed "def_cond_1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    74
val [rew] = Goal "[| !!b. j(b)==cond(b,c,d) |] ==> j(0) = d";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
by (rtac cond_0 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    77
qed "def_cond_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
fun conds def = [standard (def RS def_cond_1), standard (def RS def_cond_0)];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
val [not_1,not_0] = conds not_def;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
val [and_1,and_0] = conds and_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    83
val [or_1,or_0]   = conds or_def;
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    84
val [xor_1,xor_0] = conds xor_def;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    86
Addsimps [not_1,not_0,and_1,and_0,or_1,or_0,xor_1,xor_0];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    88
qed_goalw "not_type" Bool.thy [not_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
    "a:bool ==> not(a) : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
 (fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    92
qed_goalw "and_type" Bool.thy [and_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
    "[| a:bool;  b:bool |] ==> a and b : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
 (fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    96
qed_goalw "or_type" Bool.thy [or_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
    "[| a:bool;  b:bool |] ==> a or b : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
 (fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
   100
Addsimps [not_type, and_type, or_type];
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
   101
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   102
qed_goalw "xor_type" Bool.thy [xor_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
    "[| a:bool;  b:bool |] ==> a xor b : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
 (fn prems=> [ (typechk_tac(prems@[bool_1I, bool_0I, cond_type, not_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
6053
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
   106
Addsimps [xor_type];
8a1059aa01f0 new inductive, datatype and primrec packages, etc.
paulson
parents: 5268
diff changeset
   107
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
val bool_typechecks = [bool_1I, bool_0I, cond_type, not_type, and_type, 
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   109
                       or_type, xor_type];
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   110
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   111
(*** Laws for 'not' ***)
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   112
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   113
Goal "a:bool ==> not(not(a)) = a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   114
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   115
qed "not_not";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   116
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   117
Goal "a:bool ==> not(a and b) = not(a) or not(b)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   118
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   119
qed "not_and";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   120
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   121
Goal "a:bool ==> not(a or b) = not(a) and not(b)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   122
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   123
qed "not_or";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   124
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   125
Addsimps [not_not, not_and, not_or];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   126
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   127
(*** Laws about 'and' ***)
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   128
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   129
Goal "a: bool ==> a and a = a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   130
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   131
qed "and_absorb";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   132
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   133
Addsimps [and_absorb];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   134
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   135
Goal "[| a: bool; b:bool |] ==> a and b = b and a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   136
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   137
qed "and_commute";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   139
Goal "a: bool ==> (a and b) and c  =  a and (b and c)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   140
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   141
qed "and_assoc";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   142
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
   143
Goal "[| a: bool; b:bool; c:bool |] ==> \
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   144
\      (a or b) and c  =  (a and c) or (b and c)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   145
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   146
qed "and_or_distrib";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   147
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   148
(** binary orion **)
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   149
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   150
Goal "a: bool ==> a or a = a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   151
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   152
qed "or_absorb";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   153
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   154
Addsimps [or_absorb];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   155
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   156
Goal "[| a: bool; b:bool |] ==> a or b = b or a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   157
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   158
qed "or_commute";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   159
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   160
Goal "a: bool ==> (a or b) or c  =  a or (b or c)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   161
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   162
qed "or_assoc";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   163
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
   164
Goal "[| a: bool; b: bool; c: bool |] ==> \
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   165
\          (a and b) or c  =  (a or c) and (b or c)";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   166
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   167
qed "or_and_distrib";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   168