src/HOL/UNITY/LessThan.ML
author wenzelm
Mon, 10 Aug 1998 17:06:02 +0200
changeset 5290 b755c7240348
parent 5232 e5a7cdd07ea5
child 5320 79b326bceafb
permissions -rw-r--r--
suffix, unsuffix moved to Pure/library.ML;
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
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    10
(*** lessThan ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    11
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    12
Goalw [lessThan_def] "(i: lessThan k) = (i<k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
qed "lessThan_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
AddIffs [lessThan_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    17
Goalw [lessThan_def] "lessThan 0 = {}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    18
by (Simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    19
qed "lessThan_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    20
Addsimps [lessThan_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    22
Goalw [lessThan_def] "lessThan (Suc k) = insert k (lessThan k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    23
by (simp_tac (simpset() addsimps [less_Suc_eq]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    24
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
qed "lessThan_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    27
Goal "(UN m. lessThan m) = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    28
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    29
qed "UN_lessThan_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    31
Goalw [lessThan_def, atLeast_def, le_def]
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    32
    "Compl(lessThan k) = atLeast k";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    33
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    34
qed "Compl_lessThan";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    37
(*** greaterThan ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    38
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    39
Goalw [greaterThan_def] "(i: greaterThan k) = (k<i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    40
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
qed "greaterThan_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    42
AddIffs [greaterThan_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    43
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    44
Goalw [greaterThan_def] "greaterThan 0 = range Suc";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    45
by (blast_tac (claset() addIs [Suc_pred RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
qed "greaterThan_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
Addsimps [greaterThan_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    48
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    49
Goalw [greaterThan_def] "greaterThan (Suc k) = greaterThan k - {Suc k}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
by (blast_tac (claset() addIs [less_trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
by (asm_simp_tac (simpset() addsimps [le_Suc_eq, not_le_iff_less RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
by (asm_simp_tac (simpset() addsimps [not_le_iff_less]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    54
qed "greaterThan_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    55
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    56
Goal "(INT m. greaterThan m) = {}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
qed "INT_greaterThan_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    60
Goalw [greaterThan_def, atMost_def, le_def]
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
    "Compl(greaterThan k) = atMost k";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
qed "Compl_greaterThan";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    65
Goalw [greaterThan_def, atMost_def, le_def]
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
    "Compl(atMost k) = greaterThan k";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
qed "Compl_atMost";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    70
Goal "less_than ^^ {k} = greaterThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
qed "Image_less_than";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
Addsimps [Compl_greaterThan, Compl_atMost, Image_less_than];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    76
(*** atLeast ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    78
Goalw [atLeast_def] "(i: atLeast k) = (k<=i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
qed "atLeast_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
AddIffs [atLeast_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    82
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    83
Goalw [atLeast_def, UNIV_def] "atLeast 0 = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
by (Simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
qed "atLeast_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
Addsimps [atLeast_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    88
Goalw [atLeast_def] "atLeast (Suc k) = atLeast k - {k}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    89
by (simp_tac (simpset() addsimps [Suc_le_eq]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
by (simp_tac (simpset() addsimps [le_eq_less_or_eq]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
qed "atLeast_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    94
Goal "(UN m. atLeast m) = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
qed "UN_atLeast_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    98
Goalw [lessThan_def, atLeast_def, le_def]
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
    "Compl(atLeast k) = lessThan k";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   100
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
qed "Compl_atLeast";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   103
Goal "less_than^-1 ^^ {k} = lessThan k";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   105
qed "Image_inverse_less_than";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   107
Addsimps [Compl_lessThan, Compl_atLeast, Image_inverse_less_than];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   108
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   109
(*** atMost ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   111
Goalw [atMost_def] "(i: atMost k) = (i<=k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   113
qed "atMost_iff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
AddIffs [atMost_iff];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   115
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   116
Goalw [atMost_def] "atMost 0 = {0}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   117
by (Simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   118
qed "atMost_0";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   119
Addsimps [atMost_0];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   120
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   121
Goalw [atMost_def] "atMost (Suc k) = insert (Suc k) (atMost k)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   122
by (simp_tac (simpset() addsimps [less_Suc_eq, le_eq_less_or_eq]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   123
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
qed "atMost_Suc";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   125
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   126
Goal "(UN m. atMost m) = UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   127
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
qed "UN_atMost_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   130
Goalw [atMost_def, le_def]
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   131
    "Compl(atMost k) = greaterThan k";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   132
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
qed "Compl_atMost";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
Addsimps [Compl_atMost];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   136
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   137
(*** Combined properties ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   139
Goal "atMost n Int atLeast n = {n}";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
by (blast_tac (claset() addIs [le_anti_sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
qed "atMost_Int_atLeast";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   144
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   145
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   146
(*** Finally, a few set-theoretic laws...
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   147
     CAN BOOLEAN SIMPLIFICATION BE AUTOMATED? ***)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   148
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   149
context Set.thy;
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   150
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   151
(** Rewrites rules to eliminate A.  Conditions can be satisfied by letting B
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   152
    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
   153
**)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   154
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   155
Goal "[| A Int C <= B; B <= A Un C |] \
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   156
\     ==> (A Int B) Un (Compl A Int C) = B Un C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   157
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   158
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   159
Goal "[| A Int C <= B; B <= A Un C |] \
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   160
\     ==> (A Un B) Int (Compl A Un C) = B Int C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   161
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   162
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   163
(*The base B=A*)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   164
Goal "A Un (Compl A Int C) = A Un C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   165
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   166
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   167
Goal "A Int (Compl A Un C) = A Int C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   168
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   169
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   170
(*The base B=C*)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   171
Goal "(A Int C) Un (Compl A Int C) = C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   172
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   173
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   174
Goal "(A Un C) Int (Compl A Un C) = C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   175
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   176
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   177
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   178
(** More ad-hoc rules **)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   179
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   180
Goal "A Un B - (A - B) = B";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   181
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   182
qed "Un_Diff_Diff";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   183
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   184
Goal "A Int (B - C) Un C = A Int B Un C";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   185
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   186
qed "Int_Diff_Un";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   187
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   188
Goal "Union(B) Int A = (UN C:B. C Int A)";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   189
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   190
qed "Int_Union2";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   191
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   192
Goal "Union(B) Int A = Union((%C. C Int A)``B)";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   193
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   194
qed "Int_Union_Union";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5069
diff changeset
   195