equal
deleted
inserted
replaced
223 inductive_cases listsE [elim!]: "x#l : lists A" |
223 inductive_cases listsE [elim!]: "x#l : lists A" |
224 |
224 |
225 lemma lists_mono [mono]: "A \<subseteq> B ==> lists A \<subseteq> lists B" |
225 lemma lists_mono [mono]: "A \<subseteq> B ==> lists A \<subseteq> lists B" |
226 by (unfold lists.defs) (blast intro!: lfp_mono) |
226 by (unfold lists.defs) (blast intro!: lfp_mono) |
227 |
227 |
228 lemma lists_IntI [rule_format]: |
228 lemma lists_IntI: |
229 "l: lists A ==> l: lists B --> l: lists (A Int B)" |
229 assumes l: "l: lists A" shows "l: lists B ==> l: lists (A Int B)" using l |
230 apply (erule lists.induct) |
230 by induct blast+ |
231 apply blast+ |
|
232 done |
|
233 |
231 |
234 lemma lists_Int_eq [simp]: "lists (A \<inter> B) = lists A \<inter> lists B" |
232 lemma lists_Int_eq [simp]: "lists (A \<inter> B) = lists A \<inter> lists B" |
235 apply (rule mono_Int [THEN equalityI]) |
233 apply (rule mono_Int [THEN equalityI]) |
236 apply (simp add: mono_def lists_mono) |
234 apply (simp add: mono_def lists_mono) |
237 apply (blast intro!: lists_IntI) |
235 apply (blast intro!: lists_IntI) |
290 by (induct xs) auto |
288 by (induct xs) auto |
291 |
289 |
292 lemma self_append_conv [iff]: "(xs = xs @ ys) = (ys = [])" |
290 lemma self_append_conv [iff]: "(xs = xs @ ys) = (ys = [])" |
293 by (induct xs) auto |
291 by (induct xs) auto |
294 |
292 |
295 lemma append_eq_append_conv [rule_format, simp]: |
293 lemma append_eq_append_conv [simp]: |
296 "\<forall>ys. length xs = length ys \<or> length us = length vs |
294 "!!ys. length xs = length ys \<or> length us = length vs |
297 --> (xs@us = ys@vs) = (xs=ys \<and> us=vs)" |
295 ==> (xs@us = ys@vs) = (xs=ys \<and> us=vs)" |
298 apply (induct_tac xs) |
296 apply (induct xs) |
299 apply(rule allI) |
|
300 apply (case_tac ys) |
297 apply (case_tac ys) |
301 apply simp |
298 apply simp |
302 apply force |
299 apply force |
303 apply (rule allI) |
|
304 apply (case_tac ys) |
300 apply (case_tac ys) |
305 apply force |
301 apply force |
306 apply simp |
302 apply simp |
307 done |
303 done |
308 |
304 |
1039 lemma list_all2_conv_all_nth: |
1035 lemma list_all2_conv_all_nth: |
1040 "list_all2 P xs ys = |
1036 "list_all2 P xs ys = |
1041 (length xs = length ys \<and> (\<forall>i < length xs. P (xs!i) (ys!i)))" |
1037 (length xs = length ys \<and> (\<forall>i < length xs. P (xs!i) (ys!i)))" |
1042 by (force simp add: list_all2_def set_zip) |
1038 by (force simp add: list_all2_def set_zip) |
1043 |
1039 |
|
1040 lemma list_all2_trans: |
|
1041 assumes tr: "!!a b c. P1 a b ==> P2 b c ==> P3 a c" |
|
1042 shows "!!bs cs. list_all2 P1 as bs ==> list_all2 P2 bs cs ==> list_all2 P3 as cs" |
|
1043 (is "!!bs cs. PROP ?Q as bs cs") |
|
1044 proof (induct as) |
|
1045 fix x xs bs assume I1: "!!bs cs. PROP ?Q xs bs cs" |
|
1046 show "!!cs. PROP ?Q (x # xs) bs cs" |
|
1047 proof (induct bs) |
|
1048 fix y ys cs assume I2: "!!cs. PROP ?Q (x # xs) ys cs" |
|
1049 show "PROP ?Q (x # xs) (y # ys) cs" |
|
1050 by (induct cs) (auto intro: tr I1 I2) |
|
1051 qed simp |
|
1052 qed simp |
|
1053 |
1044 lemma list_all2_all_nthI [intro?]: |
1054 lemma list_all2_all_nthI [intro?]: |
1045 "length a = length b \<Longrightarrow> (\<And>n. n < length a \<Longrightarrow> P (a!n) (b!n)) \<Longrightarrow> list_all2 P a b" |
1055 "length a = length b \<Longrightarrow> (\<And>n. n < length a \<Longrightarrow> P (a!n) (b!n)) \<Longrightarrow> list_all2 P a b" |
1046 by (simp add: list_all2_conv_all_nth) |
1056 by (simp add: list_all2_conv_all_nth) |
1047 |
1057 |
1048 lemma list_all2_nthD [dest?]: |
1058 lemma list_all2_nthD [dest?]: |
1054 by (simp add: list_all2_conv_all_nth) |
1064 by (simp add: list_all2_conv_all_nth) |
1055 |
1065 |
1056 lemma list_all2_map2: |
1066 lemma list_all2_map2: |
1057 "list_all2 P as (map f bs) = list_all2 (\<lambda>x y. P x (f y)) as bs" |
1067 "list_all2 P as (map f bs) = list_all2 (\<lambda>x y. P x (f y)) as bs" |
1058 by (auto simp add: list_all2_conv_all_nth) |
1068 by (auto simp add: list_all2_conv_all_nth) |
1059 |
|
1060 lemma list_all2_trans[rule_format]: |
|
1061 "\<forall>a b c. P1 a b --> P2 b c --> P3 a c ==> |
|
1062 \<forall>bs cs. list_all2 P1 as bs --> list_all2 P2 bs cs --> list_all2 P3 as cs" |
|
1063 apply(induct_tac as) |
|
1064 apply simp |
|
1065 apply(rule allI) |
|
1066 apply(induct_tac bs) |
|
1067 apply simp |
|
1068 apply(rule allI) |
|
1069 apply(induct_tac cs) |
|
1070 apply auto |
|
1071 done |
|
1072 |
1069 |
1073 lemma list_all2_refl: |
1070 lemma list_all2_refl: |
1074 "(\<And>x. P x x) \<Longrightarrow> list_all2 P xs xs" |
1071 "(\<And>x. P x x) \<Longrightarrow> list_all2 P xs xs" |
1075 by (simp add: list_all2_conv_all_nth) |
1072 by (simp add: list_all2_conv_all_nth) |
1076 |
1073 |
1171 apply (induct n m rule: diff_induct) |
1168 apply (induct n m rule: diff_induct) |
1172 prefer 3 apply (subst map_Suc_upt[symmetric]) |
1169 prefer 3 apply (subst map_Suc_upt[symmetric]) |
1173 apply (auto simp add: less_diff_conv nth_upt) |
1170 apply (auto simp add: less_diff_conv nth_upt) |
1174 done |
1171 done |
1175 |
1172 |
1176 lemma nth_take_lemma [rule_format]: |
1173 lemma nth_take_lemma: |
1177 "ALL xs ys. k <= length xs --> k <= length ys |
1174 "!!xs ys. k <= length xs ==> k <= length ys ==> |
1178 --> (ALL i. i < k --> xs!i = ys!i) |
1175 (!!i. i < k --> xs!i = ys!i) ==> take k xs = take k ys" |
1179 --> take k xs = take k ys" |
1176 apply (atomize, induct k) |
1180 apply (induct k) |
|
1181 apply (simp_all add: less_Suc_eq_0_disj all_conj_distrib) |
1177 apply (simp_all add: less_Suc_eq_0_disj all_conj_distrib) |
1182 apply clarify |
1178 apply clarify |
1183 txt {* Both lists must be non-empty *} |
1179 txt {* Both lists must be non-empty *} |
1184 apply (case_tac xs) |
1180 apply (case_tac xs) |
1185 apply simp |
1181 apply simp |