quantstamp / halo2-analyzer

SMT 2023 Submission; license pending
52 stars 10 forks source link

Rust Rust Suggestions Take 2 #10

Open bragaigor opened 1 year ago

bragaigor commented 1 year ago
Now that I typed the above I'm not sure which one I prefer since the llvm compiler might just optimize either case :) 
- [x] This is more of a question then a suggestion. In the below function, do we intend on counting `RegionColumn::Selector`? I'm asking because in that case `used == false` but we call `continue` which skips the counting.
```rust
    pub fn analyze_unconstrained_cells(&mut self) -> Result<AnalyzerOutput> {
        let mut count = 0;
        for region in self.layouter.regions.iter() {
            let selectors = HashSet::from_iter(region.selectors().into_iter());

            for (reg_column, rotation) in region.columns.iter().cloned() {
                let mut used = false;

                match reg_column {
                    RegionColumn::Selector(_) => continue,
                    RegionColumn::Column(column) => {
                        for gate in self.cs.gates.iter() {
                            for poly in gate.polynomials() {
                                let advices = abstract_expr::extract_columns(poly);
                                let eval = abstract_expr::eval_abstract(poly, &selectors);

                                column.index(); // <<<<<<<<<<<<<<<<<<<<<

                                if eval != AbsResult::Zero && advices.contains(&(column, rotation))
                                {
                                    used = true;
                                }
                            }
                        }
                    }
                };

                if !used {
                    count += 1;
                    self.log.push(format!("unconstrained cell in \"{}\" region: {:?} (rotation: {:?}) -- very likely a bug.", region.name,  reg_column, rotation));
                }
            }
        }

also where I marked above with // <<<<<<<<< is not doing anything so I would delete that line

bragaigor commented 1 year ago

Installing CVC5

This are the steps to install CVC5 on MacOS (probably transferable to Linux). Instructions taken from: https://github.com/cvc5/cvc5/blob/main/INSTALL.rst

  1. Clone CVC5 from official repo
    git clone https://github.com/cvc5/cvc5

    You can also download the source code from https://github.com/cvc5/cvc5/releases/tag/cvc5-1.0.5 but using the repo is recommended.

  2. Install all dependencies and set proper ENV variables. See dependencies section below
  3. Run
    ./configure.sh —cocoa —auto-download
  4. The do:
    cd build
    make -j4
    make check
    sudo make install

Dependencies

jgorzny commented 1 year ago

We won't do CI/CD -- I don't anticipate a lot of active development