Open Brechtpd opened 1 year ago
Hi, I've finished a demo, whitch can do bool!((a && !b) || c)
-> Or[And([a, Not(b)]), c])
. And it's tested.
You can see more https://github.com/privacy-scaling-explorations/zkevm-circuits/commit/3d78844d6dc3cd8c38908e82c65ebddd64c16f57
bool!((selectorA && !selectorB) || selectorC)
->or::expr([and::expr([selectorA.expr(), not::expr(selectorB.expr())]), selectorC.expr()])
And I've finished most for the above version. The last step is its test, which blocks me.
Do you have any suggestions?
See more one https://github.com/privacy-scaling-explorations/zkevm-circuits/commit/0f7ed0e770e11bd1274e1eeeb9f5f7577c6ff44a
I totally missed this, very sorry about that!
This looks great, will try it out when I have some time. Thanks!
~~@ChengYueJia could you give us a PR regarding these changes? The code seems fine, but the naming could use some improvement. Additionally, I am available to assist with completing the testing phase if needed.~~
If our bool expression is complex enough, exhaustive enumeration is not a good solution. Here I recommend using Rust function-like procedural macros to build syntax trees and ultimately execute complex bool expressions.
#[proc_macro]
pub fn r#bool(item: TokenStream) -> TokenStream {
// parse tokens to AST tree and generate the halo2 expression based it
}
Boolean logic macro:
-> generate: