improve var creation for SumProdCircuit

This commit is contained in:
2026-04-28 17:29:11 +02:00
parent 0c4bddf3b0
commit 5caccbaf50
6 changed files with 12 additions and 11 deletions

View File

@@ -6,10 +6,10 @@ use circuit_cas::circuit::dag::CircuitExt;
fn main() {
let circuit: Rc<RefCell<ProbCircuit>> = ProbCircuit::new();
// Build (x + y) * (x + z)
let x = circuit.var("x");
let y = circuit.var("y");
let z = circuit.var("z");
// vars accept anything that implements Into<StaticVar>: &'static str, (&str, u32), (&str, u32, u32)
let x = circuit.var("x");
let y = circuit.var(("y", 1)); // indexed variable y_1
let z = circuit.var(("z", 0, 1)); // doubly-indexed variable z_{0,1}
let x_plus_y = circuit.var("x") + y;
let x_plus_z = circuit.var("x") + z;
@@ -19,7 +19,7 @@ fn main() {
let x2 = circuit.var("x");
assert_eq!(x.id, x2.id);
println!("(x + y) * (x + z) root node id: {:?}", expr.id);
println!("(x + y_1) * (x + z_{{0,1}}) root node id: {:?}", expr.id);
println!("x node id: {:?}", x.id);
println!("x deduplicated node id: {:?}", x2.id);
}