src/HOL/Library/Uprod.thy
changeset 67399 eab6ce8368fa
parent 66936 cf8d8fc23891
child 67411 3f4b0c84630f
equal deleted inserted replaced
67398:5eb932e604a2 67399:eab6ce8368fa
    54 by transfer auto
    54 by transfer auto
    55 
    55 
    56 lemma uprod_split_asm: "P (case_uprod f x) \<longleftrightarrow> \<not> (\<exists>a b. x = Upair a b \<and> \<not> P (apply_commute f a b))"
    56 lemma uprod_split_asm: "P (case_uprod f x) \<longleftrightarrow> \<not> (\<exists>a b. x = Upair a b \<and> \<not> P (apply_commute f a b))"
    57 by transfer auto
    57 by transfer auto
    58 
    58 
    59 lift_definition not_equal :: "('a, bool) commute" is "op \<noteq>" by auto
    59 lift_definition not_equal :: "('a, bool) commute" is "(\<noteq>)" by auto
    60 
    60 
    61 lemma apply_not_equal [simp]: "apply_commute not_equal x y \<longleftrightarrow> x \<noteq> y"
    61 lemma apply_not_equal [simp]: "apply_commute not_equal x y \<longleftrightarrow> x \<noteq> y"
    62 by transfer simp
    62 by transfer simp
    63 
    63 
    64 definition proper_uprod :: "'a uprod \<Rightarrow> bool"
    64 definition proper_uprod :: "'a uprod \<Rightarrow> bool"
    91 
    91 
    92 lemma map_uprod_simps [simp, code]: "map_uprod f (Upair x y) = Upair (f x) (f y)"
    92 lemma map_uprod_simps [simp, code]: "map_uprod f (Upair x y) = Upair (f x) (f y)"
    93 by transfer simp
    93 by transfer simp
    94 
    94 
    95 private lemma rel_uprod_transfer':
    95 private lemma rel_uprod_transfer':
    96   "((A ===> B ===> op =) ===> rel_prod A A ===> rel_prod B B ===> op =)
    96   "((A ===> B ===> (=)) ===> rel_prod A A ===> rel_prod B B ===> (=))
    97    (\<lambda>R (a, b) (c, d). R a c \<and> R b d \<or> R a d \<and> R b c) (\<lambda>R (a, b) (c, d). R a c \<and> R b d \<or> R a d \<and> R b c)"
    97    (\<lambda>R (a, b) (c, d). R a c \<and> R b d \<or> R a d \<and> R b c) (\<lambda>R (a, b) (c, d). R a c \<and> R b d \<or> R a d \<and> R b c)"
    98 by transfer_prover
    98 by transfer_prover
    99 
    99 
   100 lift_definition rel_uprod :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a uprod \<Rightarrow> 'b uprod \<Rightarrow> bool"
   100 lift_definition rel_uprod :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a uprod \<Rightarrow> 'b uprod \<Rightarrow> bool"
   101   is "\<lambda>R (a, b) (c, d). R a c \<and> R b d \<or> R a d \<and> R b c" parametric rel_uprod_transfer'
   101   is "\<lambda>R (a, b) (c, d). R a c \<and> R b d \<or> R a d \<and> R b c" parametric rel_uprod_transfer'
   123   show "map_uprod id = id" unfolding fun_eq_iff by transfer auto
   123   show "map_uprod id = id" unfolding fun_eq_iff by transfer auto
   124   show "map_uprod (g \<circ> f) = map_uprod g \<circ> map_uprod f" for f :: "'a \<Rightarrow> 'b" and g :: "'b \<Rightarrow> 'c"
   124   show "map_uprod (g \<circ> f) = map_uprod g \<circ> map_uprod f" for f :: "'a \<Rightarrow> 'b" and g :: "'b \<Rightarrow> 'c"
   125     unfolding fun_eq_iff by transfer auto
   125     unfolding fun_eq_iff by transfer auto
   126   show "map_uprod f x = map_uprod g x" if "\<And>z. z \<in> set_uprod x \<Longrightarrow> f z = g z" 
   126   show "map_uprod f x = map_uprod g x" if "\<And>z. z \<in> set_uprod x \<Longrightarrow> f z = g z" 
   127     for f :: "'a \<Rightarrow> 'b" and g x using that by transfer auto
   127     for f :: "'a \<Rightarrow> 'b" and g x using that by transfer auto
   128   show "set_uprod \<circ> map_uprod f = op ` f \<circ> set_uprod" for f :: "'a \<Rightarrow> 'b" by transfer auto
   128   show "set_uprod \<circ> map_uprod f = (`) f \<circ> set_uprod" for f :: "'a \<Rightarrow> 'b" by transfer auto
   129   show "card_order natLeq" by(rule natLeq_card_order)
   129   show "card_order natLeq" by(rule natLeq_card_order)
   130   show "BNF_Cardinal_Arithmetic.cinfinite natLeq" by(rule natLeq_cinfinite)
   130   show "BNF_Cardinal_Arithmetic.cinfinite natLeq" by(rule natLeq_cinfinite)
   131   show "ordLeq3 (card_of (set_uprod x)) natLeq" for x :: "'a uprod"
   131   show "ordLeq3 (card_of (set_uprod x)) natLeq" for x :: "'a uprod"
   132     by (auto simp: finite_iff_ordLess_natLeq[symmetric] intro: ordLess_imp_ordLeq)
   132     by (auto simp: finite_iff_ordLess_natLeq[symmetric] intro: ordLess_imp_ordLeq)
   133   show "rel_uprod R OO rel_uprod S \<le> rel_uprod (R OO S)"
   133   show "rel_uprod R OO rel_uprod S \<le> rel_uprod (R OO S)"
   140 by(simp add: pred_uprod_def)
   140 by(simp add: pred_uprod_def)
   141 
   141 
   142 instantiation uprod :: (equal) equal begin
   142 instantiation uprod :: (equal) equal begin
   143 
   143 
   144 definition equal_uprod :: "'a uprod \<Rightarrow> 'a uprod \<Rightarrow> bool"
   144 definition equal_uprod :: "'a uprod \<Rightarrow> 'a uprod \<Rightarrow> bool"
   145 where "equal_uprod = op ="
   145 where "equal_uprod = (=)"
   146 
   146 
   147 lemma equal_uprod_code [code]:
   147 lemma equal_uprod_code [code]:
   148   "HOL.equal (Upair x y) (Upair z u) \<longleftrightarrow> x = z \<and> y = u \<or> x = u \<and> y = z"
   148   "HOL.equal (Upair x y) (Upair z u) \<longleftrightarrow> x = z \<and> y = u \<or> x = u \<and> y = z"
   149 unfolding equal_uprod_def by simp
   149 unfolding equal_uprod_def by simp
   150 
   150