Skip to main content

Overview

The SMTResults 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

str
required
Path to the SMT solver output file containing SAT/UNSAT result and model
str
required
Path to JSON file containing original sentence data with keys:
  • Claim: The claim portion of the sentence
  • Implication: The implication portion
  • Referring expressions: Entities identified
  • Properties: Properties of entities
  • Formula: The generated FOL formula

Instance Attributes

str
Classification of the formula. Values:
  • "valid statement": Formula is satisfiable (UNSAT in negated form)
  • "logical fallacy": Formula is unsatisfiable (SAT in negated form)
str | None
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:
  1. UNSAT Result: Negation is unsatisfiable → Original formula is valid
  2. 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

Prints the interpretation of SMT results to stdout. Parameters:
bool
default:"True"
Whether to print the counterexample explanation for fallacies
Output Format:

Input File Formats

SMT Solver Output File

Expected format:
Or:

Sentence Data JSON File

Required structure:

Counterexample Generation

When a fallacy is detected, the class:
  1. Loads the original sentence data from JSON
  2. Reads the prompt template from prompt_counter_example.txt
  3. Formats the prompt with:
    • Original claim and implication
    • Referring expressions and properties
    • The FOL formula
    • The SMT solver’s model (counterexample)
  4. Sends to LLM via get_llm_result()
  5. Stores the natural language explanation in self.counter_example
The get_llm_result() function must be defined in llm.py module. Ensure this module is available and properly configured with API credentials.

Complete Usage Example

Command-Line Usage

Error Handling

Integration with Evaluation

Dependencies

The module requires:
  • llm.py: Must define get_llm_result(prompt) function
  • json: Standard library for JSON parsing
  • sys: Standard library for command-line arguments
  • prompt_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