#14 Horn Clause
#14 Horn Clause
#14 Horn Clause
CLAUSE
139,148,150
LOGIC
PROGRAMMING
Logic programming involves defining a
set of logical rules, facts, and queries to
perform automated reasoning.
The rules, often written in the form of
Horn clauses that define relationships
and implications.
IMPORTANT
SYMBOLS
(or)
(and)
~ or
(Conditional)
LITERAL:
Literal is a statement that can be either true or
false
it can be represent by a variable.
A literal can be Positive (a simple fact) or
negative.
Examples of literals:
Positive Literal "It is raining" X
Negative Literal: "It is not raining" ~X
Example 3:
∨
(X Y)→Z
Step 1: ¬(X∨Y)∨Z
Step 2: ¬X∧¬Y∨Z Distributed Property
Step 3: (¬X∨Z)∧(¬Y∨Z)
EXAMPLE QUESTION
Convert the Following into horn clause
Example 4: ∵ to remove (→) implies sign
∨B)→C
negation(¬) sign is applied
(A ∧
that converts and into or ∨
Step 1: ¬(A∨B)∨C
Step 2: ¬A∧¬B∨C
(¬A∨C)∧(¬B∨C)
Demorgan's law
Step 3:
Distributed Property
EXAMPLE QUESTION
Convert the Following into horn clause
Example 5: ∵ to remove (→) implies sign
∧B)→C
negation(¬) sign is applied
(¬A ∧
that converts and into or ∨
Step 1: ¬(¬A∧B)∨C
Step 2: (A∨¬B)∨C
Step 3: A∨¬B∨C This is not a horn clause because
in horn clause there may be
atmost one positive literal here
are two positive literals A and C
EXAMPLE QUESTION
Convert the Following into horn clause
Example 6: ∵ to remove (→) implies sign
∨¬B)→C
negation(¬) sign is applied
(A ∧
that converts and into or ∨
Step 1: ¬(A∨¬B)∨C
Step 2: (¬A∧B)∨C
Step 3: (¬A∨C)∧(B∨C) This is not a horn clause because
in horn clause there may be
atmost one positive literal here
are two positive literals B and C
TYPES OF
H0RN CLAUSE
Horn clauses can be categorized into several types
based on their structure and properties.
Unit clause
A unit clause is a clause that has only one literal,
and that literal must be either positive or
negative.
It can be understood as an assertion that the
positive literal is true (or false, depending on the
literal)
TYPES OF
H0RN CLAUSE
Example of Unit Clause:
A (true)
¬B (false)
Goal Clause:
A goal clause is a Horn clause that has no positive
literals.
It can be understood as a query to prove that the
negative literals are false.
A Horn clause can have zero or more goal clauses.
TYPES OF
H0RN CLAUSE
Example 1 of Goal Clause:
p ∨ q ∨¬r
This clause states that either p or q is true, or r is
false. The goal clause is ¬r, which means that we
are trying to prove that r is false.
TYPES OF
H0RN CLAUSE
Another Example with 2 Goal Clause:
¬p ∨ ¬q ∨ s
This clause states that either p or q is false, or s is
true. The goal clauses are ¬p and ¬q, which means
that we are trying to prove that p and q are both
false.
THANK YOU!