From 212ea6724acaadb0df1c3bd9da57bc6db4f6b80f Mon Sep 17 00:00:00 2001 From: Rafal Kolanski Date: Wed, 17 Apr 2019 00:08:55 +1000 Subject: [PATCH] lib: add obind_eqI_full to OptionMonad Sometimes after showing equality of the heads of the obind, we need this result in proof of equality of the tails. --- lib/Monad_WP/OptionMonad.thy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Monad_WP/OptionMonad.thy b/lib/Monad_WP/OptionMonad.thy index bee69c828..1d1eee899 100644 --- a/lib/Monad_WP/OptionMonad.thy +++ b/lib/Monad_WP/OptionMonad.thy @@ -223,6 +223,14 @@ lemma obind_eqI: "\ f s = f s' ; \x. f s = Some x \ g x s = g' x s' \ \ obind f g s = obind f g' s'" by (simp add: obind_def split: option.splits) +(* full form of obind_eqI; the second equality makes more sense flipped here, as we end up + with "f s = Some x ; f s' = f s" preventing "Some x = ..." *) +lemma obind_eqI_full: + "\ f s = f s' ; \x. \ f s = Some x; f s' = f s \ \ g x s = g' x s' \ + \ obind f g s = obind f g' s'" + by (drule sym[where s="f s"]) (* prevent looping *) + (clarsimp simp: obind_def split: option.splits) + lemma obindE: "\ (f |>> g) s = Some v; \v'. \f s = Some v'; g v' s = Some v\ \ P\ \ P"