Open aemartinez opened 1 year ago
In other words:
a / b
in annotations tells you the biggest $x$ such that $bx \leq a$,a / b
in Cairo gives you the only $x$ with $0 \leq x < p$ such that $bx \equiv a \mod p$.For example, in $\mathbb{F}_5$:
4 / 3
in annotations is $1$.4 / 3
in Cairo is $3$.Intuitively, we perform the following:
Describe the bug For field elements, the operation
a / b
results in anx
such thatb * x = a
. (Because this is an operation in the field, whena
is not a multiple ofb
,x
is not the integral part of the quotient as if operating withInt
s).Horus-compile
transforms the/
operator in assertions to thediv
operator in SMTLIB. The assertion@post $Return.res == a / b
will be translated to(= (memory (+ ap (- 1))) (div (memory (+ fp (- 4))) (memory (+ fp (- 3)))))
(wherea
andb
are the arguments of the function).This leads to unexpected behavior, even if
horus-check
encodes operations using moduloP
.Expected behavior
I expect
I get
To Reproduce
horus-compile==0.0.6.11
horus-check
latest version inmaster
Solver: default (cvc5)Operating system [x] Linux [ ] MacOS [ ] Windows [ ] Other (please write)
CPU architecture [ ] x86-64 [x] AArch64 [ ] Other (please write)
Additional context
Unoptimized smt query obtained from the example (simplified, showing only the relevant assertions)
z3 output
spec.json: