# Knowledge representation review

Post on 13-Feb-2017

212 views

Embed Size (px)

TRANSCRIPT

Artificial Intelligence: Methods and Applications

Lecture 3: Review of FOPL

Henrik Bjrklund Ruvan Weerasinghe

Ume University

What Id be doing

Topics in Knowledge Representation

12th Nov (Tue) Revision of FOL

15th Nov (Fri) Reasoning with categories

2nd Dec (Tue) Reasoning with uncertainty

6th Dec (Fri) Probabilistic reasoning

Representing Knowledge

Explicit vs Tacit

Declarative vs Procedural

Facts and Rules

Need to

Represent and

Reason (do inference)

Representing Knowledge

Natural language

Database schema

Propositional logic

Restrictions on representation (syntax)

Well defined inferencing (semantics)

First order (predicate) logic

Overcomes representational restriction

Maintains inferencing mechanism

Desirable Properties of a KR System

Representational adequacy

Inferential adequacy

Inferential efficiency

Acquisitional efficiency

Hard to optimize all in one formalism

Main issue: knowledge acquisition bottleneck

Knowledge Engineering

Identify the questions of interest

Gather the knowledge (acquisition)

Define predicates, constants (the ontology)

Encode the axioms of the domain

Encode the specific knowledge of the task

Use the system

Debug/maintain the system

Example

Finding out if snakes are dangerous!

color, head shape, length, movement, marking

Turns out only some ~10% of the species are actually venomous

Pythons can still maim or kill (without being venomous)!

Find out the snake taxonomy

Related to their dangerousness

Example

Representing a snake called slithery

snake_slithery / slithery_snake

snake(slithery) / slithery(snake)

called_slithery(snake)!

isa(snake, slithery) / isa(slithery, snake)

isa or instance?

Subjects and Predicates transform (usually)

Slithery is not poisonous

Example

The general knowledge in the domain?

Snakes can be venomous

Snakes can bite

Snakes can constrict (strangulate)

Venom, constriction can be fatal

Other implicit knowledge?

By default snakes are not harmful?

If someone dies, they stay dead!

Example

Specific domain knowledge Snake habitats

Snake motion

Snake color and marking

Snake length

Snake food

When and why do snakes sting, bite, constrict

http://www.sciencekids.co.nz/sciencefacts/animals/snake.html

http://www.sciencekids.co.nz/sciencefacts/animals/snake.html

Exercise

If it doesnt rain tomorrow Carl will play tennis

Stephan is not a graduate but is a good student

All basketball players are tall

Some people like durian

If promising was a virtue Peter would be a saint

Nobody likes taxes

Everyone is loyal to someone

Common Mistake 1

Typically, is the main connective with

Common mistake: using as the main connective with :

x At(x,UU) Smart(x)

means Everyone is at UU and everyone is smart

How do you say Everyone at UU is smart?

Common Mistake 2

Typically, is the main connective with

Common mistake: using as the main connective with :

x At(x,UU) Smart(x)

is true if there is anyone who is not at UU!

How do you say Someone at UU is smart?

Summary of Propositional Logic

PL is declarative

PL allows partial/disjunctive/negated information (unlike most data structures and databases)

PL is compositional: meaning of B P is derived from meaning of B and of P

Meaning in PL is context-independent (unlike natural language, where meaning depends on context)

PL has very limited expressive power E.g., cannot say all basketball players are tall

except by writing one sentence for each basketball player!

Why First Order (Predicate) Logic?

Weaknesses of Propositional Logic Cannot represent/reason at sub-sentence level

e.g. P = It is raining Q = It is not raining But ~P Q

Cannot generalise (does not allow variables) e.g. P = Socrates is mortal Q = Plato is mortal How to represent All men are mortal?

Laws of FOPL

If S is a sentence so is ~S

If S1 & S2 are sentences so is S1 S2 If S1 & S2 are sentences so is S1 S2 If S1 & S2 are sentences so is S1 S2 If S1 & S2 are sentences so is S1 S2 If X is a variable and S a sentence then

(a) X S is a sentence (b) X S is a sentence

Laws of FOPL (contd.)

(for all) is the universal quantifier

means true for all values of the variable

(there exists) is the existential quantifier

means true for some values of the variable

e.g. Y X mother(X, Y) X Y father(X, Y) mother(X, Y) parent(X, Y)

Relationships of Quantifiers

~X p(X) = X ~p(X)

~X p(X) = X ~p(X)

X (p(X) q(X)) = X p(X) Y q(Y)

X (p(X) q(X)) = X p(X) Y q(Y)

NB: X p(X) = Y p(Y) and X p(X) = Y p(Y)

Ex.: Why is X (p(X) q(X)) X p(X) Y q(Y) ?

and X (p(X) q(X)) X p(X) Y q(Y) ?

Resolution: An Algorithm for Reasoning with PL

STEP 1: Convert PL statements to standard form i.e. into a conjuction of disjuncts

STEP 2: Prove by refutation i.e. by proving that the negation of the goal

leads to a contradiction

Example of Resolution for PL

Axiom Clause

P P

(P Q) R ~P ~Q R

(S T) Q ~S Q ~T Q

T T

Example of Resolution for PL

Resolution: Prove R. So we assume ~R ~P ~Q R (2) ~R (G) ~P ~Q P (1) ~T Q (4) ~Q ~T T (5) [] (contradiction) So, we have proved R.

Example for FOPL

All Romans who know Marcus either hate Caesar or think that anyone who hates anyone is crazy

Step I (a)

Convert to clausal form e.g.

All Romans who know Marcus either hate Caesar or think that anyone who hates anyone is crazy

X(roman(X) knows(X, marcus)) hate(X, caesar) (Y Z hate(Y, Z) think_crazy(X, Y))

Step I (b)

Convert to conjuctive normal form Eliminate by rule

Standardise variables by renaming

Move universal quantifiers to the left

Eliminate existential quantifiers

Convert to conjunction of disjuncts

Rename variables taking each conjunct as clause

Step I (b) Example

Eliminate by rule i.e. a b to be replaced by ~a b

further using other rules to convert all to e.g. ~(a b) = ~a ~b we get:

X(~roman(X) ~knows(X, marcus)) (hate(X, caesar) (Y Z ~hate(Y, Z) think_crazy(X, Y)))

Step I (b) Example (contd)

Standardise variables by renaming e.g. Xp(X) Xq(X) = Xp(X) Yq(Y)

Move universal quantifiers to left

XYZ(~roman(X) ~knows(X, marcus)) (hate(X,caesar) (~hate(Y,Z) think_crazy(X, Y)))

Step I (b) Example (contd)

Eliminate any existential quantifiers X student(X) replaced by student(S1) where

S1 is a (skolem) constant

Y Z hate(Y, Z) would however be replaced by a skolem function S2 in Y hate(S2(Y),Y)

Convert to conjunction of disjuncts substitute (a b) c = (a c) (b c) etc.

~roman(X) ~knows(X, marcus) hate(X, caesar) ~hate(Y, Z) think_carzy(X, Y)

Step 2

Resolution works by combining two clauses in opposite form (one negated) to produce a resolvent clause by cancelling out the predicate concerned.

In cases where such predicates contain arguments that are non-identical, the matching substitution (unification) needs to be applied.

Step 2 Example

winter summer man(john) woman(john) ~winter cold ~man(john) male(john) man(john) woman(john) ~man(X) male(X)

summer cold woman(john) male(john)

woman(john) male(john)

Unification

The terms f(X, a(b,c)) and f(d, a(Z, c)) unify.

Z c

a d

f

b c

a X

f

The terms are made equal if d is substituted for X, and b is substituted for Z. We also say X is instantiated to d and Z is instantiated to b, or X/d, Z/b.

Unification

The terms f(X, a(b,c)) and f(Z, a(Z, c)) unify.

Z c

a Z

f

b c

a X

f

Note that Z co-refers within the term. Here, X/b, Z/b.

Unification (not!)

The terms f(c, a(b,c)) and f(Z, a(Z, c)) do not unify.

Z c

a Z

f

b c

a c

f

No matter how hard you try, these two terms cannot be made identical by substituting terms for variables.

Unification Exercise

Do terms g(Z, f(A, 17, B), A+B, 17) and

g(C, f(D, D, E), C, E) unify?

A B

+ f

g

Z 17

A B 17

C f

g

C E

D E D

Example - English [1] Marcus is a man

[2] Marcus is a Pompeian

[3] All Pompeians are Romans

[4] Caesar is a ruler

[5] All Romans are either loyal to Caesar or hate Caesar

[6] Everyone is loyal to someone

[7] People only try to assassinate rulers they are not loyal to

[8] Marcus tries to assassinate Caesar

Query: Does Marcus hate Caesar?

Example - FOPL [1] man(Marcus)

[2] Pompeian(Marcus)

[3] X Pompeian(X) Roman(X)

[4] ruler(Caesar)

[5] X Roman(X) loyalto(X,

Recommended