mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
Make some use of poly ids.
This commit is contained in:
@@ -333,7 +333,7 @@ where
|
||||
fn process_polynomial_identity(&self, identity: &Expression) -> EvalResult {
|
||||
// If there is no "next" reference in the expression,
|
||||
// we just evaluate it directly on the "next" row.
|
||||
let row = if contains_next_witness_ref(identity, self.fixed_data) {
|
||||
let row = if contains_next_witness_ref(identity) {
|
||||
// TODO this is the only situation where we use "current"
|
||||
// TODO this is the only that actually uses a window.
|
||||
EvaluationRow::Current
|
||||
|
||||
@@ -178,10 +178,7 @@ impl FixedLookup {
|
||||
// This is a matching machine if it is a plookup and the RHS is fully constant.
|
||||
if kind != IdentityKind::Plookup
|
||||
|| right.selector.is_some()
|
||||
|| right
|
||||
.expressions
|
||||
.iter()
|
||||
.any(|e| contains_witness_ref(e, fixed_data))
|
||||
|| right.expressions.iter().any(contains_witness_ref)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use pil_analyzer::{util::expr_any, Expression, PolynomialReference};
|
||||
|
||||
use super::FixedData;
|
||||
|
||||
pub trait WitnessColumnNamer {
|
||||
fn name(&self, i: usize) -> String;
|
||||
}
|
||||
@@ -16,21 +14,17 @@ pub fn contains_next_ref(expr: &Expression) -> bool {
|
||||
}
|
||||
|
||||
/// @returns true if the expression contains a reference to a next value of a witness column.
|
||||
pub fn contains_next_witness_ref(expr: &Expression, fixed_data: &FixedData) -> bool {
|
||||
pub fn contains_next_witness_ref(expr: &Expression) -> bool {
|
||||
expr_any(expr, |e| match e {
|
||||
Expression::PolynomialReference(poly) => {
|
||||
poly.next && fixed_data.witness_ids.contains_key(poly.name.as_str())
|
||||
}
|
||||
Expression::PolynomialReference(poly) => poly.next && poly.is_witness(),
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
/// @returns true if the expression contains a reference to a witness column.
|
||||
pub fn contains_witness_ref(expr: &Expression, fixed_data: &FixedData) -> bool {
|
||||
pub fn contains_witness_ref(expr: &Expression) -> bool {
|
||||
expr_any(expr, |e| match e {
|
||||
Expression::PolynomialReference(poly) => {
|
||||
fixed_data.witness_ids.contains_key(poly.name.as_str())
|
||||
}
|
||||
Expression::PolynomialReference(poly) => poly.is_witness(),
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -197,6 +197,21 @@ pub struct PolynomialReference {
|
||||
pub next: bool,
|
||||
}
|
||||
|
||||
impl PolynomialReference {
|
||||
#[inline]
|
||||
pub fn poly_id(&self) -> u64 {
|
||||
self.poly_id.unwrap().0
|
||||
}
|
||||
#[inline]
|
||||
pub fn is_witness(&self) -> bool {
|
||||
self.poly_id.unwrap().1 == PolynomialType::Committed
|
||||
}
|
||||
#[inline]
|
||||
pub fn is_fixed(&self) -> bool {
|
||||
self.poly_id.unwrap().1 == PolynomialType::Constant
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for PolynomialReference {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
// TODO for efficiency reasons, we should avoid the unwrap check here somehow.
|
||||
|
||||
Reference in New Issue
Block a user