624 Commits

Author SHA1 Message Date
chriseth
f4c99197f9 Introduce range constraint size. (#3177)
Introduce the concept of `size` for range constraint. It provides an
upper bound for the number of values in the rang econstraint and can be
different from the range width.
2025-08-18 07:07:05 +00:00
chriseth
8d11daa952 Rename effect. (#3029) 2025-07-10 08:13:34 +00:00
chriseth
3281eb57ac Rename / remove QuadraticSymbolicExpression. (#3028) 2025-07-10 07:50:52 +00:00
chriseth
d833216549 Rename quadratic symbolic expression. (#2968)
Renames QuadraticSymbolicExpression to GroupedExpression. The advantage
of doing it his way is also that we can slowly change what is called
`QuadraticSymbolicExpression` afer this PR, namely the one with
SymbolicExpression as RuntimeConstant to GroupedExpression and easily
see which on is generic already and which is not.
2025-07-02 13:03:54 +00:00
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
340b532619 FieldElement: Require MulAssign (#2924)
Pulled out of #2923
2025-06-20 11:38:37 +00:00
chriseth
779692d5ad Variable type transform. (#2750) 2025-05-21 16:13:46 +00:00
chriseth
044de121ff Prover functions for small arith. (#2608)
Tests working for "small":
- memory
- add_sub
- rotate
- shift
- memory
- arith256

Not working:
- keccak
- poseidon
- poseidon2

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-05-19 12:40:55 +00:00
Thibaut Schaeffer
2d6708bbc5 Add openvm crates (#2714)
Based on commit 1dbe4db
- Split into two crates, lib and cli
- upgrade stwo, marked one stwo test `should_panic` @ShuangWu121 
- various clippy and fmt fixes linked to the rust version update
- bring all rust versions to 2025-05-14. CI still installs other
versions for openvm which uses them internally. The stable rust version
we test on is bumped to 1.85
- remove `examples` and related tests, which test the powdr crate on the
previous version of powdr (since it uses another nightly). Happy to
discuss this if it's important @leonardoalt
2025-05-16 14:30:09 +00:00
chriseth
839a0a8dce Implement substitutions. (#2667)
Replace the mechanism of "variable update" by "substitutions". This has
the benefit that we can substitute a variable also by a more complex
value.

The next step (not this PR) would be to also allow substitution by QSEs,
which we will need if we want to apply equivalences.
2025-04-28 12:26:25 +00:00
chriseth
4366ed9d7f Solve some quadratic constraints (#2659)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-04-24 15:07:40 +00:00
chriseth
06b749bd9f Remove ast dependency. (#2660)
Removes the dependency of the constraint solver on the PIL ast
2025-04-23 14:03:56 +00:00
chriseth
8a925cf204 Move constraint analysis (#2642) 2025-04-22 14:44:50 +00:00
Georg Wiese
322e9b7bed Make reference_to_quadratic_symbolic_expression private (#2658)
My suggestion RE [this
comment](https://github.com/powdr-labs/powdr/pull/2627#discussion_r2041923644).
Needs to be rebased after #2627 is merged.

---------

Co-authored-by: chriseth <chriseth.github@gmail.com>
Co-authored-by: chriseth <chris@ethereum.org>
2025-04-22 12:30:05 +00:00
chriseth
d54ff869b5 Quadratic symbolic expressions. (#2627) 2025-04-22 10:47:53 +00:00
chriseth
f41d979c3a Combine symbol list (#2646) 2025-04-22 08:45:40 +00:00
chriseth
1d2464ff1f Quadratic symbolic expression only (#2647) 2025-04-16 11:10:33 +00:00
chriseth
0477bf491a Use expression for branch condition. (#2638) 2025-04-11 15:13:28 +00:00
chriseth
c1122e08ac Create concrete symbolic expression for concrete. (#2645) 2025-04-10 17:21:09 +00:00
chriseth
edaad20fd5 Implement sub on symbolic expression. (#2639) 2025-04-10 16:52:18 +00:00
chriseth
9cb90b3fcf Force jit for block machines on goldilocks (#2624)
Re-opened version of accidentally merged #2592

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-04-08 08:41:58 +00:00
chriseth
7491bd11e6 Fix debug print for intermediates. (#2623) 2025-04-03 08:21:30 +00:00
chriseth
5fcd9aece1 Modernize 16 bit memory. (#2621) 2025-04-02 15:48:47 +00:00
chriseth
45b3aa0ac7 Enable JIT for permutations (#2593)
Enable support for permutation constraints. The main problem with
permutation constraints is that they need a way to disable constraints
and thus this PR adds a feature to guess values for variables that have
not been assigned yet but are also not relevant in any of the
identities, for example because they are multiplied by a value that is
known to be zero.

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-04-02 15:34:44 +00:00
chriseth
28307fba85 Use regular queue for identity queue. (#2588)
This avoids cloning QueueItems and processes the items in a queue
instead of always looking at the "smallest" activated item first.

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-03-31 17:49:03 +00:00
chriseth
a991eeb8ca Perform bit decomposition as assignment if offset is known. (#2612)
If we detect a bit decomposition pattern like `X + Y * 256 + Z * 65536 =
T`, the witgen inference returns a bit decomposition effect. But if the
value of `T` is a known number, we can actually extract the concrete
values for `X`, `Y` and `Z` at compile-time and continue solving with
this additional information.
2025-03-31 13:59:30 +00:00
chriseth
e451be1539 Do now follow intermediate columns. (#2599)
Fixes https://github.com/powdr-labs/powdr/issues/2597
2025-03-28 15:30:09 +00:00
chriseth
46c8d922a4 Fix column by name. (#2602) 2025-03-28 13:27:18 +00:00
chriseth
4dbbadf40e Add sub test. (#2577)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-03-28 12:35:31 +00:00
Georg Wiese
f3a56cc4ce Implement dynamic bus (JIT) (#2545)
With this PR, there is no more `.unwrap()` on `BusSend::static_bus_id()`
(previously `bus_id()`) and `BusSend::try_match_static()`.

Note that this will only generate a machine call when the bus ID is
"known concrete". Getting there might require branching. To relax this
(and require only known, but not concrete), I think we could change
[`Effect::MachineCall`](https://github.com/powdr-labs/powdr/blob/main/executor/src/witgen/jit/effect.rs#L25)
to take a symbolic expression instead of a concrete value, but
[`CanProcessCall::can_process_call_fully()`](d039c7bd81/executor/src/witgen/jit/witgen_inference.rs (L625))
still expects a concrete value, which can't easily be changed, so I
think this is the best we can do.
2025-03-26 15:55:07 +00:00
chriseth
3876fc2226 Solve bit decomposition with negative coefficients. (#2554)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-03-26 13:57:04 +00:00
Steve Wang
8090b3a9d5 Stage 1 public reference (#2567)
Depends on #2556. Pass stage 1 publics to the backend but not using them
yet (TODO for future PR).
2025-03-26 11:00:07 +00:00
chriseth
19d7117d37 Better branch debugging. (#2587) 2025-03-26 07:35:41 +00:00
Lucas Clemente Vella
0ed9db7fb6 Fix lint on log calls. (#2589)
Log crate now has clippy enabled for its arguments
2025-03-25 18:46:26 +00:00
chriseth
c29d2268d8 Prover functions for interpreter. (#2565)
This implement prover functons for the interpreter except for the
"input/output" prover functions. I would like to merge this already
since the input/output prover functions are mainly used in the main
machine which does not have jit support yet anyway.

---------

Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-03-25 15:05:11 +00:00
chriseth
e6c9a0a44c Split compile function and use interpreter for large code. (#2569)
This first derives the code and then makes the decision of whether or
not to use the interpreter based on the derived code.

Depends on #2582
2025-03-24 22:07:21 +00:00
chriseth
7679497165 Properly check that polynomial identities are solved. (#2582)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2025-03-24 17:21:06 +00:00
Steve Wang
00bb918eb7 Stage 0 public reference (#2556)
This PR is a step towards passing stage-0 public witgen to the backend.
It focuses on modifying the pipeline to separate witness values from
public values. Additional changes to pass stage-1 public witgen is
needed before public values are fully passed to the backend.
2025-03-24 09:01:25 +00:00
chriseth
ce7a136f08 Refactor interpreter test. (#2578) 2025-03-21 19:19:27 +00:00
Georg Wiese
a492a85dec Implement dynamic bus (runtime witgen) (#2539)
Builds on #2538

With this PR, the
[`dynamic_bus`](https://github.com/powdr-labs/powdr/blob/main/test_data/asm/dynamic_bus.asm)
test passes. I did not touch JIT code yet, but it doesn't seem to be
necessary in this example.
2025-03-20 13:18:30 +00:00
chriseth
acf7ae536c Fix doc tests. (#2568) 2025-03-20 10:25:12 +00:00
chriseth
0692fefe88 Refactor interpreter actions (#2563) 2025-03-20 08:22:03 +00:00
chriseth
1e8ed888be Privacy for interpreter. (#2566) 2025-03-19 17:36:04 +00:00
Leandro Pacheco
e6c29c4a72 jit interpreter branch handling (#2481)
Co-authored-by: chriseth <chriseth.github@gmail.com>
2025-03-19 14:44:28 +00:00
Georg Wiese
d7653ce9de Mark PIL docstring as no_run (#2562)
This should fix the [failing nightly
test](https://github.com/powdr-labs/powdr/actions/runs/13937842213/job/39009058952#step:14:42451).
2025-03-19 14:25:04 +00:00
chriseth
bc3bea160a Fix call. (#2550) 2025-03-14 13:43:33 +00:00
chriseth
a6e27efd3d Include prover function in error string. (#2548) 2025-03-14 10:46:09 +00:00
Georg Wiese
3dab8713c7 Rewrite multiplicity generator, remove Connection (#2538)
The multiplicity column generator was the last place where we used
`Connection`. This PR rewrites it and removes `Connection`.
2025-03-14 10:36:27 +00:00
chriseth
199dd1ab0e Add some debugs. (#2549) 2025-03-14 10:36:19 +00:00
Georg Wiese
b4350981e3 Bug fix: Include intermediates from receives in machine parts (#2546)
Extracted from #2541

Fixes a bug that the machine parts doesn't include the intermediate
definitions that only appear in one of the receives. An example of this
is the [Arith
large](https://github.com/powdr-labs/powdr/blob/main/std/machines/large_field/arith.asm)
machine, which has intermediates like `x1c` in their list of arguments,
but doesn't refer to the in any constraint.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2025-03-13 23:06:05 +00:00