~1
                     LOGIC PROGRAMMING LESSON 1

Welcome to the Logic Programming Tutor. We're going to use it to teach
you logic programming and Prolog. Because full Prolog looks rather
frightening to the beginner, we'll start with a simpler version, which
looks more like English. But it isn't English, and to make the
distinction clear, we'll call it Logic.

You can tell the Tutor facts in Logic. You can also ask it questions. It
will try to answer these, by using its knowledge of the facts you've
typed. The connection between questions and facts may be quite
intricate, and the Tutor may have to do some rather involved reasoning
to find an answer. More of this later.

First though, you must learn to control the Tutor. You need to know
things like how to display the next section of this lesson, how to stop
when you've had enough, and how to repeat a section.

Please begin by waiting until you see a star (*) at the end of this
section. When you see it, type the word "next", and follow it with a
full-stop. Then hit the RETURN key. It is most important that you type
the full-stop, and that you hit RETURN. Otherwise, the Tutor won't do
anything.

~2
You have now given your first command to the Tutor. COMMANDS are
sentences that control the Tutor in some way; for example, by making it
move to the next section, or repeat the last section, or stop when
you've had enough.

Now, when you see a star appear at the end of this paragraph, please
type "next" again to move to the next section. As we said above, you
must follow the word by a full-stop, and you must then hit the RETURN
key. If you don't, the Tutor won't realise that you've finished your
sentence. Being stupid about such things, it won't act on its own
initiative (it has none). Instead, it will just sit and wait... and
wait... and wait.

~3
In general, when the Tutor is ready for you to type something, it shows
a star at the left of the screen. Once this appears, you can go ahead
and type. You MUST wait for the star to appear before you type, though;
do not type while text is appearing on the screen. The computer is busy,
and sharing its attention between lots of people, so sometimes there
will be a pause before it attends to you and the star appears; be
patient and wait until it does.

Also, for now, everything you type must be in lower-case, otherwise the
Tutor will not understand you. Later, we shall introduce "variables",
which have to be in upper-case. Until then, please use lower-case
letters only.

Now, please go on to the next section.

~4
You should have got here by typing "next" again (and a full-stop and
RETURN of course).

Now, you don't need to know very much about the keyboard. You must know
where RETURN is, or you wouldn't have been able to get here. Later,
you'll need the shift key, so you can put in upper-case letters. But
there's one key that will probably come in useful straight away. That's
the key for correcting mistakes.

On your keyboards, it's probably labelled DEL, and is just above the
RETURN key. Every time you press it, it moves back one place in the line
you've typed and rubs out a character. You can then type something to
replace your mistake.

Unfortunately, you can only correct mistakes in the current line. If the
typing position is at the beginning of a line and you press DEL, you
will stay there: you can't get back to the previous line. So you can't
correct a line once you've hit RETURN.

Now, continue to the next section.

~5
If you do make a mistake, then one of two things will happen.

If your sentence starts with a command word like "next", the Tutor will
recognise it as something that is a command, but not quite correct. In
this case, it will REJECT it and tell you it can't obey the command.

Otherwise, the Tutor will assume your sentence to be a fact. It will
STORE it, to give you the chance of correcting it later, and it will
tell you it has done so. Later, you will learn to delete such bad facts,
so it doesn't matter at all if you accidently add some.

In either case, the Tutor will tell you exactly what it has done. If you
do make a mistake, then don't worry. Films where smoke pours out of
computers and they explode in sparks are just bad science fiction. You
can't damage the computer just by typing at it, and you can always try
something again if it doesn't work the first time.

Now, please go on to the next section, where we show you another
command.

~6
Another useful command is "again". It tells the the Tutor to repeat the
section just displayed. Try it when you see the star appear at the end
of this section.

~7
It's almost time to show how the Tutor can use facts to answer
questions, but we'll show you two more commands first. They will come in
useful if you want to stop for a while, and continue later from where
you left off.

The "bye" command stops the Tutor, and returns the computer to the state
it was in before you started running the Tutor. You can then log out,
and then log in later to start the Tutor up again. Your teacher will
show you how to do this.

Once you've re-started the Tutor, you probably won't want to start at
section 1 and then re-read them all until you get to where you left off.
You can go straight to a section with the "section" command. To use it,
type "section" followed by a number. So, for example, "section 1" would
take you back to the start of this lesson.

Try using "section" now to look at various parts of this lesson. Make
sure you end up at the next section, section 8.

~8
In this section, we start programming in logic, and we see how to
tell the Tutor facts about romances. In the context of logic
programming, FACTS are sentences about objects - these objects can be
people, or animals, or countries, or anything else.

When the "*" appears, type the following, ending as usual with a full
stop and RETURN:

      mary loves john.

You must use only lower-case letters, even though you're talking about
people's names. As we said in section 3, if you use upper-case, then the
Tutor will treat the names as variables, and they mean something quite
different.

When you've typed your fact, the Tutor will respond "ok - fact 10
recorded". It gives each fact a unique number, and we'll explain why
later. After that, type "next" as usual to see more instructions.

~9
The Tutor has remembered the fact you typed. You can ask about it by
typing a sentence which ends in a question mark. Try

      mary loves john?

followed by RETURN. Make sure that both names start with a lower-case
letter.

~10
The Tutor should have answered "yes" to that question, because you'd
told it that Mary loves John. Now try asking

      anne loves george?

~11
The Tutor should have answered "no" to that one. Of course, in the real
world, there is almost certainly an Anne somewhere who does love a
George. But the Tutor (obviously) can't tell what's going on outside its
computer. All it has to work from is the fact you've told it about Mary
and John.

Now, if someone asked us a question we don't know the answer to, we'd
say "don't know" or "haven't a clue". But the Tutor is different. If it
doesn't know something, it ALWAYS assumes the answer is FALSE. So a "no"
answer really means "I don't have enough facts to prove that this is
true, so I'll assume it is false".

~12
You could go on in this way for some time, adding facts and asking the
Tutor whether it knows them or not. But that wouldn't be very exciting -
after all, you typed the facts, so you must know whether they're there.

But you can make things more interesting by using VARIABLES in your
questions. For example, suppose you wanted to find out WHO Mary loves?
You can ask this by putting a variable in your question. You can use any
word as a variable, as long as it starts with a capital letter - for
example, X, to represent something unknown. Try

      mary loves X?

Make sure you put the X in UPPER CASE. Don't forget the question mark;
and as usual, end with RETURN.

~13
You should have got back an answer saying

      Yes -
      X = john

~14
You can also use two variables in a question. Try this question:

      X loves Y?

In general, any word that starts with a capital is a variable. I shall
mainly write X and Y for variables, but you could use other names, such
as Person or Z or Which or Who or Blurgle or Crun (though it's a good
idea to stick to sensible names).

~15
Now watch what happens if Mary loves more than one person: You will have
to type in some more facts first. Try:

      mary loves dai.
      mary loves X?

~16
From the facts you've now put in, the Tutor can tell that Mary loves
both John and Dai, and so it gives you both as possible values of X.

Add another romance:

      juliet loves romeo.
      X loves Y?

Try those. Don't forget to end the fact with a full-stop followed by
RETURN, and the question with a question-mark followed by RETURN.

~17
In general, you can use variables in either or both positions in a
question. What question would you type to find out who loves Dai?

~18
You should have typed
      X loves dai?

But any variable names would have done, so you could instead have said
      Y loves dai?
or
      Who loves dai?
or even
      Potrzebie loves dai?
though the last is not recommended as you and your teacher won't find it
very easy to understand.

~19
We shall return to questions a bit later. First, I must tell you about
another command, and about the effect of errors. As you continue to add
facts, you may forget exactly what you've typed. You can remind yourself
by using the "show" command, which tells the Tutor to display all the
facts you have told it.

You will see that each fact starts with a number - the same number that
the Tutor told you when you originally typed the fact. Note by the way
that show does not perform any reasoning, so it's not like answering a
question. All it does is to display the text you typed when entering the
fact, after tidying up its layout a bit.

Try the "show" command now. As with "next", "again" etc, don't forget to
follow it with a full-stop and a RETURN.

~20
When you do a show, you may find that some facts are enclosed in pointy
brackets, like this <<< ... >>>. That means that the Tutor couldn't make
sense of them. Now, demonstrate this by entering the fact below.
      john loves.
Make sure what you type only has the two words "john" and "loves".

What was the Tutor's response?

When you've done that, give another show command.

~21
When you typed that dud fact, the Tutor told you that it was
grammatically incorrect. This is because each fact must contain at least
three words.

After telling you there's something wrong, the Tutor stores the text of
the dud fact; that's what you saw, in <<<...>>> brackets, when you typed
"show". What's the point of storing an erroneous fact? After all, the
Tutor can't make any inferences from it. Well, later on, you'll be
introduced to the "change" command. This allows you to change little
bits of text in incorrect facts. So the Tutor stores the text and lets
you change it, rather than forcing you to retype the lot.

~22
Of course, the Tutor does not use incorrect facts in inference. You
can see that the Tutor must have two kinds of memory. One is for the
text of facts: that's what you see after doing show. The other is for
the logical meanings of facts: that's what's used in answering
questions.

You can test this by entering a fact like
    zwoogle loves.
and asking the Tutor questions such as
    X loves?
    X loves Y?
    zwoogle loves?

No matter what you try, zwoogle will not appear as an answer. A question
like "X loves" will be reported as wrong anyway, because it is
incomplete.

~23
Now, notice what can happen with bad commands. If you type
    sction 26.
(instead of "section 26"), the Tutor will not recognise it as a command,
because of the spelling error. Like most computer programs, the Tutor is
completely incapable of recognising what to us are obvious near-misses
in spelling errors. What happens is that the Tutor will treat it as a
fact. So once again, if you do a "show", then "sction 26" would appear
inside pointy brackets.

If you type
    section twentysix.
or
    section 1001.
then the Tutor can tell they're meant to be commands because of the
first word. But they're still wrong: one uses a name instead of a
number, and the other uses a number that's far too big. So the Tutor
will tell you there was something wrong with the command and say that it
hasn't done anything about it.

~24
On the subject of errors, one particularly common mistake is to omit the
full stop at the end of a sentence:

      juliet loves romeo     <---- missing full stop
      mary loves john.

This causes the Tutor to take both lines as making up one fact:

      juliet loves romeo mary loves john.

That's because the Tutor uses full stops as we do, to mark the end of a
sentence. It has no other way to tell when a sentence finishes - it's
far too stupid to use meaning as a cue. However, it can tell that
there's something wrong with such a fact, because there are too many
words. The kind of fact you've met so far can only contain three words:
two to name things, and one to state a relation between those things.

~25
You can test this by typing such a fact. Type
      juliet loves romeo
      mary loves john.

You will see that it gets stored as a bad fact, with pointy brackets
around it.

~26
Now we shall return to our romances. So far, we have only seen simple
facts which state things that, as far as the Tutor knows, are always
true. But we can also tell the Tutor that the truth of one fact depends
on the truth of another. To do this, use the word "if":

      maggie loves denis if denis drinks gin.

Ask the question

      maggie loves X?

~27
The Tutor should have said "no". Being unable to find any facts that
tell it Maggie does love Denis, it assumes the opposite (as we saw in
section 10).

Now type
      denis drinks gin.
      maggie loves X?

You should have got the answer "X = denis".

This is an example of INFERENCE. The Tutor did not need to be told
explicitly that Maggie loves Denis - it inferred it from the "if maggie
loves denis" part of the new fact.

Try another example of inference:

      maggie loves nick if nick hates europeans.
      nick hates europeans.
      maggie loves X?

The Tutor will INFER the answer to the question, by reasoning about
the two facts.

~28
We call facts that contain "if", CONDITIONAL FACTS. You can write
conditional facts with variables in. These are more powerful, because
they let you express general rules about things. Type this one in:

      maggie loves X if X likes money.

This means "Maggie loves anyone who likes money".

~29
Now try
      maggie loves X?
      cecil likes money.
      maggie loves X?

~30
You can of course still ask questions with variables in any or both of
the two positions. The Tutor will always answer with all the inferences
it can make. So you can also ask
      X loves Y?
      X loves cecil?
and get answers drawn from all your facts.

Notice that it does not matter at all which variable names you use. In
particular, it does not matter whether the names are the same as those
in any of your facts. The questions
      X loves Y?
      Y loves X?
      Who loves SomeoneElse?
      Potrzebie loves Ftang?
will have exactly the same answers.

~31
Reasoning with conditional facts which contain variables can be very
powerful. The same conditional fact can be used for lots of inferences.
Here is another conditional fact with a variable. Type it in.

      X is_a mortal if X is_a human.

then add:

      mary is_a human.
      dai is_a human.
      john is_a human.

Finally see what the Tutor can say in answer to:

      X is_a mortal?

This is exactly the same reasoning as in the classical syllogism about
Socrates being mortal if he is a man.

~32
Before we go on to more complicated inferences, a note on what words
we're allowed in facts. Unfortunately, the Tutor won't allow the word
"is" to be used, so a fact like "mary is human" is illegal. You'll learn
why when you come on to the subject of arithmetic in Prolog. For the
moment, just accept it as one of those annoying historical accidents
that are so common in computing.

You might have thought of typing something like
      X is a mortal if X is a human.
instead. That won't work either, because the Tutor only allows three
words in each part of a fact. But what you can do is what we did above:
      X is_a mortal if X is_a human.

Here, you use an underline symbol (_) to make one word out of two. It's
a bit like a hyphen in English. The Tutor will accept any number of
underlines in words. Granted, it makes the text look less English-like;
but then, Logic isn't English. When you get to Prolog, you'll find the
use of underlines is very common. By the way, don't confuse underline
(_) with minus (-). You can't use minus instead of underline.

~33
The conditional part of a fact can have the word "and" in it. This means
that its truth depends on more than one condition. For example try this:

      anne likes P if P likes money and P likes horses.
      mark likes horses.
      mark likes money.

      X loves Y?

Notice that although the Tutor will tell you that Anne likes Mark, it
won't tell you that Maggie likes Mark. Although it knows Cecil likes
money, it doesn't know whether he likes horses. So it assumes he
doesn't. This means one of the parts of the condition is false, and so
the whole condition is false.

~34
Here's another example:

      mary dislikes X if X eats garlic and X eats curry.
      romeo eats garlic.
      chris eats curry.
      dai eats garlic.
      dai eats curry.
      mary dislikes X?

~35
So, for a condition with "and" in it to be true, the parts either side
of the "and" must both be true. That's what you'd expect.

~36
We've seen that rules can have "and"s in them. So can questions,
for example:

      mary loves john and anne loves mark?

This can be understood as

      Is it true that Mary loves John and Anne loves Mark?

~37
Questions can contain variables and "and"s together. This is more
interesting. For example, you can ask the question

      X eats garlic and X eats curry?

The Tutor interprets the X to refer to the same thing in
both cases. That's sensible: you wouldn't expect one X to be about
one person (Mary, say) and the second about a different person
(e.g. John).

So this question asks the Tutor to find one person who
both (a) eats garlic, and (b) eats curry.

~38
Similarly, you could try

      X loves cecil and X loves nick?

Here, you're asking for one person (call them X) who (a) loves Cecil,
and (b) loves Nick.

Note well that you can't ask
      X loves cecil and nick?
      X eats curry and garlic?
The Tutor will not allow you to abbreviate conditions in this way. You
must always have three words for each part of the condition.

~39
The questions in the last two sections both work exactly like the
condition in the rule you saw in section 34:

      mary dislikes X if X eats garlic and X eats curry.

There, you were saying that Mary dislikes someone (X) if this person (a)
eats garlic, and also (b) eats curry. Again, the person must be the same
in both cases.

In general, "and"s and variables in questions work just like they
do after an "if" in conditions.

We shall have more practice with inference and questions later. But we
must now turn to more peripheral matters, like how to print facts,
and how to replace one fact by another.

~40
Now you're putting in lots of facts, you may like to print them onto
paper. Depending on where you're working, you can do this with one of
three commands:

      show ctc.
      show oucs.
      show ep.

You use these just like the "show" command. The "show ctc" command makes
a copy of your facts on the Vax printer in the Computer Teaching Centre,
59 George Street. The "show oucs" command makes a copy on the Vax
printer in OUCS, 13 Banbury Road. The "show ep" command makes a copy on
the printer on level D of the Psychology Department.

If you are in CTC, the staff will be glad to show you where the printer
is and how to remove your listing from it.

If you have had enough, you may want to quit (with the "bye" command),
and come back later. If not, type "next" to find out some useful things
about changing or EDITING your facts, and saving them for future use.

~41
You have doubtless accumulated some dud facts by now that you'd like to
remove or change. If you're familiar with the programming language
Basic, you may have guessed how to do this. Each fact has a number,
which you see when you do "show".

If you type a number followed immediately by a full stop, the fact with
that number will be deleted. If you type a number followed by a fact
(and then a full stop), any fact with that number will be replaced by
the new one: if there isn't a fact with that number, the new one will be
inserted in the correct position.

~42
For example, if you type

      0 chris eats bounties.
      1 steve eats galaxy.
      2 adam eats bournvilles.

these facts will be inserted before any others, and any facts numbered
0, 1, or 2 will be removed. If you then type

      0 chris eats liquorice.
      1.
      2 michaela eats liquorice.

facts 0 and 2 are replaced, and fact 1 is deleted.

~43
There is also a "delete" command. "delete" with a number after it just
deletes that fact. So

      delete 1.

deletes fact 1.

But you can also delete a whole range of facts by using two numbers
connected by a slash. So

      delete 1/234.

deletes all facts whose numbers lie between 1 and 234 inclusive.

And most drastically of all,

        delete all.

will delete ALL your facts. Use it with care!

~44
If you can't be bothered with numbers, then you can just type "delete"
followed by the fact itself. So

      delete mary loves john.

will delete the fact "mary loves john". It's quite safe to use this even
if there isn't such a fact; in that case, the Tutor will just do
nothing.

You can also delete all facts for a given "verb". So

      delete loves.

will delete all facts about "loves". Similarly,

      delete eats.

will delete all facts about "eats".

~45
Finally, if you have just typed a fact, and you want to delete it
straight away, type "delete" on its own:

      john loves garlic.
      delete.
      john eats garlic.

This can be useful if you accidently type "." instead of "?" when asking
a question and the Tutor stores your question as a fact.

If you prefer, you can still delete the fact just by typing its number.

You may want to practise with these commands. When you think you've got
them, go on to the next section, which talks about "show".

~46
As with "delete", so with "show": you can select the facts to be shown.
This is useful if you have so many that they won't fit on one screen.

You can say

      show 1.           --- to show fact 1.
      show 1/20.        --- to show facts 1 to 20 inclusive.
      show loves.       --- to show all facts about "loves".

In fact, you can combine these ranges with the words "ctc" and "oucs".
For example
      show ctc 33.
      show oucs 10/100.
      show ep eats.
if you only want to print selected facts. The name of the printer comes
before the range.

~47
That, for the moment, concludes the business of displaying and changing
your facts. Now, how to save them.

All the facts you've currently told the Tutor make up your program's
KNOWLEDGE BASE. This is a combination of the facts' logical meanings
(with which the Tutor does its reasoning) and their text (which it uses
for "show"). The two are held in different memories, as we saw in
section 22, but the Tutor does need both of them.

You can make a permanent copy of your knowledge base. This copy is
called a FILE. It will be magnetically recorded on the Vax's HARD DISC
(a big brother of a micro-computer's cassette or floppy disc). The copy
is safe from vanishing - unless the Vax catches fire, or a software
pirate attacks it!

When you copy the knowledge base into a file, you must choose a name for
it - perhaps your surname, or a name like "myfirstfacts". Then you can
use the "save" command to keep the file safe on magnetic disc:
      save myfirstfacts.

Try this. You don't need to use the name "myfirstfacts" - choose
whatever name you like.

~48
To get back to a previously saved file, use the "restore" command,
followed by the name of the file:

      restore myfirstfacts.

This THROWS AWAY any facts currently in your knowledge base and REPLACES
them by the ones in the named magnetic disc file.

Try a sequence like:

    save facts.
    i like logic.
    save newfacts.
    restore facts.
    restore newfacts.

~49
This demonstrates that you can have several different knowledge bases
saved on file at the same time. Telling the Tutor a fact does NOT change
any of the files. You need a "save" for that. When you restore a
knowledge base, any facts you have here disappear, and are replaced by
what's in the file.

~50
You can save into the same file more than once:

    save facts.
    i want_a_drink_of coffee.
    save facts.

When you do the second save, it replaces whatever was in the file
before. (Actually, that's not quite true, and your teacher will know how
to get at the old version if you need it. But as far as you're
concerned, the old file is no longer accessible).

~51
The last word on files is about automatic saves. As you work, the Tutor
counts the number of changes you make. After every 5 changes (roughly),
it automatically saves your knowledge base in a file called AUTO. So, if
lightning suddenly strikes the computer and puts it out of action, some
your work should still be preserved, ready for use when it starts
running again. (The computer can "crash" for many reasons; and indeed,
lightning has crashed it several times. But though a crash may stop it
for some time, the files will almost never be destroyed, and will be
waiting for you when it begins running.)

The Tutor also saves your knowledge base when you say "bye". Again, this
is in a file called AUTO.

When you start up the Tutor, it looks for this file, and tries restoring
from it. So, when you come back after coffee (or whenever), your old
work should be automatically loaded. the Tutor will tell you it's done
this, and you can then use "show" to see what it's found.

Of course, you can still save and restore into files of your own choice.

~52
And the last word on Logic for this lesson is about the "why" command.
Suppose you ask a question and you want to see where the Tutor got the
answer from. You can do this with the command
      why.

Thus
      X eats garlic and X eats curry?
      ... the Tutor gives an answer ...
      why.
      ... the Tutor explains it for you ...

What happens is that the Tutor keeps a note of the last question you
asked. If you say "why", it has another go at the question, this time
keeping a log of what it's doing so it can show you where the correct
answer came from. Try asking some questions and then saying "why".

~53
You can actually say
      why?
instead. The Tutor doesn't care whether you put a dot or a question mark
after a command, as long as one of them is there. But it insists you get
them right after facts and questions so it can tell which is which.

Incidentally, the Tutor will only explain the first answer. This is due
to technical problems which I may one day sort out.

~54
Now, this is almost the end of Lesson 1. As mentioned above, when you
use the "bye" command, your facts will be saved in a file called AUTO;
and the Tutor will try reading this file when you start it up again. You
may want to save them somewhere else too; if so, please do so now.

Before ending, please read the final sections of this lesson, to clarify
what the Tutor can't do, and show how little it understands:

~55
  "As an able but little known writer has remarked:
    ''Suppose someone to  assert: The gostak distims the  doshes. You do
    not know  what this means;  nor do I.  But if  we assume that  it is
    English, we know  that 'the doshes are distimmed by  the gostak'. We
    know too that  'one distimmer of doshes is a  gostak' . If moreover,
    the 'doshes are galloons', we know that 'some galloons are distimmed
    by the gostak'. And so we may go on, and so we often do go on''
  ".

The quote above is from "The Meaning of Meaning" by C.K.Ogden and I.A.
Richards; quoted also by Dr. Miles Breuer in "The gostak and the
doshes", an S.F. tale of countries driven to war through the force of
incomprehensible slogans.

~56
The Tutor works at the same level of understanding: manipulating words
like "loves" and "joe" without any notion of what they denote. All it
does is to apply a few rules of logic. The main one is what's
technically called MODUS PONENS:

    If I have a rule of the form (Q if P)
    And I know that P is true
    Then I can deduce that Q is true.

~57
This being so, the Tutor does not and cannot perform inferences which
depend on the meaning of the words it reads.

For example, WE find it natural to infer from
      X is in Y  and  Y is in Z
that
      X is in Z.

However, from
      X faces opposite Y  and  Y faces opposite Z
we do not infer that
      X faces opposite Z

Knowing nothing of the meaning of "in", the Tutor would have no reason
to make the first inference rather than the second. Of course, we could
tell it to, by adding a rule like "X is in Z if X is in Y and Y is in
Z".

But if we don't, it will not do any such inference for itself. It has NO
common sense or general knowledge.

~58
This lack of common sense answers a common problem. If you put in a fact
such as
    england is_next_to wales.
and ask
    wales is_next_to england?

then the Tutor will say "No solutions" - i.e. it isn't. That's because,
lacking any knowledge of the meaning of "is_next_to", the Tutor doesn't
know it's reversible - doesn't know that if A is next to B, then B is
next to A. Some relationships aren't: "loves" for example. But the Tutor
has no way to know which are and which aren't.

~59
Finally, a point about ambiguity. If we say "I'm going for lunch in
about 10 minutes", the word "about" doesn't mean the same as in "Bill
Sykes set about him with a large cudgel", or "the documentary is about
the primeval struggle of the limpet for survival in a hostile marine
environment".

When using words in logic programs, we must ensure that each word in our
program has one and only one meaning. Otherwise we can get into
confusions like

    10        nothing is_better_than heaven.
    20        ham_sandwich is_better_than nothing.
    30        X is_much_better_than Y  if
              X is_better_than Z  and
              Z is_better_than Y.

from which Logic could infer that:

    ham_sandwich is_much_better_than heaven

~60
The incorrect inference above is a well-known joke; it results from the
ambiguity of "nothing". Another joke arises from the mis-use of "is":

    40        tigers eat meat.
    50        meat is_a word.
    60        X eat Y  if
              Z is_a Y  and
              X eat Z.

From these facts, the Tutor would deduce that

    tigers eat word.

These are extreme examples, but the same kind of confusion can arise in
less extreme cases. So, when programming, make sure that each name in
your program refers to one and only one concept.

~61
You have now reached the end of Lesson 1. If you want to continue
experimenting with inferences and questions, please do so. When you've
finished, there are some more examples in Supplement 1 which I'd like
you to try.

When you are ready for Lesson 2, you can get to it, if you're still
inside the Tutor, by typing the command
      script lesson2.
after which you will see the first section of Lesson 2.

If you need to start the Tutor up again first, then typing
      LOGIC LESSON2
when you see the dollar prompt will do it.
