Prolog Assignment FAQ
- Sample 5 doesn't read in correctly in iprolog!
Indeed it doesn't, because ratom reads upper case letters in the input
as variables. I have spent some time trying to write a better
tokenizer for iprolog, but its I/O appears to be rather flaky.
Thus you may assume that there are no upper case letters
in the input program. There may still be numbers and
other nonalphabetci symbols, however, so you stil need to
do some checking for correctness of variable names. Note that the
iprolog predicate atom_chars (or the xsb predicate atom_codes) may be necesary
to do this.
- I have no idea how to begin!
Read the lecture
notes: all of the main programming ideas from Prolog that
you need for the assignment are discussed there. See the discussion of
grammars in Lecture 22 (and the corresponding chapter of Clocksin and
Mellish) for ideas on how to parse the input file into a
representation of the program. In particular, the discussion of
arithmetic expressions in that lecture should help. Look at how the input
string gets converted into an atom there.
Once you have parsed the input and converted it into a representation of
the program and its specification that is easier for prolog to work
with, you need to think about how you can evaluate your representation
of boolean expressions and simulate the program to check whether it
satifies its specification.
- What if the user calls check(File,I,O) with I equal to a
list of the form [val(a,true),val(b,false), ...] that contains variables not in the program?
You may assume that this doesn't happen, and that when check is called
with I and O instantiated they are of the right form.
- in testingcode.P, I cant get test(sampleX,3) to work. Do you really mean to have "O == 02" in the code for "produces"?
Yes, that's what is should be in an ideal world. We want to check
whether the ouptut O2 is identical with O, not unify it with O. It
works just fine in XSB, but unfortunately, there seems to be a bug
in iprolog that prevents this working correctly. So use O = O2
instead, but be aware that you might be missing some errors this
way.
Suggestions or bugs report to cs2411@cse.unsw.edu.au
Last Modified: 28 Feb 2000