Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
18 views75 pages

AI Lecture 4 Logic

The document provides an overview of logic, emphasizing its role in reasoning and argument analysis. It categorizes logic into formal and informal types, detailing various specialized logics such as modal, deontic, and fuzzy logic. Additionally, it explains propositional logic, logical connectives, and the construction of truth tables to evaluate logical statements.

Uploaded by

vkhbrn52nr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views75 pages

AI Lecture 4 Logic

The document provides an overview of logic, emphasizing its role in reasoning and argument analysis. It categorizes logic into formal and informal types, detailing various specialized logics such as modal, deontic, and fuzzy logic. Additionally, it explains propositional logic, logical connectives, and the construction of truth tables to evaluate logical statements.

Uploaded by

vkhbrn52nr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 75

Artificial Intelligence

Logic
Logic?
• In general, logic is the study of correct reasoning.
• This includes how to identify good arguments and avoid bad ones.
• It helps us ensure our thinking is clear and our conclusions follow from our
evidence.
• More specifically, logic can refer to the field of formal logic.
• This is a branch of mathematics that studies the structure of valid
arguments.
• It uses symbols and rules to analyze arguments without worrying about the
specific content.
Logic?
• Logic is essentially the toolbox for good reasoning.
• It equips you to distinguish between strong arguments and weak ones.
• Here's a breakdown of the concept:
• Core principle: Logic is the study of how to arrive at well-
founded conclusions.
• Focus: It emphasizes analyzing information and arguments based
on reason and evidence, steering clear of emotions or biases.
• Applications: Logic is used in various fields like math, philosophy,
and computer science, but also in everyday situations where we
need to make sound judgments.
Categories/Types of Logic
1. Formal vs. Informal Logic
• Formal Logic: This is the technical side, using symbols and strict rules to
analyze the structure of arguments. It focuses on whether the form of the
argument guarantees a true conclusion if the starting statements (premises)
are true. Examples include:
• Propositional Logic: Deals with basic statements (propositions) like "It is
raining" and explores how they can be combined (AND, OR, NOT) to form
more complex statements.
• First-Order Logic: Expands on propositional logic by allowing variables and
quantifiers (all, some, none) to represent objects and properties.
• Informal Logic: This deals with arguments expressed in everyday language. It
equips you to analyze arguments based on their content and structure, identify
fallacies (errors in reasoning) like hasty generalizations or post hoc fallacies,
and evaluate the strength of the argument.
Categories/Types of Logic (Cont’)
2. Other Specialized Logics
Beyond the formal/informal divide, there are various forms of logic that focus on
specific areas:
• Modal Logic: Deals with possibility, necessity, and obligation. Useful in fields
like philosophy and computer science.
• Deontic Logic: Focuses on concepts of obligation, permission, and prohibition.
Relevant in legal reasoning and ethics.
• Fuzzy Logic: Used in situations where there are degrees of truth (not just true
or false). Useful in control systems and artificial intelligence.
• Higher-order logic (HOL): is a powerful type of formal logic that expands on
the capabilities of first-order logic.
• Aristotelian logic, Euclidean geometry, Peano axioms, Zermelo Fraenkel set
theory, etc
• By understanding logic, you can:
• Think critically: You can assess information objectively and
avoid being swayed by misleading arguments.
• Strengthen your arguments: You can learn how to present
your ideas in a clear and convincing way.
• Solve problems: You can approach challenges in a logical
and systematic manner.

6
Propositional Logic
• Propositional logic, also sometimes called sentential logic or statement
logic, is the foundation of formal logic.
• It deals with the relationships between basic statements, also known as
propositions.
• A statement is a verbal or written assertion.
• A proposition is a statement that is either true or false, but not both.
• We say that the truth value of a proposition is either true (T) or false (F).

• Corresponds to 1 and 0 in digital circuits

7
Statement/Proposition

• “Elephants are bigger than mice.”

Is this a statement? yes

Is this a proposition? yes

What is the truth


value true
of the proposition?
8
Propositional Logic
Simple and Compound statements

A statement may be a simple/atomic statement Or a compound


statement.
For example, “Kofi is a bad boy” is a simple statement which can be either
true or false.
Two or more simple statements can also be combined to form a compound
statement. For example, “Kofi is a bad boy” and “kofi is a thief” are two simple
statements which can be combined to form a compound statement “If Kofi is a
bad boy then Kofi is a thief”. 9
Propositional Logic
• In Logic, we use letters to represent simple statements.

• For example,

• p:Kofi is a student.

• q: Kofi is in form five.

• The basic property of any statement is, it is either true (T) or false (F) and
cannot be true or false at the same time.

10
Logical connectives or operators
The basic logical operators are

 Conjunction (AND or ∧ )

 Disjunction (OR or ∨)

 Negation (NOT or ~)

 Implication/Conditional (IF…THEN) (⇒) (→)

 Equivalence/Biconditional (IF AND ONLY IF) (↔)

These may be used to combine two simple statements to form a


compound statement. 11
Converse statements
The converse of a statement is the reverse form of the statement.
a. Converse of Implication
Consider the following simple statements.
p: Abena has measles
q: Abena is in the hospital
The converse of the compound statement ‘If Abena has measles then Abena is
in the hospital’ is ‘If Abena is in the hospital then Abena has measles’.
Note: the converse of any compound statement is not always true. That is if the
compound statement ‘If Abena has measeles then Abena is in the hosital’ is
true it does not aways follow that ‘If Abena is in the hospital then Abena has
measles. i.e. if p→q is true then the converse statement q→p is not always
true and therefore not valid.
12
Converse statements
b. Converse of conjunction (AND)

Consider the following statements:

p: Kofi is a student

q: Kofi is in form five

The converse of the compound statement: “Kofi is a student and in form five” is
‘Kofi is in form five and a student’. This converse statement is true only when the
compound statement is true.

i.e. if p∧q is true then the converse statement q∧p is also true.13
Converse statements
c. Converse of disjunction (OR)

Consider the following statements:

p: Kofi is a student

q: Ama is in form five

The converse of the compound statement: “Either Kofi is a student or Ama is in


form five” is ‘Either Ama is in form five or Kofi is a student’

This converse statement is true only when the compound statement is true.

i.e. if p∨q is true then the converse statement q∨p is also true.14
The truth table
• The truth table is used to show whether two logical expressions are the same
or not.

• It also shows how the truth of a compound statement depends on the truth of
its component simple statements.

• The truth table gives all posible truth values of it components.

• In truth tables, we represent truth by T and false by F.

15
And () (Conjunction)
Two simple statements p and q can be combined by the word “AND” to form a
compound statement “p and q”.

The compound statement p and q is also represented as p ^ q.

For example, p: Kofi is a student and q: Kofi is in form five, can be combined as “
Kofi is a student and in form five”.

Thus we write p and q or p ^ q.

The compound statement p ^ q is true only when both p and q are true.

Otherwise it is false. 16
And () (Conjunction) cont’
• The table below is the truth table for p  q
p q pq

T T T

T F F

F T F

F F F

 The first two columns give the four possible values of p and q. The third column if for p  q.
 For the first row p is the true (T) and q is also true (T), therefore p  q is true since both p and q are true.
 For the other three rows p  q is false since both p and q are not true.
 Note that the compound statement p  q is true only when p and q are both true.
17
‘Or’ (Disjunction)
When two statements are connected by the word “OR”, the result of this
combination is called disjunction of the two statements.

• We have two types of disjunction

Inclusive disjunction (∨)

Exclusive disjunction(⊻)

18
Inclusive Or (∨) (Inclusive
disjunction)
• If p and q are two simple statements then the compound statement p or q
written as p ∨ q is true when any of the statements p or q or
both are true. Otherwise it is false.

• For example, p: Kofi is a student and q: Ama is in form five, can


be combined as “ Kofi is a student or Ama is in form five”.

• This combined statement is true if any of them is true or both


are true.

• Otherwise it is false. 19
Inclusive Or (∨) (Inclusive
disjunction)
• Below is the truth table of p ∨ q (p or q or both)

p q p∨q

T T T

T F T

F T T

F F F

The third column is p ∨ q. Since both p and q are false in the fourth row, p ∨ q is also false.
Note that if at least one of the two simple statements is true, then p ∨ q is true.
20
Exclusive Or (⊻) ( Exclusive disjunction)

• If p and q are two simple statements then the compound statement


Either p or q written as p ⊻ q is true when any of the statements
p or q is true but both cannot be true.

• Otherwise it is false.

• Consider the two statements: p: I am in Accra and q: I am


in Kumasi.

• We can write p ⊻ q since I cannot be in Accra and Kumasi at


the same time. 21
Exclusive Or (⊻) ( Exclusive disjunction)

• Below is the truth table of p ⊻ q (p or q)

p q p⊻ q

T T F

T F T

F T T

F F F

The third column is p ⊻ q . Since both p and q are false in the fourth row, p ⊻ q
is also false.
Also since both p and q are true in the first row, p ⊻ q is false.
Note that if exactly one of the two simple staements is true p ⊻ q is true.
22
Not (~) (Negation)
• Given a simple statement p, another statement called the negation of p can be formed
by inserting in statement p the word “not”.

• The negation of p is written as ~p (i.e not p).

• Consider the two statements,

• p: Kofi is a bad boy

• q: Kofi is not a bad boy

• For these two statements, if p is true, then q must be false. q is said to be the negation
of p

• i.e q = ~p. Thus if p is true then ~p is false.


23
• Also if p is false then ~p is true
Not (~) (Negation)
• The truth table for ~p

p ~p

T F

F T

24
Implication/Conditional (⇒) (→ )
For any two statements p and q, p⇒q means q is true only when p is true.

p⇒q means “statement p implies the statement q” or “if p then q”

Consider the following statements:

• p : Abena has measles

• q : Abena is in the hospital

The compound statement ‘If Abena has measles then Abena is in the

hospital’ means p⇒q

25
Implication/Conditional (⇒) (→ )
• Consider the truth table for p⇒q below
p q p⇒q
T T T
T F F
F T T
F F T

For the second row, p is true but q is false.

Therefore p⇒q is false.

For the fourth row, although both statements are false p⇒q
26
is true.
Identifying conditional statements
• “if p, then q”
• “p implies q”
• Because conditional statements • “if p, q”
play such an essential role in • “p only if q”
mathematical/logical reasoning, • “p is sufficient for q”
a variety of terminology is used • “a sufficient condition for q is p”
to express p → q. • “q if p”
• You will encounter most if not • “q whenever p”
all of the following ways to • “q when p”
express this conditional • “q is necessary for p”
statement: • “a necessary condition for p is q”
• “q follows from p”
27
• “q unless ¬ p”
CONVERSE, CONTRAPOSITIVE, AND
INVERSE of Conditional Statements
• We can form some new conditional statements starting with a conditional
statement p → q.
• In particular, there are three related conditional statements that occur so
often that they have special names.
• The proposition q → p is called the converse of p → q.
• The contrapositive of p → q is the proposition ¬ q → ¬ p.
• The proposition ¬ p → ¬ q is called the inverse of p → q.
• Of these three conditional statements formed from p → q, only the
contrapositive always has the same truth value as p → q.

28
EXAMPLE: What are the contrapositive, the
converse, and the inverse of the conditional
statement:
“The home team wins whenever it is raining?”
• Solution: Because “q whenever p” is one of the ways to express the conditional
statement p → q, the original statement can be rewritten as
• “If it is raining, then the home team wins.”
• Consequently, the contrapositive of this conditional statement is:
• “If the home team does not win, then it is not raining.”
• The converse is:
• “If the home team wins, then it is raining.”
• The inverse is:
• “If it is not raining, then the home team does not win.”
29
Equivalence/Biconditional (↔)
• If p and q are said to be equivalent, it means that they have
the same truth value.

• In other words, whenever p is true, q is also true, and


whenever p is false, q is also false.

• Mathematically, it can be represented as "p ↔ q" or "p if and


only if q."

30
Equivalence/Biconditional (↔)
• Truth table that shows the possible truth values for the equivalence "p ↔ q":

p q p↔q

T T T

T F F

F T F

F F T

• p and q are equivalent if and only if they have the same truth value in all cases.

31
Identifying biconditional
statements
• There are some other common ways to express p ↔ q:
• “p is necessary and sufficient for q”
• “if p then q, and conversely”
• “p iff q.”
• The last way of expressing the biconditional statement p ↔ q uses the
abbreviation “iff” for “if and only if.”
• Note that p ↔ q has exactly the same truth value as (p → q) ∧ (q → p).

32
Examples:
1. Form the truth table for (p  ~ q) and hence ~(p  ~ q)

p q ~q p^~q ~(p^~q)
T T F F T
T F T T F
F T F F T
F F T F T

33
Examples:
2. Construct a truth table for the logical expression "(p ↔ q) ∧
(~r)" (conjunction of equivalence and negation).

34
Famous logical equivalences
• (a OR b) ↔ (b OR a) commutatitvity
• (a AND b) ↔ (b AND a) commutatitvity
• ((a AND b) AND c) ↔ (a AND (b AND c)) associativity
• ((a OR b) OR c) ↔ (a OR (b OR c)) associativity
• NOT(NOT(a)) ↔ a double-negation elimination
• (a => b) ↔ (NOT(b) => NOT(a)) contraposition
• (a => b) ↔ (NOT(a) OR b) implication elimination
• NOT(a AND b) ↔ (NOT(a) OR NOT(b)) De Morgan
• NOT(a OR b) ↔ (NOT(a) AND NOT(b)) De Morgan
• (a AND (b OR c)) ↔ ((a AND b) OR (a AND c)) distributivity
• (a OR (b AND c)) ↔ ((a OR b) AND (a OR c)) distributivity
Tautology
In logic, a tautology is a statement or logical expression that
is always true, regardless of the truth values of its
components or variables.
In other words, a tautology is a statement that is true in every
possible interpretation or truth assignment.
To identify a tautology, we can construct a truth table for the
logical expression and observe that the result is always true.
36
Tautology
• Example of a tautology and its truth table:

• Logical Expression: p OR (NOT p)


p NOT p p OR (NOT p)
T F T
F T T

• From the truth table, regardless of the truth value of p, the expression p OR (NOT p) always

evaluates to true. Therefore, p OR (NOT p) is a tautology.

• Tautologies are important in logic and mathematics as they represent statements that are

inherently true, providing a foundation for reasoning and logical deductions.

37
Contradiction
In logic, a contradiction is a statement or logical expression that is
always false, regardless of the truth values of its components or
variables.
 It represents a situation where a statement asserts both a claim and
its negation simultaneously.
To identify a contradiction, we can construct a truth table for the
logical expression and observe that the result is always false.

38
Contradiction
• Example of a contradiction and its truth table:
• Logical Expression: p AND (NOT p)

p NOT p p AND (NOT p)


T F F
F T F

• From the truth table, regardless of the truth value of p, the


expression p AND (NOT p) always evaluates to false. Therefore, p
AND (NOT p) is a contradiction.
• Contradictions are important in logic as they represent statements
that are inherently false, leading to logical inconsistencies and
invalid arguments. They can help identify errors in reasoning or
highlight contradictions within a system or set of statements. 39
Contingency
• And if the proposition is neither a tautology nor a contradiction—that
is, if there is at least one row where it's true and at least one row
where it's false—then the proposition is a contingency.
• A proposition that is neither a tautology nor contradiction is called a
contingency.
• E.g: Matt is either 39 years old or 40 years old

• Equivalence is a contingency.

40
Construct truth tables to test the following
sentences for tautology, contradiction and
contingency.
1. P→Q 11. [P → (Q → R)] & (P → R)
2. (P v ~P) & (Q & ~Q) 12. (P & Q) → (P → Q)
3. P←→Q 13. ~P → P
4. ~ (P & ~P) 14. ~P → (Q v P)
5. ~ (P v ~P) 15. ~P & ~(~P v ~Q)
6. ~ (P v P) 16. P v (Q → P)
7. (P & ~P) v (Q & ~Q) 17. (P ← → Q) & [(~P v ~Q) & P]
8. ~ (P v ~~Q) & (P & ~Q) 18. (P ← → Q) & (P → Q)
9. (P ← → Q) v (Q ← → P) 19. [P → (Q → R)] & (R → P)
10. ~ [(P → Q) → R] 20. (P ← → Q) v ~ [(~P & Q) v (P & ~Q)
41
Properties of Operators
1. Commutativity: 4. Identity:
• P ∧ true = P
• P∧Q↔Q∧P
• P ∨ false = P
• P∨Q↔Q∨P
5. Domination:
2. Associativity: • P ∨ true = true
• (P ∧ Q) ∧ R ↔ P ∧ (Q ∧ R) • P ∧ false = false

• (P ∨ Q) ∨ R ↔ P ∨ (Q ∨ R)
6. Double Negation:
• ¬ (¬P) = P
3. Distributivity:
• P ∧ (Q ∨ R) ↔ (P ∧ Q) ∨ (P ∧ R) 7. Idempotence:
• P∧P=P
• P ∨ (Q ∧ R) ↔ (P ∨ Q) ∧ (P ∨ R)
• P∨P=P
Applications of Propositional
Logic in AI
1. Knowledge Representation:
Propositional logic is used to represent knowledge in a structured and
unambiguous way. It allows AI systems to store and manipulate facts
about the world. For instance, in expert systems, knowledge is encoded
as a set of propositions and logical rules.
2. Automated Reasoning:
AI systems use propositional logic to perform automated reasoning.
Logical inference rules, such as Modus Ponens and Modus Tollens, enable
systems to derive new knowledge from existing facts. For example:
Modus Ponens: If “P → Q” and “P” are true, then “Q” must be true.
Modus Tollens: If “P → Q” and “¬Q” are true, then “¬P” must be true.
Applications of Propositional
Logic in AI
3. Problem Solving and Planning:
Propositional logic is fundamental in solving problems and planning actions.
AI planners use logical representations of actions, states, and goals to
generate sequences of actions that achieve desired outcomes. For example,
the STRIPS planning system employs propositional logic to represent
preconditions and effects of actions.
4. Decision Making:
In decision-making processes, propositional logic helps AI systems evaluate
various options and determine the best course of action. Logical rules can
encode decision criteria, and truth tables can be used to assess the
outcomes of different choices.
Applications of Propositional
Logic in AI
5. Natural Language Processing (NLP):
Propositional logic is applied in NLP for tasks like semantic parsing, where
natural language sentences are converted into logical representations. This
helps in understanding and reasoning about the meaning of sentences.
6. Game Theory and Multi-Agent Systems:
In game theory and multi-agent systems, propositional logic is used to
model the beliefs and actions of agents. Logical frameworks help in
predicting the behavior of agents and designing strategies for interaction.
Limitations of Propositional
Logic
• Lack of Expressiveness: does not allow for the representation of how one
proposition relates to another or to use variables to refer to objects in the
world
• Scalability: the size of the resultant truth tables increases exponentially (2n)
with the number of propositions, which makes practical problems infeasible.
• Limited Inference: It can only take on ‘true or false’ solutions, not probabilities
or multidimensional levels of truth.
• Absence of Quantifiers: Unlike predicate logic, propositional logic does not
allow the use of quantifiers such as “for all” (denoted by ∀) or “there exists”
(denoted by ∃), both of which are powerful expressions.
Inference
• The act of checking the validity of each proposition and operation, and
finally evaluating the outcome (conclusion) is known as inference.
• However, besides evaluating extensive truth tables all the time, we can also
make use of several inference rules to arrive at the final outcome or
conclusion.
• The main reason for doing so would be that the size of these truth tables
with the various operations starts increasing exponentially (with the
number of propositions increasing.
Inference rules (Rules of Inference)
• Rules of inference are syntactical transform rules which one can use to infer
a conclusion from a premise (hypotheses, beliefs, etc.)
• Rules of Inference provide the templates or guidelines for constructing valid
arguments from the statements that we already have.
• A sequence of inference rules, when applied, leads to a conclusion that is
often termed as a logical proof.
• The most popular inference rules are as follows:
Modus Ponens
• Perhaps the most popular inference rule, it’s also known as the Implication
Elimination rule or law of detachment.
• It can be represented as ((P → Q) ^ P) → Q , which indicates that if P
implies Q and P is asserted to be True , then it is inferred that Q is True .
• The representation can be evaluated easily using truth tables.
• A simple example would be the statement: If it is sunny, we will play
football, represented by P → Q .
• Now if we say that It is sunny, this indicates that P is True, hence Q
automatically is inferred as True , indicating We will play football.
Modus Tollens
• This is quite similar to the previous rule and is represented formally as
((P → Q) ^ ¬Q) → ¬P, which indicates that if P implies Q and Q is actually
asserted to be False, then it is inferred that P is False.
• An example proposition would be If he is a bachelor, he is not married,
indicated by P → Q .
• Now if we propose that He is married, represented by ¬Q, then we can
infer ¬P, which translates to He is not a bachelor.
Disjunctive Syllogism
• This is also known as Disjunction Elimination and is formally represented
as ((P v Q), ^ ¬P) → Q, which indicates that if either P or Q is True and P is
False , then Q is True.
• A simple example would be the statement: He is a miracle worker or a
fraud represented by P v Q and the statement: He is not a miracle worker
represented by ¬P. We can then infer He is a fraud , depicted by Q.
Hypothetical Syllogism
• This is often known as the Chain Rule of Deduction or Transitivity and is
formally represented as ((P → Q) ^ (Q → R)) → (P → R) , which tells us that if
P implies Q , and Q implies R , we can infer that P implies R .
• A really interesting example to understand this would be the statement: If I
am sick, I can’t go to work represented by P → Q and If I can’t go to work,
the building construction will not be complete represented by Q → R .
• Then we can infer If I am sick, the building construction will not be complete,
which can be represented by P → R .
Constructive Dilemma
• This inference rule is the disjunctive version of Modus Ponens and can be formally
represented as (((P → Q) ^ (R → S)) ^ (P v R)) → (Q v S), which indicates that if P
implies Q , and R implies S, and either P or R is True , then it can be inferred that
either Q or S is True.
• Consider the following propositions: If I work hard, I will be successful represented
by P → Q , and If I win the lottery, I will be rich represented by R → S.
• Now we propose that I work hard or I win the lottery is True , which is represented
by P v R .
• We can then infer that I will be successful or I will be rich, represented by Q v S.
• The complement of this rule is Destructive Dilemma, the disjunctive version of
Modus Tollens.
First-Order Logic (FOL)
A story
• Your roommate comes home; he/she is completely wet
• You know the following things:
• Your roommate is wet
• If your roommate is wet, it is because of rain, sprinklers, or both
• If your roommate is wet because of sprinklers, the sprinklers must be on
• If your roommate is wet because of rain, your roommate must not be carrying
the umbrella
• The umbrella is not in the umbrella holder
• If the umbrella is not in the umbrella holder, either you must be carrying the
umbrella, or your roommate must be carrying the umbrella
• You are not carrying the umbrella
• Can you conclude that the sprinklers are on?
• Can AI conclude that the sprinklers are on?
Knowledge base for the story
• RoommateWet
• RoommateWet => (RoommateWetBecauseOfRain OR
RoommateWetBecauseOfSprinklers)
• RoommateWetBecauseOfSprinklers => SprinklersOn
• RoommateWetBecauseOfRain =>
NOT(RoommateCarryingUmbrella)
• UmbrellaGone
• UmbrellaGone => (YouCarryingUmbrella OR
RoommateCarryingUmbrella)
• NOT(YouCarryingUmbrella)
Limitations of propositional
logic
• So far we studied propositional logic
• Some English statements are hard to model in
propositional logic:
• “If your roommate is wet because of rain, your
roommate must not be carrying any umbrella”
• Pathetic attempt at modeling this:
• RoommateWetBecauseOfRain =>
(NOT(RoommateCarryingUmbrella0) AND
NOT(RoommateCarryingUmbrella1) AND
NOT(RoommateCarryingUmbrella2) AND …)
Problems with propositional
logic
• No notion of objects
• No notion of relations among objects
• RoommateCarryingUmbrella0 is instructive to us, suggesting
• there is an object we call Roommate,
• there is an object we call Umbrella0,
• there is a relationship Carrying between these two objects

• Formally, this cannot be done with propositional logic.


• Might as well have replaced RoommateCarryingUmbrella0 by P0,
RoommateCarryingUmbrella1 by P1, ….
First Order Logic
• First order logic (FOL), also known popularly as predicate logic or first order
predicate calculus, is defined as a collection of well-defined formal systems
which is used extensively in deduction, inference, and representation of
knowledge.
• FOL allows us to use quantifiers and variables in sentences, which enable us
to overcome some of the limitations with propositional logic.
• If we are to consider the pros and cons of propositional logic (PL), considering
the points in its favor, PL is declarative and allows us to easily represent facts
using a well-formed syntax.
• PL also allows complex representations like conjunctive, disjunctive, and
negated knowledge representations.
First Order Logic (Cont’)
• This by nature makes PL compositional wherein a composite or complex
proposition is built from the simple propositions that are its components
along with logical connectives.
• However, there are several areas where PL is lacking. It is definitely not easy
to represent facts in PL because for each possible atomic fact, we will need a
unique symbolic representation.
• Hence, due to this limitation, PL has very limited expressive power.
• Hence, the basic idea behind FOL is to not treat propositions as atomic
entities.
• FOL has a much richer syntax and necessary components for the same
compared to PL.
• The basic components in FOL are as follows:
Components of FOL
• Objects : These are specific entities or terms with individual unique identities
like people, animals, and so on.
• Relations : These are also known as predicates and usually hold among objects
or sets of objects and express some form of relationship or connection, like
is_man, is_brother, is_mortal. Relations typically correspond to verbs.
• Functions : These are a subset of relations where there is always only one
output value or object for some given input. Examples would be height,
weight, age_of.
• Properties : These are specific attributes of objects that help in distinguishing
them from other objects, like round, huge, tall, black, red, and so on.
• Connectives : These are the logical connectives that are similar to the ones in
PL, which include not (¬), and (^), or (v), implies (→), and iff (if and only if ↔).
Components of FOL (Cont’)
• Quantifiers : These include two types of quantifiers: universal (ꓯ), which
stands for “for all” or “all,” or “for every” and existential (ꓱ), which stands for
“there exists” or “there exists some” or “there exists at least one”. They are
used for quantifying entities in a logical or mathematical expression.
• Constant symbols : These are used to represent concrete entities or objects in
the world. Examples would be John, King, Red, and 7.
• Variable symbols : These are used to represent variables like x, y, and z.
• Function symbols : These are used to map functions to outcomes. Examples
would be, age_of(John) = 25 or color_of(Tree) = Green.
• Predicate symbols : These map specific entities and a relation or function
between them to a truth value based on the outcome. Examples would be
color(sky, blue) = True.
Popular Uses of Quantifiers in
FOL
• NB: Assuming x and y are humans.

• (ꓯx), (ꓱy) : loves(x, y) means that everyone in the world loves at least
someone.
• (ꓱy) : (ꓯx), loves(x, y) means that someone in the world is loved by
everyone.
• (ꓯy), (ꓱx) : loves(x, y) means that everyone in the world has at least
someone who loves them.
• (ꓱx) : (ꓯy), loves(x, y) means that there is at least someone in the
world who loves everyone.
Quantifier Identities and
Properties
Natural Language and FOL
Practice converting English to first-order
logic

• “John has Jane’s umbrella”


• Has(John, Umbrella(Jane))
• “John has an umbrella”
• there exists y: (Has(John, y) AND IsUmbrella(y))
• “Anything that has an umbrella is not wet”
• for all x: ((there exists y: (Has(x, y) AND IsUmbrella(y))) =>
NOT(IsWet(x)))
• “Any person who has an umbrella is not wet”
• for all x: (IsPerson(x) => ((there exists y: (Has(x, y) AND
IsUmbrella(y))) => NOT(IsWet(x))))
More practice converting English to first-
order logic

• “John has at least two umbrellas”


• there exists x: (there exists y: (Has(John, x) AND
IsUmbrella(x) AND Has(John, y) AND IsUmbrella(y) AND
NOT(x=y))
• “John has at most two umbrellas”
• for all x, y, z: ((Has(John, x) AND IsUmbrella(x) AND
Has(John, y) AND IsUmbrella(y) AND Has(John, z) AND
IsUmbrella(z)) => (x=y OR x=z OR y=z))
Even more practice converting English to
first-order logic…

• “Duke’s basketball team defeats any other basketball


team”
• for all x: ((IsBasketballTeam(x) AND
NOT(x=BasketballTeamOf(Duke))) =>
Defeats(BasketballTeamOf(Duke), x))
• “Every team defeats some other team”
• for all x: (IsTeam(x) => (there exists y: (IsTeam(y) AND
NOT(x=y) AND Defeats(x,y))))
Relationship between universal and existential
quantifiers

• for all x: a
• is equivalent to
• NOT(there exists x: NOT(a))
Something we cannot do in first-order logic

• We are not allowed to reason in general about relations and functions


• The following would correspond to higher-order logic (which is more
powerful):
• “If John is Jack’s roommate, then any property of John is also a property of
Jack’s roommate”
• (John=Roommate(Jack)) => for all p: (p(John) => p(Roommate(Jack)))
• “If a property is inherited by children, then for any thing, if that property is
true of it, it must also be true for any child of it”
• for all p: (IsInheritedByChildren(p) => (for all x, y: ((IsChildOf(x,y) AND p(y)) =>
p(x))))
Applications of First-Order Logic
in AI
• First-order logic is instrumental in various AI applications, enabling systems to
reason about complex knowledge structures and make informed decisions. Some
of the key applications of FOL in AI include:

• Knowledge Representation: FOL provides a robust framework for representing


complex relationships and properties of objects. For example, in a medical
diagnosis system, predicates can represent symptoms, diseases, and their
relationships, allowing the system to reason about potential diagnoses.
• Automated Theorem Proving: Automated theorem proving involves using
algorithms to prove mathematical theorems. FOL provides the foundational
structure for many theorem proving systems, enabling them to verify software and
hardware correctness, prove mathematical theorems, and more.
Applications of First-Order Logic
in AI
• Natural Language Processing (NLP): In NLP, FOL is used to parse and
understand natural language by representing the meaning of sentences in a
formal, logical manner. This allows AI systems to perform tasks such as
question answering, machine translation, and text summarization.
• Expert Systems: Expert systems encode expert knowledge using FOL and
reason about it to make decisions. For example, a legal expert system might
use FOL to represent legal rules and infer outcomes based on given facts,
aiding in legal decision-making processes.
• Semantic Web: The Semantic Web uses FOL to describe relationships
between web resources, enabling more intelligent information retrieval and
processing. This enhances the ability of AI systems to understand and interact
with web content.
Axioms and theorems
• Axioms: basic facts about the domain, our
“initial” knowledge base
• Theorems: statements that are logically derived
from axioms

You might also like