Home Knowledge Base Symbolic execution

Symbolic execution is a program analysis technique that executes programs with symbolic inputs rather than concrete values — exploring multiple execution paths simultaneously by representing inputs as symbols and tracking constraints on those symbols, enabling systematic path exploration and automated test generation.

What Is Symbolic Execution?

How Symbolic Execution Works

1. Initialize: Start with symbolic inputs (α, β, γ, ...).

2. Execute Symbolically: Interpret program operations symbolically.

3. Branch Handling: At conditional branches, fork execution.

4. Constraint Collection: Accumulate path constraints.

5. Constraint Solving: Use SMT solver to check satisfiability.

6. Test Generation: For each feasible path, generate concrete test input.

Example: Symbolic Execution

def test_function(x, y):
    z = x + y
    if z > 10:
        if x > 5:
            return "A"  # Path 1
        else:
            return "B"  # Path 2
    else:
        return "C"  # Path 3

# Symbolic execution with inputs x=α, y=β:

# Path 1: z > 10 AND x > 5
# Constraints: α + β > 10 AND α > 5
# Solver finds: α=6, β=5 → test_function(6, 5) = "A"

# Path 2: z > 10 AND x <= 5
# Constraints: α + β > 10 AND α <= 5
# Solver finds: α=5, β=6 → test_function(5, 6) = "B"

# Path 3: z <= 10
# Constraints: α + β <= 10
# Solver finds: α=3, β=2 → test_function(3, 2) = "C"

# Result: 3 test cases covering all paths!

Applications

Symbolic Execution Tools

Challenges

Optimization Techniques

Concolic Execution (Concrete + Symbolic)

1. Execute program concretely with random input. 2. Collect path constraints symbolically during execution. 3. Negate one constraint to explore alternative path. 4. Solve constraints to generate new input. 5. Repeat with new input.

Example: Finding Buffer Overflow

void vulnerable(char *input) {
    char buffer[10];
    if (strlen(input) > 10) {
        return;  // Safe path
    }
    strcpy(buffer, input);  // Potential overflow
}

// Symbolic execution:
// Input: input = symbolic string α
// Path 1: strlen(α) > 10 → return (safe)
// Path 2: strlen(α) <= 10 → strcpy(buffer, α)
//   - If strlen(α) == 10, strcpy writes 11 bytes (including null)
//   - Buffer overflow detected!
// Generated test: input = "0123456789" (10 chars)
// Triggers overflow!

LLMs and Symbolic Execution

Benefits

Limitations

Symbolic execution is a powerful program analysis technique — it systematically explores program paths to generate tests, find bugs, and verify properties, providing deeper analysis than random testing but with scalability challenges that require careful engineering.

symbolic executionsoftware engineering

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.