Artificial Intelligence - First Logic Order

AI - First Logic Order (Fully Explained)

Artificial Intelligence - First Logic Order

Propositional Logic vs First-Order Logic

Propositional logic is all about basic statements — things that are either true or false. Straightforward. But here’s the thing: it doesn’t go very far. It can’t really describe relationships between things or easily express general rules.

Take this: “The sky is hot.” Propositional logic? It’ll only say, “Yep, that’s true,” or “Nope, that’s false.” It can’t dig deeper — like linking the heat to the sun or explaining why it’s hot.

Or let’s say you want to state, “All students in a class like math.” With propositional logic, you’d have to write out one statement for every single student. That’s fine for five students — not so fine for five hundred.

This is where First-Order Logic (FOL) comes in. It extends propositional logic by adding quantifiers (like “all” or “some”) and variables. Basically, it helps express those big, general statements without writing a hundred separate lines.


First-Order Logic in Artificial Intelligence

FOL — also called Predicate Logic — is like propositional logic’s big brother. It doesn’t just label a statement as true or false. It lets us describe relationships between objects, rules, and statements about entire groups.

That makes it super useful in AI. Why? Because AI often needs to work with rules like “If someone buys a product, they get a receipt” — rules that apply to everyone, not just one person.


Key Components of First-Order Logic

FOL works using several building blocks. Here’s a breakdown:

  • Constants: Fixed values or objects. Examples: India, Bob, 7, Apple.
  • Variables: Placeholders that can represent different values. Think of x, y, z. If your domain is students, x could mean any student in that group.
  • Predicates: Statements about objects or their relationships. Example: Father(John, Robert) says “John is Robert’s father.”
  • Functions: Take an input and return a single value. Example: Age(Alice) = 25 means Alice’s age is 25.
  • Quantifiers: Say whether a statement applies to all objects (∀x) or at least one (∃x). Example: ∀x Likes(x,Math) means “Every student likes math.”
  • Logical Connectives: Combine statements into more complex ones. Example: CompletesTraining(x) → EligibleForPromotion(x) means “If an employee completes training, they’re eligible for promotion.”


Logical Components in Formal Logic

Here’s a quick summary table:

ComponentExamples
Constants1, 5, Apple, Bob, India
Variablesx, y, z, a, b
PredicatesFather, Teacher, Brother
Functionssqrt, AgeOf, LeftLegOf
Quantifiers∀ (for all), ∃ (there exists)
Connectives∧ (and), ∨ (or), ¬ (not), → (implies), ↔ (if and only if)

Syntax and Semantics of First-Order Logic

  • Syntax: This is how you write a proper statement — using constants, variables, predicates, etc.
  • Semantics: This is the meaning behind those statements — how they map to real-world ideas.

Example:
Take this sentence: “Every customer who buys something gets an invoice.”

In FOL:
∀x (Customer(x) ∧ Purchases(x,Product) → ReceivesInvoice(x))

Here, syntax is how it’s written. Semantics is interpreting it: “All customers who purchase something get an invoice.”


Quantifiers in First-Order Logic

Quantifiers let you talk about all objects or some objects in a group.

  • Universal Quantifier (∀): “For every.”

Example: “All employees follow the rules.”

∀x (Employee(x) → FollowsRules(x))

  • Existential Quantifier (∃): “There exists at least one.”

Example: “There’s at least one employee who got promoted.”

∃x (Employee(x) ∧ ReceivedPromotion(x))


Sentences in First-Order Logic

In FOL, you’ve got two types:

  • Atomic Sentences: Basic statements without logical connectors.

Example: Teacher(John, Mathematics) means John teaches Mathematics.

  • Complex Sentences: Combine atomic ones with AND, OR, NOT, etc.

Examples:

∃y (Teacher(y) ∧ Teaches(y,Math)) – “There’s at least one teacher who teaches math.”

∀x (Customer(x) → Buys(x,OnlineCourses)) – “All customers buy online courses.”


Free and Bound Variables

  • Free Variables: Not controlled by a quantifier.

Example: P(y) — here, y could be anything.

  • Bound Variables: Controlled by a quantifier.

Example: ∃y (Price(y) < 10) — here, y is bound to “products with a price under 10.”


Challenges and Limitations of FOL

FOL is powerful, but not perfect.

  • Uncertainty: It only works with statements that are completely true or false.
  • Complexity: Large datasets make it slow to process.
  • Limited Flexibility: It struggles with vague ideas like “most people” or “around 10.”
  • Rigid Structure: Every rule must be defined explicitly.
  • Lack of Common Sense: It can’t make assumptions the way humans do.