Professional Documents
Culture Documents
The Calculator Project - Formal Reasoning About Programs: March 1995
The Calculator Project - Formal Reasoning About Programs: March 1995
net/publication/2653699
CITATIONS READS
5 2,277
5 authors, including:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Steve Reeves on 02 November 2012.
QMW1. Search for, or build, systems which would be Below we will work through parts of two simple
useful as calculators supporting functional examples to show how each calculator performs, but first
programming and formal reasoning; we make some general remarks. The calculators had to
have two main attributes: robustness and ease-of-use.
OU 2. Plan and carry out “before, during and after” They clearly had to be robust since in the environment
assessments of students on the functional that they were to be used in we could not afford to have
programming and logic courses; them breaking due to mistakes by students or the
inevitable experiments, enthusiastically conducted, whose
QMW2. Use the calculators in teaching; goals would be to find out how to break them.
They had to be easy to use in order that the calculators
OU3. Analysis of data gathered and writing-up of themselves did not become part of the problem that the
results; students were facing. They were intended to ease the
students’ burdens, not add to them. They had to have good
QMW3. Improvement of calculators based on feedback supporting documentation or help facilities and it had to
from OU2. be clear at any point that the students had control.
It became clear during QMW1 that while there were 4.1: Tarski’s World
many, many calculators which could be used to support
the logic course (of very varied usefulness, see [3]), there The main aims of this system are to introduce the
were none for the functional programming course. Hence, syntax of first-order logic (actually an interpreted first-
we had to build our own calculator to support the order logic with equality), to make the bridge to its
functional programming course, which used Miranda. semantics via the idea of an interpretation and to support
So, the outcome of these initial phases was the the teaching of semantic ideas like consistency,
decision to use Tarski’s World [4], developed by the inconsistency and entailment.
Center for the Study of Language and Information, Central to all this is the graphical representation of the
Stanford University, to support the logic course and our link between syntax and semantics, the interpretation.
Experience shows that students, when presented with the
usual formal definition of an interpretation (a pair of
functions, one mapping terms to objects in the universe
and the other mapping predicate letters to relations of the
appropriate arity), start to give up. In Tarski’s World very
natural use is made of a picture, the situation, to give
meaning to terms and predicates.
The situation displays a picture of the world which
contains some objects of certain shapes (cubes, tetrahedra,
dodecahedra) with certain attributes (names, sizes and their
shapes) and standing in certain relations to other objects
(larger than, in front of, between).
Figure one shows, in the top, left-hand window, a
picture of a “world”, the situation, in which the sentences
in the lower left-hand window are interpreted.
The student can decide whether or not a given sentence
is a well-formed formula or a sentence and then the system
can check for the well-formedness of formulae and
sentences - see the small box in the top right-hand corner
of the sentence window in figure one. This allows exercise
of the syntactic knowledge of the student and, by suitable
examples and questions, allows the support of teaching of
these notions. Figure One Tarski’s World
Having mastered some of the syntax of the language,
the student can then go on into learning about the
semantics. Given a sentence and a situation, the student support tools we looked at (around 15 of them), Tarski’s
can try to reason for themselves about the truth-value of World was amongst the best.
the sentence. Having reached some conclusion, the system
can used to check it. For simple examples it is usually
enough to be told you are wrong. In more complex cases 4.2: MiraCalc
the student can use the “game” to investigate why their
choice was wrong. MiraCalc aims simply to provide an environment in
The game poses a series of questions about the truth- which students can investigate the syntactic structure of
values of parts of the sentence concerned, gradually their scripts, find out more about the type of expressions
“homing in” on a misunderstanding, which is made very in the script and evaluate expressions in the environment
clear by using the situation to show why the truth-value formed by a script in a variety of ways: either fully, as in
was wrongly calculated by the student. Experience shows the Miranda system, in largish chunks (so-called “skips”)
that this is, not surprisingly, viewed as a much more and one step at a time (in the manner of Bird and Wadler’s
interesting way of calculating truth-values than going explanations in [6]).
through seemingly endless exercises using truth-tables. The step-by-step evaluation option turned out to be
Typical problems involve being given a situation and a highly favoured by the students since it allowed them to
list of sentences and being asked which sentences are true see exactly how evaluation in Miranda works and clearly
in the situation and being given a list of sentences and supported the task of working out why their programs
being asked to build a situation that makes them all true, were not working as expected.
if possible. This allows the ideas of consistency and Since for a functional language there are none of the
entailment, and their opposites, to be introduced and complications of, for example, global variables and side-
developed. effects that afflict other sorts of language, the mechanism
As ever with systems which have a graphical for doing step-by-step evaluation and, more importantly,
component at their heart, it is impossible to do justice to the rather small amount of information that has to be
Tarski’s World by words and “snapshots”. The reader is given to the user to enable them to make sense of what is
urged to try it and see. Suffice to say that of all the logic happening at each step, means that the calculator is
relatively simple, one of the main attributes that we
decided on for a successful system.
Figure Two MiraCalc on a Mac
- When you use the ‘game’ bit you can see the steps,
you can see what you've done wrong. It's a bit like
computer games
- If you don't understand the sentence, then you can
build it up bit by bit. It's easy to try things in
different ways
- It makes it very easy to experiment. You can try
out ideas about what the sentences mean. It's great,
it would be a pain trying out different things on
paper, having to keep erasing things, crossing
things out
The results showed an interesting contrast. There is a committed resources to supporting labs for the logic
significant difference between those who had used the course is significant and their attitude towards the course
software tool and those who hadn't, in relation to FP1 end improved. According to some measure of relevance and
of year scores, in the group of students who had studied A importance, the students seemed more likely to view the
level maths. This difference is however is far more logic course as equal to the programming courses.
pronounced within the group of students who had not
studied A level maths (figure six).
Indications are then that the use of the software tool 6: Further work
MiraCalc has had a positive effect upon the learning
outcomes and that this effect is most strongly seen in the Since this project finished, various of its members
results of those students who had not studied A level have been considering how to continue work in this area,
maths. Given that one of the principal motivations for building on the achievements outlined above. Firstly, it
developing and introducing these software tools had been should be noted that use of the calculators is continuing at
to address difficulties which 'non' mathematical students QMW, and they are also now being used at Waikato,
experience, this is a most encouraging result. where the developments mentioned below are taking place.
A final observation, based purely on anecdotal evidence In one main development, work is now underway to
from teaching staff, was that students treat a ‘theoretical’ improve MiraCalc. The Mac version (as shown in figure
course like Introduction to Logic more seriously when it one above) does not allow use of all of Miranda, though
is supported with labs just as the programming courses enough of the language is supported to allow a first course
were. to use it successfully. This is because of the relatively
What appears to be happening is that the Department is short amount of time we had to put into developing the
influencing the students’ perceptions about the relevance calculator between the start of the project and the use of
of logic. Without the labs, which is how such courses are MiraCalc in the functional programming course.
often taught, the students see the courses as more During the final part of the project, after teaching had
peripheral to Computer Science and hence less important, finished, we were able to extend MiraCalc to include all of
so they treat the course less seriously. Typically this the language in the form of a Unix-based version which
manifests itself in students leaving the logic coursework has an X interface. We decided to follow this route so that
until last when there is competition from other courses labs that were X workstation-based could also use
and being less willing to devote time to independent study MiraCalc, and Mac-based labs could use the full system
of the course. (It also has to be said that some teaching via MacX.
staff are guilty of reinforcing this problem by what they Even though MiraCalc implements all of Miranda it is
say about such courses and how they schedule not truly lazy in that although it uses normal-order
consideration of them during tutorials.) evaluation it does not use sharing. We intend, in future
In the students’ eyes, the fact that the Department work, to consider how to include the idea of sharing in the