src/HOL/Ord.ML
author berghofe
Fri, 24 Jul 1998 13:19:38 +0200
changeset 5184 9b8547a9496a
parent 5143 b94cd208f073
child 5316 7a8975451a89
permissions -rw-r--r--
Adapted to new datatype package.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 923
diff changeset
     1
(*  Title:      HOL/Ord.ML
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 923
diff changeset
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
The type class for ordered types
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
     9
(** mono **)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
val [prem] = goalw Ord.thy [mono_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
    "[| !!A B. A <= B ==> f(A) <= f(B) |] ==> mono(f)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
by (REPEAT (ares_tac [allI, impI, prem] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
qed "monoI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
val [major,minor] = goalw Ord.thy [mono_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
    "[| mono(f);  A <= B |] ==> f(A) <= f(B)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
by (rtac (major RS spec RS spec RS mp) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
by (rtac minor 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
qed "monoD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    22
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    23
section "Orders";
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    24
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    25
AddIffs [order_refl];
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    26
4600
e3e7e901ce6c New theorem order_eq_refl
paulson
parents: 4089
diff changeset
    27
(*This form is useful with the classical reasoner*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    28
Goal "!!x::'a::order. x = y ==> x <= y";
4600
e3e7e901ce6c New theorem order_eq_refl
paulson
parents: 4089
diff changeset
    29
by (etac ssubst 1);
e3e7e901ce6c New theorem order_eq_refl
paulson
parents: 4089
diff changeset
    30
by (rtac order_refl 1);
e3e7e901ce6c New theorem order_eq_refl
paulson
parents: 4089
diff changeset
    31
qed "order_eq_refl";
e3e7e901ce6c New theorem order_eq_refl
paulson
parents: 4089
diff changeset
    32
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    33
Goal "~ x < (x::'a::order)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 2935
diff changeset
    34
by (simp_tac (simpset() addsimps [order_less_le]) 1);
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    35
qed "order_less_irrefl";
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    36
AddIffs [order_less_irrefl];
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    37
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    38
Goal "(x::'a::order) <= y = (x < y | x = y)";
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 2935
diff changeset
    39
by (simp_tac (simpset() addsimps [order_less_le]) 1);
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    40
by (Blast_tac 1);
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    41
qed "order_le_less";
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    42
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    43
(** min **)
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    44
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5132
diff changeset
    45
val prems = Goalw [min_def] "(!!x. least <= x) ==> min least x = least";
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5132
diff changeset
    46
by (simp_tac (simpset() addsimps prems) 1);
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    47
qed "min_leastL";
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    48
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    49
val prems = goalw thy [min_def]
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    50
 "(!!x::'a::order. least <= x) ==> min x least = least";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    51
by (cut_facts_tac prems 1);
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    52
by (Asm_simp_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 2935
diff changeset
    53
by (blast_tac (claset() addIs [order_antisym]) 1);
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    54
qed "min_leastR";
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    55
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    56
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    57
section "Linear/Total Orders";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    58
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    59
Goal "!!x::'a::linorder. x<y | x=y | y<x";
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    60
by (simp_tac (simpset() addsimps [order_less_le]) 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5069
diff changeset
    61
by (cut_facts_tac [linorder_linear] 1);
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    62
by (Blast_tac 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    63
qed "linorder_less_linear";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    64
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    65
Goalw [max_def] "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4640
diff changeset
    66
by (Simp_tac 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5069
diff changeset
    67
by (cut_facts_tac [linorder_linear] 1);
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    68
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    69
qed "le_max_iff_disj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    70
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    71
Goalw [max_def] "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4640
diff changeset
    72
by (Simp_tac 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5069
diff changeset
    73
by (cut_facts_tac [linorder_linear] 1);
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    74
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    75
qed "max_le_iff_conj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    76
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    77
Goalw [min_def] "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4640
diff changeset
    78
by (Simp_tac 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5069
diff changeset
    79
by (cut_facts_tac [linorder_linear] 1);
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    80
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    81
qed "le_min_iff_conj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    82
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4686
diff changeset
    83
Goalw [min_def] "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4640
diff changeset
    84
by (Simp_tac 1);
5132
24f992a25adc isatool expandshort;
wenzelm
parents: 5069
diff changeset
    85
by (cut_facts_tac [linorder_linear] 1);
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    86
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    87
qed "min_le_iff_disj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    88
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    89