> ## 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.

# Logical Fallacies

> Understanding the logical fallacies detected by NL2FOL

## What are Logical Fallacies?

Logical fallacies are errors in reasoning that undermine the logic of an argument. They occur when conclusions don't follow logically from their premises, even if the premises themselves are true.

<Info>
  The NL2FOL system is designed to detect logical fallacies by translating natural language arguments into first-order logic and using SMT solvers to check their validity.
</Info>

## Why First-Order Logic for Fallacy Detection?

First-order logic provides a formal framework that:

* **Precisely represents** the structure of arguments
* **Eliminates ambiguity** present in natural language
* **Enables automated verification** using SMT solvers
* **Reveals hidden assumptions** in reasoning

<Tip>
  By converting an argument to FOL, we can determine if a conclusion logically follows from its premises or if the reasoning contains a flaw.
</Tip>

## Primary Fallacy: Hasty Generalization

The NL2FOL system focuses primarily on detecting **hasty generalizations** (also called faulty generalizations), which is one of the most common logical fallacies.

### Definition

A hasty generalization occurs when someone draws a broad conclusion from insufficient or unrepresentative evidence.

<CardGroup cols={2}>
  <Card title="Structure" icon="diagram-project">
    * **Premise**: A specific observation or limited sample
    * **Conclusion**: A universal claim about all cases
  </Card>

  <Card title="Why It's Fallacious" icon="x">
    The leap from "some" or "one" to "all" is not logically justified without sufficient evidence
  </Card>
</CardGroup>

### Examples from the Dataset

The system is trained on thousands of real-world examples from `data/fallacies.csv`:

<Accordion title="Example 1: Personal Experience → Universal Claim">
  **Fallacy**: "Annie must like Starbucks because all white girls like Starbucks."

  **Analysis**:

  * Claim: Some white girls like Starbucks (limited observation)
  * Implication: ALL white girls like Starbucks (universal claim)
  * Flaw: Generalizes from limited experience to entire population

  **FOL Representation**:

  ```
  exists x (IsWhiteGirl(x) and LikesStarbucks(x)) 
    -> forall y (IsWhiteGirl(y) -> LikesStarbucks(y))
  ```
</Accordion>

<Accordion title="Example 2: Single Instance → All Cases">
  **Fallacy**: "The two courses I took at UF were not very interesting. I don't think it's a good university."

  **Analysis**:

  * Claim: Two courses at UF were not interesting (n=2)
  * Implication: UF is not a good university (judgment of entire institution)
  * Flaw: Two courses are insufficient to evaluate an entire university

  **FOL Representation**:

  ```
  exists x (IsCourseAtUF(x) and NotInteresting(x)) 
    -> forall y (IsCourseAtUF(y) -> NotInteresting(y))
  ```
</Accordion>

<Accordion title="Example 3: Geographic Stereotype">
  **Fallacy**: "A driver with a New York license plate cuts you off in traffic. You decide that all New York drivers are terrible drivers."

  **Analysis**:

  * Claim: One NY driver drove poorly (single instance)
  * Implication: All NY drivers are terrible (universal generalization)
  * Flaw: One driver's behavior doesn't represent all drivers from that region

  **FOL Representation**:

  ```
  exists x (IsNYDriver(x) and DrivesTerribly(x)) 
    -> forall y (IsNYDriver(y) -> DrivesTerribly(y))
  ```
</Accordion>

<Accordion title="Example 4: Professional Generalization">
  **Fallacy**: "Look at people like Michael Vick and OJ Simpson. Professional athletes really have no sense of morality."

  **Analysis**:

  * Claim: Two athletes exhibited immoral behavior
  * Implication: All professional athletes have no sense of morality
  * Flaw: Cherry-picking examples to condemn an entire profession

  **FOL Representation**:

  ```
  exists x (IsProfessionalAthlete(x) and NotMoral(x)) 
    -> forall y (IsProfessionalAthlete(y) -> NotMoral(y))
  ```
</Accordion>

## The Dataset

The system uses multiple datasets for training and evaluation:

### Fallacies Dataset

```python theme={null}
# From src/nl_to_fol.py:389-420
def setup_dataset(fallacy_set='logic',length=100):
    if fallacy_set=='logic':
        df_fallacies=pd.read_csv('data/fallacies.csv')
        df_fallacies['label']=[0]*len(df_fallacies)  # 0 = fallacy
        df_fallacies=df_fallacies[['source_article','label','updated_label']]
    
    df_valids=pd.read_csv('data/nli_entailments_test.csv')
    df_valids['label']=[1]*len(df_valids)  # 1 = valid reasoning
```

<Note>
  The system uses a **binary classification** approach:

  * Label 0: Logical fallacy (invalid reasoning)
  * Label 1: Valid logical reasoning
</Note>

### Dataset Statistics

From `data/fallacies.csv`:

* **Total examples**: 230+ unique fallacy instances
* **Primary category**: Faulty generalization / Hasty generalization
* **Sources**: Quiz questions, educational materials, real-world examples
* **Categories**: Personal stereotypes, professional generalizations, cultural biases, statistical misuse

## Common Patterns in Hasty Generalizations

### Pattern 1: Personal Experience

```
Structure: "My [experience] was [quality], so [universal statement]"

Examples:
- "My roommate's philosophy class was hard, so ALL philosophy classes must be hard"
- "Pain-Away worked for me, so it's sure to work for you, too"
```

### Pattern 2: Small Sample Size

```
Structure: "I observed [small number] of [group], therefore [all of group]"

Examples:
- "Four out of five dentists recommend this toothpaste, therefore it must be great"
- "I asked six friends and they agreed, so this is generally popular"
```

### Pattern 3: Stereotyping

```
Structure: "[Individual from group] has [property], therefore [all group members] have [property]"

Examples:
- "Fred, the German, stole my wallet. Therefore, all Germans are thieves"
- "All women care about are their looks"
```

### Pattern 4: Temporal Fallacy

```
Structure: "[Event] happened [once/recently], therefore [always/all time]"

Examples:
- "It's warmer this year in Las Vegas, therefore global warming is rapidly accelerating"
- "My first day was easy, so it will always be easy"
```

## Detecting Fallacies with FOL

The key insight is that hasty generalizations have a characteristic logical structure:

<CardGroup cols={1}>
  <Card title="Fallacious Pattern" icon="xmark">
    ```
    exists x (P(x) and Q(x)) -> forall y (P(y) -> Q(y))
    ```

    "Because some x has properties P and Q, all things with property P have property Q"

    This is **logically invalid** - the existence of one or few instances doesn't prove a universal rule.
  </Card>
</CardGroup>

### Why This Formula is Invalid

When we check this with an SMT solver:

1. The solver attempts to find a model where the negation is true
2. The negation: `NOT(exists x (P(x) and Q(x)) -> forall y (P(y) -> Q(y)))`
3. This is satisfiable when:
   * There exists at least one x with P(x) and Q(x) (the observed case)
   * There exists at least one y with P(y) but NOT Q(y) (a counterexample)
4. Since such a model exists, the original formula is **invalid**

<Tip>
  The SMT solver returns **SAT** (satisfiable) for the negation, indicating the argument is fallacious.
</Tip>

## Beyond Hasty Generalization

While the system focuses on hasty generalization, the framework can be extended to other fallacy types:

<CardGroup cols={2}>
  <Card title="Appeal to Authority" icon="user-crown">
    Accepting a claim based solely on authority rather than evidence

    Example: "Experts say it, so it must be true"
  </Card>

  <Card title="False Cause" icon="link-slash">
    Assuming causation from correlation

    Example: "My dog was sprayed by a skunk on the trail, therefore trail running is dangerous"
  </Card>

  <Card title="Circular Reasoning" icon="rotate">
    Using the conclusion as a premise

    Example: "The Bible is true because it says so in the Bible"
  </Card>

  <Card title="False Dilemma" icon="code-fork">
    Presenting only two options when more exist

    Example: "You're either with us or against us"
  </Card>
</CardGroup>

## Practical Applications

<Info>
  Understanding logical fallacies is crucial for:

  * **Critical thinking**: Evaluating arguments in media, politics, and daily life
  * **Argument construction**: Building sound logical arguments
  * **Debate**: Identifying weak reasoning in opposing arguments
  * **Research**: Avoiding flawed conclusions from data
  * **AI/ML**: Training systems to reason more accurately
</Info>

## Next Steps

<CardGroup cols={2}>
  <Card title="First-Order Logic" icon="function" href="/concepts/first-order-logic">
    Learn the formal logic system used for fallacy detection
  </Card>

  <Card title="Translation Pipeline" icon="diagram-project" href="/concepts/translation-pipeline">
    See how natural language is converted to logical formulas
  </Card>

  <Card title="SMT Solving" icon="gear" href="/concepts/smt-solving">
    Understand how solvers verify logical validity
  </Card>

  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Try detecting fallacies yourself
  </Card>
</CardGroup>
