5 PL Anf FOL
5 PL Anf FOL
Propositional Logic
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:
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.
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
Example:
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
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.
First-Order logic:
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:
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.
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).
6. Return SUBST