mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-01-08 04:53:59 -05:00
Remove unused functions. (#3293)
This commit is contained in:
@@ -142,7 +142,7 @@ pub fn optimize_exec_bus<T: FieldElement>(
|
||||
.iter()
|
||||
.map(|arg| {
|
||||
let mut arg = arg.clone();
|
||||
powdr::substitute_algebraic_algebraic(&mut arg, &subs);
|
||||
powdr::substitute_subexpressions(&mut arg, &subs);
|
||||
simplify_expression(arg)
|
||||
})
|
||||
.collect();
|
||||
@@ -170,14 +170,14 @@ pub fn optimize_exec_bus<T: FieldElement>(
|
||||
machine.bus_interactions.push(latest_send.unwrap());
|
||||
|
||||
for c in &mut machine.constraints {
|
||||
powdr::substitute_algebraic_algebraic(&mut c.expr, &subs);
|
||||
powdr::substitute_subexpressions(&mut c.expr, &subs);
|
||||
c.expr = simplify_expression(c.expr.clone());
|
||||
}
|
||||
for b in &mut machine.bus_interactions {
|
||||
powdr::substitute_algebraic_algebraic(&mut b.mult, &subs);
|
||||
powdr::substitute_subexpressions(&mut b.mult, &subs);
|
||||
b.mult = simplify_expression(b.mult.clone());
|
||||
for a in &mut b.args {
|
||||
powdr::substitute_algebraic_algebraic(a, &subs);
|
||||
powdr::substitute_subexpressions(a, &subs);
|
||||
*a = simplify_expression(a.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use itertools::Itertools;
|
||||
@@ -8,20 +8,6 @@ use powdr_number::FieldElement;
|
||||
use crate::expression::{AlgebraicExpression, AlgebraicReference};
|
||||
use crate::SymbolicMachine;
|
||||
|
||||
// After powdr and lib are adjusted, this function can be renamed and the old substitute removed
|
||||
pub fn substitute_algebraic<T: Clone>(
|
||||
expr: &mut AlgebraicExpression<T>,
|
||||
sub: &BTreeMap<AlgebraicReference, AlgebraicExpression<T>>,
|
||||
) {
|
||||
expr.pre_visit_expressions_mut(&mut |expr| {
|
||||
if let AlgebraicExpression::Reference(r) = expr {
|
||||
if let Some(sub_expr) = sub.get(r) {
|
||||
*expr = sub_expr.clone();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn make_refs_zero<T: FieldElement>(expr: &mut AlgebraicExpression<T>) {
|
||||
let zero = AlgebraicExpression::Number(T::zero());
|
||||
expr.pre_visit_expressions_mut(&mut |expr| {
|
||||
@@ -36,18 +22,7 @@ pub fn make_bool<T: FieldElement>(expr: AlgebraicExpression<T>) -> AlgebraicExpr
|
||||
expr.clone() * (expr - one)
|
||||
}
|
||||
|
||||
pub fn has_ref<T: Clone + std::cmp::PartialEq>(
|
||||
expr: &AlgebraicExpression<T>,
|
||||
r: &AlgebraicExpression<T>,
|
||||
) -> bool {
|
||||
expr.all_children().any(|expr| expr == r)
|
||||
}
|
||||
|
||||
pub fn is_ref<T: Clone>(expr: &AlgebraicExpression<T>) -> bool {
|
||||
matches!(expr, AlgebraicExpression::Reference(_))
|
||||
}
|
||||
|
||||
pub fn substitute_algebraic_algebraic<T: Clone + std::cmp::Ord>(
|
||||
pub fn substitute_subexpressions<T: Clone + std::cmp::Ord>(
|
||||
expr: &mut AlgebraicExpression<T>,
|
||||
sub: &BTreeMap<AlgebraicExpression<T>, AlgebraicExpression<T>>,
|
||||
) {
|
||||
@@ -58,21 +33,6 @@ pub fn substitute_algebraic_algebraic<T: Clone + std::cmp::Ord>(
|
||||
});
|
||||
}
|
||||
|
||||
// After powdr and lib are adjusted, this function can be renamed and the old collect_cols removed
|
||||
pub fn collect_cols_algebraic<T: Clone + Ord>(
|
||||
expr: &AlgebraicExpression<T>,
|
||||
) -> BTreeSet<AlgebraicExpression<T>> {
|
||||
expr.all_children()
|
||||
.filter_map(|expr| {
|
||||
if let AlgebraicExpression::Reference(..) = expr {
|
||||
Some(expr.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub trait UniqueReferences<'a, T: 'a> {
|
||||
/// Returns an iterator over the unique references
|
||||
fn unique_references(&'a self) -> impl Iterator<Item = AlgebraicReference>;
|
||||
|
||||
Reference in New Issue
Block a user