-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for the Prop Monad #165
base: master
Are you sure you want to change the base?
Conversation
Proved Proper Instance, WIP Unfold law.
Interesting subtleties while defining the
Our original definition of the
However, this approach is problematic because it applies the same step to every iteration of the loop, which is not desirable for cases when each iteration of the loop might choose a different nondeterministic action. For instance, consider the following example. We can define a "tt and ff printing loop", where the body of the loop is defined as the nondeterministic set of actions as follows:
An iteration of this body, ideally, would be As a possible fix to this problem, we can modify the existential quantifier on each step of the iteration with a natural number which indexes the loop body.
So, each
This is the IterUnfold law that needs to be proved for PropTM. By the pointwise equality defined on the underlying Prop, this becomes:
However, notice that in order to reason about the second case, ( The hypothesis
Without classical reasoning, we cannot reason about a |
Some notes with the experiment on defining PropTM with a generalized notion of eqM (on definitions that didn't work, and why). 1. Initial eqmR PropTM definition Our initial attempt at defining the eqmR instance for PropTM gave the following definition to eqm:
Notice that
However, as seen in [Awkward Proper Instance], this definition will require us to make strange claims about propositions that hold for a PropTM. 2. Awkward Proper Instance In order to prove
Let's assume that This is the same as the "too strong universal quantification" statement that we wanted to eliminate! We do not want this proper instance to hold true, because that would imply that our parameterized equivalence relation implies a more general notion of equivalence over more relations. 3. Current Experiment
Right now, we're trying to see if proving an EqmR_OK and EqmRMonad instance for this definition makes sense in branch |
1. Why not "MayRet"? 2. Weaker closedness condition @YaZko 's proposal of a weaker closedness property: 3. Heterogeneous relations (See Basics/HeterogeneousRelations.v in |
Another note --- Haskell's restricted data types allows the definition of monads on types with equality, which is similar to what we do (See : Section 3, Restricted Monads). |
This PR describes the ongoing work to provide good library support to denote non-deterministic languages with [itree]s, such as is done in Vellvm.
The gist of it is to provide an (iterative) [Prop] monad transformer, roughly of type [fun M A -> (M A -> Prop)].
The main current draft is contained in the file [Basics/MonadPropClosed], that works more specifically over a sigma type in order to only consider sets of computations closed for the underlying equivalence.
From a technical standpoint, we are currently identifying two main difficulties.
Consider the definition of [bind]: judging the membership of a computation, it should accept it if it can be decomposed into a bind such that each component essentially belong to two sets. However, when it comes to the continuation, we have a subtlety: for the [bind_ret_l] law to hold true, we need to restrict the membership check over values that the first part of the monadic computation may return (see comment in commit 1de7443 for details).
This leads us to define the typeclass
MayReturn
whose study is in progress. The current definition has been instantiated for the [itree E] monad, but seems to raise issue in the case of the [StateT] monad transformer. A suggestion to be looked at in details might be that rather than relating monadic computations to values (m A -> A -> Prop), we might want to related monadic transformer applied to the [itree E] monad to ones applied to the [Id] monad (T (itree E) A -> T A -> Prop).The second difficulty comes with proving the left associativity monadic law. The intuition behind the difficulty is that we have an hypothesis stating that
forall a:A, mayret ma a -> exists mb kbc, ...
, i.e. a propositional hypothesis positing for each value that may be returned by the part 1 of the computation a way to break down the remaining of the computation into two parts. From this, we need to craft a concrete continuation, i.e. a function, to feed to our concrete bind.It feels like classical reasoning is necessary, but phrasing things right is not yet clear. The current feeling is that we may need to assume the underlying monad to be pointed (so that we have a default value to return, e.g. [spin], in the absurd branches of the continuation), and that we would use an oracle to decide [mayret] in the continuation.
Finally, additional resources are: