Zulip Chat Archive

Stream: new members

Topic: slimcheck with definitions that contain quantifiers


Mark Aagaard (Oct 30 2024 at 15:31):

I'm playing around with SlimCheck to learn how best to use it. Is SlimCheck able to generate tests for definitions that contain quantifiers over Nats? I am able to do Testable.check for expressions that contain quantifiers, but when I put the expression inside a definition, I get a "failed to synthesize Testable" error.

Is there a way to use Testable.check on definitions that contain quantifiers?

Here's a small example:

import Mathlib.Tactic
open SlimCheck

def q (n:ℕ) : Bool := n > 3

#eval Testable.check (∀ (n:ℕ), q n) -- this works and gives a counterexample

def q2 := ∀ (n:ℕ), n > 3 -- now put the quantifier inside the def

#eval Testable.check q2 -- fails with "failed to synthesize Testable q2"

-mark

Henrik Böving (Oct 30 2024 at 15:49):

You need to make the definition an abbrev or define the testable instance yourself. That's just a consequence of how TC synthesis works

Ruben Van de Velde (Oct 30 2024 at 15:55):

Please also check #backticks

Mark Aagaard (Oct 30 2024 at 18:26):

Changing from def to abbrev didn't help. I'm still getting failed to synthesize Testable q2. Do I need to define a testable instance of q2? Is the best resource for this:

https://github.com/argumentcomputer/LSpec/blob/main/LSpec/Instances.lean

-mark

Henrik Böving (Oct 30 2024 at 19:09):

Ah I guess this is a bit unlucky because of the way that slim_check works internally with binders

Henrik Böving (Oct 30 2024 at 19:12):

I'd guess you have to define the instance yourself at this point rather unfortunately mhm

Henrik Böving (Oct 30 2024 at 19:13):

But this should be fixable in plausible


Last updated: May 02 2025 at 03:31 UTC