src/HOL/Sum_Type.thy
changeset 55534 b18bdcbda41b
parent 55469 b19dd108f0c2
child 55575 a5e33e18fb5c
equal deleted inserted replaced
55533:6260caf1d612 55534:b18bdcbda41b
   118 lemmas cases = sum.case
   118 lemmas cases = sum.case
   119 lemmas simps = sum.inject sum.distinct sum.case old.sum.recs
   119 lemmas simps = sum.inject sum.distinct sum.case old.sum.recs
   120 
   120 
   121 setup {* Sign.parent_path *}
   121 setup {* Sign.parent_path *}
   122 
   122 
   123 primrec sum_map :: "('a \<Rightarrow> 'c) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> 'a + 'b \<Rightarrow> 'c + 'd" where
   123 old_primrec sum_map :: "('a \<Rightarrow> 'c) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> 'a + 'b \<Rightarrow> 'c + 'd" where
   124   "sum_map f1 f2 (Inl a) = Inl (f1 a)"
   124   "sum_map f1 f2 (Inl a) = Inl (f1 a)"
   125 | "sum_map f1 f2 (Inr a) = Inr (f2 a)"
   125 | "sum_map f1 f2 (Inr a) = Inr (f2 a)"
   126 
   126 
   127 functor sum_map: sum_map proof -
   127 functor sum_map: sum_map proof -
   128   fix f g h i
   128   fix f g h i
   175     from a have "case_sum f1 f2 (Inr y) = case_sum g1 g2 (Inr y)" by simp
   175     from a have "case_sum f1 f2 (Inr y) = case_sum g1 g2 (Inr y)" by simp
   176     then show "f2 y = g2 y" by simp
   176     then show "f2 y = g2 y" by simp
   177   qed
   177   qed
   178 qed
   178 qed
   179 
   179 
   180 primrec Suml :: "('a \<Rightarrow> 'c) \<Rightarrow> 'a + 'b \<Rightarrow> 'c" where
   180 old_primrec Suml :: "('a \<Rightarrow> 'c) \<Rightarrow> 'a + 'b \<Rightarrow> 'c" where
   181   "Suml f (Inl x) = f x"
   181   "Suml f (Inl x) = f x"
   182 
   182 
   183 primrec Sumr :: "('b \<Rightarrow> 'c) \<Rightarrow> 'a + 'b \<Rightarrow> 'c" where
   183 old_primrec Sumr :: "('b \<Rightarrow> 'c) \<Rightarrow> 'a + 'b \<Rightarrow> 'c" where
   184   "Sumr f (Inr x) = f x"
   184   "Sumr f (Inr x) = f x"
   185 
   185 
   186 lemma Suml_inject:
   186 lemma Suml_inject:
   187   assumes "Suml f = Suml g" shows "f = g"
   187   assumes "Suml f = Suml g" shows "f = g"
   188 proof
   188 proof