-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): add semicolon for return expr
- Loading branch information
Showing
6 changed files
with
123 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
def FunctionsAir | ||
|
||
fn get_multiplicity_flags(s0: felt, s1: felt) -> felt[4] { | ||
return [!s0 & !s1, s0 & !s1, !s0 & s1, s0 & s1] | ||
return [!s0 & !s1, s0 & !s1, !s0 & s1, s0 & s1]; | ||
} | ||
|
||
fn fold_vec(a: felt[12]) -> felt { | ||
return sum([x for x in a]) | ||
return sum([x for x in a]); | ||
} | ||
|
||
fn fold_scalar_and_vec(a: felt, b: felt[12]) -> felt { | ||
let m = fold_vec(b) | ||
let n = m + 1 | ||
let o = n * 2 | ||
return o | ||
let m = fold_vec(b); | ||
let n = m + 1; | ||
let o = n * 2; | ||
return o; | ||
} | ||
|
||
trace_columns { | ||
main: [t, s0, s1, v, b[12]] | ||
aux: [b_range] | ||
main: [t, s0, s1, v, b[12]], | ||
aux: [b_range], | ||
} | ||
|
||
public_inputs { | ||
stack_inputs: [16] | ||
stack_inputs: [16], | ||
} | ||
|
||
random_values { | ||
alpha: [16] | ||
alpha: [16], | ||
} | ||
|
||
boundary_constraints { | ||
enf v.first = 0 | ||
enf v.first = 0; | ||
} | ||
|
||
integrity_constraints { | ||
# let val = $alpha[0] + v | ||
let f = get_multiplicity_flags(s0, s1) | ||
let z = v^7 * f[3] + v^2 * f[2] + v * f[1] + f[0] | ||
# let folded_value = fold_scalar_and_vec(v, b) | ||
enf b_range' = b_range * (z * t - t + 1) | ||
# enf b_range' = b_range * 2 | ||
let y = fold_scalar_and_vec(v, b) | ||
# let c = fold_scalar_and_vec(t, b) | ||
enf v' = y | ||
# let val = $alpha[0] + v; | ||
let f = get_multiplicity_flags(s0, s1); | ||
let z = v^7 * f[3] + v^2 * f[2] + v * f[1] + f[0]; | ||
# let folded_value = fold_scalar_and_vec(v, b); | ||
enf b_range' = b_range * (z * t - t + 1); | ||
# enf b_range' = b_range * 2; | ||
let y = fold_scalar_and_vec(v, b); | ||
# let c = fold_scalar_and_vec(t, b); | ||
enf v' = y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,90 @@ | ||
def FunctionsAir | ||
|
||
fn fold_sum(a: felt[4]) -> felt { | ||
return a[0] + a[1] + a[2] + a[3] | ||
return a[0] + a[1] + a[2] + a[3]; | ||
} | ||
|
||
fn fold_vec(a: felt[4]) -> felt { | ||
let m = a[0] * a[1] | ||
let n = m * a[2] | ||
let o = n * a[3] | ||
return o | ||
let m = a[0] * a[1]; | ||
let n = m * a[2]; | ||
let o = n * a[3]; | ||
return o; | ||
} | ||
|
||
fn cube(base: felt) -> felt { | ||
return base^3 | ||
return base^3; | ||
} | ||
|
||
fn cube_vec(base: felt[4]) -> felt[4] { | ||
let cubed_vec = [x^3 for x in base] | ||
return cubed_vec | ||
let cubed_vec = [x^3 for x in base]; | ||
return cubed_vec; | ||
} | ||
|
||
fn func_return(a: felt[4]) -> felt { | ||
return fold_sum(a) | ||
return fold_sum(a); | ||
} | ||
|
||
fn func_func_return(a: felt[4]) -> felt { | ||
return fold_sum(a) * fold_vec(a) | ||
return fold_sum(a) * fold_vec(a); | ||
} | ||
|
||
fn bin_return(a: felt[4]) -> felt { | ||
return fold_sum(a) * 4 | ||
return fold_sum(a) * 4; | ||
} | ||
|
||
trace_columns { | ||
main: [t, s0, s1, v, b[4]] | ||
aux: [b_range] | ||
main: [t, s0, s1, v, b[4]], | ||
aux: [b_range], | ||
} | ||
|
||
public_inputs { | ||
stack_inputs: [16] | ||
stack_inputs: [16], | ||
} | ||
|
||
random_values { | ||
alpha: [16] | ||
alpha: [16], | ||
} | ||
|
||
boundary_constraints { | ||
enf v.first = 0 | ||
enf v.first = 0; | ||
} | ||
|
||
integrity_constraints { | ||
# -------- function call is assigned to a variable and used in a binary expression ------------ | ||
|
||
# binary expression invloving scalar expressions | ||
let simple_expression = t * v | ||
enf simple_expression = 1 | ||
let simple_expression = t * v; | ||
enf simple_expression = 1; | ||
|
||
# binary expression involving one function call | ||
let folded_vec = fold_vec(b) * v | ||
enf folded_vec = 1 | ||
let folded_vec = fold_vec(b) * v; | ||
enf folded_vec = 1; | ||
|
||
# binary expression involving two function calls | ||
let complex_fold = fold_sum(b) * fold_vec(b) | ||
enf complex_fold = 1 | ||
let complex_fold = fold_sum(b) * fold_vec(b); | ||
enf complex_fold = 1; | ||
|
||
|
||
# -------- function calls used in constraint ------------ | ||
enf fold_vec(b) = 1 | ||
enf t * fold_vec(b) = 1 | ||
enf s0 + fold_sum(b) * fold_vec(b) = 1 | ||
enf fold_vec(b) = 1; | ||
enf t * fold_vec(b) = 1; | ||
enf s0 + fold_sum(b) * fold_vec(b) = 1; | ||
|
||
# -------- functions with function calls as return statements ------------ | ||
enf func_return(b) = 1 | ||
enf func_func_return(b) = 1 | ||
enf bin_return(b) = 1 | ||
enf func_return(b) = 1; | ||
enf func_func_return(b) = 1; | ||
enf bin_return(b) = 1; | ||
|
||
# -------- different types of arguments in a function call ------------ | ||
|
||
# function call with a function call as an argument | ||
# enf fold_vec(cube_vec(b)) = 1 | ||
# enf fold_vec(cube_vec(b)) = 1; | ||
|
||
# function call as value in list comprehension | ||
# let folded_vec = sum([cube(x) for x in b]) | ||
# enf t * folded_vec = 1 | ||
# let folded_vec = sum([cube(x) for x in b]); | ||
# enf t * folded_vec = 1; | ||
|
||
# function call as iterable in list comprehension | ||
# let folded_vec = sum([x + 1 for x in cube_vec(b)]) | ||
# enf t * folded_vec = 1 | ||
# let folded_vec = sum([x + 1 for x in cube_vec(b)]); | ||
# enf t * folded_vec = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.