jellyfish icon indicating copy to clipboard operation
jellyfish copied to clipboard

[Constraint] Introduce ConstraintSystemReference idea for friendly API

Open alxiong opened this issue 2 years ago • 0 comments

From @zhenfeizhang in https://github.com/EspressoSystems/jellyfish/pull/94#issuecomment-1209379869

In general I want to advocate my "circuit ref" idea. For example

struct BoolVar<'a> {
  index: Variable,
  cs: &'a ConstraintSystem
}

On top of overloading operators here are some additional thoughts:

  • to access the variable, we should use an API get_index(&self)->Variable -- i think it is a bit cleaner than into()
    • it makes more sense to me to implement Into/From for Vec<BoolVar> and Variable, in both directions, which are binary (de)composition
  • to create new variables we should use associated function BoolVar::new(cs: &ConstraintSystem, value: bool) rather than Circuit::create_bool_variable(...) and so on...
  • to check variable bound we can simply call bool_var.check_bound(), and we do not need to pass parameters
  • [ ] add CSRef for BoolVar
  • [ ] add CSRef for PointVar
  • [ ] add CSRef for Variable

alxiong avatar Aug 09 '22 15:08 alxiong