src/HOL/UNITY/LessThan.ML
author paulson
Fri, 12 May 2000 15:05:02 +0200
changeset 8862 78643f8449c6
parent 8128 3a5864b465e2
child 8948 b797cfa3548d
permissions -rw-r--r--
NatSimprocs is now a theory, not a file
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/LessThan/LessThan
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     5
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     6
lessThan, greaterThan, atLeast, atMost
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     7
*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     8
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     9
7878
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    10
(*** Restrict [MOVE TO RELATION.THY??] ***)
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    11
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    12
Goalw [Restrict_def] "((x,y): Restrict A r) = ((x,y): r & x: A)";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    13
by (Blast_tac 1);
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    14
qed "Restrict_iff";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    15
AddIffs [Restrict_iff];
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    16
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    17
Goal "Restrict UNIV = id";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    18
by (rtac ext 1);
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    19
by (auto_tac (claset(), simpset() addsimps [Restrict_def]));
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    20
qed "Restrict_UNIV";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    21
Addsimps [Restrict_UNIV];
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    22
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    23
Goal "Restrict {} r = {}";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    24
by (auto_tac (claset(), simpset() addsimps [Restrict_def]));
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    25
qed "Restrict_empty";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    26
Addsimps [Restrict_empty];
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    27
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    28
Goalw [Restrict_def] "Restrict A (Restrict B r) = Restrict (A Int B) r";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    29
by (Blast_tac 1);
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    30
qed "Restrict_Int";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    31
Addsimps [Restrict_Int];
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    32
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    33
Goalw [Restrict_def] "Domain r <= A ==> Restrict A r = r";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    34
by Auto_tac;
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    35
qed "Restrict_triv";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    36
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    37
Goalw [Restrict_def] "Restrict A r <= r";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    38
by Auto_tac;
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    39
qed "Restrict_subset";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    40
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    41
Goalw [Restrict_def]
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    42
     "[| A <= B;  Restrict B r = Restrict B s |] \
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    43
\     ==> Restrict A r = Restrict A s";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    44
by (blast_tac (claset() addSEs [equalityE]) 1);
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    45
qed "Restrict_eq_mono";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    46
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    47
Goalw [Restrict_def, image_def]
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    48
     "[| s : RR;  Restrict A r = Restrict A s |] \
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    49
\     ==> Restrict A r : Restrict A `` RR";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    50
by Auto_tac;
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    51
qed "Restrict_imageI";
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    52
7915
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    53
Goal "Domain (Restrict A r) = A Int Domain r";
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    54
by (Blast_tac 1);
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    55
qed "Domain_Restrict";
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    56
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    57
Goal "(Restrict A r) ^^ B = r ^^ (A Int B)";
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    58
by (Blast_tac 1);
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    59
qed "Image_Restrict";
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    60
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    61
Addsimps [Domain_Restrict, Image_Restrict];
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    62
c7fd7eb3b0ef ALMOST working version: LocalTo results commented out
paulson
parents: 7878
diff changeset
    63
7878
43b03d412b82 working version with localTo[C] instead of localTo
paulson
parents: 7521
diff changeset
    64
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
(*** lessThan ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    67
Goalw [lessThan_def] "(i: lessThan k) = (i<k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
qed "lessThan_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
AddIffs [lessThan_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    72
Goalw [lessThan_def] "lessThan 0 = {}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
by (Simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
qed "lessThan_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
Addsimps [lessThan_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    76
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    77
Goalw [lessThan_def] "lessThan (Suc k) = insert k (lessThan k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
by (simp_tac (simpset() addsimps [less_Suc_eq]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
qed "lessThan_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5625
diff changeset
    82
Goalw [lessThan_def, atMost_def] "lessThan (Suc k) = atMost k";
fe887910e32e specifications as sets of programs
paulson
parents: 5625
diff changeset
    83
by (simp_tac (simpset() addsimps [less_Suc_eq_le]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5625
diff changeset
    84
qed "lessThan_Suc_atMost";
fe887910e32e specifications as sets of programs
paulson
parents: 5625
diff changeset
    85
6825
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
    86
Goal "finite (lessThan k)";
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
    87
by (induct_tac "k" 1);
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
    88
by (simp_tac (simpset() addsimps [lessThan_Suc]) 2);
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
    89
by Auto_tac;
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
    90
qed "finite_lessThan";
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
    91
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    92
Goal "(UN m. lessThan m) = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    94
qed "UN_lessThan_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    96
Goalw [lessThan_def, atLeast_def, le_def]
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
    97
    "-lessThan k = atLeast k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    98
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
qed "Compl_lessThan";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   100
7521
a18adacbdbd2 new theorem single_Diff_lessThan
paulson
parents: 6825
diff changeset
   101
Goal "{k} - lessThan k = {k}";
a18adacbdbd2 new theorem single_Diff_lessThan
paulson
parents: 6825
diff changeset
   102
by (Blast_tac 1);
a18adacbdbd2 new theorem single_Diff_lessThan
paulson
parents: 6825
diff changeset
   103
qed "single_Diff_lessThan";
a18adacbdbd2 new theorem single_Diff_lessThan
paulson
parents: 6825
diff changeset
   104
Addsimps [single_Diff_lessThan];
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   105
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
(*** greaterThan ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   107
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   108
Goalw [greaterThan_def] "(i: greaterThan k) = (k<i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   109
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
qed "greaterThan_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
AddIffs [greaterThan_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   113
Goalw [greaterThan_def] "greaterThan 0 = range Suc";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
by (blast_tac (claset() addIs [Suc_pred RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   115
qed "greaterThan_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   116
Addsimps [greaterThan_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   117
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   118
Goalw [greaterThan_def] "greaterThan (Suc k) = greaterThan k - {Suc k}";
5625
77e9ab9cd7b1 polymorphic versions of nat_neq_iff and nat_neqE
paulson
parents: 5596
diff changeset
   119
by (auto_tac (claset() addEs [linorder_neqE], simpset()));
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   120
qed "greaterThan_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   121
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   122
Goal "(INT m. greaterThan m) = {}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   123
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
qed "INT_greaterThan_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   125
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   126
Goalw [greaterThan_def, atMost_def, le_def]
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   127
    "-greaterThan k = atMost k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
qed "Compl_greaterThan";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   131
Goalw [greaterThan_def, atMost_def, le_def]
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   132
    "-atMost k = greaterThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
qed "Compl_atMost";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   136
Goal "less_than ^^ {k} = greaterThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   137
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
qed "Image_less_than";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
Addsimps [Compl_greaterThan, Compl_atMost, Image_less_than];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
(*** atLeast ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   144
Goalw [atLeast_def] "(i: atLeast k) = (k<=i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   145
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   146
qed "atLeast_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   147
AddIffs [atLeast_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   148
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   149
Goalw [atLeast_def, UNIV_def] "atLeast 0 = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
by (Simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   151
qed "atLeast_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   152
Addsimps [atLeast_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   153
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   154
Goalw [atLeast_def] "atLeast (Suc k) = atLeast k - {k}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   155
by (simp_tac (simpset() addsimps [Suc_le_eq]) 1);
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5490
diff changeset
   156
by (simp_tac (simpset() addsimps [order_le_less]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   157
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   158
qed "atLeast_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   159
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   160
Goal "(UN m. atLeast m) = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   161
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   162
qed "UN_atLeast_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   163
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   164
Goalw [lessThan_def, atLeast_def, le_def]
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   165
    "-atLeast k = lessThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   167
qed "Compl_atLeast";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   169
Goal "less_than^-1 ^^ {k} = lessThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   170
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   171
qed "Image_inverse_less_than";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   173
Addsimps [Compl_lessThan, Compl_atLeast, Image_inverse_less_than];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   175
(*** atMost ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   176
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   177
Goalw [atMost_def] "(i: atMost k) = (i<=k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   178
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   179
qed "atMost_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   180
AddIffs [atMost_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   181
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   182
Goalw [atMost_def] "atMost 0 = {0}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   183
by (Simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   184
qed "atMost_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   185
Addsimps [atMost_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   186
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   187
Goalw [atMost_def] "atMost (Suc k) = insert (Suc k) (atMost k)";
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5490
diff changeset
   188
by (simp_tac (simpset() addsimps [less_Suc_eq, order_le_less]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   189
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   190
qed "atMost_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   191
6825
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
   192
Goal "finite (atMost k)";
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
   193
by (induct_tac "k" 1);
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
   194
by (simp_tac (simpset() addsimps [atMost_Suc]) 2);
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
   195
by Auto_tac;
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
   196
qed "finite_atMost";
30e09714eef5 new finiteness theorems
paulson
parents: 6707
diff changeset
   197
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   198
Goal "(UN m. atMost m) = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   199
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   200
qed "UN_atMost_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   201
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   202
Goalw [atMost_def, le_def]
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   203
    "-atMost k = greaterThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   204
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
qed "Compl_atMost";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
Addsimps [Compl_atMost];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   208
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   209
(*** Combined properties ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   210
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   211
Goal "atMost n Int atLeast n = {n}";
6707
3b07e62a718c using generic rules when possible
paulson
parents: 6128
diff changeset
   212
by (blast_tac (claset() addIs [order_antisym]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   213
qed "atMost_Int_atLeast";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   214
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   215
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   216
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   217
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   218
(*** Finally, a few set-theoretic laws...
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   219
     CAN BOOLEAN SIMPLIFICATION BE AUTOMATED? ***)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   220
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   221
context Set.thy;
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   222
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   223
(** Rewrite rules to eliminate A.  Conditions can be satisfied by letting B
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   224
    be any set including A Int C and contained in A Un C, such as B=A or B=C.
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   225
**)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   226
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   227
Goal "[| A Int C <= B; B <= A Un C |] \
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   228
\     ==> (A Int B) Un (-A Int C) = B Un C";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   229
by (Blast_tac 1);
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   230
qed "set_cancel1";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   231
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   232
Goal "[| A Int C <= B; B <= A Un C |] \
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   233
\     ==> (A Un B) Int (-A Un C) = B Int C";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   234
by (Blast_tac 1);
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   235
qed "set_cancel2";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   236
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   237
(*The base B=A*)
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   238
Goal "A Un (-A Int C) = A Un C";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   239
by (Blast_tac 1);
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   240
qed "set_cancel3";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   241
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   242
Goal "A Int (-A Un C) = A Int C";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   243
by (Blast_tac 1);
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   244
qed "set_cancel4";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   245
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   246
(*The base B=C*)
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   247
Goal "(A Int C) Un (-A Int C) = C";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   248
by (Blast_tac 1);
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   249
qed "set_cancel5";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   250
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   251
Goal "(A Un C) Int (-A Un C) = C";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   252
by (Blast_tac 1);
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   253
qed "set_cancel6";
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   254
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   255
Addsimps [set_cancel1, set_cancel2, set_cancel3,
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   256
	  set_cancel4, set_cancel5, set_cancel6];
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   257
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   258
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   259
(** More ad-hoc rules **)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   260
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   261
Goal "A Un B - (A - B) = B";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   262
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   263
qed "Un_Diff_Diff";
5490
85855f65d0c6 From Compl(A) to -A
paulson
parents: 5355
diff changeset
   264
Addsimps [Un_Diff_Diff];
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   265
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   266
Goal "A Int (B - C) Un C = A Int B Un C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   267
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   268
qed "Int_Diff_Un";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   269
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   270
Goal "Union(B) Int A = (UN C:B. C Int A)";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   271
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   272
qed "Int_Union2";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   273
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   274
Goal "Union(B) Int A = Union((%C. C Int A)``B)";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   275
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   276
qed "Int_Union_Union";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   277