Skip to content

Commit

Permalink
monad laws for either
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaliva committed Nov 22, 2023
1 parent bf1294e commit 6e29ecb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions coq/Proofs/ProofsAux.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Require Import Common.ZMap.

Require Import ExtLib.Structures.Monads.
Require Import ExtLib.Structures.Monad.
Require Import ExtLib.Structures.MonadLaws.
Require Import ExtLib.Data.Monads.EitherMonad.
Require Import Coq.Relations.Relation_Definitions.

Expand Down Expand Up @@ -436,3 +437,11 @@ Section SimpleError.
Qed.

End SimpleError.


#[global] Instance Monad_either_MonadLaws {T:Type}:
MonadLaws (Monad_either T).
Proof.
split; intros; unfold Monad_either, ret, bind;
repeat break_match;subst; try inl_inr_inv; try reflexivity; try inl_inr.
Qed.
7 changes: 4 additions & 3 deletions coq/Proofs/Revocation.v
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Require Import Lia.
Require Import StructTact.StructTactics.

From ExtLib.Data Require Import List.
From ExtLib.Structures Require Import Monad Monads MonadExc MonadState Traversable.
From ExtLib.Structures Require Import Monad Monads MonadLaws MonadExc MonadState Traversable.
From ExtLib.Data.Monads Require Import EitherMonad OptionMonad.

From Coq.Lists Require Import List SetoidList. (* after exltlib *)
Expand Down Expand Up @@ -1061,6 +1061,7 @@ Module RevocationProofs.
(Ec : relation C)
(m : Type -> Type)
(M : Monad m)
(ML: MonadLaws M)
(EMa : relation (m A))
(RetProper: Proper (Ea ==> EMa) ret)
(BindProper: Proper ((EMa) ==> (Ea ==> EMa) ==> (EMa)) (@bind m M A A))
Expand Down Expand Up @@ -1517,8 +1518,8 @@ Module RevocationProofs.
eapply monadic_fold_left2_proper with
(Ea:=repr_fold2_eq)
(Eb:=eq)
(Ec:=struct_field_eq);
[typeclasses eauto|typeclasses eauto|reflexivity|assumption|repeat split;auto|].
(Ec:=struct_field_eq); try typeclasses eauto;
[reflexivity|assumption|repeat split;auto|].

(* proper for 'f' *)
intros a a' Ea.
Expand Down

0 comments on commit 6e29ecb

Please sign in to comment.