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

[Prototype] PIL compiler #1

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open

[Prototype] PIL compiler #1

wants to merge 15 commits into from

Conversation

georgwiese
Copy link
Owner

Basic PIL compiler for SP1.

To test:

cd examples/fibonacci/script
cargo run -r

Prints this PIL for the AddSub chip:

col fixed is_first_row = [1] + [0]*;
col fixed is_last_row = [0] + [1]*;
col fixed is_transition = [0] + [1]* + [0];
col witness shard;
col witness nonce;
col witness add_operation__value__0__0;
col witness add_operation__value__0__1;
col witness add_operation__value__0__2;
col witness add_operation__value__0__3;
col witness add_operation__carry__0;
col witness add_operation__carry__1;
col witness add_operation__carry__2;
col witness operand_1__0__0;
col witness operand_1__0__1;
col witness operand_1__0__2;
col witness operand_1__0__3;
col witness operand_2__0__0;
col witness operand_2__0__1;
col witness operand_2__0__2;
col witness operand_2__0__3;
col witness is_add;
col witness is_sub;
(is_first_row * nonce) = 0;
(is_transition * ((nonce + 1) - nonce')) = 0;
((is_add + is_sub) * (((operand_1__0__0 + operand_2__0__0) - add_operation__value__0__0) * (((operand_1__0__0 + operand_2__0__0) - add_operation__value__0__0) - 256))) = 0;
((is_add + is_sub) * ((((operand_1__0__1 + operand_2__0__1) - add_operation__value__0__1) + add_operation__carry__0) * ((((operand_1__0__1 + operand_2__0__1) - add_operation__value__0__1) + add_operation__carry__0) - 256))) = 0;
((is_add + is_sub) * ((((operand_1__0__2 + operand_2__0__2) - add_operation__value__0__2) + add_operation__carry__1) * ((((operand_1__0__2 + operand_2__0__2) - add_operation__value__0__2) + add_operation__carry__1) - 256))) = 0;
((is_add + is_sub) * ((((operand_1__0__3 + operand_2__0__3) - add_operation__value__0__3) + add_operation__carry__2) * ((((operand_1__0__3 + operand_2__0__3) - add_operation__value__0__3) + add_operation__carry__2) - 256))) = 0;
((is_add + is_sub) * (add_operation__carry__0 * (((operand_1__0__0 + operand_2__0__0) - add_operation__value__0__0) - 256))) = 0;
((is_add + is_sub) * (add_operation__carry__1 * ((((operand_1__0__1 + operand_2__0__1) - add_operation__value__0__1) + add_operation__carry__0) - 256))) = 0;
((is_add + is_sub) * (add_operation__carry__2 * ((((operand_1__0__2 + operand_2__0__2) - add_operation__value__0__2) + add_operation__carry__1) - 256))) = 0;
((is_add + is_sub) * ((add_operation__carry__0 - 1) * ((operand_1__0__0 + operand_2__0__0) - add_operation__value__0__0))) = 0;
((is_add + is_sub) * ((add_operation__carry__1 - 1) * (((operand_1__0__1 + operand_2__0__1) - add_operation__value__0__1) + add_operation__carry__0))) = 0;
((is_add + is_sub) * ((add_operation__carry__2 - 1) * (((operand_1__0__2 + operand_2__0__2) - add_operation__value__0__2) + add_operation__carry__1))) = 0;
((is_add + is_sub) * (add_operation__carry__0 * (add_operation__carry__0 - 1))) = 0;
((is_add + is_sub) * (add_operation__carry__1 * (add_operation__carry__1 - 1))) = 0;
((is_add + is_sub) * (add_operation__carry__2 * (add_operation__carry__2 - 1))) = 0;
((is_add + is_sub) * ((is_add + is_sub) * ((is_add + is_sub) - 1))) = 0;
(is_add * (is_add - 1)) = 0;
(is_sub * (is_sub - 1)) = 0;
((is_add + is_sub) * ((is_add + is_sub) - 1)) = 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant