Skip to content

Commit

Permalink
Rename convert.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Jan 25, 2024
1 parent 0c182ec commit 3aceb95
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 33 deletions.
26 changes: 13 additions & 13 deletions executor/src/constant_evaluator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ mod test {
pub fn test_poly_call() {
let src = r#"
constant %N = 10;
namespace std::conv(%N);
namespace std::convert(%N);
let int = [];
namespace F(%N);
col fixed seq(i) { i };
col fixed doub(i) { std::conv::int(seq((2 * i) % %N)) + 1 };
col fixed doub(i) { std::convert::int(seq((2 * i) % %N)) + 1 };
col fixed half_nibble(i) { i & 0x7 };
col fixed doubled_half_nibble(i) { half_nibble(i / 2) };
"#;
Expand Down Expand Up @@ -371,23 +371,23 @@ mod test {
pub fn comparisons() {
let src = r#"
constant %N = 6;
namespace std::conv(%N);
namespace std::convert(%N);
let int = 9;
let fe = 8;
namespace F(%N);
col fixed id(i) { i };
col fixed inv(i) { %N - i };
col fixed a = [0, 1, 0, 1, 2, 1];
col fixed b = [0, 0, 1, 1, 0, 5];
col fixed or(i) { if (a(i) != std::conv::fe(0)) || (b(i) != std::conv::fe(0)) { 1 } else { 0 } };
col fixed and(i) { if (a(i) != std::conv::fe(0)) && (b(i) != std::conv::fe(0)) { 1 } else { 0 } };
col fixed not(i) { if !(a(i) != std::conv::fe(0)) { 1 } else { 0 } };
col fixed less(i) { if std::conv::int(id(i)) < std::conv::int(inv(i)) { 1 } else { 0 } };
col fixed less_eq(i) { if std::conv::int(id(i)) <= std::conv::int(inv(i)) { 1 } else { 0 } };
col fixed or(i) { if (a(i) != std::convert::fe(0)) || (b(i) != std::convert::fe(0)) { 1 } else { 0 } };
col fixed and(i) { if (a(i) != std::convert::fe(0)) && (b(i) != std::convert::fe(0)) { 1 } else { 0 } };
col fixed not(i) { if !(a(i) != std::convert::fe(0)) { 1 } else { 0 } };
col fixed less(i) { if std::convert::int(id(i)) < std::convert::int(inv(i)) { 1 } else { 0 } };
col fixed less_eq(i) { if std::convert::int(id(i)) <= std::convert::int(inv(i)) { 1 } else { 0 } };
col fixed eq(i) { if id(i) == inv(i) { 1 } else { 0 } };
col fixed not_eq(i) { if id(i) != inv(i) { 1 } else { 0 } };
col fixed greater(i) { if std::conv::int(id(i)) > std::conv::int(inv(i)) { 1 } else { 0 } };
col fixed greater_eq(i) { if std::conv::int(id(i)) >= std::conv::int(inv(i)) { 1 } else { 0 } };
col fixed greater(i) { if std::convert::int(id(i)) > std::convert::int(inv(i)) { 1 } else { 0 } };
col fixed greater_eq(i) { if std::convert::int(id(i)) >= std::convert::int(inv(i)) { 1 } else { 0 } };
"#;
let analyzed = analyze_string(src);
assert_eq!(analyzed.degree(), 6);
Expand Down Expand Up @@ -489,11 +489,11 @@ mod test {
pub fn bigint_arith() {
let src = r#"
constant %N = 4;
namespace std::conv(%N);
namespace std::convert(%N);
let int = [];
let fe = [];
namespace F(%N);
let x = |i| std::conv::fe((std::conv::int(1) << (2000 + i)) >> 2000);
let x = |i| std::convert::fe((std::convert::int(1) << (2000 + i)) >> 2000);
"#;
let analyzed = analyze_string::<GoldilocksField>(src);
assert_eq!(analyzed.degree(), 4);
Expand All @@ -505,7 +505,7 @@ mod test {
pub fn modulo_negative() {
let src = r#"
constant %N = 4;
namespace std::conv(%N);
namespace std::convert(%N);
let int = [];
let fe = [];
namespace F(%N);
Expand Down
2 changes: 1 addition & 1 deletion linker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ namespace main_sub(16);
pol pc_update = ((((((instr_jmpz * (instr_jmpz_pc_update + instr_jmpz_pc_update_1)) + (instr_jmp * instr_jmp_param_l)) + (instr__jump_to_operation * _operation_id)) + (instr__loop * pc)) + (instr_return * 0)) + ((1 - ((((instr_jmpz + instr_jmp) + instr__jump_to_operation) + instr__loop) + instr_return)) * (pc + 1)));
pc' = ((1 - first_step') * pc_update);
pol constant p_line = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + [10]*;
pol commit X_free_value(i) query match pc(i) { 2 => ("input", 1), 4 => ("input", (std::conv::int(CNT(i)) + 1)), 7 => ("input", 0), };
pol commit X_free_value(i) query match pc(i) { 2 => ("input", 1), 4 => ("input", (std::convert::int(CNT(i)) + 1)), 7 => ("input", 0), };
pol constant p_X_const = [0]*;
pol constant p_X_read_free = [0, 0, 1, 0, 1, 0, 0, -1, 0, 0, 0] + [0]*;
pol constant p_instr__jump_to_operation = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] + [0]*;
Expand Down
8 changes: 4 additions & 4 deletions pil-analyzer/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ impl<'a, T: FieldElement, C: Custom> Value<'a, T, C> {
const BUILTINS: [(&str, BuiltinFunction); 6] = [
("std::array::len", BuiltinFunction::ArrayLen),
("std::check::panic", BuiltinFunction::Panic),
("std::conv::fe", BuiltinFunction::ToFe),
("std::conv::int", BuiltinFunction::ToInt),
("std::convert::fe", BuiltinFunction::ToFe),
("std::convert::int", BuiltinFunction::ToInt),
("std::debug::print", BuiltinFunction::Print),
("std::field::modulus", BuiltinFunction::Modulus),
];
Expand All @@ -200,9 +200,9 @@ pub enum BuiltinFunction {
/// std::debug::print: string -> [], prints its argument on stdout.
/// Returns an empty array.
Print,
/// std::conv::int: fe/int -> int, converts fe to int
/// std::convert::int: fe/int -> int, converts fe to int
ToInt,
/// std::conv::fe: int/fe -> fe, converts int to fe
/// std::convert::fe: int/fe -> fe, converts int to fe
ToFe,
}

Expand Down
2 changes: 1 addition & 1 deletion std/binary.asm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::conv::int;
use std::convert::int;

machine Binary(latch, operation_id) {

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions std/mod.asm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod array;
mod binary;
mod check;
mod conv;
mod convert;
mod debug;
mod field;
mod hash;
mod shift;
mod split;
mod utils;
mod utils;
6 changes: 3 additions & 3 deletions std/split/split_bn254.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ machine SplitBN254(RESET, _) {
// previous block)
// A hint is provided because automatic witness generation does not
// understand step 3 to figure out that the byte decomposition is unique.
col witness bytes(i) query ("hint", (std::conv::int(in_acc(i + 1)) >> (((i + 1) % 32) * 8)) % 0xff);
col witness bytes(i) query ("hint", (std::convert::int(in_acc(i + 1)) >> (((i + 1) % 32) * 8)) % 0xff);
// Puts the bytes together to form the input
col witness in_acc;
// Factors to multiply the bytes by
Expand Down Expand Up @@ -62,8 +62,8 @@ machine SplitBN254(RESET, _) {
// Byte comparison block machine
col fixed P_A(i) { i % 256 };
col fixed P_B(i) { (i >> 8) % 256 };
col fixed P_LT(i) { std::conv::int(P_A(i)) < std::conv::int(P_B(i)) };
col fixed P_GT(i) { std::conv::int(P_A(i)) > std::conv::int(P_B(i)) };
col fixed P_LT(i) { std::convert::int(P_A(i)) < std::convert::int(P_B(i)) };
col fixed P_GT(i) { std::convert::int(P_A(i)) > std::convert::int(P_B(i)) };

// Compare the current byte with the corresponding byte of the maximum value.
col witness lt;
Expand Down
6 changes: 3 additions & 3 deletions std/split/split_gl.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ machine SplitGL(RESET, _) {
// previous block)
// A hint is provided because automatic witness generation does not
// understand step 3 to figure out that the byte decomposition is unique.
col witness bytes(i) query ("hint", (std::conv::int(in_acc(i + 1)) >> (((i + 1) % 8) * 8)) % 0xff);
col witness bytes(i) query ("hint", (std::convert::int(in_acc(i + 1)) >> (((i + 1) % 8) * 8)) % 0xff);
// Puts the bytes together to form the input
col witness in_acc;
// Factors to multiply the bytes by
Expand Down Expand Up @@ -58,8 +58,8 @@ machine SplitGL(RESET, _) {
// Byte comparison block machine
col fixed P_A(i) { i % 256 };
col fixed P_B(i) { (i >> 8) % 256 };
col fixed P_LT(i) { std::conv::int(P_A(i)) < std::conv::int(P_B(i)) };
col fixed P_GT(i) { std::conv::int(P_A(i)) > std::conv::int(P_B(i)) };
col fixed P_LT(i) { std::convert::int(P_A(i)) < std::convert::int(P_B(i)) };
col fixed P_GT(i) { std::convert::int(P_A(i)) > std::convert::int(P_B(i)) };

// Compare the current byte with the corresponding byte of the maximum value.
col witness lt;
Expand Down
4 changes: 2 additions & 2 deletions test_data/asm/simple_sum.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// This imports the `conv` module which contains functions to convert
// between integers and field elements.
use std::conv::int;
use std::convert::int;

machine Main {
reg pc[@pc]; // "@pc" means "pc' = pc + 1" is the default propagation (instead of pc' = pc) and it tracks the line in the program.
Expand Down Expand Up @@ -37,7 +37,7 @@ machine Main {

start:
jmpz CNT, check;
A <=X= A + ${ ("input", std::conv::int(CNT) + 1) };
A <=X= A + ${ ("input", std::convert::int(CNT) + 1) };
// Could use "CNT <=X= CNT - 1", but that would need X.
dec_CNT;
jmp start;
Expand Down
4 changes: 2 additions & 2 deletions test_data/pil/block_lookup_or.pil
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
constant %N = 65536;

namespace std::conv(%N);
namespace std::convert(%N);
// Due to its name, the semantics of this function will be overridden.
// We ensure that this happens by making it diverge in its given semantics.
let int = [|i| int(i)];
Expand All @@ -12,7 +12,7 @@ namespace Or(%N);

col fixed P_A(i) { i % 256 };
col fixed P_B(i) { (i >> 8) % 256 };
col fixed P_C(i) { (std::conv::int(P_A(i)) | std::conv::int(P_B(i))) & 0xff };
col fixed P_C(i) { (std::convert::int(P_A(i)) | std::convert::int(P_B(i))) & 0xff };

// ROW RESET FACTOR
// 0 0 1 << 8
Expand Down
4 changes: 2 additions & 2 deletions test_data/pil/pair_lookup.pil
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
constant %N = 65536;
namespace std::conv(%N);
namespace std::convert(%N);
let int = [];

namespace Main(%N);
col fixed A(i) { i % 256 };
col fixed B(i) { (i >> 8) % 256 };
col fixed C(i) { (std::conv::int(A(i)) + std::conv::int(B(i))) & 0xff };
col fixed C(i) { (std::convert::int(A(i)) + std::convert::int(B(i))) & 0xff };


col fixed a(i) { (i + 13) * 29 & 0xff };
Expand Down

0 comments on commit 3aceb95

Please sign in to comment.