Individuals and Relations It is useful to view the world as - - PowerPoint PPT Presentation

individuals and relations
SMART_READER_LITE
LIVE PREVIEW

Individuals and Relations It is useful to view the world as - - PowerPoint PPT Presentation

Individuals and Relations It is useful to view the world as consisting of individuals (objects, things) and relations among individuals. Often features are made from relations among individuals and functions of individuals. Reasoning in terms


slide-1
SLIDE 1

Individuals and Relations

It is useful to view the world as consisting of individuals (objects, things) and relations among individuals. Often features are made from relations among individuals and functions of individuals. Reasoning in terms of individuals and relationships can be simpler than reasoning in terms of features, if we can express general knowledge that covers all individuals. Sometimes we may know some individual exists, but not which one. Sometimes there are infinitely many individuals we want to refer to (e.g., set of all integers, or the set of all stacks of blocks).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 1

slide-2
SLIDE 2

Role of Semantics in Automated Reasoning

in(kim,cs_building) in(kim,r123). part_of(r123,cs_building). in(X,Y) ← ฀ part_of(Z,Y) ∧ in(X,Z). kim r123 r023 cs_building in( , ) part_of( , ) person( )

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 2

slide-3
SLIDE 3

Features of Automated Reasoning

Users can have meanings for symbols in their head. The computer doesn’t need to know these meanings to derive logical consequence. Users can interpret any answers according to their meaning.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 3

slide-4
SLIDE 4

Decision-theoretic Planning

flat or modular or hierarchical explicit states or features or individuals and relations static or finite stage or indefinite stage or infinite stage fully observable or partially observable deterministic or stochastic dynamics goals or complex preferences single agent or multiple agents knowledge is given or knowledge is learned perfect rationality or bounded rationality

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 4

slide-5
SLIDE 5

Representational Assumptions of Datalog

An agent’s knowledge can be usefully described in terms of individuals and relations among individuals. An agent’s knowledge base consists of definite and positive statements. The environment is static. There are only a finite number of individuals of interest in the

  • domain. Each individual can be given a unique name.

= ⇒ Datalog

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 5

slide-6
SLIDE 6

Syntax of Datalog

A variable starts with upper-case letter. A constant starts with lower-case letter or is a sequence of digits (numeral). A predicate symbol starts with lower-case letter. A term is either a variable or a constant. An atomic symbol (atom) is of the form p or p(t1, . . . , tn) where p is a predicate symbol and ti are terms.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 6

slide-7
SLIDE 7

Syntax of Datalog (cont)

A definite clause is either an atomic symbol (a fact) or of the form: a

b1 ∧ · · · ∧ bm

  • head

body where a and bi are atomic symbols. query is of the form ?b1 ∧ · · · ∧ bm. knowledge base is a set of definite clauses.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 7

slide-8
SLIDE 8

Example Knowledge Base

in(kim, R) ← teaches(kim, cs322) ∧ in(cs322, R). grandfather(william, X) ← father(william, Y ) ∧ parent(Y , X). slithy(toves) ← mimsy ∧ borogroves ∧

  • utgrabe(mome, Raths).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 8

slide-9
SLIDE 9

Semantics: General Idea

A semantics specifies the meaning of sentences in the language. An interpretation specifies: what objects (individuals) are in the world the correspondence between symbols in the computer and

  • bjects & relations in world

◮ constants denote individuals ◮ predicate symbols denote relations c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 9

slide-10
SLIDE 10

Formal Semantics

An interpretation is a triple I = D, φ, π, where D, the domain, is a nonempty set. Elements of D are individuals. φ is a mapping that assigns to each constant an element of

  • D. Constant c denotes individual φ(c).

π is a mapping that assigns to each n-ary predicate symbol a relation: a function from Dn into {TRUE, FALSE}.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 10

slide-11
SLIDE 11

Example Interpretation

Constants: phone, pencil, telephone. Predicate Symbol: noisy (unary), left of (binary). D = {✂,☎,✎}. φ(phone) = ☎, φ(pencil) = ✎, φ(telephone) = ☎. π(noisy): ✂

FALSE

TRUE

FALSE

π(left of ): ✂,✂

FALSE

✂,☎

TRUE

✂,✎

TRUE

☎,✂

FALSE

☎,☎

FALSE

☎,✎

TRUE

✎,✂

FALSE

✎,☎

FALSE

✎,✎

FALSE

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 11

slide-12
SLIDE 12

Important points to note

The domain D can contain real objects. (e.g., a person, a room, a course). D can’t necessarily be stored in a computer. π(p) specifies whether the relation denoted by the n-ary predicate symbol p is true or false for each n-tuple of individuals. If predicate symbol p has no arguments, then π(p) is either

TRUE or FALSE.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 12

slide-13
SLIDE 13

Truth in an interpretation

A constant c denotes in I the individual φ(c). Ground (variable-free) atom p(t1, . . . , tn) is true in interpretation I if π(p)(φ(t1), . . . , φ(tn)) = TRUE in interpretation I and false otherwise. Ground clause h ← b1 ∧ . . . ∧ bm is false in interpretation I if h is false in I and each bi is true in I, and is true in interpretation I

  • therwise.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 13

slide-14
SLIDE 14

Example Truths

In the interpretation given before, which of following are true? noisy(phone) noisy(telephone) noisy(pencil) left of (phone, pencil) left of (phone, telephone) noisy(phone) ← left of (phone, telephone) noisy(pencil) ← left of (phone, telephone) noisy(pencil) ← left of (phone, pencil) noisy(phone) ← noisy(telephone) ∧ noisy(pencil)

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 14

slide-15
SLIDE 15

Example Truths

In the interpretation given before, which of following are true? noisy(phone) true noisy(telephone) true noisy(pencil) false left of (phone, pencil) true left of (phone, telephone) false noisy(phone) ← left of (phone, telephone) true noisy(pencil) ← left of (phone, telephone) true noisy(pencil) ← left of (phone, pencil) false noisy(phone) ← noisy(telephone) ∧ noisy(pencil) true

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 15

slide-16
SLIDE 16

Models and logical consequences (recall)

A knowledge base, KB, is true in interpretation I if and only if every clause in KB is true in I. A model of a set of clauses is an interpretation in which all the clauses are true. If KB is a set of clauses and g is a conjunction of atoms, g is a logical consequence of KB, written KB | = g, if g is true in every model of KB. That is, KB | = g if there is no interpretation in which KB is true and g is false.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 16

slide-17
SLIDE 17

User’s view of Semantics

  • 1. Choose a task domain: intended interpretation.
  • 2. Associate constants with individuals you want to name.
  • 3. For each relation you want to represent, associate a predicate

symbol in the language.

  • 4. Tell the system clauses that are true in the intended

interpretation: axiomatizing the domain.

  • 5. Ask questions about the intended interpretation.
  • 6. If KB |

= g, then g must be true in the intended interpretation.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 17

slide-18
SLIDE 18

Computer’s view of semantics

The computer doesn’t have access to the intended interpretation. All it knows is the knowledge base. The computer can determine if a formula is a logical consequence of KB. If KB | = g then g must be true in the intended interpretation. If KB | = g then there is a model of KB in which g is false. This could be the intended interpretation.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 18

slide-19
SLIDE 19

Role of Semantics in an RRS

in(kim,cs_building) in(kim,r123). part_of(r123,cs_building). in(X,Y) ← ฀ part_of(Z,Y) ∧ in(X,Z). kim r123 r023 cs_building in( , ) part_of( , ) person( )

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.1, Page 19

slide-20
SLIDE 20

Variables

Variables are universally quantified in the scope of a clause. A variable assignment is a function from variables into the domain. Given an interpretation and a variable assignment, each term denotes an individual and each clause is either true or false. A clause containing variables is true in an interpretation if it is true for all variable assignments.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 1

slide-21
SLIDE 21

Queries and Answers

A query is a way to ask if a body is a logical consequence of the knowledge base: ?b1 ∧ · · · ∧ bm. An answer is either an instance of the query that is a logical consequence of the knowledge base KB, or no if no instance is a logical consequence of KB.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 2

slide-22
SLIDE 22

Example Queries

KB =    in(kim, r123). part of (r123, cs building). in(X, Y ) ← part of (Z, Y ) ∧ in(X, Z). Query Answer ?part of (r123, B).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 3

slide-23
SLIDE 23

Example Queries

KB =    in(kim, r123). part of (r123, cs building). in(X, Y ) ← part of (Z, Y ) ∧ in(X, Z). Query Answer ?part of (r123, B). part of (r123, cs building) ?part of (r023, cs building).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 4

slide-24
SLIDE 24

Example Queries

KB =    in(kim, r123). part of (r123, cs building). in(X, Y ) ← part of (Z, Y ) ∧ in(X, Z). Query Answer ?part of (r123, B). part of (r123, cs building) ?part of (r023, cs building). no ?in(kim, r023).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 5

slide-25
SLIDE 25

Example Queries

KB =    in(kim, r123). part of (r123, cs building). in(X, Y ) ← part of (Z, Y ) ∧ in(X, Z). Query Answer ?part of (r123, B). part of (r123, cs building) ?part of (r023, cs building). no ?in(kim, r023). no ?in(kim, B).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 6

slide-26
SLIDE 26

Example Queries

KB =    in(kim, r123). part of (r123, cs building). in(X, Y ) ← part of (Z, Y ) ∧ in(X, Z). Query Answer ?part of (r123, B). part of (r123, cs building) ?part of (r023, cs building). no ?in(kim, r023). no ?in(kim, B). in(kim, r123) in(kim, cs building)

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 7

slide-27
SLIDE 27

Electrical Environment

light two-way switch switch

  • ff
  • n

power

  • utlet

circuit breaker

  • utside power

cb1 s1 w1 s2 w2 w0 l1 w3 s3 w4 l2 p1 w5 cb2 w6 p2

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 8

slide-28
SLIDE 28

Axiomatizing the Electrical Environment

% light(L) is true if L is a light light(l1). light(l2). % down(S) is true if switch S is down down(s1). up(s2). up(s3). % ok(D) is true if D is not broken

  • k(l1).
  • k(l2).
  • k(cb1).
  • k(cb2).

?light(l1). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 9

slide-29
SLIDE 29

Axiomatizing the Electrical Environment

% light(L) is true if L is a light light(l1). light(l2). % down(S) is true if switch S is down down(s1). up(s2). up(s3). % ok(D) is true if D is not broken

  • k(l1).
  • k(l2).
  • k(cb1).
  • k(cb2).

?light(l1). = ⇒ yes ?light(l6). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 10

slide-30
SLIDE 30

Axiomatizing the Electrical Environment

% light(L) is true if L is a light light(l1). light(l2). % down(S) is true if switch S is down down(s1). up(s2). up(s3). % ok(D) is true if D is not broken

  • k(l1).
  • k(l2).
  • k(cb1).
  • k(cb2).

?light(l1). = ⇒ yes ?light(l6). = ⇒ no ?up(X). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 11

slide-31
SLIDE 31

Axiomatizing the Electrical Environment

% light(L) is true if L is a light light(l1). light(l2). % down(S) is true if switch S is down down(s1). up(s2). up(s3). % ok(D) is true if D is not broken

  • k(l1).
  • k(l2).
  • k(cb1).
  • k(cb2).

?light(l1). = ⇒ yes ?light(l6). = ⇒ no ?up(X). = ⇒ up(s2), up(s3)

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 12

slide-32
SLIDE 32

connected to(X, Y ) is true if component X is connected to Y connected to(w0, w1) ← up(s2). connected to(w0, w2) ← down(s2). connected to(w1, w3) ← up(s1). connected to(w2, w3) ← down(s1). connected to(w4, w3) ← up(s3). connected to(p1, w3). ?connected to(w0, W ). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 13

slide-33
SLIDE 33

connected to(X, Y ) is true if component X is connected to Y connected to(w0, w1) ← up(s2). connected to(w0, w2) ← down(s2). connected to(w1, w3) ← up(s1). connected to(w2, w3) ← down(s1). connected to(w4, w3) ← up(s3). connected to(p1, w3). ?connected to(w0, W ). = ⇒ W = w1 ?connected to(w1, W ). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 14

slide-34
SLIDE 34

connected to(X, Y ) is true if component X is connected to Y connected to(w0, w1) ← up(s2). connected to(w0, w2) ← down(s2). connected to(w1, w3) ← up(s1). connected to(w2, w3) ← down(s1). connected to(w4, w3) ← up(s3). connected to(p1, w3). ?connected to(w0, W ). = ⇒ W = w1 ?connected to(w1, W ). = ⇒ no ?connected to(Y , w3). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 15

slide-35
SLIDE 35

connected to(X, Y ) is true if component X is connected to Y connected to(w0, w1) ← up(s2). connected to(w0, w2) ← down(s2). connected to(w1, w3) ← up(s1). connected to(w2, w3) ← down(s1). connected to(w4, w3) ← up(s3). connected to(p1, w3). ?connected to(w0, W ). = ⇒ W = w1 ?connected to(w1, W ). = ⇒ no ?connected to(Y , w3). = ⇒ Y = w2, Y = w4, Y = p1 ?connected to(X, W ). = ⇒

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 16

slide-36
SLIDE 36

connected to(X, Y ) is true if component X is connected to Y connected to(w0, w1) ← up(s2). connected to(w0, w2) ← down(s2). connected to(w1, w3) ← up(s1). connected to(w2, w3) ← down(s1). connected to(w4, w3) ← up(s3). connected to(p1, w3). ?connected to(w0, W ). = ⇒ W = w1 ?connected to(w1, W ). = ⇒ no ?connected to(Y , w3). = ⇒ Y = w2, Y = w4, Y = p1 ?connected to(X, W ). = ⇒ X = w0, W = w1, . . .

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 17

slide-37
SLIDE 37

% lit(L) is true if the light L is lit lit(L) ← light(L) ∧ ok(L) ∧ live(L). % live(C) is true if there is power coming into C live(Y ) ← connected to(Y , Z) ∧ live(Z). live(outside). This is a recursive definition of live.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 18

slide-38
SLIDE 38

Recursion and Mathematical Induction

above(X, Y ) ← on(X, Y ). above(X, Y ) ← on(X, Z) ∧ above(Z, Y ). This can be seen as: Recursive definition of above: prove above in terms of a base case (on) or a simpler instance of itself; or Way to prove above by mathematical induction: the base case is when there are no blocks between X and Y , and if you can prove above when there are n blocks between them, you can prove it when there are n + 1 blocks.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 19

slide-39
SLIDE 39

Limitations

Suppose you had a database using the relation: enrolled(S, C) which is true when student S is enrolled in course C. Can you define the relation: empty course(C) which is true when course C has no students enrolled in it? Why? or Why not?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 20

slide-40
SLIDE 40

Limitations

Suppose you had a database using the relation: enrolled(S, C) which is true when student S is enrolled in course C. Can you define the relation: empty course(C) which is true when course C has no students enrolled in it? Why? or Why not? empty course(C) doesn’t logically follow from a set of enrolled relation because there are always models where someone is enrolled in a course!

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.2, Page 21

slide-41
SLIDE 41

Reasoning with Variables

An instance of an atom or a clause is obtained by uniformly substituting terms for variables. A substitution is a finite set of the form {V1/t1, . . . , Vn/tn}, where each Vi is a distinct variable and each ti is a term. The application of a substitution σ = {V1/t1, . . . , Vn/tn} to an atom or clause e, written eσ, is the instance of e with every occurrence of Vi replaced by ti.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 1

slide-42
SLIDE 42

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(X, Y , Z, e)σ1 = p(A, b, C, D)σ2 = p(X, Y , Z, e)σ2 = p(A, b, C, D)σ3 = p(X, Y , Z, e)σ3 =

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 2

slide-43
SLIDE 43

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(A, b, C, e) p(X, Y , Z, e)σ1 = p(A, b, C, D)σ2 = p(X, Y , Z, e)σ2 = p(A, b, C, D)σ3 = p(X, Y , Z, e)σ3 =

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 3

slide-44
SLIDE 44

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(A, b, C, e) p(X, Y , Z, e)σ1 = p(A, b, C, e) p(A, b, C, D)σ2 = p(X, Y , Z, e)σ2 = p(A, b, C, D)σ3 = p(X, Y , Z, e)σ3 =

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 4

slide-45
SLIDE 45

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(A, b, C, e) p(X, Y , Z, e)σ1 = p(A, b, C, e) p(A, b, C, D)σ2 = p(X, b, Z, e) p(X, Y , Z, e)σ2 = p(A, b, C, D)σ3 = p(X, Y , Z, e)σ3 =

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 5

slide-46
SLIDE 46

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(A, b, C, e) p(X, Y , Z, e)σ1 = p(A, b, C, e) p(A, b, C, D)σ2 = p(X, b, Z, e) p(X, Y , Z, e)σ2 = p(X, b, Z, e) p(A, b, C, D)σ3 = p(X, Y , Z, e)σ3 =

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 6

slide-47
SLIDE 47

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(A, b, C, e) p(X, Y , Z, e)σ1 = p(A, b, C, e) p(A, b, C, D)σ2 = p(X, b, Z, e) p(X, Y , Z, e)σ2 = p(X, b, Z, e) p(A, b, C, D)σ3 = p(V , b, W , e) p(X, Y , Z, e)σ3 =

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 7

slide-48
SLIDE 48

Application Examples

The following are substitutions: σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {A/X, Y /b, C/Z, D/e} σ3 = {A/V , X/V , Y /b, C/W , Z/W , D/e} The following shows some applications: p(A, b, C, D)σ1 = p(A, b, C, e) p(X, Y , Z, e)σ1 = p(A, b, C, e) p(A, b, C, D)σ2 = p(X, b, Z, e) p(X, Y , Z, e)σ2 = p(X, b, Z, e) p(A, b, C, D)σ3 = p(V , b, W , e) p(X, Y , Z, e)σ3 = p(V , b, W , e)

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 8

slide-49
SLIDE 49

Unifiers

Substitution σ is a unifier of e1 and e2 if e1σ = e2σ. Substitution σ is a most general unifier (mgu) of e1 and e2 if

◮ σ is a unifier of e1 and e2; and ◮ if substitution σ′ also unifies e1 and e2, then eσ′ is an instance

  • f eσ for all atoms e.

If two atoms have a unifier, they have a most general unifier.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 9

slide-50
SLIDE 50

Unification Example

Which of the following are unifiers of p(A, b, C, D) and p(X, Y , Z, e): σ1 = {X/A, Y /b, Z/C, D/e} σ2 = {Y /b, D/e} σ3 = {X/A, Y /b, Z/C, D/e, W /a} σ4 = {A/X, Y /b, C/Z, D/e} σ5 = {X/a, Y /b, Z/c, D/e} σ6 = {A/a, X/a, Y /b, C/c, Z/c, D/e} σ7 = {A/V , X/V , Y /b, C/W , Z/W , D/e} σ8 = {X/A, Y /b, Z/A, C/A, D/e} Which are most general unifiers?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 10

slide-51
SLIDE 51

Unification Example

p(A, b, C, D) and p(X, Y , Z, e) have as unifiers: σ1 = {X/A, Y /b, Z/C, D/e} σ4 = {A/X, Y /b, C/Z, D/e} σ7 = {A/V , X/V , Y /b, C/W , Z/W , D/e} σ6 = {A/a, X/a, Y /b, C/c, Z/c, D/e} σ8 = {X/A, Y /b, Z/A, C/A, D/e} σ3 = {X/A, Y /b, Z/C, D/e, W /a} The first three are most general unifiers. The following substitutions are not unifiers: σ2 = {Y /b, D/e} σ5 = {X/a, Y /b, Z/c, D/e}

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 11

slide-52
SLIDE 52

1: procedure unify(t1, t2)

⊲ Returns mgu of t1 and t2 or ⊥.

2:

E ← {t1 = t2} ⊲ Set of equality statements

3:

S ← {} ⊲ Substitution

4:

while E = {} do

5:

select and remove x = y from E

6:

if y is not identical to x then

7:

if x is a variable then

8:

replace x with y in E and S

9:

S ← {x/y} ∪ S

10:

else if y is a variable then

11:

replace y with x in E and S

12:

S ← {y/x} ∪ S

13:

else if x is p(x1, . . . , xn) and y is p(y1, . . . , yn) then

14:

E ← E ∪ {x1 = y1, . . . , xn = yn}

15:

else

16:

return ⊥ ⊲ t1 and t2 do not unify

17:

return S ⊲ S is mgu of t1 and t2

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 12

slide-53
SLIDE 53

Logical Consequence

Atom g is a logical consequence of KB if and only if: g is an instance of a fact in KB, or there is an instance of a rule g ← b1 ∧ . . . ∧ bk in KB such that each bi is a logical consequence of KB.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 13

slide-54
SLIDE 54

Aside: Debugging false conclusions

To debug answer g that is false in the intended interpretation: If g is a fact in KB, this fact is wrong. Otherwise, suppose g was proved using the rule: g ← b1 ∧ . . . ∧ bk where each bi is a logical consequence of KB.

◮ If each bi is true in the intended interpretation, this clause is

false in the intended interpretation.

◮ If some bi is false in the intended interpretation, debug bi. c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 14

slide-55
SLIDE 55

Proofs

A proof is a mechanically derivable demonstration that a formula logically follows from a knowledge base. Given a proof procedure, KB ⊢ g means g can be derived from knowledge base KB. Recall KB | = g means g is true in all models of KB. A proof procedure is sound if KB ⊢ g implies KB | = g. A proof procedure is complete if KB | = g implies KB ⊢ g.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 15

slide-56
SLIDE 56

Bottom-up proof procedure

KB ⊢ g if there is g′ added to C in this procedure where g = g′θ: C := {}; repeat select clause “h ← b1 ∧ . . . ∧ bm” in KB such that there is a substitution θ such that for all i, there exists b′

i ∈ C and θ′ i where biθ = b′ iθ′ i and

there is no h′ ∈ C and θ′ such that h′θ′ = hθ C := C ∪ {hθ} until no more clauses can be selected.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 16

slide-57
SLIDE 57

Example

live(Y ) ← connected to(Y , Z) ∧ live(Z). live(outside). connected to(w6, w5). connected to(w5, outside).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 17

slide-58
SLIDE 58

Example

live(Y ) ← connected to(Y , Z) ∧ live(Z). live(outside). connected to(w6, w5). connected to(w5, outside). C = {live(outside), connected to(w6, w5), connected to(w5, outside), live(w5), live(w6)}

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 18

slide-59
SLIDE 59

Soundness of bottom-up proof procedure

If KB ⊢ g then KB | = g. Suppose there is a g such that KB ⊢ g and KB | = g. Then there must be a first atom added to C that has an instance that isn’t true in every model of KB. Call it h.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 19

slide-60
SLIDE 60

Soundness of bottom-up proof procedure

If KB ⊢ g then KB | = g. Suppose there is a g such that KB ⊢ g and KB | = g. Then there must be a first atom added to C that has an instance that isn’t true in every model of KB. Call it h. Suppose h isn’t true in model I of KB. There must be an instance of clause in KB of form h′ ← b1 ∧ . . . ∧ bm where

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 20

slide-61
SLIDE 61

Soundness of bottom-up proof procedure

If KB ⊢ g then KB | = g. Suppose there is a g such that KB ⊢ g and KB | = g. Then there must be a first atom added to C that has an instance that isn’t true in every model of KB. Call it h. Suppose h isn’t true in model I of KB. There must be an instance of clause in KB of form h′ ← b1 ∧ . . . ∧ bm where h = h′θ and biθ is an instance of an element of C.

◮ Each biθ is true in I. ◮ h is false in I. ◮ So an instance of this clause is false in I. ◮ Therefore I isn’t a model of KB. ◮ Contradiction. c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 21

slide-62
SLIDE 62

Fixed Point

The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 22

slide-63
SLIDE 63

Fixed Point

The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. Let I be the Herbrand interpretation in which every ground instance of every element of the fixed point is true and every

  • ther atom is false.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 23

slide-64
SLIDE 64

Fixed Point

The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. Let I be the Herbrand interpretation in which every ground instance of every element of the fixed point is true and every

  • ther atom is false.

I is a model of KB. Proof:

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 24

slide-65
SLIDE 65

Fixed Point

The C generated by the bottom-up algorithm is called a fixed point. C can be infinite; we require the selection to be fair. Herbrand interpretation: The domain is the set of constants. We invent a constant if the KB or query doesn’t contain one. Each constant denotes itself. Let I be the Herbrand interpretation in which every ground instance of every element of the fixed point is true and every

  • ther atom is false.

I is a model of KB. Proof: suppose h ← b1 ∧ . . . ∧ bm in KB is false in I. Then h is false and each bi is true in I. Thus h can be added to C. Contradiction to C being the fixed point. I is called a Minimal Model.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 25

slide-66
SLIDE 66

Completeness

If KB | = g then KB ⊢ g. Suppose KB | = g. Then g is true in all models of KB.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 26

slide-67
SLIDE 67

Completeness

If KB | = g then KB ⊢ g. Suppose KB | = g. Then g is true in all models of KB. Thus g is true in the minimal model.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 27

slide-68
SLIDE 68

Completeness

If KB | = g then KB ⊢ g. Suppose KB | = g. Then g is true in all models of KB. Thus g is true in the minimal model. Thus g is in the fixed point.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 28

slide-69
SLIDE 69

Completeness

If KB | = g then KB ⊢ g. Suppose KB | = g. Then g is true in all models of KB. Thus g is true in the minimal model. Thus g is in the fixed point. Thus g is generated by the bottom up algorithm.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 29

slide-70
SLIDE 70

Completeness

If KB | = g then KB ⊢ g. Suppose KB | = g. Then g is true in all models of KB. Thus g is true in the minimal model. Thus g is in the fixed point. Thus g is generated by the bottom up algorithm. Thus KB ⊢ g.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 30

slide-71
SLIDE 71

Top-down Proof procedure

A generalized answer clause is of the form yes(t1, . . . , tk) ← a1 ∧ a2 ∧ . . . ∧ am, where t1, . . . , tk are terms and a1, . . . , am are atoms.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 31

slide-72
SLIDE 72

Top-down Proof procedure

A generalized answer clause is of the form yes(t1, . . . , tk) ← a1 ∧ a2 ∧ . . . ∧ am, where t1, . . . , tk are terms and a1, . . . , am are atoms. The SLD resolution of this generalized answer clause on ai with the clause a ← b1 ∧ . . . ∧ bp, where ai and a have most general unifier θ, is (yes(t1, . . . , tk) ← a1∧ . . . ∧ai−1 ∧ b1∧ . . . ∧bp ∧ ai+1∧ . . . ∧am)θ.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 32

slide-73
SLIDE 73

Top-down Proof Procedure

To solve query ?B with variables V1, . . . , Vk:

Set ac to generalized answer clause yes(V1, . . . , Vk) ← B while ac is not an answer do Suppose ac is yes(t1, . . . , tk) ← a1 ∧ a2 ∧ . . . ∧ am select atom ai in the body of ac choose clause a ← b1 ∧ . . . ∧ bp in KB Rename all variables in a ← b1 ∧ . . . ∧ bp Let θ be the most general unifier of ai and a. Fail if they don’t unify Set ac to (yes(t1, . . . , tk) ← a1 ∧ . . . ∧ ai−1∧ b1 ∧ . . . ∧ bp ∧ ai+1 ∧ . . . ∧ am)θ end while. Answer is V1 = t1, . . . , Vk = tk where ac is yes(t1, . . . , tk) ←

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 33

slide-74
SLIDE 74

Example

live(Y ) ← connected to(Y , Z) ∧ live(Z). live(outside). connected to(w6, w5). connected to(w5, outside). ?live(A).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 34

slide-75
SLIDE 75

Example

live(Y ) ← connected to(Y , Z) ∧ live(Z). live(outside). connected to(w6, w5). connected to(w5, outside). ?live(A). yes(A) ← live(A). yes(A) ← connected to(A, Z1) ∧ live(Z1). yes(w6) ← live(w5). yes(w6) ← connected to(w5, Z2) ∧ live(Z2). yes(w6) ← live(outside). yes(w6) ← .

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 35

slide-76
SLIDE 76

Function Symbols

Often we want to refer to individuals in terms of components. Examples: 4:55 p.m. English sentences. A classlist. We extend the notion of term. So that a term can be f (t1, . . . , tn) where f is a function symbol and the ti are terms. In an interpretation and with a variable assignment, term f (t1, . . . , tn) denotes an individual in the domain. One function symbol and one constant can refer to infinitely many individuals.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 36

slide-77
SLIDE 77

Lists

A list is an ordered sequence of elements. Let’s use the constant nil to denote the empty list, and the function cons(H, T) to denote the list with first element H and rest-of-list T. These are not built-in. The list containing sue, kim and randy is cons(sue, cons(kim, cons(randy, nil))) append(X, Y , Z) is true if list Z contains the elements of X followed by the elements of Y append(nil, Z, Z). append(cons(A, X), Y , cons(A, Z))← append(X, Y , Z).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 37

slide-78
SLIDE 78

Unification with function symbols

Consider a knowledge base consisting of one fact: lt(X, s(X)). Should the following query succeed? ask lt(Y , Y ).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 38

slide-79
SLIDE 79

Unification with function symbols

Consider a knowledge base consisting of one fact: lt(X, s(X)). Should the following query succeed? ask lt(Y , Y ). What does the top-down proof procedure give?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 39

slide-80
SLIDE 80

Unification with function symbols

Consider a knowledge base consisting of one fact: lt(X, s(X)). Should the following query succeed? ask lt(Y , Y ). What does the top-down proof procedure give? Solution: variable X should not unify with a term that contains X inside. E.g., X should not unify with s(X). Simple modification of the unification algorithm, which Prolog does not do!

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.3, Page 40

slide-81
SLIDE 81

Complete Knowledge Assumption

Often you want to assume that your knowledge is complete. Example: assume that a database of what students are enrolled in a course is complete. We don’t want to have to state all negative enrolment facts! The definite clause language is monotonic: adding clauses can’t invalidate a previous conclusion. Under the complete knowledge assumption, the system is non-monotonic: adding clauses can invalidate a previous conclusion.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 1

slide-82
SLIDE 82

Equality

Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = D, φ, π. t1 and t2 are ground terms then t1 = t2 is true in interpretation I if t1 and t2 denote the same individual. That is, t1 = t2 if φ(t1) is the same as φ(t2). t1 = t2 when t1 and t2 denote different individuals.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 2

slide-83
SLIDE 83

Equality

Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = D, φ, π. t1 and t2 are ground terms then t1 = t2 is true in interpretation I if t1 and t2 denote the same individual. That is, t1 = t2 if φ(t1) is the same as φ(t2). t1 = t2 when t1 and t2 denote different individuals. Example: D = {✂,☎,✎}. φ(phone) = ☎, φ(pencil) = ✎, φ(telephone) = ☎ What equalities and inequalities hold?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 3

slide-84
SLIDE 84

Equality

Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = D, φ, π. t1 and t2 are ground terms then t1 = t2 is true in interpretation I if t1 and t2 denote the same individual. That is, t1 = t2 if φ(t1) is the same as φ(t2). t1 = t2 when t1 and t2 denote different individuals. Example: D = {✂,☎,✎}. φ(phone) = ☎, φ(pencil) = ✎, φ(telephone) = ☎ What equalities and inequalities hold? phone = telephone, phone = phone, pencil = pencil, telephone = telephone pencil = phone, pencil = telephone

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 4

slide-85
SLIDE 85

Equality

Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = D, φ, π. t1 and t2 are ground terms then t1 = t2 is true in interpretation I if t1 and t2 denote the same individual. That is, t1 = t2 if φ(t1) is the same as φ(t2). t1 = t2 when t1 and t2 denote different individuals. Example: D = {✂,☎,✎}. φ(phone) = ☎, φ(pencil) = ✎, φ(telephone) = ☎ What equalities and inequalities hold? phone = telephone, phone = phone, pencil = pencil, telephone = telephone pencil = phone, pencil = telephone Equality does not mean similarity!

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 5

slide-86
SLIDE 86

Properties of Equality

Equality is: Reflexive: X = X Symmetric: if X = Y then Y = X Transitive: if X = Y and Y = Z then X = Z For each n-ary function symbol f f (X1, . . . , Xn) = f (Y1, . . . , Yn) if X1 = Y1 and · · · and Xn = Yn. For each n-ary predicate symbol p p(X1, . . . , Xn) if p(Y1, . . . , Yn) and X1 = Y1 and · · · and Xn = Yn.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 6

slide-87
SLIDE 87

Unique Names Assumption

Suppose the only clauses for enrolled are enrolled(sam, cs222) enrolled(chris, cs222) enrolled(sam, cs873) To conclude ¬enrolled(chris, cs873), what do we need to assume?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 7

slide-88
SLIDE 88

Unique Names Assumption

Suppose the only clauses for enrolled are enrolled(sam, cs222) enrolled(chris, cs222) enrolled(sam, cs873) To conclude ¬enrolled(chris, cs873), what do we need to assume?

◮ All other enrolled facts are false ◮ Inequalities:

sam = chris ∧ cs873 = cs222

The unique names assumption (UNA) is the assumption that distinct ground terms denote different individuals.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 8

slide-89
SLIDE 89

Completion of a knowledge base: propositional case

Suppose the rules for atom a are a ← b1. . . . a ← bn. equivalently a ← b1 ∨ . . . ∨ bn. Under the Complete Knowledge Assumption, if a is true, one

  • f the bi must be true:

a → b1 ∨ . . . ∨ bn. Thus, the clauses for a mean a ↔ b1 ∨ . . . ∨ bn

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 9

slide-90
SLIDE 90

Clark Normal Form

The Clark normal form of the clause p(t1, . . . , tk) ← B. is the clause p(V1, . . . , Vk) ← ∃W1 . . . ∃Wm V1 = t1 ∧ . . . ∧ Vk = tk ∧ B. where V1, . . . , Vk are k variables that did not appear in the original clause W1, . . . , Wm are the original variables in the clause.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 10

slide-91
SLIDE 91

Clark Normal Form

The Clark normal form of the clause p(t1, . . . , tk) ← B. is the clause p(V1, . . . , Vk) ← ∃W1 . . . ∃Wm V1 = t1 ∧ . . . ∧ Vk = tk ∧ B. where V1, . . . , Vk are k variables that did not appear in the original clause W1, . . . , Wm are the original variables in the clause. When the clause is an atomic clause, B is true. Often can be simplified by replacing ∃W V = W ∧ p(W ) with P(V ).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 11

slide-92
SLIDE 92

Clark normal form

For the clauses student(mary). student(sam). student(X) ← undergrad(X). the Clark normal form is student(V ) ← V = mary. student(V ) ← V = sam. student(V ) ← ∃X V = X ∧ undergrad(X).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 12

slide-93
SLIDE 93

Clark’s Completion

Suppose all of the clauses for p are put into Clark normal form, with the same set of introduced variables, giving p(V1, . . . , Vk) ← B1. . . . p(V1, . . . , Vk) ← Bn. which is equivalent to p(V1, . . . , Vk) ← B1 ∨ . . . ∨ Bn. Clark’s completion of predicate p is the equivalence ∀V1 . . . ∀Vk p(V1, . . . , Vk) ↔ B1 ∨ . . . ∨ Bn If there are no clauses for p,

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 13

slide-94
SLIDE 94

Clark’s Completion

Suppose all of the clauses for p are put into Clark normal form, with the same set of introduced variables, giving p(V1, . . . , Vk) ← B1. . . . p(V1, . . . , Vk) ← Bn. which is equivalent to p(V1, . . . , Vk) ← B1 ∨ . . . ∨ Bn. Clark’s completion of predicate p is the equivalence ∀V1 . . . ∀Vk p(V1, . . . , Vk) ↔ B1 ∨ . . . ∨ Bn If there are no clauses for p, the completion results in ∀V1 . . . ∀Vk p(V1, . . . , Vk) ↔ false Clark’s completion of a knowledge base consists of the completion

  • f every predicate symbol along the unique names assumption.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 14

slide-95
SLIDE 95

Completion example

p ← q ∧ ∼r. p ← s. q ← ∼s. r ← ∼t. t. s ← w.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 15

slide-96
SLIDE 96

Completion Example

Consider the recursive definition: passed each([ ], St, MinPass). passed each([C|R], St, MinPass) ← passed(St, C, MinPass) ∧ passed each(R, St, MinPass). In Clark normal form, this can be written as

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 16

slide-97
SLIDE 97

Completion Example

Consider the recursive definition: passed each([ ], St, MinPass). passed each([C|R], St, MinPass) ← passed(St, C, MinPass) ∧ passed each(R, St, MinPass). In Clark normal form, this can be written as passed each(L, S, M) ← L = [ ]. passed each(L, S, M) ← ∃C ∃R L = [C|R] ∧ passed(S, C, M) ∧ passed each(R, S, M). Here we renamed the variables as appropriate. Thus, Clark’s completion of passed each is

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 17

slide-98
SLIDE 98

Completion Example

Consider the recursive definition: passed each([ ], St, MinPass). passed each([C|R], St, MinPass) ← passed(St, C, MinPass) ∧ passed each(R, St, MinPass). In Clark normal form, this can be written as passed each(L, S, M) ← L = [ ]. passed each(L, S, M) ← ∃C ∃R L = [C|R] ∧ passed(S, C, M) ∧ passed each(R, S, M). Here we renamed the variables as appropriate. Thus, Clark’s completion of passed each is ∀L ∀S ∀M passed each(L, S, M) ↔ L = [ ] ∨ ∃C ∃R L = [C|R] ∧ passed(S, C, M) ∧ passed each(R, S, M).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 18

slide-99
SLIDE 99

Clark’s Completion of a KB

Clark’s completion of a knowledge base consists of the completion of every predicate. The completion of an n-ary predicate p with no clauses is p(V1, . . . , Vn) ↔ false. You can interpret negations in the body of clauses. ∼a means a is false under the complete knowledge

  • assumption. ∼a is replaced by ¬a in the completion.

This is negation as failure.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 19

slide-100
SLIDE 100

Defining empty course

Given database of: course(C) that is true if C is a course enrolled(S, C) that is true if student S is enrolled in course C. Define empty course(C) that is true if there are no students enrolled in course C.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 20

slide-101
SLIDE 101

Defining empty course

Given database of: course(C) that is true if C is a course enrolled(S, C) that is true if student S is enrolled in course C. Define empty course(C) that is true if there are no students enrolled in course C. Using negation as failure, empty course(C) can be defined by empty course(C) ← course(C) ∧ ∼has enrollment(C). has enrollment(C) ← enrolled(S, C).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 21

slide-102
SLIDE 102

Defining empty course

Given database of: course(C) that is true if C is a course enrolled(S, C) that is true if student S is enrolled in course C. Define empty course(C) that is true if there are no students enrolled in course C. Using negation as failure, empty course(C) can be defined by empty course(C) ← course(C) ∧ ∼has enrollment(C). has enrollment(C) ← enrolled(S, C). The completion of this is:

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 22

slide-103
SLIDE 103

Defining empty course

Given database of: course(C) that is true if C is a course enrolled(S, C) that is true if student S is enrolled in course C. Define empty course(C) that is true if there are no students enrolled in course C. Using negation as failure, empty course(C) can be defined by empty course(C) ← course(C) ∧ ∼has enrollment(C). has enrollment(C) ← enrolled(S, C). The completion of this is: ∀C empty course(C) ⇐ ⇒ course(C) ∧ ¬has enrollment(C). ∀C has enrollment(C) ⇐ ⇒ ∃S enrolled(S, C).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 23

slide-104
SLIDE 104

Bottom-up negation as failure interpreter

C := {}; repeat either select r ∈ KB such that r is “h ← b1 ∧ . . . ∧ bm” bi ∈ C for all i, and h / ∈ C; C := C ∪ {h}

  • r

select h such that for every rule “h ← b1 ∧ . . . ∧ bm” ∈ KB either for some bi, ∼bi ∈ C

  • r some bi = ∼g and g ∈ C

C := C ∪ {∼h} until no more selections are possible

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 24

slide-105
SLIDE 105

Negation as failure example

p ← q ∧ ∼r. p ← s. q ← ∼s. r ← ∼t. t. s ← w.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 25

slide-106
SLIDE 106

Top-Down negation as failure proof procedure

If the proof for a fails, you can conclude ∼a. Failure can be defined recursively: Suppose you have rules for atom a: a ← b1 . . . a ← bn If each body bi fails, a fails. A body fails if one of the conjuncts in the body fails. Note that you need finite failure. Example p ← p.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 26

slide-107
SLIDE 107

Floundering

p(X) ← ∼q(X) ∧ r(X). q(a). q(b). r(d). ask p(X). What is the answer to the query?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 27

slide-108
SLIDE 108

Floundering

p(X) ← ∼q(X) ∧ r(X). q(a). q(b). r(d). ask p(X). What is the answer to the query? How can a top-down proof procedure find the answer?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 28

slide-109
SLIDE 109

Floundering

p(X) ← ∼q(X) ∧ r(X). q(a). q(b). r(d). ask p(X). What is the answer to the query? How can a top-down proof procedure find the answer? Delay the subgoal until it is bound enough. Sometimes it never gets bound enough — “floundering”.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 29

slide-110
SLIDE 110

Problematic Cases

p(X) ← ∼q(X) q(X) ← ∼r(X) r(a) ask p(X). What is the answer?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 30

slide-111
SLIDE 111

Problematic Cases

p(X) ← ∼q(X) q(X) ← ∼r(X) r(a) ask p(X). What is the answer? What does delaying do?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 31

slide-112
SLIDE 112

Problematic Cases

p(X) ← ∼q(X) q(X) ← ∼r(X) r(a) ask p(X). What is the answer? What does delaying do? How can this be implemented?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 32

slide-113
SLIDE 113

Natural Language Understanding

We want to communicate with computers using natural language (spoken and written).

◮ unstructured natural language — allow any statements, but

make mistakes or failure.

◮ controlled natural language — only allow unambiguous

statements that can be interpreted (e.g., in supermarkets or for doctors).

There is a vast amount of information in natural language. Understanding language to extract information or answering questions is more difficult than getting extracting gestalt properties such as topic, or choosing a help page. Many of the problems of AI are explicit in natural language

  • understanding. “AI complete”.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 1

slide-114
SLIDE 114

Syntax, Semantics, Pragmatics

Syntax describes the form of language (using a grammar). Semantics provides the meaning of language. Pragmatics explains the purpose or the use of language (how utterances relate to the world). Examples: This lecture is about natural language. The green frogs sleep soundly. Colorless green ideas sleep furiously. Furiously sleep ideas green colorless.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 2

slide-115
SLIDE 115

Beyond N-grams

A man with a big hairy cat drank the cold milk. Who or what drank the milk?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 3

slide-116
SLIDE 116

Beyond N-grams

A man with a big hairy cat drank the cold milk. Who or what drank the milk? Simple syntax diagram: s np vp pp np np a man with a big hairy cat drank the cold milk

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 4

slide-117
SLIDE 117

Context-free grammar

A terminal symbol is a word (perhaps including punctuation). A non-terminal symbol can be rewritten as a sequence of terminal and non-terminal symbols, e.g., sentence − → noun phrase, verb phrase verb phrase − → verb, noun phrase verb − → [drank] Can be written as a logic program, where a sentence is a sequence of words: sentence(S) ← noun phrase(N), verb phrase(V ), append(N, V , S). To say word “drank” is a verb: verb([drank]).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 5

slide-118
SLIDE 118

Difference Lists

Non-terminal symbol s becomes a predicate with two arguments, s(T1, T2), meaning:

◮ T2 is an ending of the list T1 ◮ all of the words in T1 before T2 form a sequence of words of

the category s.

Lists T1 and T2 together form a difference list. “the student” is a noun phrase: noun phrase([the, student, passed, the, course], [passed, the, course])

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 6

slide-119
SLIDE 119

Difference Lists

Non-terminal symbol s becomes a predicate with two arguments, s(T1, T2), meaning:

◮ T2 is an ending of the list T1 ◮ all of the words in T1 before T2 form a sequence of words of

the category s.

Lists T1 and T2 together form a difference list. “the student” is a noun phrase: noun phrase([the, student, passed, the, course], [passed, the, course]) The word “drank” is a verb: verb([drank|W ], W ).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 7

slide-120
SLIDE 120

Definite clause grammar

The grammar rule sentence − → noun phrase, verb phrase means that there is a sentence between T0 and T2 if there is a noun phrase between T0 and T1 and a verb phrase between T1 and T2: sentence(T0, T2) ← noun phrase(T0, T1) ∧ verb phrase(T1, T2).

sentence

  • T0
  • noun phrase

T1

  • verb phrase

T2

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 8

slide-121
SLIDE 121

Definite clause grammar rules

The rewriting rule h − → b1, b2, . . . , bn says that h is b1 then b2, . . . , then bn: h(T0, Tn) ← b1(T0, T1) ∧ b2(T1, T2) ∧ . . . bn(Tn−1, Tn). using the interpretation

h

  • T0
  • b1

T1

  • b2

T2 · · · Tn−1

  • bn

Tn

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 9

slide-122
SLIDE 122

Terminal Symbols

Non-terminal h gets mapped to the terminal symbols, t1, ..., tn: h([t1, · · · , tn|T], T) using the interpretation

h

  • t1, · · · , tn T

Thus, h(T1, T2) is true if T1 = [t1, ..., tn|T2].

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 10

slide-123
SLIDE 123

Complete Context Free Grammar Example

see http://artint.info/code/Prolog/ch12/cfg_simple.pl What will the following query return? noun phrase([the, student, passed, the, course, with, a, computer], R).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 11

slide-124
SLIDE 124

Complete Context Free Grammar Example

see http://artint.info/code/Prolog/ch12/cfg_simple.pl What will the following query return? noun phrase([the, student, passed, the, course, with, a, computer], R). How many answers does the following query have? sentence([the, student, passed, the, course, with, a, computer], R).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 12

slide-125
SLIDE 125

Augmenting the Grammar

Two mechanisms can make the grammar more expressive: extra arguments to the non-terminal symbols arbitrary conditions on the rules. We have a Turing-complete programming language at our disposal!

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 13

slide-126
SLIDE 126

Building Structures for Non-terminals

Add an extra argument representing a parse tree: sentence(T0, T2, s(NP, VP)) ← noun phrase(T0, T1, NP) ∧ verb phrase(T1, T2, VP).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 14

slide-127
SLIDE 127

Enforcing Constraints

Add an argument representing the number (singular or plural), as well as the parse tree: sentence(T0, T2, Num, s(NP, VP)) ← noun phrase(T0, T1, Num, NP) ∧ verb phrase(T1, T2, Num, VP). The parse tree can return the determiner (definite or indefinite), number, modifiers (adjectives) and any prepositional phrase: noun phrase(T, T, Num, no np). noun phrase(T0, T4, Num, np(Det, Num, Mods, Noun, PP)) ← det(T0, T1, Num, Det) ∧ modifiers(T1, T2, Mods) ∧ noun(T2, T3, Num, Noun) ∧ pp(T3, T4, PP).

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 15

slide-128
SLIDE 128

Complete Example

see http://artint.info/code/Prolog/ch12/nl_numbera.pl

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 16

slide-129
SLIDE 129

Question-answering

How can we get from natural language to a query or to logical statements? Goal: map natural language to a query that can be asked of a knowledge base. Add arguments representing the individual and the relations about that individual. E.g., noun phrase(T0, T1, O, C0, C1) means

◮ T0 − T1 is a difference list forming a noun phrase. ◮ The noun phrase refers to the individual O. ◮ C0 is list of previous relations. ◮ C1 is C0 together with the relations on individual O given by

the noun phrase.

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 17

slide-130
SLIDE 130

Example natural language to query

see http://artint.info/code/Prolog/ch12/nl_interface.pl

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 18

slide-131
SLIDE 131

Context and world knowledge

The student took many courses. Two computer science courses and one mathematics course were particularly

  • difficult. The mathematics course. . .

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 19

slide-132
SLIDE 132

Context and world knowledge

The student took many courses. Two computer science courses and one mathematics course were particularly

  • difficult. The mathematics course. . .

Who was the captain of the Titanic? Was she tall?

c

  • D. Poole and A. Mackworth 2016

Artificial Intelligence, Lecture 13.4, Page 20