air_script_core/
expression.rs

1use super::{
2    Identifier, IndexedTraceAccess, ListComprehension, MatrixAccess, NamedTraceAccess, VectorAccess,
3};
4
5/// Arithmetic expressions for evaluation of constraints.
6#[derive(Debug, Eq, PartialEq, Clone)]
7pub enum Expression {
8    Const(u64),
9    /// Represents any named constant or variable.
10    Elem(Identifier),
11    /// Represents an element inside a constant or variable vector. [VectorAccess] contains the
12    /// name of the vector and the index of the element to access.
13    VectorAccess(VectorAccess),
14    /// Represents an element inside a constant or variable matrix. [MatrixAccess] contains the
15    /// name of the matrix and indices of the element to access.
16    MatrixAccess(MatrixAccess),
17    IndexedTraceAccess(IndexedTraceAccess),
18    NamedTraceAccess(NamedTraceAccess),
19    /// Represents a random value provided by the verifier. The first inner value is the name of
20    /// the random values array and the second is the index of this random value in that array
21    Rand(Identifier, usize),
22    Add(Box<Expression>, Box<Expression>),
23    Sub(Box<Expression>, Box<Expression>),
24    Mul(Box<Expression>, Box<Expression>),
25    Exp(Box<Expression>, Box<Expression>),
26    ListFolding(ListFoldingType),
27}
28
29#[derive(Debug, Clone, Eq, PartialEq)]
30pub enum ListFoldingType {
31    Sum(ListComprehension),
32    Prod(ListComprehension),
33}