-
Notifications
You must be signed in to change notification settings - Fork 122
Document grouped expressions and define system equivalence. #3376
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
c804bc3
dc298c2
92a4775
6de5343
7998161
9aefbdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -204,6 +204,63 @@ TODO Continue with the abstraction using Range Constraints. | |||||
| ## Combining Range Constraints | ||||||
|
|
||||||
|
|
||||||
| ## Grouped Expressions | ||||||
|
|
||||||
| The main data structure used for algebraic expressions the _Grouped Expression_. | ||||||
| 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). | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Now sure Algebraic Expressions were defined as a type?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| It even provides a normal form for affine Algebraic Constraints if multiplied by a factor such that | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why Algebraic Constraints in capital initials?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
| the constant term is zero or one. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can this become zero?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @chriseth
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: |
||||||
|
|
||||||
| This normal fom makes it easy to compare affine Algebraic Expressions for equality, | ||||||
chriseth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| 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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least you do not need to search for the variable. |
||||||
|
|
||||||
| Addition and subtraction of Grouped Expressions is implemented to remove linear terms that cancel each other out, | ||||||
chriseth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| and it performs some checks also in the quadratic terms, but this part is not complete for performance reasons. | ||||||
chriseth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ## Equivalence Notion | ||||||
|
|
||||||
| TODO define the property of a Constraint System the optimizer preserves | ||||||
|
|
||||||
| 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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
|
|
||||||
| As an example, consider the two systems | ||||||
|
|
||||||
| System A: | ||||||
| ``` | ||||||
| x = 8 | ||||||
| x + y + z = 12 | ||||||
| 2 1 [x, y, z] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||||||
| w * (w - 1) = 0 | ||||||
| ``` | ||||||
|
|
||||||
| System B: | ||||||
| ``` | ||||||
| y + z = 4 | ||||||
| 2 1 [8, y, z] | ||||||
| ``` | ||||||
|
|
||||||
| 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? | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently for openvm every stateful interaction has a receive and a send |
||||||
|
|
||||||
| Note that System B is obtained from System A by substituting `x = 8` and removing `w`. | ||||||
|
|
||||||
| All satisfying assignments of System A must have `x = 8` and either `w = 0` or `w = 1`. | ||||||
| Such an assignment also satisfies System B and it produces the same values for the stateful bus interaction. | ||||||
|
|
||||||
| The converse is a bit more complicated: Satisfying assignments of system B only assign the variables | ||||||
| `y` and `z`. So we need to extend the assignment for System A into a satisfying one. For `x`, the only | ||||||
| choice we have is `x = 8`, but there are two ways to extend the assignment with regards to `w` such that | ||||||
| it is still satisfying, `w = 0` or `w = 1`. Since both ways to extend the assignment | ||||||
| produce the same values in the stateful bus interaction, the systems are equivalent. | ||||||
|
|
||||||
| ## Optimization Steps | ||||||
|
|
||||||
| The called functions are | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.