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

Duplicate Binarity Constraints #185

Open
DavePearce opened this issue Jun 10, 2024 · 2 comments
Open

Duplicate Binarity Constraints #185

DavePearce opened this issue Jun 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@DavePearce
Copy link
Collaborator

(see #183)

This is an inefficiency, but I have labelled it as a bug here as it really should be fixed. Consider:

(module test)
(defcolumns (P :binary@prove))
(defperspective p1 P ((A :binary@prove)))
(defperspective p2 P ((B :binary)))

Here, a single binary constraint is given for the underlying column:

test.B-binarity :=
col#3 * (1 - col#3)

Now consider this:

(module test)
(defcolumns (P :binary@prove))
(defperspective p1 P ((A :binary@prove)))
(defperspective p2 P ((B :binary@prove)))

In this case, we get two binarity constraints:

test.A-binarity :=
col#2 * (1 - col#2)

test.B-binarity :=
col#3 * (1 - col#3)

Which we can see in the final define.go are really generated:

test__A_xor_B := build.RegisterCommit("test.A_xor_B", build.Settings.Traces.Test)
test__A_xor_B := build.RegisterCommit("test.A_xor_B", build.Settings.Traces.Test)
test__P1 := build.RegisterCommit("test.P1", build.Settings.Traces.Test)
test__P2 := build.RegisterCommit("test.P2", build.Settings.Traces.Test)

//
// Constraints
//
build.GlobalConstraint("test.A-binarity", test__A_xor_B.AsVariable().Mul(symbolic.NewConstant("1").Sub(test__A_xor_B.AsVariable())))
build.GlobalConstraint("test.B-binarity", test__A_xor_B.AsVariable().Mul(symbolic.NewConstant("1").Sub(test__A_xor_B.AsVariable())))
build.GlobalConstraint("test.P1-binarity", test__P1.AsVariable().Mul(symbolic.NewConstant("1").Sub(test__P1.AsVariable())))
build.GlobalConstraint("test.P2-binarity", test__P2.AsVariable().Mul(symbolic.NewConstant("1").Sub(test__P2.AsVariable())))
build.GlobalConstraint("test.c1", test__P1.AsVariable().Mul(test__A_xor_B.AsVariable().Sub(symbolic.NewConstant("10"))))
@DavePearce DavePearce added the bug Something isn't working label Jun 10, 2024
@DavePearce DavePearce changed the title Duplicate Typing Constraints Duplicate Binarity Constraints Jun 10, 2024
@delehef
Copy link
Contributor

delehef commented Jun 10, 2024

Probably the same as #186

@DavePearce
Copy link
Collaborator Author

Hmmm, this is actually quite tricky to implement correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants