Analyze Python code for correctness using symbolic execution and SMT solving to automatically find counterexamples for functions with type annotations and contracts.
86
Build a date range validation utility with formal contract specifications. The implementation should include preconditions and postconditions that can be verified to ensure correctness.
Validates that a date falls within a specified range and performs date arithmetic correctly.
Calculates the number of days between two dates and validates business logic constraints.
@generates
from datetime import date, timedelta
def is_date_in_range(start: date, end: date, check: date) -> bool:
"""
Check if a date falls within a specified range (inclusive).
pre: start <= end
post: __return__ == (start <= check <= end)
"""
pass
def add_days_to_date(start: date, days: int) -> date:
"""
Add a specified number of days to a date.
pre: days >= 0
post[start]: __return__ >= start
"""
pass
def days_between(start: date, end: date) -> int:
"""
Calculate the number of days between two dates.
pre: start <= end
post: __return__ >= 0
"""
passProvides symbolic execution and contract verification capabilities for Python code, including support for standard library types like datetime.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-crosshair-toolevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10