Assume we are given three types in Lean.
constants A B C : Type
There is a canonical map of the following form.
definition can : sum (A × B) (A × C) → A × (sum B C) :=
λ x , sum.cases_on x (λ y : A × B, ⟨y.fst, sum.inl y.snd⟩)
(λ y : A × C, ⟨y.fst, sum.inr y.snd⟩)
I believe that this map should have an inverse (according to B. Jacobs book Categorical Logic and Type Theory page 143 coproducts in type theory are automatically distributive). I have trouble constructing the inverse in Lean, because I do not understand how sum.rec works, and I have trouble relating Jacobs unpack P as ... notation to the inductive definition of sums in Lean.
Can someone show me how I can define the inverse of can in Lean using sum.rec?
equiv.prod_sum_distrib
, for which the interesting implementation is here (withA
on the right instead of left) $\endgroup$