Closed World Assumption Go through some last year
- Slides: 12
Closed World Assumption Go through some last year exam questions More help on chatbot 1
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 2
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) ) 3
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. 4
Negation as Failure (in code) not(G): call(G), % if G succeeds !, % then we cut % backtracking, then fail. % make not(G) fail. not(G). % otherwise, not(G) % succeeds. 5
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. find_all. 6
Examples of using not(G) Assume human('Mary') is NOT defined. Assume human('Mary') IS defined. ? - not human('Mary'). ? - human('Mary'), !, fail. Fail(as ? - !, fail. it is not defined) Succeed ? - fail. We get a ‘true’. We get a ‘false’. 7
Issues with Negation as Failure • not(G) can’t return results. ? - not human('Mary'). Yes. ? - not human(X). True. (but there is no answer for X) Why not? 8
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(X, Y): +(u_turn(X, Y)). Check these with 2 versions. ? – no_u_turn(south, north). 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(west, north). no_u_turn(west, sorth). no_u_turn(X, X). ? – no_u_turn(south, west). ? – no_u_turn(south, X). 9
A Program Given in Past Paper Need 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). 10
Some Past Exam Questions • Discuss how to define dislikes relation by using negation by finite failure. • Explain what is meant by the closed world assumption. • What result is obtained when the goal ? - dislikes(X, Y). is executed? Justify your answer. 11
More Help on chatbot • For key words searching, the following program is useful: intersect(L 1, L 2, L 3). (watch out difference from last week’s intersect) • ? - intersect([a, b, c], [c, a, w], L). L = [a, c] intersect( ): -
- Closed world assumption
- Fire and ice diamante poem
- Some say the world will end in fire some say in ice
- Plc timer symbol
- Through one man sin entered
- Surface integral of electric field
- Surface integral of electric field
- School leaver poems
- Classification writing
- They say it only takes a little faith
- Sometimes you win some sometimes you lose some
- Cakecountable or uncountable
- What are some contact forces and some noncontact forces