Skip to content

sqrt(x) < x not a valid check #27

Open
@CrossEye

Description

@CrossEye

In examples/dependent.js, we have this contract for a supposed square root function:

@ (x: Pos) -> res: Num | res <= x

And the failing implementation of sqrt is

return x * x;

Both of these have some issues in the range (0, 1). Note that sqrt(0.25); //=> 0.5 and that 0.5 < 0.25; //=> false. Similarly, in the same range 0.7 * 0,7 = 0.49, and 0.49 < 0.7, so this succeeds for range (0, 1).

I'm brand-new here, and don't know if this is acceptable. Obviously, any value that makes such a contract fail is a demonstration that the implementation is wrong, but I don't know what standard you want to set with the examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions