# HG changeset patch # User wenzelm # Date 1633199506 -7200 # Node ID 2cf4d6cf4c0d356d2bd38484bbec24e5ed1b29f9 # Parent 584c4db57f68061bbff96e8f7c772a2341317010 trim whitespace; diff -r 584c4db57f68 -r 2cf4d6cf4c0d src/HOL/List.thy --- a/src/HOL/List.thy Sat Oct 02 20:28:30 2021 +0200 +++ b/src/HOL/List.thy Sat Oct 02 20:31:46 2021 +0200 @@ -371,7 +371,7 @@ begin abbreviation sorted :: "'a list \ bool" where - "sorted \ sorted_wrt (\)" + "sorted \ sorted_wrt (\)" lemma sorted_simps: "sorted [] = True" "sorted (x # ys) = ((\y \ set ys. x\y) \ sorted ys)" by auto @@ -1499,7 +1499,7 @@ | len (Const(\<^const_name>\rev\,_) $ xs) acc = len xs acc | len (Const(\<^const_name>\map\,_) $ _ $ xs) acc = len xs acc | len (Const(\<^const_name>\concat\,T) $ (Const(\<^const_name>\rev\,_) $ xss)) acc - = len (Const(\<^const_name>\concat\,T) $ xss) acc + = len (Const(\<^const_name>\concat\,T) $ xss) acc | len t (ts,n) = (t::ts,n); val ss = simpset_of \<^context>; @@ -3128,7 +3128,7 @@ assumes "set xs \ S" shows "Finite_Set.fold f y (set xs) = fold f (remdups xs) y" by (rule sym, use assms in \induct xs arbitrary: y\) - (simp_all add: insert_absorb fold_fun_left_comm) + (simp_all add: insert_absorb fold_fun_left_comm) lemma (in comp_fun_idem_on) fold_set_fold: assumes "set xs \ S" @@ -3510,7 +3510,7 @@ lemma successively_append_iff: "successively P (xs @ ys) \ - successively P xs \ successively P ys \ + successively P xs \ successively P ys \ (xs = [] \ ys = [] \ P (last xs) (hd ys))" by (induction xs) (auto simp: successively_Cons) @@ -4141,7 +4141,7 @@ by (metis (full_types) dropWhile_eq_self_iff last_snoc remdups_adj_append_dropWhile) thus ?thesis by (simp add: xs) qed - thus ?thesis using assms + thus ?thesis using assms by (cases "xs = []"; cases "ys = []") auto qed @@ -4425,7 +4425,7 @@ by (auto dest: length_filter_less simp add: removeAll_filter_not_eq) lemma distinct_concat_iff: "distinct (concat xs) \ - distinct (removeAll [] xs) \ + distinct (removeAll [] xs) \ (\ys. ys \ set xs \ distinct ys) \ (\ys zs. ys \ set xs \ zs \ set xs \ ys \ zs \ set ys \ set zs = {})" apply (induct xs) @@ -4993,7 +4993,7 @@ lemma splice_replicate[simp]: "splice (replicate m x) (replicate n x) = replicate (m+n) x" proof (induction "replicate m x" "replicate n x" arbitrary: m n rule: splice.induct) case (2 x xs) - then show ?case + then show ?case by (auto simp add: Cons_replicate_eq dest: gr0_implies_Suc) qed auto @@ -5360,7 +5360,7 @@ lemma infinite_UNIV_listI: "\ finite(UNIV::'a list set)" by (metis UNIV_I finite_maxlen length_replicate less_irrefl) -lemma same_length_different: +lemma same_length_different: assumes "xs \ ys" and "length xs = length ys" shows "\pre x xs' y ys'. x\y \ xs = pre @ [x] @ xs' \ ys = pre @ [y] @ ys'" using assms @@ -5462,7 +5462,7 @@ proof assume ?L thus ?R - by (simp add: sorted_wrt_iff_nth_less) + by (simp add: sorted_wrt_iff_nth_less) next assume ?R have "i < j \ j < length xs \ P (xs ! i) (xs ! j)" for i j @@ -5545,7 +5545,7 @@ "sorted xs \ i \ j \ j < length xs \ xs!i \ xs!j" by (auto simp: sorted_iff_nth_mono) -lemma sorted_iff_nth_Suc: +lemma sorted_iff_nth_Suc: "sorted xs \ (\i. Suc i < length xs \ xs!i \ xs!(Suc i))" by(simp add: sorted_wrt_iff_nth_Suc_transp) @@ -5573,13 +5573,13 @@ thus ?L by (simp add: sorted_iff_nth_mono) qed -lemma sorted_rev_iff_nth_Suc: +lemma sorted_rev_iff_nth_Suc: "sorted (rev xs) \ (\i. Suc i < length xs \ xs!(Suc i) \ xs!i)" proof- interpret dual: linorder "(\x y. y \ x)" "(\x y. y < x)" using dual_linorder . show ?thesis - using dual_linorder dual.sorted_iff_nth_Suc dual.sorted_iff_nth_mono + using dual_linorder dual.sorted_iff_nth_Suc dual.sorted_iff_nth_mono unfolding sorted_rev_iff_nth_mono by simp qed @@ -6244,7 +6244,7 @@ proof (cases ys) case Nil then show ?thesis - using Cons.prems by auto + using Cons.prems by auto next case (Cons y ys') then have "xs = ys'" @@ -6255,13 +6255,13 @@ using local.Cons by blast qed qed auto - + lemma (in linorder) strict_sorted_equal_Uniq: "\\<^sub>\\<^sub>1xs. sorted_wrt (<) xs \ set xs = A" by (simp add: Uniq_def strict_sorted_equal) lemma sorted_key_list_of_set_inject: assumes "A \ S" "B \ S" - assumes "sorted_key_list_of_set f A = sorted_key_list_of_set f B" "finite A" "finite B" + assumes "sorted_key_list_of_set f A = sorted_key_list_of_set f B" "finite A" "finite B" shows "A = B" using assms set_sorted_key_list_of_set by metis @@ -6326,7 +6326,7 @@ "sorted_list_of_set {m.. j" + assumes "Suc i \ j" shows "sorted_list_of_set {i<..j} = Suc i # sorted_list_of_set {Suc i<..j}" using sorted_list_of_set_greaterThanLessThan [of i "Suc j"] by (metis assms greaterThanAtMost_def greaterThanLessThan_eq le_imp_less_Suc lessThan_Suc_atMost) -lemma nth_sorted_list_of_set_greaterThanLessThan: +lemma nth_sorted_list_of_set_greaterThanLessThan: "n < j - Suc i \ sorted_list_of_set {i<.. sorted_list_of_set {i<..j} ! n = Suc (i+n)" using nth_sorted_list_of_set_greaterThanLessThan [of n "Suc j" i] by (simp add: greaterThanAtMost_def greaterThanLessThan_eq lessThan_Suc_atMost) @@ -6515,7 +6515,7 @@ "(xs, ys) \ lexn r n \ length xs = n \ length ys = n" by (induct n arbitrary: xs ys) auto -lemma wf_lex [intro!]: +lemma wf_lex [intro!]: assumes "wf r" shows "wf (lex r)" unfolding lex_def proof (rule wf_UN) @@ -6631,7 +6631,7 @@ if "xs \ ys" and len: "length xs = length ys" for xs ys proof - obtain pre x xs' y ys' where "x\y" and xs: "xs = pre @ [x] @ xs'" and ys: "ys = pre @ [y] @ys'" - by (meson len \xs \ ys\ same_length_different) + by (meson len \xs \ ys\ same_length_different) then consider "(x,y) \ r" | "(y,x) \ r" by (meson UNIV_I assms total_on_def) then show ?thesis @@ -6662,14 +6662,14 @@ by (simp add: lex_conv) (blast intro: Cons_eq_appendI) qed -lemma Nil_lenlex_iff1 [simp]: "([], ns) \ lenlex r \ ns \ []" +lemma Nil_lenlex_iff1 [simp]: "([], ns) \ lenlex r \ ns \ []" and Nil_lenlex_iff2 [simp]: "(ns,[]) \ lenlex r" by (auto simp: lenlex_def) -lemma Cons_lenlex_iff: - "((m # ms, n # ns) \ lenlex r) \ - length ms < length ns - \ length ms = length ns \ (m,n) \ r +lemma Cons_lenlex_iff: + "((m # ms, n # ns) \ lenlex r) \ + length ms < length ns + \ length ms = length ns \ (m,n) \ r \ (m = n \ (ms,ns) \ lenlex r)" by (auto simp: lenlex_def) @@ -6797,19 +6797,19 @@ proof- from leD[OF assms(2)] assms(1)[unfolded lexord_take_index_conv[of u w r] min_absorb2[OF assms(2)]] obtain i where "take i u = take i w" and "(u!i,w!i) \ r" and "i < length w" - by blast + by blast hence "((u@v)!i, (w@z)!i) \ r" unfolding nth_append using less_le_trans[OF \i < length w\ assms(2)] \(u!i,w!i) \ r\ by presburger moreover have "i < min (length (u@v)) (length (w@z))" using assms(2) \i < length w\ by simp moreover have "take i (u@v) = take i (w@z)" - using assms(2) \i < length w\ \take i u = take i w\ by simp + using assms(2) \i < length w\ \take i u = take i w\ by simp ultimately show ?thesis using lexord_take_index_conv by blast qed -lemma lexord_sufE: +lemma lexord_sufE: assumes "(xs@zs,ys@qs) \ lexord r" "xs \ ys" "length xs = length ys" "length zs = length qs" shows "(xs,ys) \ lexord r" proof- @@ -6893,7 +6893,7 @@ qed corollary lexord_linear: "(\a b. (a,b) \ r \ a = b \ (b,a) \ r) \ (x,y) \ lexord r \ x = y \ (y,x) \ lexord r" - using total_lexord by (metis UNIV_I total_on_def) + using total_lexord by (metis UNIV_I total_on_def) lemma lexord_irrefl: "irrefl R \ irrefl (lexord R)" @@ -6902,7 +6902,7 @@ lemma lexord_asym: assumes "asym R" shows "asym (lexord R)" -proof +proof fix xs ys assume "(xs, ys) \ lexord R" then show "(ys, xs) \ lexord R" @@ -6932,12 +6932,12 @@ by (simp add: lenlex_def asym_inv_image asym_less_than asym_lex asym_lex_prod) lemma lenlex_append1: - assumes len: "(us,xs) \ lenlex R" and eq: "length vs = length ys" + assumes len: "(us,xs) \ lenlex R" and eq: "length vs = length ys" shows "(us @ vs, xs @ ys) \ lenlex R" using len proof (induction us) case Nil - then show ?case + then show ?case by (simp add: lenlex_def eq) next case (Cons u us) @@ -6950,7 +6950,7 @@ shows "(us @ xs, us @ ys) \ lenlex R \ (xs, ys) \ lenlex R" proof (induction us) case Nil - then show ?case + then show ?case by (simp add: lenlex_def) next case (Cons u us)