-
Notifications
You must be signed in to change notification settings - Fork 7
Derive proof of completeness for derived generators #74
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
Comments
It definitely is a necessary thing. And since I have already thought quite something about this problem a while ago, I'll try to summarise those thoughts here (not necessarily all at once). Raw generatorsFirst of all, it looks like completeness proof of our current generators must assume completeness of raw generators. Alternatively, we can consider that this proof would be a variant of implication of completeness of some raw generators to a completeness of our generators, but this looks extremely hard since no raw generators are visible outside the type of a generator. Type of the proofHonest wayIn the simplest form the completeness proof should look like *for this particular generator of type Since running of our generators involves a random seed, the realisation of the completeness property could look like this: 0 Complete : Gen a -> Type
Complete g = (x : a) -> (seed ** runGen g seed = x) if we had a function Or at least the resulting type could be Generality problemThe problem is that our generators runner But this is not the hardest problem. Problems for pureEven if we would agree that our completeness property involves only particular pure Proposed solution (discussible)So, my idea was to abstract over implementation, assuming some reasonable properties for external stuff. Say, assuming that we can get any Having that, we can formulate a type for completeness property which describes each separate constructor of Say, if data Gen : Type -> Type where
Empty : Gen a
Pure : a -> Gen a
Raw : (MonadRandom m => m a) -> Gen a
OneOf : List (Gen a) -> Gen a
Bind : Gen a -> (a -> Gen b) -> Gen b we can consider the property in the following form: data Complete : Gen a -> Type where
NoElems : Not a -> Complete Empty
SingleElem : ((x, y : a) -> x = y) -> Complete $ Pure x
AssumeRaw : Complete $ Raw sf
Choose : Either (All Complete gs, ?composite_compl) -> Complete $ OneOf gs
Chain : Complete lhs -> ((x : a) -> Complete $ rhs x) -> Complete $ Bind lhs rhs (we need to think what to write instead of Having property in this form, we need several separate properties proving that, say FurtherLike in #57 with emptiness characteristic, we can try to add completeness property to the type of |
Alternative approach to specifying completeness, assuming for now that we don't have (or care about)
|
Another option is to use something similar to what @buzden described in Honest way, but with a special predictable 0 Complete : Gen a -> Type
Complete g = (x : a) -> (seed ** runGen g seed predictableRandom = x) |
Additionally, instead of supplying a predictable implementation of Moreover, the fairness condition would also have a connection to |
Currently, there is a strong reasons to believe that derived generators are (intensionally) complete - in our case, this means that in the tree representing a derived generator for certain type (for each value of this type) there exists a leaf node that contains this value. However, there is no proof that this completeness holds. For correctness reasons, it might be useful to derive a proof of intensional completeness along with the generator.
The text was updated successfully, but these errors were encountered: