src/HOL/Library/List_lexord.thy
changeset 15737 c7e522520910
child 17200 3a4d03d1a31b
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Library/List_lexord.thy	Fri Apr 15 14:14:24 2005 +0200
     1.3 @@ -0,0 +1,53 @@
     1.4 +(*  Title:      HOL/Library/List_lexord.thy
     1.5 +    ID:         $Id$
     1.6 +    Author:     Norbert Voelker
     1.7 +*)
     1.8 +
     1.9 +header {* Instantiation of order classes for lexord on lists *}
    1.10 +
    1.11 +theory List_lexord
    1.12 +imports Main
    1.13 +begin
    1.14 +
    1.15 +instance list :: (ord) ord ..
    1.16 +defs(overloaded)
    1.17 +  list_le_def:  "(xs::('a::ord) list) \<le> ys \<equiv> (xs < ys \<or> xs = ys)" 
    1.18 +  list_less_def: "(xs::('a::ord) list) < ys \<equiv> (xs,ys) \<in> lexord {(u,v). u < v}"
    1.19 +
    1.20 +lemmas list_ord_defs = list_less_def list_le_def
    1.21 +
    1.22 +instance list::(order)order
    1.23 +  apply (intro_classes, unfold list_ord_defs)
    1.24 +  apply (rule disjI2, safe)
    1.25 +  apply (blast intro: lexord_trans transI order_less_trans)
    1.26 +  apply (rule_tac r1 = "{(a::'a,b). a < b}" in lexord_irreflexive [THEN notE])
    1.27 +  apply simp
    1.28 +  apply (blast intro: lexord_trans transI order_less_trans)
    1.29 +  apply (rule_tac r1 = "{(a::'a,b). a < b}" in lexord_irreflexive [THEN notE])
    1.30 +  apply simp
    1.31 +  by assumption
    1.32 +
    1.33 +instance list::(linorder)linorder
    1.34 +  apply (intro_classes, unfold list_le_def list_less_def, safe)
    1.35 +  apply (cut_tac x="x" and y="y" and  r = "{(a,b). a < b}"  in lexord_linear)
    1.36 +  by (force, simp)
    1.37 +
    1.38 +lemma not_less_Nil[simp]: "~(x < [])";
    1.39 +  by (unfold list_less_def, simp);
    1.40 +
    1.41 +lemma Nil_less_Cons[simp]: "[] < a # x";
    1.42 +  by (unfold list_less_def, simp);
    1.43 +
    1.44 +lemma Cons_less_Cons[simp]: "(a # x < b # y) = (a < b | a = b & x < y)";
    1.45 +  by (unfold list_less_def, simp);
    1.46 +
    1.47 +lemma le_Nil[simp]: "(x <= [])   = (x = [])";
    1.48 +  by (unfold list_ord_defs, case_tac x, auto);
    1.49 +
    1.50 +lemma Nil_le_Cons[simp]: "([] <= x)";
    1.51 +  by (unfold list_ord_defs, case_tac x, auto);
    1.52 +
    1.53 +lemma Cons_le_Cons[simp]: "(a # x <= b # y) = (a < b | a = b & x <= y)";
    1.54 +  by (unfold list_ord_defs, auto);
    1.55 +
    1.56 +end
    1.57 \ No newline at end of file