src/HOL/Ord.ML
author paulson
Thu Sep 10 17:17:22 1998 +0200 (1998-09-10)
changeset 5449 d853d1ac85a3
parent 5316 7a8975451a89
child 5538 c55bf0487abe
permissions -rw-r--r--
Adds order_refl, order_less_irrefl as simps, not as Iffs, to avoid PROOF FAILED
clasohm@1465
     1
(*  Title:      HOL/Ord.ML
clasohm@923
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1993  University of Cambridge
clasohm@923
     5
clasohm@923
     6
The type class for ordered types
clasohm@923
     7
*)
clasohm@923
     8
paulson@5449
     9
(*Tell Blast_tac about overloading of < and <= to reduce the risk of
paulson@5449
    10
  its applying a rule for the wrong type*)
paulson@5449
    11
Blast.overloaded ("op <", domain_type); 
paulson@5449
    12
Blast.overloaded ("op <=", domain_type);
paulson@5449
    13
nipkow@2608
    14
(** mono **)
clasohm@923
    15
paulson@5316
    16
val [prem] = Goalw [mono_def]
clasohm@923
    17
    "[| !!A B. A <= B ==> f(A) <= f(B) |] ==> mono(f)";
clasohm@923
    18
by (REPEAT (ares_tac [allI, impI, prem] 1));
clasohm@923
    19
qed "monoI";
clasohm@923
    20
paulson@5316
    21
Goalw [mono_def] "[| mono(f);  A <= B |] ==> f(A) <= f(B)";
paulson@5316
    22
by (Fast_tac 1);
clasohm@923
    23
qed "monoD";
clasohm@923
    24
nipkow@2608
    25
nipkow@2608
    26
section "Orders";
nipkow@2608
    27
paulson@5449
    28
Addsimps [order_refl];
nipkow@2608
    29
paulson@4600
    30
(*This form is useful with the classical reasoner*)
wenzelm@5069
    31
Goal "!!x::'a::order. x = y ==> x <= y";
paulson@4600
    32
by (etac ssubst 1);
paulson@4600
    33
by (rtac order_refl 1);
paulson@4600
    34
qed "order_eq_refl";
paulson@4600
    35
wenzelm@5069
    36
Goal "~ x < (x::'a::order)";
wenzelm@4089
    37
by (simp_tac (simpset() addsimps [order_less_le]) 1);
nipkow@2608
    38
qed "order_less_irrefl";
paulson@5449
    39
Addsimps [order_less_irrefl];
nipkow@2608
    40
wenzelm@5069
    41
Goal "(x::'a::order) <= y = (x < y | x = y)";
wenzelm@4089
    42
by (simp_tac (simpset() addsimps [order_less_le]) 1);
paulson@5449
    43
   (*NOT suitable for AddIffs, since it can cause PROOF FAILED*)
paulson@5449
    44
by (blast_tac (claset() addSIs [order_refl]) 1);
nipkow@2608
    45
qed "order_le_less";
nipkow@2608
    46
nipkow@2608
    47
(** min **)
nipkow@2608
    48
paulson@5143
    49
val prems = Goalw [min_def] "(!!x. least <= x) ==> min least x = least";
paulson@5143
    50
by (simp_tac (simpset() addsimps prems) 1);
nipkow@2608
    51
qed "min_leastL";
nipkow@2608
    52
paulson@5316
    53
val prems = Goalw [min_def]
nipkow@2608
    54
 "(!!x::'a::order. least <= x) ==> min x least = least";
paulson@2935
    55
by (cut_facts_tac prems 1);
paulson@2935
    56
by (Asm_simp_tac 1);
wenzelm@4089
    57
by (blast_tac (claset() addIs [order_antisym]) 1);
nipkow@2608
    58
qed "min_leastR";
nipkow@4640
    59
nipkow@4640
    60
nipkow@4640
    61
section "Linear/Total Orders";
nipkow@4640
    62
wenzelm@5069
    63
Goal "!!x::'a::linorder. x<y | x=y | y<x";
nipkow@4640
    64
by (simp_tac (simpset() addsimps [order_less_le]) 1);
wenzelm@5132
    65
by (cut_facts_tac [linorder_linear] 1);
nipkow@4640
    66
by (Blast_tac 1);
nipkow@4640
    67
qed "linorder_less_linear";
nipkow@4640
    68
wenzelm@5069
    69
Goalw [max_def] "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)";
nipkow@4686
    70
by (Simp_tac 1);
wenzelm@5132
    71
by (cut_facts_tac [linorder_linear] 1);
nipkow@4640
    72
by (blast_tac (claset() addIs [order_trans]) 1);
nipkow@4640
    73
qed "le_max_iff_disj";
nipkow@4640
    74
wenzelm@5069
    75
Goalw [max_def] "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)";
nipkow@4686
    76
by (Simp_tac 1);
wenzelm@5132
    77
by (cut_facts_tac [linorder_linear] 1);
nipkow@4640
    78
by (blast_tac (claset() addIs [order_trans]) 1);
nipkow@4640
    79
qed "max_le_iff_conj";
nipkow@4640
    80
wenzelm@5069
    81
Goalw [min_def] "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)";
nipkow@4686
    82
by (Simp_tac 1);
wenzelm@5132
    83
by (cut_facts_tac [linorder_linear] 1);
nipkow@4640
    84
by (blast_tac (claset() addIs [order_trans]) 1);
nipkow@4640
    85
qed "le_min_iff_conj";
nipkow@4640
    86
wenzelm@5069
    87
Goalw [min_def] "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)";
nipkow@4686
    88
by (Simp_tac 1);
wenzelm@5132
    89
by (cut_facts_tac [linorder_linear] 1);
nipkow@4640
    90
by (blast_tac (claset() addIs [order_trans]) 1);
nipkow@4640
    91
qed "min_le_iff_disj";
nipkow@4640
    92
nipkow@4640
    93