Overview
Thefol_to_cvc.py script converts first-order logic formulas into SMT-LIB format and executes the CVC4 solver to check satisfiability. This determines whether logical arguments are valid or contain fallacies.
How It Works
Interpret Results
Maps solver output to validity classification:
unsat= Valid argumentsat/unknown= Logical fallacy (LF)
Command Usage
Basic Command
Parameters
The name of the run from nl_to_fol.py. The script will:
- Read from:
results/<run_name>.csv - Create SMT files in:
results/<run_name>_smt/ - Save results to:
results/<run_name>_results.csv
Example Usage
Prerequisites
SMT-LIB Format
The FOL formulas are converted to SMT-LIB2 format. The system handles:Operator Conversions
| FOL Syntax | SMT-LIB Syntax |
|---|---|
ForAll | forall |
ThereExists | exists |
& | and |
~ | not |
-> | Implication operator |
Example Conversion
Input FOL:Output Files
For each datapointi, the script generates:
SMT Files
results/<run_name>_smt/i.smt2
The SMT-LIB formatted formula file.
results/<run_name>_smt/i_out.txt
The solver output containing:
- First line:
sat,unsat, orunknown - Remaining lines: Counter-model (if sat)
Results CSV
results/<run_name>_results.csv
Adds a result column to the original CSV:
Valid- Formula is unsatisfiable (valid argument)LF- Formula is satisfiable or unknown (logical fallacy)- Empty string - Processing error
Finite Model Finding
When the solver returnsunknown, the script automatically retries with finite model finding:
Finite model finding can significantly increase solving time but improves coverage for complex formulas.
Understanding Results
UNSAT (Valid Argument)
When the SMT solver returnsunsat, it means:
- The negation of the formula is unsatisfiable
- No counter-example exists
- The original argument is logically valid
SAT (Logical Fallacy)
When the SMT solver returnssat, it means:
- A counter-example exists
- The argument contains a logical fallacy
- The model shows why the implication doesn’t hold
Unknown
When the solver returnsunknown:
- The formula is too complex for automatic decision
- Classified as potential fallacy (conservative approach)
- Retry with finite model finding may resolve
Processing Flow
Performance Considerations
Error Handling
The script includes comprehensive error handling:CVCGenerator Class
TheCVCGenerator class (from cvc.py) handles:
- FOL parsing
- SMT-LIB syntax generation
- Sort and function declarations
- Formula negation (for validity checking)
The solver checks the negation of the formula. If the negation is unsatisfiable, the original formula is valid.
Troubleshooting
Common Issues
CVC4 not found- Check that FOL formulas are well-formed
- Verify all operators are properly converted
- Review
Logical Form 2column for malformed expressions
Alternative Solvers
While the script uses CVC4, you can adapt it for other SMT solvers: CVC5 (newer version)Next Steps
After generating SMT results:- Interpret individual results with counter-examples using
interpret_smt_results.py - Evaluate overall performance using
get_metrics.py - Analyze error cases and improve FOL translation
