clean up tuple stuff in R1CS

This commit is contained in:
Alex Ozdemir
2021-05-22 00:40:09 -07:00
parent 737056b686
commit 0955b5cb62

View File

@@ -25,6 +25,7 @@ enum EmbeddedTerm {
Bv(Rc<RefCell<BvEntry>>),
Bool(Lc),
Field(Lc),
#[allow(dead_code)]
Tuple(Vec<EmbeddedTerm>),
}
@@ -283,58 +284,16 @@ impl ToR1cs {
}
}
#[allow(unreachable_code)]
#[allow(unused_variables)]
fn embed_tuple(&mut self, a: Term) {
panic!("Tuple: {}", a);
// if !self.cache.contains_key(&a) {
// for t in &a.cs {
// self.embed(t.clone());
// }
// let t = match &a.op {
// Op::Tuple => {
// let subembeddings =
// a.cs.iter()
// .map(|child| self.cache.get(child).unwrap().clone())
// .collect();
// EmbeddedTerm::Tuple(subembeddings)
// }
// Op::Const(Value::Tuple(consts)) => {
// let subembeddings = consts
// .iter()
// .map(|child| {
// // a bit of recursion
// let subconst = leaf_term(Op::Const(child.clone()));
// self.embed(subconst.clone());
// self.cache.get(&subconst).unwrap().clone()
// })
// .collect();
// EmbeddedTerm::Tuple(subembeddings)
// }
// Op::Var(name, Sort::Tuple(sorts)) => {
// let subembeddings = sorts
// .iter()
// .enumerate()
// .map(|(i, s)| {
// let var = format!("{}.{}", name, i);
// if let Some(vs) = self.values.as_ref() {
// let v = vs
// .get(name)
// .unwrap_or_else(|| panic!("No value for {}", name))
// .as_tuple()[i]
// .clone();
// // safe b/c if-let.
// self.values.as_mut().unwrap().insert(var.clone(), v);
// }
// let subvar = leaf_term(Op::Var(var, s.clone()));
// self.embed(subvar.clone());
// self.cache.get(&subvar).unwrap().clone()
// })
// .collect();
// EmbeddedTerm::Tuple(subembeddings)
// }
// _ => panic!("Cannot embed tuple term: {}", a),
// };
// self.cache.insert(a, t);
// }
if !self.cache.contains_key(&a) {
let t = match &a.op {
// May want to support cunstor operators here...
_ => panic!("Cannot embed tuple term: {}", a),
};
self.cache.insert(a, t);
}
}
fn get_field(&self, tuple_term: &Term, field: usize) -> EmbeddedTerm {