| author | berghofe | 
| Thu, 03 Apr 2008 17:50:50 +0200 | |
| changeset 26532 | 3fc9730403c1 | 
| parent 26056 | 6a0801279f4c | 
| child 32960 | 69916a850301 | 
| permissions | -rw-r--r-- | 
| 
26056
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1  | 
(* Title: ZF/List  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
2  | 
ID: $Id$  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
3  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
4  | 
Copyright 1994 University of Cambridge  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
5  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
6  | 
*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
7  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
8  | 
header{*Lists in Zermelo-Fraenkel Set Theory*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
9  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
10  | 
theory List_ZF imports Datatype_ZF ArithSimp begin  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
11  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
12  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
13  | 
list :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
14  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
15  | 
datatype  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
16  | 
  "list(A)" = Nil | Cons ("a:A", "l: list(A)")
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
17  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
18  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
19  | 
syntax  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
20  | 
 "[]"        :: i                                       ("[]")
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
21  | 
 "@List"     :: "is => i"                                 ("[(_)]")
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
22  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
23  | 
translations  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
24  | 
"[x, xs]" == "Cons(x, [xs])"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
25  | 
"[x]" == "Cons(x, [])"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
26  | 
"[]" == "Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
27  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
28  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
29  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
30  | 
length :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
31  | 
hd :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
32  | 
tl :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
33  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
34  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
35  | 
"length([]) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
36  | 
"length(Cons(a,l)) = succ(length(l))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
37  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
38  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
39  | 
"hd([]) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
40  | 
"hd(Cons(a,l)) = a"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
41  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
42  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
43  | 
"tl([]) = []"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
44  | 
"tl(Cons(a,l)) = l"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
45  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
46  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
47  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
48  | 
map :: "[i=>i, i] => i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
49  | 
set_of_list :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
50  | 
app :: "[i,i]=>i" (infixr "@" 60)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
51  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
52  | 
(*map is a binding operator -- it applies to meta-level functions, not  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
53  | 
object-level functions. This simplifies the final form of term_rec_conv,  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
54  | 
although complicating its derivation.*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
55  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
56  | 
"map(f,[]) = []"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
57  | 
"map(f,Cons(a,l)) = Cons(f(a), map(f,l))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
58  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
59  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
60  | 
"set_of_list([]) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
61  | 
"set_of_list(Cons(a,l)) = cons(a, set_of_list(l))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
62  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
63  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
64  | 
app_Nil: "[] @ ys = ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
65  | 
app_Cons: "(Cons(a,l)) @ ys = Cons(a, l @ ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
66  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
67  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
68  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
69  | 
rev :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
70  | 
flat :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
71  | 
list_add :: "i=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
72  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
73  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
74  | 
"rev([]) = []"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
75  | 
"rev(Cons(a,l)) = rev(l) @ [a]"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
76  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
77  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
78  | 
"flat([]) = []"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
79  | 
"flat(Cons(l,ls)) = l @ flat(ls)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
80  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
81  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
82  | 
"list_add([]) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
83  | 
"list_add(Cons(a,l)) = a #+ list_add(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
84  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
85  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
86  | 
drop :: "[i,i]=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
87  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
88  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
89  | 
drop_0: "drop(0,l) = l"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
90  | 
drop_succ: "drop(succ(i), l) = tl (drop(i,l))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
91  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
92  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
93  | 
(*** Thanks to Sidi Ehmety for the following ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
94  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
95  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
96  | 
(* Function `take' returns the first n elements of a list *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
97  | 
take :: "[i,i]=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
98  | 
"take(n, as) == list_rec(lam n:nat. [],  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
99  | 
%a l r. lam n:nat. nat_case([], %m. Cons(a, r`m), n), as)`n"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
100  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
101  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
102  | 
nth :: "[i, i]=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
103  | 
  --{*returns the (n+1)th element of a list, or 0 if the
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
104  | 
list is too short.*}  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
105  | 
"nth(n, as) == list_rec(lam n:nat. 0,  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
106  | 
%a l r. lam n:nat. nat_case(a, %m. r`m, n), as) ` n"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
107  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
108  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
109  | 
list_update :: "[i, i, i]=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
110  | 
"list_update(xs, i, v) == list_rec(lam n:nat. Nil,  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
111  | 
%u us vs. lam n:nat. nat_case(Cons(v, us), %m. Cons(u, vs`m), n), xs)`i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
112  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
113  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
114  | 
filter :: "[i=>o, i] => i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
115  | 
upt :: "[i, i] =>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
116  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
117  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
118  | 
"filter(P, Nil) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
119  | 
"filter(P, Cons(x, xs)) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
120  | 
(if P(x) then Cons(x, filter(P, xs)) else filter(P, xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
121  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
122  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
123  | 
"upt(i, 0) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
124  | 
"upt(i, succ(j)) = (if i le j then upt(i, j)@[j] else Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
125  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
126  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
127  | 
min :: "[i,i] =>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
128  | 
"min(x, y) == (if x le y then x else y)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
129  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
130  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
131  | 
max :: "[i, i] =>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
132  | 
"max(x, y) == (if x le y then y else x)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
133  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
134  | 
(*** Aspects of the datatype definition ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
135  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
136  | 
declare list.intros [simp,TC]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
137  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
138  | 
(*An elimination rule, for type-checking*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
139  | 
inductive_cases ConsE: "Cons(a,l) : list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
140  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
141  | 
lemma Cons_type_iff [simp]: "Cons(a,l) \<in> list(A) <-> a \<in> A & l \<in> list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
142  | 
by (blast elim: ConsE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
143  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
144  | 
(*Proving freeness results*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
145  | 
lemma Cons_iff: "Cons(a,l)=Cons(a',l') <-> a=a' & l=l'"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
146  | 
by auto  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
147  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
148  | 
lemma Nil_Cons_iff: "~ Nil=Cons(a,l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
149  | 
by auto  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
150  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
151  | 
lemma list_unfold: "list(A) = {0} + (A * list(A))"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
152  | 
by (blast intro!: list.intros [unfolded list.con_defs]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
153  | 
elim: list.cases [unfolded list.con_defs])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
154  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
155  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
156  | 
(** Lemmas to justify using "list" in other recursive type definitions **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
157  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
158  | 
lemma list_mono: "A<=B ==> list(A) <= list(B)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
159  | 
apply (unfold list.defs )  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
160  | 
apply (rule lfp_mono)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
161  | 
apply (simp_all add: list.bnd_mono)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
162  | 
apply (assumption | rule univ_mono basic_monos)+  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
163  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
164  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
165  | 
(*There is a similar proof by list induction.*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
166  | 
lemma list_univ: "list(univ(A)) <= univ(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
167  | 
apply (unfold list.defs list.con_defs)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
168  | 
apply (rule lfp_lowerbound)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
169  | 
apply (rule_tac [2] A_subset_univ [THEN univ_mono])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
170  | 
apply (blast intro!: zero_in_univ Inl_in_univ Inr_in_univ Pair_in_univ)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
171  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
172  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
173  | 
(*These two theorems justify datatypes involving list(nat), list(A), ...*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
174  | 
lemmas list_subset_univ = subset_trans [OF list_mono list_univ]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
175  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
176  | 
lemma list_into_univ: "[| l: list(A); A <= univ(B) |] ==> l: univ(B)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
177  | 
by (blast intro: list_subset_univ [THEN subsetD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
178  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
179  | 
lemma list_case_type:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
180  | 
"[| l: list(A);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
181  | 
c: C(Nil);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
182  | 
!!x y. [| x: A; y: list(A) |] ==> h(x,y): C(Cons(x,y))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
183  | 
|] ==> list_case(c,h,l) : C(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
184  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
185  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
186  | 
lemma list_0_triv: "list(0) = {Nil}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
187  | 
apply (rule equalityI, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
188  | 
apply (induct_tac x, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
189  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
190  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
191  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
192  | 
(*** List functions ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
193  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
194  | 
lemma tl_type: "l: list(A) ==> tl(l) : list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
195  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
196  | 
apply (simp_all (no_asm_simp) add: list.intros)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
197  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
198  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
199  | 
(** drop **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
200  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
201  | 
lemma drop_Nil [simp]: "i:nat ==> drop(i, Nil) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
202  | 
apply (induct_tac "i")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
203  | 
apply (simp_all (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
204  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
205  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
206  | 
lemma drop_succ_Cons [simp]: "i:nat ==> drop(succ(i), Cons(a,l)) = drop(i,l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
207  | 
apply (rule sym)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
208  | 
apply (induct_tac "i")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
209  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
210  | 
apply (simp (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
211  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
212  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
213  | 
lemma drop_type [simp,TC]: "[| i:nat; l: list(A) |] ==> drop(i,l) : list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
214  | 
apply (induct_tac "i")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
215  | 
apply (simp_all (no_asm_simp) add: tl_type)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
216  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
217  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
218  | 
declare drop_succ [simp del]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
219  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
220  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
221  | 
(** Type checking -- proved by induction, as usual **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
222  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
223  | 
lemma list_rec_type [TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
224  | 
"[| l: list(A);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
225  | 
c: C(Nil);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
226  | 
!!x y r. [| x:A; y: list(A); r: C(y) |] ==> h(x,y,r): C(Cons(x,y))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
227  | 
|] ==> list_rec(c,h,l) : C(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
228  | 
by (induct_tac "l", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
229  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
230  | 
(** map **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
231  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
232  | 
lemma map_type [TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
233  | 
"[| l: list(A); !!x. x: A ==> h(x): B |] ==> map(h,l) : list(B)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
234  | 
apply (simp add: map_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
235  | 
apply (typecheck add: list.intros list_rec_type, blast)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
236  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
237  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
238  | 
lemma map_type2 [TC]: "l: list(A) ==> map(h,l) : list({h(u). u:A})"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
239  | 
apply (erule map_type)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
240  | 
apply (erule RepFunI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
241  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
242  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
243  | 
(** length **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
244  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
245  | 
lemma length_type [TC]: "l: list(A) ==> length(l) : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
246  | 
by (simp add: length_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
247  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
248  | 
lemma lt_length_in_nat:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
249  | 
"[|x < length(xs); xs \<in> list(A)|] ==> x \<in> nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
250  | 
by (frule lt_nat_in_nat, typecheck)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
251  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
252  | 
(** app **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
253  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
254  | 
lemma app_type [TC]: "[| xs: list(A); ys: list(A) |] ==> xs@ys : list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
255  | 
by (simp add: app_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
256  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
257  | 
(** rev **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
258  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
259  | 
lemma rev_type [TC]: "xs: list(A) ==> rev(xs) : list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
260  | 
by (simp add: rev_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
261  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
262  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
263  | 
(** flat **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
264  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
265  | 
lemma flat_type [TC]: "ls: list(list(A)) ==> flat(ls) : list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
266  | 
by (simp add: flat_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
267  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
268  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
269  | 
(** set_of_list **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
270  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
271  | 
lemma set_of_list_type [TC]: "l: list(A) ==> set_of_list(l) : Pow(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
272  | 
apply (unfold set_of_list_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
273  | 
apply (erule list_rec_type, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
274  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
275  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
276  | 
lemma set_of_list_append:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
277  | 
"xs: list(A) ==> set_of_list (xs@ys) = set_of_list(xs) Un set_of_list(ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
278  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
279  | 
apply (simp_all (no_asm_simp) add: Un_cons)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
280  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
281  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
282  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
283  | 
(** list_add **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
284  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
285  | 
lemma list_add_type [TC]: "xs: list(nat) ==> list_add(xs) : nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
286  | 
by (simp add: list_add_list_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
287  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
288  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
289  | 
(*** theorems about map ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
290  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
291  | 
lemma map_ident [simp]: "l: list(A) ==> map(%u. u, l) = l"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
292  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
293  | 
apply (simp_all (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
294  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
295  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
296  | 
lemma map_compose: "l: list(A) ==> map(h, map(j,l)) = map(%u. h(j(u)), l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
297  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
298  | 
apply (simp_all (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
299  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
300  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
301  | 
lemma map_app_distrib: "xs: list(A) ==> map(h, xs@ys) = map(h,xs) @ map(h,ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
302  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
303  | 
apply (simp_all (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
304  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
305  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
306  | 
lemma map_flat: "ls: list(list(A)) ==> map(h, flat(ls)) = flat(map(map(h),ls))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
307  | 
apply (induct_tac "ls")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
308  | 
apply (simp_all (no_asm_simp) add: map_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
309  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
310  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
311  | 
lemma list_rec_map:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
312  | 
"l: list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
313  | 
list_rec(c, d, map(h,l)) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
314  | 
list_rec(c, %x xs r. d(h(x), map(h,xs), r), l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
315  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
316  | 
apply (simp_all (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
317  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
318  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
319  | 
(** theorems about list(Collect(A,P)) -- used in Induct/Term.thy **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
320  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
321  | 
(* c : list(Collect(B,P)) ==> c : list(B) *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
322  | 
lemmas list_CollectD = Collect_subset [THEN list_mono, THEN subsetD, standard]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
323  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
324  | 
lemma map_list_Collect: "l: list({x:A. h(x)=j(x)}) ==> map(h,l) = map(j,l)"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
325  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
326  | 
apply (simp_all (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
327  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
328  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
329  | 
(*** theorems about length ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
330  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
331  | 
lemma length_map [simp]: "xs: list(A) ==> length(map(h,xs)) = length(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
332  | 
by (induct_tac "xs", simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
333  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
334  | 
lemma length_app [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
335  | 
"[| xs: list(A); ys: list(A) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
336  | 
==> length(xs@ys) = length(xs) #+ length(ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
337  | 
by (induct_tac "xs", simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
338  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
339  | 
lemma length_rev [simp]: "xs: list(A) ==> length(rev(xs)) = length(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
340  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
341  | 
apply (simp_all (no_asm_simp) add: length_app)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
342  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
343  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
344  | 
lemma length_flat:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
345  | 
"ls: list(list(A)) ==> length(flat(ls)) = list_add(map(length,ls))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
346  | 
apply (induct_tac "ls")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
347  | 
apply (simp_all (no_asm_simp) add: length_app)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
348  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
349  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
350  | 
(** Length and drop **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
351  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
352  | 
(*Lemma for the inductive step of drop_length*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
353  | 
lemma drop_length_Cons [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
354  | 
"xs: list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
355  | 
\<forall>x. EX z zs. drop(length(xs), Cons(x,xs)) = Cons(z,zs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
356  | 
by (erule list.induct, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
357  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
358  | 
lemma drop_length [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
359  | 
"l: list(A) ==> \<forall>i \<in> length(l). (EX z zs. drop(i,l) = Cons(z,zs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
360  | 
apply (erule list.induct, simp_all, safe)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
361  | 
apply (erule drop_length_Cons)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
362  | 
apply (rule natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
363  | 
apply (erule Ord_trans [OF asm_rl length_type Ord_nat], assumption, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
364  | 
apply (blast intro: succ_in_naturalD length_type)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
365  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
366  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
367  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
368  | 
(*** theorems about app ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
369  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
370  | 
lemma app_right_Nil [simp]: "xs: list(A) ==> xs@Nil=xs"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
371  | 
by (erule list.induct, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
372  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
373  | 
lemma app_assoc: "xs: list(A) ==> (xs@ys)@zs = xs@(ys@zs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
374  | 
by (induct_tac "xs", simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
375  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
376  | 
lemma flat_app_distrib: "ls: list(list(A)) ==> flat(ls@ms) = flat(ls)@flat(ms)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
377  | 
apply (induct_tac "ls")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
378  | 
apply (simp_all (no_asm_simp) add: app_assoc)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
379  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
380  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
381  | 
(*** theorems about rev ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
382  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
383  | 
lemma rev_map_distrib: "l: list(A) ==> rev(map(h,l)) = map(h,rev(l))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
384  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
385  | 
apply (simp_all (no_asm_simp) add: map_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
386  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
387  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
388  | 
(*Simplifier needs the premises as assumptions because rewriting will not  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
389  | 
instantiate the variable ?A in the rules' typing conditions; note that  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
390  | 
rev_type does not instantiate ?A. Only the premises do.  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
391  | 
*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
392  | 
lemma rev_app_distrib:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
393  | 
"[| xs: list(A); ys: list(A) |] ==> rev(xs@ys) = rev(ys)@rev(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
394  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
395  | 
apply (simp_all add: app_assoc)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
396  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
397  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
398  | 
lemma rev_rev_ident [simp]: "l: list(A) ==> rev(rev(l))=l"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
399  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
400  | 
apply (simp_all (no_asm_simp) add: rev_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
401  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
402  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
403  | 
lemma rev_flat: "ls: list(list(A)) ==> rev(flat(ls)) = flat(map(rev,rev(ls)))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
404  | 
apply (induct_tac "ls")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
405  | 
apply (simp_all add: map_app_distrib flat_app_distrib rev_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
406  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
407  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
408  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
409  | 
(*** theorems about list_add ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
410  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
411  | 
lemma list_add_app:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
412  | 
"[| xs: list(nat); ys: list(nat) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
413  | 
==> list_add(xs@ys) = list_add(ys) #+ list_add(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
414  | 
apply (induct_tac "xs", simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
415  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
416  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
417  | 
lemma list_add_rev: "l: list(nat) ==> list_add(rev(l)) = list_add(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
418  | 
apply (induct_tac "l")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
419  | 
apply (simp_all (no_asm_simp) add: list_add_app)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
420  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
421  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
422  | 
lemma list_add_flat:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
423  | 
"ls: list(list(nat)) ==> list_add(flat(ls)) = list_add(map(list_add,ls))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
424  | 
apply (induct_tac "ls")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
425  | 
apply (simp_all (no_asm_simp) add: list_add_app)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
426  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
427  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
428  | 
(** New induction rules **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
429  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
430  | 
lemma list_append_induct [case_names Nil snoc, consumes 1]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
431  | 
"[| l: list(A);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
432  | 
P(Nil);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
433  | 
!!x y. [| x: A; y: list(A); P(y) |] ==> P(y @ [x])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
434  | 
|] ==> P(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
435  | 
apply (subgoal_tac "P(rev(rev(l)))", simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
436  | 
apply (erule rev_type [THEN list.induct], simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
437  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
438  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
439  | 
lemma list_complete_induct_lemma [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
440  | 
assumes ih:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
441  | 
"\<And>l. [| l \<in> list(A);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
442  | 
\<forall>l' \<in> list(A). length(l') < length(l) --> P(l')|]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
443  | 
==> P(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
444  | 
shows "n \<in> nat ==> \<forall>l \<in> list(A). length(l) < n --> P(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
445  | 
apply (induct_tac n, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
446  | 
apply (blast intro: ih elim!: leE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
447  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
448  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
449  | 
theorem list_complete_induct:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
450  | 
"[| l \<in> list(A);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
451  | 
\<And>l. [| l \<in> list(A);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
452  | 
\<forall>l' \<in> list(A). length(l') < length(l) --> P(l')|]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
453  | 
==> P(l)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
454  | 
|] ==> P(l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
455  | 
apply (rule list_complete_induct_lemma [of A])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
456  | 
prefer 4 apply (rule le_refl, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
457  | 
apply blast  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
458  | 
apply simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
459  | 
apply assumption  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
460  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
461  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
462  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
463  | 
(*** Thanks to Sidi Ehmety for these results about min, take, etc. ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
464  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
465  | 
(** min FIXME: replace by Int! **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
466  | 
(* Min theorems are also true for i, j ordinals *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
467  | 
lemma min_sym: "[| i:nat; j:nat |] ==> min(i,j)=min(j,i)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
468  | 
apply (unfold min_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
469  | 
apply (auto dest!: not_lt_imp_le dest: lt_not_sym intro: le_anti_sym)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
470  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
471  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
472  | 
lemma min_type [simp,TC]: "[| i:nat; j:nat |] ==> min(i,j):nat"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
473  | 
by (unfold min_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
474  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
475  | 
lemma min_0 [simp]: "i:nat ==> min(0,i) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
476  | 
apply (unfold min_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
477  | 
apply (auto dest: not_lt_imp_le)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
478  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
479  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
480  | 
lemma min_02 [simp]: "i:nat ==> min(i, 0) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
481  | 
apply (unfold min_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
482  | 
apply (auto dest: not_lt_imp_le)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
483  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
484  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
485  | 
lemma lt_min_iff: "[| i:nat; j:nat; k:nat |] ==> i<min(j,k) <-> i<j & i<k"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
486  | 
apply (unfold min_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
487  | 
apply (auto dest!: not_lt_imp_le intro: lt_trans2 lt_trans)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
488  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
489  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
490  | 
lemma min_succ_succ [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
491  | 
"[| i:nat; j:nat |] ==> min(succ(i), succ(j))= succ(min(i, j))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
492  | 
apply (unfold min_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
493  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
494  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
495  | 
(*** more theorems about lists ***)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
496  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
497  | 
(** filter **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
498  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
499  | 
lemma filter_append [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
500  | 
"xs:list(A) ==> filter(P, xs@ys) = filter(P, xs) @ filter(P, ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
501  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
502  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
503  | 
lemma filter_type [simp,TC]: "xs:list(A) ==> filter(P, xs):list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
504  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
505  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
506  | 
lemma length_filter: "xs:list(A) ==> length(filter(P, xs)) le length(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
507  | 
apply (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
508  | 
apply (rule_tac j = "length (l) " in le_trans)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
509  | 
apply (auto simp add: le_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
510  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
511  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
512  | 
lemma filter_is_subset: "xs:list(A) ==> set_of_list(filter(P,xs)) <= set_of_list(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
513  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
514  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
515  | 
lemma filter_False [simp]: "xs:list(A) ==> filter(%p. False, xs) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
516  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
517  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
518  | 
lemma filter_True [simp]: "xs:list(A) ==> filter(%p. True, xs) = xs"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
519  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
520  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
521  | 
(** length **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
522  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
523  | 
lemma length_is_0_iff [simp]: "xs:list(A) ==> length(xs)=0 <-> xs=Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
524  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
525  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
526  | 
lemma length_is_0_iff2 [simp]: "xs:list(A) ==> 0 = length(xs) <-> xs=Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
527  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
528  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
529  | 
lemma length_tl [simp]: "xs:list(A) ==> length(tl(xs)) = length(xs) #- 1"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
530  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
531  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
532  | 
lemma length_greater_0_iff: "xs:list(A) ==> 0<length(xs) <-> xs ~= Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
533  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
534  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
535  | 
lemma length_succ_iff: "xs:list(A) ==> length(xs)=succ(n) <-> (EX y ys. xs=Cons(y, ys) & length(ys)=n)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
536  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
537  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
538  | 
(** more theorems about append **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
539  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
540  | 
lemma append_is_Nil_iff [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
541  | 
"xs:list(A) ==> (xs@ys = Nil) <-> (xs=Nil & ys = Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
542  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
543  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
544  | 
lemma append_is_Nil_iff2 [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
545  | 
"xs:list(A) ==> (Nil = xs@ys) <-> (xs=Nil & ys = Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
546  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
547  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
548  | 
lemma append_left_is_self_iff [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
549  | 
"xs:list(A) ==> (xs@ys = xs) <-> (ys = Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
550  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
551  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
552  | 
lemma append_left_is_self_iff2 [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
553  | 
"xs:list(A) ==> (xs = xs@ys) <-> (ys = Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
554  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
555  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
556  | 
(*TOO SLOW as a default simprule!*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
557  | 
lemma append_left_is_Nil_iff [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
558  | 
"[| xs:list(A); ys:list(A); zs:list(A) |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
559  | 
length(ys)=length(zs) --> (xs@ys=zs <-> (xs=Nil & ys=zs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
560  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
561  | 
apply (auto simp add: length_app)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
562  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
563  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
564  | 
(*TOO SLOW as a default simprule!*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
565  | 
lemma append_left_is_Nil_iff2 [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
566  | 
"[| xs:list(A); ys:list(A); zs:list(A) |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
567  | 
length(ys)=length(zs) --> (zs=ys@xs <-> (xs=Nil & ys=zs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
568  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
569  | 
apply (auto simp add: length_app)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
570  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
571  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
572  | 
lemma append_eq_append_iff [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
573  | 
"xs:list(A) ==> \<forall>ys \<in> list(A).  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
574  | 
length(xs)=length(ys) --> (xs@us = ys@vs) <-> (xs=ys & us=vs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
575  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
576  | 
apply (simp (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
577  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
578  | 
apply (erule_tac a = ys in list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
579  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
580  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
581  | 
lemma append_eq_append [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
582  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
583  | 
\<forall>ys \<in> list(A). \<forall>us \<in> list(A). \<forall>vs \<in> list(A).  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
584  | 
length(us) = length(vs) --> (xs@us = ys@vs) --> (xs=ys & us=vs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
585  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
586  | 
apply (force simp add: length_app, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
587  | 
apply (erule_tac a = ys in list.cases, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
588  | 
apply (subgoal_tac "Cons (a, l) @ us =vs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
589  | 
apply (drule rev_iffD1 [OF _ append_left_is_Nil_iff], simp_all, blast)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
590  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
591  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
592  | 
lemma append_eq_append_iff2 [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
593  | 
"[| xs:list(A); ys:list(A); us:list(A); vs:list(A); length(us)=length(vs) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
594  | 
==> xs@us = ys@vs <-> (xs=ys & us=vs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
595  | 
apply (rule iffI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
596  | 
apply (rule append_eq_append, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
597  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
598  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
599  | 
lemma append_self_iff [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
600  | 
"[| xs:list(A); ys:list(A); zs:list(A) |] ==> xs@ys=xs@zs <-> ys=zs"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
601  | 
by simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
602  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
603  | 
lemma append_self_iff2 [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
604  | 
"[| xs:list(A); ys:list(A); zs:list(A) |] ==> ys@xs=zs@xs <-> ys=zs"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
605  | 
by simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
606  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
607  | 
(* Can also be proved from append_eq_append_iff2,  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
608  | 
but the proof requires two more hypotheses: x:A and y:A *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
609  | 
lemma append1_eq_iff [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
610  | 
"xs:list(A) ==> \<forall>ys \<in> list(A). xs@[x] = ys@[y] <-> (xs = ys & x=y)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
611  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
612  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
613  | 
apply (erule list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
614  | 
apply simp_all  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
615  | 
txt{*Inductive step*}  
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
616  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
617  | 
apply (erule_tac a=ys in list.cases, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
618  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
619  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
620  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
621  | 
lemma append_right_is_self_iff [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
622  | 
"[| xs:list(A); ys:list(A) |] ==> (xs@ys = ys) <-> (xs=Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
623  | 
by (simp (no_asm_simp) add: append_left_is_Nil_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
624  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
625  | 
lemma append_right_is_self_iff2 [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
626  | 
"[| xs:list(A); ys:list(A) |] ==> (ys = xs@ys) <-> (xs=Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
627  | 
apply (rule iffI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
628  | 
apply (drule sym, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
629  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
630  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
631  | 
lemma hd_append [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
632  | 
"xs:list(A) ==> xs ~= Nil --> hd(xs @ ys) = hd(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
633  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
634  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
635  | 
lemma tl_append [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
636  | 
"xs:list(A) ==> xs~=Nil --> tl(xs @ ys) = tl(xs)@ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
637  | 
by (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
638  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
639  | 
(** rev **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
640  | 
lemma rev_is_Nil_iff [simp]: "xs:list(A) ==> (rev(xs) = Nil <-> xs = Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
641  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
642  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
643  | 
lemma Nil_is_rev_iff [simp]: "xs:list(A) ==> (Nil = rev(xs) <-> xs = Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
644  | 
by (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
645  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
646  | 
lemma rev_is_rev_iff [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
647  | 
"xs:list(A) ==> \<forall>ys \<in> list(A). rev(xs)=rev(ys) <-> xs=ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
648  | 
apply (erule list.induct, force, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
649  | 
apply (erule_tac a = ys in list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
650  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
651  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
652  | 
lemma rev_list_elim [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
653  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
654  | 
(xs=Nil --> P) --> (\<forall>ys \<in> list(A). \<forall>y \<in> A. xs =ys@[y] -->P)-->P"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
655  | 
by (erule list_append_induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
656  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
657  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
658  | 
(** more theorems about drop **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
659  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
660  | 
lemma length_drop [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
661  | 
"n:nat ==> \<forall>xs \<in> list(A). length(drop(n, xs)) = length(xs) #- n"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
662  | 
apply (erule nat_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
663  | 
apply (auto elim: list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
664  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
665  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
666  | 
lemma drop_all [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
667  | 
"n:nat ==> \<forall>xs \<in> list(A). length(xs) le n --> drop(n, xs)=Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
668  | 
apply (erule nat_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
669  | 
apply (auto elim: list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
670  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
671  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
672  | 
lemma drop_append [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
673  | 
"n:nat ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
674  | 
\<forall>xs \<in> list(A). drop(n, xs@ys) = drop(n,xs) @ drop(n #- length(xs), ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
675  | 
apply (induct_tac "n")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
676  | 
apply (auto elim: list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
677  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
678  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
679  | 
lemma drop_drop:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
680  | 
"m:nat ==> \<forall>xs \<in> list(A). \<forall>n \<in> nat. drop(n, drop(m, xs))=drop(n #+ m, xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
681  | 
apply (induct_tac "m")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
682  | 
apply (auto elim: list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
683  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
684  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
685  | 
(** take **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
686  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
687  | 
lemma take_0 [simp]: "xs:list(A) ==> take(0, xs) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
688  | 
apply (unfold take_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
689  | 
apply (erule list.induct, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
690  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
691  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
692  | 
lemma take_succ_Cons [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
693  | 
"n:nat ==> take(succ(n), Cons(a, xs)) = Cons(a, take(n, xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
694  | 
by (simp add: take_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
695  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
696  | 
(* Needed for proving take_all *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
697  | 
lemma take_Nil [simp]: "n:nat ==> take(n, Nil) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
698  | 
by (unfold take_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
699  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
700  | 
lemma take_all [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
701  | 
"n:nat ==> \<forall>xs \<in> list(A). length(xs) le n --> take(n, xs) = xs"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
702  | 
apply (erule nat_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
703  | 
apply (auto elim: list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
704  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
705  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
706  | 
lemma take_type [rule_format,simp,TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
707  | 
"xs:list(A) ==> \<forall>n \<in> nat. take(n, xs):list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
708  | 
apply (erule list.induct, simp, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
709  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
710  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
711  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
712  | 
lemma take_append [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
713  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
714  | 
\<forall>ys \<in> list(A). \<forall>n \<in> nat. take(n, xs @ ys) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
715  | 
take(n, xs) @ take(n #- length(xs), ys)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
716  | 
apply (erule list.induct, simp, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
717  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
718  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
719  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
720  | 
lemma take_take [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
721  | 
"m : nat ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
722  | 
\<forall>xs \<in> list(A). \<forall>n \<in> nat. take(n, take(m,xs))= take(min(n, m), xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
723  | 
apply (induct_tac "m", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
724  | 
apply (erule_tac a = xs in list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
725  | 
apply (auto simp add: take_Nil)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
726  | 
apply (erule_tac n=n in natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
727  | 
apply (auto intro: take_0 take_type)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
728  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
729  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
730  | 
(** nth **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
731  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
732  | 
lemma nth_0 [simp]: "nth(0, Cons(a, l)) = a"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
733  | 
by (simp add: nth_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
734  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
735  | 
lemma nth_Cons [simp]: "n:nat ==> nth(succ(n), Cons(a,l)) = nth(n,l)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
736  | 
by (simp add: nth_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
737  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
738  | 
lemma nth_empty [simp]: "nth(n, Nil) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
739  | 
by (simp add: nth_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
740  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
741  | 
lemma nth_type [rule_format,simp,TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
742  | 
"xs:list(A) ==> \<forall>n. n < length(xs) --> nth(n,xs) : A"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
743  | 
apply (erule list.induct, simp, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
744  | 
apply (subgoal_tac "n \<in> nat")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
745  | 
apply (erule natE, auto dest!: le_in_nat)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
746  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
747  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
748  | 
lemma nth_eq_0 [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
749  | 
"xs:list(A) ==> \<forall>n \<in> nat. length(xs) le n --> nth(n,xs) = 0"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
750  | 
apply (erule list.induct, simp, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
751  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
752  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
753  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
754  | 
lemma nth_append [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
755  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
756  | 
\<forall>n \<in> nat. nth(n, xs @ ys) = (if n < length(xs) then nth(n,xs)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
757  | 
else nth(n #- length(xs), ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
758  | 
apply (induct_tac "xs", simp, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
759  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
760  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
761  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
762  | 
lemma set_of_list_conv_nth:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
763  | 
"xs:list(A)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
764  | 
     ==> set_of_list(xs) = {x:A. EX i:nat. i<length(xs) & x = nth(i,xs)}"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
765  | 
apply (induct_tac "xs", simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
766  | 
apply (rule equalityI, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
767  | 
apply (rule_tac x = 0 in bexI, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
768  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
769  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
770  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
771  | 
(* Other theorems about lists *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
772  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
773  | 
lemma nth_take_lemma [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
774  | 
"k:nat ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
775  | 
\<forall>xs \<in> list(A). (\<forall>ys \<in> list(A). k le length(xs) --> k le length(ys) -->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
776  | 
(\<forall>i \<in> nat. i<k --> nth(i,xs) = nth(i,ys))--> take(k,xs) = take(k,ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
777  | 
apply (induct_tac "k")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
778  | 
apply (simp_all (no_asm_simp) add: lt_succ_eq_0_disj all_conj_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
779  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
780  | 
(*Both lists are non-empty*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
781  | 
apply (erule_tac a=xs in list.cases, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
782  | 
apply (erule_tac a=ys in list.cases, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
783  | 
apply (simp (no_asm_use) )  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
784  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
785  | 
apply (simp (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
786  | 
apply (rule conjI, force)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
787  | 
apply (rename_tac y ys z zs)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
788  | 
apply (drule_tac x = zs and x1 = ys in bspec [THEN bspec], auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
789  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
790  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
791  | 
lemma nth_equalityI [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
792  | 
"[| xs:list(A); ys:list(A); length(xs) = length(ys);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
793  | 
\<forall>i \<in> nat. i < length(xs) --> nth(i,xs) = nth(i,ys) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
794  | 
==> xs = ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
795  | 
apply (subgoal_tac "length (xs) le length (ys) ")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
796  | 
apply (cut_tac k="length(xs)" and xs=xs and ys=ys in nth_take_lemma)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
797  | 
apply (simp_all add: take_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
798  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
799  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
800  | 
(*The famous take-lemma*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
801  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
802  | 
lemma take_equalityI [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
803  | 
"[| xs:list(A); ys:list(A); (\<forall>i \<in> nat. take(i, xs) = take(i,ys)) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
804  | 
==> xs = ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
805  | 
apply (case_tac "length (xs) le length (ys) ")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
806  | 
apply (drule_tac x = "length (ys) " in bspec)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
807  | 
apply (drule_tac [3] not_lt_imp_le)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
808  | 
apply (subgoal_tac [5] "length (ys) le length (xs) ")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
809  | 
apply (rule_tac [6] j = "succ (length (ys))" in le_trans)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
810  | 
apply (rule_tac [6] leI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
811  | 
apply (drule_tac [5] x = "length (xs) " in bspec)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
812  | 
apply (simp_all add: take_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
813  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
814  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
815  | 
lemma nth_drop [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
816  | 
"n:nat ==> \<forall>i \<in> nat. \<forall>xs \<in> list(A). nth(i, drop(n, xs)) = nth(n #+ i, xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
817  | 
apply (induct_tac "n", simp_all, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
818  | 
apply (erule list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
819  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
820  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
821  | 
lemma take_succ [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
822  | 
"xs\<in>list(A)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
823  | 
==> \<forall>i. i < length(xs) --> take(succ(i), xs) = take(i,xs) @ [nth(i, xs)]"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
824  | 
apply (induct_tac "xs", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
825  | 
apply (subgoal_tac "i\<in>nat")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
826  | 
apply (erule natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
827  | 
apply (auto simp add: le_in_nat)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
828  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
829  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
830  | 
lemma take_add [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
831  | 
"[|xs\<in>list(A); j\<in>nat|]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
832  | 
==> \<forall>i\<in>nat. take(i #+ j, xs) = take(i,xs) @ take(j, drop(i,xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
833  | 
apply (induct_tac "xs", simp_all, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
834  | 
apply (erule_tac n = i in natE, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
835  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
836  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
837  | 
lemma length_take:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
838  | 
"l\<in>list(A) ==> \<forall>n\<in>nat. length(take(n,l)) = min(n, length(l))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
839  | 
apply (induct_tac "l", safe, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
840  | 
apply (erule natE, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
841  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
842  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
843  | 
subsection{*The function zip*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
844  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
845  | 
text{*Crafty definition to eliminate a type argument*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
846  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
847  | 
consts  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
848  | 
zip_aux :: "[i,i]=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
849  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
850  | 
primrec (*explicit lambda is required because both arguments of "un" vary*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
851  | 
"zip_aux(B,[]) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
852  | 
(\<lambda>ys \<in> list(B). list_case([], %y l. [], ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
853  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
854  | 
"zip_aux(B,Cons(x,l)) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
855  | 
(\<lambda>ys \<in> list(B).  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
856  | 
list_case(Nil, %y zs. Cons(<x,y>, zip_aux(B,l)`zs), ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
857  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
858  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
859  | 
zip :: "[i, i]=>i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
860  | 
"zip(xs, ys) == zip_aux(set_of_list(ys),xs)`ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
861  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
862  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
863  | 
(* zip equations *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
864  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
865  | 
lemma list_on_set_of_list: "xs \<in> list(A) ==> xs \<in> list(set_of_list(xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
866  | 
apply (induct_tac xs, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
867  | 
apply (blast intro: list_mono [THEN subsetD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
868  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
869  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
870  | 
lemma zip_Nil [simp]: "ys:list(A) ==> zip(Nil, ys)=Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
871  | 
apply (simp add: zip_def list_on_set_of_list [of _ A])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
872  | 
apply (erule list.cases, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
873  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
874  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
875  | 
lemma zip_Nil2 [simp]: "xs:list(A) ==> zip(xs, Nil)=Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
876  | 
apply (simp add: zip_def list_on_set_of_list [of _ A])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
877  | 
apply (erule list.cases, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
878  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
879  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
880  | 
lemma zip_aux_unique [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
881  | 
"[|B<=C; xs \<in> list(A)|]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
882  | 
==> \<forall>ys \<in> list(B). zip_aux(C,xs) ` ys = zip_aux(B,xs) ` ys"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
883  | 
apply (induct_tac xs)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
884  | 
apply simp_all  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
885  | 
apply (blast intro: list_mono [THEN subsetD], clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
886  | 
apply (erule_tac a=ys in list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
887  | 
apply (blast intro: list_mono [THEN subsetD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
888  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
889  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
890  | 
lemma zip_Cons_Cons [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
891  | 
"[| xs:list(A); ys:list(B); x:A; y:B |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
892  | 
zip(Cons(x,xs), Cons(y, ys)) = Cons(<x,y>, zip(xs, ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
893  | 
apply (simp add: zip_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
894  | 
apply (rule zip_aux_unique, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
895  | 
apply (simp add: list_on_set_of_list [of _ B])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
896  | 
apply (blast intro: list_on_set_of_list list_mono [THEN subsetD])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
897  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
898  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
899  | 
lemma zip_type [rule_format,simp,TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
900  | 
"xs:list(A) ==> \<forall>ys \<in> list(B). zip(xs, ys):list(A*B)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
901  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
902  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
903  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
904  | 
apply (erule_tac a = ys in list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
905  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
906  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
907  | 
(* zip length *)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
908  | 
lemma length_zip [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
909  | 
"xs:list(A) ==> \<forall>ys \<in> list(B). length(zip(xs,ys)) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
910  | 
min(length(xs), length(ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
911  | 
apply (unfold min_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
912  | 
apply (induct_tac "xs", simp_all, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
913  | 
apply (erule_tac a = ys in list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
914  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
915  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
916  | 
lemma zip_append1 [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
917  | 
"[| ys:list(A); zs:list(B) |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
918  | 
\<forall>xs \<in> list(A). zip(xs @ ys, zs) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
919  | 
zip(xs, take(length(xs), zs)) @ zip(ys, drop(length(xs),zs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
920  | 
apply (induct_tac "zs", force, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
921  | 
apply (erule_tac a = xs in list.cases, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
922  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
923  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
924  | 
lemma zip_append2 [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
925  | 
"[| xs:list(A); zs:list(B) |] ==> \<forall>ys \<in> list(B). zip(xs, ys@zs) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
926  | 
zip(take(length(ys), xs), ys) @ zip(drop(length(ys), xs), zs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
927  | 
apply (induct_tac "xs", force, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
928  | 
apply (erule_tac a = ys in list.cases, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
929  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
930  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
931  | 
lemma zip_append [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
932  | 
"[| length(xs) = length(us); length(ys) = length(vs);  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
933  | 
xs:list(A); us:list(B); ys:list(A); vs:list(B) |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
934  | 
==> zip(xs@ys,us@vs) = zip(xs, us) @ zip(ys, vs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
935  | 
by (simp (no_asm_simp) add: zip_append1 drop_append diff_self_eq_0)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
936  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
937  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
938  | 
lemma zip_rev [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
939  | 
"ys:list(B) ==> \<forall>xs \<in> list(A).  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
940  | 
length(xs) = length(ys) --> zip(rev(xs), rev(ys)) = rev(zip(xs, ys))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
941  | 
apply (induct_tac "ys", force, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
942  | 
apply (erule_tac a = xs in list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
943  | 
apply (auto simp add: length_rev)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
944  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
945  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
946  | 
lemma nth_zip [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
947  | 
"ys:list(B) ==> \<forall>i \<in> nat. \<forall>xs \<in> list(A).  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
948  | 
i < length(xs) --> i < length(ys) -->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
949  | 
nth(i,zip(xs, ys)) = <nth(i,xs),nth(i, ys)>"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
950  | 
apply (induct_tac "ys", force, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
951  | 
apply (erule_tac a = xs in list.cases, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
952  | 
apply (auto elim: natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
953  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
954  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
955  | 
lemma set_of_list_zip [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
956  | 
"[| xs:list(A); ys:list(B); i:nat |]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
957  | 
==> set_of_list(zip(xs, ys)) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
958  | 
          {<x, y>:A*B. EX i:nat. i < min(length(xs), length(ys))
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
959  | 
& x = nth(i, xs) & y = nth(i, ys)}"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
960  | 
by (force intro!: Collect_cong simp add: lt_min_iff set_of_list_conv_nth)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
961  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
962  | 
(** list_update **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
963  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
964  | 
lemma list_update_Nil [simp]: "i:nat ==>list_update(Nil, i, v) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
965  | 
by (unfold list_update_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
966  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
967  | 
lemma list_update_Cons_0 [simp]: "list_update(Cons(x, xs), 0, v)= Cons(v, xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
968  | 
by (unfold list_update_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
969  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
970  | 
lemma list_update_Cons_succ [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
971  | 
"n:nat ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
972  | 
list_update(Cons(x, xs), succ(n), v)= Cons(x, list_update(xs, n, v))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
973  | 
apply (unfold list_update_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
974  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
975  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
976  | 
lemma list_update_type [rule_format,simp,TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
977  | 
"[| xs:list(A); v:A |] ==> \<forall>n \<in> nat. list_update(xs, n, v):list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
978  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
979  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
980  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
981  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
982  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
983  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
984  | 
lemma length_list_update [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
985  | 
"xs:list(A) ==> \<forall>i \<in> nat. length(list_update(xs, i, v))=length(xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
986  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
987  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
988  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
989  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
990  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
991  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
992  | 
lemma nth_list_update [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
993  | 
"[| xs:list(A) |] ==> \<forall>i \<in> nat. \<forall>j \<in> nat. i < length(xs) -->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
994  | 
nth(j, list_update(xs, i, x)) = (if i=j then x else nth(j, xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
995  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
996  | 
apply simp_all  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
997  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
998  | 
apply (rename_tac i j)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
999  | 
apply (erule_tac n=i in natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1000  | 
apply (erule_tac [2] n=j in natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1001  | 
apply (erule_tac n=j in natE, simp_all, force)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1002  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1003  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1004  | 
lemma nth_list_update_eq [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1005  | 
"[| i < length(xs); xs:list(A) |] ==> nth(i, list_update(xs, i,x)) = x"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1006  | 
by (simp (no_asm_simp) add: lt_length_in_nat nth_list_update)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1007  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1008  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1009  | 
lemma nth_list_update_neq [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1010  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1011  | 
\<forall>i \<in> nat. \<forall>j \<in> nat. i ~= j --> nth(j, list_update(xs,i,x)) = nth(j,xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1012  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1013  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1014  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1015  | 
apply (erule natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1016  | 
apply (erule_tac [2] natE, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1017  | 
apply (erule natE, simp_all)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1018  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1019  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1020  | 
lemma list_update_overwrite [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1021  | 
"xs:list(A) ==> \<forall>i \<in> nat. i < length(xs)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1022  | 
--> list_update(list_update(xs, i, x), i, y) = list_update(xs, i,y)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1023  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1024  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1025  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1026  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1027  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1028  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1029  | 
lemma list_update_same_conv [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1030  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1031  | 
\<forall>i \<in> nat. i < length(xs) -->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1032  | 
(list_update(xs, i, x) = xs) <-> (nth(i, xs) = x)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1033  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1034  | 
apply (simp (no_asm))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1035  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1036  | 
apply (erule natE, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1037  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1038  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1039  | 
lemma update_zip [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1040  | 
"ys:list(B) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1041  | 
\<forall>i \<in> nat. \<forall>xy \<in> A*B. \<forall>xs \<in> list(A).  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1042  | 
length(xs) = length(ys) -->  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1043  | 
list_update(zip(xs, ys), i, xy) = zip(list_update(xs, i, fst(xy)),  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1044  | 
list_update(ys, i, snd(xy)))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1045  | 
apply (induct_tac "ys")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1046  | 
apply auto  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1047  | 
apply (erule_tac a = xs in list.cases)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1048  | 
apply (auto elim: natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1049  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1050  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1051  | 
lemma set_update_subset_cons [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1052  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1053  | 
\<forall>i \<in> nat. set_of_list(list_update(xs, i, x)) <= cons(x, set_of_list(xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1054  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1055  | 
apply simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1056  | 
apply (rule ballI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1057  | 
apply (erule natE, simp_all, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1058  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1059  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1060  | 
lemma set_of_list_update_subsetI:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1061  | 
"[| set_of_list(xs) <= A; xs:list(A); x:A; i:nat|]  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1062  | 
==> set_of_list(list_update(xs, i,x)) <= A"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1063  | 
apply (rule subset_trans)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1064  | 
apply (rule set_update_subset_cons, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1065  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1066  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1067  | 
(** upt **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1068  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1069  | 
lemma upt_rec:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1070  | 
"j:nat ==> upt(i,j) = (if i<j then Cons(i, upt(succ(i), j)) else Nil)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1071  | 
apply (induct_tac "j", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1072  | 
apply (drule not_lt_imp_le)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1073  | 
apply (auto simp: lt_Ord intro: le_anti_sym)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1074  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1075  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1076  | 
lemma upt_conv_Nil [simp]: "[| j le i; j:nat |] ==> upt(i,j) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1077  | 
apply (subst upt_rec, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1078  | 
apply (auto simp add: le_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1079  | 
apply (drule lt_asym [THEN notE], auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1080  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1081  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1082  | 
(*Only needed if upt_Suc is deleted from the simpset*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1083  | 
lemma upt_succ_append:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1084  | 
"[| i le j; j:nat |] ==> upt(i,succ(j)) = upt(i, j)@[j]"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1085  | 
by simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1086  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1087  | 
lemma upt_conv_Cons:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1088  | 
"[| i<j; j:nat |] ==> upt(i,j) = Cons(i,upt(succ(i),j))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1089  | 
apply (rule trans)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1090  | 
apply (rule upt_rec, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1091  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1092  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1093  | 
lemma upt_type [simp,TC]: "j:nat ==> upt(i,j):list(nat)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1094  | 
by (induct_tac "j", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1095  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1096  | 
(*LOOPS as a simprule, since j<=j*)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1097  | 
lemma upt_add_eq_append:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1098  | 
"[| i le j; j:nat; k:nat |] ==> upt(i, j #+k) = upt(i,j)@upt(j,j#+k)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1099  | 
apply (induct_tac "k")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1100  | 
apply (auto simp add: app_assoc app_type)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1101  | 
apply (rule_tac j = j in le_trans, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1102  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1103  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1104  | 
lemma length_upt [simp]: "[| i:nat; j:nat |] ==>length(upt(i,j)) = j #- i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1105  | 
apply (induct_tac "j")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1106  | 
apply (rule_tac [2] sym)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1107  | 
apply (auto dest!: not_lt_imp_le simp add: diff_succ diff_is_0_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1108  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1109  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1110  | 
lemma nth_upt [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1111  | 
"[| i:nat; j:nat; k:nat |] ==> i #+ k < j --> nth(k, upt(i,j)) = i #+ k"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1112  | 
apply (induct_tac "j", simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1113  | 
apply (simp add: nth_append le_iff)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1114  | 
apply (auto dest!: not_lt_imp_le  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1115  | 
simp add: nth_append less_diff_conv add_commute)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1116  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1117  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1118  | 
lemma take_upt [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1119  | 
"[| m:nat; n:nat |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1120  | 
\<forall>i \<in> nat. i #+ m le n --> take(m, upt(i,n)) = upt(i,i#+m)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1121  | 
apply (induct_tac "m")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1122  | 
apply (simp (no_asm_simp) add: take_0)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1123  | 
apply clarify  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1124  | 
apply (subst upt_rec, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1125  | 
apply (rule sym)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1126  | 
apply (subst upt_rec, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1127  | 
apply (simp_all del: upt.simps)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1128  | 
apply (rule_tac j = "succ (i #+ x) " in lt_trans2)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1129  | 
apply auto  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1130  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1131  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1132  | 
lemma map_succ_upt:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1133  | 
"[| m:nat; n:nat |] ==> map(succ, upt(m,n))= upt(succ(m), succ(n))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1134  | 
apply (induct_tac "n")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1135  | 
apply (auto simp add: map_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1136  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1137  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1138  | 
lemma nth_map [rule_format,simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1139  | 
"xs:list(A) ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1140  | 
\<forall>n \<in> nat. n < length(xs) --> nth(n, map(f, xs)) = f(nth(n, xs))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1141  | 
apply (induct_tac "xs", simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1142  | 
apply (rule ballI)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1143  | 
apply (induct_tac "n", auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1144  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1145  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1146  | 
lemma nth_map_upt [rule_format]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1147  | 
"[| m:nat; n:nat |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1148  | 
\<forall>i \<in> nat. i < n #- m --> nth(i, map(f, upt(m,n))) = f(m #+ i)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1149  | 
apply (rule_tac n = m and m = n in diff_induct, typecheck, simp, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1150  | 
apply (subst map_succ_upt [symmetric], simp_all, clarify)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1151  | 
apply (subgoal_tac "i < length (upt (0, x))")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1152  | 
prefer 2  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1153  | 
apply (simp add: less_diff_conv)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1154  | 
apply (rule_tac j = "succ (i #+ y) " in lt_trans2)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1155  | 
apply simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1156  | 
apply simp  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1157  | 
apply (subgoal_tac "i < length (upt (y, x))")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1158  | 
apply (simp_all add: add_commute less_diff_conv)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1159  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1160  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1161  | 
(** sublist (a generalization of nth to sets) **)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1162  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1163  | 
definition  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1164  | 
sublist :: "[i, i] => i" where  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1165  | 
"sublist(xs, A)==  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1166  | 
map(fst, (filter(%p. snd(p): A, zip(xs, upt(0,length(xs))))))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1167  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1168  | 
lemma sublist_0 [simp]: "xs:list(A) ==>sublist(xs, 0) =Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1169  | 
by (unfold sublist_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1170  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1171  | 
lemma sublist_Nil [simp]: "sublist(Nil, A) = Nil"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1172  | 
by (unfold sublist_def, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1173  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1174  | 
lemma sublist_shift_lemma:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1175  | 
"[| xs:list(B); i:nat |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1176  | 
map(fst, filter(%p. snd(p):A, zip(xs, upt(i,i #+ length(xs))))) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1177  | 
map(fst, filter(%p. snd(p):nat & snd(p) #+ i:A, zip(xs,upt(0,length(xs)))))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1178  | 
apply (erule list_append_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1179  | 
apply (simp (no_asm_simp))  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1180  | 
apply (auto simp add: add_commute length_app filter_append map_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1181  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1182  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1183  | 
lemma sublist_type [simp,TC]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1184  | 
"xs:list(B) ==> sublist(xs, A):list(B)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1185  | 
apply (unfold sublist_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1186  | 
apply (induct_tac "xs")  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1187  | 
apply (auto simp add: filter_append map_app_distrib)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1188  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1189  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1190  | 
lemma upt_add_eq_append2:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1191  | 
"[| i:nat; j:nat |] ==> upt(0, i #+ j) = upt(0, i) @ upt(i, i #+ j)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1192  | 
by (simp add: upt_add_eq_append [of 0] nat_0_le)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1193  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1194  | 
lemma sublist_append:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1195  | 
"[| xs:list(B); ys:list(B) |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1196  | 
  sublist(xs@ys, A) = sublist(xs, A) @ sublist(ys, {j:nat. j #+ length(xs): A})"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1197  | 
apply (unfold sublist_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1198  | 
apply (erule_tac l = ys in list_append_induct, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1199  | 
apply (simp (no_asm_simp) add: upt_add_eq_append2 app_assoc [symmetric])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1200  | 
apply (auto simp add: sublist_shift_lemma length_type map_app_distrib app_assoc)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1201  | 
apply (simp_all add: add_commute)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1202  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1203  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1204  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1205  | 
lemma sublist_Cons:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1206  | 
"[| xs:list(B); x:B |] ==>  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1207  | 
sublist(Cons(x, xs), A) =  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1208  | 
      (if 0:A then [x] else []) @ sublist(xs, {j:nat. succ(j) : A})"
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1209  | 
apply (erule_tac l = xs in list_append_induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1210  | 
apply (simp (no_asm_simp) add: sublist_def)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1211  | 
apply (simp del: app_Cons add: app_Cons [symmetric] sublist_append, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1212  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1213  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1214  | 
lemma sublist_singleton [simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1215  | 
"sublist([x], A) = (if 0 : A then [x] else [])"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1216  | 
by (simp add: sublist_Cons)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1217  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1218  | 
lemma sublist_upt_eq_take [rule_format, simp]:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1219  | 
"xs:list(A) ==> ALL n:nat. sublist(xs,n) = take(n,xs)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1220  | 
apply (erule list.induct, simp)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1221  | 
apply (clarify );  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1222  | 
apply (erule natE)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1223  | 
apply (simp_all add: nat_eq_Collect_lt Ord_mem_iff_lt sublist_Cons)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1224  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1225  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1226  | 
lemma sublist_Int_eq:  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1227  | 
"xs : list(B) ==> sublist(xs, A \<inter> nat) = sublist(xs, A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1228  | 
apply (erule list.induct)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1229  | 
apply (simp_all add: sublist_Cons)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1230  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1231  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1232  | 
text{*Repetition of a List Element*}
 | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1233  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1234  | 
consts repeat :: "[i,i]=>i"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1235  | 
primrec  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1236  | 
"repeat(a,0) = []"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1237  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1238  | 
"repeat(a,succ(n)) = Cons(a,repeat(a,n))"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1239  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1240  | 
lemma length_repeat: "n \<in> nat ==> length(repeat(a,n)) = n"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1241  | 
by (induct_tac n, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1242  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1243  | 
lemma repeat_succ_app: "n \<in> nat ==> repeat(a,succ(n)) = repeat(a,n) @ [a]"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1244  | 
apply (induct_tac n)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1245  | 
apply (simp_all del: app_Cons add: app_Cons [symmetric])  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1246  | 
done  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1247  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1248  | 
lemma repeat_type [TC]: "[|a \<in> A; n \<in> nat|] ==> repeat(a,n) \<in> list(A)"  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1249  | 
by (induct_tac n, auto)  | 
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1250  | 
|
| 
 
6a0801279f4c
Made theory names in ZF disjoint from HOL theory names to allow loading both developments
 
krauss 
parents:  
diff
changeset
 | 
1251  | 
end  |