6 releases
0.1.3 | Oct 17, 2024 |
---|---|
0.1.2 | Oct 16, 2024 |
0.0.1 | Oct 11, 2024 |
#923 in Math
245KB
5K
SLoC
ashlang
A language designed to compile and execute on mathematical virtual machines.
Simplicity is the philosophy of ashlang. The language is simple to learn and expresses relationships very close to the arithmetization. Functions are globally available to encourage the development of a single, well audited, well maintained standard library of logic that can be re-used in many proving systems.
Targets
ashlang currently supports two targets:
ar1cs
- an extended rank 1 constraint system that includes witness calculation instructionstasm
- a novel assembly language used to express instructions for the Triton VM
Provers
ashlang supprts proving on the following systems:
TritonVM/triton-vm
- usingtasm
target in this cratemicrosoft/spartan
- usingar1cs
target in chancehudson/ashlang-spartan
Language
ashlang is a scripting language for expressing mathematical relations between scalars and vectors in a finite field.
The language is untyped, with each variable being one of the following:
- scalar
- vector
- matrix (of any dimension)
ashlang is designed to be written in conjunction with a lower level language. Each file is a single function, it may be invoked using its filename. Directories are recursively imported and functions become globally available.
Features
- element-wise vector operations
- throws if vectors of mismatched size are used in an operation e.g.
val[0..10] * lav[0..5]
- functions cannot be declared, each file is a single function
- files are not imported, function calls match the filename and tell the compiler what files are needed
- r1cs witnesses can be computed without specialized code
Language support tracking
Target tasm
- scalar math operations
- tuple inputs
- let variables
- re-assigned variables
- static variables
- define static variables
- static variables as function arguments
- static variables as loop condition
- static variables as function return values
- function support
-
let
assignment -
static
assignment (static evaluation) - return function content directly
- arguments
-
- function auto-import
- if statement
- equality
- block support
- general block support
- builtin functions
-
assert_eq
-
crash
-
- vector support
- vectors of any dimension e.g.
v[2][3][4][1]
- vector variable support
- vector constants support
- vector math support
- vector index ranges e.g.
[0..5]
- vector binary operation support
- vector support in functions
- vector support as function argument
- vector support as function return
- vector index access by static e.g.
v[i]
- vectors of any dimension e.g.
- loops
Target r1cs
- scalar math operations
- tuple inputs
- let variables
- re-assigned variables
- static variables
- define static variables
- static variables as function arguments
- static variables as loop condition
- static variables as function return values
- function support
-
let
assignment -
static
assignment (static evaluation) - return function content directly
- arguments
-
- function auto-import
- if statement
- equality
- block support
- general block support
- builtin functions
-
assert_eq
-
crash
-
- vector support
- vectors of any dimension e.g.
v[2][3][4][1]
- vector variable support
- vector static support
- vector math support
- vector index ranges e.g.
[0..5]
- vector binary operation support
- vector support in functions
- vector support as function argument
- vector support as function return
- vector index access by static e.g.
v[i]
- vectors of any dimension e.g.
- loops
Dependencies
~9–22MB
~325K SLoC