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

Expr formatting. #888

Merged
merged 1 commit into from
Nov 19, 2024
Merged

Expr formatting. #888

merged 1 commit into from
Nov 19, 2024

Conversation

Alon-Ti
Copy link
Contributor

@Alon-Ti Alon-Ti commented Nov 14, 2024

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@Alon-Ti Alon-Ti marked this pull request as ready for review November 14, 2024 14:26
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from 059b0f4 to 4cdfe97 Compare November 17, 2024 07:44
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from 436a78c to 9ebe2ae Compare November 17, 2024 07:45
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from 4cdfe97 to 4f5955b Compare November 17, 2024 09:53
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from 9ebe2ae to e0a38e9 Compare November 17, 2024 09:53
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @Alon-Ti)


crates/prover/src/constraint_framework/expr.rs line 56 at r1 (raw file):

                d.format_expr()
            ),
            Expr::Const(c) => c.0.to_string(),

Const is a BaseField so why are you treat it as a string?

Code quote:

Expr::Const(c) => c.0.to_string(),

crates/prover/src/constraint_framework/expr.rs line 59 at r1 (raw file):

            Expr::Var(v) => v.to_string(),
            Expr::Add(a, b) => format!("{} + {}", a.format_expr(), b.format_expr()),
            Expr::Sub(a, b) => format!("{} - ({})", a.format_expr(), b.format_expr()),

don't you need to add parenthesis on this too?

Suggestion:

Expr::Sub(a, b) => format!("({}) - ({})", a.format_expr(), b.format_expr())

crates/prover/src/constraint_framework/expr.rs line 444 at r1 (raw file):

        let eval = test_struct.evaluate(ExprEvaluator::new(16, (SecureField::zero(), None)));
        assert_eq!(eval.constraints[0].format_expr(), "(1) * ((((col_1_0[0]) * (col_1_1[0])) * (col_1_2[0])) * (1/(col_1_0[0] + col_1_1[0])))");
        assert_eq!(eval.constraints[1].format_expr(), "(1) * ((SecureCol(col_2_4[0], col_2_6[0], col_2_8[0], col_2_10[0]) - (SecureCol(col_2_5[18446744073709551615], col_2_7[18446744073709551615], col_2_9[18446744073709551615], col_2_11[18446744073709551615]) - ((col_0_3[0]) * (SecureCol(0, 0, 0, 0)))) - (0)) * (0 + (TestRelation_alpha0) * (col_1_0[0]) + (TestRelation_alpha1) * (col_1_1[0]) + (TestRelation_alpha2) * (col_1_2[0]) - (TestRelation_z)) - (1))");

I think you should write it in a clearer indentation, (so it will be easy to understand what the constraints are, and then you it in the test.

Code quote:

        assert_eq!(eval.constraints[0].format_expr(), "(1) * ((((col_1_0[0]) * (col_1_1[0])) * (col_1_2[0])) * (1/(col_1_0[0] + col_1_1[0])))");
        assert_eq!(eval.constraints[1].format_expr(), "(1) * ((SecureCol(col_2_4[0], col_2_6[0], col_2_8[0], col_2_10[0]) - (SecureCol(col_2_5[18446744073709551615], col_2_7[18446744073709551615], col_2_9[18446744073709551615], col_2_11[18446744073709551615]) - ((col_0_3[0]) * (SecureCol(0, 0, 0, 0)))) - (0)) * (0 + (TestRelation_alpha0) * (col_1_0[0]) + (TestRelation_alpha1) * (col_1_1[0]) + (TestRelation_alpha2) * (col_1_2[0]) - (TestRelation_z)) - (1))");

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 1caa5eb Previous: f6214d1 Ratio
merkle throughput/simd merkle 29815729 ns/iter (± 440489) 14690867 ns/iter (± 434150) 2.03

This comment was automatically generated by workflow using github-action-benchmark.

CC: @shaharsamocha7

@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from 4f5955b to b8d7a09 Compare November 17, 2024 11:00
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from e0a38e9 to 36aa69d Compare November 17, 2024 11:00
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from b8d7a09 to 2601e11 Compare November 17, 2024 11:52
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch 2 times, most recently from af65bfc to 5c04e62 Compare November 17, 2024 12:15
Copy link
Contributor Author

@Alon-Ti Alon-Ti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @shaharsamocha7)


crates/prover/src/constraint_framework/expr.rs line 56 at r1 (raw file):

Previously, shaharsamocha7 wrote…

Const is a BaseField so why are you treat it as a string?

Oh, right, the unreduced form :(


crates/prover/src/constraint_framework/expr.rs line 59 at r1 (raw file):

Previously, shaharsamocha7 wrote…

don't you need to add parenthesis on this too?

Isn't it correct like this? I think add doesn't need parens, sub needs parens on the negative part and mul needs parens on both.

a * b - d + c - (x * y + z) <=> (a * b - d + c) - (x * y + z)


crates/prover/src/constraint_framework/expr.rs line 444 at r1 (raw file):

Previously, shaharsamocha7 wrote…

I think you should write it in a clearer indentation, (so it will be easy to understand what the constraints are, and then you it in the test.

Done.

@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from 2601e11 to a61816c Compare November 17, 2024 14:24
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from 5c04e62 to 78e9027 Compare November 17, 2024 14:24
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from a61816c to db26f4c Compare November 17, 2024 15:18
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from 78e9027 to b8f42ec Compare November 17, 2024 15:18
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch 2 times, most recently from b45fd93 to 72d6918 Compare November 18, 2024 07:42
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from b8f42ec to 01455db Compare November 18, 2024 07:42
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup branch from 72d6918 to 9037ea4 Compare November 18, 2024 12:07
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from 01455db to 89c469c Compare November 18, 2024 12:07
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Alon-Ti)

@Alon-Ti Alon-Ti changed the base branch from alont/formal-expr-logup to graphite-base/888 November 18, 2024 16:45
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from 89c469c to aeac992 Compare November 18, 2024 16:45
@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.87%. Comparing base (96f7025) to head (1caa5eb).
Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
crates/prover/src/constraint_framework/expr.rs 97.72% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #888      +/-   ##
==========================================
+ Coverage   91.85%   91.87%   +0.01%     
==========================================
  Files          93       93              
  Lines       13053    13097      +44     
  Branches    13053    13097      +44     
==========================================
+ Hits        11990    12033      +43     
- Misses        948      949       +1     
  Partials      115      115              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@Alon-Ti Alon-Ti changed the base branch from graphite-base/888 to dev November 18, 2024 16:46
@Alon-Ti Alon-Ti force-pushed the alont/formal-expr-logup1 branch from aeac992 to e55c200 Compare November 18, 2024 16:46
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

Successfully merging this pull request may close these issues.

4 participants