Commit Graph

7 Commits

Author SHA1 Message Date
Georg Wiese
a22065ee2d Refactor QuadraticSymbolicExpression (#2923)
This PR refactors `QuadraticSymbolicExpression`: I removed the reference
to
[`SymbolicExpression`](f60e9d9f69/constraint-solver/src/quadratic_symbolic_expression.rs (L70)).
It can represent values that are known at runtime, represented as an
expression. We don't need this in the context of APC: Variables are
either unknown or known at compile time, and therefore can be
represented as a `FieldElement` instead.

The idea is to introduce [this
trait](4989be08f3/constraint-solver/src/runtime_constant.rs (L11)),
which is implemented by `SymbolicExpression` and any `T: FieldElement`.
This way, we can continue to use the solver with
`QuadraticSymbolicExpression<SymbolicExpression<T, V>, V>` (equivalent
to the current `QuadraticSymbolicExpression<T, V>`) in the old JIT
pipeline and use the simpler `QuadraticSymbolicExpression<T, V>` in the
APC pipeline.

---------

Co-authored-by: chriseth <chriseth.github@gmail.com>
2025-06-30 15:47:12 +00:00
Georg Wiese
aa34cebc4b autoprecopiles: Never use ast expression (#2890)
This PR gets rid of the conversion between
`powdr_autoprecompiles::legacy_expression::AlgebraicExpression` and
`powdr_ast::analyzed::AlgebraicExpression`. It was only used in two
places to re-use functions from the `powdr_pilopt` crate:
- `quadratic_symbolic_expression_to_algebraic`: I copied & adjusted it
- `simplify_expression`: I implemented it as
`quadratic_symbolic_expression_to_algebraic(&algebraic_to_quadratic_symbolic_expression(&e))`,
which I'm sure is not exactly the same, but seems to work

As a result, the `autoprecompiles` crate no longer depends on `ast`,
`pil-analyzer`, and `pilopt`.
2025-06-13 22:20:31 +00:00
Georg Wiese
0e04662254 New expression type (#2831)
This PR adds a new `powdr_expression` crate, containing a simplified
version of `powdr_ast::analyzed::AlgebraicExpression`. The idea here is
that this decouples our Autoprecompiles code from the PowdrVM & PIL
codebase. This will allow us to gradually change the expression type
according to our needs. See #2832 and #2833 as work-in-progress
examples.

Differences to previous `AlgebraicExpression`:
- Generic over the reference type (but
`powdr_autoprecompiles::legacy_expression` adds `AlgebraicReference` and
defines `type AlgebraicExpression<T> = ActualAlgebraicExpression<T,
AlgebraicReference>`, for now)
- Removed `AlgebraicExpression::{PublicReference,Challenge}` variants
- Removed `AlgebraicBinaryOperator::Pow` variant
- `degree_with_cache()` -> `degree()`, as we don't have intermediate
polynomials anymore

I included a `powdr_ast::analyzed::AlgebraicExpression <-->
powdr_autoprecompiles::legacy_expression::AlgebraicExpression`
conversion, which is only used to interact with the `powdr_pilopt`
crate, which still is used by the APC codebase and the PowdrVM / PIL
codebase.
2025-06-06 12:59:15 +00:00
chriseth
2638c5226c Remove parser dependency. (#2745) 2025-05-21 08:59:41 +00:00
Georg Wiese
550c12b091 Remove opcode heuristic (#2699)
With backtracking, it should be able to solve for the opcode flags
covered by this heuristic.

This PR does not need any adjustments to `powdr-openvm`, but I opened a
PR using this branch to show that CI passes:
https://github.com/powdr-labs/powdr-openvm/pull/122
2025-05-15 10:17:05 +00:00
chriseth
6f2878b623 Fix bench. (#2694) 2025-05-07 10:49:01 +00:00
chriseth
fa5566891a Autoprecompiles clean v1 (#2686)
Co-authored-by: Leo Alt <leo@powdrlabs.com>
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-05-07 07:35:02 +00:00