closed world assumption n.
Skip this Video
Loading SlideShow in 5 Seconds..
Closed World Assumption PowerPoint Presentation
Download Presentation
Closed World Assumption

Loading in 2 Seconds...

play fullscreen
1 / 16

Closed World Assumption - PowerPoint PPT Presentation

  • Uploaded on

Closed World Assumption. Go through some last year exam questions More help on chatbot. Closed World Assumption.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Closed World Assumption' - opa

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
closed world assumption

Closed World Assumption

Go through some last year exam questions

More help on chatbot

closed world assumption1
Closed World Assumption

In logic program, we assume that the world is closed in the sense that everything that exists is in the program or can be derived from the program. Accordingly, if something is not in the program (or cannot be derived from it) then it is not true and consequently its negation is true. This deserves special care because we do not normally assume that the world is closed

an example
An Example

If we ask Prolog:

?- not human('Mary').

Prolog will probably answer ‘yes’. But this should not be understood as Prolog saying Mary is not human. What Prolog really means to say is: ‘there is not enough information in the program to prove that Mary is human’.

(Note that, in SICStus Prolog, not(G) is written as \+(G) )

negation as failure
Negation as Failure

Q. How is not(Goal) implemented?

A. Prolog does not try to prove this goal directly. Instead, it tries to prove the opposite, and if the opposite cannot be proved then Prolog assume that the not(Goal) succeeds. This is called negation as failure.

negation as failure in code
Negation as Failure (in code)


call(G), % if G succeeds

!, % then we cut

% backtracking, then

fail. % make not(G) fail.

not(G). % otherwise, not(G)

% succeeds.

two control facilities in prolog call g and fail
Two Control Facilities in Prolog: call(G) and fail
  • call(G) – it treats the term G as a goal, executes G as if it appeared textually in its place.

For example - if_then_else(P,Q,R): if P then Q else R

if_then_else(P,Q,R):- call(P), !, call(Q).

if_then_else(P,Q,R):- call(R).

  • fail is a goal that always fails.

For example – a ‘fail loop’ to print out all top boy names

find_all:- boy_names(X,Y,1), write((X,Y)), nl, fail.


examples of using not g
Examples of using not(G)

Assume human('Mary') is NOT defined.

?- not human('Mary').

?- human('Mary'),


Fail(as it is not defined) Succeed

We get a ‘true’.

Assume human('Mary') IS defined.

?- not human('Mary').

?- human('Mary'),


?- !,fail.

?- fail.

We get a ‘false’.

issues with negation as failure
not(G) can’t return results.

?- not human('Mary').


?- not human(X).

True. (but there is no answer for X)

Why not?

Issues with Negation as Failure
issues with negation as failure use no u turn as an example
u_turn(south, north).

u_turn(north, south).

u_turn(east, west).

u_turn(west, east).



no_u_turn(south, east).

no_u_turn(south, west).

no_u_turn(north, east).

no_u_turn(north, west).

no_u_turn(east, north).

no_u_turn(east, south).



no_u_turn(X, X).

Issues with Negation as Failure - use ‘no_u_turn’ as an example

Check these with 2 versions.

? – no_u_turn(south, north).

? – no_u_turn(south,west).

? – no_u_turn(south, X).


a program given in past paper need to answer what you get from each query
A Program Given in Past PaperNeed to answer what you get from each query.

likes(fred, hannah).

likes(hannah, fred).

likes(hannah, logic).

likes(hannah, Who):- likes(Who, logic).

likes(father(Who), What):-

likes(Who, What).

?- likes(fred, amy).

?- likes(hannah,X).

?- likes(X,hannah).

some past exam questions
Some Past Exam Questions
  • Explain what is meant by the closed world assumption.
  • Explain what is meant by negation as failure.
  • Discuss the relationship between the close world assumption and the negation as failure.
  • Discuss how to define dislikes relation by using negation as failure.
  • What result is obtained when the goal

?- dislikes(X,Y).

is executed? Justify your answer.

help on chatbot from lecture 7
help on chatbot – from lecture 7

From ‘cango’ program’s output, you need to write out a detailed direction. It is very similar to write_list(L), if you just say to east, south, etc.

% give_direction(DirList, DistanceList)

give_direction([],[]):- nl.


write(‘go ’), write(H1), write(‘ ’), write(H2), write(‘ meters, ’), give_direction(T1,T2).

For a more human-like solution, you can say ‘turn left/right’, and indicate which side the room is. You need to use same trick used in ‘cango’: add pre-direction as an extra parameter

help on chatbot from lec ture 8
Help on Chatbot – from lecture 8


pattern_tofm([to, X, from, Y|_], X, Y):-

is_valid_loc(X), is_valid_loc(Y), ! .

pattern_tofm([to,room,X,from,room,Y|_], X, Y):-

is_valid_loc(X), is_valid_loc(Y), ! .


pattern_tofm([_|T], X, Y):- % carry on checking

pattern_tofm(T, X, Y).


more help on chatbot searching key words from a dictionary
More Help on chatbot – searching key words from a dictionary
  • For key words searching, the following program is useful: intersect(L1,L2,L3).
  • ?- intersect([a,b,c],[c,a,w],L).

L = [a,c]

  • watch out the difference from the intersect program given in lecture 8, which is

intersect(L1, L2, X):- member(X, L1), member(X, L2).

Here we only find a common element X

intersect a b c c a w l l a c
?- intersect([a,b,c],[c,a,w],L). L = [a,c]

How to define this?

intersect( ).

intersect( ):-

intersect( ):-

files needed for chatbot
Files needed forchatbot
  • A dummy chatbot
  • Something for reading input
  • Optional (if you want to use grammar rules)