Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sub test. #2577

Merged
merged 36 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5f9c452
Solve bit decomposition with negative coefficients.
chriseth Mar 14, 2025
bf43c73
Make bit decomposition its own effect.
chriseth Mar 17, 2025
99558c2
fixes
chriseth Mar 17, 2025
f4f8a28
Remove negative case since this is now also covered.
chriseth Mar 17, 2025
f5fe3f5
Update test expectations.
chriseth Mar 17, 2025
1a378c3
Implement missing functions.
chriseth Mar 17, 2025
fcc5190
Codegen for bit decomposition.
chriseth Mar 18, 2025
7b4780e
clippy
chriseth Mar 18, 2025
94a8cc4
Test with negative value.
chriseth Mar 18, 2025
44bdd08
Use shift instead of division.
chriseth Mar 18, 2025
d2980dd
Fix typo.
chriseth Mar 18, 2025
a3b210c
Bit decomposition interpreter.
chriseth Mar 18, 2025
2e7d3a7
Jump through some hoops.
chriseth Mar 19, 2025
4ddae64
Tests and fixes.
chriseth Mar 19, 2025
721cd36
Merge remote-tracking branch 'origin/main' into bit_decomp_interpreter
chriseth Mar 19, 2025
589963b
Cover check.
chriseth Mar 20, 2025
977f106
Update executor/src/witgen/jit/compiler.rs
chriseth Mar 20, 2025
14647d1
Review.
chriseth Mar 20, 2025
2e87944
Remove bitand_signed_negated.
chriseth Mar 20, 2025
0906258
debugging
chriseth Mar 20, 2025
1059fa6
Add comment.
chriseth Mar 20, 2025
5cf50ee
Make all variables to be assigned in the branch mutable.
chriseth Mar 20, 2025
00750c8
Revert "debugging"
chriseth Mar 20, 2025
f71190c
remove debug
chriseth Mar 20, 2025
d398c25
Fix expectation.
chriseth Mar 20, 2025
85a3a4d
Merge remote-tracking branch 'origin/main' into solve_bit_decompositi…
chriseth Mar 21, 2025
1c1eaa2
Merge remote-tracking branch 'origin/main' into solve_bit_decompositi…
chriseth Mar 24, 2025
15ffafd
Add sub test.
chriseth Mar 21, 2025
f113904
comment.
chriseth Mar 24, 2025
170ccce
Use babybear.
chriseth Mar 24, 2025
ea0a974
Merge remote-tracking branch 'origin/main' into solve_bit_decompositi…
chriseth Mar 24, 2025
4b994fd
Merge branch 'solve_bit_decomposition_with_negative_numbers' into add…
chriseth Mar 24, 2025
2ed4e01
Merge branch 'bit_decomp_interpreter' into add_sub_test
chriseth Mar 24, 2025
2a1127a
tests.
chriseth Mar 25, 2025
a09ed44
explanation.
chriseth Mar 25, 2025
e2f5cff
Merge remote-tracking branch 'origin/main' into add_sub_test
chriseth Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add sub test.
  • Loading branch information
chriseth committed Mar 24, 2025
commit 15ffafd31b1f480a79c5066841d39f1c551cce56
15 changes: 15 additions & 0 deletions executor/src/witgen/jit/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,4 +811,19 @@ namespace arith(8);
],
);
}

#[test]
fn add_sub_bb() {
let pil = read_to_string("../test_data/pil/add_sub_bb.pil").unwrap();
let (analyzed, fixed_col_vals) = read_pil::<GoldilocksField>(&pil);
let fixed_data = FixedData::new(&analyzed, &fixed_col_vals, &[], Default::default(), 0);
let fixed_data = global_constraints::set_global_constraints(fixed_data);
let interpreter_gt =
TestInterpreter::new(&analyzed, &fixed_data, "main_add_sub", 4, 1, &|_| {
Err("Query not implemented".to_string())
});
interpreter_gt.test(&[1, 2, 3, 4, 0], &[1, 2, 3, 4, 0]);
interpreter_gt.test(&[3, 2, 3, 4, 0], &[3, 2, 3, 4, 0]);
interpreter_gt.test(&[5, 2, 3, 4, 0], &[5, 2, 3, 4, 1]);
}
}
28 changes: 28 additions & 0 deletions test_data/pil/add_sub_bb.pil
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// A compiled version of "add_sub.asm" for babybear.
namespace main(32..4096);
// Dummy connection constraint
col witness i1, i2, i3, i4, i5;
[i1, i2, i3, i4, i5] is [main_add_sub::C_h, main_add_sub::C_l, main_add_sub::B_h, main_add_sub::B_l, main_add_sub::carry32];
namespace main_add_sub(32..4096);
col witness carry16;
main_add_sub::carry16 * (1 - main_add_sub::carry16) = 0;
col witness carry32;
main_add_sub::carry32 * (1 - main_add_sub::carry32) = 0;
col witness A_h;
col witness A_l;
col witness B_h;
col witness B_l;
col witness C_h;
col witness C_l;
main_add_sub::A_l + main_add_sub::B_l = main_add_sub::C_l + main_add_sub::carry16 * 65536;
main_add_sub::A_h + main_add_sub::B_h + main_add_sub::carry16 = main_add_sub::C_h + main_add_sub::carry32 * 65536;
col witness sel;
main_add_sub::sel * (1 - main_add_sub::sel) = 0;
[main_add_sub::A_l] in [main_byte2::BYTE2];
[main_add_sub::A_h] in [main_byte2::BYTE2];
[main_add_sub::B_l] in [main_byte2::BYTE2];
[main_add_sub::B_h] in [main_byte2::BYTE2];
[main_add_sub::C_l] in [main_byte2::BYTE2];
[main_add_sub::C_h] in [main_byte2::BYTE2];
namespace main_byte2(65536);
col fixed BYTE2(i) { i & 65535_int };
Loading