-
Notifications
You must be signed in to change notification settings - Fork 97
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
Distinguish between integer, field element and bool. #910
Conversation
765b9b8
to
f96cdfc
Compare
7b1bfea
to
40ba2f0
Compare
8c3274e
to
47ae649
Compare
c5e5597
to
3e3349d
Compare
c3d49ed
to
4811624
Compare
@@ -229,23 +232,23 @@ namespace Arith(N); | |||
// I have no idea where the "- 4 * prepend_zeros(p, 16)" comes from, but it was in the original constraints. | |||
let product_with_p = (|| |x| |nr| product(p, x)(nr) - 4 * prepend_zeros(p, 16)(nr))(); | |||
|
|||
let eq1 = (|| |nr| product(sf, x2f)(nr) - product(sf, x1f)(nr) - y2f(nr) + y1f(nr) + product_with_p(q0f)(nr))(); | |||
let eq1 = (|| |nr| std::field::modulus() + product(sf, x2f)(nr) - product(sf, x1f)(nr) - y2f(nr) + y1f(nr) + product_with_p(q0f)(nr))(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I need to check if we still need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still needed.
book/src/pil/types.md
Outdated
|
||
Powdr-pil is usually side-effect free, but there are some situations where side-effects happen. | ||
This includes the `std::debug::print` built-in function. Expressions are usually evaluated | ||
left-to right and eagerly, but it is best to not rely on this behaviour. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be exhaustive on the exceptions
book/src/pil/types.md
Outdated
The lambda expression `|| 7` is a function that returns a constant (has no parameters). | ||
Lambda functions can capture anything in their environment and thus form closures. | ||
|
||
Due to the dynamic typing of powdr-pil, the exact type of a lambda expression can often not be determined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds confusing. Why does it do dynamic typing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because nobody found the time to implement a proper generic type checker. This will be replaced once we have a proper type checker. Thibaut told me that I should not document what we plan but what we have...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea but still, we don't do dynamic typing, it's all compile-time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it depends on what you mean by compiling. But even witness generation uses dynamic typing since you can call functions from the query callbacks and those functions could look like
|i| match i {
0 => [],
1 => 7,
_ => (1,2)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wat, really?! Can we stop that :D
1713e69
to
007b605
Compare
test_data/std/poseidon_gl_test.asm
Outdated
@@ -55,7 +55,7 @@ machine Main { | |||
assert_eq C, 14940024623104903507; | |||
assert_eq D, 10772674582659927682; | |||
|
|||
A, B, C, D <== poseidon(18446744069414584321, 18446744069414584321, 18446744069414584321, 18446744069414584321, 18446744069414584321, 18446744069414584321, 18446744069414584321, 18446744069414584321, 0, 0, 0, 0); | |||
A, B, C, D <== poseidon(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it panic otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the number is the goldilocks modulus. So the test should do exactly the same as it did before.
@georgwiese any reason you chose these numbers (and used explicit zeros for the last four elements)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test vectors are the same as polygon's. I guess they were chosen exactly to test that the result is the same as if you change the inputs to 0s. The last 4 are 0s because they're the cap
that are used to "change" the hash function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, they come from the JSON linked in the comment a few lines above.
a6075b9
to
5532b6a
Compare
No description provided.