CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-crosshair-tool

Analyze Python code for correctness using symbolic execution and SMT solving to automatically find counterexamples for functions with type annotations and contracts.

86

1.24x
Overview
Eval results
Files

task.mdevals/scenario-2/

Symbolic Value Generator

A Python utility that generates symbolic values for testing and constraint solving. The generator creates symbolic representations of Python types that can be used in symbolic execution and validation scenarios.

Capabilities

Generate symbolic primitives

  • Given a primitive type (int, str, bool), the generator creates a symbolic value of that type. @test
  • When generating a symbolic integer named "x", it returns a symbolic value that behaves like an integer. @test

Generate symbolic collections

  • Given a list type, the generator creates a symbolic list with symbolic elements. @test
  • Given a dictionary type, the generator creates a symbolic dictionary structure. @test

Implementation

@generates

API

from typing import Any, Type

class SymbolicValueGenerator:
    """
    A generator that creates symbolic values for different Python types.
    """

    def create_symbolic(self, type_hint: Type, name: str = "sym") -> Any:
        """
        Creates a symbolic value of the specified type.

        Args:
            type_hint: The Python type to generate a symbolic value for
            name: A variable name for the symbolic value (default: "sym")

        Returns:
            A symbolic value that represents the given type and can be
            used in constraint solving and symbolic execution

        Raises:
            TypeError: If the type is not supported for symbolic generation
        """
        pass

    def realize(self, symbolic_value: Any) -> Any:
        """
        Converts a symbolic value to a concrete value.

        Args:
            symbolic_value: A symbolic value to convert

        Returns:
            A concrete Python value
        """
        pass

Dependencies { .dependencies }

crosshair-tool { .dependency }

Provides symbolic execution and type proxy support for generating symbolic values.

Install with Tessl CLI

npx tessl i tessl/pypi-crosshair-tool

tile.json