book image Knowledge Representation, Reasoning, and the Design of Intelligent Agents

Knowledge Representation, Reasoning, and the Design of Intelligent Agents
The Answer-Set Programming Approach

by Michael Gelfond and Yulia Kahl
Cambridge University Press

Welcome!
The goal of this site is to provide additional resources for those using the book.
Questions can be sent to Yulia Kahl at ygkahl@gmail.com.
Last modified: March 13, 2017. Updates are marked with New!


Contents


Programs from the Book

Download all here

Chapter 4

family.lp -- Section 4.1.1
basic family relationships
orphans.lp -- Section 4.1.2
defining orphans
ancestors.lp -- Section 4.1.3
defining ancestors
ec.lp -- Section 4.2
representing an electrical circuit
hierarchy.lp -- Section 4.3
representing a basic inheritance hierarchy

Chapter 5

uncaring.lp -- Section 5.1
uncaring John -- basic defauts and their exceptions
cowardly.lp -- Section 5.1.2
cowardly students -- more defaults with weak and strong exceptions
course_catalog_1.lp -- Section 5.2
representing null values with value 'staff'
course_catalog_2.lp -- Section 5.2
representing null values with disjunction
orphans2.lp -- Section 5.3
priorities between defaults
blue_deep.lp -- Section 5.4.1
inheritance hierarchy with defaults
darling.lp -- Section 5.4.2
redefining membership using defaults
tweety.lp -- Section 5.4.3
illustration of the specificity principle as applied to an inheritance hierarchy with multiple defaults and exceptions

Chapter 6

hamgraph.lp -- Section 6.1
finds Hamiltonian cycles
sudoku.lp -- Section 6.2.1
solves a Sudoku puzzle
sudokudlv.lp -- Section 6.2.1
sudoku.lp in DLV syntax
mystery.lp -- Section 6.2.2
solves a murder puzzle

Chapter 8

blocks1.lp -- Section 8.1
only for experimentation
blocks2.lp -- Section 8.1
only for experimentation
blocks3.lp -- Section 8.1
final version
bc.lp -- Section 8.5.1
briefcase domain translated from AL system description
bw.lp -- Section 8.5.2
blocks world domain translated from AL system description
twoarms.lp -- Section 8.5.3
blocks world with concurrent actions

Chapter 9 (and Appendices D.1 and D.2)

bwplan_choice.lp -- Section 9.1
bw.lp + simple planning module using choice rule + example initial situation + example goal
where bw.txt is the AL system description of the blocks-world domain translated into ASP (see Ch. 8)
bwplan_disjunction.lp -- Section 9.1
same as bwplan_choice.lp but the simple planning module uses a disjunctive rule instead of a choice rule
ignite.lp -- Section 9.2.2 & Appendix D.1
finds a plan for igniting a burner through a series of pipes and valves
crossing.lp -- Section 9.2.3 & Appendix D.2
finds a plan for solving the missionaries and cannibals problem
heuristics.lp -- Section 9.3
bwplan_choice.lp + new initial state, new goal state + heuristics
twoarmsplan.lp -- Section 9.4
planner for blocks world with concurrent actions
crbwplan.lp -- Section 9.5
CR-Prolog planner for blocks world

Chapter 10 (and Appendix D.3)

circuit.lp -- Section 10.3 & Appendix D.3
finds possible explanations for a broken circuit

Chapter 12

derivatives.pl -- Section 12.2.3
Prolog program that computes derivatives of polynomials

SPARC Versions of Book Programs

Download all SPARC programs here

Chapter 4:

s_family.sp
s_orphans.sp
s_ancestors.sp
s_ec.sp
s_hierarchy.sp

Chapter 5:

s_uncaring.sp
s_course_catalog_1.sp
s_course_catalog_2.sp
s_cowardly.sp
s_orphans2.sp
s_blue_deep.sp
s_darling.sp
s_tweety.sp

Chapter 6:

s_hamgraph.sp
s_sudoku.sp
s_mystery.sp

Chapter 8:

s_blocks1.sp
s_blocks2.sp
s_blocks3.sp
s_bc.sp
s_bw.sp
s_twoarms.sp

Chapter 9:

s_bwplan.sp
s_ignite.sp
s_crossing.sp
s_heuristics.sp

Chapter 10:

s_circuit.sp

Solvers and Other Useful Software

For clingo, gringo, and clasp visit the Potassco site at http://potassco.sourceforge.net/.

For DLV and ASPIDE, visit http://www.dlvsystem.com/.

SPARC can be found at https://github.com/iensen/sparc/wiki.

There is a new tool for running SPARC programs online which can be found at http://ec2-52-25-88-7.us-west-2.compute.amazonaws.com.
You can simply cut and paste programs to replace the sample code and ask queries or get answer sets.

CRModels is at http://www.mbal.tk/crmodels/.

MKAtoms is at http://www.mbal.tk/mkatoms/.

Additional resources can be found at the Texas Tech Knowledge Representation Lab site
at http://www.depts.ttu.edu/cs/research/krlab/.


Additional Exercises with Solutions

EXERCISES ASP SOLUTIONS SPARC SOLUTIONS
ex02.pdf   (Ch. 2) soln_ex02.pdf The answer sets are the same.
This file has the SPARC code for the mini programs: s_ex02.txt
ex_local_cwa.txt   (Ch. 4) local_cwa.lp s_local_cwa.sp
ex_cars.txt   (Section 5.5) cars.cr   (CR-Prolog) s_cars.sp
ex_loops.txt   (Ch. 6) loops.lp s_loops.sp
ex_clique.txt  (Ch. 6) clique.lp s_clique.sp
ex_max_clique.txt  (Ch. 6) max_clique.cr   (CR-Prolog) s_max_clique.sp
ex_morphing_vehicles.txt   (Ch. 8) morphing_vehicles.lp s_morphing_vehicles.sp

Errata

Special thanks to Elham Hojati and Yuliya Lierler for finding some of these.
LOCATION ERROR FIX
p. 173 — line 3 {occurs(ai): 0 ≤ i ≤ k} {occurs(aj, i): 0 ≤ j ≤ k}
p. 173 In showing the translation of preconditions, we did not make a note about the case where the preconditions are statics. Since in this case we are not concerned about showing their change over time, we should not use holds. Simply write the statics as they are. For example: given a rule "a causes l if s, f" where s is a static and f is a fluent, the translation is
h(l,I+1) :- s,
            holds(f,I),
            occurs(a,I),
            I < n.
Blocks world New! In the original description of the blocks world, we fail to flush out an implicit rule; namely, that a given block must have a location. The effect of this is not felt until we suggest in Section 8.5.3 that we can remove rule 7 from p. 180
impossible put(B1,B) if on(B2,B)
because it is an overspecification. With this rule gone, it becomes possible for a block to be nowhere.
Subsequent references and examples already ignore the removal of the rule, so the text makes sense except for the actual example on overspecification on p. 184.
p. 185, Figure 8.9 New! States in which f holds do not have loops showing what happens when action a is executed. Add loops labeled by the letter a to the three states in which f holds as there is nothing preventing the exectution of action a in those states.
p. 194 — next to last line (i) For any 0 < i ≤ k, occurs(ai, i-1) in S (i) For any 0 < i ≤ k, occurs(ai, i) in S
p. 199 — line 26 fluent(defined, wrong_config(B)) fluent(defined, wrong_config)
p. 223 — line 24 E2 would be the only possible explanation E1 would be the only possible explanation
p. 246 — line 29 W1 is 1/24 W is 1/24
p. 250 — last line draw(T):{C:available(C,T)} random(draw(T):{C:available(C,T)})