Skip to content

Commit e5720a7

Browse files
author
Leo
authored
Merge pull request #1089 from powdr-labs/revert-1082-assignment-registers-intermediate
Revert "Turn assignment registers into intermediate polynomials"
2 parents 4aa8f82 + 3bf1bcc commit e5720a7

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

asm-to-pil/src/vm_to_constrained.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,15 @@ impl<T: FieldElement> ASMPILConverter<T> {
299299
default_update = Some(direct_reference(&name));
300300
}
301301
};
302-
// Assignment registers are intermediate columns
303-
if ty != RegisterTy::Assignment {
304-
self.pil.push(witness_column(source, name.clone(), None));
305-
}
306302
self.registers.insert(
307-
name,
303+
name.to_string(),
308304
Register {
309305
conditioned_updates,
310306
default_update,
311307
ty,
312308
},
313309
);
310+
self.pil.push(witness_column(source, name, None));
314311
}
315312

316313
fn handle_instruction_def(
@@ -840,10 +837,9 @@ impl<T: FieldElement> ASMPILConverter<T> {
840837
direct_reference(read_free) * direct_reference(free_value),
841838
])
842839
.sum();
843-
self.pil.push(PilStatement::PolynomialDefinition(
840+
self.pil.push(PilStatement::Expression(
844841
SourceRef::unknown(),
845-
register.clone(),
846-
assign_constraint,
842+
build::identity(direct_reference(register), assign_constraint),
847843
));
848844
}
849845

linker/src/lib.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ mod test {
298298
let expectation = r#"namespace main(16);
299299
pol commit _operation_id(i) query ("hint", 4);
300300
pol commit pc;
301+
pol commit X;
302+
pol commit Y;
301303
pol commit reg_write_X_A;
302304
pol commit reg_write_Y_A;
303305
pol commit A;
@@ -312,12 +314,12 @@ mod test {
312314
pol commit X_read_free;
313315
pol commit read_X_A;
314316
pol commit read_X_pc;
315-
pol X = ((((read_X_A * A) + (read_X_pc * pc)) + X_const) + (X_read_free * X_free_value));
317+
(X = ((((read_X_A * A) + (read_X_pc * pc)) + X_const) + (X_read_free * X_free_value)));
316318
pol commit Y_const;
317319
pol commit Y_read_free;
318320
pol commit read_Y_A;
319321
pol commit read_Y_pc;
320-
pol Y = ((((read_Y_A * A) + (read_Y_pc * pc)) + Y_const) + (Y_read_free * Y_free_value));
322+
(Y = ((((read_Y_A * A) + (read_Y_pc * pc)) + Y_const) + (Y_read_free * Y_free_value)));
321323
pol constant first_step = [1] + [0]*;
322324
(A' = ((((reg_write_X_A * X) + (reg_write_Y_A * Y)) + (instr__reset * 0)) + ((1 - ((reg_write_X_A + reg_write_Y_A) + instr__reset)) * A)));
323325
pol pc_update = ((((instr__jump_to_operation * _operation_id) + (instr__loop * pc)) + (instr_return * 0)) + ((1 - ((instr__jump_to_operation + instr__loop) + instr_return)) * (pc + 1)));
@@ -356,6 +358,7 @@ namespace main_sub(16);
356358
pol commit _operation_id(i) query ("hint", 5);
357359
pol commit pc;
358360
pol commit _input_0;
361+
pol commit _output_0;
359362
pol commit instr__jump_to_operation;
360363
pol commit instr__reset;
361364
pol commit instr__loop;
@@ -364,7 +367,7 @@ namespace main_sub(16);
364367
pol commit _output_0_read_free;
365368
pol commit read__output_0_pc;
366369
pol commit read__output_0__input_0;
367-
pol _output_0 = ((((read__output_0_pc * pc) + (read__output_0__input_0 * _input_0)) + _output_0_const) + (_output_0_read_free * _output_0_free_value));
370+
(_output_0 = ((((read__output_0_pc * pc) + (read__output_0__input_0 * _input_0)) + _output_0_const) + (_output_0_read_free * _output_0_free_value)));
368371
pol constant first_step = [1] + [0]*;
369372
(((1 - instr__reset) * (_input_0' - _input_0)) = 0);
370373
pol pc_update = ((((instr__jump_to_operation * _operation_id) + (instr__loop * pc)) + (instr_return * 0)) + ((1 - ((instr__jump_to_operation + instr__loop) + instr_return)) * (pc + 1)));
@@ -405,6 +408,7 @@ namespace main_sub(16);
405408
((XIsZero * (1 - XIsZero)) = 0);
406409
pol commit _operation_id(i) query ("hint", 10);
407410
pol commit pc;
411+
pol commit X;
408412
pol commit reg_write_X_A;
409413
pol commit A;
410414
pol commit reg_write_X_CNT;
@@ -427,7 +431,7 @@ namespace main_sub(16);
427431
pol commit read_X_A;
428432
pol commit read_X_CNT;
429433
pol commit read_X_pc;
430-
pol X = (((((read_X_A * A) + (read_X_CNT * CNT)) + (read_X_pc * pc)) + X_const) + (X_read_free * X_free_value));
434+
(X = (((((read_X_A * A) + (read_X_CNT * CNT)) + (read_X_pc * pc)) + X_const) + (X_read_free * X_free_value)));
431435
pol constant first_step = [1] + [0]*;
432436
(A' = (((reg_write_X_A * X) + (instr__reset * 0)) + ((1 - (reg_write_X_A + instr__reset)) * A)));
433437
(CNT' = ((((reg_write_X_CNT * X) + (instr_dec_CNT * (CNT - 1))) + (instr__reset * 0)) + ((1 - ((reg_write_X_CNT + instr_dec_CNT) + instr__reset)) * CNT)));
@@ -578,6 +582,7 @@ machine Main {
578582
let expected = r#"namespace main(1024);
579583
pol commit _operation_id(i) query ("hint", 3);
580584
pol commit pc;
585+
pol commit X;
581586
pol commit reg_write_X_A;
582587
pol commit A;
583588
pol commit instr_add5_into_A;
@@ -589,7 +594,7 @@ machine Main {
589594
pol commit X_read_free;
590595
pol commit read_X_A;
591596
pol commit read_X_pc;
592-
pol X = ((((read_X_A * A) + (read_X_pc * pc)) + X_const) + (X_read_free * X_free_value));
597+
(X = ((((read_X_A * A) + (read_X_pc * pc)) + X_const) + (X_read_free * X_free_value)));
593598
pol constant first_step = [1] + [0]*;
594599
(A' = ((((reg_write_X_A * X) + (instr_add5_into_A * A')) + (instr__reset * 0)) + ((1 - ((reg_write_X_A + instr_add5_into_A) + instr__reset)) * A)));
595600
pol pc_update = ((((instr__jump_to_operation * _operation_id) + (instr__loop * pc)) + (instr_return * 0)) + ((1 - ((instr__jump_to_operation + instr__loop) + instr_return)) * (pc + 1)));

0 commit comments

Comments
 (0)