Showing posts with label SWI-Prolog. Show all posts
Showing posts with label SWI-Prolog. Show all posts

Wednesday, October 24, 2018

Transgender? Ask an AI

An image of Aiden Katri uploaded to her Facebook page on Tuesday, March 29, 2016, together with a post explaining her decision to conscientiously object (Aiden Katri/Facebook)

Commenting on yesterday's post, "The 'is' and 'ought' of homosexuality", Roy suggested I should write something on the current hot topic of transgenderism.

As a topic this ranks with dissing the Religion of Peace, suggesting the Saudi ruling clique might have psychopathic tendencies or speaking out in support of Brexit.

Obviously I'm not going to go there .. . But wait! Let's be objective about this. We can ask an AI. Time to invoke SWI Prolog in theorem-proving mode.

---

Let’s start by introducing a convenient acronym: marbiafl:
“Male As Regards Body - Identifies As Female Lesbian”.
The scientific approach would be to axiomatise the properties of the marbiafl and then appeal to Leibniz's law, the identity of indiscernibles. First we list the properties of heterosexual men, then the properties of heterosexual women (for simplicity just the 95% of the population who are straight) and finally, the properties of transgender people who are biologically male but who self-identify as lesbian females.

property(man, often_aggressive).
property(man, male_genitalia).
property(man, over_muscled_or_fat).
property(man, hairy_face).
property(man, wants_sex_with_women).

property(woman, often_agreeable).
property(woman, female_genitalia).
property(woman, often_slim_and_petite).
property(woman, smooth_face).
property(woman, romantically_inclined_to_men).

property(marbiafl, often_aggressive).
property(marbiafl, male_genitalia).
property(marbiafl, over_muscled_or_fat).
property(marbiafl, hairy_face).
property(marbiafl, wants_sex_with_women).

Now we ask: are transgender people (as defined above) men or women?

transgender_is(X, Y) :- findall(P, property(X, P), Plist), findall(P, property(Y, P), Plist).

This says a transgender person X is a Y (man or woman) if all the properties of X (gathered in Plist) are just the same as all the properties of a Y (a man or a woman). This is Leibniz's law.

Here is how findall works on the dataset already defined, using SWI Prolog:

?- findall(P, property(man, P), Plist).
Plist = [often_aggressive, male_genitalia, over_muscled_or_fat, hairy_face, wants_sex_with_women].

?- findall(P, property(woman, P), Plist).
Plist = [often_agreeable, female_genitalia, often_slim_and_petite, smooth_face, romantically_inclined_to_men].

?- findall(P, property(marbiafl, P), Plist).
Plist = [often_aggressive, male_genitalia, over_muscled_or_fat, hairy_face, wants_sex_with_women].
---

We have now trained the AI and it's ready to answer our questions.

?- transgender_is(marbiafl, woman).
 false.

?- transgender_is(marbiafl, man).
 true.

Oh dear! A shock for activists, I wasn't expecting that.

Tuesday, August 07, 2018

Your personality chooses your religion (humour)



The "New Atheists" (Dawkins et al) have a down on religion because -- it isn't true.

Duh! of course no religion can survive the laws of physics .. which explain everything. But religion does more for us than that.
  • It provides a moral framework for our lives as social beings
  • It provides some reassurance in the face of our own mortality
  • Adherence advertises to ourselves and others a commitment to moral behaviour.
These are all things worth having. Yet it's hard to commit to the difficult path of self-discipline and self-denial except under supernatural duress. A candidate religion would be preferable to the extent it was at least somewhat believable.

And then there is the style of the religion. Can one approach it in an intellectually austere way - as an introvert? Or does one have to sway, dance, sing and play the guitar?

Finally  there's not much chance of impressing others with your own commitment to virtue if you advertise your adherence to a faith that no-one has ever heard of, or which is a laughing stock. Church of Scientology, anyone?

So faced with these constraints, I turned to AI and cranked up my Prolog theorem-prover again (last used in car selection).

/* Choosing your religion by the four psychological temperaments (SP, SJ, NF, NT)

Classify religions (faiths) on the following dimensions:
- intensity [ascetic, calm, emotional, shrill]
- plausibility [low, medium]
- recognition amongst the UK public [low, medium]

candidates: evangelical, anglican, wahhabism, sufism, hinduism, buddhism, philosophical_taoism, sjw.
*/

religion(R) :- member(R, [evangelical, anglican, wahhabism, sufism, hinduism, buddhism, philosophical_taoism, sjw]).

intensity(evangelical, emotional).
intensity(anglican, calm).
intensity(wahhabism, emotional).
intensity(sufism, ascetic).
intensity(hinduism, emotional).
intensity(buddhism, calm).
intensity(philosophical_taoism, ascetic).
intensity(sjw, shrill).

plausibility(R, low) :- member(R, [evangelical, anglican, wahhabism, sufism, hinduism]).
plausibility(R, medium) :- member(R, [buddhism, philosophical_taoism, sjw]).

recognition(R, low)     :- member(R, [buddhism, philosophical_taoism, wahhabism, sufism]).
recognition(R, medium)  :- member(R, [evangelical, anglican,  hinduism, sjw]).

choose(Religion, sp) :- intensity(Religion, emotional).
choose(Religion, sj) :- intensity(Religion, calm), recognition(Religion, medium).
choose(Religion, nf) :- intensity(Religion, X), X \= ascetic.
choose(Religion, nt) :- intensity(Religion, ascetic), plausibility(Religion, medium).

?- choose(Religion, sp).
Religion = evangelical ;
Religion = wahhabism ;
Religion = hinduism.
?- choose(Religion, sj).
Religion = anglican ;
?- choose(Religion, nf).
Religion = evangelical ;
Religion = anglican ;
Religion = wahhabism ;
Religion = hinduism ;
Religion = buddhism ;
Religion = sjw.
?- choose(Religion, nt).
Religion = philosophical_taoism ;
---

Notice that I've used the Myers-Briggs/Keirsey temperament classifications: SP-Artisan, SJ-Guardian, NF-Idealist, NT-Rational.

I speak to you as an NT, a Rational. I must say that Taoism is no surprise, but despite my admiration for Lao Tzu and Ursula le Guin, I won't be following the Way any time soon. Too passive, too airy-fairy and how can you take seriously people who call themselves 'cultivators'???

---

Disclaimer: this post is satirical and lays no claim to empirical verisimilitude. It is based on no research and no conclusions should be drawn. If anyone's feelings are hurt, I can only plead for forgiveness. That shouldn't be too difficult.

Sunday, November 05, 2017

Towards the esoterically-programmed chatbot

Gary Larson has this famous cartoon:



It might as well be labelled, 'What chatbots hear'.

I type something profound to the chatbot, and this is what the program gets:
"I     *!@      +^%    £")#     owl      +=&£."
Plainly no amount of inference is going to reconstruct that. However, a gossipy chatbot has only to keep the conversation going .. .



An Eliza-type program uses patterns such as:
"I tokens* owl tokens*"  => "How interested are you in owls?"
where the response is bland enough to match most owl-related utterances.

If the chatbot can recognise a little more, perhaps put some syntactic structure to it, then we could do a semantically-informed best match to the noisy user input using a metric over the space of semantic structures (I'm thinking something like situation semantics, or more likely an extensible, data-populated semantic net).

It might be tempting to map everything into a vector space but that's way too much gratuitous (and irrelevant) structure: like doing logic programming using arithmetic over Gödel numbering. To save us from that was why God invented compilers.

---

I'd like to play with some of these ideas, restart my stalled chatbot programme. But I'm lazy, I don't want to do low-level coding, I want a really high-level language which lets me get straight into the problem space. And this brings me - via consideration of Lisp and Haskell - back to Prolog.

As I wrote a couple of years ago,
"First, Prolog. Its supporters always touted it as a higher-level language than Lisp - though I always found Lisp more congenial, I like to set up data structures and manipulate them explicitly. With Prolog you define relationships between things and the miraculous powers of unification and depth-first search with backtracking pull magical rabbits out of hats. The Eliza program in Prolog can be read in its entirety on one screen, ditto for the blocks world planning system.

This procedural power is the result of enormously complex recursive structures built at execution time by the Prolog system. It frequently defies one's powers of abstraction, short-term memory and inference to visualise what's actually going on. I know you're meant to read and understand the programs declaratively, but in reality you don't get too far without a consideration of what actually happens at run-time.

Still, the power to write ridiculously-powerful programs in just a few lines of code is addictive. It reminds me of the first time I fired the General-Purpose Machine Gun (GPMG). I was good with the Lee-Enfield rifle and prided myself on my accuracy; the GPMG just bounced around and hosed the target. So much power and so little control!"
---

Oh, and here's Eliza in Prolog (as modified to represent our deceased pet, Shadow) from the Sterling and Shapiro book, 'The Art of Prolog', (chapter 14):
shadow :-
write('Hello, I am Shadow. Miaow!'),
nl,write('Please type your thoughts and press return.'),
nl,write('To finish type bye'),nl,
read_word_list(Input),shadow(Input),!.

shadow([bye]) :- reply(['Goodbye, miaow!']).

shadow(Input) :-
pattern(Stimulus,Response),
match(Stimulus,Dictionary,Input),
match(Response,Dictionary,Output),
reply(Output),
read_word_list(Input1),
!,shadow(Input1).

match([Word|Pattern],Dictionary,[Word|Target]) :-
atom(Word),
match(Pattern,Dictionary,Target).

match([N|Pattern],Dictionary,Target) :-
integer(N),
append(LeftTarget,RightTarget,Target),
lookup(N,Dictionary,LeftTarget),
match(Pattern,Dictionary,RightTarget).

match([],_,[]).


reply([Head|Tail]) :- write(Head), write(' '),reply(Tail).

reply([]) :- nl.

lookup(Key,[(Key,Value)|_],Value).

lookup(Key,[(Key1,_)|Dict],Value) :- Key \= Key1,lookup(Key,Dict,Value).

There are some lower-level functions (and the relevant patterns) defined elsewhere, but this is the gist of it. Pretty clear, wouldn't you say?


Amazon link

I used to think it was just me, but I read somewhere of the despair of computer science students at Edinburgh university at the sheer intellectual difficulty of writing (and even understanding) non-trivial programs in Prolog. It would seem there's a high IQ-cutoff just to use the language at all.

This reminds me of Marain, the language of the Culture, where those dialects used by the Minds were simply beyond the intellectual capacities of humans. And while we're on that case, let me remind you of a real-world counterpart: Malbolge.
"... invented by Ben Olmstead in 1998 and named after the eighth circle of hell in Dante's Inferno. "Malbolge was specifically designed to be almost impossible to use, via a counter-intuitive 'crazy operation', base-three arithmetic, and self-altering code." *

In fact the author of Malbolge was unable himself to write a program in it.

In the end it required an AI system to write the first program, using a form of 'best-first' search in the space of all possible programs.

Here is the "Hello World!" program in Malbolge.
(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc
---

* Malbolge design trivia.
After each instruction is executed, the guilty instruction gets encrypted so that it won't do the same thing next time, unless a jump just happened. Right after a jump, Malbolge will encrypt the innocent instruction just prior to the one it jumped to instead."
Of course, with artificial neural networks and deep learning, we're already away with the fairies as far as esoteric programming is concerned.

As for me, I've re-installed SWI-Prolog. Time to get up to speed with programming in logic again - so hard to think with, yet so much more compact than Lisp.

Saturday, December 10, 2016

Why I never get anything done

I'm thinking ahead to when I get the Replika app on my Nexus 6 phone, early next year. I guess I'll soon be loading their Cloud database with forty texts per day.

I need to remember their usage model:
""Anyone grieving for a loved one will soon be able to talk to them using artificial intelligence technology pioneered by a woman who lost her best friend.

"Eugenia Kuyda, co-founder of Luka, a US technology company, has used the latest in AI systems to create a virtual version of Roman Mazurenko, who was killed in a road accident last year, days before his 33rd birthday.

"She fed more than 8,000 lines of text messages sent by Mr Mazurenko into a Google programme that allows people to create their own “chatbots” — computer programmes designed to simulate conversation with human users.

"The chatbot responds to questions in language that mimics Mr Mazurenko’s speech patterns so that she and other friends can “talk” to him as part of the grieving process.

"Ms Kuyda, 29, said that any doubts she had about the technology were allayed when the bot responded to her first questions in a tone that sounded like her friend."

The point of all this is that someone else, interacting with my chatbot-Replika, will think they're talking to "me". But I'm a different person depending on to whom I'm talking. Not everyone gets my flippant sense of humour so occasionally I have to act serious.

That's going to be a tough one.

Then I thought: it's unlikely that Replika (the company) will build a personal back-story, a contextual knowledge-base to power inference and make "my" replies more intelligent.

So why not do it myself?

I could simply copy all those Q&A texts into a .txt file and process them via a program like Eliza plus an automated theorem-prover (ATP).

The easiest way to do this would be in Prolog. The Eliza part isn't so hard: I already implemented a simple version using "The Art of Prolog" by Sterling and Shapiro. Writing an ATP in Prolog would also be interesting (and is also covered in the book).




The strategy is this. Start with the natural language input from those forty texts per day, specifically the questions being asked of me. We can't do inference on natural language so we have to translate it into a formal language with inference rules. The simplest is first-order predicate calculus: the Prolog clause variant would work.

We need the additional knowledge base which I would hand-craft (based on my own text responses) plus some rules to guide conversational inference - getting from an input to producing an appropriate output. All this could be coded as Prolog rules. It's similar to writing a meta-interpreter for Prolog in Prolog, covered in the book.

Finally I would translate the clausal form of the output into natural language as "my" response. A better response than any that a superficial Eliza-chatbot-like architecture could give.

You may think, like me, that this is already sounding like a big project.

---

So then I think. No-one but me could ever use this system. (Which kind of undermines the point).

It would have to be embedded in something like SWI-Prolog which would need to be launched first and would only work on my own machine. Getting it to work consistently and robustly across the Internet is most likely impossible.

Perhaps this should be implemented in Javascript so that my expert-system-Replika hybrid could be loaded into a client web page for anyone who wanted to have a conversation with "me"?
- There appears to be no really usable Prolog to Javascript compiler.
Writing anything as complex as I have described in native Javascript seems impossibly difficult.

... and so my mind wanders off, to something more immediately gratifying ... .

---

Sorry if this all sounds so GOFAI. I have as much chance of running TensorFlow at home as fly ...

Tuesday, September 08, 2015

Helping out the dork

If you read this recent post, you will have met the dork musing on whether his girl really fancies him or not.



Like Leibniz, we can now cry "calculemus!" using the power of SWI-Prolog.

The dork muses:  "Not sure if she likes me, or she's just a nice person." She shows the dork affection, but what more can he infer? His problem is that nice people show affection to everybody.

In Prolog we write:
shows_affection(girl,dork).

nice(X) :- shows_affection(X,Y).
Y will get successively bound to anyone X shows affection to. When we run a query as to whether the girl is nice, this is what we get:
?- nice(girl).

true.

But ..  if someone likes you, they show affection to you and are (or ought to be) indifferent to others. So the dork needs to check whether the girl is indifferent to all others. Suppose she is, then we write:
indifferent(girl,everyone_else).

likes(X,Y) :- shows_affection(X,Y), indifferent(X,Z), Z\=Y.

We run the query: does the girl like the dork?
?- likes(girl,dork).

true
So under these assumptions the dork gets lucky ,, but he has to check.

---

I tagged this post as humour, and joke. Prolog adds very little except as a check on assumptions, but the tiniest bit of thought is needed to address the dilemma of the cartoon.

Thursday, September 03, 2015

AI Progress Report



So I got 'Eliza' working today, the simplified version from 'The Art of Prolog'. Time to take stock and figure out where to go next.

First, Prolog. Its supporters always touted it as a higher-level language than Lisp - though I always found Lisp more congenial, I like to set up data structures and manipulate them explicitly. With Prolog you define relationships between things and the miraculous powers of unification and depth-first search with backtracking pull magical rabbits out of hats. The Eliza program in Prolog can be read in its entirety on one screen, ditto for the blocks world planning system.

This procedural power is the result of enormously complex recursive structures built at execution time by the Prolog system. It frequently defies one's powers of abstraction, short-term memory and inference to visualise what's actually going on. I know you're meant to read and understand the programs declaratively, but in reality you don't get too far without a consideration of what actually happens at run-time.

Still, the power to write ridiculously-powerful programs in just a few lines of code is addictive. It reminds me of the first time I fired the General-Purpose Machine Gun (GPMG). I was good with the Lee-Enfield rifle and prided myself on my accuracy; the GPMG just bounced around and hosed the target. So much power and so little control!

---

Eliza and the Blocks World Planner were little milestones I had set myself, like climbing Pen y Fan. Items on my bucket list if you like. So what next?

Once you know how to set up knowledge bases and inferential systems you have the tools for developing intelligent agents. But, as I have cited before on these pages, 'in the knowledge lies the power'. If your agent lives in a closed-world with a fixed and limited database and rule set, it's going to run out of new things to do pretty fast. The interest comes from its interactions with the wider world.

Yet as Doug Lenat noted in the context of his 'Cyc' project:
"Any time you look at any kind of real life piece of text or utterance that one human wrote or said to another human, it's filled with analogies, modal logic, belief, expectation, fear, nested modals, lots of variables and quantifiers," Lenat said. "Everyone else is looking for a free-lunch way to finesse that. Shallow chatbots show a veneer of intelligence or statistical learning from large amounts of data. Amazon and Netflix recommend books and movies very well without understanding in any way what they're doing or why someone might like something.

"It's the difference between someone who understands what they're doing and someone going through the motions of performing something."

Cycorp's product, Cyc, isn't "programmed" in the conventional sense. It's much more accurate to say it's being "taught." Lenat told us that most people think of computer programs as "procedural, [like] a flowchart," but building Cyc is "much more like educating a child."

"We're using a consistent language to build a model of the world," he said.

This means Cyc can see "the white space rather than the black space in what everyone reads and writes to each other." An author might explicitly choose certain words and sentences as he's writing, but in between the sentences are all sorts of things you expect the reader to infer; Cyc aims to make these inferences.

Consider the sentence, "John Smith robbed First National Bank and was sentenced to 30 years in prison." It leaves out the details surrounding his being caught, arrested, put on trial, and found guilty. A human would never actually go through all that detail because it's alternately boring, confusing, or insulting. You can safely assume other people know what you're talking about. It's like pronoun use - he, she, it - one assumes people can figure out the referent. This stuff is very hard for computers to understand and get right, but Cyc does both.

"If computers were human," Lenat told us, "they'd present themselves as autistic, schizophrenic, or otherwise brittle. It would be unwise or dangerous for that person to take care of children and cook meals, but it's on the horizon for home robots. That's like saying, 'We have an important job to do, but we're going to hire dogs and cats to do it.'"
Cyc has been in development since 1984 and its knowledge base currently contains over one million human-defined assertions, rules or common sense ideas. Yet it's still barely found practical use. I'm certainly not planning on reproducing that level of effort.

I think we're back to virtualizing the cat ...

Saturday, August 15, 2015

Is your author a butterfly?

The author's wife continually accuses your interlocutor of being a butterfly. He is said to pick up a new interest, insanely obsess about it (ordering books, reading articles, immersing himself) for .. oh, a few weeks ... until the next big thing comes up and, magpie-like, he moves on.

I naturally deprecate this characterisation but how to disprove it? Time to ask an artificial intelligence. Here is the transcript of my query to the mighty and powerful SWI-Prolog system.




/* Is Nigel a butterfly? */

likes(nigel,physics).
likes(nigel,prolog).
likes(nigel,genetics).
likes(nigel,politics).
likes(nigel,cosmology).

interests(Person,List) :- findall(Topic,likes(Person,Topic),List).

obsessive(Person)       :- interests(Person,L),length(L,N),N=<2.

butterfly(Person)       :- not(obsessive(Person)).




Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 7.2.2) Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.

Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word).


1 ?- interests(nigel, L).
L = [physics, prolog, genetics, politics, cosmology].

2 ?- obsessive(nigel).
false.

3 ?- butterfly(nigel).
true.



I am abashed, but what can I do? Clare was right after all: computer says yes ...

Thursday, July 30, 2015

The Once and Future Kevin

Few things that Kevin did were unplanned. He thought he was the anchor to his flighty wife Suzanne, the person who smoothed the way, anticipated all of life’s little difficulties. But Kevin was aware that one day he would die. What would Suzanne do without his helpful guidance?

He had heard of email systems which would send a missive at a future date of your own choice. Why not send a note from beyond the grave, perhaps every year, on her birthday? Kevin immediately fired up Word and began to draft. But what could he write? Being dead, he would know nothing of the news, or Suzanne’s predicaments. Perhaps he should compose nostalgic text, recalling their life and times together?

Honestly, he couldn’t summon up the energy.

Instead, he downloaded the ‘Eliza’ program, renamed it ‘Kevin’, and began to improve it. After some months, ‘Kevin’, running on a Google server, could: - access Google News; apply Kevin’s unique take on the world (Kevin had coded himself into the rules engine); and could potentially send emails to Suzanne and even somewhat understand any replies (which was roughly Kevin’s own level of personal competence).

To be on the safe side, ‘Kevin’ sent monthly emails to Kevin, and if Kevin were to miss two replies in a row, ‘Kevin’ would presume him dead and immediately switch to sending timely and relevant messages to his grieving widow.

To his great surprise, Kevin died.

Suzanne was initially quite discombobulated by her husband’s demise. Freed from his smothering routines, she now had to think for herself. After a few weeks she pulled herself together and joined the local tennis club. There she met the handsome and charismatic coach with whom she rapidly developed a warm and affectionate relationship. Coincidentally, he was also called Kevin.

Suzanne never did look at her old email account, sharing her new partner’s instead. She had never got on with computers anyway. All is change in the world of the Internet and ‘Kevin’ was soon off-line in one of Google’s periodic efficiency drives, dumped into archival storage.

But Kevin had one consolation: at least Google never truly forgot him.

---

(c) Nigel Seel, 2015.


Eliza

Eliza Doolittle
Just loaded the Prolog implementation of the famous 'Eliza' from the Internet (here, heroically coded by Viren Patel back in 1992). Amazingly it runs without problems on my SWI-Prolog system. Here's a test dialogue .. just a moment ago.

Hello. I am ELIZA. How can I help you?
> I am sick.

I am sorry to hear you are sick.
> Ask me why I am sick

Do you think coming here will help you not to be sick?
> I'd like to think so.

I am not sure I understand you fully.
> Are you ever sick?

Why are you interested in whether I am ever sick or not?
> You interest me.

Why do you think I interest you?
> Because you're tantalising.

Is that the real reason?
> Yes, you interest me.

You seem quite positive.
> I am, very positive.

Is it because you are very positive that you came to me?
>
This is the point where the content-less nature of the dialogue begins to pall. Still, I think Eliza is fixable: insert a knowledge-base and reasoning system between the input and output processing and 'Eliza' suddenly becomes a lot less vacuous.

I feel digital immortality coming upon me by stealth ..

Wednesday, July 29, 2015

Avoiding left recursion

/*
A reminder of why I had (and still have) some qualms about Prolog, elegant though it is. We're told that Prolog programs are to be read declaratively, as specifications - don't think about the execution model! So pretty much my first SWI-Prolog program is this simple statement of likes below. To make it more interesting, I (counterfactually) state that 'likes' is transitive. So this is the program you get.

Program (wrong)

likes(puss-puss, voles).
likes(adrian, football).
likes(adrian, puss-puss).
likes(alex, jokes).
likes(alex, adrian).

likes(X, Z) :- likes(X, Y), likes(Y, Z).   %  transitivity of 'likes'

And this is what you see when you run the program with the query likes(alex,Y) where the intention is to list all the things Alex likes.

Result 

?- likes(alex, X).
X = jokes ;
X = adrian ;
ERROR: Out of local stack

What has happened is that the two facts:

likes(alex, jokes).
likes(alex, adrian).

were matched, then the 'transitivity' clause was invoked, which unfortunately matched itself repeatedly in an infinite loop, until the interpreter ran out of stack space. No problem with the program declaratively, but operationally it loops.

Here's the correct program with the results.

Program (correct)
*/

likes1(puss-puss, voles).
likes1(adrian, football).
likes1(adrian, puss-puss).
likes1(alex, jokes).
likes1(alex, adrian).

likes(X,Y) :- likes1(X,Y).
likes(X, Z) :- likes1(X, Y), likes(Y, Z).   % to stop left recursion, likes1 is first.
/*

Result when executed

?- likes(alex,X).
X = jokes ;
X = adrian ;
X = football ;
X = puss-puss ;
X = voles ;
false.

Even this simple program has a small capacity to surprise: how did it figure out that Alex likes voles?

---

Note: this post is executable by pasting into your favourite interpreter such as here (click on 'create a new program' once you closed the annoying 'Limited Edition!' window).

When copying from here don't forget the top slash-asterisk and the bottom asterisk-slash sign below, plus the full stop after the query likes(alex, X). For extra credit, try likes(Y, voles).  to illustrate Prolog running backwards.
*/

Tuesday, July 28, 2015

A garden in summer

A trip to Wroughton, near Swindon today to visit my mother (with Elaine, pictured below). The hospice is next door to where she's staying and the gardens (and coffee shop) seemed a nice place to visit. A little video follows the picture. The word 'summer' is being used here in a purely calendric way as the mode of dress suggests.

The public garden at the Prospect Hospice, Wroughton



Not much posting here this past week. My excuse? Family visits trash the serenity needed to compose; the Tour was on and we spent hours trying to figure out whether Contador and/or Nibali were suffering post-juice burn-outs; plus not much new was really happening in the world worth commenting on.

Still, all that stuff is behind us now. I was about to install SWI-Prolog and then got diverted with backing up my data (to numerous hard disks and scattered USB drives - you can't have too much security!). Turns out that when your datasets are in the tens of Gigabytes and you need to encrypt (security!) this takes a while - like a day. So that was Monday and I'm finishing off things this afternoon. Prolog tomorrow?

---

OK, we cracked: I put the central heating back on this evening.