Files
powdr/test_data/pil/referencing_array.pil
2024-02-09 08:17:55 +01:00

29 lines
870 B
Plaintext

let N = 16;
namespace std::array(N);
let len = [];
namespace Main(N);
let make_array = |n, f| if n == 0 { [] } else { make_array(n - 1, f) + [f(n - 1)] };
let nth_clock: int -> col = |k| |i| if i % std::array::len(clocks) == k { 1 } else { 0 };
let clocks: col[4] = make_array(4, nth_clock);
let wit: col[4];
make_array(4, |k| wit[k] = clocks[k]);
// The constraint above is already sufficient.
// These are here to check that the correct witnesses and the correct clocks are
// referenced above.
wit[0] * wit[1] = 0;
wit[0] * wit[2] = 0;
wit[0] * wit[3] = 0;
wit[1] * wit[2] = 0;
wit[1] * wit[3] = 0;
wit[2] * wit[3] = 0;
wit[0] + wit[1] + wit[2] + wit[3] = 1;
// intermediate poly array
let inter: expr[4] = make_array(4, |i| wit[i] + 10);
make_array(4, |k| inter[k] = clocks[k] + 10);