Skip to content
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] - fix(slim_check): do not crash when binders contain a function type #11231

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Mathlib/Testing/SlimCheck/Testable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ open Lean
quantifiers and add `NamedBinder` annotations next to them. -/
partial def addDecorations (e : Expr) : MetaM Expr :=
Meta.transform e fun expr => do
if not (← Meta.inferType e).isProp then
return .continue
if not (← Meta.inferType expr).isProp then
return .done expr
Comment on lines +512 to +513
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the meaning clearer this way (although I know you weren't the one introducing this spelling).

Suggested change
if not (← Meta.inferType expr).isProp then
return .done expr
unless (← Meta.inferType expr).isProp
return .done expr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does unless support else? I think in an else/if chain, using unless makes things a little weirder to read.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it does, but I claim that's a feature. The unless clause indicates a condition on which you want to immediately abort, which is not what an else/if chain indicates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to use "this if isn't really part of this patch" to avoid having to do anything in this CL. If you feel strongly that unless is underused, perhaps open a follow-up with 10 or so replacements across mathlib and see what people think.

bors merge

else if let Expr.forallE name type body data := expr then
let newType ← addDecorations type
let newBody ← Meta.withLocalDecl name data type fun fvar => do
Expand Down
15 changes: 15 additions & 0 deletions test/slim_check.lean
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,21 @@ issue: ⋯ does not hold
exact test_sorry
trivial

open scoped BigOperators in
example (n : ℕ) : true := by
have : ∑ f : Unit → Fin (n + 1), f () = 0 := by
success_if_fail_with_msg "
===================
Found problems!
n := 1
issue: 1 = 0 does not hold
(0 shrinks)
-------------------
"
slim_check (config := { randomSeed := some 257 })
exact test_sorry
trivial

-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/slim_check.20question/near/412709012
open scoped BigOperators in
/--
Expand Down