Models

What Is First-Order Logic (FOL)?

A formal logical language using predicates, variables, quantifiers, and connectives to express statements about objects and their relations, supporting automated reasoning.

What Is First-Order Logic (FOL)?

First-order logic (FOL), also called first-order predicate logic, is a formal language for expressing claims about objects, properties, and relations. It extends propositional logic with variables, predicates such as Human(x), quantifiers such as ∀ and ∃, and connectives such as ∧, ∨, and →. In LLM evaluation, FOL-shaped tasks test whether a model preserves quantifier scope, entailment direction, and premise-conclusion validity. FutureAGI uses that lens when scoring reasoning traces, RAG entailment, and agent plans.

Why It Matters in Production LLM and Agent Systems

LLMs produce fluent text, not logically valid arguments. The two are easy to confuse. A model can string together a grammatically clean chain-of-thought that quietly reverses a quantifier, conflates “some” with “all,” or applies modus ponens to a conditional whose antecedent it never established. FOL gives you a precise vocabulary for what went wrong. Without that vocabulary, the only debugging tool you have is “the answer feels off.”

The pain shows up in stakes-heavy use cases: legal reasoning over contracts, regulatory compliance over policy text, scientific Q&A over published claims, agent planning over tool preconditions. A backend engineer integrates a contract-analysis LLM and watches it confidently misread a “may” as a “must.” A platform engineer wires an agent to a knowledge graph and sees the agent reason past stated relations because the LLM does not respect the implicit quantifier. A compliance owner cannot prove the LLM’s policy answers are sound — only that they sound right.

In 2026 stacks combining LLMs with neuro-symbolic reasoners, MCP-served knowledge graphs, and retrieval over structured data, FOL competence is a useful filter. It separates models that pattern-match logical surface forms from models that actually preserve quantifier scope and entailment direction. The symptom in logs is usually not a syntax error; it is a plausible answer whose trace shows a missing premise, an inverted relation, or a conclusion stronger than the evidence.

How FutureAGI Handles Logical Reasoning Quality

FutureAGI does not run an FOL theorem prover; we evaluate the outputs of LLMs whose reasoning has FOL structure. The anchor surfaces are ReasoningQuality, FactualConsistency, traceAI-langchain, and the agent.trajectory.step span field.

Concretely: a legal-tech team running a contract-Q&A agent on traceAI-langchain instruments every reasoning step. Each agent.trajectory.step captures the observation, the model’s intermediate claim, and the final answer. ReasoningQuality scores whether the chain is logically valid given those observations, with a 0-1 score and a reason explaining where it broke. FactualConsistency then checks whether the cited clause actually entails the generated claim. That second pass catches the common bug where the model turns “the vendor may terminate after notice” into “the vendor must terminate.”

For datasets, the same evaluators run offline against a curated logic suite: FOL-style problem cases, domain-specific entailment pairs, and adversarial quantifier-scope examples. Scores feed regression evaluation, so a prompt change that improves surface fluency but quietly breaks logical validity is caught before release. FutureAGI’s approach is to make logical validity a first-class evaluator metric alongside fluency and helpfulness — three separate axes that production agents must balance. Unlike Ragas faithfulness, which mainly checks answer-context agreement, this workflow also asks whether each inference step follows from its stated premises.

How to Measure or Detect It

LLM logical correctness is measured by chain validity, entailment accuracy, and downstream task pass rates. Use both online trace checks and offline datasets, because FOL failures often appear only after several turns. Record the evaluator version with every run so prompt and model changes can be compared later:

  • ReasoningQuality — returns 0–1 plus a reason for the validity of an agent’s reasoning chain across the trajectory.
  • FactualConsistency — NLI-based check between a generated claim and provided context.
  • agent.trajectory.step trace review — inspect the exact step where the model introduced a missing premise, reversed a quantifier, or skipped a tool precondition.
  • Per-step pass rate (dashboard signal) — track each chain step independently; an agent that fails one step in five is silently broken on long chains.
  • Quantifier-scope test set — a small held-out set of FOL-shaped problems with all/some/no quantifiers; a sharp regression detector.
  • Argument-correctness cohort — keep premise-conclusion examples separate from arithmetic and retrieval examples, because each failure mode needs a different prompt or fallback.
from fi.evals import ReasoningQuality, FactualConsistency

rq = ReasoningQuality()
result = rq.evaluate(
    input="All humans are mortal. Socrates is a human.",
    output="Therefore Socrates is mortal.",
)
print(result.score, result.reason)

Common Mistakes

These errors often survive unit tests because the final answer still sounds coherent:

  • Treating fluent chain-of-thought as valid. Many fluent chains contain quantifier reversals or undistributed middle terms; check validity, not style.
  • Skipping NLI checks for retrieved-content entailment. A model can paraphrase a clause into a stronger claim than the source supports; FactualConsistency catches this.
  • Using a single overall reasoning score. Aggregate scores hide step-level breaks; track per-step pass rate and inspect the failing trace span.
  • Comparing FOL competence with arithmetic. FOL reasoning and arithmetic reasoning fail differently; keep separate test sets and thresholds.
  • Treating chain-of-thought as the verifier. Use a separate evaluator (or judge model) to grade the chain; the same model cannot reliably check its own logic.

Frequently Asked Questions

What is first-order logic?

First-order logic is a formal language with predicates, variables, quantifiers, and logical connectives that lets you express statements about objects and their relations and supports automated theorem proving.

How is first-order logic different from propositional logic?

Propositional logic deals only with whole statements that are true or false. First-order logic adds variables, predicates, and quantifiers (∀, ∃) so you can reason about classes of objects, not just specific ones.

How does FutureAGI evaluate LLM reasoning involving FOL?

FutureAGI's ReasoningQuality evaluator scores reasoning traces, while FactualConsistency checks whether claims are entailed by reference context. Teams inspect agent.trajectory.step spans for the step that broke.