by Yu Feng
Does this ring a bell?
computeKSum(list, k)
function that calculates the sum of the k largest values in a soccer league list.[49, 62, 82, 54, 76], k = 2 → 158 (82 + 76)
N
) for list transformations:sort, reverse, take, filter, head, last, sum, max, min ...
with integer grammars for indices and predicates.take
: y.size < x1.size ∧ y.max ≤ x1.max ∧ x2>0
.head( take( filter( x1 , ? ) , ? ) )
with unfilled holes (?
)y ≤ v1.max
, v1.max ≤ v3.max
, ... combined with I/O specification x1=[49,62,82,54,76] ∧ y=158
y ≤ 82
yet y = 158
)head
or take
with any operator having identical size/max specifications would still result in infeasibility.Equivalence Modulo Conflict analysis determines that sort ≡ take ≡ reverse ≡ filter at node N₁, allowing NEO to learn a lemma that prunes 63 sibling ASTs in one operation.
Fp²
ExpressionsFp²
is a quadratic extension field of the prime field Fp. In cryptography, Fp² represents complex numbers over a finite field, where elements are expressed as a + bi with a,b ∈ Fp. Fp² expressions are mathematical formulas that manipulate these field elements using operations like addition, multiplication, and squaring.Expr ::= Var // a0, a1, xi, tmp…
| Const // field constants
| Add(Expr, Expr) // +
| Sub(Expr, Expr) // –
| Sqr(Expr) // x * x (cheap-mul)
| Mul(Expr, Expr) // general multiplication
| MulConst(Const, Expr) // ξ * x (const-mul)
| Let Var = Expr ; Expr // share sub-results
Fp²
.Fp²
Operations2·Sqr + 1·Mul + 1·MulConst + 1·Add = 27
3·Sqr + 1·MulConst + 2·Add + 2·Sub = 26
def sq_fp4_naive(a0, a1, xi):
c0 = a0*a0 + (a1*a1)*xi
c1 = 2 * a0 * a1
return (c0, c1)
# 2 sqr + 1 mul + ξ-mul
def sq_fp4_optimized(a0, a1, xi):
t0 = a0*a0
t1 = a1*a1
c0 = t1 * xi + t0
c1 = (a0 + a1)**2 - t0 - t1
return (c0, c1)
# 3 sqr, no general mul
# A = a0 + a1*V where V^2 = ξ (Fp² coefficients)