# HG changeset patch # User desharna # Date 1683701984 -7200 # Node ID db041670d6bbe6464baae019e59a9d35b2697789 # Parent b0ef3aae2bdba5ec2043b0b42bd96349bd43f32c added lemmas transp_on_multpHO and transp_multpHO diff -r b0ef3aae2bdb -r db041670d6bb NEWS --- a/NEWS Wed May 10 08:56:32 2023 +0200 +++ b/NEWS Wed May 10 08:59:44 2023 +0200 @@ -275,6 +275,8 @@ totalp_multpHO totalp_on_multpDM totalp_on_multpHO + transp_multpHO + transp_on_multpHO * 'primcorec': Made the internal tactic more robust in the face of nested corecursion. diff -r b0ef3aae2bdb -r db041670d6bb src/HOL/Library/Multiset_Order.thy --- a/src/HOL/Library/Multiset_Order.thy Wed May 10 08:56:32 2023 +0200 +++ b/src/HOL/Library/Multiset_Order.thy Wed May 10 08:59:44 2023 +0200 @@ -311,6 +311,146 @@ paragraph \Transitivity\ +lemma transp_on_multp\<^sub>H\<^sub>O: + assumes "asymp_on A R" and "transp_on A R" and + B_sub_A: "\M. M \ B \ set_mset M \ A" + shows "transp_on B (multp\<^sub>H\<^sub>O R)" +proof (rule transp_onI) + from assms have "asymp_on B (multp\<^sub>H\<^sub>O R)" + using asymp_on_multp\<^sub>H\<^sub>O by metis + + fix M1 M2 M3 + assume hyps: "M1 \ B" "M2 \ B" "M3 \ B" "multp\<^sub>H\<^sub>O R M1 M2" "multp\<^sub>H\<^sub>O R M2 M3" + + from assms have + [intro]: "asymp_on (set_mset M1 \ set_mset M2) R" "transp_on (set_mset M1 \ set_mset M2) R" + using \M1 \ B\ \M2 \ B\ + by (simp_all add: asymp_on_subset transp_on_subset) + + from assms have "transp_on (set_mset M1) R" + by (meson transp_on_subset hyps(1)) + + from \multp\<^sub>H\<^sub>O R M1 M2\ have + "M1 \ M2" and + "\y. count M2 y < count M1 y \ (\x. R y x \ count M1 x < count M2 x)" + unfolding multp\<^sub>H\<^sub>O_def by simp_all + + from \multp\<^sub>H\<^sub>O R M2 M3\ have + "M2 \ M3" and + "\y. count M3 y < count M2 y \ (\x. R y x \ count M2 x < count M3 x)" + unfolding multp\<^sub>H\<^sub>O_def by simp_all + + show "multp\<^sub>H\<^sub>O R M1 M3" + proof (rule ccontr) + let ?P = "\x. count M3 x < count M1 x \ (\y. R x y \ count M1 y \ count M3 y)" + + assume "\ multp\<^sub>H\<^sub>O R M1 M3" + hence "M1 = M3 \ (\x. ?P x)" + unfolding multp\<^sub>H\<^sub>O_def by force + thus False + proof (elim disjE) + assume "M1 = M3" + thus False + using \asymp_on B (multp\<^sub>H\<^sub>O R)\[THEN asymp_onD] + using \M2 \ B\ \M3 \ B\ \multp\<^sub>H\<^sub>O R M1 M2\ \multp\<^sub>H\<^sub>O R M2 M3\ + by metis + next + assume "\x. ?P x" + hence "\x \# M1 + M2. ?P x" + by (auto simp: count_inI) + have "\y \# M1 + M2. ?P y \ (\z \# M1 + M2. R y z \ \ ?P z)" + proof (rule Finite_Set.bex_max_element_with_property) + show "\x \# M1 + M2. ?P x" + using \\x. ?P x\ + by (auto simp: count_inI) + qed auto + then obtain x where + "x \# M1 + M2" and + "count M3 x < count M1 x" and + "\y. R x y \ count M1 y \ count M3 y" and + "\y \# M1 + M2. R x y \ count M3 y < count M1 y \ (\z. R y z \ count M1 z < count M3 z)" + by force + + let ?Q = "\x'. R\<^sup>=\<^sup>= x x' \ count M3 x' < count M2 x'" + show False + proof (cases "\x'. ?Q x'") + case True + have "\y \# M1 + M2. ?Q y \ (\z \# M1 + M2. R y z \ \ ?Q z)" + proof (rule Finite_Set.bex_max_element_with_property) + show "\x \# M1 + M2. ?Q x" + using \\x. ?Q x\ + by (auto simp: count_inI) + qed auto + then obtain x' where + "x' \# M1 + M2" and + "R\<^sup>=\<^sup>= x x'" and + "count M3 x' < count M2 x'" and + maximality_x': "\z \# M1 + M2. R x' z \ \ (R\<^sup>=\<^sup>= x z) \ count M3 z \ count M2 z" + by (auto simp: linorder_not_less) + with \multp\<^sub>H\<^sub>O R M2 M3\ obtain y' where + "R x' y'" and "count M2 y' < count M3 y'" + unfolding multp\<^sub>H\<^sub>O_def by auto + hence "count M2 y' < count M1 y'" + by (smt (verit) \R\<^sup>=\<^sup>= x x'\ \\y. R x y \ count M3 y \ count M1 y\ + \count M3 x < count M1 x\ \count M3 x' < count M2 x'\ assms(2) count_inI + dual_order.strict_trans1 hyps(1) hyps(2) hyps(3) less_nat_zero_code B_sub_A subsetD + sup2E transp_onD) + with \multp\<^sub>H\<^sub>O R M1 M2\ obtain y'' where + "R y' y''" and "count M1 y'' < count M2 y''" + unfolding multp\<^sub>H\<^sub>O_def by auto + hence "count M3 y'' < count M2 y''" + by (smt (verit, del_insts) \R x' y'\ \R\<^sup>=\<^sup>= x x'\ \\y. R x y \ count M3 y \ count M1 y\ + \count M2 y' < count M3 y'\ \count M3 x < count M1 x\ \count M3 x' < count M2 x'\ + assms(2) count_greater_zero_iff dual_order.strict_trans1 hyps(1) hyps(2) hyps(3) + less_nat_zero_code linorder_not_less B_sub_A subset_iff sup2E transp_onD) + + moreover have "count M2 y'' \ count M3 y''" + proof - + have "y'' \# M1 + M2" + by (metis \count M1 y'' < count M2 y''\ count_inI not_less_iff_gr_or_eq union_iff) + + moreover have "R x' y''" + by (metis \R x' y'\ \R y' y''\ \count M2 y' < count M1 y'\ + \transp_on (set_mset M1 \ set_mset M2) R\ \x' \# M1 + M2\ calculation count_inI + nat_neq_iff set_mset_union transp_onD union_iff) + + moreover have "R\<^sup>=\<^sup>= x y''" + using \R\<^sup>=\<^sup>= x x'\ + by (metis (mono_tags, opaque_lifting) \transp_on (set_mset M1 \ set_mset M2) R\ + \x \# M1 + M2\ \x' \# M1 + M2\ calculation(1) calculation(2) set_mset_union sup2I1 + transp_onD transp_on_reflclp) + + ultimately show ?thesis + using maximality_x'[rule_format, of y''] by metis + qed + + ultimately show ?thesis + by linarith + next + case False + hence "\x'. R\<^sup>=\<^sup>= x x' \ count M2 x' \ count M3 x'" + by auto + hence "count M2 x \ count M3 x" + by simp + hence "count M2 x < count M1 x" + using \count M3 x < count M1 x\ by linarith + with \multp\<^sub>H\<^sub>O R M1 M2\ obtain y where + "R x y" and "count M1 y < count M2 y" + unfolding multp\<^sub>H\<^sub>O_def by auto + hence "count M3 y < count M2 y" + using \\y. R x y \ count M3 y \ count M1 y\ dual_order.strict_trans2 by metis + then show ?thesis + using False \R x y\ by auto + qed + qed + qed +qed + +lemma transp_multp\<^sub>H\<^sub>O: + assumes "asymp R" and "transp R" + shows "transp (multp\<^sub>H\<^sub>O R)" + using assms transp_on_multp\<^sub>H\<^sub>O[of UNIV, simplified] by metis + paragraph \Totality\