tessl install tessl/pypi-crosshair-tool@0.0.0Analyze Python code for correctness using symbolic execution and SMT solving to automatically find counterexamples for functions with type annotations and contracts.
Agent Success
Agent success rate when using this tile
86%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.25x
Baseline
Agent success rate without this tile
69%
Build a plugin that extends a symbolic execution tool to support custom contract verification for a domain-specific type.
You are building support for a Coordinate class that represents geographic coordinates with latitude and longitude values. The plugin must enable symbolic analysis of functions that use this custom type.
Implement a plugin that registers symbolic value creation for the Coordinate type. The plugin should:
Add programmatic contract registration for a third-party function calculate_distance(coord1, coord2) that computes distance between coordinates. Register contracts that specify:
find_nearest(target, locations) that returns the closest location to a target coordinate, the plugin enables finding counterexamples when the function violates its postcondition. @testcalculate_distance are enforced during analysis, catching violations where the function returns negative distances. @test@generates
class Coordinate:
"""Represents a geographic coordinate with latitude and longitude."""
def __init__(self, lat: float, lon: float):
pass
@property
def lat(self) -> float:
pass
@property
def lon(self) -> float:
pass
def calculate_distance(coord1: Coordinate, coord2: Coordinate) -> float:
"""Calculate distance between two coordinates in kilometers."""
pass
def find_nearest(target: Coordinate, locations: list[Coordinate]) -> Coordinate:
"""
Find the nearest coordinate from a list of locations.
post: __return__ in locations
post: all(calculate_distance(target, __return__) <= calculate_distance(target, loc) for loc in locations)
"""
pass
def setup_plugin():
"""
Configure the plugin by registering symbolic type creators and contracts.
This function should be called to initialize the plugin.
"""
passProvides symbolic execution and contract verification capabilities.