Part A
Part A
Class Teacher:
Md. Shamim Hossain
Lecturer
Dept. of EEE, PUST
What is Artificial Intelligence(AI)?
Definition-1:
• Artificial Intelligence (AI) is the study of
computations that make it possible to
perceive, reason and act.
• Latest Perception of AI :-
3
What is Intelligence(বুদ্ধিমত্তা)?
• Intelligence is a property of mind that
encompasses many related mental abilities,
such as the capabilities to
– reason
– plan
– solve problems
– think abstractly
– comprehend ideas and language and
– learn.
4
Sub-areas of AI (Importance)
5
Applications
• Business : Financial strategies, give advice
• Engineering: check design, offer suggestions to
create new product
• Manufacturing: Assembly, inspection &
maintenance
• Mining: used when conditions are dangerous
• Hospital : monitoring, diagnosing & prescribing
• Education : In teaching
• Household : Advice on cooking, shopping etc.
• Farming : prune trees & selectively harvest mixed
crops.
6
Knowledge
• Knowledge can be defined as the body of facts and
principles accumulated by human-kind or the fact, or
state of knowing.
• In biological organisms, knowledge is likely stored as
complex structures of interconnected neurons.
• In Computer Science, knowledge is also stored as
complex structures, but in the form of collections of
magnetic spots and voltage states.
9
Types of Knowledge
• Procedural knowledge is compiled knowledge
related to the performance of some task.
• Example: To solve the algebraic equations.
12
• END TODAY
THANKS
13
Knowledge Representation
2
Knowledge Representation
• A knowledge representation is most
fundamentally a substitute for the thing itself,
used to enable an entity to determine
consequences by reasoning about the world.
• Reasoning is the use of symbolic
representations of some statements in order
to derive new ones.
3
Predicate logic (PL):
• Predicate logic is the generic term for
symbolic formal systems like first-order logic,
second-order logic, many-sorted logic, or
infinitary logic.
4
Predicate Logic (PL):
● It has three more logical notions as compared to PL.
❖ Terms,
❖ Predicates
❖ Quantifiers
● Term
− a constant (single individual or concept i.e.,5, john etc.),
− a variable that stands for different individuals
− n-place function f(t1, …, tn) where t1, …, tn are terms. A function is a
mapping that maps n terms to a term.
● Predicate
− a relation that maps n terms to a truth value true (T) or false (F).
● Quantifiers
− Universal () or existential() quantifiers i.e. and used in
conjunction with variables.
5
Examples
● “x loves y” is represented as LOVE(x, y) which maps it to
true or false when x and y get instantiated to actual values.
● “john’s father loves john” is represented as
LOVE(father(john), john).
− Here father is a function that maps john to his father.
● x is greater than y is represented in predicate calculus as
GT(x, y).
● It is defined as follows:
GT( x, y) =T , if x y
=F , otherwise
● Symbols like GT and LOVE are called predicates .
− Predicates two terms and map to T or F depending upon the values
of their terms.
6
Examples – Cont..
8
Propositional Logic
• Propositions are elementary atomic sentences.
• It may be either true or false but may take on no
other value.
• Examples (Simple propositions):
❖ It is raining.
❖Jone and mary have five children.
❖Snow is white.
❖Snow is black.
❖People live on the Earth.
❖ People live on the Moon.
9
Compound Proposition
• Examples (Compound propositions):
❖It is raining and the wind is blowing.
❖If you study hard you will be rewarded.
❖The sum of 10 and 20 is not 40.
❖The sum of 20 and 10 is 40.
• T and F are special symbols having the values
true and false.
10
Conti…
• Logical Connectives:
Symbol Meaning
˜ for not or negation
11
Syntax
• The syntax of PL is defined recursively as follows:
• T and F are formulas.
• IF P and Q are formulas, the following are also formulas:
• (˜P)
• (P&Q)
• (PVQ)
• (P→Q)
• (P Q)
12
Semantics
• The semantics or meaning of a sentence is
just the value true or false: that is, it is as
assignment of a truth value to the sentences.
• An interpretation for a sentence or group of
sentences in an assignment of the truth value
to each propositional symbol.
13
Conti…
14
Semantic Rules for statements
Consider t and t' denotes true statements, f and f' denotes false
statements, and a is any statement.
15
Example:
• Let I assign true to P , false to Q and false to R in
statement ((P & -Q) →R)VQ.
• What is the meaning of the statement?
Answer:
• Rule 2 gives -Q as true.
• Rule 3 gives (P & -Q) as true.
• Rule 6 gives (P & -Q) →R as false.
• Rule 5 gives the statement ((P & -Q) →R)VQ
value as false.
16
Assignment
• Find the meaning of the statement
(-PVQ)&R→SV(-R&Q)
for each of the interpretations given below.
• (a). I1 : P is true, Q is true, R is false, S is true.
• (b). I2 : P is true, Q is false, R is true, S is true.
17
Example
• Find the meaning of the following statement:
• ~(P V ~Q) & (R → S) for the interpretation given
bellow:
• I: P is true, Q is false, R is true and S is false.
Answer:
• Rule 2 gives -Q as true.
• Rule 4 gives (P V -Q) as true.
• Rule 4 gives ~(P V -Q) as false.
• Rule 6 gives (R → S) as false.
• Rule 3 gives the statement ~(P V ~Q) & (R → S) value
as false.
18
Example
• Represent the following facts in predicate logic:
• (i). All employees earning Tk. 2,50,000/= or more
per year have to pay taxes.
• x ((E(x) & GE(i(x), 250000)) →T(x))
• (ii). People only try to assassinate rulers they are
not loyal to.
• y: x : person(x) Ʌ ruler(y) Ʌ tryassassinate(x, y)
→ ¬loyalto (x, y)
• (iii). John likes all kinds of food.
• Like (john, all-kinds-of-food)
19
•THE END
•THANKS
20
Predicate Logic Conti….
3
Example: On The above definitions:
• A valid statement is satisfiable, and a contradictory
statement is invalid, but the converse is not necessarily true.
• P is satisfiable but not valid since an interpretation that
assigns false to P assigns false to the sentence P.
• P V ~P is valid since every interpretation results in a value of
true for (P V ~P ).
• P & ~P is a contradiction since every interpretation results in
a value of false for (P & ~P).
• P and ~(~P) are equivalent since each has the same truth
values under every interpretation.
• P is a logical consequence of (P & Q) since any interpretation
for which (P & Q) is true, P is also true.
4
Theorem
• Theorem 4.1: The sentence s is a logical
consequence of s1 , s2 , ...... , sn if and only if s1 & s2
& s3 . . . . & sn → s is valid.
• Proof: Theorem 4.1 can be seen by first noting that
if s is a logical consequence of s1 , s2 , .......... , sn ,
then for any interpretation I in which s1 & s2 & s3 ,
..... . &sn → s is true.
• on the other hand, if s1 & s2 & s3 , .... & sn →s is valid,
then for any interpretation I if s1 & s2 & s3 , ..... . &sn
is true, s is also true.
5
Theorem
• Theorem 4.2: The sentence s is a logical
consequence of s1 , s2 , ...... , sn if and only if s1 & s2
& s3 , .... & sn & ~s is inconsistent.
6
Conti …..
• But
~(s1 & s2 & s3 , ..... . &sn → s ) = ~(~(s1 & s2 & s3 , ..... . &sn ) V s)
[By Conditional Elimination]
= ~~(s1 & s2 & s3 , ..... . &sn ) & ~s)
[ By De Morgan’s Law]
= s1 & s2 & s3 , ..... . &sn & ~s
❑ When s is a logical consequence of s1 , s2 , ...... , sn , the formula
s1 & s2 & s3 , ..... . &sn → s is called a theorem, with s is the
conclusion.
❑ When s is a logical consequence of the set S = {s1 , s2 , ...... , sn }
we will also set S logically implies s , written Sⱶs .
7
Table 4.2 lists some of the important laws of PL
(Some Equivalence Laws)
8
Example
• Show that P→Q is equivalent to ~PVQ and
that P Q is equivalent to the expression
(P→Q)&(Q→P).
9
TABLE 4.3 : Truth table for equitant
sentences
10
Inference Rules
• The inference rules of PL provide the means
to perform logical proofs or deductions.
11
Modus Ponens:
• From P and P → Q infer Q. This sometimes
written as
• P
• P →Q
• Q
12
Example For Modus Ponens:
13
Chain Rule
• Form P → Q and Q→ R, infer P→R.
• Or
• P→Q
• Q→R
• P→R
14
Example for Chain Rule
• Given: (programmer likes LISP)→ (programmer hates COBOL)
• and : (programmer hates COBOL) → (programmer likes recursion)
• Conclude: (programmer likes LISP)→ (programmer likes recursion)
15
Assignment-2
Construct a truth Table for the expression
(A & (A V B)).
16
•Thanks
17
Syntax and Semantics
for FOPL
Md. Shamim Hossain
Lecturer
Dept. of EEE , PUST
FOPL (Fist Order Predicate Logic)
• FOPL was developed by logicians to extend
the expressiveness of PL.
• The semantics of FOPL are determined by
interpretations assigned to predicates, rather
than propositions.
2
Syntax of FOPL
• The symbols and rules of combination
permitted in FOPL are defined as follows:
• Connectives: There are five connective
symbols:
• ~(not or negation)
• & (and or conjunction)
• V (or or inclusive disjunction)
• → (implication)
• (equivalence or if and only if).
3
Syntax of FOPL
• Quantifiers: The two quantifier symbols are (
existential quantification) and (universal
quantification).
• Where (x) means for some x or there is an x .
and (x) means for all x.
• When more than one variable is being quantified
by the same quantifier, such as, (x) (y) (z),
we abbreviate with a single quantifier and drop
the parentheses to get xyz.
4
Syntax of FOPL
• Constants: Constants are terms that can fixed-
values over a given domain.
• They are denoted by numbers, words, and
small letters near the beginning of the
alphabet.
• Examples: a , b , c , 5.256, -67, -75.65 , flight-
305, john, , Marina, etc.
5
Syntax of FOPL
• Variables: Variables are terms that can
assume different values over a given domain.
• They are denoted by words and small letters
near the end of the alphabet.
• Examples: aircraft-type, individuals, x, y, and z.
6
Syntax of FOPL
• Functions: Function symbols denote relations
defined on a domain D. They map n elements
(n≥0) to a single element of the domain.
• Symbols f , g, & h, and words such as father-of
, or age-of, represent functions.
• An n place (n-ary) function is written as f(t1, t2,
t3, .. .. .. tn) where the ti are terms (constants,
variables, or functions) defined over some
domain. A 0-ary function is a constant.
7
Syntax of FOPL
• Predicates: Predicate symbols denote
relations or functional mappings from the
elements of a domain D to the values true or
false.
• Capital letters and capitalized words such as P,
Q, R, EQUAL, and MARRIED are used to
represent predicates.
8
Syntax of FOPL
• Like functions, predicates may have n (n ≥ 0)
terms for arguments written as P(t1, t2, t3, .. ..
.., tn)
• Where the terms ti , i =1 , 2, 3, .. .. .. , n are
defined over some domain.
• A 0-ary predicate is a proposition, that is, a
constant predicate.
9
Syntax of FOPL
• Constants, variables, and functions are
referred to as terms, and predicates are
referred to as atomic formulas or atoms for
short.
10
Syntax of FOPL
• Examples:
• E1: All employees earning $ 1400 or more
per year pay taxes.
• E2: Some employees are sick today.
• E3: No employee earns more than the
president.
11
Syntax of FOPL
• To represent such expressions FOPL, we must define
abbreviations for the predicates and functions.
• E(x) for x is an employee.
• P(x) for x is president.
• i(x) for the income of x (lower case denotes a
function).
• GE(u,v) for u is greater than or equal to v.
• S(x) for x is sick today.
• T(x) for x pays taxes.
12
Syntax of FOPL
• Using the above abbreviations, we represent
E1, E2, and E3 as:
• E1: x ((E(x) & GE(i(x),1400)) →T(x))
• E2: y (E(y) →S(y))
• E3: xy ((E(x) & P(y)) → ~GE(i(x),i(y)))
• (we can read “for all x and for all y if x is an
employee and y is president, the income of x
is not greater than or equal to the income of
y)
13
Syntax of FOPL
• An atomic formula is a wffs (well-formed
formulas) .
• If P and Q are wffs, then P ,~P, P & Q, P V Q,
P Q, x P(x), and x P(x) are wffs.
• Wffs are formed only by applying the above rules a
finite number of times.
• The above rules state that all wffs are formed from
atomic formulas and the proper application of
quantifiers and logical connections.
14
Syntax of FOPL
• Some examples of valid wffs are
• MAN(john)
• PILOT(father-of(bill))
• xyz((FATHER(x,y)&FATHER(y,z))
→GRANDFATHER(x,z))
• x NUMBER(x) →(y GREATER-THAN(y,x))
15
Syntax of FOPL
• Some examples of statements that are not wffs are:
• P P(x)→Q(x)
• /* Universal quantification is applied to the predicate P(x).
This is invalid in FOPL. */
• MAN(~john)
• /*The expression is invalid since the term John, a constant, is
negated. */
• father-of(Q(x))
• /* The expression is invalid due to it is function with a
predicate argument. */
• MARRIED(MAN,WOMAN)
• /* The expression fails since it is predicate with two predicate
arguments.*/
16
Semantics for FOPL
• When considering specific wffs, we always
have in mind some domain D. If not stated
explicitly, D will be understood from the
context.
• The arguments predicates must be terms
(constant, variables or functions). Therefore,
the domain of each n-place predicate is also
defined over D.
17
Semantics for FOPL
• For Example, our domain might be all entities
that make up the Computer Science &
Engineering Department at the University of
Rajshahi.
• In this case, constants would be Professors
(Dell, Cooke, Gelfond, and so on), Staff
(Martha, Pat, Linda and so on), books, labs,
offices and so forth.
18
Semantics for FOPL
• The functions we may choose might be
advisor-of(x), lab-capacity(y), dept-grade-
average(z), and the predicates MARRIED(x),
TENURED(y), COLLABORATE(x,y) to name a
few.
• When an assignment of values is given to
each term and to each predicate symbol in a
wff, we say an interpretation is given to the
wff.
19
Semantics for FOPL
• If the truth values for two different wffs are
the same under every interpretation, they are
said to be equivalent.
• A predicate (or wff) that has no variables is
called a ground atom.
20
Semantics for FOPL
• For example, the predicate P(x) in x P(x), is
true only if it is true for every value of x in the
domain D.
• Likewise, the P(x) in x P(x) is true only if it is
true for at least one value of x in the domain.
• If the above conditions are not satisfied, the
predicate evaluates to false.
21
Semantics for FOPL
• For example, we want to evaluate the truth
value of the expression E, where
• E: x ((A(a,x) V B(f(x))) & C(x))→D(x)
• In this expression, there are four predicates:
A, B, C, and D.
• The predicate A is a two-place predicate, the
first argument being the constant a, and the
second argument, a variable x.
22
Semantics for FOPL
• The predicates B, C and D are all unary
predicates where the argument of B is a
function f(x), and the argument of C and D is
the variable x.
• Since the whole expression E is quantified
with the universal quantifier x, it will
evaluate to true only if it evaluates to true for
all x in the domain D.
23
Semantics for FOPL
• Thus, to complete our example, suppose E is
interpreted as follows: Define the domain D = {1, 2}
and from D let the interpretation I assign the
following values:
• a=2
• f(1) = 2, f(2) = 1
• A(2,1) = true, A(2,2) = false
• B(1) = true, B(2) = false
• C(1) = true, C(2) = false
• D(1) = false, D(2) = true
24
Semantics for FOPL
• Using a table such as Table 4.3 we can
evaluates E as follows:
a) . If x = 1, A(2,1) evaluates to true, B(2)
evaluates to false, and (A(2,1) V B(2))
evaluates to true. C(1) evaluates to true.
Therefore, the expression in the outer
parentheses evaluates to true. Hence, since
D(1) evaluates to false, the expression E
evaluates to false.
25
Semantics for FOPL
(b) In a similar way, if x =2, the expression can
be shown to evaluate to true.
Consequently, since E is not true for all x, the
expression evaluates to false.
26
Properties of WFFS (well-formed formulas)
28
Table 4.4 Equivalent Logical Expressions
29
Table 4.4 Equivalent Logical Expressions Cont..
31
Properties of WFFS
• A wff is said to be valid if it is true under
every interpretation.
• A wff is said to be inconsistent if it is false
under every interpretation.
• A wff that is not valid is invalid.
• Likewise, a wff that is not inconsistent is
satisfiable.
• Again, this means that a valid wff is satisfiable
and an inconsistent wff is invalid, but the
32
respective converse statements do not hold.
Properties of WFFS
• Finally, we say that a wff Q is a logical
consequence of the wffs P1, P2, P3, .. .. .. , Pn if
and only if whenever P1 & P2 & P3 & .. .. .. &
Pn is true under an interpretation.
• Then, Q is also true.
33
Properties of WFFS
• Example :
(a). P &~P is inconsistent and P V ~P is valid
since the first is false under every
interpretation and the second is true under
every interpretation.
(b). From the two wffs
CLEVER(bill) and
x CLEVER(x) → SUCCEED(x)
34
Properties of WFFS
• We can show that SUCCEED(bill) is a logical
consequence. Thus, assume that both
CLEVER(bill) and
x CLEVER(x) → SUCCEED(x)
are true under an interpretation.
• Then
CLEVER(bill) → SUCCEED(bill)
Is certainly true since the wff was assumed to be
true for all x, including x= bill.
35
Properties of WFFS
• But,
CLEVER(bill) → SUCCEED(bill) = ~ CLEVER(bill) V SUCCEED(bill)
are equivalent and, since CLEVER(bill) is true,
~CLEVER(bill) is false and, therefore,
SUCCEED(bill) must be true. Thus, we
conclude SUCCEED(bill) is a logical
consequence of
CLEVER(bill) and x CLEVER(x) → SUCCEED(x)
36
CONVERSION TO CLAUSAL FORM
• As noted earlier, we are interested in mechanical
inference by programs using symbolic FOPL expressions.
• One method we shall examine is called resolution.
• It requires that all statements be converted into a
normalized clausal form.
• We define a clause as the disjunction of a number of
literals.
• A ground clause is one in which no variables occur in
the expression.
• A Horn clause is a clause with at most one positive
literal.
37
CONVERSION TO CLAUSAL FORM
• Clausal Conversion Procedure:
• Step 1: Eliminate all implication and
equivalency connectives (Use ~P V Q in place
of P → Q and (~P V Q) & (~Q V P) in place of
P Q).
• Step 2: Move all negations in to immediately
precede an atom (use P in place of ~(~P), and
DeMorgran’s laws, x ~F[x] in place of ~(x)
F[x] and x ~F[x] in place of ~(x) F[x] ).
38
CONVERSION TO CLAUSAL FORM
• Step 3: Rename variables, if necessary, so that
all quantifiers have variable assignments; that
is, rename variables so that variables bound
by a different quantifier.
• For example, in the expression
• x (P(x) → (x Q(x)))
rename the second “dummy” variable x which is
bound by the existential quantifier to be a
different variable, say y, to give
x (P(x) → (y Q(y))).
39
CONVERSION TO CLAUSAL FORM
• Step 4: Skolemize by replacing all existentially
quantified variables with Skolem functions as
described above, and deleting the
corresponding existential quantifiers.
• Step 5: Move all universal quantifiers to left of
the expression and put the expression on the
right into CNF (Clausal Normal Form).
•
40
CONVERSION TO CLAUSAL FORM
41
Assignment-3
• Determine whether each of the following
sentences is (i) satisfiable, (ii) contradictory
(iii) valid.
• S1: (P & Q) V ~(P & Q)
• S2: (P V Q) → (P &Q)
• S3: (P & Q) → R V ~Q
• S4: (P V Q) & (P V ~Q) V P
• S5: P → Q → ~P
• S6: P V Q & ~P V ~Q & P
42
•THANKS
•THE END
43