Skip to content

Commit

Permalink
fix(Testing/SlimCheck/Testable): do not call inferType on an expres…
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Feb 10, 2024
1 parent a6a17da commit 25c2e96
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Mathlib/Testing/SlimCheck/Testable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,11 @@ partial def addDecorations (e : Expr) : MetaM Expr :=
if not (← Meta.inferType e).isProp then
return .continue
else if let Expr.forallE name type body data := expr then
let n := name.toString
let newType ← addDecorations type
let newBody ← addDecorations body
let newBody ← Meta.withLocalDecl name data type fun fvar => do
return (← addDecorations (body.instantiate1 fvar)).abstract #[fvar]
let rest := Expr.forallE name newType newBody data
return .done <| (← Meta.mkAppM `SlimCheck.NamedBinder #[mkStrLit n, rest])
return .done <| (← Meta.mkAppM `SlimCheck.NamedBinder #[mkStrLit name.toString, rest])
else
return .continue

Expand Down
25 changes: 25 additions & 0 deletions test/slim_check.lean
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,28 @@ issue: ⋯ does not hold
slim_check (config := { randomSeed := some 257 })
admit
trivial

-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/slim_check.20question/near/412709012
open scoped BigOperators in
/--
info: Success
---
warning: declaration uses 'sorry'
-/
#guard_msgs in
example (q : ℕ) : q = 0 ∨ q ≥ 2
8 = ∑ k in Finset.range 2, 5 ^ k * Nat.choose (2 * q + 1) (2 * k + 1) := by
slim_check

-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/slim_check.20giving.20wrong.20counterexamples.3F/near/420008365
open Nat in
/--
info: Success
---
warning: declaration uses 'sorry'
-/
#guard_msgs in
theorem testBit_pred :
testBit (pred x) i = (decide (0 < x) &&
(Bool.xor ((List.range i).all fun j => ! testBit x j) (testBit x i))) := by
slim_check

0 comments on commit 25c2e96

Please sign in to comment.