Documentation Index
Fetch the complete documentation index at: https://mintlify.com/lovishchopra/NL2FOL/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheSMTResults class interprets the output from SMT solvers (like CVC5) to determine whether a first-order logic formula represents a valid statement or contains a logical fallacy. It also uses LLMs to generate human-readable counterexamples when fallacies are detected.
Class Definition
Parameters
Path to the SMT solver output file containing SAT/UNSAT result and model
Path to JSON file containing original sentence data with keys:
Claim: The claim portion of the sentenceImplication: The implication portionReferring expressions: Entities identifiedProperties: Properties of entitiesFormula: The generated FOL formula
Instance Attributes
Classification of the formula. Values:
"valid statement": Formula is satisfiable (UNSAT in negated form)"logical fallacy": Formula is unsatisfiable (SAT in negated form)
Human-readable counterexample generated by LLM (only for logical fallacies)
How It Works
The SMT solver receives the negation of the original formula. The interpretation logic:- UNSAT Result: Negation is unsatisfiable → Original formula is valid
- SAT Result: Negation is satisfiable → Original formula is invalid (fallacy)
When the solver returns SAT, it provides a model (counterexample) showing variable assignments that make the negated formula true, thereby disproving the original claim.
Methods
get_results
Whether to print the counterexample explanation for fallacies
Input File Formats
SMT Solver Output File
Expected format:Sentence Data JSON File
Required structure:Counterexample Generation
When a fallacy is detected, the class:- Loads the original sentence data from JSON
- Reads the prompt template from
prompt_counter_example.txt - Formats the prompt with:
- Original claim and implication
- Referring expressions and properties
- The FOL formula
- The SMT solver’s model (counterexample)
- Sends to LLM via
get_llm_result() - Stores the natural language explanation in
self.counter_example
Complete Usage Example
Command-Line Usage
Error Handling
Integration with Evaluation
Dependencies
The module requires:llm.py: Must defineget_llm_result(prompt)functionjson: Standard library for JSON parsingsys: Standard library for command-line argumentsprompt_counter_example.txt: Prompt template file
Ensure
prompt_counter_example.txt exists in the working directory with appropriate placeholders for claim, implication, referring expressions, properties, formula, and counter model.See Also
- NL2FOL - Generate FOL formulas from natural language
- CVCGenerator - Create SMT solver input files
- Helper Functions - Utility functions for processing
