update claude settings and wip DAG with SlotMap

This commit is contained in:
2026-04-22 11:45:35 +02:00
parent 345bc0f126
commit 5ef4893f03
10 changed files with 155 additions and 0 deletions

26
examples/dag.rs Normal file
View File

@@ -0,0 +1,26 @@
use std::cell::RefCell;
use std::rc::Rc;
use circuit_cas::circuit::dag::{Circuit, CircuitExt};
use circuit_cas::var;
fn main() {
let circuit = Rc::new(RefCell::new(Circuit::new()));
// Build (x + y) * (x + z)
let x = circuit.leaf(var!("x"));
let y = circuit.leaf(var!("y"));
let z = circuit.leaf(var!("z"));
let x_plus_y = circuit.leaf(var!("x")) + y;
let x_plus_z = circuit.leaf(var!("x")) + z;
let expr = x_plus_y * x_plus_z;
// Deduplication: both x leaves share the same NodeId
let x2 = circuit.leaf(var!("x"));
assert_eq!(x.id, x2.id);
println!("(x + y) * (x + z) root node id: {:?}", expr.id);
println!("x node id: {:?}", x.id);
println!("x deduplicated node id: {:?}", x2.id);
}

28
examples/flat.rs Normal file
View File

@@ -0,0 +1,28 @@
use circuit_cas::poly::flat;
use circuit_cas::var;
fn main() {
let poly = (2
* ((var!("x", 1, 5) ^ 5) * (var!("x", 1, 2) ^ 5) * (var!("x", 2, 5) ^ 1)))
+ (3 * ((var!("x", 1, 9) ^ 5) * (var!("x", 1, 2) ^ 5) * (var!("x", 2, 5) ^ 1)));
let x = var!("x");
let y = var!("x\u{0304}");
let z = var!("z");
let other = -3 * ((&x ^ 2) * (&y ^ 4));
let mono = (&x^2)*(&y^4);
let inside = (&x^2)*(&y^2)*(&z^1);
if mono.contains(&inside){
println!("{inside}\u{2286}{mono}");
}else{
println!("{inside}\u{2284}{mono}");
}
println!("{poly}");
let z = poly - other;
println!("{z}");
}