Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMPSCI 367

Assignment 2

due 8 October 2023

Due: by 11:59pm on the due date. Late assignments will not be marked.

Total mark: 15.

Worth: This assignment counts towards 15% of your inal mark.

Please answer ALL questions.  submit the answer to Question 1 as a pdf ile Q1. pdf.  submit the answers to Question 2 and Question 3 as prolog code, i.e.,  . pl iles, as mapcolouring. pl and surround. pl, respectively.

1.  [5 marks] suppose you are building a decision support system that helps people with invest- ment options. The system assumes that the user has some money to invest and can help select among the following possibilities:

. an income fund

. a growth fund

. a conservative fund

You will build a simple knowledge base, consisting of a set of rules written below (in a slightly abbreviated form). Each rule is written as an implication, expressed in terms of an if part (the premise) and a then part (the conclusion).  The conclusion conservative, income, growth are the three fund possibilities.

For example, rule (3) delivers the following message:  “If you are retired and you have basic insurance coverage, then the category of fund to select is the income fund” .

(1) if have  health insuTance and have life insuTance

then basic insuTance coveTage

(2) if investment foT TetiTement and  basic  insuTance  coveTage

then conservative

(3) if TetiTed and basic insuTance coveTage

then income

(4) if investment foT childTen  education and  basic  insuTance coveTage

then growth

(5) if investment foT home  owneTship and  basic  insuTance coveTage

then growth

(6) if age三65

then not TetiTed

(7) if age>65

then TetiTed

(8) if not TetiTed and no pension

then investment foT TetiTement

(9) if have childTen and childTen,s education not funded

then investment foT childTen education

(10) if no home owneTship and want home

then investment foT home owneTship

Answer the following questions and write down the solutions in Q1. pdf ile.  clearly indicate the solutions to (a) and (b):

(a) [2  marks] Design a deinite clause knowledge base using the information above.  clearly list the atomic propositions (with their intended meaning) and the clauses in the KB. An

example that contains a few atomic propositions and a rule is given below:

E①ample. Atomic propositions:

. BasInsure: The user has basic insurance cover

. HeaInsure: The user has health insurance

. LifInsure: The user has life insurance

clause (1): BasInsure — HeaInsure V LifInsure

(b) [3 marks] suppose a user has the following information:

(11)  is 42 years old

(12)  has health insurance, and (13) life insurance

(14)  not covered by a pension plan

(15)  has one child, age 12, who (16) does not have funding for education (17)  does not currently own a house and (18) would like to own one.

Apply sLD resolution on the three queries

i.  ask   conservative

ii.  ask   income

iii.  ask   growth

For each case, provide aproof if the answer is true, and answer why if the answer is false.

2.  [4 marks] solve the map colouring problem for North Island using prolog.  Up to three colours, red, green, blue, are allowed to use.  Two adjacent regions cannot be marked with the same colour.

You may use the following knowledge base:

. different(red, green) .

. different(red, blue) .

. different(green, blue) .

. different(green, red) .

. different(blue, red) .

. different(blue, green) .

Implement a prolog predicate mapcolouring(N,A,WA,B,G,T,M,H,WE)where a variable should be  the  corresponding  word  as  indicated  in  the  following  map.     submit  your  answer  as mapcolouring. pl ile.

3.  [6  marks] Given is a 4 x 4 board with each grid marked with either  “+” or  “ —” .  The goal is to ind all — grids that are SUTToUnded by +.  A — grid at the edge cannot  be surrounded.

More formally, each grid can have up to 4 neighbour grids, i.e., top, bottom, left and right. If one grid or a group of “ —” grids forms a  “connected” area and their neighbours are all  “+” grids, then all “ —” grids in this group are SUTToUnded.  otherwise, if any a — grid in that group has a — neighbour that is at the edge, then all neg grids in this group are non-surrounded.  For example, in igure (a), the — grids highlighted in red are surrounded; in igure (b), no — grid is surrounded.

use the constants g11, g12, . . . , g44 to denote the coordinates of grids.  use the rules neg(G) and pos(G) to denote a grid marked with — and +, respectively, where the variable G e {g11, g12, . . . , g44}.

You are requested to: Build  a  knowledge  base  and  implement  a  prolog  predicate is surrounded (G) such that is surrounded (G) is true if G is a — grid and is surround- ed by + grids, and false otherwise.  You are allowed to deine any additional and auxiliary rules.

Evaluation. your programme may be tested using diferent conigurations of the board.  For example, the coniguration code for the igure (a) is:

neg(g21).

neg(g23).

neg(g32).

neg(g33).


pos(g11).

pos(g12).

pos(g13).

pos(g14).

pos(g22).

pos(g24).

pos(g31).

pos(g34).

pos(g41).

pos(g42).

pos(g43).

pos(g44).

The coniguration code will be added at the top of the knowledge base when testing.

Submit your answer as surround. pl ile.