src/HOL/Library/List_lexord.thy
author paulson
Tue Jun 28 15:27:45 2005 +0200 (2005-06-28)
changeset 16587 b34c8aa657a5
parent 15737 c7e522520910
child 17200 3a4d03d1a31b
permissions -rw-r--r--
Constant "If" is now local
nipkow@15737
     1
(*  Title:      HOL/Library/List_lexord.thy
nipkow@15737
     2
    ID:         $Id$
nipkow@15737
     3
    Author:     Norbert Voelker
nipkow@15737
     4
*)
nipkow@15737
     5
nipkow@15737
     6
header {* Instantiation of order classes for lexord on lists *}
nipkow@15737
     7
nipkow@15737
     8
theory List_lexord
nipkow@15737
     9
imports Main
nipkow@15737
    10
begin
nipkow@15737
    11
nipkow@15737
    12
instance list :: (ord) ord ..
nipkow@15737
    13
defs(overloaded)
nipkow@15737
    14
  list_le_def:  "(xs::('a::ord) list) \<le> ys \<equiv> (xs < ys \<or> xs = ys)" 
nipkow@15737
    15
  list_less_def: "(xs::('a::ord) list) < ys \<equiv> (xs,ys) \<in> lexord {(u,v). u < v}"
nipkow@15737
    16
nipkow@15737
    17
lemmas list_ord_defs = list_less_def list_le_def
nipkow@15737
    18
nipkow@15737
    19
instance list::(order)order
nipkow@15737
    20
  apply (intro_classes, unfold list_ord_defs)
nipkow@15737
    21
  apply (rule disjI2, safe)
nipkow@15737
    22
  apply (blast intro: lexord_trans transI order_less_trans)
nipkow@15737
    23
  apply (rule_tac r1 = "{(a::'a,b). a < b}" in lexord_irreflexive [THEN notE])
nipkow@15737
    24
  apply simp
nipkow@15737
    25
  apply (blast intro: lexord_trans transI order_less_trans)
nipkow@15737
    26
  apply (rule_tac r1 = "{(a::'a,b). a < b}" in lexord_irreflexive [THEN notE])
nipkow@15737
    27
  apply simp
nipkow@15737
    28
  by assumption
nipkow@15737
    29
nipkow@15737
    30
instance list::(linorder)linorder
nipkow@15737
    31
  apply (intro_classes, unfold list_le_def list_less_def, safe)
nipkow@15737
    32
  apply (cut_tac x="x" and y="y" and  r = "{(a,b). a < b}"  in lexord_linear)
nipkow@15737
    33
  by (force, simp)
nipkow@15737
    34
nipkow@15737
    35
lemma not_less_Nil[simp]: "~(x < [])";
nipkow@15737
    36
  by (unfold list_less_def, simp);
nipkow@15737
    37
nipkow@15737
    38
lemma Nil_less_Cons[simp]: "[] < a # x";
nipkow@15737
    39
  by (unfold list_less_def, simp);
nipkow@15737
    40
nipkow@15737
    41
lemma Cons_less_Cons[simp]: "(a # x < b # y) = (a < b | a = b & x < y)";
nipkow@15737
    42
  by (unfold list_less_def, simp);
nipkow@15737
    43
nipkow@15737
    44
lemma le_Nil[simp]: "(x <= [])   = (x = [])";
nipkow@15737
    45
  by (unfold list_ord_defs, case_tac x, auto);
nipkow@15737
    46
nipkow@15737
    47
lemma Nil_le_Cons[simp]: "([] <= x)";
nipkow@15737
    48
  by (unfold list_ord_defs, case_tac x, auto);
nipkow@15737
    49
nipkow@15737
    50
lemma Cons_le_Cons[simp]: "(a # x <= b # y) = (a < b | a = b & x <= y)";
nipkow@15737
    51
  by (unfold list_ord_defs, auto);
nipkow@15737
    52
nipkow@15737
    53
end