src/HOL/Library/Permutation.thy
changeset 17200 3a4d03d1a31b
parent 15140 322485b816ac
child 19380 b808efaa5828
     1.1 --- a/src/HOL/Library/Permutation.thy	Wed Aug 31 15:46:36 2005 +0200
     1.2 +++ b/src/HOL/Library/Permutation.thy	Wed Aug 31 15:46:37 2005 +0200
     1.3 @@ -24,20 +24,20 @@
     1.4      trans [intro]: "xs <~~> ys ==> ys <~~> zs ==> xs <~~> zs"
     1.5  
     1.6  lemma perm_refl [iff]: "l <~~> l"
     1.7 -by (induct l, auto)
     1.8 +  by (induct l) auto
     1.9  
    1.10  
    1.11  subsection {* Some examples of rule induction on permutations *}
    1.12  
    1.13  lemma xperm_empty_imp_aux: "xs <~~> ys ==> xs = [] --> ys = []"
    1.14 -    -- {*the form of the premise lets the induction bind @{term xs} 
    1.15 +    -- {*the form of the premise lets the induction bind @{term xs}
    1.16           and @{term ys} *}
    1.17    apply (erule perm.induct)
    1.18       apply (simp_all (no_asm_simp))
    1.19    done
    1.20  
    1.21  lemma xperm_empty_imp: "[] <~~> ys ==> ys = []"
    1.22 -by (insert xperm_empty_imp_aux, blast)
    1.23 +  using xperm_empty_imp_aux by blast
    1.24  
    1.25  
    1.26  text {*
    1.27 @@ -45,16 +45,16 @@
    1.28    *}
    1.29  
    1.30  lemma perm_length: "xs <~~> ys ==> length xs = length ys"
    1.31 -by (erule perm.induct, simp_all)
    1.32 +  by (erule perm.induct) simp_all
    1.33  
    1.34  lemma perm_empty_imp: "[] <~~> xs ==> xs = []"
    1.35 -by (drule perm_length, auto)
    1.36 +  by (drule perm_length) auto
    1.37  
    1.38  lemma perm_sym: "xs <~~> ys ==> ys <~~> xs"
    1.39 -by (erule perm.induct, auto)
    1.40 +  by (erule perm.induct) auto
    1.41  
    1.42  lemma perm_mem [rule_format]: "xs <~~> ys ==> x mem xs --> x mem ys"
    1.43 -by (erule perm.induct, auto)
    1.44 +  by (erule perm.induct) auto
    1.45  
    1.46  
    1.47  subsection {* Ways of making new permutations *}
    1.48 @@ -64,32 +64,34 @@
    1.49  *}
    1.50  
    1.51  lemma perm_append_Cons: "a # xs @ ys <~~> xs @ a # ys"
    1.52 -by (induct xs, auto)
    1.53 +  by (induct xs) auto
    1.54  
    1.55  lemma perm_append_swap: "xs @ ys <~~> ys @ xs"
    1.56 -  apply (induct xs, simp_all)
    1.57 +  apply (induct xs)
    1.58 +    apply simp_all
    1.59    apply (blast intro: perm_append_Cons)
    1.60    done
    1.61  
    1.62  lemma perm_append_single: "a # xs <~~> xs @ [a]"
    1.63 -  by (rule perm.trans [OF _ perm_append_swap], simp)
    1.64 +  by (rule perm.trans [OF _ perm_append_swap]) simp
    1.65  
    1.66  lemma perm_rev: "rev xs <~~> xs"
    1.67 -  apply (induct xs, simp_all)
    1.68 +  apply (induct xs)
    1.69 +   apply simp_all
    1.70    apply (blast intro!: perm_append_single intro: perm_sym)
    1.71    done
    1.72  
    1.73  lemma perm_append1: "xs <~~> ys ==> l @ xs <~~> l @ ys"
    1.74 -by (induct l, auto)
    1.75 +  by (induct l) auto
    1.76  
    1.77  lemma perm_append2: "xs <~~> ys ==> xs @ l <~~> ys @ l"
    1.78 -by (blast intro!: perm_append_swap perm_append1)
    1.79 +  by (blast intro!: perm_append_swap perm_append1)
    1.80  
    1.81  
    1.82  subsection {* Further results *}
    1.83  
    1.84  lemma perm_empty [iff]: "([] <~~> xs) = (xs = [])"
    1.85 -by (blast intro: perm_empty_imp)
    1.86 +  by (blast intro: perm_empty_imp)
    1.87  
    1.88  lemma perm_empty2 [iff]: "(xs <~~> []) = (xs = [])"
    1.89    apply auto
    1.90 @@ -97,13 +99,13 @@
    1.91    done
    1.92  
    1.93  lemma perm_sing_imp [rule_format]: "ys <~~> xs ==> xs = [y] --> ys = [y]"
    1.94 -by (erule perm.induct, auto)
    1.95 +  by (erule perm.induct) auto
    1.96  
    1.97  lemma perm_sing_eq [iff]: "(ys <~~> [y]) = (ys = [y])"
    1.98 -by (blast intro: perm_sing_imp)
    1.99 +  by (blast intro: perm_sing_imp)
   1.100  
   1.101  lemma perm_sing_eq2 [iff]: "([y] <~~> ys) = (ys = [y])"
   1.102 -by (blast dest: perm_sym)
   1.103 +  by (blast dest: perm_sym)
   1.104  
   1.105  
   1.106  subsection {* Removing elements *}
   1.107 @@ -115,29 +117,31 @@
   1.108    "remove x (y # ys) = (if x = y then ys else y # remove x ys)"
   1.109  
   1.110  lemma perm_remove: "x \<in> set ys ==> ys <~~> x # remove x ys"
   1.111 -by (induct ys, auto)
   1.112 +  by (induct ys) auto
   1.113  
   1.114  lemma remove_commute: "remove x (remove y l) = remove y (remove x l)"
   1.115 -by (induct l, auto)
   1.116 +  by (induct l) auto
   1.117  
   1.118 -lemma multiset_of_remove[simp]: 
   1.119 -  "multiset_of (remove a x) = multiset_of x - {#a#}"
   1.120 -  by (induct_tac x, auto simp: multiset_eq_conv_count_eq) 
   1.121 +lemma multiset_of_remove[simp]:
   1.122 +    "multiset_of (remove a x) = multiset_of x - {#a#}"
   1.123 +  apply (induct x)
   1.124 +   apply (auto simp: multiset_eq_conv_count_eq)
   1.125 +  done
   1.126  
   1.127  
   1.128  text {* \medskip Congruence rule *}
   1.129  
   1.130  lemma perm_remove_perm: "xs <~~> ys ==> remove z xs <~~> remove z ys"
   1.131 -by (erule perm.induct, auto)
   1.132 +  by (erule perm.induct) auto
   1.133  
   1.134  lemma remove_hd [simp]: "remove z (z # xs) = xs"
   1.135    by auto
   1.136  
   1.137  lemma cons_perm_imp_perm: "z # xs <~~> z # ys ==> xs <~~> ys"
   1.138 -by (drule_tac z = z in perm_remove_perm, auto)
   1.139 +  by (drule_tac z = z in perm_remove_perm) auto
   1.140  
   1.141  lemma cons_perm_eq [iff]: "(z#xs <~~> z#ys) = (xs <~~> ys)"
   1.142 -by (blast intro: cons_perm_imp_perm)
   1.143 +  by (blast intro: cons_perm_imp_perm)
   1.144  
   1.145  lemma append_perm_imp_perm: "!!xs ys. zs @ xs <~~> zs @ ys ==> xs <~~> ys"
   1.146    apply (induct zs rule: rev_induct)
   1.147 @@ -146,7 +150,7 @@
   1.148    done
   1.149  
   1.150  lemma perm_append1_eq [iff]: "(zs @ xs <~~> zs @ ys) = (xs <~~> ys)"
   1.151 -by (blast intro: append_perm_imp_perm perm_append1)
   1.152 +  by (blast intro: append_perm_imp_perm perm_append1)
   1.153  
   1.154  lemma perm_append2_eq [iff]: "(xs @ zs <~~> ys @ zs) = (xs <~~> ys)"
   1.155    apply (safe intro!: perm_append2)
   1.156 @@ -157,20 +161,20 @@
   1.157    done
   1.158  
   1.159  lemma multiset_of_eq_perm: "(multiset_of xs = multiset_of ys) = (xs <~~> ys) "
   1.160 -  apply (rule iffI) 
   1.161 -  apply (erule_tac [2] perm.induct, simp_all add: union_ac) 
   1.162 -  apply (erule rev_mp, rule_tac x=ys in spec) 
   1.163 -  apply (induct_tac xs, auto) 
   1.164 -  apply (erule_tac x = "remove a x" in allE, drule sym, simp) 
   1.165 -  apply (subgoal_tac "a \<in> set x") 
   1.166 -  apply (drule_tac z=a in perm.Cons) 
   1.167 -  apply (erule perm.trans, rule perm_sym, erule perm_remove) 
   1.168 +  apply (rule iffI)
   1.169 +  apply (erule_tac [2] perm.induct, simp_all add: union_ac)
   1.170 +  apply (erule rev_mp, rule_tac x=ys in spec)
   1.171 +  apply (induct_tac xs, auto)
   1.172 +  apply (erule_tac x = "remove a x" in allE, drule sym, simp)
   1.173 +  apply (subgoal_tac "a \<in> set x")
   1.174 +  apply (drule_tac z=a in perm.Cons)
   1.175 +  apply (erule perm.trans, rule perm_sym, erule perm_remove)
   1.176    apply (drule_tac f=set_of in arg_cong, simp)
   1.177    done
   1.178  
   1.179 -lemma multiset_of_le_perm_append: 
   1.180 -  "(multiset_of xs \<le># multiset_of ys) = (\<exists> zs. xs @ zs <~~> ys)"; 
   1.181 -  apply (auto simp: multiset_of_eq_perm[THEN sym] mset_le_exists_conv) 
   1.182 +lemma multiset_of_le_perm_append:
   1.183 +    "(multiset_of xs \<le># multiset_of ys) = (\<exists>zs. xs @ zs <~~> ys)";
   1.184 +  apply (auto simp: multiset_of_eq_perm[THEN sym] mset_le_exists_conv)
   1.185    apply (insert surj_multiset_of, drule surjD)
   1.186    apply (blast intro: sym)+
   1.187    done