Library TLC.LibSum
Set Implicit Arguments.
From TLC Require Import LibTactics LibLogic LibBool.
Generalizable Variables A B.
Definition
Instance sum_inhab_l : forall `{Inhab A} B, Inhab (A + B).
Proof using. intros. apply (Inhab_of_val (inl arbitrary)). Qed.
Instance sum_inhab_r : forall `{Inhab B} A, Inhab (A + B).
Proof using. intros. apply (Inhab_of_val (inr arbitrary)). Qed.
Definition Inhab_sum : forall `{Inhab A, Inhab B}, Inhab (A + B).
Proof using. typeclass. Qed.
Definition is_inl (A B : Type) (x : A + B) : bool :=
match x with
| inl _ => true
| inr _ => false
end.
Definition is_inr (A B : Type) (x : A + B) : bool :=
match x with
| inl _ => false
| inr _ => true
end.
Section IsIn.
Variables (A B : Type).
Implicit Type x : A + B.
Lemma is_inl_neg_is_inr : forall x,
is_inl x = ! (is_inr x).
Proof using. intros x. destruct~ x. Qed.
Lemma is_inr_neg_is_inl : forall x,
is_inr x = ! (is_inl x).
Proof using. intros x. destruct~ x. Qed.
End IsIn.