[solvers/symex] Add minimal symbolic execution engine - #4887
Draft
copybara-service[bot] wants to merge 1 commit into
Draft
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test_972273562
branch
2 times, most recently
from
September 2, 2026 21:31
5b21b49 to
59ac299
Compare
copybara-service
Bot
force-pushed
the
test_972273562
branch
from
September 10, 2026 05:56
59ac299 to
baa3dc8
Compare
copybara-service
Bot
force-pushed
the
test_972273562
branch
from
September 10, 2026 07:04
baa3dc8 to
aca6fa9
Compare
Implements a symbolic execution engine for XLS IR functions that systematically
discovers feasible execution paths through multiplexers and generates concrete
test vectors for each path.
Architecture:
Uses a clean, decoupled two-phase architecture:
1. Up-front IR Encoding (Z3EncodingVisitor):
The entire function DAG is translated into Z3 ASTs in a single post-order
pass up-front. By subclassing IrTranslator, all 50+ IR op translations
(arithmetic, bitwise, tuples, bit-slices, comparisons) are reused directly.
Multiplexers (Select, PrioritySelect) are intercepted and translated as
unconstrained symbolic SSA variables rather than folded into monolithic
nested ite(...) trees.
2. Incremental SMT Decision-Tree Traversal (SymExEngine):
Path exploration operates as a depth-first search over multiplexer branch
choices in topological order. At each branch, a solver frame is pushed
(Z3_solver_push), the branch condition (C_k) and arm equality (V_mux == A_k)
are asserted, and satisfiability is checked. Unsatisfiable branches are
pruned immediately, backtracking early without exploring downstream nodes.
3. Leaf Test Generation:
When a feasible leaf is reached, concrete satisfying parameter assignments
are extracted from the solver model into a SymbolicPath.
Files:
- symex_engine.{h,cc}: Path exploration engine and solver orchestration.
- z3_encoding_visitor.{h,cc}: Subclass of IrTranslator providing free SSA mux
variables and branch condition / arm equality encodings.
- z3_ir_translator.h: Moved context-borrowing constructor and NoteTranslation
to protected, and added translations() const accessor to enable subclass
extension.
- symbolic_path.{h,cc}: Data structures for paths, decisions, and tests.
- Tests:
- symex_engine_test.cc: Path exploration, early pruning, and coverage.
- z3_encoding_visitor_test.cc: Opcode, tuple, and mux translation.
- symbolic_path_test.cc: Path condition and test vector accessors.
- symex_e2e_test.cc: E2E ALU execution test with interpreter validation.
PiperOrigin-RevId: 972273562
copybara-service
Bot
force-pushed
the
test_972273562
branch
from
September 11, 2026 07:17
aca6fa9 to
c25e521
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[solvers/symex] Add minimal symbolic execution engine
Implements a symbolic execution engine for XLS IR functions that systematically
discovers feasible execution paths through multiplexers and generates concrete
test vectors for each path.
Architecture:
Uses a clean, decoupled two-phase architecture:
Up-front IR Encoding (Z3EncodingVisitor):
The entire function DAG is translated into Z3 ASTs in a single post-order
pass up-front. By subclassing IrTranslator, all 50+ IR op translations
(arithmetic, bitwise, tuples, bit-slices, comparisons) are reused directly.
Multiplexers (Select, PrioritySelect) are intercepted and translated as
unconstrained symbolic SSA variables rather than folded into monolithic
nested ite(...) trees.
Incremental SMT Decision-Tree Traversal (SymExEngine):
Path exploration operates as a depth-first search over multiplexer branch
choices in topological order. At each branch, a solver frame is pushed
(Z3_solver_push), the branch condition (C_k) and arm equality (V_mux == A_k)
are asserted, and satisfiability is checked. Unsatisfiable branches are
pruned immediately, backtracking early without exploring downstream nodes.
Leaf Test Generation:
When a feasible leaf is reached, concrete satisfying parameter assignments
are extracted from the solver model into a SymbolicPath.
Files:
variables and branch condition / arm equality encodings.
to protected, and added translations() const accessor to enable subclass
extension.