From 7f7028ce1333521bc5b5f02cde39f897f2502c30 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 22 Nov 2016 11:18:53 +0100 Subject: [PATCH] prove fmap_Some_setoid --- theories/option.v | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/theories/option.v b/theories/option.v index 16eee71..52dc722 100644 --- a/theories/option.v +++ b/theories/option.v @@ -180,6 +180,16 @@ Proof. unfold is_Some; destruct mx; naive_solver. Qed. Lemma fmap_Some {A B} (f : A → B) mx y : f <\$> mx = Some y ↔ ∃ x, mx = Some x ∧ y = f x. Proof. destruct mx; naive_solver. Qed. +Lemma fmap_Some_setoid {A B} `{Equiv B} `{!Equivalence ((≡) : relation B)} + (f : A → B) mx y : + f <\$> mx ≡ Some y ↔ ∃ x, mx = Some x ∧ y ≡ f x. +Proof. + destruct mx; simpl; split. + - intros ?%Some_equiv_inj. eauto. + - intros (? & ->%Some_inj & ?). constructor. done. + - intros ?%symmetry%equiv_None. done. + - intros (? & ? & ?). done. +Qed. Lemma fmap_None {A B} (f : A → B) mx : f <\$> mx = None ↔ mx = None. Proof. by destruct mx. Qed. Lemma option_fmap_id {A} (mx : option A) : id <\$> mx = mx. -- GitLab