-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
The following example passes verification:
{-@ LIQUID "--exactdc" @-}
module Test where
import Language.Haskell.Liquid.ProofCombinators
{-@
f :: xs:[a]
-> ys:[a]
-> zs:[a]
-> ws:[a]
-> vs:[a]
-> us:[a]
-> { append xs (append ys (append zs (append ws (append vs us)))) =
append (append (append (append (append xs ys) zs) ws) vs) us
}
@-}
f :: [a] -> [a] -> [a] -> [a] -> [a] -> [a] -> ()
f xs ys zs ws vs us =
() ? lemmaAssoc xs ys zs -- 1 constraint, 2 kvars
? lemmaAssoc xs ys (append zs (append ws (append vs us))) -- 65 constraints, 4 kvars
? lemmaAssoc (append xs ys) zs (append ws (append vs us)) -- 213 constraints, 6 kvars
? lemmaAssoc (append (append xs ys) zs) ws (append vs us) -- 477 constraints, 8 kvars
? lemmaAssoc (append (append (append xs ys) zs) ws) vs us -- 889 constraints, 10 kvars
{-@
assume lemmaAssoc
:: xs:[a]
-> ys:[a]
-> zs:[a]
-> { append xs (append ys zs) = append (append xs ys) zs}
@-}
lemmaAssoc :: [a] -> [a] -> [a] -> ()
lemmaAssoc _ _ _ = ()
append :: [a] -> [a] -> [a]
append [] ys = ys
append (x:xs) ys = x : append xs ys
{-@ reflect append @-}
LH reports 889 constraints were verified, and the fqout file shows 10 kvars.
If I comment the last application of lemmaAssoc
the constraints drop roughly by half, although verification starts to fail, of course. The kvars also diminished as noted in the commments. Every time a lemma application is commented out the number of constraints halves again.
This doesn't look good for two reasons:
- There is no inference of refinement types that could help verifying
f
, so introducing kvars doesn't seem to serve any purpose. - The exponential growth of constraints has a serious impact on performance in larger examples with 130 kvars and 56000 constraints.
Can we somehow cut on the number of kvars or checked constraints when introducing lemma applications?
Metadata
Metadata
Assignees
Labels
No labels