Coder Social home page Coder Social logo

Bug in proofs about leon HOT 10 OPEN

BLepers avatar BLepers commented on July 17, 2024
Bug in proofs

from leon.

Comments (10)

samarion avatar samarion commented on July 17, 2024

from leon.

larsrh avatar larsrh commented on July 17, 2024

Strangely enough the Isabelle solver thinks a and b are terminating. Leon claims that b(0) doesn't terminate but Isabelle evaluates that to false. (I'm guessing because i == 1 evaluates to false, so the conclusion is never actually executed.)

from leon.

BLepers avatar BLepers commented on July 17, 2024

Ok... Would it be possible to give an error in that case? It is a bit strange to see that this code passes verification :)

from leon.

samarion avatar samarion commented on July 17, 2024

from leon.

larsrh avatar larsrh commented on July 17, 2024

It turns out my assessment was wrong. Here's what Isabelle sees:

fun a :: "int ⇒ int" and b :: "int ⇒ bool" where
"a i = i - 1" |
"b i = (i = 1 ⟶ a i = 0)"

Hence, the function definitions themselves are definitely terminating, because there is no call to b in a (the Isabelle backend will – by default – not include the pre- and postconditions in the function definition). If the functions are annotated with @isabelle.fullBody, then Isabelle sees the call to b and correctly refuses to define the function. I'm unsure what to make of all this.

from leon.

larsrh avatar larsrh commented on July 17, 2024

In essence, the question is: How do you deal with pre- and postconditions introducing complications in the call graph?

from leon.

larsrh avatar larsrh commented on July 17, 2024

By the way, the Isabelle backend is supposed to always give sound results even without --termination switched on. So there is definitely an issue here somewhere.

from leon.

vkuncak avatar vkuncak commented on July 17, 2024

I think that @BLepers is not specifically talking about the Isabelle back end. Termination checker should be on by default and turning it off explicitly should be allowed but known to cause soundness issues if the functions are not terminating. @BLepers , let us know what termination checker reports and if it is too weak in some cases.

from leon.

BLepers avatar BLepers commented on July 17, 2024

The termination checker says that a does not finish:

[  Info  ] ║ apply       ✓ Terminates (Non-recursive)                                           
[  Info  ] ║ apply       ✓ Terminates (Non-recursive)                                          
[  Info  ] ║ a           ✗ Non-terminating for call: a(0)                                     
[  Info  ] ║ b           ✗ Calls non-terminating functions a 

So I guess it makes sense that the verification phase is not sound for that example (even though it should probably fail by default as Viktor said because errors like that can easily be made).

What I find a bit confusing in that example is that a() never "really" calls b(). I.e., if you run the applicative code without the "ensuring", there is no infinite loop. (Basically I just tried to separate a bit the proof logic - b() - and the applicative code - a()).

from leon.

samarion avatar samarion commented on July 17, 2024

The guarantee Leon is giving you when it says "valid" is that if you run the code, every time you encounter a contract, it won't evaluate to false. In this case, Leon is telling you the contract of a() (namely b()) will never evaluate to false (which is true since it won't terminate). However, you didn't guarantee that the contract would evaluate to true, which is typically what you would want when you say something is verified.

Note that with termination (and a few other checks that guarantee the program won't crash), never evaluating to false is equivalent to always evaluating to true.

from leon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.