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

Possibility to see the counter-example generated by the SMT solver #169

Open
acmLL opened this issue Feb 9, 2023 · 10 comments
Open

Possibility to see the counter-example generated by the SMT solver #169

acmLL opened this issue Feb 9, 2023 · 10 comments

Comments

@acmLL
Copy link

acmLL commented Feb 9, 2023

I think that it would be interesting to see the counter-example generated by the SMT solver. The "False" is already helpful but a counter-example can help the specifier to improve the annotations. Thanks!

@langfield
Copy link
Contributor

langfield commented Feb 9, 2023

Yes we certainly have talked about this, and I believe it is on our to-do list, haha.

I am definitely not an SMT expert, but we do allow the dumping of queries with the --output-queries flag, and it is possible with e.g. z3 to manually see the satisfying inputs using the get-value function.

As an aside, I don't suppose you'd be interested in becoming a contributor and working on a feature like this with us? We'd be sure to give you as much as help as possible getting you up-to-speed! 😁

@acmLL
Copy link
Author

acmLL commented Feb 9, 2023

Hey, @langfield . Thank you very much for your promptly reply! I am a professor and not a Dev :-( Probably I will not speed up the development of horus... :-( Best!

P.S.: By the way, what math.cairo lib does horus-compile use? I saw that it has its own math.cairo file...

@langfield
Copy link
Contributor

No worries!

Can you link me to the math.cairo file you're referring to? Or the relevant line?

@acmLL
Copy link
Author

acmLL commented Feb 13, 2023

I am trying to use horus on this

%lang starknet

from starkware.cairo.common.uint256 import Uint256

from contracts.lib.aliases import ray, ufelt, wad
from contracts.lib.wad_ray import WadRay

// @post -WadRay.BOUND <= $Return.res and $Return.res < WadRay.BOUND
func main_{range_check_ptr}(a, b: felt) -> (res: felt) {
    return (res=WadRay.wmul(a, b));
}

And the cairo program WadRay imports the math.cairo (which is not annotated) using this

from starkware.cairo.common.math import (
    abs_value,
    assert_le,
    assert_nn_le,
    sign,
    signed_div_rem,
    unsigned_div_rem,
)

I do not know if horus is using the above math.cairo or the one located in golden/tou_amm (which is annotated with pre/post) or horus-compile/tests/golden (which is also annotated).

If horus uses the math.cairo from starkware, should I annotate the imported functions? Thanks!

@langfield
Copy link
Contributor

langfield commented Feb 13, 2023

Ah, now I understand. So the horus-compile tools behaves more or less like starknet-compile. It will look for math.cairo in the current working directory if it's imported like from math import assert_le. Otherwise, it will use the version installed with the python package cairo-lang.

So no, it will not use math.cairo from the toy_amm/ directory unless your import is like from math ... and you run it in the toy_amm/ directory.

@acmLL
Copy link
Author

acmLL commented Feb 13, 2023

Thanks, @langfield . Can I annotate the math.cairo that comes with the distribution (working directory or python package)? I know that horus calculates default pre/post-conditions but...

@langfield
Copy link
Contributor

langfield commented Feb 13, 2023 via email

@acmLL
Copy link
Author

acmLL commented Feb 13, 2023

Great! Thanks!

@langfield
Copy link
Contributor

langfield commented Feb 13, 2023 via email

@acmLL
Copy link
Author

acmLL commented Feb 13, 2023

Ok, @langfield . Thank you very much for your attention! Best!

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

2 participants