Skip to content
Snippets Groups Projects
Commit 58c3a75f authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Add a tactic to simplify expressions in the option monad.

parent 9fcbbccf
No related branches found
No related tags found
No related merge requests found
......@@ -129,6 +129,18 @@ Instance option_join: MJoin option := λ A x,
end.
Instance option_fmap: FMap option := @option_map.
Ltac simplify_options := repeat
match goal with
| _ => progress simplify_eqs
| H : mbind (M:=option) ?f ?o = ?x |- _ =>
change (option_bind _ _ f o = x) in H;
destruct o; simpl in H; try discriminate
| H : context [ ?o = _ ] |- mbind (M:=option) ?f ?o = ?x =>
change (option_bind _ _ f o = x);
erewrite H by eauto;
simpl
end.
Lemma option_fmap_is_Some {A B} (f : A B) (x : option A) : is_Some x is_Some (f <$> x).
Proof. destruct x; split; intros [??]; subst; compute; eauto; discriminate. Qed.
Lemma option_fmap_is_None {A B} (f : A B) (x : option A) : x = None f <$> x = None.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment