Skip to content

Chamelean#56

Draft
codyroux wants to merge 36 commits intoleanprover-community:mainfrom
codyroux:chamelean/v4.26-bump
Draft

Chamelean#56
codyroux wants to merge 36 commits intoleanprover-community:mainfrom
codyroux:chamelean/v4.26-bump

Conversation

@codyroux
Copy link
Contributor

This implements the Chamelean functionality for deriving generators for types T constrained by inductive predicates P : T -> Prop (or more complex ones).

This roughly implements a backtracking search based on unification, guided by the constraints in the constructors of P.

The user interface is a derive_generator command, which takes syntax of the form

derive_generator fun param_1 ... param_n => exists output, P param_1 ... param_n output

where all the param_i and ouptut are variables, and P is an inductive family. The form of the constructors of P is also constrained, only constants, variables and applications are allowed (which to an extent is a silly syntactic restriction).

I think this feature is best presented as a "use at your own risk" in progress feature, if it were to be merged in its current state.

There are many issues, for the known ones see here: https://github.com/codyroux/plausible/issues

codyroux and others added 30 commits September 15, 2025 22:48
This is an implementation of Rocq "quickchick" style constrained generation: for a given inductive predicate `P` over an inductive type `T`, one can derive an `ArbitrarySuchThat` instance, which gives a `Gen (Option T)` capable of generating elements of `T` which always satisfy `P`.
* Schedule Enumeration Working Draft and LazyList made Productive

* Hooking in new schedule enumeration, buggy

* Efficient schedule enumeration hooked in

* Resolving universe constraint error in checker by adding Unit type annotations in checkerBacktrack derivation.

* Updated test cases to make them less fragile in the face of changing schedules

* Ready for merge, test errors fixed or suppressed

* Cleaned up printed messages

* Cleaned up unused functions and commented out code, and turned <- into proper arrows

* Turned λ into fun

* Undo mistaken change to enumerator fuel cap (needed later) and regexp example, and removing unnessecary error log

* Suppress result of trying regex enumerator

* Responding to comments on merge, cleanup

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
)

* Enumeration exponentially improved by only including each enumerator once when combining enumerators with enumerate, and remove fuel cap on enumerations

* Cleanup some mistakes from using an older commit

* Remove outdated comment on min in enumeration and add test checking that the size of enumeration is appropriate when some branches fail.

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
…sisExp (#7)

* Take the WHNF of expressions before turning them into a HypothesisExp.

* Nix some stale examples.

* Further example cleanup.
…or Literals

* feat: Major pruning of equivalent schedules in enumeration using SCC; Supporting Literals; Bugfix (#17)

* chore: Turn warnings into trace calls

* chore: Well typed cedar test, now works

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
* feat: Partial Order Reduction Major Improvement

* chore: fixing typos and adding comment to LazyList.range

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
And make it more flexible: we take in a term of the form
(fun x y z .. => exists w, P x y w) and run the elaborator to get
somewhat more robust parsing. We now error if an argument to P is
not a variable, which we probably wanted to do anyway.
* fix: Function calls in constructor types now supported correctly

* Remove dead code and fix name of exprToConstructorExpr

* chore: Minor refactors and fixes (biggest being factoring out schedule score)

* chore: Added comment describing TyCtor

---------

Co-authored-by: Cody Roux <cody.roux@gmail.com>
Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
…bug (#45)

* fix: type variables should not be linearized

* fix: Unknowns generated for multiple flattened functions now have distinct names

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
* feat: Inductive families with Type arguments supported in generator/enum/checker derivation

* chore: removing commented code and making targetType underscored as it is unused

* chore: Removed commented code and unnecessary import and added doc string

* fix: Correctly use Arbitrary for Generator Type arguments and Enum for Enumerator Type arguments

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
* feat: Branch and bound optimizations in schedule enumeration

* chore: removing dead code and privating definitions

* chore: Replaced $ with <| and made laziness test less inefficient upon failure

---------

Co-authored-by: Segev Elazar Mittelman <segevem@amazon.com>
* Pass around constructor names for less cryptic error messages.

* chore: make index error message a bit nicer.

* chore: minor doc cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants