First-Order Logic in Artificial Intelligence
This is a free course. Log in to run the code exercises and track your progress.
First-Order Logic in Artificial Intelligence
First-Order Logic (FOL), also called predicate logic, is a knowledge-representation approach in AI for encoding objects, relationships, and rules in a structured form. By extending propositional logic with predicates and quantifiers, it lets AI systems reason over information more powerfully.
- Enables logical inference and knowledge-based reasoning
- More expressive than propositional logic for complex claims
- Frequently used in NLP, expert systems, and theorem proving
Key Components
- Constants: Denote particular objects or entities. Example: Alice, 2, NewYork
- Variables: Stand for unspecified objects or entities. Example: x, y, z
- Predicates: Express properties or relationships. Example: Likes(Alice, Bob) means "Alice likes Bob"
- Functions: Map objects to other objects. Example: MotherOf(x) denotes the mother of x
- Quantifiers: Fix the scope of variables:
- Universal Quantifier (∀): Applies a predicate to every element. Example: \(\forall x \, (Person(x) \rightarrow Mortal(x))\) means "All persons are mortal"
- Existential Quantifier (∃): Asserts that at least one element exists. Example: \(\exists x \, (Person(x) \land Likes(x, IceCream))\) means "Someone likes ice cream"
- Logical Connectives: Include conjunction (\(\land\)), disjunction (\(\lor\)), implication (\(\rightarrow\)), biconditional (\(\leftrightarrow\)) and negation (\(\neg\)).
Syntax, Semantics and Logical Reasoning
FOL syntax spells out how valid logical expressions are built; semantics gives those expressions meaning relative to a domain of interpretation. Together they let AI systems represent knowledge and draw conclusions through logical reasoning.
For example, consider the following statements:
- \(\forall x \, (Cat(x) \rightarrow Mammal(x))\) means “All cats are mammals”
- \(\forall x \, (Mammal(x) \rightarrow Animal(x))\) means “All mammals are animals”
- Cat(Tom) means “Tom is a cat”
Using logical inference, we can derive:
- Mammal(Tom) meaning “Tom is a mammal”
- Animal(Tom) meaning “Tom is an animal”
This demonstrates how First-Order Logic lets AI systems obtain new knowledge from existing facts and relationships.
Advanced Concepts
- Unification: Finds substitutions that make two logical expressions identical. Used in automated reasoning for pattern matching.
- Resolution: Applies inference rules to prove or disprove statements.
- Model Checking: Checks whether a system meets given specifications.
- Logic Programming: Puts FOL to work in languages such as Prolog for AI tasks in NLP and expert systems.
Propositional Logic Vs First-Order Logic
| Parameter | Propositional Logic (PL) | First-Order Logic (FOL) |
|---|---|---|
| Representation | Represents complete statements as true or false | Represents objects, properties, and relationships |
| Quantifiers | Does not use quantifiers | Uses quantifiers like \(\forall\) and \(\exists\) |
| Expressiveness | Limited expressiveness | Highly expressive |
| Reasoning Capability | Handles simple logical reasoning | Supports complex inference and reasoning |
| Applications | Used in simple logical systems | Used in AI, NLP, and expert systems |
Advantages
- Captures complex relationships and rules more effectively than propositional logic
- Supports logical inference to obtain new knowledge from known facts
- Uses quantifiers to state generalizations and existence claims
- Offers a structured framework for knowledge representation and reasoning
Limitations
- Computationally costly for large knowledge bases
- Cannot handle uncertainty well without extensions
- Encoding real-world problems in logic can grow complex
- Some FOL problems are undecidable and have no guaranteed solution
Applications
- Knowledge Representation: Structures objects, properties, and relationships for reasoning
- Automated Theorem Proving: Applies logical rules to prove mathematical claims and verify systems
- Natural Language Processing (NLP): Maps natural language into logical forms for understanding and reasoning
- Expert Systems: Encodes domain knowledge for decisions in areas such as medical or legal assistants
- Semantic Web: Describes relationships among web resources to improve search and retrieval