*** empty log message ***
authornipkow
Mon May 13 15:27:28 2002 +0200 (2002-05-13)
changeset 1314559bc43b51aa2
parent 13144 c5ae1522fb82
child 13146 f43153b63361
*** empty log message ***
src/HOL/Lex/RegExp2NA.ML
src/HOL/Lex/RegExp2NAe.ML
src/HOL/List.thy
src/HOL/UNITY/Comp/AllocBase.ML
src/HOL/UNITY/GenPrefix.ML
     1.1 --- a/src/HOL/Lex/RegExp2NA.ML	Mon May 13 13:22:15 2002 +0200
     1.2 +++ b/src/HOL/Lex/RegExp2NA.ML	Mon May 13 15:27:28 2002 +0200
     1.3 @@ -348,7 +348,7 @@
     1.4  \     (? us v. w = concat us @ v & \
     1.5  \              (!u:set us. accepts A u) & \
     1.6  \              (start A,r) : steps A v)";
     1.7 -by (rev_induct_tac "w" 1);
     1.8 +by (res_inst_tac [("xs","w")] rev_induct 1);
     1.9   by (Simp_tac 1);
    1.10   by (res_inst_tac [("x","[]")] exI 1);
    1.11   by (Simp_tac 1);
    1.12 @@ -368,7 +368,7 @@
    1.13  Goal
    1.14   "us ~= [] --> (!u : set us. accepts A u) --> accepts (plus A) (concat us)";
    1.15  by (simp_tac (simpset() addsimps [accepts_conv_steps]) 1);
    1.16 -by (rev_induct_tac "us" 1);
    1.17 +by (res_inst_tac [("xs","us")] rev_induct 1);
    1.18   by (Simp_tac 1);
    1.19  by (rename_tac "u us" 1);
    1.20  by (Simp_tac 1);
     2.1 --- a/src/HOL/Lex/RegExp2NAe.ML	Mon May 13 13:22:15 2002 +0200
     2.2 +++ b/src/HOL/Lex/RegExp2NAe.ML	Mon May 13 15:27:28 2002 +0200
     2.3 @@ -500,7 +500,7 @@
     2.4  \ (? us v. w = concat us @ v & \
     2.5  \             (!u:set us. accepts A u) & \
     2.6  \             (? r. (start A,r) : steps A v & rr = True#r))";
     2.7 -by (rev_induct_tac "w" 1);
     2.8 +by (res_inst_tac [("xs","w")] rev_induct 1);
     2.9   by (Asm_full_simp_tac 1);
    2.10   by (Clarify_tac 1);
    2.11   by (res_inst_tac [("x","[]")] exI 1);
     3.1 --- a/src/HOL/List.thy	Mon May 13 13:22:15 2002 +0200
     3.2 +++ b/src/HOL/List.thy	Mon May 13 15:27:28 2002 +0200
     3.3 @@ -1,7 +1,7 @@
     3.4 -(*  Title:      HOL/List.thy
     3.5 -    ID:         $Id$
     3.6 -    Author:     Tobias Nipkow
     3.7 -    Copyright   1994 TU Muenchen
     3.8 +(*Title:HOL/List.thy
     3.9 +ID: $Id$
    3.10 +Author: Tobias Nipkow
    3.11 +Copyright 1994 TU Muenchen
    3.12  *)
    3.13  
    3.14  header {* The datatype of finite lists *}
    3.15 @@ -9,171 +9,171 @@
    3.16  theory List = PreList:
    3.17  
    3.18  datatype 'a list =
    3.19 -    Nil    ("[]")
    3.20 -  | Cons 'a  "'a list"    (infixr "#" 65)
    3.21 +Nil("[]")
    3.22 +| Cons 'a"'a list"(infixr "#" 65)
    3.23  
    3.24  consts
    3.25 -  "@"         :: "'a list => 'a list => 'a list"            (infixr 65)
    3.26 -  filter      :: "('a => bool) => 'a list => 'a list"
    3.27 -  concat      :: "'a list list => 'a list"
    3.28 -  foldl       :: "('b => 'a => 'b) => 'b => 'a list => 'b"
    3.29 -  foldr       :: "('a => 'b => 'b) => 'a list => 'b => 'b"
    3.30 -  hd          :: "'a list => 'a"
    3.31 -  tl          :: "'a list => 'a list"
    3.32 -  last        :: "'a list => 'a"
    3.33 -  butlast     :: "'a list => 'a list"
    3.34 -  set         :: "'a list => 'a set"
    3.35 -  list_all    :: "('a => bool) => ('a list => bool)"
    3.36 -  list_all2   :: "('a => 'b => bool) => 'a list => 'b list => bool"
    3.37 -  map         :: "('a=>'b) => ('a list => 'b list)"
    3.38 -  mem         :: "'a => 'a list => bool"                    (infixl 55)
    3.39 -  nth         :: "'a list => nat => 'a"                   (infixl "!" 100)
    3.40 -  list_update :: "'a list => nat => 'a => 'a list"
    3.41 -  take        :: "nat => 'a list => 'a list"
    3.42 -  drop        :: "nat => 'a list => 'a list"
    3.43 -  takeWhile   :: "('a => bool) => 'a list => 'a list"
    3.44 -  dropWhile   :: "('a => bool) => 'a list => 'a list"
    3.45 -  rev         :: "'a list => 'a list"
    3.46 -  zip         :: "'a list => 'b list => ('a * 'b) list"
    3.47 -  upt         :: "nat => nat => nat list"                   ("(1[_../_'(])")
    3.48 -  remdups     :: "'a list => 'a list"
    3.49 -  null        :: "'a list => bool"
    3.50 -  "distinct"  :: "'a list => bool"
    3.51 -  replicate   :: "nat => 'a => 'a list"
    3.52 +"@" :: "'a list => 'a list => 'a list"(infixr 65)
    3.53 +filter:: "('a => bool) => 'a list => 'a list"
    3.54 +concat:: "'a list list => 'a list"
    3.55 +foldl :: "('b => 'a => 'b) => 'b => 'a list => 'b"
    3.56 +foldr :: "('a => 'b => 'b) => 'a list => 'b => 'b"
    3.57 +hd:: "'a list => 'a"
    3.58 +tl:: "'a list => 'a list"
    3.59 +last:: "'a list => 'a"
    3.60 +butlast :: "'a list => 'a list"
    3.61 +set :: "'a list => 'a set"
    3.62 +list_all:: "('a => bool) => ('a list => bool)"
    3.63 +list_all2 :: "('a => 'b => bool) => 'a list => 'b list => bool"
    3.64 +map :: "('a=>'b) => ('a list => 'b list)"
    3.65 +mem :: "'a => 'a list => bool"(infixl 55)
    3.66 +nth :: "'a list => nat => 'a" (infixl "!" 100)
    3.67 +list_update :: "'a list => nat => 'a => 'a list"
    3.68 +take:: "nat => 'a list => 'a list"
    3.69 +drop:: "nat => 'a list => 'a list"
    3.70 +takeWhile :: "('a => bool) => 'a list => 'a list"
    3.71 +dropWhile :: "('a => bool) => 'a list => 'a list"
    3.72 +rev :: "'a list => 'a list"
    3.73 +zip :: "'a list => 'b list => ('a * 'b) list"
    3.74 +upt :: "nat => nat => nat list" ("(1[_../_'(])")
    3.75 +remdups :: "'a list => 'a list"
    3.76 +null:: "'a list => bool"
    3.77 +"distinct":: "'a list => bool"
    3.78 +replicate :: "nat => 'a => 'a list"
    3.79  
    3.80  nonterminals
    3.81 -  lupdbinds  lupdbind
    3.82 +lupdbindslupdbind
    3.83  
    3.84  syntax
    3.85 -  -- {* list Enumeration *}
    3.86 -  "@list"     :: "args => 'a list"                          ("[(_)]")
    3.87 +-- {* list Enumeration *}
    3.88 +"@list" :: "args => 'a list"("[(_)]")
    3.89  
    3.90 -  -- {* Special syntax for filter *}
    3.91 -  "@filter"   :: "[pttrn, 'a list, bool] => 'a list"        ("(1[_:_./ _])")
    3.92 +-- {* Special syntax for filter *}
    3.93 +"@filter" :: "[pttrn, 'a list, bool] => 'a list"("(1[_:_./ _])")
    3.94  
    3.95 -  -- {* list update *}
    3.96 -  "_lupdbind"      :: "['a, 'a] => lupdbind"            ("(2_ :=/ _)")
    3.97 -  ""               :: "lupdbind => lupdbinds"           ("_")
    3.98 -  "_lupdbinds"     :: "[lupdbind, lupdbinds] => lupdbinds" ("_,/ _")
    3.99 -  "_LUpdate"       :: "['a, lupdbinds] => 'a"           ("_/[(_)]" [900,0] 900)
   3.100 +-- {* list update *}
   3.101 +"_lupdbind":: "['a, 'a] => lupdbind"("(2_ :=/ _)")
   3.102 +"" :: "lupdbind => lupdbinds" ("_")
   3.103 +"_lupdbinds" :: "[lupdbind, lupdbinds] => lupdbinds" ("_,/ _")
   3.104 +"_LUpdate" :: "['a, lupdbinds] => 'a" ("_/[(_)]" [900,0] 900)
   3.105  
   3.106 -  upto        :: "nat => nat => nat list"                   ("(1[_../_])")
   3.107 +upto:: "nat => nat => nat list" ("(1[_../_])")
   3.108  
   3.109  translations
   3.110 -  "[x, xs]"     == "x#[xs]"
   3.111 -  "[x]"         == "x#[]"
   3.112 -  "[x:xs . P]"  == "filter (%x. P) xs"
   3.113 +"[x, xs]" == "x#[xs]"
   3.114 +"[x]" == "x#[]"
   3.115 +"[x:xs . P]"== "filter (%x. P) xs"
   3.116  
   3.117 -  "_LUpdate xs (_lupdbinds b bs)"  == "_LUpdate (_LUpdate xs b) bs"
   3.118 -  "xs[i:=x]"                       == "list_update xs i x"
   3.119 +"_LUpdate xs (_lupdbinds b bs)"== "_LUpdate (_LUpdate xs b) bs"
   3.120 +"xs[i:=x]" == "list_update xs i x"
   3.121  
   3.122 -  "[i..j]" == "[i..(Suc j)(]"
   3.123 +"[i..j]" == "[i..(Suc j)(]"
   3.124  
   3.125  
   3.126  syntax (xsymbols)
   3.127 -  "@filter"   :: "[pttrn, 'a list, bool] => 'a list"        ("(1[_\<in>_ ./ _])")
   3.128 +"@filter" :: "[pttrn, 'a list, bool] => 'a list"("(1[_\<in>_ ./ _])")
   3.129  
   3.130  
   3.131  text {*
   3.132 -  Function @{text size} is overloaded for all datatypes.  Users may
   3.133 -  refer to the list version as @{text length}. *}
   3.134 +Function @{text size} is overloaded for all datatypes.Users may
   3.135 +refer to the list version as @{text length}. *}
   3.136  
   3.137  syntax length :: "'a list => nat"
   3.138  translations "length" => "size :: _ list => nat"
   3.139  
   3.140  typed_print_translation {*
   3.141 -  let
   3.142 -    fun size_tr' _ (Type ("fun", (Type ("list", _) :: _))) [t] =
   3.143 -          Syntax.const "length" $ t
   3.144 -      | size_tr' _ _ _ = raise Match;
   3.145 -  in [("size", size_tr')] end
   3.146 +let
   3.147 +fun size_tr' _ (Type ("fun", (Type ("list", _) :: _))) [t] =
   3.148 +Syntax.const "length" $ t
   3.149 +| size_tr' _ _ _ = raise Match;
   3.150 +in [("size", size_tr')] end
   3.151  *}
   3.152  
   3.153  primrec
   3.154 -  "hd(x#xs) = x"
   3.155 +"hd(x#xs) = x"
   3.156  primrec
   3.157 -  "tl([])   = []"
   3.158 -  "tl(x#xs) = xs"
   3.159 +"tl([]) = []"
   3.160 +"tl(x#xs) = xs"
   3.161  primrec
   3.162 -  "null([])   = True"
   3.163 -  "null(x#xs) = False"
   3.164 +"null([]) = True"
   3.165 +"null(x#xs) = False"
   3.166  primrec
   3.167 -  "last(x#xs) = (if xs=[] then x else last xs)"
   3.168 +"last(x#xs) = (if xs=[] then x else last xs)"
   3.169  primrec
   3.170 -  "butlast []    = []"
   3.171 -  "butlast(x#xs) = (if xs=[] then [] else x#butlast xs)"
   3.172 +"butlast []= []"
   3.173 +"butlast(x#xs) = (if xs=[] then [] else x#butlast xs)"
   3.174  primrec
   3.175 -  "x mem []     = False"
   3.176 -  "x mem (y#ys) = (if y=x then True else x mem ys)"
   3.177 +"x mem [] = False"
   3.178 +"x mem (y#ys) = (if y=x then True else x mem ys)"
   3.179  primrec
   3.180 -  "set [] = {}"
   3.181 -  "set (x#xs) = insert x (set xs)"
   3.182 +"set [] = {}"
   3.183 +"set (x#xs) = insert x (set xs)"
   3.184  primrec
   3.185 -  list_all_Nil:  "list_all P [] = True"
   3.186 -  list_all_Cons: "list_all P (x#xs) = (P(x) \<and> list_all P xs)"
   3.187 +list_all_Nil:"list_all P [] = True"
   3.188 +list_all_Cons: "list_all P (x#xs) = (P(x) \<and> list_all P xs)"
   3.189  primrec
   3.190 -  "map f []     = []"
   3.191 -  "map f (x#xs) = f(x)#map f xs"
   3.192 +"map f [] = []"
   3.193 +"map f (x#xs) = f(x)#map f xs"
   3.194  primrec
   3.195 -  append_Nil:  "[]    @ys = ys"
   3.196 -  append_Cons: "(x#xs)@ys = x#(xs@ys)"
   3.197 +append_Nil:"[]@ys = ys"
   3.198 +append_Cons: "(x#xs)@ys = x#(xs@ys)"
   3.199  primrec
   3.200 -  "rev([])   = []"
   3.201 -  "rev(x#xs) = rev(xs) @ [x]"
   3.202 +"rev([]) = []"
   3.203 +"rev(x#xs) = rev(xs) @ [x]"
   3.204  primrec
   3.205 -  "filter P []     = []"
   3.206 -  "filter P (x#xs) = (if P x then x#filter P xs else filter P xs)"
   3.207 +"filter P [] = []"
   3.208 +"filter P (x#xs) = (if P x then x#filter P xs else filter P xs)"
   3.209  primrec
   3.210 -  foldl_Nil:  "foldl f a [] = a"
   3.211 -  foldl_Cons: "foldl f a (x#xs) = foldl f (f a x) xs"
   3.212 +foldl_Nil:"foldl f a [] = a"
   3.213 +foldl_Cons: "foldl f a (x#xs) = foldl f (f a x) xs"
   3.214  primrec
   3.215 -  "foldr f [] a     = a"
   3.216 -  "foldr f (x#xs) a = f x (foldr f xs a)"
   3.217 +"foldr f [] a = a"
   3.218 +"foldr f (x#xs) a = f x (foldr f xs a)"
   3.219  primrec
   3.220 -  "concat([])   = []"
   3.221 -  "concat(x#xs) = x @ concat(xs)"
   3.222 +"concat([]) = []"
   3.223 +"concat(x#xs) = x @ concat(xs)"
   3.224  primrec
   3.225 -  drop_Nil:  "drop n [] = []"
   3.226 -  drop_Cons: "drop n (x#xs) = (case n of 0 => x#xs | Suc(m) => drop m xs)"
   3.227 -    -- {* Warning: simpset does not contain this definition *}
   3.228 -    -- {* but separate theorems for @{text "n = 0"} and @{text "n = Suc k"} *}
   3.229 +drop_Nil:"drop n [] = []"
   3.230 +drop_Cons: "drop n (x#xs) = (case n of 0 => x#xs | Suc(m) => drop m xs)"
   3.231 +-- {* Warning: simpset does not contain this definition *}
   3.232 +-- {* but separate theorems for @{text "n = 0"} and @{text "n = Suc k"} *}
   3.233  primrec
   3.234 -  take_Nil:  "take n [] = []"
   3.235 -  take_Cons: "take n (x#xs) = (case n of 0 => [] | Suc(m) => x # take m xs)"
   3.236 -    -- {* Warning: simpset does not contain this definition *}
   3.237 -    -- {* but separate theorems for @{text "n = 0"} and @{text "n = Suc k"} *}
   3.238 +take_Nil:"take n [] = []"
   3.239 +take_Cons: "take n (x#xs) = (case n of 0 => [] | Suc(m) => x # take m xs)"
   3.240 +-- {* Warning: simpset does not contain this definition *}
   3.241 +-- {* but separate theorems for @{text "n = 0"} and @{text "n = Suc k"} *}
   3.242  primrec
   3.243 -  nth_Cons:  "(x#xs)!n = (case n of 0 => x | (Suc k) => xs!k)"
   3.244 -    -- {* Warning: simpset does not contain this definition *}
   3.245 -    -- {* but separate theorems for @{text "n = 0"} and @{text "n = Suc k"} *}
   3.246 +nth_Cons:"(x#xs)!n = (case n of 0 => x | (Suc k) => xs!k)"
   3.247 +-- {* Warning: simpset does not contain this definition *}
   3.248 +-- {* but separate theorems for @{text "n = 0"} and @{text "n = Suc k"} *}
   3.249  primrec
   3.250 -  "[][i:=v] = []"
   3.251 -  "(x#xs)[i:=v] =
   3.252 -    (case i of 0 => v # xs
   3.253 -    | Suc j => x # xs[j:=v])"
   3.254 +"[][i:=v] = []"
   3.255 +"(x#xs)[i:=v] =
   3.256 +(case i of 0 => v # xs
   3.257 +| Suc j => x # xs[j:=v])"
   3.258  primrec
   3.259 -  "takeWhile P []     = []"
   3.260 -  "takeWhile P (x#xs) = (if P x then x#takeWhile P xs else [])"
   3.261 +"takeWhile P [] = []"
   3.262 +"takeWhile P (x#xs) = (if P x then x#takeWhile P xs else [])"
   3.263  primrec
   3.264 -  "dropWhile P []     = []"
   3.265 -  "dropWhile P (x#xs) = (if P x then dropWhile P xs else x#xs)"
   3.266 +"dropWhile P [] = []"
   3.267 +"dropWhile P (x#xs) = (if P x then dropWhile P xs else x#xs)"
   3.268  primrec
   3.269 -  "zip xs []     = []"
   3.270 -  zip_Cons: "zip xs (y#ys) = (case xs of [] => [] | z#zs => (z,y)#zip zs ys)"
   3.271 -    -- {* Warning: simpset does not contain this definition *}
   3.272 -    -- {* but separate theorems for @{text "xs = []"} and @{text "xs = z # zs"} *}
   3.273 +"zip xs [] = []"
   3.274 +zip_Cons: "zip xs (y#ys) = (case xs of [] => [] | z#zs => (z,y)#zip zs ys)"
   3.275 +-- {* Warning: simpset does not contain this definition *}
   3.276 +-- {* but separate theorems for @{text "xs = []"} and @{text "xs = z # zs"} *}
   3.277  primrec
   3.278 -  upt_0:   "[i..0(] = []"
   3.279 -  upt_Suc: "[i..(Suc j)(] = (if i <= j then [i..j(] @ [j] else [])"
   3.280 +upt_0: "[i..0(] = []"
   3.281 +upt_Suc: "[i..(Suc j)(] = (if i <= j then [i..j(] @ [j] else [])"
   3.282  primrec
   3.283 -  "distinct []     = True"
   3.284 -  "distinct (x#xs) = (x ~: set xs \<and> distinct xs)"
   3.285 +"distinct [] = True"
   3.286 +"distinct (x#xs) = (x ~: set xs \<and> distinct xs)"
   3.287  primrec
   3.288 -  "remdups [] = []"
   3.289 -  "remdups (x#xs) = (if x : set xs then remdups xs else x # remdups xs)"
   3.290 +"remdups [] = []"
   3.291 +"remdups (x#xs) = (if x : set xs then remdups xs else x # remdups xs)"
   3.292  primrec
   3.293 -  replicate_0:   "replicate  0      x = []"
   3.294 -  replicate_Suc: "replicate (Suc n) x = x # replicate n x"
   3.295 +replicate_0: "replicate0x = []"
   3.296 +replicate_Suc: "replicate (Suc n) x = x # replicate n x"
   3.297  defs
   3.298   list_all2_def:
   3.299   "list_all2 P xs ys == length xs = length ys \<and> (\<forall>(x, y) \<in> set (zip xs ys). P x y)"
   3.300 @@ -182,181 +182,181 @@
   3.301  subsection {* Lexicographic orderings on lists *}
   3.302  
   3.303  consts
   3.304 -  lexn :: "('a * 'a)set => nat => ('a list * 'a list)set"
   3.305 +lexn :: "('a * 'a)set => nat => ('a list * 'a list)set"
   3.306  primrec
   3.307 -  "lexn r 0 = {}"
   3.308 -  "lexn r (Suc n) =
   3.309 -    (prod_fun (%(x,xs). x#xs) (%(x,xs). x#xs) ` (r <*lex*> lexn r n)) Int
   3.310 -      {(xs,ys). length xs = Suc n \<and> length ys = Suc n}"
   3.311 +"lexn r 0 = {}"
   3.312 +"lexn r (Suc n) =
   3.313 +(prod_fun (%(x,xs). x#xs) (%(x,xs). x#xs) ` (r <*lex*> lexn r n)) Int
   3.314 +{(xs,ys). length xs = Suc n \<and> length ys = Suc n}"
   3.315  
   3.316  constdefs
   3.317 -  lex :: "('a \<times> 'a) set => ('a list \<times> 'a list) set"
   3.318 -  "lex r == \<Union>n. lexn r n"
   3.319 +lex :: "('a \<times> 'a) set => ('a list \<times> 'a list) set"
   3.320 +"lex r == \<Union>n. lexn r n"
   3.321  
   3.322 -  lexico :: "('a \<times> 'a) set => ('a list \<times> 'a list) set"
   3.323 -  "lexico r == inv_image (less_than <*lex*> lex r) (%xs. (length xs, xs))"
   3.324 +lexico :: "('a \<times> 'a) set => ('a list \<times> 'a list) set"
   3.325 +"lexico r == inv_image (less_than <*lex*> lex r) (%xs. (length xs, xs))"
   3.326  
   3.327 -  sublist :: "'a list => nat set => 'a list"
   3.328 -  "sublist xs A == map fst (filter (%p. snd p : A) (zip xs [0..size xs(]))"
   3.329 +sublist :: "'a list => nat set => 'a list"
   3.330 +"sublist xs A == map fst (filter (%p. snd p : A) (zip xs [0..size xs(]))"
   3.331  
   3.332  
   3.333  lemma not_Cons_self [simp]: "xs \<noteq> x # xs"
   3.334 -  by (induct xs) auto
   3.335 +by (induct xs) auto
   3.336  
   3.337  lemmas not_Cons_self2 [simp] = not_Cons_self [symmetric]
   3.338  
   3.339  lemma neq_Nil_conv: "(xs \<noteq> []) = (\<exists>y ys. xs = y # ys)"
   3.340 -  by (induct xs) auto
   3.341 +by (induct xs) auto
   3.342  
   3.343  lemma length_induct:
   3.344 -    "(!!xs. \<forall>ys. length ys < length xs --> P ys ==> P xs) ==> P xs"
   3.345 -  by (rule measure_induct [of length]) rules
   3.346 +"(!!xs. \<forall>ys. length ys < length xs --> P ys ==> P xs) ==> P xs"
   3.347 +by (rule measure_induct [of length]) rules
   3.348  
   3.349  
   3.350  subsection {* @{text lists}: the list-forming operator over sets *}
   3.351  
   3.352  consts lists :: "'a set => 'a list set"
   3.353  inductive "lists A"
   3.354 -  intros
   3.355 -    Nil [intro!]: "[]: lists A"
   3.356 -    Cons [intro!]: "[| a: A;  l: lists A  |] ==> a#l : lists A"
   3.357 +intros
   3.358 +Nil [intro!]: "[]: lists A"
   3.359 +Cons [intro!]: "[| a: A;l: lists A|] ==> a#l : lists A"
   3.360  
   3.361  inductive_cases listsE [elim!]: "x#l : lists A"
   3.362  
   3.363  lemma lists_mono: "A \<subseteq> B ==> lists A \<subseteq> lists B"
   3.364 -  by (unfold lists.defs) (blast intro!: lfp_mono)
   3.365 +by (unfold lists.defs) (blast intro!: lfp_mono)
   3.366  
   3.367  lemma lists_IntI [rule_format]:
   3.368 -    "l: lists A ==> l: lists B --> l: lists (A Int B)"
   3.369 -  apply (erule lists.induct)
   3.370 -  apply blast+
   3.371 -  done
   3.372 +"l: lists A ==> l: lists B --> l: lists (A Int B)"
   3.373 +apply (erule lists.induct)
   3.374 +apply blast+
   3.375 +done
   3.376  
   3.377  lemma lists_Int_eq [simp]: "lists (A \<inter> B) = lists A \<inter> lists B"
   3.378 -  apply (rule mono_Int [THEN equalityI])
   3.379 -  apply (simp add: mono_def lists_mono)
   3.380 -  apply (blast intro!: lists_IntI)
   3.381 -  done
   3.382 +apply (rule mono_Int [THEN equalityI])
   3.383 +apply (simp add: mono_def lists_mono)
   3.384 +apply (blast intro!: lists_IntI)
   3.385 +done
   3.386  
   3.387  lemma append_in_lists_conv [iff]:
   3.388 -    "(xs @ ys : lists A) = (xs : lists A \<and> ys : lists A)"
   3.389 -  by (induct xs) auto
   3.390 +"(xs @ ys : lists A) = (xs : lists A \<and> ys : lists A)"
   3.391 +by (induct xs) auto
   3.392  
   3.393  
   3.394  subsection {* @{text length} *}
   3.395  
   3.396  text {*
   3.397 -  Needs to come before @{text "@"} because of theorem @{text
   3.398 -  append_eq_append_conv}.
   3.399 +Needs to come before @{text "@"} because of theorem @{text
   3.400 +append_eq_append_conv}.
   3.401  *}
   3.402  
   3.403  lemma length_append [simp]: "length (xs @ ys) = length xs + length ys"
   3.404 -  by (induct xs) auto
   3.405 +by (induct xs) auto
   3.406  
   3.407  lemma length_map [simp]: "length (map f xs) = length xs"
   3.408 -  by (induct xs) auto
   3.409 +by (induct xs) auto
   3.410  
   3.411  lemma length_rev [simp]: "length (rev xs) = length xs"
   3.412 -  by (induct xs) auto
   3.413 +by (induct xs) auto
   3.414  
   3.415  lemma length_tl [simp]: "length (tl xs) = length xs - 1"
   3.416 -  by (cases xs) auto
   3.417 +by (cases xs) auto
   3.418  
   3.419  lemma length_0_conv [iff]: "(length xs = 0) = (xs = [])"
   3.420 -  by (induct xs) auto
   3.421 +by (induct xs) auto
   3.422  
   3.423  lemma length_greater_0_conv [iff]: "(0 < length xs) = (xs \<noteq> [])"
   3.424 -  by (induct xs) auto
   3.425 +by (induct xs) auto
   3.426  
   3.427  lemma length_Suc_conv:
   3.428 -    "(length xs = Suc n) = (\<exists>y ys. xs = y # ys \<and> length ys = n)"
   3.429 -  by (induct xs) auto
   3.430 +"(length xs = Suc n) = (\<exists>y ys. xs = y # ys \<and> length ys = n)"
   3.431 +by (induct xs) auto
   3.432  
   3.433  
   3.434  subsection {* @{text "@"} -- append *}
   3.435  
   3.436  lemma append_assoc [simp]: "(xs @ ys) @ zs = xs @ (ys @ zs)"
   3.437 -  by (induct xs) auto
   3.438 +by (induct xs) auto
   3.439  
   3.440  lemma append_Nil2 [simp]: "xs @ [] = xs"
   3.441 -  by (induct xs) auto
   3.442 +by (induct xs) auto
   3.443  
   3.444  lemma append_is_Nil_conv [iff]: "(xs @ ys = []) = (xs = [] \<and> ys = [])"
   3.445 -  by (induct xs) auto
   3.446 +by (induct xs) auto
   3.447  
   3.448  lemma Nil_is_append_conv [iff]: "([] = xs @ ys) = (xs = [] \<and> ys = [])"
   3.449 -  by (induct xs) auto
   3.450 +by (induct xs) auto
   3.451  
   3.452  lemma append_self_conv [iff]: "(xs @ ys = xs) = (ys = [])"
   3.453 -  by (induct xs) auto
   3.454 +by (induct xs) auto
   3.455  
   3.456  lemma self_append_conv [iff]: "(xs = xs @ ys) = (ys = [])"
   3.457 -  by (induct xs) auto
   3.458 +by (induct xs) auto
   3.459  
   3.460  lemma append_eq_append_conv [rule_format, simp]:
   3.461   "\<forall>ys. length xs = length ys \<or> length us = length vs
   3.462 -       --> (xs@us = ys@vs) = (xs=ys \<and> us=vs)"
   3.463 -  apply (induct_tac xs)
   3.464 -   apply(rule allI)
   3.465 -   apply (case_tac ys)
   3.466 -    apply simp
   3.467 -   apply force
   3.468 -  apply (rule allI)
   3.469 -  apply (case_tac ys)
   3.470 -   apply force
   3.471 -  apply simp
   3.472 -  done
   3.473 + --> (xs@us = ys@vs) = (xs=ys \<and> us=vs)"
   3.474 +apply (induct_tac xs)
   3.475 + apply(rule allI)
   3.476 + apply (case_tac ys)
   3.477 +apply simp
   3.478 + apply force
   3.479 +apply (rule allI)
   3.480 +apply (case_tac ys)
   3.481 + apply force
   3.482 +apply simp
   3.483 +done
   3.484  
   3.485  lemma same_append_eq [iff]: "(xs @ ys = xs @ zs) = (ys = zs)"
   3.486 -  by simp
   3.487 +by simp
   3.488  
   3.489  lemma append1_eq_conv [iff]: "(xs @ [x] = ys @ [y]) = (xs = ys \<and> x = y)"
   3.490 -  by simp
   3.491 +by simp
   3.492  
   3.493  lemma append_same_eq [iff]: "(ys @ xs = zs @ xs) = (ys = zs)"
   3.494 -  by simp
   3.495 +by simp
   3.496  
   3.497  lemma append_self_conv2 [iff]: "(xs @ ys = ys) = (xs = [])"
   3.498 -  using append_same_eq [of _ _ "[]"] by auto
   3.499 +using append_same_eq [of _ _ "[]"] by auto
   3.500  
   3.501  lemma self_append_conv2 [iff]: "(ys = xs @ ys) = (xs = [])"
   3.502 -  using append_same_eq [of "[]"] by auto
   3.503 +using append_same_eq [of "[]"] by auto
   3.504  
   3.505  lemma hd_Cons_tl [simp]: "xs \<noteq> [] ==> hd xs # tl xs = xs"
   3.506 -  by (induct xs) auto
   3.507 +by (induct xs) auto
   3.508  
   3.509  lemma hd_append: "hd (xs @ ys) = (if xs = [] then hd ys else hd xs)"
   3.510 -  by (induct xs) auto
   3.511 +by (induct xs) auto
   3.512  
   3.513  lemma hd_append2 [simp]: "xs \<noteq> [] ==> hd (xs @ ys) = hd xs"
   3.514 -  by (simp add: hd_append split: list.split)
   3.515 +by (simp add: hd_append split: list.split)
   3.516  
   3.517  lemma tl_append: "tl (xs @ ys) = (case xs of [] => tl ys | z#zs => zs @ ys)"
   3.518 -  by (simp split: list.split)
   3.519 +by (simp split: list.split)
   3.520  
   3.521  lemma tl_append2 [simp]: "xs \<noteq> [] ==> tl (xs @ ys) = tl xs @ ys"
   3.522 -  by (simp add: tl_append split: list.split)
   3.523 +by (simp add: tl_append split: list.split)
   3.524  
   3.525  
   3.526  text {* Trivial rules for solving @{text "@"}-equations automatically. *}
   3.527  
   3.528  lemma eq_Nil_appendI: "xs = ys ==> xs = [] @ ys"
   3.529 -  by simp
   3.530 +by simp
   3.531  
   3.532  lemma Cons_eq_appendI:
   3.533 -    "[| x # xs1 = ys; xs = xs1 @ zs |] ==> x # xs = ys @ zs"
   3.534 -  by (drule sym) simp
   3.535 +"[| x # xs1 = ys; xs = xs1 @ zs |] ==> x # xs = ys @ zs"
   3.536 +by (drule sym) simp
   3.537  
   3.538  lemma append_eq_appendI:
   3.539 -    "[| xs @ xs1 = zs; ys = xs1 @ us |] ==> xs @ ys = zs @ us"
   3.540 -  by (drule sym) simp
   3.541 +"[| xs @ xs1 = zs; ys = xs1 @ us |] ==> xs @ ys = zs @ us"
   3.542 +by (drule sym) simp
   3.543  
   3.544  
   3.545  text {*
   3.546 -  Simplification procedure for all list equalities.
   3.547 -  Currently only tries to rearrange @{text "@"} to see if
   3.548 -  - both lists end in a singleton list,
   3.549 -  - or both lists end in the same list.
   3.550 +Simplification procedure for all list equalities.
   3.551 +Currently only tries to rearrange @{text "@"} to see if
   3.552 +- both lists end in a singleton list,
   3.553 +- or both lists end in the same list.
   3.554  *}
   3.555  
   3.556  ML_setup {*
   3.557 @@ -369,47 +369,47 @@
   3.558  val append_same_eq = thm "append_same_eq";
   3.559  
   3.560  val list_eq_pattern =
   3.561 -  Thm.read_cterm (Theory.sign_of (the_context ())) ("(xs::'a list) = ys",HOLogic.boolT)
   3.562 +Thm.read_cterm (Theory.sign_of (the_context ())) ("(xs::'a list) = ys",HOLogic.boolT)
   3.563  
   3.564  fun last (cons as Const("List.list.Cons",_) $ _ $ xs) =
   3.565 -      (case xs of Const("List.list.Nil",_) => cons | _ => last xs)
   3.566 -  | last (Const("List.op @",_) $ _ $ ys) = last ys
   3.567 -  | last t = t
   3.568 +(case xs of Const("List.list.Nil",_) => cons | _ => last xs)
   3.569 +| last (Const("List.op @",_) $ _ $ ys) = last ys
   3.570 +| last t = t
   3.571  
   3.572  fun list1 (Const("List.list.Cons",_) $ _ $ Const("List.list.Nil",_)) = true
   3.573 -  | list1 _ = false
   3.574 +| list1 _ = false
   3.575  
   3.576  fun butlast ((cons as Const("List.list.Cons",_) $ x) $ xs) =
   3.577 -      (case xs of Const("List.list.Nil",_) => xs | _ => cons $ butlast xs)
   3.578 -  | butlast ((app as Const("List.op @",_) $ xs) $ ys) = app $ butlast ys
   3.579 -  | butlast xs = Const("List.list.Nil",fastype_of xs)
   3.580 +(case xs of Const("List.list.Nil",_) => xs | _ => cons $ butlast xs)
   3.581 +| butlast ((app as Const("List.op @",_) $ xs) $ ys) = app $ butlast ys
   3.582 +| butlast xs = Const("List.list.Nil",fastype_of xs)
   3.583  
   3.584  val rearr_tac =
   3.585 -  simp_tac (HOL_basic_ss addsimps [append_assoc,append_Nil,append_Cons])
   3.586 +simp_tac (HOL_basic_ss addsimps [append_assoc,append_Nil,append_Cons])
   3.587  
   3.588  fun list_eq sg _ (F as (eq as Const(_,eqT)) $ lhs $ rhs) =
   3.589 -  let
   3.590 -    val lastl = last lhs and lastr = last rhs
   3.591 -    fun rearr conv =
   3.592 -      let val lhs1 = butlast lhs and rhs1 = butlast rhs
   3.593 -          val Type(_,listT::_) = eqT
   3.594 -          val appT = [listT,listT] ---> listT
   3.595 -          val app = Const("List.op @",appT)
   3.596 -          val F2 = eq $ (app$lhs1$lastl) $ (app$rhs1$lastr)
   3.597 -          val ct = cterm_of sg (HOLogic.mk_Trueprop(HOLogic.mk_eq(F,F2)))
   3.598 -          val thm = prove_goalw_cterm [] ct (K [rearr_tac 1])
   3.599 -            handle ERROR =>
   3.600 -            error("The error(s) above occurred while trying to prove " ^
   3.601 -                  string_of_cterm ct)
   3.602 -      in Some((conv RS (thm RS trans)) RS eq_reflection) end
   3.603 +let
   3.604 +val lastl = last lhs and lastr = last rhs
   3.605 +fun rearr conv =
   3.606 +let val lhs1 = butlast lhs and rhs1 = butlast rhs
   3.607 +val Type(_,listT::_) = eqT
   3.608 +val appT = [listT,listT] ---> listT
   3.609 +val app = Const("List.op @",appT)
   3.610 +val F2 = eq $ (app$lhs1$lastl) $ (app$rhs1$lastr)
   3.611 +val ct = cterm_of sg (HOLogic.mk_Trueprop(HOLogic.mk_eq(F,F2)))
   3.612 +val thm = prove_goalw_cterm [] ct (K [rearr_tac 1])
   3.613 +handle ERROR =>
   3.614 +error("The error(s) above occurred while trying to prove " ^
   3.615 +string_of_cterm ct)
   3.616 +in Some((conv RS (thm RS trans)) RS eq_reflection) end
   3.617  
   3.618 -  in if list1 lastl andalso list1 lastr
   3.619 -     then rearr append1_eq_conv
   3.620 -     else
   3.621 -     if lastl aconv lastr
   3.622 -     then rearr append_same_eq
   3.623 -     else None
   3.624 -  end
   3.625 +in if list1 lastl andalso list1 lastr
   3.626 + then rearr append1_eq_conv
   3.627 + else
   3.628 + if lastl aconv lastr
   3.629 + then rearr append_same_eq
   3.630 + else None
   3.631 +end
   3.632  in
   3.633  val list_eq_simproc = mk_simproc "list_eq" [list_eq_pattern] list_eq
   3.634  end;
   3.635 @@ -421,944 +421,945 @@
   3.636  subsection {* @{text map} *}
   3.637  
   3.638  lemma map_ext: "(!!x. x : set xs --> f x = g x) ==> map f xs = map g xs"
   3.639 -  by (induct xs) simp_all
   3.640 +by (induct xs) simp_all
   3.641  
   3.642  lemma map_ident [simp]: "map (\<lambda>x. x) = (\<lambda>xs. xs)"
   3.643 -  by (rule ext, induct_tac xs) auto
   3.644 +by (rule ext, induct_tac xs) auto
   3.645  
   3.646  lemma map_append [simp]: "map f (xs @ ys) = map f xs @ map f ys"
   3.647 -  by (induct xs) auto
   3.648 +by (induct xs) auto
   3.649  
   3.650  lemma map_compose: "map (f o g) xs = map f (map g xs)"
   3.651 -  by (induct xs) (auto simp add: o_def)
   3.652 +by (induct xs) (auto simp add: o_def)
   3.653  
   3.654  lemma rev_map: "rev (map f xs) = map f (rev xs)"
   3.655 -  by (induct xs) auto
   3.656 +by (induct xs) auto
   3.657  
   3.658  lemma map_cong:
   3.659 -  "xs = ys ==> (!!x. x : set ys ==> f x = g x) ==> map f xs = map g ys"
   3.660 -  -- {* a congruence rule for @{text map} *}
   3.661 -  by (clarify, induct ys) auto
   3.662 +"xs = ys ==> (!!x. x : set ys ==> f x = g x) ==> map f xs = map g ys"
   3.663 +-- {* a congruence rule for @{text map} *}
   3.664 +by (clarify, induct ys) auto
   3.665  
   3.666  lemma map_is_Nil_conv [iff]: "(map f xs = []) = (xs = [])"
   3.667 -  by (cases xs) auto
   3.668 +by (cases xs) auto
   3.669  
   3.670  lemma Nil_is_map_conv [iff]: "([] = map f xs) = (xs = [])"
   3.671 -  by (cases xs) auto
   3.672 +by (cases xs) auto
   3.673  
   3.674  lemma map_eq_Cons:
   3.675 -  "(map f xs = y # ys) = (\<exists>x xs'. xs = x # xs' \<and> f x = y \<and> map f xs' = ys)"
   3.676 -  by (cases xs) auto
   3.677 +"(map f xs = y # ys) = (\<exists>x xs'. xs = x # xs' \<and> f x = y \<and> map f xs' = ys)"
   3.678 +by (cases xs) auto
   3.679  
   3.680  lemma map_injective:
   3.681 -    "!!xs. map f xs = map f ys ==> (\<forall>x y. f x = f y --> x = y) ==> xs = ys"
   3.682 -  by (induct ys) (auto simp add: map_eq_Cons)
   3.683 +"!!xs. map f xs = map f ys ==> (\<forall>x y. f x = f y --> x = y) ==> xs = ys"
   3.684 +by (induct ys) (auto simp add: map_eq_Cons)
   3.685  
   3.686  lemma inj_mapI: "inj f ==> inj (map f)"
   3.687 -  by (rules dest: map_injective injD intro: injI)
   3.688 +by (rules dest: map_injective injD intro: injI)
   3.689  
   3.690  lemma inj_mapD: "inj (map f) ==> inj f"
   3.691 -  apply (unfold inj_on_def)
   3.692 -  apply clarify
   3.693 -  apply (erule_tac x = "[x]" in ballE)
   3.694 -   apply (erule_tac x = "[y]" in ballE)
   3.695 -    apply simp
   3.696 -   apply blast
   3.697 -  apply blast
   3.698 -  done
   3.699 +apply (unfold inj_on_def)
   3.700 +apply clarify
   3.701 +apply (erule_tac x = "[x]" in ballE)
   3.702 + apply (erule_tac x = "[y]" in ballE)
   3.703 +apply simp
   3.704 + apply blast
   3.705 +apply blast
   3.706 +done
   3.707  
   3.708  lemma inj_map: "inj (map f) = inj f"
   3.709 -  by (blast dest: inj_mapD intro: inj_mapI)
   3.710 +by (blast dest: inj_mapD intro: inj_mapI)
   3.711  
   3.712  
   3.713  subsection {* @{text rev} *}
   3.714  
   3.715  lemma rev_append [simp]: "rev (xs @ ys) = rev ys @ rev xs"
   3.716 -  by (induct xs) auto
   3.717 +by (induct xs) auto
   3.718  
   3.719  lemma rev_rev_ident [simp]: "rev (rev xs) = xs"
   3.720 -  by (induct xs) auto
   3.721 +by (induct xs) auto
   3.722  
   3.723  lemma rev_is_Nil_conv [iff]: "(rev xs = []) = (xs = [])"
   3.724 -  by (induct xs) auto
   3.725 +by (induct xs) auto
   3.726  
   3.727  lemma Nil_is_rev_conv [iff]: "([] = rev xs) = (xs = [])"
   3.728 -  by (induct xs) auto
   3.729 +by (induct xs) auto
   3.730  
   3.731  lemma rev_is_rev_conv [iff]: "!!ys. (rev xs = rev ys) = (xs = ys)"
   3.732 -  apply (induct xs)
   3.733 -   apply force
   3.734 -  apply (case_tac ys)
   3.735 -   apply simp
   3.736 -  apply force
   3.737 -  done
   3.738 +apply (induct xs)
   3.739 + apply force
   3.740 +apply (case_tac ys)
   3.741 + apply simp
   3.742 +apply force
   3.743 +done
   3.744  
   3.745  lemma rev_induct: "[| P []; !!x xs. P xs ==> P (xs @ [x]) |] ==> P xs"
   3.746 -  apply(subst rev_rev_ident[symmetric])
   3.747 -  apply(rule_tac list = "rev xs" in list.induct, simp_all)
   3.748 -  done
   3.749 +apply(subst rev_rev_ident[symmetric])
   3.750 +apply(rule_tac list = "rev xs" in list.induct, simp_all)
   3.751 +done
   3.752  
   3.753 -ML {* val rev_induct_tac = induct_thm_tac (thm "rev_induct") *}  -- "compatibility"
   3.754 +ML {* val rev_induct_tac = induct_thm_tac (thm "rev_induct") *}-- "compatibility"
   3.755  
   3.756 -lemma rev_exhaust: "(xs = [] ==> P) ==>  (!!ys y. xs = ys @ [y] ==> P) ==> P"
   3.757 -  by (induct xs rule: rev_induct) auto
   3.758 +lemma rev_exhaust: "(xs = [] ==> P) ==>(!!ys y. xs = ys @ [y] ==> P) ==> P"
   3.759 +by (induct xs rule: rev_induct) auto
   3.760  
   3.761  
   3.762  subsection {* @{text set} *}
   3.763  
   3.764  lemma finite_set [iff]: "finite (set xs)"
   3.765 -  by (induct xs) auto
   3.766 +by (induct xs) auto
   3.767  
   3.768  lemma set_append [simp]: "set (xs @ ys) = (set xs \<union> set ys)"
   3.769 -  by (induct xs) auto
   3.770 +by (induct xs) auto
   3.771  
   3.772  lemma set_subset_Cons: "set xs \<subseteq> set (x # xs)"
   3.773 -  by auto
   3.774 +by auto
   3.775  
   3.776  lemma set_empty [iff]: "(set xs = {}) = (xs = [])"
   3.777 -  by (induct xs) auto
   3.778 +by (induct xs) auto
   3.779  
   3.780  lemma set_rev [simp]: "set (rev xs) = set xs"
   3.781 -  by (induct xs) auto
   3.782 +by (induct xs) auto
   3.783  
   3.784  lemma set_map [simp]: "set (map f xs) = f`(set xs)"
   3.785 -  by (induct xs) auto
   3.786 +by (induct xs) auto
   3.787  
   3.788  lemma set_filter [simp]: "set (filter P xs) = {x. x : set xs \<and> P x}"
   3.789 -  by (induct xs) auto
   3.790 +by (induct xs) auto
   3.791  
   3.792  lemma set_upt [simp]: "set[i..j(] = {k. i \<le> k \<and> k < j}"
   3.793 -  apply (induct j)
   3.794 -   apply simp_all
   3.795 -  apply(erule ssubst)
   3.796 -  apply auto
   3.797 -  apply arith
   3.798 -  done
   3.799 +apply (induct j)
   3.800 + apply simp_all
   3.801 +apply(erule ssubst)
   3.802 +apply auto
   3.803 +apply arith
   3.804 +done
   3.805  
   3.806  lemma in_set_conv_decomp: "(x : set xs) = (\<exists>ys zs. xs = ys @ x # zs)"
   3.807 -  apply (induct xs)
   3.808 -   apply simp
   3.809 -  apply simp
   3.810 -  apply (rule iffI)
   3.811 -   apply (blast intro: eq_Nil_appendI Cons_eq_appendI)
   3.812 -  apply (erule exE)+
   3.813 -  apply (case_tac ys)
   3.814 -  apply auto
   3.815 -  done
   3.816 +apply (induct xs)
   3.817 + apply simp
   3.818 +apply simp
   3.819 +apply (rule iffI)
   3.820 + apply (blast intro: eq_Nil_appendI Cons_eq_appendI)
   3.821 +apply (erule exE)+
   3.822 +apply (case_tac ys)
   3.823 +apply auto
   3.824 +done
   3.825  
   3.826  lemma in_lists_conv_set: "(xs : lists A) = (\<forall>x \<in> set xs. x : A)"
   3.827 -  -- {* eliminate @{text lists} in favour of @{text set} *}
   3.828 -  by (induct xs) auto
   3.829 +-- {* eliminate @{text lists} in favour of @{text set} *}
   3.830 +by (induct xs) auto
   3.831  
   3.832  lemma in_listsD [dest!]: "xs \<in> lists A ==> \<forall>x\<in>set xs. x \<in> A"
   3.833 -  by (rule in_lists_conv_set [THEN iffD1])
   3.834 +by (rule in_lists_conv_set [THEN iffD1])
   3.835  
   3.836  lemma in_listsI [intro!]: "\<forall>x\<in>set xs. x \<in> A ==> xs \<in> lists A"
   3.837 -  by (rule in_lists_conv_set [THEN iffD2])
   3.838 +by (rule in_lists_conv_set [THEN iffD2])
   3.839  
   3.840  
   3.841  subsection {* @{text mem} *}
   3.842  
   3.843  lemma set_mem_eq: "(x mem xs) = (x : set xs)"
   3.844 -  by (induct xs) auto
   3.845 +by (induct xs) auto
   3.846  
   3.847  
   3.848  subsection {* @{text list_all} *}
   3.849  
   3.850  lemma list_all_conv: "list_all P xs = (\<forall>x \<in> set xs. P x)"
   3.851 -  by (induct xs) auto
   3.852 +by (induct xs) auto
   3.853  
   3.854  lemma list_all_append [simp]:
   3.855 -    "list_all P (xs @ ys) = (list_all P xs \<and> list_all P ys)"
   3.856 -  by (induct xs) auto
   3.857 +"list_all P (xs @ ys) = (list_all P xs \<and> list_all P ys)"
   3.858 +by (induct xs) auto
   3.859  
   3.860  
   3.861  subsection {* @{text filter} *}
   3.862  
   3.863  lemma filter_append [simp]: "filter P (xs @ ys) = filter P xs @ filter P ys"
   3.864 -  by (induct xs) auto
   3.865 +by (induct xs) auto
   3.866  
   3.867  lemma filter_filter [simp]: "filter P (filter Q xs) = filter (\<lambda>x. Q x \<and> P x) xs"
   3.868 -  by (induct xs) auto
   3.869 +by (induct xs) auto
   3.870  
   3.871  lemma filter_True [simp]: "\<forall>x \<in> set xs. P x ==> filter P xs = xs"
   3.872 -  by (induct xs) auto
   3.873 +by (induct xs) auto
   3.874  
   3.875  lemma filter_False [simp]: "\<forall>x \<in> set xs. \<not> P x ==> filter P xs = []"
   3.876 -  by (induct xs) auto
   3.877 +by (induct xs) auto
   3.878  
   3.879  lemma length_filter [simp]: "length (filter P xs) \<le> length xs"
   3.880 -  by (induct xs) (auto simp add: le_SucI)
   3.881 +by (induct xs) (auto simp add: le_SucI)
   3.882  
   3.883  lemma filter_is_subset [simp]: "set (filter P xs) \<le> set xs"
   3.884 -  by auto
   3.885 +by auto
   3.886  
   3.887  
   3.888  subsection {* @{text concat} *}
   3.889  
   3.890  lemma concat_append [simp]: "concat (xs @ ys) = concat xs @ concat ys"
   3.891 -  by (induct xs) auto
   3.892 +by (induct xs) auto
   3.893  
   3.894  lemma concat_eq_Nil_conv [iff]: "(concat xss = []) = (\<forall>xs \<in> set xss. xs = [])"
   3.895 -  by (induct xss) auto
   3.896 +by (induct xss) auto
   3.897  
   3.898  lemma Nil_eq_concat_conv [iff]: "([] = concat xss) = (\<forall>xs \<in> set xss. xs = [])"
   3.899 -  by (induct xss) auto
   3.900 +by (induct xss) auto
   3.901  
   3.902  lemma set_concat [simp]: "set (concat xs) = \<Union>(set ` set xs)"
   3.903 -  by (induct xs) auto
   3.904 +by (induct xs) auto
   3.905  
   3.906  lemma map_concat: "map f (concat xs) = concat (map (map f) xs)"
   3.907 -  by (induct xs) auto
   3.908 +by (induct xs) auto
   3.909  
   3.910  lemma filter_concat: "filter p (concat xs) = concat (map (filter p) xs)"
   3.911 -  by (induct xs) auto
   3.912 +by (induct xs) auto
   3.913  
   3.914  lemma rev_concat: "rev (concat xs) = concat (map rev (rev xs))"
   3.915 -  by (induct xs) auto
   3.916 +by (induct xs) auto
   3.917  
   3.918  
   3.919  subsection {* @{text nth} *}
   3.920  
   3.921  lemma nth_Cons_0 [simp]: "(x # xs)!0 = x"
   3.922 -  by auto
   3.923 +by auto
   3.924  
   3.925  lemma nth_Cons_Suc [simp]: "(x # xs)!(Suc n) = xs!n"
   3.926 -  by auto
   3.927 +by auto
   3.928  
   3.929  declare nth.simps [simp del]
   3.930  
   3.931  lemma nth_append:
   3.932 -    "!!n. (xs @ ys)!n = (if n < length xs then xs!n else ys!(n - length xs))"
   3.933 -  apply(induct "xs")
   3.934 -   apply simp
   3.935 -  apply (case_tac n)
   3.936 -   apply auto
   3.937 -  done
   3.938 +"!!n. (xs @ ys)!n = (if n < length xs then xs!n else ys!(n - length xs))"
   3.939 +apply(induct "xs")
   3.940 + apply simp
   3.941 +apply (case_tac n)
   3.942 + apply auto
   3.943 +done
   3.944  
   3.945  lemma nth_map [simp]: "!!n. n < length xs ==> (map f xs)!n = f(xs!n)"
   3.946 -  apply(induct xs)
   3.947 -   apply simp
   3.948 -  apply (case_tac n)
   3.949 -   apply auto
   3.950 -  done
   3.951 +apply(induct xs)
   3.952 + apply simp
   3.953 +apply (case_tac n)
   3.954 + apply auto
   3.955 +done
   3.956  
   3.957  lemma set_conv_nth: "set xs = {xs!i | i. i < length xs}"
   3.958 -  apply (induct_tac xs)
   3.959 -   apply simp
   3.960 -  apply simp
   3.961 -  apply safe
   3.962 -    apply (rule_tac x = 0 in exI)
   3.963 -    apply simp
   3.964 -   apply (rule_tac x = "Suc i" in exI)
   3.965 -   apply simp
   3.966 -  apply (case_tac i)
   3.967 -   apply simp
   3.968 -  apply (rename_tac j)
   3.969 -  apply (rule_tac x = j in exI)
   3.970 -  apply simp
   3.971 -  done
   3.972 +apply (induct_tac xs)
   3.973 + apply simp
   3.974 +apply simp
   3.975 +apply safe
   3.976 +apply (rule_tac x = 0 in exI)
   3.977 +apply simp
   3.978 + apply (rule_tac x = "Suc i" in exI)
   3.979 + apply simp
   3.980 +apply (case_tac i)
   3.981 + apply simp
   3.982 +apply (rename_tac j)
   3.983 +apply (rule_tac x = j in exI)
   3.984 +apply simp
   3.985 +done
   3.986  
   3.987 -lemma list_ball_nth: "[| n < length xs; !x : set xs. P x  |] ==> P(xs!n)"
   3.988 -  by (auto simp add: set_conv_nth)
   3.989 +lemma list_ball_nth: "[| n < length xs; !x : set xs. P x|] ==> P(xs!n)"
   3.990 +by (auto simp add: set_conv_nth)
   3.991  
   3.992  lemma nth_mem [simp]: "n < length xs ==> xs!n : set xs"
   3.993 -  by (auto simp add: set_conv_nth)
   3.994 +by (auto simp add: set_conv_nth)
   3.995  
   3.996  lemma all_nth_imp_all_set:
   3.997 -    "[| !i < length xs. P(xs!i); x : set xs  |] ==> P x"
   3.998 -  by (auto simp add: set_conv_nth)
   3.999 +"[| !i < length xs. P(xs!i); x : set xs|] ==> P x"
  3.1000 +by (auto simp add: set_conv_nth)
  3.1001  
  3.1002  lemma all_set_conv_all_nth:
  3.1003 -    "(\<forall>x \<in> set xs. P x) = (\<forall>i. i < length xs --> P (xs ! i))"
  3.1004 -  by (auto simp add: set_conv_nth)
  3.1005 +"(\<forall>x \<in> set xs. P x) = (\<forall>i. i < length xs --> P (xs ! i))"
  3.1006 +by (auto simp add: set_conv_nth)
  3.1007  
  3.1008  
  3.1009  subsection {* @{text list_update} *}
  3.1010  
  3.1011  lemma length_list_update [simp]: "!!i. length(xs[i:=x]) = length xs"
  3.1012 -  by (induct xs) (auto split: nat.split)
  3.1013 +by (induct xs) (auto split: nat.split)
  3.1014  
  3.1015  lemma nth_list_update:
  3.1016 -    "!!i j. i < length xs  ==> (xs[i:=x])!j = (if i = j then x else xs!j)"
  3.1017 -  by (induct xs) (auto simp add: nth_Cons split: nat.split)
  3.1018 +"!!i j. i < length xs==> (xs[i:=x])!j = (if i = j then x else xs!j)"
  3.1019 +by (induct xs) (auto simp add: nth_Cons split: nat.split)
  3.1020  
  3.1021  lemma nth_list_update_eq [simp]: "i < length xs ==> (xs[i:=x])!i = x"
  3.1022 -  by (simp add: nth_list_update)
  3.1023 +by (simp add: nth_list_update)
  3.1024  
  3.1025  lemma nth_list_update_neq [simp]: "!!i j. i \<noteq> j ==> xs[i:=x]!j = xs!j"
  3.1026 -  by (induct xs) (auto simp add: nth_Cons split: nat.split)
  3.1027 +by (induct xs) (auto simp add: nth_Cons split: nat.split)
  3.1028  
  3.1029  lemma list_update_overwrite [simp]:
  3.1030 -    "!!i. i < size xs ==> xs[i:=x, i:=y] = xs[i:=y]"
  3.1031 -  by (induct xs) (auto split: nat.split)
  3.1032 +"!!i. i < size xs ==> xs[i:=x, i:=y] = xs[i:=y]"
  3.1033 +by (induct xs) (auto split: nat.split)
  3.1034  
  3.1035  lemma list_update_same_conv:
  3.1036 -    "!!i. i < length xs ==> (xs[i := x] = xs) = (xs!i = x)"
  3.1037 -  by (induct xs) (auto split: nat.split)
  3.1038 +"!!i. i < length xs ==> (xs[i := x] = xs) = (xs!i = x)"
  3.1039 +by (induct xs) (auto split: nat.split)
  3.1040  
  3.1041  lemma update_zip:
  3.1042 -  "!!i xy xs. length xs = length ys ==>
  3.1043 -    (zip xs ys)[i:=xy] = zip (xs[i:=fst xy]) (ys[i:=snd xy])"
  3.1044 -  by (induct ys) (auto, case_tac xs, auto split: nat.split)
  3.1045 +"!!i xy xs. length xs = length ys ==>
  3.1046 +(zip xs ys)[i:=xy] = zip (xs[i:=fst xy]) (ys[i:=snd xy])"
  3.1047 +by (induct ys) (auto, case_tac xs, auto split: nat.split)
  3.1048  
  3.1049  lemma set_update_subset_insert: "!!i. set(xs[i:=x]) <= insert x (set xs)"
  3.1050 -  by (induct xs) (auto split: nat.split)
  3.1051 +by (induct xs) (auto split: nat.split)
  3.1052  
  3.1053  lemma set_update_subsetI: "[| set xs <= A; x:A |] ==> set(xs[i := x]) <= A"
  3.1054 -  by (blast dest!: set_update_subset_insert [THEN subsetD])
  3.1055 +by (blast dest!: set_update_subset_insert [THEN subsetD])
  3.1056  
  3.1057  
  3.1058  subsection {* @{text last} and @{text butlast} *}
  3.1059  
  3.1060  lemma last_snoc [simp]: "last (xs @ [x]) = x"
  3.1061 -  by (induct xs) auto
  3.1062 +by (induct xs) auto
  3.1063  
  3.1064  lemma butlast_snoc [simp]: "butlast (xs @ [x]) = xs"
  3.1065 -  by (induct xs) auto
  3.1066 +by (induct xs) auto
  3.1067  
  3.1068  lemma length_butlast [simp]: "length (butlast xs) = length xs - 1"
  3.1069 -  by (induct xs rule: rev_induct) auto
  3.1070 +by (induct xs rule: rev_induct) auto
  3.1071  
  3.1072  lemma butlast_append:
  3.1073 -    "!!ys. butlast (xs @ ys) = (if ys = [] then butlast xs else xs @ butlast ys)"
  3.1074 -  by (induct xs) auto
  3.1075 +"!!ys. butlast (xs @ ys) = (if ys = [] then butlast xs else xs @ butlast ys)"
  3.1076 +by (induct xs) auto
  3.1077  
  3.1078  lemma append_butlast_last_id [simp]:
  3.1079 -    "xs \<noteq> [] ==> butlast xs @ [last xs] = xs"
  3.1080 -  by (induct xs) auto
  3.1081 +"xs \<noteq> [] ==> butlast xs @ [last xs] = xs"
  3.1082 +by (induct xs) auto
  3.1083  
  3.1084  lemma in_set_butlastD: "x : set (butlast xs) ==> x : set xs"
  3.1085 -  by (induct xs) (auto split: split_if_asm)
  3.1086 +by (induct xs) (auto split: split_if_asm)
  3.1087  
  3.1088  lemma in_set_butlast_appendI:
  3.1089 -    "x : set (butlast xs) | x : set (butlast ys) ==> x : set (butlast (xs @ ys))"
  3.1090 -  by (auto dest: in_set_butlastD simp add: butlast_append)
  3.1091 +"x : set (butlast xs) | x : set (butlast ys) ==> x : set (butlast (xs @ ys))"
  3.1092 +by (auto dest: in_set_butlastD simp add: butlast_append)
  3.1093  
  3.1094  
  3.1095  subsection {* @{text take} and @{text drop} *}
  3.1096  
  3.1097  lemma take_0 [simp]: "take 0 xs = []"
  3.1098 -  by (induct xs) auto
  3.1099 +by (induct xs) auto
  3.1100  
  3.1101  lemma drop_0 [simp]: "drop 0 xs = xs"
  3.1102 -  by (induct xs) auto
  3.1103 +by (induct xs) auto
  3.1104  
  3.1105  lemma take_Suc_Cons [simp]: "take (Suc n) (x # xs) = x # take n xs"
  3.1106 -  by simp
  3.1107 +by simp
  3.1108  
  3.1109  lemma drop_Suc_Cons [simp]: "drop (Suc n) (x # xs) = drop n xs"
  3.1110 -  by simp
  3.1111 +by simp
  3.1112  
  3.1113  declare take_Cons [simp del] and drop_Cons [simp del]
  3.1114  
  3.1115  lemma length_take [simp]: "!!xs. length (take n xs) = min (length xs) n"
  3.1116 -  by (induct n) (auto, case_tac xs, auto)
  3.1117 +by (induct n) (auto, case_tac xs, auto)
  3.1118  
  3.1119  lemma length_drop [simp]: "!!xs. length (drop n xs) = (length xs - n)"
  3.1120 -  by (induct n) (auto, case_tac xs, auto)
  3.1121 +by (induct n) (auto, case_tac xs, auto)
  3.1122  
  3.1123  lemma take_all [simp]: "!!xs. length xs <= n ==> take n xs = xs"
  3.1124 -  by (induct n) (auto, case_tac xs, auto)
  3.1125 +by (induct n) (auto, case_tac xs, auto)
  3.1126  
  3.1127  lemma drop_all [simp]: "!!xs. length xs <= n ==> drop n xs = []"
  3.1128 -  by (induct n) (auto, case_tac xs, auto)
  3.1129 +by (induct n) (auto, case_tac xs, auto)
  3.1130  
  3.1131  lemma take_append [simp]:
  3.1132 -    "!!xs. take n (xs @ ys) = (take n xs @ take (n - length xs) ys)"
  3.1133 -  by (induct n) (auto, case_tac xs, auto)
  3.1134 +"!!xs. take n (xs @ ys) = (take n xs @ take (n - length xs) ys)"
  3.1135 +by (induct n) (auto, case_tac xs, auto)
  3.1136  
  3.1137  lemma drop_append [simp]:
  3.1138 -    "!!xs. drop n (xs @ ys) = drop n xs @ drop (n - length xs) ys"
  3.1139 -  by (induct n) (auto, case_tac xs, auto)
  3.1140 +"!!xs. drop n (xs @ ys) = drop n xs @ drop (n - length xs) ys"
  3.1141 +by (induct n) (auto, case_tac xs, auto)
  3.1142  
  3.1143  lemma take_take [simp]: "!!xs n. take n (take m xs) = take (min n m) xs"
  3.1144 -  apply (induct m)
  3.1145 -   apply auto
  3.1146 -  apply (case_tac xs)
  3.1147 -   apply auto
  3.1148 -  apply (case_tac na)
  3.1149 -   apply auto
  3.1150 -  done
  3.1151 +apply (induct m)
  3.1152 + apply auto
  3.1153 +apply (case_tac xs)
  3.1154 + apply auto
  3.1155 +apply (case_tac na)
  3.1156 + apply auto
  3.1157 +done
  3.1158  
  3.1159  lemma drop_drop [simp]: "!!xs. drop n (drop m xs) = drop (n + m) xs"
  3.1160 -  apply (induct m)
  3.1161 -   apply auto
  3.1162 -  apply (case_tac xs)
  3.1163 -   apply auto
  3.1164 -  done
  3.1165 +apply (induct m)
  3.1166 + apply auto
  3.1167 +apply (case_tac xs)
  3.1168 + apply auto
  3.1169 +done
  3.1170  
  3.1171  lemma take_drop: "!!xs n. take n (drop m xs) = drop m (take (n + m) xs)"
  3.1172 -  apply (induct m)
  3.1173 -   apply auto
  3.1174 -  apply (case_tac xs)
  3.1175 -   apply auto
  3.1176 -  done
  3.1177 +apply (induct m)
  3.1178 + apply auto
  3.1179 +apply (case_tac xs)
  3.1180 + apply auto
  3.1181 +done
  3.1182  
  3.1183  lemma append_take_drop_id [simp]: "!!xs. take n xs @ drop n xs = xs"
  3.1184 -  apply (induct n)
  3.1185 -   apply auto
  3.1186 -  apply (case_tac xs)
  3.1187 -   apply auto
  3.1188 -  done
  3.1189 +apply (induct n)
  3.1190 + apply auto
  3.1191 +apply (case_tac xs)
  3.1192 + apply auto
  3.1193 +done
  3.1194  
  3.1195  lemma take_map: "!!xs. take n (map f xs) = map f (take n xs)"
  3.1196 -  apply (induct n)
  3.1197 -   apply auto
  3.1198 -  apply (case_tac xs)
  3.1199 -   apply auto
  3.1200 -  done
  3.1201 +apply (induct n)
  3.1202 + apply auto
  3.1203 +apply (case_tac xs)
  3.1204 + apply auto
  3.1205 +done
  3.1206  
  3.1207  lemma drop_map: "!!xs. drop n (map f xs) = map f (drop n xs)"
  3.1208 -  apply (induct n)
  3.1209 -   apply auto
  3.1210 -  apply (case_tac xs)
  3.1211 -   apply auto
  3.1212 -  done
  3.1213 +apply (induct n)
  3.1214 + apply auto
  3.1215 +apply (case_tac xs)
  3.1216 + apply auto
  3.1217 +done
  3.1218  
  3.1219  lemma rev_take: "!!i. rev (take i xs) = drop (length xs - i) (rev xs)"
  3.1220 -  apply (induct xs)
  3.1221 -   apply auto
  3.1222 -  apply (case_tac i)
  3.1223 -   apply auto
  3.1224 -  done
  3.1225 +apply (induct xs)
  3.1226 + apply auto
  3.1227 +apply (case_tac i)
  3.1228 + apply auto
  3.1229 +done
  3.1230  
  3.1231  lemma rev_drop: "!!i. rev (drop i xs) = take (length xs - i) (rev xs)"
  3.1232 -  apply (induct xs)
  3.1233 -   apply auto
  3.1234 -  apply (case_tac i)
  3.1235 -   apply auto
  3.1236 -  done
  3.1237 +apply (induct xs)
  3.1238 + apply auto
  3.1239 +apply (case_tac i)
  3.1240 + apply auto
  3.1241 +done
  3.1242  
  3.1243  lemma nth_take [simp]: "!!n i. i < n ==> (take n xs)!i = xs!i"
  3.1244 -  apply (induct xs)
  3.1245 -   apply auto
  3.1246 -  apply (case_tac n)
  3.1247 -   apply(blast )
  3.1248 -  apply (case_tac i)
  3.1249 -   apply auto
  3.1250 -  done
  3.1251 +apply (induct xs)
  3.1252 + apply auto
  3.1253 +apply (case_tac n)
  3.1254 + apply(blast )
  3.1255 +apply (case_tac i)
  3.1256 + apply auto
  3.1257 +done
  3.1258  
  3.1259  lemma nth_drop [simp]:
  3.1260 -    "!!xs i. n + i <= length xs ==> (drop n xs)!i = xs!(n + i)"
  3.1261 -  apply (induct n)
  3.1262 -   apply auto
  3.1263 -  apply (case_tac xs)
  3.1264 -   apply auto
  3.1265 -  done
  3.1266 +"!!xs i. n + i <= length xs ==> (drop n xs)!i = xs!(n + i)"
  3.1267 +apply (induct n)
  3.1268 + apply auto
  3.1269 +apply (case_tac xs)
  3.1270 + apply auto
  3.1271 +done
  3.1272  
  3.1273  lemma append_eq_conv_conj:
  3.1274 -    "!!zs. (xs @ ys = zs) = (xs = take (length xs) zs \<and> ys = drop (length xs) zs)"
  3.1275 -  apply(induct xs)
  3.1276 -   apply simp
  3.1277 -  apply clarsimp
  3.1278 -  apply (case_tac zs)
  3.1279 -  apply auto
  3.1280 -  done
  3.1281 +"!!zs. (xs @ ys = zs) = (xs = take (length xs) zs \<and> ys = drop (length xs) zs)"
  3.1282 +apply(induct xs)
  3.1283 + apply simp
  3.1284 +apply clarsimp
  3.1285 +apply (case_tac zs)
  3.1286 +apply auto
  3.1287 +done
  3.1288  
  3.1289  
  3.1290  subsection {* @{text takeWhile} and @{text dropWhile} *}
  3.1291  
  3.1292  lemma takeWhile_dropWhile_id [simp]: "takeWhile P xs @ dropWhile P xs = xs"
  3.1293 -  by (induct xs) auto
  3.1294 +by (induct xs) auto
  3.1295  
  3.1296  lemma takeWhile_append1 [simp]:
  3.1297 -    "[| x:set xs; ~P(x)  |] ==> takeWhile P (xs @ ys) = takeWhile P xs"
  3.1298 -  by (induct xs) auto
  3.1299 +"[| x:set xs; ~P(x)|] ==> takeWhile P (xs @ ys) = takeWhile P xs"
  3.1300 +by (induct xs) auto
  3.1301  
  3.1302  lemma takeWhile_append2 [simp]:
  3.1303 -    "(!!x. x : set xs ==> P x) ==> takeWhile P (xs @ ys) = xs @ takeWhile P ys"
  3.1304 -  by (induct xs) auto
  3.1305 +"(!!x. x : set xs ==> P x) ==> takeWhile P (xs @ ys) = xs @ takeWhile P ys"
  3.1306 +by (induct xs) auto
  3.1307  
  3.1308  lemma takeWhile_tail: "\<not> P x ==> takeWhile P (xs @ (x#l)) = takeWhile P xs"
  3.1309 -  by (induct xs) auto
  3.1310 +by (induct xs) auto
  3.1311  
  3.1312  lemma dropWhile_append1 [simp]:
  3.1313 -    "[| x : set xs; ~P(x)  |] ==> dropWhile P (xs @ ys) = (dropWhile P xs)@ys"
  3.1314 -  by (induct xs) auto
  3.1315 +"[| x : set xs; ~P(x)|] ==> dropWhile P (xs @ ys) = (dropWhile P xs)@ys"
  3.1316 +by (induct xs) auto
  3.1317  
  3.1318  lemma dropWhile_append2 [simp]:
  3.1319 -    "(!!x. x:set xs ==> P(x)) ==> dropWhile P (xs @ ys) = dropWhile P ys"
  3.1320 -  by (induct xs) auto
  3.1321 +"(!!x. x:set xs ==> P(x)) ==> dropWhile P (xs @ ys) = dropWhile P ys"
  3.1322 +by (induct xs) auto
  3.1323  
  3.1324  lemma set_take_whileD: "x : set (takeWhile P xs) ==> x : set xs \<and> P x"
  3.1325 -  by (induct xs) (auto split: split_if_asm)
  3.1326 +by (induct xs) (auto split: split_if_asm)
  3.1327  
  3.1328  
  3.1329  subsection {* @{text zip} *}
  3.1330  
  3.1331  lemma zip_Nil [simp]: "zip [] ys = []"
  3.1332 -  by (induct ys) auto
  3.1333 +by (induct ys) auto
  3.1334  
  3.1335  lemma zip_Cons_Cons [simp]: "zip (x # xs) (y # ys) = (x, y) # zip xs ys"
  3.1336 -  by simp
  3.1337 +by simp
  3.1338  
  3.1339  declare zip_Cons [simp del]
  3.1340  
  3.1341  lemma length_zip [simp]:
  3.1342 -    "!!xs. length (zip xs ys) = min (length xs) (length ys)"
  3.1343 -  apply(induct ys)
  3.1344 -   apply simp
  3.1345 -  apply (case_tac xs)
  3.1346 -   apply auto
  3.1347 -  done
  3.1348 +"!!xs. length (zip xs ys) = min (length xs) (length ys)"
  3.1349 +apply(induct ys)
  3.1350 + apply simp
  3.1351 +apply (case_tac xs)
  3.1352 + apply auto
  3.1353 +done
  3.1354  
  3.1355  lemma zip_append1:
  3.1356 -  "!!xs. zip (xs @ ys) zs =
  3.1357 -      zip xs (take (length xs) zs) @ zip ys (drop (length xs) zs)"
  3.1358 -  apply (induct zs)
  3.1359 -   apply simp
  3.1360 -  apply (case_tac xs)
  3.1361 -   apply simp_all
  3.1362 -  done
  3.1363 +"!!xs. zip (xs @ ys) zs =
  3.1364 +zip xs (take (length xs) zs) @ zip ys (drop (length xs) zs)"
  3.1365 +apply (induct zs)
  3.1366 + apply simp
  3.1367 +apply (case_tac xs)
  3.1368 + apply simp_all
  3.1369 +done
  3.1370  
  3.1371  lemma zip_append2:
  3.1372 -  "!!ys. zip xs (ys @ zs) =
  3.1373 -      zip (take (length ys) xs) ys @ zip (drop (length ys) xs) zs"
  3.1374 -  apply (induct xs)
  3.1375 -   apply simp
  3.1376 -  apply (case_tac ys)
  3.1377 -   apply simp_all
  3.1378 -  done
  3.1379 +"!!ys. zip xs (ys @ zs) =
  3.1380 +zip (take (length ys) xs) ys @ zip (drop (length ys) xs) zs"
  3.1381 +apply (induct xs)
  3.1382 + apply simp
  3.1383 +apply (case_tac ys)
  3.1384 + apply simp_all
  3.1385 +done
  3.1386  
  3.1387  lemma zip_append [simp]:
  3.1388   "[| length xs = length us; length ys = length vs |] ==>
  3.1389 -    zip (xs@ys) (us@vs) = zip xs us @ zip ys vs"
  3.1390 -  by (simp add: zip_append1)
  3.1391 +zip (xs@ys) (us@vs) = zip xs us @ zip ys vs"
  3.1392 +by (simp add: zip_append1)
  3.1393  
  3.1394  lemma zip_rev:
  3.1395 -    "!!xs. length xs = length ys ==> zip (rev xs) (rev ys) = rev (zip xs ys)"
  3.1396 -  apply(induct ys)
  3.1397 -   apply simp
  3.1398 -  apply (case_tac xs)
  3.1399 -   apply simp_all
  3.1400 -  done
  3.1401 +"!!xs. length xs = length ys ==> zip (rev xs) (rev ys) = rev (zip xs ys)"
  3.1402 +apply(induct ys)
  3.1403 + apply simp
  3.1404 +apply (case_tac xs)
  3.1405 + apply simp_all
  3.1406 +done
  3.1407  
  3.1408  lemma nth_zip [simp]:
  3.1409 -  "!!i xs. [| i < length xs; i < length ys  |] ==> (zip xs ys)!i = (xs!i, ys!i)"
  3.1410 -  apply (induct ys)
  3.1411 -   apply simp
  3.1412 -  apply (case_tac xs)
  3.1413 -   apply (simp_all add: nth.simps split: nat.split)
  3.1414 -  done
  3.1415 +"!!i xs. [| i < length xs; i < length ys|] ==> (zip xs ys)!i = (xs!i, ys!i)"
  3.1416 +apply (induct ys)
  3.1417 + apply simp
  3.1418 +apply (case_tac xs)
  3.1419 + apply (simp_all add: nth.simps split: nat.split)
  3.1420 +done
  3.1421  
  3.1422  lemma set_zip:
  3.1423 -    "set (zip xs ys) = {(xs!i, ys!i) | i. i < min (length xs) (length ys)}"
  3.1424 -  by (simp add: set_conv_nth cong: rev_conj_cong)
  3.1425 +"set (zip xs ys) = {(xs!i, ys!i) | i. i < min (length xs) (length ys)}"
  3.1426 +by (simp add: set_conv_nth cong: rev_conj_cong)
  3.1427  
  3.1428  lemma zip_update:
  3.1429 -    "length xs = length ys ==> zip (xs[i:=x]) (ys[i:=y]) = (zip xs ys)[i:=(x,y)]"
  3.1430 -  by (rule sym, simp add: update_zip)
  3.1431 +"length xs = length ys ==> zip (xs[i:=x]) (ys[i:=y]) = (zip xs ys)[i:=(x,y)]"
  3.1432 +by (rule sym, simp add: update_zip)
  3.1433  
  3.1434  lemma zip_replicate [simp]:
  3.1435 -    "!!j. zip (replicate i x) (replicate j y) = replicate (min i j) (x,y)"
  3.1436 -  apply (induct i)
  3.1437 -   apply auto
  3.1438 -  apply (case_tac j)
  3.1439 -   apply auto
  3.1440 -  done
  3.1441 +"!!j. zip (replicate i x) (replicate j y) = replicate (min i j) (x,y)"
  3.1442 +apply (induct i)
  3.1443 + apply auto
  3.1444 +apply (case_tac j)
  3.1445 + apply auto
  3.1446 +done
  3.1447  
  3.1448  
  3.1449  subsection {* @{text list_all2} *}
  3.1450  
  3.1451  lemma list_all2_lengthD: "list_all2 P xs ys ==> length xs = length ys"
  3.1452 -  by (simp add: list_all2_def)
  3.1453 +by (simp add: list_all2_def)
  3.1454  
  3.1455  lemma list_all2_Nil [iff]: "list_all2 P [] ys = (ys = [])"
  3.1456 -  by (simp add: list_all2_def)
  3.1457 +by (simp add: list_all2_def)
  3.1458  
  3.1459  lemma list_all2_Nil2[iff]: "list_all2 P xs [] = (xs = [])"
  3.1460 -  by (simp add: list_all2_def)
  3.1461 +by (simp add: list_all2_def)
  3.1462  
  3.1463  lemma list_all2_Cons [iff]:
  3.1464 -    "list_all2 P (x # xs) (y # ys) = (P x y \<and> list_all2 P xs ys)"
  3.1465 -  by (auto simp add: list_all2_def)
  3.1466 +"list_all2 P (x # xs) (y # ys) = (P x y \<and> list_all2 P xs ys)"
  3.1467 +by (auto simp add: list_all2_def)
  3.1468  
  3.1469  lemma list_all2_Cons1:
  3.1470 -    "list_all2 P (x # xs) ys = (\<exists>z zs. ys = z # zs \<and> P x z \<and> list_all2 P xs zs)"
  3.1471 -  by (cases ys) auto
  3.1472 +"list_all2 P (x # xs) ys = (\<exists>z zs. ys = z # zs \<and> P x z \<and> list_all2 P xs zs)"
  3.1473 +by (cases ys) auto
  3.1474  
  3.1475  lemma list_all2_Cons2:
  3.1476 -    "list_all2 P xs (y # ys) = (\<exists>z zs. xs = z # zs \<and> P z y \<and> list_all2 P zs ys)"
  3.1477 -  by (cases xs) auto
  3.1478 +"list_all2 P xs (y # ys) = (\<exists>z zs. xs = z # zs \<and> P z y \<and> list_all2 P zs ys)"
  3.1479 +by (cases xs) auto
  3.1480  
  3.1481  lemma list_all2_rev [iff]:
  3.1482 -    "list_all2 P (rev xs) (rev ys) = list_all2 P xs ys"
  3.1483 -  by (simp add: list_all2_def zip_rev cong: conj_cong)
  3.1484 +"list_all2 P (rev xs) (rev ys) = list_all2 P xs ys"
  3.1485 +by (simp add: list_all2_def zip_rev cong: conj_cong)
  3.1486  
  3.1487  lemma list_all2_append1:
  3.1488 -  "list_all2 P (xs @ ys) zs =
  3.1489 -    (EX us vs. zs = us @ vs \<and> length us = length xs \<and> length vs = length ys \<and>
  3.1490 -      list_all2 P xs us \<and> list_all2 P ys vs)"
  3.1491 -  apply (simp add: list_all2_def zip_append1)
  3.1492 -  apply (rule iffI)
  3.1493 -   apply (rule_tac x = "take (length xs) zs" in exI)
  3.1494 -   apply (rule_tac x = "drop (length xs) zs" in exI)
  3.1495 -   apply (force split: nat_diff_split simp add: min_def)
  3.1496 -  apply clarify
  3.1497 -  apply (simp add: ball_Un)
  3.1498 -  done
  3.1499 +"list_all2 P (xs @ ys) zs =
  3.1500 +(EX us vs. zs = us @ vs \<and> length us = length xs \<and> length vs = length ys \<and>
  3.1501 +list_all2 P xs us \<and> list_all2 P ys vs)"
  3.1502 +apply (simp add: list_all2_def zip_append1)
  3.1503 +apply (rule iffI)
  3.1504 + apply (rule_tac x = "take (length xs) zs" in exI)
  3.1505 + apply (rule_tac x = "drop (length xs) zs" in exI)
  3.1506 + apply (force split: nat_diff_split simp add: min_def)
  3.1507 +apply clarify
  3.1508 +apply (simp add: ball_Un)
  3.1509 +done
  3.1510  
  3.1511  lemma list_all2_append2:
  3.1512 -  "list_all2 P xs (ys @ zs) =
  3.1513 -    (EX us vs. xs = us @ vs \<and> length us = length ys \<and> length vs = length zs \<and>
  3.1514 -      list_all2 P us ys \<and> list_all2 P vs zs)"
  3.1515 -  apply (simp add: list_all2_def zip_append2)
  3.1516 -  apply (rule iffI)
  3.1517 -   apply (rule_tac x = "take (length ys) xs" in exI)
  3.1518 -   apply (rule_tac x = "drop (length ys) xs" in exI)
  3.1519 -   apply (force split: nat_diff_split simp add: min_def)
  3.1520 -  apply clarify
  3.1521 -  apply (simp add: ball_Un)
  3.1522 -  done
  3.1523 +"list_all2 P xs (ys @ zs) =
  3.1524 +(EX us vs. xs = us @ vs \<and> length us = length ys \<and> length vs = length zs \<and>
  3.1525 +list_all2 P us ys \<and> list_all2 P vs zs)"
  3.1526 +apply (simp add: list_all2_def zip_append2)
  3.1527 +apply (rule iffI)
  3.1528 + apply (rule_tac x = "take (length ys) xs" in exI)
  3.1529 + apply (rule_tac x = "drop (length ys) xs" in exI)
  3.1530 + apply (force split: nat_diff_split simp add: min_def)
  3.1531 +apply clarify
  3.1532 +apply (simp add: ball_Un)
  3.1533 +done
  3.1534  
  3.1535  lemma list_all2_conv_all_nth:
  3.1536 -  "list_all2 P xs ys =
  3.1537 -    (length xs = length ys \<and> (\<forall>i < length xs. P (xs!i) (ys!i)))"
  3.1538 -  by (force simp add: list_all2_def set_zip)
  3.1539 +"list_all2 P xs ys =
  3.1540 +(length xs = length ys \<and> (\<forall>i < length xs. P (xs!i) (ys!i)))"
  3.1541 +by (force simp add: list_all2_def set_zip)
  3.1542  
  3.1543  lemma list_all2_trans[rule_format]:
  3.1544 -  "\<forall>a b c. P1 a b --> P2 b c --> P3 a c ==>
  3.1545 -    \<forall>bs cs. list_all2 P1 as bs --> list_all2 P2 bs cs --> list_all2 P3 as cs"
  3.1546 -  apply(induct_tac as)
  3.1547 -   apply simp
  3.1548 -  apply(rule allI)
  3.1549 -  apply(induct_tac bs)
  3.1550 -   apply simp
  3.1551 -  apply(rule allI)
  3.1552 -  apply(induct_tac cs)
  3.1553 -   apply auto
  3.1554 -  done
  3.1555 +"\<forall>a b c. P1 a b --> P2 b c --> P3 a c ==>
  3.1556 +\<forall>bs cs. list_all2 P1 as bs --> list_all2 P2 bs cs --> list_all2 P3 as cs"
  3.1557 +apply(induct_tac as)
  3.1558 + apply simp
  3.1559 +apply(rule allI)
  3.1560 +apply(induct_tac bs)
  3.1561 + apply simp
  3.1562 +apply(rule allI)
  3.1563 +apply(induct_tac cs)
  3.1564 + apply auto
  3.1565 +done
  3.1566  
  3.1567  
  3.1568  subsection {* @{text foldl} *}
  3.1569  
  3.1570  lemma foldl_append [simp]:
  3.1571 -  "!!a. foldl f a (xs @ ys) = foldl f (foldl f a xs) ys"
  3.1572 -  by (induct xs) auto
  3.1573 +"!!a. foldl f a (xs @ ys) = foldl f (foldl f a xs) ys"
  3.1574 +by (induct xs) auto
  3.1575  
  3.1576  text {*
  3.1577 -  Note: @{text "n \<le> foldl (op +) n ns"} looks simpler, but is more
  3.1578 -  difficult to use because it requires an additional transitivity step.
  3.1579 +Note: @{text "n \<le> foldl (op +) n ns"} looks simpler, but is more
  3.1580 +difficult to use because it requires an additional transitivity step.
  3.1581  *}
  3.1582  
  3.1583  lemma start_le_sum: "!!n::nat. m <= n ==> m <= foldl (op +) n ns"
  3.1584 -  by (induct ns) auto
  3.1585 +by (induct ns) auto
  3.1586  
  3.1587  lemma elem_le_sum: "!!n::nat. n : set ns ==> n <= foldl (op +) 0 ns"
  3.1588 -  by (force intro: start_le_sum simp add: in_set_conv_decomp)
  3.1589 +by (force intro: start_le_sum simp add: in_set_conv_decomp)
  3.1590  
  3.1591  lemma sum_eq_0_conv [iff]:
  3.1592 -    "!!m::nat. (foldl (op +) m ns = 0) = (m = 0 \<and> (\<forall>n \<in> set ns. n = 0))"
  3.1593 -  by (induct ns) auto
  3.1594 +"!!m::nat. (foldl (op +) m ns = 0) = (m = 0 \<and> (\<forall>n \<in> set ns. n = 0))"
  3.1595 +by (induct ns) auto
  3.1596  
  3.1597  
  3.1598  subsection {* @{text upto} *}
  3.1599  
  3.1600  lemma upt_rec: "[i..j(] = (if i<j then i#[Suc i..j(] else [])"
  3.1601 -  -- {* Does not terminate! *}
  3.1602 -  by (induct j) auto
  3.1603 +-- {* Does not terminate! *}
  3.1604 +by (induct j) auto
  3.1605  
  3.1606  lemma upt_conv_Nil [simp]: "j <= i ==> [i..j(] = []"
  3.1607 -  by (subst upt_rec) simp
  3.1608 +by (subst upt_rec) simp
  3.1609  
  3.1610  lemma upt_Suc_append: "i <= j ==> [i..(Suc j)(] = [i..j(]@[j]"
  3.1611 -  -- {* Only needed if @{text upt_Suc} is deleted from the simpset. *}
  3.1612 -  by simp
  3.1613 +-- {* Only needed if @{text upt_Suc} is deleted from the simpset. *}
  3.1614 +by simp
  3.1615  
  3.1616  lemma upt_conv_Cons: "i < j ==> [i..j(] = i # [Suc i..j(]"
  3.1617 -  apply(rule trans)
  3.1618 -  apply(subst upt_rec)
  3.1619 -   prefer 2 apply(rule refl)
  3.1620 -  apply simp
  3.1621 -  done
  3.1622 +apply(rule trans)
  3.1623 +apply(subst upt_rec)
  3.1624 + prefer 2 apply(rule refl)
  3.1625 +apply simp
  3.1626 +done
  3.1627  
  3.1628  lemma upt_add_eq_append: "i<=j ==> [i..j+k(] = [i..j(]@[j..j+k(]"
  3.1629 -  -- {* LOOPS as a simprule, since @{text "j <= j"}. *}
  3.1630 -  by (induct k) auto
  3.1631 +-- {* LOOPS as a simprule, since @{text "j <= j"}. *}
  3.1632 +by (induct k) auto
  3.1633  
  3.1634  lemma length_upt [simp]: "length [i..j(] = j - i"
  3.1635 -  by (induct j) (auto simp add: Suc_diff_le)
  3.1636 +by (induct j) (auto simp add: Suc_diff_le)
  3.1637  
  3.1638  lemma nth_upt [simp]: "i + k < j ==> [i..j(] ! k = i + k"
  3.1639 -  apply (induct j)
  3.1640 -  apply (auto simp add: less_Suc_eq nth_append split: nat_diff_split)
  3.1641 -  done
  3.1642 +apply (induct j)
  3.1643 +apply (auto simp add: less_Suc_eq nth_append split: nat_diff_split)
  3.1644 +done
  3.1645  
  3.1646  lemma take_upt [simp]: "!!i. i+m <= n ==> take m [i..n(] = [i..i+m(]"
  3.1647 -  apply (induct m)
  3.1648 -   apply simp
  3.1649 -  apply (subst upt_rec)
  3.1650 -  apply (rule sym)
  3.1651 -  apply (subst upt_rec)
  3.1652 -  apply (simp del: upt.simps)
  3.1653 -  done
  3.1654 +apply (induct m)
  3.1655 + apply simp
  3.1656 +apply (subst upt_rec)
  3.1657 +apply (rule sym)
  3.1658 +apply (subst upt_rec)
  3.1659 +apply (simp del: upt.simps)
  3.1660 +done
  3.1661  
  3.1662  lemma map_Suc_upt: "map Suc [m..n(] = [Suc m..n]"
  3.1663 -  by (induct n) auto
  3.1664 +by (induct n) auto
  3.1665  
  3.1666  lemma nth_map_upt: "!!i. i < n-m ==> (map f [m..n(]) ! i = f(m+i)"
  3.1667 -  apply (induct n m rule: diff_induct)
  3.1668 -    prefer 3 apply (subst map_Suc_upt[symmetric])
  3.1669 -    apply (auto simp add: less_diff_conv nth_upt)
  3.1670 -  done
  3.1671 +apply (induct n m rule: diff_induct)
  3.1672 +prefer 3 apply (subst map_Suc_upt[symmetric])
  3.1673 +apply (auto simp add: less_diff_conv nth_upt)
  3.1674 +done
  3.1675  
  3.1676  lemma nth_take_lemma [rule_format]:
  3.1677 -  "ALL xs ys. k <= length xs --> k <= length ys
  3.1678 -    --> (ALL i. i < k --> xs!i = ys!i)
  3.1679 -    --> take k xs = take k ys"
  3.1680 -  apply (induct k)
  3.1681 -  apply (simp_all add: less_Suc_eq_0_disj all_conj_distrib)
  3.1682 -  apply clarify
  3.1683 -  txt {* Both lists must be non-empty *}
  3.1684 -  apply (case_tac xs)
  3.1685 -   apply simp
  3.1686 -  apply (case_tac ys)
  3.1687 -   apply clarify
  3.1688 -   apply (simp (no_asm_use))
  3.1689 -  apply clarify
  3.1690 -  txt {* prenexing's needed, not miniscoping *}
  3.1691 -  apply (simp (no_asm_use) add: all_simps [symmetric] del: all_simps)
  3.1692 -  apply blast
  3.1693 -  done
  3.1694 +"ALL xs ys. k <= length xs --> k <= length ys
  3.1695 +--> (ALL i. i < k --> xs!i = ys!i)
  3.1696 +--> take k xs = take k ys"
  3.1697 +apply (induct k)
  3.1698 +apply (simp_all add: less_Suc_eq_0_disj all_conj_distrib)
  3.1699 +apply clarify
  3.1700 +txt {* Both lists must be non-empty *}
  3.1701 +apply (case_tac xs)
  3.1702 + apply simp
  3.1703 +apply (case_tac ys)
  3.1704 + apply clarify
  3.1705 + apply (simp (no_asm_use))
  3.1706 +apply clarify
  3.1707 +txt {* prenexing's needed, not miniscoping *}
  3.1708 +apply (simp (no_asm_use) add: all_simps [symmetric] del: all_simps)
  3.1709 +apply blast
  3.1710 +done
  3.1711  
  3.1712  lemma nth_equalityI:
  3.1713   "[| length xs = length ys; ALL i < length xs. xs!i = ys!i |] ==> xs = ys"
  3.1714 -  apply (frule nth_take_lemma [OF le_refl eq_imp_le])
  3.1715 -  apply (simp_all add: take_all)
  3.1716 -  done
  3.1717 +apply (frule nth_take_lemma [OF le_refl eq_imp_le])
  3.1718 +apply (simp_all add: take_all)
  3.1719 +done
  3.1720  
  3.1721  lemma take_equalityI: "(\<forall>i. take i xs = take i ys) ==> xs = ys"
  3.1722 -  -- {* The famous take-lemma. *}
  3.1723 -  apply (drule_tac x = "max (length xs) (length ys)" in spec)
  3.1724 -  apply (simp add: le_max_iff_disj take_all)
  3.1725 -  done
  3.1726 +-- {* The famous take-lemma. *}
  3.1727 +apply (drule_tac x = "max (length xs) (length ys)" in spec)
  3.1728 +apply (simp add: le_max_iff_disj take_all)
  3.1729 +done
  3.1730  
  3.1731  
  3.1732  subsection {* @{text "distinct"} and @{text remdups} *}
  3.1733  
  3.1734  lemma distinct_append [simp]:
  3.1735 -    "distinct (xs @ ys) = (distinct xs \<and> distinct ys \<and> set xs \<inter> set ys = {})"
  3.1736 -  by (induct xs) auto
  3.1737 +"distinct (xs @ ys) = (distinct xs \<and> distinct ys \<and> set xs \<inter> set ys = {})"
  3.1738 +by (induct xs) auto
  3.1739  
  3.1740  lemma set_remdups [simp]: "set (remdups xs) = set xs"
  3.1741 -  by (induct xs) (auto simp add: insert_absorb)
  3.1742 +by (induct xs) (auto simp add: insert_absorb)
  3.1743  
  3.1744  lemma distinct_remdups [iff]: "distinct (remdups xs)"
  3.1745 -  by (induct xs) auto
  3.1746 +by (induct xs) auto
  3.1747  
  3.1748  lemma distinct_filter [simp]: "distinct xs ==> distinct (filter P xs)"
  3.1749 -  by (induct xs) auto
  3.1750 +by (induct xs) auto
  3.1751  
  3.1752  text {*
  3.1753 -  It is best to avoid this indexed version of distinct, but sometimes
  3.1754 -  it is useful. *}
  3.1755 +It is best to avoid this indexed version of distinct, but sometimes
  3.1756 +it is useful. *}
  3.1757  lemma distinct_conv_nth:
  3.1758 -    "distinct xs = (\<forall>i j. i < size xs \<and> j < size xs \<and> i \<noteq> j --> xs!i \<noteq> xs!j)"
  3.1759 -  apply (induct_tac xs)
  3.1760 -   apply simp
  3.1761 -  apply simp
  3.1762 -  apply (rule iffI)
  3.1763 -   apply clarsimp
  3.1764 -   apply (case_tac i)
  3.1765 -    apply (case_tac j)
  3.1766 -     apply simp
  3.1767 -    apply (simp add: set_conv_nth)
  3.1768 -   apply (case_tac j)
  3.1769 -    apply (clarsimp simp add: set_conv_nth)
  3.1770 -   apply simp
  3.1771 -  apply (rule conjI)
  3.1772 -   apply (clarsimp simp add: set_conv_nth)
  3.1773 -   apply (erule_tac x = 0 in allE)
  3.1774 -   apply (erule_tac x = "Suc i" in allE)
  3.1775 -   apply simp
  3.1776 -  apply clarsimp
  3.1777 -  apply (erule_tac x = "Suc i" in allE)
  3.1778 -  apply (erule_tac x = "Suc j" in allE)
  3.1779 -  apply simp
  3.1780 -  done
  3.1781 +"distinct xs = (\<forall>i j. i < size xs \<and> j < size xs \<and> i \<noteq> j --> xs!i \<noteq> xs!j)"
  3.1782 +apply (induct_tac xs)
  3.1783 + apply simp
  3.1784 +apply simp
  3.1785 +apply (rule iffI)
  3.1786 + apply clarsimp
  3.1787 + apply (case_tac i)
  3.1788 +apply (case_tac j)
  3.1789 + apply simp
  3.1790 +apply (simp add: set_conv_nth)
  3.1791 + apply (case_tac j)
  3.1792 +apply (clarsimp simp add: set_conv_nth)
  3.1793 + apply simp
  3.1794 +apply (rule conjI)
  3.1795 + apply (clarsimp simp add: set_conv_nth)
  3.1796 + apply (erule_tac x = 0 in allE)
  3.1797 + apply (erule_tac x = "Suc i" in allE)
  3.1798 + apply simp
  3.1799 +apply clarsimp
  3.1800 +apply (erule_tac x = "Suc i" in allE)
  3.1801 +apply (erule_tac x = "Suc j" in allE)
  3.1802 +apply simp
  3.1803 +done
  3.1804  
  3.1805  
  3.1806  subsection {* @{text replicate} *}
  3.1807  
  3.1808  lemma length_replicate [simp]: "length (replicate n x) = n"
  3.1809 -  by (induct n) auto
  3.1810 +by (induct n) auto
  3.1811  
  3.1812  lemma map_replicate [simp]: "map f (replicate n x) = replicate n (f x)"
  3.1813 -  by (induct n) auto
  3.1814 +by (induct n) auto
  3.1815  
  3.1816  lemma replicate_app_Cons_same:
  3.1817 -    "(replicate n x) @ (x # xs) = x # replicate n x @ xs"
  3.1818 -  by (induct n) auto
  3.1819 +"(replicate n x) @ (x # xs) = x # replicate n x @ xs"
  3.1820 +by (induct n) auto
  3.1821  
  3.1822  lemma rev_replicate [simp]: "rev (replicate n x) = replicate n x"
  3.1823 -  apply(induct n)
  3.1824 -   apply simp
  3.1825 -  apply (simp add: replicate_app_Cons_same)
  3.1826 -  done
  3.1827 +apply(induct n)
  3.1828 + apply simp
  3.1829 +apply (simp add: replicate_app_Cons_same)
  3.1830 +done
  3.1831  
  3.1832  lemma replicate_add: "replicate (n + m) x = replicate n x @ replicate m x"
  3.1833 -  by (induct n) auto
  3.1834 +by (induct n) auto
  3.1835  
  3.1836  lemma hd_replicate [simp]: "n \<noteq> 0 ==> hd (replicate n x) = x"
  3.1837 -  by (induct n) auto
  3.1838 +by (induct n) auto
  3.1839  
  3.1840  lemma tl_replicate [simp]: "n \<noteq> 0 ==> tl (replicate n x) = replicate (n - 1) x"
  3.1841 -  by (induct n) auto
  3.1842 +by (induct n) auto
  3.1843  
  3.1844  lemma last_replicate [simp]: "n \<noteq> 0 ==> last (replicate n x) = x"
  3.1845 -  by (atomize (full), induct n) auto
  3.1846 +by (atomize (full), induct n) auto
  3.1847  
  3.1848  lemma nth_replicate[simp]: "!!i. i < n ==> (replicate n x)!i = x"
  3.1849 -  apply(induct n)
  3.1850 -   apply simp
  3.1851 -  apply (simp add: nth_Cons split: nat.split)
  3.1852 -  done
  3.1853 +apply(induct n)
  3.1854 + apply simp
  3.1855 +apply (simp add: nth_Cons split: nat.split)
  3.1856 +done
  3.1857  
  3.1858  lemma set_replicate_Suc: "set (replicate (Suc n) x) = {x}"
  3.1859 -  by (induct n) auto
  3.1860 +by (induct n) auto
  3.1861  
  3.1862  lemma set_replicate [simp]: "n \<noteq> 0 ==> set (replicate n x) = {x}"
  3.1863 -  by (fast dest!: not0_implies_Suc intro!: set_replicate_Suc)
  3.1864 +by (fast dest!: not0_implies_Suc intro!: set_replicate_Suc)
  3.1865  
  3.1866  lemma set_replicate_conv_if: "set (replicate n x) = (if n = 0 then {} else {x})"
  3.1867 -  by auto
  3.1868 +by auto
  3.1869  
  3.1870  lemma in_set_replicateD: "x : set (replicate n y) ==> x = y"
  3.1871 -  by (simp add: set_replicate_conv_if split: split_if_asm)
  3.1872 +by (simp add: set_replicate_conv_if split: split_if_asm)
  3.1873  
  3.1874  
  3.1875  subsection {* Lexcicographic orderings on lists *}
  3.1876  
  3.1877  lemma wf_lexn: "wf r ==> wf (lexn r n)"
  3.1878 -  apply (induct_tac n)
  3.1879 -   apply simp
  3.1880 -  apply simp
  3.1881 -  apply(rule wf_subset)
  3.1882 -   prefer 2 apply (rule Int_lower1)
  3.1883 -  apply(rule wf_prod_fun_image)
  3.1884 -   prefer 2 apply (rule injI)
  3.1885 -  apply auto
  3.1886 -  done
  3.1887 +apply (induct_tac n)
  3.1888 + apply simp
  3.1889 +apply simp
  3.1890 +apply(rule wf_subset)
  3.1891 + prefer 2 apply (rule Int_lower1)
  3.1892 +apply(rule wf_prod_fun_image)
  3.1893 + prefer 2 apply (rule injI)
  3.1894 +apply auto
  3.1895 +done
  3.1896  
  3.1897  lemma lexn_length:
  3.1898 -    "!!xs ys. (xs, ys) : lexn r n ==> length xs = n \<and> length ys = n"
  3.1899 -  by (induct n) auto
  3.1900 +"!!xs ys. (xs, ys) : lexn r n ==> length xs = n \<and> length ys = n"
  3.1901 +by (induct n) auto
  3.1902  
  3.1903  lemma wf_lex [intro!]: "wf r ==> wf (lex r)"
  3.1904 -  apply (unfold lex_def)
  3.1905 -  apply (rule wf_UN)
  3.1906 -  apply (blast intro: wf_lexn)
  3.1907 -  apply clarify
  3.1908 -  apply (rename_tac m n)
  3.1909 -  apply (subgoal_tac "m \<noteq> n")
  3.1910 -   prefer 2 apply blast
  3.1911 -  apply (blast dest: lexn_length not_sym)
  3.1912 -  done
  3.1913 +apply (unfold lex_def)
  3.1914 +apply (rule wf_UN)
  3.1915 +apply (blast intro: wf_lexn)
  3.1916 +apply clarify
  3.1917 +apply (rename_tac m n)
  3.1918 +apply (subgoal_tac "m \<noteq> n")
  3.1919 + prefer 2 apply blast
  3.1920 +apply (blast dest: lexn_length not_sym)
  3.1921 +done
  3.1922  
  3.1923  lemma lexn_conv:
  3.1924 -  "lexn r n =
  3.1925 -    {(xs,ys). length xs = n \<and> length ys = n \<and>
  3.1926 -      (\<exists>xys x y xs' ys'. xs= xys @ x#xs' \<and> ys= xys @ y # ys' \<and> (x, y):r)}"
  3.1927 -  apply (induct_tac n)
  3.1928 -   apply simp
  3.1929 -   apply blast
  3.1930 -  apply (simp add: image_Collect lex_prod_def)
  3.1931 -  apply auto
  3.1932 -    apply blast
  3.1933 -   apply (rename_tac a xys x xs' y ys')
  3.1934 -   apply (rule_tac x = "a # xys" in exI)
  3.1935 -   apply simp
  3.1936 -  apply (case_tac xys)
  3.1937 -   apply simp_all
  3.1938 -  apply blast
  3.1939 -  done
  3.1940 +"lexn r n =
  3.1941 +{(xs,ys). length xs = n \<and> length ys = n \<and>
  3.1942 +(\<exists>xys x y xs' ys'. xs= xys @ x#xs' \<and> ys= xys @ y # ys' \<and> (x, y):r)}"
  3.1943 +apply (induct_tac n)
  3.1944 + apply simp
  3.1945 + apply blast
  3.1946 +apply (simp add: image_Collect lex_prod_def)
  3.1947 +apply auto
  3.1948 +apply blast
  3.1949 + apply (rename_tac a xys x xs' y ys')
  3.1950 + apply (rule_tac x = "a # xys" in exI)
  3.1951 + apply simp
  3.1952 +apply (case_tac xys)
  3.1953 + apply simp_all
  3.1954 +apply blast
  3.1955 +done
  3.1956  
  3.1957  lemma lex_conv:
  3.1958 -  "lex r =
  3.1959 -    {(xs,ys). length xs = length ys \<and>
  3.1960 -      (\<exists>xys x y xs' ys'. xs = xys @ x # xs' \<and> ys = xys @ y # ys' \<and> (x, y):r)}"
  3.1961 -  by (force simp add: lex_def lexn_conv)
  3.1962 +"lex r =
  3.1963 +{(xs,ys). length xs = length ys \<and>
  3.1964 +(\<exists>xys x y xs' ys'. xs = xys @ x # xs' \<and> ys = xys @ y # ys' \<and> (x, y):r)}"
  3.1965 +by (force simp add: lex_def lexn_conv)
  3.1966  
  3.1967  lemma wf_lexico [intro!]: "wf r ==> wf (lexico r)"
  3.1968 -  by (unfold lexico_def) blast
  3.1969 +by (unfold lexico_def) blast
  3.1970  
  3.1971  lemma lexico_conv:
  3.1972 -  "lexico r = {(xs,ys). length xs < length ys |
  3.1973 -      length xs = length ys \<and> (xs, ys) : lex r}"
  3.1974 -  by (simp add: lexico_def diag_def lex_prod_def measure_def inv_image_def)
  3.1975 +"lexico r = {(xs,ys). length xs < length ys |
  3.1976 +length xs = length ys \<and> (xs, ys) : lex r}"
  3.1977 +by (simp add: lexico_def diag_def lex_prod_def measure_def inv_image_def)
  3.1978  
  3.1979  lemma Nil_notin_lex [iff]: "([], ys) \<notin> lex r"
  3.1980 -  by (simp add: lex_conv)
  3.1981 +by (simp add: lex_conv)
  3.1982  
  3.1983  lemma Nil2_notin_lex [iff]: "(xs, []) \<notin> lex r"
  3.1984 -  by (simp add:lex_conv)
  3.1985 +by (simp add:lex_conv)
  3.1986  
  3.1987  lemma Cons_in_lex [iff]:
  3.1988 -  "((x # xs, y # ys) : lex r) =
  3.1989 -    ((x, y) : r \<and> length xs = length ys | x = y \<and> (xs, ys) : lex r)"
  3.1990 -  apply (simp add: lex_conv)
  3.1991 -  apply (rule iffI)
  3.1992 -   prefer 2 apply (blast intro: Cons_eq_appendI)
  3.1993 -  apply clarify
  3.1994 -  apply (case_tac xys)
  3.1995 -   apply simp
  3.1996 -  apply simp
  3.1997 -  apply blast
  3.1998 -  done
  3.1999 +"((x # xs, y # ys) : lex r) =
  3.2000 +((x, y) : r \<and> length xs = length ys | x = y \<and> (xs, ys) : lex r)"
  3.2001 +apply (simp add: lex_conv)
  3.2002 +apply (rule iffI)
  3.2003 + prefer 2 apply (blast intro: Cons_eq_appendI)
  3.2004 +apply clarify
  3.2005 +apply (case_tac xys)
  3.2006 + apply simp
  3.2007 +apply simp
  3.2008 +apply blast
  3.2009 +done
  3.2010  
  3.2011  
  3.2012  subsection {* @{text sublist} --- a generalization of @{text nth} to sets *}
  3.2013  
  3.2014  lemma sublist_empty [simp]: "sublist xs {} = []"
  3.2015 -  by (auto simp add: sublist_def)
  3.2016 +by (auto simp add: sublist_def)
  3.2017  
  3.2018  lemma sublist_nil [simp]: "sublist [] A = []"
  3.2019 -  by (auto simp add: sublist_def)
  3.2020 +by (auto simp add: sublist_def)
  3.2021  
  3.2022  lemma sublist_shift_lemma:
  3.2023 -  "map fst [p:zip xs [i..i + length xs(] . snd p : A] =
  3.2024 -    map fst [p:zip xs [0..length xs(] . snd p + i : A]"
  3.2025 -  by (induct xs rule: rev_induct) (simp_all add: add_commute)
  3.2026 +"map fst [p:zip xs [i..i + length xs(] . snd p : A] =
  3.2027 +map fst [p:zip xs [0..length xs(] . snd p + i : A]"
  3.2028 +by (induct xs rule: rev_induct) (simp_all add: add_commute)
  3.2029  
  3.2030  lemma sublist_append:
  3.2031 -    "sublist (l @ l') A = sublist l A @ sublist l' {j. j + length l : A}"
  3.2032 -  apply (unfold sublist_def)
  3.2033 -  apply (induct l' rule: rev_induct)
  3.2034 -   apply simp
  3.2035 -  apply (simp add: upt_add_eq_append[of 0] zip_append sublist_shift_lemma)
  3.2036 -  apply (simp add: add_commute)
  3.2037 -  done
  3.2038 +"sublist (l @ l') A = sublist l A @ sublist l' {j. j + length l : A}"
  3.2039 +apply (unfold sublist_def)
  3.2040 +apply (induct l' rule: rev_induct)
  3.2041 + apply simp
  3.2042 +apply (simp add: upt_add_eq_append[of 0] zip_append sublist_shift_lemma)
  3.2043 +apply (simp add: add_commute)
  3.2044 +done
  3.2045  
  3.2046  lemma sublist_Cons:
  3.2047 -    "sublist (x # l) A = (if 0:A then [x] else []) @ sublist l {j. Suc j : A}"
  3.2048 -  apply (induct l rule: rev_induct)
  3.2049 -   apply (simp add: sublist_def)
  3.2050 -  apply (simp del: append_Cons add: append_Cons[symmetric] sublist_append)
  3.2051 -  done
  3.2052 +"sublist (x # l) A = (if 0:A then [x] else []) @ sublist l {j. Suc j : A}"
  3.2053 +apply (induct l rule: rev_induct)
  3.2054 + apply (simp add: sublist_def)
  3.2055 +apply (simp del: append_Cons add: append_Cons[symmetric] sublist_append)
  3.2056 +done
  3.2057  
  3.2058  lemma sublist_singleton [simp]: "sublist [x] A = (if 0 : A then [x] else [])"
  3.2059 -  by (simp add: sublist_Cons)
  3.2060 +by (simp add: sublist_Cons)
  3.2061  
  3.2062  lemma sublist_upt_eq_take [simp]: "sublist l {..n(} = take n l"
  3.2063 -  apply (induct l rule: rev_induct)
  3.2064 -   apply simp
  3.2065 -  apply (simp split: nat_diff_split add: sublist_append)
  3.2066 -  done
  3.2067 +apply (induct l rule: rev_induct)
  3.2068 + apply simp
  3.2069 +apply (simp split: nat_diff_split add: sublist_append)
  3.2070 +done
  3.2071  
  3.2072  
  3.2073  lemma take_Cons':
  3.2074 -    "take n (x # xs) = (if n = 0 then [] else x # take (n - 1) xs)"
  3.2075 -  by (cases n) simp_all
  3.2076 +"take n (x # xs) = (if n = 0 then [] else x # take (n - 1) xs)"
  3.2077 +by (cases n) simp_all
  3.2078  
  3.2079  lemma drop_Cons':
  3.2080 -    "drop n (x # xs) = (if n = 0 then x # xs else drop (n - 1) xs)"
  3.2081 -  by (cases n) simp_all
  3.2082 +"drop n (x # xs) = (if n = 0 then x # xs else drop (n - 1) xs)"
  3.2083 +by (cases n) simp_all
  3.2084  
  3.2085  lemma nth_Cons': "(x # xs)!n = (if n = 0 then x else xs!(n - 1))"
  3.2086 -  by (cases n) simp_all
  3.2087 +by (cases n) simp_all
  3.2088  
  3.2089 -lemmas [of "number_of v", standard, simp] =
  3.2090 -  take_Cons' drop_Cons' nth_Cons'
  3.2091 +lemmas [simp] = take_Cons'[of "number_of v",standard]
  3.2092 +                drop_Cons'[of "number_of v",standard]
  3.2093 +                nth_Cons'[of _ _ "number_of v",standard]
  3.2094  
  3.2095  end
     4.1 --- a/src/HOL/UNITY/Comp/AllocBase.ML	Mon May 13 13:22:15 2002 +0200
     4.2 +++ b/src/HOL/UNITY/Comp/AllocBase.ML	Mon May 13 15:27:28 2002 +0200
     4.3 @@ -56,7 +56,7 @@
     4.4  
     4.5  Goal "bag_of (sublist l A) = \
     4.6  \     (\\<Sum>i: A Int lessThan (length l). {# l!i #})";
     4.7 -by (rev_induct_tac "l" 1);
     4.8 +by (res_inst_tac [("xs","l")] rev_induct 1);
     4.9  by (Simp_tac 1);
    4.10  by (asm_simp_tac
    4.11      (simpset() addsimps [sublist_append, Int_insert_right, lessThan_Suc, 
     5.1 --- a/src/HOL/UNITY/GenPrefix.ML	Mon May 13 13:22:15 2002 +0200
     5.2 +++ b/src/HOL/UNITY/GenPrefix.ML	Mon May 13 15:27:28 2002 +0200
     5.3 @@ -341,7 +341,7 @@
     5.4  Addsimps [prefix_snoc];
     5.5  
     5.6  Goal "(xs <= ys@zs) = (xs <= ys | (? us. xs = ys@us & us <= zs))";
     5.7 -by (rev_induct_tac "zs" 1);
     5.8 +by (res_inst_tac [("xs","zs")] rev_induct 1);
     5.9   by (Force_tac 1);
    5.10  by (asm_full_simp_tac (simpset() delsimps [append_assoc]
    5.11                                   addsimps [append_assoc RS sym])1);
    5.12 @@ -351,7 +351,7 @@
    5.13  (*Although the prefix ordering is not linear, the prefixes of a list
    5.14    are linearly ordered.*)
    5.15  Goal "!!zs::'a list. xs <= zs --> ys <= zs --> xs <= ys | ys <= xs";
    5.16 -by (rev_induct_tac "zs" 1);
    5.17 +by (res_inst_tac [("xs","zs")] rev_induct 1);
    5.18  by Auto_tac;
    5.19  qed_spec_mp "common_prefix_linear";
    5.20