-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add modular-arithmetic types to Geb external API #61
Comments
It occurs to me regarding these variable-type-size interfaces that they could be constructed from single-type-size interfaces such as |
A question for @lukaszcz : does Juvix (currently, at least) use natural-number types that aren't of |
We currently use theoretically unbounded numbers, but having fixed We might also want to have direct access to the actual fields elements with their corresponding operations (e.g. where division is actual field division not integer division). That would be a separate Field type. |
Good point -- I filed #122 for this. |
GEB 0.3.2 introduces the following changes. * The STLC frontend no longer requires full type information in terms. The syntax of the terms changed. * An error node has been introduced which allows to compile Juvix `fail` nodes. The following features required for compilation from Juvix are still missing in GEB. * Modular arithmetic types ([GEB issue #61](anoma/geb#61)). * Functor/algebra iteration to implement bounded inductive types ([GEB issue #62](anoma/geb#62)).
The
substobj
andsubstmorph
types in https://github.com/anoma/geb/blob/main/src/specs/geb.lisp should be extended with those required for built-in modular arithmetic.Specifically, there will be a new object called something like
fs n
for each non-zero naturaln
(not for zero, because arithmetic mod 0 isNat
itself, and circuits can only support fixed-size natural numbers).There will be the following new morphisms with the following signatures, where
bool
iscoprod so1 so1
, andfs <n>
means for every non-zero natural number<n>
:m
including zero and less thann
,const m
:so1 -> fs n
inj
:fs m -> fs n
(injects one bounded type into another -- may wrap around ifm > n
; equal toid
ifm == n
)+
:prod (fs m) (fs n) -> fs p
*
:prod (fs m) (fs n) -> fs p
-
:prod (fs m) (fs n) -> fs p
/
:prod (fs m) (fs n) -> fs p
%
:prod (fs m) (fs n) -> fs p
==
:prod (fs m) (fs n) -> bool
<
:prod (fs m) (fs n) -> bool
Because the arithmetic is modular, overflows just cause wraparound. Division and modulus by zero will produce errors at witness generation time in VampIR. (Once we support dependent types in Geb, we will be able to allow users to include proof content demonstrating that they are not dividing by zero.)
VampIR higher-order functions might be helpful in integrating this with #60 ; see https://github.com/anoma/vamp-ir/blob/main/tests/funcs.pir for examples.
The text was updated successfully, but these errors were encountered: