Sample Paper - CS607P
Sample Paper - CS607P
FINALTERM EXAMINATION
Fall 2022
CS607P – Artificial Intelligence Practical
Time: 90 min
Marks: 40
The weather is hot. Here the hot (use of linguistic variable is used) can be represented by
_______.
A. Fuzzy Set
B. Crisp Set
C. Linguistic Set
D. Logic Set
In CLIPS IDE which option is used to display the list of facts exist?
A. CLIPS> (facts)
B. CLIPS> (retract)
C. CLIPS> (assert)
D. CLIPS> (duplicate)
Select the right option that will remove the fact no. 1 in CLIPS IDE.
We have added the given fact in CLIPS IDE.
CLIPS>(assert ( father ( fathersName “Ahmed”) (sonsName “Bilal”) ) )
Which of the following function will be used to duplicate a modified fact.
The (reset) command in CLIPS IDE is used to remove ________ from memory.
A. facts
B. rules
C. both facts and rules
D. remove duplications
__________ in CLIPS are always written in a question mark (?) followed by a symbolic
field name.
A. Facts
B. Agenda
C. Rules
D. Variables
Recursive Call sums up to formulate the possible moves in ________ queens problem.
A. 4x4 only
B. 8x8 only
C. NXN only
D. all
The extended version of Eight Queen Puzzle applicable for n*n squares deals with
________ queens.
A. 5
B. 6
C. 8
D. n
Select the right format used to use stop the watch command in CLIPS IDE.
A. CLIPS> (clear facts)
B. CLIPS> (unwatch facts)
C. CLIPS> (watch facts)
D. CLIPS> (stop facts)
Select the right option that will remove the fact no. 1 in CLIPS IDE.
A. CLIPS> (facts 1)
B. CLIPS> (retract 1)
C. CLIPS> (assert 1)
D. CLIPS> (clear 1)
Select the right option that will add the fact “Virtual University” in CLIPS IDE.
A. CLIPS> (facts(Virtual University))
B. CLIPS> (clear(Virtual University))
C. CLIPS> (assert (Virtual University))
D. CLIPS> (retract(Virtual University))
Descriptive Part:
Question No: 25 (Marks: 05)
Write code for the following function using CLIPS and also write the output.
• (+ 6 3 6)
• (* 5 4.5 8)
• (+ 4 (* 8 8) 2 )
• (* 6 (+ 3 (* 3 3) 4) (* 6 6))
• (+ 4 4(- 6 2))
Answer
• CLIPS> (+ 6 3 6) Output: 15
• CLIPS> (* 5 4.5 8) Output: 180.0
• CLIPS> (+ 4 (* 8 8) 2 ) Output: 70
• CLIPS> (* 6 (+ 3 (* 3 3) 4) (* 6 6)) Output: 3456
• CLIPS> (+ 4 4(- 6 2)) Output: 12
Write the program in CLIPS IDE that will save the facts about information of enrolled AI
courses like course id (CS607, CS607P) and name (Artificial Intelligence, Artificial
Intelligence Practical). You are required to make templates for enrolled courses. After
loading the facts in working memory use the facts command to see the index of courses
facts. After that remove any one of the course fact and again list the total index of courses
facts. Just send the screen shot of your CLIPS IDE and added fact should also be
displayed in fact window.
Answer
CLIPS> (deftemplate course “Enrolled Courses” (slot id) (slot name))
CLIPS> (assert (course (id CS607) (name “Artificial Intelligence”))
(course (id CS607P) (name “Artificial Intelligence Practical”)))
CLIPS> (facts)
f-0 (course (id CS607) (name “Artificial Intelligence”))
f-1 (course (id CS607P) (name “Artificial Intelligence Practical”)))
For a total of 2 facts
CLIPS> (retract 1)
CLIPS> (facts)
f-0 (course (id CS607) (name “Artificial Intelligence”))
For a total of 1 fact
Question No: 27 (Marks: 05)
CLIPS operates by maintaining a list of Facts and a set of Rules which operate on them.
Facts on their own are of only limited use. The application of Rules is necessary to
develop a program capable of some useful function and this can be achieved by using
rule-based programming. Write a program in CLIPS IDE to generate the given below rule
and add a fact that will fire the added rule and use the facts command to see the index of
total facts present in working memory both prior and after running of rule.
Generate a Rule:
IF Lunch Time
THEN Eat Lunch
Answer
CLIPS>(defrule diet (lunch time) => (assert (eat lunch)))
CLIPS>(assert (lunch time))
CLIPS>(facts)
f-0 (lunch time)
For a total of 1 fact.
CLIPS>(run)
CLIPS>(facts)
f-0 (lunch time)
f-1 (eat lunch)
For a total of 2 facts.
CLIPS>(exit)
Write the program in CLIPS IDE that will save the facts about stationary products (at
least 5 products). You are required to make fact list of items. After loading the facts in
working memory use the facts command to see the index of product facts. Remove fact 3
by using the relevant command and again use the facts command to see the index of
remaining product facts.
Answer
CLIPS> (assert (Pen) (Pencil) (Notebook)(Book)(Ink))
<Fact-4>
CLIPS> (facts)
f-0 (Pen)
f-1 (Pencil)
f-2 (Notebook)
f-3 (Book)
f-4 (Ink)
For a total of 5 fact.
CLIPS> (retract 2)
CLIPS> (facts)
f-0 (Pen)
f-1 (Pencil)
f-3 (Book)
f-4 (Ink)
For a total of 4 fact.
CLIPS> (exit)
Extra memory, usually a stack, is needed to keep track of the nodes discovered so far
along a specified branch which helps in backtracking of the graph.
Consider the Eight-Queen problem to use representation and strategy on chess board.
Show the positions of Individuals on chess board table and calculate the fitness values for
both individuals in first iteration. The individuals (board positions) are given below:
(a) 47285421
(b) 52416782
Answer
Part a)
Q8
Q3 Q7
Q1 Q6
Q5
Q2
Q4
47285421
Fitness Value:
Q1 can attack Q6, Q3 Q5 can attack Q6
Q2 can attack Q7, Q8 Q6 can attack Q1,Q5
Q3 can attack Q7, Q1 Q7 can attack Q3, Q2, Q8
Q4 can attack None Q8 can attack Q7, Q2
Fitness value= 1
Part b)
Q4
Q2 Q8
Q3
Q1
Q5
Q6
Q7
52416782
Fitness Value:
Q1 can attack None Q5 can attack Q3,Q6, Q7
Q2 can attack Q8 Q6 can attack Q3, Q5, Q7
Q3 can attack Q5, Q6, Q7 Q7 can attack Q3, Q5, Q6
Q4 can attack None Q8 can attack Q2
Fitness value= 2