LLZK 0.1.0
Veridise's ZK Language IR
|
A dependency graph of constraints enforced by an LLZK struct. More...
#include <ConstraintDependencyGraph.h>
Public Member Functions | |
void | dump () const |
Dumps the CDG to stderr. | |
void | print (mlir::raw_ostream &os) const |
Print the CDG to the specified output stream. | |
ConstraintDependencyGraph | translate (ConstrainRefRemappings translation) const |
Translate the ConstrainRefs in this CDG to that of a different context. | |
ConstrainRefSet | getConstrainingValues (const ConstrainRef &ref) const |
Get the values that are connected to the given ref via emitted constraints. | |
ConstraintDependencyGraph (const ConstraintDependencyGraph &other) | |
ConstraintDependencyGraph & | operator= (const ConstraintDependencyGraph &other) |
~ConstraintDependencyGraph ()=default | |
Static Public Member Functions | |
static mlir::FailureOr< ConstraintDependencyGraph > | compute (mlir::ModuleOp mod, component::StructDefOp s, mlir::DataFlowSolver &solver, mlir::AnalysisManager &am) |
Compute a ConstraintDependencyGraph (CDG) | |
A dependency graph of constraints enforced by an LLZK struct.
Mathematically speaking, a constraint dependency graph (CDG) is a transitive closure of edges where there is an edge between signals a
and b
iff a
and b
appear in the same constraint.
Less formally, a CDG is a set of signals that constrain one another through one or more emit operations (constrain.in
or constrain.eq
). The CDG only indicate that signals are connected by constraints, but do not include information about the type of computation that binds them together.
For example, a CDG of the form: { {arg1, arg2, arg3[@foo]} } Means that arg1, arg2, and field @foo of arg3, are connected via some constraints. These constraints could take the form of (in Circom notation): arg1 + arg3[@foo] === arg2 Or arg2 === arg2 / arg3[@foo] Or any other form of constraint including those values.
The CDG also records information about constant values (e.g., felt.const) that are included in constraints, but does not compute a transitive closure over constant values, as constant value usage in constraints does not imply any dependency between signal values (e.g., constraints a + b === 0 and c + d === 0 both use constant 0, but does not enforce a dependency between a, b, c, and d).
Definition at line 100 of file ConstraintDependencyGraph.h.
|
inline |
Definition at line 147 of file ConstraintDependencyGraph.h.
|
default |
|
static |
Compute a ConstraintDependencyGraph (CDG)
mod | The LLZK-complaint module that is the parent of struct s . |
s | The struct to compute the CDG for. |
solver | A pre-configured DataFlowSolver. The liveness of the struct must already be computed in this solver in order for the constraint analysis to run. |
am | A module-level analysis manager. This analysis manager needs to originate from a module-level analysis (i.e., for the mod module) so that analyses for other constraints can be queried via the getChildAnalysis method. |
Definition at line 244 of file ConstraintDependencyGraph.cpp.
void llzk::ConstraintDependencyGraph::dump | ( | ) | const |
Dumps the CDG to stderr.
Definition at line 254 of file ConstraintDependencyGraph.cpp.
ConstrainRefSet llzk::ConstraintDependencyGraph::getConstrainingValues | ( | const ConstrainRef & | ref | ) | const |
Get the values that are connected to the given ref via emitted constraints.
This method looks for constraints to the value in the ref and constraints to any prefix of this value. For example, if ref is an array element (foo[2]), this looks for constraints on foo[2] as well as foo, as arrays may be constrained in their entirety via constrain.in operations.
ref |
Definition at line 510 of file ConstraintDependencyGraph.cpp.
|
inline |
Definition at line 150 of file ConstraintDependencyGraph.h.
void llzk::ConstraintDependencyGraph::print | ( | mlir::raw_ostream & | os | ) | const |
Print the CDG to the specified output stream.
Print all constraints. Any element that is unconstrained is omitted.
os | The LLVM/MLIR output stream. |
Definition at line 257 of file ConstraintDependencyGraph.cpp.
ConstraintDependencyGraph llzk::ConstraintDependencyGraph::translate | ( | ConstrainRefRemappings | translation | ) | const |
Translate the ConstrainRefs in this CDG to that of a different context.
Used to translate a CDG of a struct to a CDG for a called subcomponent.
translation | A vector of mappings of current reference prefix -> translated reference prefix. |
Definition at line 428 of file ConstraintDependencyGraph.cpp.