Skip to content
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

Deriving false is possible with termination checking enabled #2459

Open
hetzenmat opened this issue Dec 6, 2024 · 4 comments
Open

Deriving false is possible with termination checking enabled #2459

hetzenmat opened this issue Dec 6, 2024 · 4 comments

Comments

@hetzenmat
Copy link

In the code below, all functions are shown terminating and can be reflected, but one can derive false.
Is this expected behavior?

{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--ple" @-}

module A where

data L a = LNil | LCons a (L a)

{-@ reflect infList @-}
{-@ infList :: L a -> Bool @-}
infList :: L a -> Bool
infList LNil = False
infList (LCons _ t) = infList t

{-@ reflect g @-}
{-@ g :: {l:L () | infList l} -> {r:Bool | r && (not r)} @-}
g :: L () -> Bool
g (LCons () r) = g r

I tested this code with the latest git version of LH as well as the online Demo.

@facundominguez
Copy link
Collaborator

👋 Hello @hetzenmat. The specification of g is essentially equivalent to

{-@ g :: {l:L () | false } -> {r:Bool | false } @-}

I think it is expected that you can prove false from false.

@ranjitjhala
Copy link
Member

To add to @facundominguez 's observation above -- LH will not let you "call" the function g as it's precondition is false for any (finite) list you give it...

@hetzenmat
Copy link
Author

Thank you for the fast reply.
I crafted this example in such a way that one gets no warning if false could be proved.
If I replace r && (not r) by false, a warning is generated.

I guess with an additional check even for my example a warning can be generated, i.e., check if the refinement is of the form P && (not P) for some expression P.

@AlecsFerra
Copy link
Contributor

AlecsFerra commented Dec 13, 2024

I think is more of a bug to warn the user here, as we are expected to prove false in this context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants