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

Simplify expressions. #894

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Simplify expressions. #894

wants to merge 1 commit into from

Conversation

Alon-Ti
Copy link
Contributor

@Alon-Ti Alon-Ti commented Nov 19, 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 19, 2024 11:49
@Alon-Ti Alon-Ti force-pushed the alont/formal-logup-sums-variables branch from 22d6538 to 86f314a Compare November 19, 2024 11:51
@Alon-Ti Alon-Ti force-pushed the alont/formal-logup-sums-variables branch from 86f314a to 1ed3739 Compare November 19, 2024 11:58
@Alon-Ti Alon-Ti force-pushed the alont/formal-logup-sums-variables branch from 1ed3739 to 92a18c4 Compare November 19, 2024 12:55
@Alon-Ti Alon-Ti force-pushed the alont/formal-logup-sums-variables branch from 92a18c4 to 91ce7f8 Compare November 19, 2024 13:01
@Alon-Ti Alon-Ti force-pushed the alont/formal-logup-sums-variables branch from 91ce7f8 to c45d810 Compare November 19, 2024 13:06
@Alon-Ti Alon-Ti force-pushed the alont/formal-logup-sums-variables branch from c45d810 to e88e970 Compare November 19, 2024 13:09
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: 188ba5c Previous: cd8b37b Ratio
iffts/simd ifft/22 12710376 ns/iter (± 141611) 6306399 ns/iter (± 210024) 2.02
merkle throughput/simd merkle 30188735 ns/iter (± 734672) 13712527 ns/iter (± 579195) 2.20

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

CC: @shaharsamocha7

@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 19 lines in your changes missing coverage. Please review.

Project coverage is 91.64%. Comparing base (0b14862) to head (1d9f08c).

Files with missing lines Patch % Lines
crates/prover/src/constraint_framework/expr.rs 75.00% 16 Missing and 3 partials ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           alont/formal-logup-sums-variables     #894      +/-   ##
=====================================================================
- Coverage                              91.92%   91.64%   -0.28%     
=====================================================================
  Files                                     93       93              
  Lines                                  13721    13291     -430     
  Branches                               13721    13291     -430     
=====================================================================
- Hits                                   12613    12181     -432     
+ Misses                                   999      990       -9     
- Partials                                 109      120      +11     

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


🚨 Try these New Features:

Copy link
Collaborator

@ohad-starkware ohad-starkware 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 2 files reviewed, 2 unresolved discussions (waiting on @Alon-Ti and @shaharsamocha7)


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

            }
        }
        Expr::Mul(a, b) => {

are you covering 1 * 1 => const(1)?


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

            let b = simplify(*b);
            if let (Expr::Const(a), Expr::Const(b)) = (a.clone(), b.clone()) {
                Expr::Const(a - b)

Suggestion:

a * b

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 2 files reviewed, 2 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)


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

Previously, ohad-starkware (Ohad) wrote…

are you covering 1 * 1 => const(1)?

I think so, it would be caught in the first if let, no?


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

            let b = simplify(*b);
            if let (Expr::Const(a), Expr::Const(b)) = (a.clone(), b.clone()) {
                Expr::Const(a - b)

Done.

Copy link
Collaborator

@ohad-starkware ohad-starkware 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 2 files reviewed, all discussions resolved (waiting on @shaharsamocha7)


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

Previously, Alon-Ti wrote…

I think so, it would be caught in the first if let, no?

right


crates/prover/src/constraint_framework/expr.rs line 356 at r2 (raw file):

            .temp_vars
            .iter()
            .map(|(name, expr)| format!("let {} = {};", name, simplify(expr.clone()).format_expr()))

can you find a way to reduce the syntax?
maybe expr.simplify_and_format()
non blocking

Code quote:

 simplify(expr.clone()).format_expr()))

Copy link
Collaborator

@ohad-starkware ohad-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @shaharsamocha7)

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.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @Alon-Ti and @ohad-starkware)


crates/prover/src/examples/state_machine/mod.rs line 321 at r2 (raw file):

            - (0)) \
            * ((temp_0) * (temp_1)) \
            - ((temp_1) * (1) + (temp_0) * (-(1)));"

I thought it should change to that

Suggestion:

- (temp_1 - temp_0);"

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 2 files reviewed, 1 unresolved discussion (waiting on @ohad-starkware and @shaharsamocha7)


crates/prover/src/examples/state_machine/mod.rs line 321 at r2 (raw file):

Previously, shaharsamocha7 wrote…

I thought it should change to that

Nice catch!

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 1 of 2 files at r5, all commit messages.
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on @ohad-starkware)

@Alon-Ti Alon-Ti changed the base branch from alont/formal-logup-sums-variables to graphite-base/894 November 26, 2024 08:27
@Alon-Ti Alon-Ti changed the base branch from graphite-base/894 to dev November 26, 2024 08:28
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 1 of 2 files at r5.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Alon-Ti)


crates/prover/src/constraint_framework/expr.rs line 196 at r5 (raw file):

}

pub fn simplify(expr: Expr) -> Expr {

I think this function should have more tests

Code quote:

pub fn simplify(expr: Expr) -> Expr {

crates/prover/src/constraint_framework/expr.rs line 217 at r5 (raw file):

            } else {
                a + b
            }

I think match statement is more readable
Consider to change

Code quote:

            if let (Expr::Const(a), Expr::Const(b)) = (a.clone(), b.clone()) {
                Expr::Const(a + b)
            } else if a == Expr::zero() {
                b
            } else if b == Expr::zero() {
                a
            } else if let Expr::Neg(a) = a {
                if let Expr::Neg(b) = b {
                    -(*a + *b)
                } else {
                    b - *a
                }
            } else if let Expr::Neg(b) = b {
                a - *b
            } else {
                a + b
            }

crates/prover/src/constraint_framework/expr.rs line 264 at r5 (raw file):

            let a = simplify(*a);
            match a {
                Expr::Neg(b) => *b,

Is this Neg(Neg(a))? can you comment on that?

Code quote:

Expr::Neg(b) => *b,

crates/prover/src/constraint_framework/expr.rs line 264 at r5 (raw file):

            let a = simplify(*a);
            match a {
                Expr::Neg(b) => *b,

What happens if a is a secure column?

Code quote:

            match a {
                Expr::Neg(b) => *b,

crates/prover/src/constraint_framework/expr.rs line 267 at r5 (raw file):

                Expr::Const(c) => Expr::Const(-c),
                Expr::Sub(a, b) => Expr::Sub(b, a),
                _ => -a,

I'm a bit worried of this
Will it always be correct?

Code quote:

_ => -a,

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.

5 participants