-
Notifications
You must be signed in to change notification settings - Fork 0
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
Inconsistent generalizations for [Int]
and [Bool]
#4
Comments
@ColinRunciman, thanks for discovering this. |
I know why now. For the Since the background of {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoMonomorphismRestriction #-} -- AAARRRRGGHHHH!!!!
import Test.Extrapolate
-- incorrect property:
prop_lengthZip :: [a] -> [a] -> Bool
prop_lengthZip xs ys = length (zip xs ys) == max (length xs) (length ys)
main :: IO ()
main = do
check (prop_lengthZip :: [Int] -> [Int] -> Bool)
putStrLn "\n"
chk (prop_lengthZip :: [()] -> [()] -> Bool)
putStrLn "\n"
chk (prop_lengthZip :: [Bool] -> [Bool] -> Bool)
where
chk = check `withBackground` [constant "/=" ((/=) :: Int -> Int -> Bool)] output: *** Failed! Falsifiable (after 2 tests):
[] [0]
Generalization:
xs (_:xs)
Conditional Generalization:
xs ys when length xs /= length ys
*** Failed! Falsifiable (after 2 tests):
[] [()]
Generalization:
us (_:us)
Conditional Generalization:
us vs when length us /= length vs
*** Failed! Falsifiable (after 2 tests):
[] [False]
Generalization:
ps (_:ps)
Conditional Generalization:
ps qs when length ps /= length qs Hah! Maybe what I need to do for a permanent fix is to always include the background of |
Reasons: * Bool is in every property, all conditions are Bool; * Int is in a lot of functions from the prelude. A more definitive solution (for the Int case) would be to check the types of background and include any types found there. For example, the list background has length by default of return type Int. this partially solves #4
For the above program, the output is the following:
Extrapolate is able to produce a conditional generalization involving
length
of[Int]
but not of[Bool]
and[()]
. Why?The text was updated successfully, but these errors were encountered: