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

Open
wants to merge 1 commit into
base: alont/formal-expr-logup
Choose a base branch
from

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

Copy link
Contributor Author

Alon-Ti commented Nov 14, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

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: 78e9027 Previous: f6214d1 Ratio
merkle throughput/simd merkle 30829455 ns/iter (± 455168) 14690867 ns/iter (± 434150) 2.10

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

CC: @shaharsamocha7

@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.

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.

3 participants