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

Unsatisfiable spec of square root function #701

Open
mick62 opened this issue Jun 14, 2019 · 6 comments
Open

Unsatisfiable spec of square root function #701

mick62 opened this issue Jun 14, 2019 · 6 comments
Labels
enhancement Not a bug, but nice to have language Issues in parser, TC, interpreter, POG or CG
Milestone

Comments

@mick62
Copy link

mick62 commented Jun 14, 2019

Description

Only partial satisfiable spec for square root function in Web documentation.

Steps to Reproduce

Documentation on http://overturetool.org/languages/
Text:
"For example, a function SQRT for calculating a square root of a natural number might be defined as follows: ... "

Expected behavior:

A general satisfiable specification defines an eps > 0 for the distance between x and r*r, i.e.

SQRT(x:nat) r:real
post abs(r*r - x) <= eps

Actual behavior:

Text:
SQRT(x:nat) r:real
post r*r = x

The problem with this definition is that the postcondition can only be fulfilled when x is a square number a^2 like 4. But for all other (i.e. non-square) numbers, function SQRT can not terminate because the type of real numbers is assumed as having unlimited precision. The process of calculating e.g. sqrt(2) can not end in finite time as the mathematical object sqrt(2) has infinite many digits.

@nickbattle
Copy link
Contributor

You make an interesting point. But I think that pure VDM is unlimited precision. Of course any implementation would have finite precision in an interpreter, but should a pure specification really take that into account?

(Incidentally, there is an arbitrary precision build of VDMJ available, but it is still finite precision).

@mick62
Copy link
Author

mick62 commented Jun 14, 2019 via email

@nickbattle
Copy link
Contributor

Interesting. I hadn't come across Limes notation, though it is only mentioned in German web pages - do you just mean limit notation?

You might be on to something here. I can see the value of a clear mathematical statement that describes something precisely that accounts for the imprecision of an implementation. But we would have to think through where it could be sensibly applied in the specification language (and define its semantics, of course).

There is a mechanism for proposing language changes, via the Language Board. It can be a lengthy process, but several changes have been successfully made over the years. The onus is on the person proposing the change to define something that is adequate; the Language Board isn't there to solve problems, but to manage the change process. See LB wiki.

@peterwvj
Copy link
Member

peterwvj commented Jun 21, 2019

Since VDM is unlimited precision, changing the language to address this issue feels wrong. That being said, I do agree that a notation for expressing limits could be useful. Just a crazy thought: to void changing the language itself, would it be possible to use the annotations feature to create something useful? Perhaps something that would enable users to express function limits by adding annotations such as @Limit(r * r, x) in their specs.

@nickbattle
Copy link
Contributor

It would certainly be possible to create an annotation, but what functionality would it have - is there a proof obligation associated with the limit?

@peterwvj
Copy link
Member

I'm not sure, but my point is just that you could use it to implement the same functionality that a new language feature would contribute. Syntax validation would be helpful, perhaps it would produce a PO like you suggest, perhaps integration with some other tool more suitable for these analyses etc. It was just a thought.

@peterwvj peterwvj modified the milestones: v2.7.2, v2.7.4 Sep 30, 2019
@nickbattle nickbattle self-assigned this Dec 17, 2019
@nickbattle nickbattle added enhancement Not a bug, but nice to have language Issues in parser, TC, interpreter, POG or CG labels Dec 20, 2019
@nickbattle nickbattle removed their assignment Dec 20, 2019
@idhugoid idhugoid modified the milestones: v2.7.4, v3.0.2 Mar 16, 2020
@idhugoid idhugoid modified the milestones: v3.0.0, v3.0.2 Aug 28, 2020
@idhugoid idhugoid modified the milestones: v3.0.2, v3.0.4 Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Not a bug, but nice to have language Issues in parser, TC, interpreter, POG or CG
Projects
None yet
Development

No branches or pull requests

4 participants