src/HOL/ex/Sorting.thy
 author obua Mon Apr 10 16:00:34 2006 +0200 (2006-04-10) changeset 19404 9bf2cdc9e8e8 parent 15815 62854cac5410 child 19736 d8d0f8f51d69 permissions -rw-r--r--
Moved stuff from Ring_and_Field to Matrix
```     1 (*  Title:      HOL/ex/sorting.thy
```
```     2     ID:         \$Id\$
```
```     3     Author:     Tobias Nipkow
```
```     4     Copyright   1994 TU Muenchen
```
```     5 *)
```
```     6
```
```     7 header{*Sorting: Basic Theory*}
```
```     8
```
```     9 theory Sorting
```
```    10 imports Main Multiset
```
```    11 begin
```
```    12
```
```    13 consts
```
```    14   sorted1:: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool"
```
```    15   sorted :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool"
```
```    16
```
```    17 primrec
```
```    18   "sorted1 le [] = True"
```
```    19   "sorted1 le (x#xs) = ((case xs of [] => True | y#ys => le x y) &
```
```    20                         sorted1 le xs)"
```
```    21
```
```    22 primrec
```
```    23   "sorted le [] = True"
```
```    24   "sorted le (x#xs) = ((\<forall>y \<in> set xs. le x y) & sorted le xs)"
```
```    25
```
```    26
```
```    27 constdefs
```
```    28   total  :: "('a \<Rightarrow> 'a \<Rightarrow> bool) => bool"
```
```    29    "total r == (\<forall>x y. r x y | r y x)"
```
```    30
```
```    31   transf :: "('a \<Rightarrow> 'a \<Rightarrow> bool) => bool"
```
```    32    "transf f == (\<forall>x y z. f x y & f y z --> f x z)"
```
```    33
```
```    34
```
```    35
```
```    36 (* Equivalence of two definitions of `sorted' *)
```
```    37
```
```    38 lemma sorted1_is_sorted: "transf(le) ==> sorted1 le xs = sorted le xs";
```
```    39 apply(induct xs)
```
```    40  apply simp
```
```    41 apply(simp split: list.split)
```
```    42 apply(unfold transf_def);
```
```    43 apply(blast)
```
```    44 done
```
```    45
```
```    46 lemma sorted_append [simp]:
```
```    47  "sorted le (xs@ys) =
```
```    48   (sorted le xs & sorted le ys & (\<forall>x \<in> set xs. \<forall>y \<in> set ys. le x y))"
```
```    49 by (induct xs, auto)
```
```    50
```
```    51 end
```