src/ZF/Bool.ML
author wenzelm
Sun, 29 Nov 1998 13:14:45 +0100
changeset 5986 6ebbc9e7cc20
parent 5268 59ef39008514
child 6053 8a1059aa01f0
permissions -rw-r--r--
added oct_char;
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
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    27
Goalw bool_defs "1~=0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
by (rtac succ_not_0 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    29
qed "one_not_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
(** 1=0 ==> R **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
val one_neq_0 = one_not_0 RS notE;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    34
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
    35
    "[| c: bool;  c=1 ==> P;  c=0 ==> P |] ==> P";
129
dc50a4b96d7b expandshort and other trivial changes
lcp
parents: 119
diff changeset
    36
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
    37
by (REPEAT (eresolve_tac (singletonE::prems) 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    38
qed "boolE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
(** cond **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
(*1 means true*)
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    43
Goalw bool_defs "cond(1,c,d) = c";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
by (rtac (refl RS if_P) 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    45
qed "cond_1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
(*0 means false*)
5067
62b6288e6005 isatool fixgoal;
wenzelm
parents: 4091
diff changeset
    48
Goalw bool_defs "cond(0,c,d) = d";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
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
    50
qed "cond_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    52
Addsimps [cond_1, cond_0];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    53
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 2493
diff changeset
    54
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
    55
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    56
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    57
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
    58
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    59
qed "cond_type";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    61
val [rew] = Goal "[| !!b. j(b)==cond(b,c,d) |] ==> j(1) = c";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
by (rtac cond_1 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    64
qed "def_cond_1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
    66
val [rew] = Goal "[| !!b. j(b)==cond(b,c,d) |] ==> j(0) = d";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
by (rewtac rew);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
by (rtac cond_0 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    69
qed "def_cond_0";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
fun conds def = [standard (def RS def_cond_1), standard (def RS def_cond_0)];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
val [not_1,not_0] = conds not_def;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
val [and_1,and_0] = conds and_def;
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    75
val [or_1,or_0]   = conds or_def;
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    76
val [xor_1,xor_0] = conds xor_def;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    78
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
    79
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    80
qed_goalw "not_type" Bool.thy [not_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
    "a:bool ==> not(a) : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
 (fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    84
qed_goalw "and_type" Bool.thy [and_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
    "[| a:bool;  b:bool |] ==> a and b : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
 (fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
    88
qed_goalw "or_type" Bool.thy [or_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
    "[| a:bool;  b:bool |] ==> a or b : 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 "xor_type" Bool.thy [xor_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
    "[| a:bool;  b:bool |] ==> a xor b : bool"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
 (fn prems=> [ (typechk_tac(prems@[bool_1I, bool_0I, cond_type, not_type])) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
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
    97
                       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
    98
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
    99
(*** Laws for 'not' ***)
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   100
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   101
Goal "a:bool ==> not(not(a)) = a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   102
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   103
qed "not_not";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   104
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   105
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
   106
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   107
qed "not_and";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   108
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   109
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
   110
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   111
qed "not_or";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   112
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   113
Addsimps [not_not, not_and, not_or];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   114
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   115
(*** Laws about 'and' ***)
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 ==> a and a = a";
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 "and_absorb";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   120
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   121
Addsimps [and_absorb];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   122
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   123
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
   124
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   125
qed "and_commute";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   127
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
   128
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   129
qed "and_assoc";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   130
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
   131
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
   132
\      (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
   133
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   134
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
   135
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   136
(** binary orion **)
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   137
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   138
Goal "a: bool ==> a or a = a";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   139
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   140
qed "or_absorb";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   141
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   142
Addsimps [or_absorb];
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   143
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   144
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
   145
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   146
qed "or_commute";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   147
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5067
diff changeset
   148
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
   149
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   150
qed "or_assoc";
119
0e58da397b1d boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents: 37
diff changeset
   151
5268
59ef39008514 even more tidying of Goal commands
paulson
parents: 5137
diff changeset
   152
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
   153
\          (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
   154
by (bool_tac 1);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 129
diff changeset
   155
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
   156