Giter Site home page Giter Site logo

affeldt-aist / monae Goto Github PK

View Code? Open in Web Editor NEW
67.0 6.0 10.0 2.78 MB

Monadic effects and equational reasonig in Coq

License: GNU Lesser General Public License v2.1

Coq 99.92% Makefile 0.08%
monads monad-transformers probabilistic-programming nondeterminism mathcomp ssreflect math-comp monadic-effects

monae's People

Contributors

affeldt-aist avatar ayumusaito avatar celestinesauvage avatar davidnowak avatar garrigue avatar t6s avatar tzskp1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

monae's Issues

Minimization of dependencies

First of all, I would like to thank all the contributors to this library!
For our project, we've been searching for a Coq library of monad theory and among few alternatives we chose monae.
Currently, we need just a basic stuff: basic hierarchy (functors, natural transformations, monads, nondet monads) and basic instances (list, state, etc). We've been really happy to find everything we need in monae.
However, a big list of library dependencies was a bit disappointing.

For example, a dependency on coq-infotheo was surprising, as well as dependencies on mathcomp-fingroup, mathcomp-solvable, etc. From what I understood after a quick pass over the sources, coq-infotheo is used mostly for the probability monad. The boolp.v library from mathcomp-analysis is used heavily for "classical" reasoning. I haven't understood how mathcomp-fingroup, mathcomp-field, etc are used.

Since the monad theory is a cornerstone of PL theory, it would be really nice to have a core library of monad theory with a minimalistic list of dependencies. If you'll be interested in achieving this goal I would be happy to help with this and prepare a PR.

I think there are two possible ways to achieve this:
(1) split the library into two: something like monae-core with a basic hierarchy of monads and common theory,
and e.g. monae-prob with the probability monad
(2) use opam's depopts feature and install various advanced features of the library (e.g. prob monad) only if the user already has all required packages installed.

notation broken

The notations on top of hierarchy.bind (>>=, the do notation) seem to be broken with HB.
They parse but do not always display.

Remove when available from analysis

monae/gcm_model.v

Lines 659 to 667 in 5bfc22a

Section move_to_classical_sets_ext.
Lemma eq_bigcup_cond :
forall (T U : Type) (P Q : set U) (X Y : U -> set T),
P = Q -> (forall i, P i -> X i = Y i) -> \bigcup_(i in P) X i = \bigcup_(i in Q) Y i.
Proof.
move=> ? ? P Q X Y pq XY.
by rewrite eqEsubset; split=> x; case=> j; rewrite -?pq=> ?; rewrite -?XY // => ?; eexists j; rewrite -?pq // -XY //.
Qed.
End move_to_classical_sets_ext.

A similar lemma should appear in analysis soon. Let us keep this one for a while until it is subsumed
instead of moving it to infotheo.

@t6s

A shorter proof of image_preserves_convex_hull, using Fintype.fin_all_exists

(Put it here because I do not have writing rights, and not really worth forking for just that)

Lemma image_preserves_convex_hull (A B : finType) (f : {affine {dist A} -> {dist B}})
  (Z : set {dist A}) : f @` hull Z = hull (f @` Z).
Proof.
rewrite predeqE => b; split.
  case=> a [n [g [e [Hg]]]] ->{a} <-{b}.
  exists n, (f \o g), e; split.
    move=> b /= [i _] <-{b} /=.
    by exists (g i) => //; apply Hg; exists i.
  by rewrite affine_function_Sum.
case=> n [g [e [Hg]]] ->{b}.
suff [h Hh] : exists h : 'I_n -> dist_convType A, forall i, h i \in Z /\ f (h i) = g i.
  exists (\Sum_e h).
    exists n; exists h; exists e; split => //.
    move=> a [i _] <-.
    move: (Hh i) => [].
    by rewrite in_setE.
  rewrite affine_function_Sum; apply eq_convn => // i /=.
  by case: (Hh i).
apply (@fin_all_exists _ _ (fun i hi => hi \in Z /\ f hi = g i)) => i.
case: (Hg (g i)); first by exists i.
move=> a // HZa Hfa.
exists a; split; by rewrite // in_setE.
Qed.

reduce dependency wrt infotheo

by move=> ? ?; rewrite /bind classical_sets_ext.bigcup_of_singleton image_id.

bigcup_of_singleton and bigcup_image will be in the next version of mathcomp-analysis
and this dependency wrt infotheo can be removed

NB: bigcup_of_singleton became bigcup_of_set1

code duplicated in infotheo

monae/example_array.v

Lines 24 to 43 in 56087f1

(* TODO: Pr to infotheo *)
Local Open Scope zarith_ext_scope.
Reserved Notation "n %:Z" (at level 2, left associativity, format "n %:Z").
Definition natZ := nosimpl Z_of_nat.
Notation "n %:Z" := (natZ n) : zarith_ext_scope.
Notation "z .+1Z" := (Z.succ z) (at level 2, left associativity,
format "z .+1Z") : zarith_ext_scope.
Lemma add1Z z : (1 + z)%Z = z.+1Z.
Proof. by rewrite Z.add_1_l. Qed.
Lemma natZ0 : 0%:Z = 0%Z. Proof. exact: Nat2Z.inj_0. Qed.
Lemma natZS n : n.+1%:Z = n%:Z.+1Z.
Proof. by rewrite -Zpos_P_of_succ_nat. Qed.
Local Close Scope zarith_ext_scope.
(* TODO: Pr to infotheo (end) *)

non forgetful inheritance detected

monae/category.v

Lines 906 to 907 in 30808b4

HB.instance Definition _ := isMonad.Build C F bindE joinretM joinMret joinA.
(* TODO: eliminate Warning: non forgetful inheritance detected *)

monae/category.v

Lines 959 to 961 in 30808b4

HB.instance Definition monad_of_adjoint_mixin :=
isMonad.Build C M bindE join_left_unit join_right_unit join_associativity.
(* TODO: eliminate Warning: non forgetful inheritance detected *)

@t6s

Adding monadic fixpoint to define Mu's quicksort

The definition of qperm function in the quicksort branch requires an interaction between fixpoints and binds to show its termination.
Currently there is no such mechanism, and it seems hard to finish the definition.

One possible solution is in http://leventerkok.github.io/papers/mfix.pdf : the monadic fixpoint operator mfix.
Let's see if this mfix can be added to monae with useful laws and if this enables quicksort.

typo in Record isMonadArray

In Record isMonadArray in hierarchy.v,

  agetpustskip : forall i, aget i >>= aput i = skip ;

this line has a typo: agetpustskip -> agetputskip ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.