src/HOL/Ord.ML
author nipkow
Fri, 20 Feb 1998 17:56:39 +0100
changeset 4640 ac6cf9f18653
parent 4600 e3e7e901ce6c
child 4686 74a12e86b20b
permissions -rw-r--r--
Congruence rules use == in premises now. New class linord.
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*)
e3e7e901ce6c New theorem order_eq_refl
paulson
parents: 4089
diff changeset
    28
goal Ord.thy "!!x::'a::order. x = y ==> x <= y";
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
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    33
goal Ord.thy "~ 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
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    38
goal thy "(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
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    45
goalw thy [min_def] "!!least. (!!x. least <= x) ==> min least x = least";
2935
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    46
by (split_tac [expand_if] 1);
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    47
by (Asm_simp_tac 1);
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    48
qed "min_leastL";
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    49
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    50
val prems = goalw thy [min_def]
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    51
 "(!!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
    52
by (cut_facts_tac prems 1);
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    53
by (split_tac [expand_if] 1);
998cb95fdd43 Yet more fast_tac->blast_tac, and other tidying
paulson
parents: 2608
diff changeset
    54
by (Asm_simp_tac 1);
4089
96fba19bcbe2 isatool fixclasimp;
wenzelm
parents: 2935
diff changeset
    55
by (blast_tac (claset() addIs [order_antisym]) 1);
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 1465
diff changeset
    56
qed "min_leastR";
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    57
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    58
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    59
section "Linear/Total Orders";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    60
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    61
goal thy "!!x::'a::linorder. x<y | x=y | y<x";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    62
by (simp_tac (simpset() addsimps [order_less_le]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    63
by(cut_facts_tac [linorder_linear] 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    64
by (Blast_tac 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    65
qed "linorder_less_linear";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    66
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    67
goalw thy [max_def] "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    68
by (simp_tac (simpset() addsimps [] addsplits [expand_if]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    69
by(cut_facts_tac [linorder_linear] 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    70
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    71
qed "le_max_iff_disj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    72
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    73
goalw thy [max_def] "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    74
by (simp_tac (simpset() addsimps [] addsplits [expand_if]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    75
by(cut_facts_tac [linorder_linear] 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    76
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    77
qed "max_le_iff_conj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    78
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    79
goalw thy [min_def] "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    80
by (simp_tac (simpset() addsimps [] addsplits [expand_if]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    81
by(cut_facts_tac [linorder_linear] 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    82
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    83
qed "le_min_iff_conj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    84
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    85
goalw thy [min_def] "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    86
by (simp_tac (simpset() addsimps [] addsplits [expand_if]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    87
by(cut_facts_tac [linorder_linear] 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    88
by (blast_tac (claset() addIs [order_trans]) 1);
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    89
qed "min_le_iff_disj";
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    90
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 4600
diff changeset
    91