PyVCG - Verification Condition Generator

raw JSON →
1.0.10 verified Mon Apr 27 auth: no python

A Python library for generating verification conditions (VCs) from an intermediate language (IL) and emitting SMTLIB or interacting with solvers like CVC5 and Z3. Current version 1.0.10, supports Python 3.8+. Release cadence: irregular, with several minor releases in 2023-2024.

pip install pyvcg
error ImportError: cannot import name 'Solver' from 'pyvcg'
cause Old versions or wrong import path; Solver is in the top-level __init__.py.
fix
Use: from pyvcg import Solver
error pyvcg.exceptions.Recursion: Cycle detected in AST
cause You constructed a recursive tree (cycle) which is forbidden since version 1.0.9.
fix
Ensure the AST is a DAG. For self-recursive records, use the add_component method with the record sort itself.
error ValueError: Unsupported Python version. Only Python 3.8 to 3.10 are supported.
cause Old versions of pyvcg (<1.0.8) relied on CVC5 with limited Python support.
fix
Upgrade to pyvcg >=1.0.8 which supports Python 3.11+.
error OSError: libcvc5.so: cannot open shared object file
cause Missing CVC5 native library or incompatible version.
fix
Install cvc5: pip install cvc5 (ensure version matches PyVCG requirements). On Windows, use pyvcg >=1.0.7.
breaking Recursive trees are rejected since version 1.0.9. Attempting to create a cyclic AST raises pyvcg.Recursion.
fix Ensure your AST is a DAG; reuse nodes only without cycles.
deprecated The CVC5 API driver is being phased out in favor of SMTLIB-based driver. The CVC5 API driver may stop working in future releases.
fix Use the SMTLIB driver: set driver='smtlib' when creating Solver.
gotcha CVC5 version 1.0.7 is broken. PyVCG 1.0.3 pins to CVC5 1.0.5. Always match PyVCG's cvc5 dependency version.
fix Use pip install 'cvc5==1.0.5' with PyVCG 1.0.3 or upgrade to a newer PyVCG.
gotcha String literals in SMTLIB output are escaped incorrectly in versions <1.0.2. Non-printable characters and quotes may cause solver parsing errors.
fix Upgrade to pyvcg >=1.0.2.

Create a solver, add a boolean assertion, and check satisfiability.

from pyvcg import Solver, Literal, Sort

solver = Solver()
# Create a boolean constant
p = Literal('p', Sort.Bool)
solver.assert_formula(p)
result = solver.check()
print(result)