0% found this document useful (0 votes)
25 views31 pages

5 PL Anf FOL

- Logic provides rules and meaning to mathematical statements. Propositional logic uses basic building blocks called propositions that can be either true or false. Propositional logic symbols include logical connectives like and, or, implies, and if and only if. - Inference uses rules like modus ponens, modus tollens, and disjunctive syllogism to derive new conclusions from given facts or hypotheses. Forward chaining starts with known facts and applies rules while backward chaining starts with a goal and works backwards to find supporting facts. - Resolution is an inference rule used to prove whether an argument is correct. It involves taking the disjunction of literals after removing complementary literals between clauses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views31 pages

5 PL Anf FOL

- Logic provides rules and meaning to mathematical statements. Propositional logic uses basic building blocks called propositions that can be either true or false. Propositional logic symbols include logical connectives like and, or, implies, and if and only if. - Inference uses rules like modus ponens, modus tollens, and disjunctive syllogism to derive new conclusions from given facts or hypotheses. Forward chaining starts with known facts and applies rules while backward chaining starts with a goal and works backwards to find supporting facts. - Resolution is an inference rule used to prove whether an argument is correct. It involves taking the disjunction of literals after removing complementary literals between clauses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

What is Logic?

• Logic is the basis of all mathematical reasoning


• The rules of logic give precise meaning to mathematical statements.
• Example : ∃X such that X ≠ (a^2)+(b^2)
Which in Simple English means “There exists an integer that is not the sum of two
squares”.

Propositional Logic

• A proposition is the basic building block of logic. It is defined as a declarative


sentence that is either True or False, but not both.

proposition Not proposition


1. The sun rises in the East and sets in the West.
1. What time is it?
2. 1 + 1 = 2
2. Go out and play.
3. 'b' is a vowel.
Equivalences
Two logical expressions are said to be equivalent if they have the same truth value in all cases.
Sometimes this fact helps in proving a mathematical result by replacing one expression with another
equivalent expression, without changing the truth value of the original compound proposition.

Types of propositions based on Truth values

There are three types of propositions when classified according to their truth values
•Tautology – A proposition which is always true, is called a tautology.
•Contradiction – A proposition which is always false, is called a contradiction.
•Contingency – A proposition that is neither a tautology nor a contradiction is called a contingency.
Propositional logic
• Logical constants: true, false
• Propositional symbols: P, Q, S, ... (atomic sentences)
• Wrapping parentheses: ( … )
• Sentences are combined by connectives:
∧ ...and [conjunction]
∨ ...or [disjunction]
⇒...implies [implication / conditional]
⇔..is equivalent [biconditional]
¬ ...not [negation]
• Literal: atomic sentence or negated atomic sentence

4
Examples of PL sentences
• P means “It is hot.”
• Q means “It is humid.”
• R means “It is raining.”
• (P ∧ Q) → R
“If it is hot and humid, then it is raining”
• Q→P
“If it is humid, then it is hot”
• A better way:
Hot = “It is hot”
Humid = “It is humid”
Raining = “It is raining”

5
Propositional logic (PL)
• A simple language useful for showing key ideas and definitions
• User defines a set of propositional symbols, like P and Q.
• User defines the semantics of each propositional symbol:
– P means “It is hot”
– Q means “It is humid”
– R means “It is raining”
• A sentence (well formed formula) is defined as follows:
– A symbol is a sentence
– If S is a sentence, then ¬S is a sentence
– If S is a sentence, then (S) is a sentence
– If S and T are sentences, then (S ∨ T), (S ∧ T), (S → T), and (S ↔ T) are
sentences
– A sentence results from a finite number of applications of the above rules

6
Inference:
In artificial intelligence, we need intelligent computers which can create new logic from
old logic or by evidence, so generating the conclusions from evidence and facts is
termed as Inference.
Inference rules:
• Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.
• In inference rules, the implication among all the connectives plays an important role.
Following are some terminologies related to inference rules:

Implication: It is one of the logical connectives which can be represented as P → Q.


It is a Boolean expression.

Converse: The converse of implication, which means the right-hand side proposition
goes to the left-hand side and vice-versa. It can be written as Q → P.

Contrapositive: The negation of converse is termed as contrapositive, and it can be


represented as ¬ Q → ¬ P.

Inverse: The negation of implication is called inverse. It can be represented as ¬ P →


¬ Q.
Inference rules:
Types of Inference rules:

1. Modus Ponens:
if P and P → Q is true, then we can infer that Q will be true.

Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.
2. Modus Tollens

if P→ Q is true and ¬ Q is true, then ¬ P will also true.

Example:

Statement-1: "If I am sleepy then I go to bed" ==> P→ Q


Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P
3. Hypothetical Syllogism

The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true,
and Q→R is true.

Example:
Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
4. Disjunctive Syllogism:

The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will be true.

Example:
Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
5. Addition:
It states that If P is true, then P∨Q will be true.

Example:
Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
6. Simplification:

The simplification rule state that if P∧ Q is true, then Q or P will also be true.
7. Resolution:

The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be true.
• The resolution principle is used to prove whether an argument is correct or not.
• Literal: A variable or negation of a variable is called a literal
• In propositional calculus a literal is simply a propositional variable or its
negation.
• Clause: A clause is a disjunction of literal
• Resolvant: For any two clauses C1 and C2 , if C1 has literal L1 and C2 has Literal L2
which is a complement of L1, Then delete L1 and L2 from C1 and C2 and construct the
disjunction of remaining literal. The result so obtained is called as resolvant.
• Suppose ,
• C1=P v Q v R
• C2= ~ P v S v T

• P and ~P are complementary to each other . According to the definition of resolvant


, delete P and ~P and take disjunction of remaining
• Q v R v S v T --------> resolvant
Inference engine:
The inference engine is the component of the intelligent system in artificial intelligence,
which applies logical rules to the knowledge base to infer new information from known
facts. The first inference engine was part of the expert system.
Inference engine commonly proceeds in two modes, which are:

1. Forward chaining
2. Backward chaining
1. Forward Chaining
• Forward chaining is also known as a forward deduction or forward reasoning method when using an
inference engine. Forward chaining is a form of reasoning which start with atomic sentences in the
knowledge base and applies inference rules (Modus Ponens) in the forward direction to extract more
data until a goal is reached.
• The Forward-chaining algorithm starts from known facts, triggers all rules whose premises are
satisfied, and add their conclusion to the known facts. This process repeats until the problem is
solved.

Properties of Forward-Chaining:
• It is a down-up approach, as it moves from bottom to top.
• It is a process of making a conclusion based on known facts or data, by starting from the initial state
and reaches the goal state.
• Forward-chaining approach is also called as data-driven as we reach to the goal using available data.
• Forward -chaining approach is commonly used in the expert system, such as CLIPS, business, and
production rule systems.
2. Backward Chaining:
Backward-chaining is also known as a backward deduction or backward reasoning method when using
an inference engine. A backward chaining algorithm is a form of reasoning, which starts with the goal
and works backward, chaining through rules to find known facts that support the goal.

Properties of backward chaining:


• It is known as a top-down approach.
• Backward-chaining is based on modus ponens inference rule.
• In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.
• It is called a goal-driven approach, as a list of goals decides which rules are selected and used.
• Backward -chaining algorithm is used in game theory, automated theorem proving tools, inference
engines, proof assistants, and various AI applications.
• The backward-chaining method mostly used a depth-first search strategy for proof.
Resolution in Propositional Logic
• The resolution principle is used to prove whether an argument is correct or not.
• Literal: A variable or negation of a variable is called a literal
• In propositional calculus a literal is simply a propositional variable or its
negation.
• Clause: A clause is a disjunction of literal
• A clause expression is either a literal or a disjunction of literals. If p and q are
• logical constants, then the following are clause expressions.
• p
• ¬p
• p∨q
• Resolvant: For any two clauses C1 and C2 , if C1 has literal L1 and C2 has Literal L2
which is a complement of L1, Then delete L1 and L2 from C1 and C2 and construct the
disjunction of remaining literal. The result so obtained is called as resolvant.
• Suppose ,
• C1=P v Q v R
• C2= ~ P v S v T

• P and ~P are complementary to each other . According to the definition of resolvant


, delete P and ~P and take disjunction of remaining
• Q v R v S v T --------> resolvant
First-Order Logic
The propositional logic, we can only represent the facts, which are either true or false. PL is not sufficient to represent
the complex sentences or natural language statements. The propositional logic has very limited expressive power.
Consider the following sentence, which we cannot represent using PL logic.

"Some fruits are sweet"

First-Order logic:

• In artificial intelligence, first-order logic is another method of knowledge representation. This is a


development of propositional logic.
• First-order predicate logic and predicate logic are other names for first-order logic.
Basic Elements of First-order logic:

Constant: 1, 2, A, John, Mumbai, cat,....


Variables: x, y, z, a, b,....

Predicates: Brother, Father, >,....

Function: sqrt, LeftLegOf, ....


Connectives: ∧, ∨, ¬, ⇒, ⇔
Equality: ==
Quantifier: ∀, ∃

Atomic sentences:

Atomic sentences are the most basic sentences of first-order logic. These sentences are formed from a
predicate symbol followed by a parenthesis with a sequence of terms.
We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => cat (Chinky).
Complex Sentences:

Complex sentences are made by combining atomic sentences using connectives.


First-order logic statements can be divided into two parts:
Subject: Subject is the main part of the statement.
Predicate: A predicate can be defined as a relation, which binds two atoms together in a statement.
Example: X is an Integer

Quantifiers in First-order logic:


A quantifier is a language element which generates quantification, and quantification specifies the
quantity of specimen in the universe of discourse.

There are two types of quantifier:


Universal Quantifier, (for all, everyone, everything)
Existential quantifier, (for some, at least one).
Universal Quantifier,
For all x
For each x
For every x.

Example:
Let a variable x
All man drink coffee=> ∀x man(x) → drink (x, coffee)
There are all x where x is a man who drink coffee.

Existential Quantifier:
• Existential quantifiers are the type of quantifiers, which express that the statement within its
scope is true for at least one instance of something.
• It is denoted by the logical operator ∃
There exists a 'x.'
For some 'x.'
For at least one 'x.'
Example: Some boys are intelligent. =>∃x: boys(x) ∧ intelligent(x)
There are some x where x is a boy who is intelligent.

The main connective for universal quantifier ∀ is implication →.


The main connective for existential quantifier ∃ is and ∧.
Inference in First order Logic
Inference in First-Order Logic is used to deduce new facts or sentences from existing sentences.

Basic terminologies used in FOL

Substitution:
If we write F[a/x], so it refers to substitute a constant "a" in place of variable "x".

Equality:
Example: Brother (John) = Smith
Example: ¬(x=y) which is equivalent to x ≠y.
Unification Algorithm

What is Unification ?

• In propositional logic, it is easy to determine that two literals cannot both be true at the same
time.
• Simply look for L and L In predicate logic, this matching process is more complicated since
the arguments of the predicates must be considered.
• For example, man(John) and ¬man(John) is a contradiction, while man(John)
artdman(Spot) is not
• Thus, in order to determine contradictions, we need a matching procedure that compares two
literals and discovers whether there exists a set of substitutions that makes them identical.
• There is a straightforward recursive procedure, called the unification algorithm, that does
just this.
• The basic idea of unification is very simple. To attempt to unify two literals, we first
check if their initial predicate symbols are the same. If so, we can proceed. Otherwise,
there is no way they can be unified, regardless of their arguments. For example, the
two literals
Algorithm : Unification
1. If L1 or L2 are both variables or constants, then:
(a) If L1 and L2 are identical, then return NIL
(b) (b) Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL}, else return (L2/L1).(c)
(c) Else if L2 is a variable then if L2 occurs in Lt then return {FAIL}, else return (L1/L2)
(d) Else return {FAIL}.

2. If the initial predicate symbols in L1 and L2 are not identical, then return (FAIL).

3. If L1 and L2 have a different number of arguments, then return (FAIL).


4. Set SUBST to NIL (At the end of this procedure, SUBST will contain all the substitutions used to
any

5. For i 1 to number of arguments in L1:


(a) Call Unify with the Ah argument of L1 and the ith argument of L2, putting result in S.
(b) If S contains FAIL. then return (FAIL).
(c) If S is not equal to NIL. then:
i. Apply S to the remainder of both L1 and L2
ii. SUBST: APPEND(S, SUBST).

6. Return SUBST

You might also like