University of Dar Es Salaam Coict: Department of Computer Science & Eng
University of Dar Es Salaam Coict: Department of Computer Science & Eng
COICT
Department of Computer Science & Eng.
Lecturer: Nyamwihula, W.
Block B: Room B09
Mobile: 0784281242/0754588001
Email: [email protected]
Outlines
Knowledge representation in AI
Symbolic Logic
Symbolic logic representation
Formal system
Propositional logic
Predicate logic
Theorem proving
1. Knowledge representation
S =< A , F , A , >
O formal system is a quadruple
A rule of inferenceR of arity n is an
association:
R
R F n F , y = y1 ,..., y n x, x, y i F , i = 1, n
Immediate consequence = {y , ... , y } E = A
1 n 0
Be the set of premises
E1 = E 0 {x| y E 0n , y x} E 2 = E1 {x| y E1n , y x}
n 1 n 1
E i ( i 0)
An element
is an immediate consequence of a set of premises
Formal systems - cont
If E 0 = A (then
= )the elements of Ei are called theorems
Formal language
3.1 Syntax
Alphabet
A well-formed formula (wff) in propositional logic is:
(1) An atom is a wff
(2) If P is a wff, then ~P is a wff.
(3) If P and Q are wffs then PQ, PQ, PQ si PQ are wffs.
(4) The set of all wffs can be generated by repeatedly applying
rules (1)..(3).
3.2 Semantics
Interpretation
Evaluation function of a formula
Properties of wffs
Valid / tautulogy
Satisfiable
Contradiction
Equivalent formulas
Semantics - cont
A formula F is a logical consequence of a
formula P
A formula F is a logical consequence of a set
of formulas P1,…Pn
Notation of logical consequence P1,…Pn F.
Theorem. Formula F is a logical
consequence of a set of formulas P1,…Pn if
the formula P1,…Pn F is valid.
Teorema. Formula F is a logical
consequence of a set of formulas P1,…Pn if
the formula P1… Pn ~F is a contradiction.
Equivalence rules
Asociativitate (P Q) R P (Q R) (P Q) R P (Q R)
Distributivitate P (Q R) (P Q) (P R) P (Q R) (P Q) (P R)
De Morgan ~ (P Q) ~ P ~ Q ~ (P Q) ~ P ~ Q
Eliminarea
implicatiei P Q ~ P Q
Eliminarea
implicatiei duble P Q (P Q) (Q P)
3.3 Obtaining new knowledge
Conceptualization
Reprezentation in a formal language
Model theory
KB || x M
Proof theory
KB |S x M
Monotonic logics
Non-monotonic logics
3.4 Inference rules
P
PQ
Modus Ponens Q
Substitution
PQ
Chain rule QR
PR
P
AND introduction Q
PQ
Transposition PQ
~ Q ~ P
Example
Mihai has money
The car is white
The car is nice
If the car is white or the car is nice and
Mihai has money then Mihai goes to the
mountain
B
A
F
(A F) B C
3. First order predicate logic
3.1 Syntax
Be D a domain of values. A term is defined as:
(1)A constant is a term with a fixed value
belonging to D.
(2)A variable is a term which may take values in
D.
(3)If f is a function of n arguments and t ,..t are
1 n
terms then f(t1,..tn) is a term.
(4)All terms are generated by the application of
rules (1)…(3).
Syntax PL - cont
Predicates of arity n
Atom or atomic formula.
Literal
Termeni Predicate
P
(x)(y) loves(x,y)
(y)(x)loves(x,y)
3.4. Inference rules in PL
Modus Ponens
Substitution
Chaining
Transpozition
AND elimination (AE)
AND introduction (AI)
Universal instantiation (UI)
Existential instantiation (EI)
Rezolution
Example
Horses are faster than dogs and there is a greyhound that is
faster than every rabbit. We know that Harry is a horse and that
Ralph is a rabbit. Derive that Harry is faster than Ralph.
Horse(x) Greyhound(y)
Dog(y) Rabbit(z)
Faster(y,z))
Rabbit(Ralph)
y Greyhound(y) Dog(y)
x y z Faster(x,y) Faster(y,z) Faster(x,z)
Proof example
Theorem: Faster(Harry, Ralph) ?
Proof using inference rules
1. x y Horse(x) Dog(y) Faster(x,y)
2. y Greyhound(y) (z Rabbit(z) Faster(y,z))
3. y Greyhound(y) Dog(y)
4. xyz Faster(x,y) Faster(y,z) Faster(x,z)
5. Horse(Harry)
6. Rabbit(Ralph)
7. Greyhound(Greg) (z Rabbit(z) Faster(Greg,z)) 2, EI
8. Greyhound(Greg) 7, AE
9. z Rabbit(z) Faster(Greg,z)) 7, AE
Proof example - cont
10. Rabbit(Ralph) Faster(Greg,Ralph) 9, UI
11. Faster(Greg,Ralph) 6,10, MP
12. Greyhound(Greg) Dog(Greg) 3, UI
13. Dog(Greg) 12, 8, MP
14. Horse(Harry) Dog(Greg) Faster(Harry, Greg) 1, UI
15. Horse(Harry) Dog(Greg) 5, 13, AI
16. Faster(Harry, Greg) 14, 15, MP
17. Faster(Harry, Greg) Faster(Greg, Ralph) Faster(Harry,Ralph)
4, UI
18. Faster(Harry, Greg) Faster(Greg, Ralph) 16, 11, AI
19. Faster(Harry,Ralph) 17, 19, MP