Skip to content

Conversation

@chriseth
Copy link
Member

@chriseth chriseth commented Oct 21, 2025

Documents grouped expressions and defines the notion of equivalence we are preserving with the optimizer.

Note that our memory optimization uses a less strict version of equivalence that still needs to be defined.

A Grouped Expression consists of a constant term, a list of linear terms (a list of pairs of a non-zero coefficient
and a variable) and a list of quadratic terms (a list of pairs of Grouped Expressions).

For affine Algebraic Expressions, the Grouped Expression provides a normal form (if sorted by variable).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
For affine Algebraic Expressions, the Grouped Expression provides a normal form (if sorted by variable).
For affine algebraic expressions, the Grouped Expression provides a normal form (if sorted by variable).

Now sure Algebraic Expressions were defined as a type?

Copy link
Member Author

Choose a reason for hiding this comment

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

and a variable) and a list of quadratic terms (a list of pairs of Grouped Expressions).

For affine Algebraic Expressions, the Grouped Expression provides a normal form (if sorted by variable).
It even provides a normal form for affine Algebraic Constraints if multiplied by a factor such that
Copy link
Member

Choose a reason for hiding this comment

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

Why Algebraic Constraints in capital initials?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm writing all properly defined concepts in capitals, and in italics (using _..._) at the place where they are defined.

This normal fom makes it easy to compare affine Algebraic Expressions for equality,
check if they have a constant difference, etc.

If a map data structure is used for the linear terms, substitution of variables is also quick.
Copy link
Member

Choose a reason for hiding this comment

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

Why

Copy link
Member Author

Choose a reason for hiding this comment

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

At least you do not need to search for the variable.


We call two Constraint Systems _equivalent_ if every satisfying assignment for one system
can be extended to a satisfying assignment for the other system and every such extension
leads to the same payloads and multiplicities for all _stateful_ bus interactions in both systems.
Copy link
Member

Choose a reason for hiding this comment

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

And every non-satisfying assignment of the first system must also not satisfy the second

Copy link
Member Author

Choose a reason for hiding this comment

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

I meant "if for both of the two systems, every satisfying assignment can be extended to a satisfying system for the other", so it's symmetric. Is that the misunderstanding? If not:

Written like this, we could have a non-satisfying assignment for one system that is non-satisfying since it assigns an invalid value to a variable that does not occur in the other system, then that assignment could still be satisfying for the other system.

But even in the case we have the same variables, I think what you mean is already included:
Suppose we have an assignment A that does not satisfy system 1 but it does satisfy system 2. Then because of equivalence, it must be extensible to a satisfying assignment for system 1, which is a contradiction since the variables are the same but A does not satisfy system 1.

Copy link
Member

Choose a reason for hiding this comment

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

Right yea, I missed the "one system or the other" being generic, I think it's fine as is

```
x = 8
x + y + z = 12
2 1 [x, y, z]
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is a bus interaction, maybe write as a tuple to look more organized?


Let us assume that the bus with ID 2 is stateful and allows all combinations of values between 0 and 100 (inclusive).
Note that the variables `y` and `z` are not uniquely determined in either system, so the stateful bus
acts both as input and output for the system. TODO can that be or do we need one send and one receive?
Copy link
Member

Choose a reason for hiding this comment

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

Currently for openvm every stateful interaction has a receive and a send


For affine Algebraic Expressions, the Grouped Expression provides a normal form (if sorted by variable).
It even provides a normal form for affine Algebraic Constraints if multiplied by a factor such that
the constant term is zero or one.
Copy link
Collaborator

Choose a reason for hiding this comment

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

How can this become zero?
It sounds like there would have to be some factor such that (const * factor) mod P = 0, which would mean that either const or factor is zero.

Copy link
Member

Choose a reason for hiding this comment

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

ping @chriseth

Copy link
Member Author

@chriseth chriseth Nov 3, 2025

Choose a reason for hiding this comment

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

Ah this is actually more complicated than I thought and also written in a bad way. What about the following:

It even provides a normal form for affine Algebraic Constraints if we require 
the coefficient of the first variable (according to some fixed order on the 
variables) to be one. Note that an Algebraic Constraint can be multiplied 
by a nonzero factor without changing the semantics.

@leonardoalt
Copy link
Member

Needs a main merge

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