Teaching Prolog to 12 (or so) year olds

Hi,

I am looking for problems that are well suited to introduce Prolog to 12 year olds. The typical exercises found in text books aren’t really a draw at this age.

One direction i was thinking about is a kind of adventure game – those text based games where one walks around and picks tools, encounters puzzles, etc. but, it would be good to have something already available that could be used as a basis.

Any thoughts on this would be greatly appreciated.

Dan

1 Like

Some funny adventure games that may be simple enough for the kids to modify and extend:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/adventure

Also some logical puzzles:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/puzzles

Have fun!

Great. Thanks.

Dan

I once found

https://bobthesimplebot.github.io/

when looking through the “LPS” system: http://lps.doc.ic.ac.uk/

There might be something useful there (not sure).

About 4 years ago, when my son was 14, he expressed an interest in learning programming whilst still at school so over the next few weeks…

I explained just enough of Prolog about facts and rules so that we could create a database of Pokemon creatures, what types they were, weaknesses etc as here:
https://www.eurogamer.net/articles/2018-12-21-pokemon-go-type-chart-effectiveness-weaknesses

Then I explained predicates to the point where we wrote some rules so do simple things like find all the water types etc, what pokemons evolve into what etc.

It was still more fun for me though! :smiley:

thanks.

Looks like it could be a good starting point … and if interest persist to branch out to an adventure game …

I don’t plan on specifically teaching my kids to program in Prolog, or even much programming. I say that as someone who is a programmer and has implemented an ISO compliant Prolog system. I am interested in teaching them to think “better” and that will, amongst other things, involve logic modelling. I like the style of the Kowalski’s paper:

https://www.researchgate.net/publication/220837209_Logic_as_a_Computer_Language_for_Children

It’s as close to what I might end up doing. I can imagine starting with a travel network (subway map, train map, road map, etc.) and seeing if they can come up with rules of getting from A to B, and things like that. You can explore names, variables, relations (symmetry, transitivity, etc.), set theory, recursion, computational complexity, and many other things without even touching a computer.

Actually, if I were to do any programming with them it would probably involve robotics. I’m one of the LOGO generation! Lots of opportunity to work with physics, geometry, trig. etc. which to me are more important for them to learn than configuring a machine.

3 Likes

Late to the party but I will give it a go.

I wonder what is the current math curriculum for a 12-year old. (next paragraph will explain why I think this is relevant.) My somewhat fragmentary memories from that time are that we were covering a bastardized version of the first few books of Euclid’s “Elements” (so basically geometry, mostly simple formal proofs and applying those to problems); another theme running through math/physics for 6, 7, 8 grade was reading a question formulated as text and figuring out how to write an equation that solves it, then solving it.

Now: for me at that point of time, I would have loved to write a program that takes an equation and solves it as required by the teacher, for example:

2x + 8 = 22 (input to the program)

The program prints out:

2x = 22 - 8

2x = 14

x = 14/2

x = 7

Something else in a similar vein would be proving triangle congruence, with each step telling me which theorem in my textbook’s bastardized version of The Elements is applied.

In physics in particular, doing the “units check”. (If I am looking for “speed”, does my equation when solved for x give me m/s or did I make a mistake?)

I know this sounds BORING! but as a matter of fact, I was bored to death by having to actually go through all the mechanical steps of the problems we were usually solving. We did not have computers available to us nor did I know that computers can do that, but I suspect I would have absolutely loved it.

  1. I would have loved writing such a program
  2. Even more so, I would have loved that I don’t have to manually do this shit again and again and again.

Those kinds of programs exist, also for Prolog, but the fun here is to write them from scratch.

Writing just such a program isn’t easy. I’ve only seen it in undergraduate/postgraduate texts. Bundy’s Computer Modelling of Mathematical Reasoning (in Prolog), or Forbus and De Kleer’s building problem solvers (in Lisp). Forbus and De Kleer are quit clear about them just covering what Bundy did (in his doctoral thesis?) as they’re more interested in using this as an example of search and heuristics taming the combinatorial explosion. I think Bundy’s three catgories of rules (attraction methods, collection methods, and isolation methdods) was quite a leap, so not something for kids or young adults to come up with themselves, form scratch.

Yay for LOGO! Out computer studies teacher, Ms. Turpit, was heavily involved with the local colleges and IT and she obtained a full sized working plastic wheeled turtle for us for two months, it was awesome. Driven by our Research Machines 380Z.

1 Like

Something I’ve found fun and educational is solving the kind of logic puzzles that involve filling out a table. I found a book of these in a remainder sale a while back and the first one goes like this:

Tackfield St Andrew is a lovely little Suffolk village whose inhabitants are very conservative – they still refer to a number of retired Londoners who moved there years ago as ‘the new people’. From the clues below, can you work out where in London each of ‘the new people’ came from, how long they’ve lived in the village, and the name of each one’s home there?

It has a diagram which shows there are four variables with three values each:

Names: Alan Bradley, Mavis Norton, Walter Young
Area: Battersea, Islington, Paddington
Period: 8, 11, 16 years
House: Meadow View, Rose Cottage, White Gates

Then there are four clues to fit these together:

  1. Walter Young, who lives at Meadow View, is not the former Londoner who used to live and work in Islington.
  1. The person whose ex-home was just behind Paddington railway station has lived in Tackfield St Andrew longer than Alan Bradley.
  1. The Resident in White Gates has lived in the village for more than 8 years.
  1. One of the ‘new people’ has actually been living at Rose Cottage for 16 years.

My solution from a while back (which I should probably revisit to see if I can improve it) is:

puzzle(People) :-
    People = [newpeople(_, _,  8, _), 
              newpeople(_, _, 11, _), 
              newpeople(_, _, 16, 'Rose Cottage')],
    member(newpeople('Alan Bradley', _, Period1, _), People),
    member(newpeople('Mavis Norton', _, _, _), People),
    member(newpeople('Walter Young', _, _, 'Meadow View'), People),
    member(newpeople(_, _, Period2, 'White Gates'), People),
    member(newpeople(_, 'Battersea', _, _), People),
    member(newpeople(_, 'Islington', _, _), People),
    member(newpeople(_, 'Paddington', Period3, _), People),
    \+member(newpeople('Walter Young', 'Islington', _, _), People),
    Period2 > 8,
    Period3 > Period1.

These are known as Zebra or Einstein’s puzzle (Wikipedia)

Slightly older kids might enjoy the red and green Puzzles in Logic, Language, and Computation.


2 Likes

Thank you.

Too bad that these books are quite pricey …

I noticed that tabling is helpful as well – since stratifying recursive calls makes it more complex to explain recursive concepts that are otherwise quite natural to describe, e.g. transitivity.

Although, with tabling interactive tracing is not possible (tabling traces bottom out at system tries calls)

Dan

This is not so much about things being easy or difficult (and anyway, I cannot claim to be able to say what is easy and what is difficult to a 12-year old. I was a 12-year old too long ago and there is no way I can put myself in the shoes of a 12-year old. I do remember though that teachers did spend forever on the obvious stuff and tended to skip over the hard stuff. I don’t know the reasons for those memories.)

This is about motivation. Everything is worth pursuing as long as it is somehow motivating; at the same time, it is a waste of emotional power to try and do things that are not interesting. And different kids are interested in different things, and some kids don’t seem to be interested in the things we grown ups have to do at all. So maybe the real interesting question here is:

How do we figure out what would be exciting to a 12-year old?

Robots (as @emacstheviking already said above) seem to be a bit more universally exciting to children of all ages. But the really exciting stuff in robots (to a 37-year old child) is a bit too far away from Prolog. Or rather, there is quite a bit of ground to cover (sensor output, actuators, working with limited “computer” inside the robot, communication and so on) before one gets to a more high-level view of the robot.

PS: yes, I admit I get bored with puzzles a bit too easily. Here is an informal proof that I think I stole from another kid that went to the same high-school as me.

To solve a given puzzle means that someone knows beforehand that the puzzle has a solution. So, we know that the puzzle has a solution, and someone has already worked out the solution. So, the puzzle is already solved.

(If memory serves me, the kid I have in mind was way ahead everyone else in his mathematical ability and was bored to death; he used this reasoning once on our philosophy/logic teacher to piss her off, with great success.)

There must be something very rewarding or addictive in the process of solving a solvable puzzle to make is worth the effort. For example, the promise that you could come up with something that everyone else has missed so far (dreaming is allowed). But this means that a) the problems are complex and b) we must define what counts as a solution on our own!

This is worth repeating with other words. If we know from the get-go that there is a well known road to a solution, this immediately diminishes the perceived worth of getting there. This (in my personal and very unpopular opinion) is the tragic failure of our current educational system. (Now I will terribly generalize things to keep it short, of course there are counter-examples to what I will say.)

Since we want to have experimental evidence that we are successfully educating our kids, we have come up with tests and exams that can be reproducibly evaluated accross children, schools and so on. This has resulted to an overfitting of the teaching material and the teaching effort: we are teaching our kids to be better at the exams that we have created for them. This is a terrible failure in my opinion.

I will stop here because this is too far off-topic and this is probably the wrong forum altogether.

1 Like

Hi all,

While puzzles can surely be a draw for a (smart) 12 year old; what I had in mind was to teach programming skills that are, eventually, useful for real-world problem solving.

Also, i was thinking to find examples were the prolog paradigm is clearly well suited, i.e. where representation is a key solution component, and where rules, recursive and non-deterministic reasoning play a key role in developing declarative, easy to understand, and elegant solutions.

So, i think the adventure game seems to fit here well; symbolic math could be interesting but its much more specialized, puzzles are fun, but also quite specialized. And robotics at the level of physical actuation seems less well suited for a prolog paradigm.

Dan

A tutorial on writing an adventure game in Prolog is online at

https://www.amzi.com/AdventureInProlog/advtop.php

I haven’t personally worked through it, so can’t say how good it is.

Something I found interesting is that Infocom developed their own Lisp dialect to write Zork etc in, which is now freely available from github.

I recall reading somewhere that the original Colossal Cave’s Fortran code is also freely available on the web.

So basically, you are in a twisty maze of passageways, all alike when it comes to writing text-based interactive fiction.

I remember them being muuuuch cheaper!

Anyway, keeping on topic, have you read Mindstorms?

Here’s a documentary covering most of the same ground:

Some interesting Prolog based robotics stuff from the University of Toronto Cognitive Robotics group:
http://www.cs.toronto.edu/cogrobo/main/systems/