-
Notifications
You must be signed in to change notification settings - Fork 259
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
[Merged by Bors] - feat: tactic frontend for slim_check #3114
Conversation
Closes #1103. |
I don't actually know anything about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry the review request slipped past me :/
I think the change looks good. Leo has also told me that
the wider verification community is very interested in counter
example generation so this is certainly a good step towards it.
Regarding the teaching purposes I will write down a basic explanation
of what it does:
- You give it some proof goal or proposition
- It tries to generate random examples for inputs of that proposition
- Checks if they hold, if a certain amount does it will abort and be happy, if they do not it will instead try to minimize the counter example by a certain shrinking strategy
This general technique is called property testing, it was popularized by a Haskell library called quickcheck if you want to look more into it
So this might be pretty useful for students to figure out they are trying to prove False
early on. Note that slim_check in its current state is pretty bare bones though. It barely has instances for the sampling values of types. I think in order to actually use it on a larger scale we would definitely be interested in a deriving handler and in general more base instances.
Can't the mathlib3 instances be forward-ported here? |
It can in principle but the mathlib3 code here looks vastly different from what you would write in Lean 4. I remember trying for like an hour to get it to work before eventually giving up and just PRing what I already head. |
I propose merging as is. Instance and derive handlers can be added as there is energy to do so, but likely won't happen if people can't see that (e.g. it might have been useful already here). |
I just tried this out for the first time, it's very cool! Here's a counterexample it couldn't find: example (a b c d : ℤ) (h1 : a ≤ b) (h2 : d ≤ c) (h4 : 0 ≤ a) (h3 : 0 ≤ d) : a / c ≤ b / d := by
slim_check -- 2 3 1 0 is a counterexample Is this to be expected? (eg is Anyway, I'm on board with merging now. |
I'm actually finding that Using |
The integers are very much sampleable, the issue is just that slim_check is throwing So it might very well be that as soon as the amount of variables rises and there are
This will force it to only explore a smaller space but with the same amount of tries so
Which is now basically guaranteed to find a counter example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hargoniX Thanks for the review! 🎉
bors merge
Adds a tactic front end for `slim_check`, and provides commands `#test` and `#sample`. Updates all the mathlib3 tests, although many are broken. There are still some missing parts of `Mathlib.Testing.SlimCheck.Sampleable`: in particular we can't currently sample from lists, and this explains most of the broken tests. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>
Pull request successfully merged into master. Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Per [zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/slim_check.20is.20broken/near/356447820). - [x] depends on: #3114 [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/) Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>
Adds a tactic front end for
slim_check
, and provides commands#test
and#sample
.Updates all the mathlib3 tests, although many are broken.
There are still some missing parts of
Mathlib.Testing.SlimCheck.Sampleable
: in particular we can't currently sample from lists, and this explains most of the broken tests.