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