Commit 58c3a75f authored by Robbert Krebbers's avatar Robbert Krebbers

Add a tactic to simplify expressions in the option monad.

parent 9fcbbccf
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment