feat: add binary search shrinking for numeric types#60
Open
alok wants to merge 1 commit intoleanprover-community:mainfrom
Open
feat: add binary search shrinking for numeric types#60alok wants to merge 1 commit intoleanprover-community:mainfrom
alok wants to merge 1 commit intoleanprover-community:mainfrom
Conversation
Nat.shrinkToMinimal finds the true minimal failing value via binary search, improving on Nat.shrink which only tries n/2, n/4, ... Example: for test `n ≥ 50`, starting from 4096: - Nat.shrink finds 64 (smallest power of 2 ≥ 50) - Nat.shrinkToMinimal finds 50 (true minimal) Adds shrinkToMinimal for: Nat, Int, Fin, UInt8/16/32/64
Contributor
|
Hi, I came across this PR while browsing, I have a comment about this PR and a broader comment about Plausible's current integer shrinking:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
shrinkToMinimalfor numeric types using binary search.Problem:
Nat.shrinkonly tries n/2, n/4, ... so for testn ≥ 50from 4096, it finds 64.Solution: Binary search finds true minimal (50).
Adds:
Nat.binarySearch,*.shrinkToMinimalfor Nat, Int, Fin, UInt8/16/32/64Termination proven via
termination_by hi - lo.