Showing posts with label Shadow. Show all posts
Showing posts with label Shadow. Show all posts

Tuesday, March 11, 2025

"If you died today, you would probably go to hell"

 ChatGPT tells me: 

"The Mormon Church sees the Catholic Church as part of an apostate Christianity that emerged after the original church's corruption, though it respects Catholics as sincere believers in Christ. Conversely, the Catholic Church does not recognize Mormonism as Christian due to its differing theology, particularly on the nature of God, but values Mormons' commitment to family and morality, fostering cooperation on shared social issues."

Orson Scott Card is a practising Mormon, a member of the Church of Jesus Christ of Latter-day Saints (LDS Church). In his SF writing he wears his religion lightly, although his strong interest in ethics, values and morality shines through. In the Ender/Shadow series he portrays the recurring character of Sister Carlotta, a Roman Catholic nun who works as an agent of the Interstellar Fleet.

I won't give you the context of the following dialogue between Sister Carlotta and 'Bean' (Julian Delphiki) who is an amoral military veteran of Battle School currently on the run in Latin America: it would be too lengthy.


Amazon link

Instead focus on the theme here: Sister Carlotta speaking to Bean - who selfishly cares only for his own survival, meanwhile despising that very drive as mere mammalian instinct.

“You keep thinking that death is the most terrible thing that can happen to a person, but to God, death just means you're coming home a few moments ahead of schedule. To God, the dreadful outcome of a human life is when that person embraces sin and rejects the joy that God offers. So of all the millions who might die in a war, each individual life is tragic only if it ends in sin."

"So why are you going to such trouble to keep me alive?" asked Bean, thinking he knew the answer.

"You want me to say something that will weaken my case," said Carlotta. "Like telling you that I'm human and so I want to prevent your death right now because I love you. And that's true, I have no children but you're as close as I come to having any, and I would be stricken to the soul if you died at the hands of that twisted boy. But in truth, Julian Delphiki, the reason I work so hard to prevent your death is because, if you died today, you would probably go to hell,”

Shadow of the Hegemon: Book 2 of the Shadow saga, p. 95.

In Shadow of the Hegemon, Bean is approximately 9-10 years old. Despite his young age, he is intellectually far beyond his years, one of the smartest human beings alive due to his genetic modifications, which also contribute to his emotional detachment and existential nihilism.

A well-taken point about life and death, I thought, regardless of your religious proclivities.

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.

Friday, February 10, 2017

So I posted a lot of Lisp here

OK, I know that most of you won't want to hack through pages of Lisp code and pages of Lisp rules. The post which is worth a look at is the example in use.

This shows the strength and weakness of the vanilla Eliza in action.

---

It's tempting, and even conventional, to scoff at Eliza. Peter Norvig says in Chapter 5.4 of his "Paradigms of Artificial Intelligence Programming":
" In the end, it is the technique that is important - not the program. ELIZA has been "explained away" and should rightfully be moved to the curio shelf. Pattern matching in general remains important technique, and we will see it again in subsequent chapters. The notion of a rule-based translator is also important. The problem of understanding English (and other languages) remains an important part of AI. Clearly, the problem of understanding English is not solved by ELIZA."

But the Eliza engine is a very good place to start.

---

What next?



The inadequacies of pseudo-human interlocutors are more forgivable in an animal. I'm going to craft a rule set for our dear, departed pet using the existing Eliza engine: Shadow v. 1.0.

Then it's back to Peter Norvig for his Prolog interpreter in Lisp (chapter 11). This will give me a unification algorithm and a resolution procedure.

My proposed architecture is to use the Eliza engine for input-output and have a Prolog-style knowledge-representation and inference-engine at the back.

In theory, the knowledge-based could be data-filled with rather tedious Q&A - the kind of thing which gives chatbots a bad name - but it's more pleasant for the user to have an initial registration procedure in which the user just tells the system about the domain of interest. For example, details of family and friends. Yes, I'm aware of privacy issues: you ask, in the age of Facebook?

The final area of architecture which I've been thinking about is the topic of conversation. This relates to the information and issues currently being talked about which drive the conversation forward. In Eliza it's basically in the hands of the user: there is no chatbot control mechanism.

But we can do better once we can do inference.

Watch this space.

Tuesday, February 07, 2017

The return of (virtual) Shadow

The late Shadow

Chapter 5 of Peter Norvig's excellent "Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp" is entitled "ELIZA: Dialog with a Machine". I have spent the afternoon studying his pattern-matching code and transferring it into an executable Lisp file.*

An example of an Eliza pattern is this:
'((?* ?P) need (?* ?X))
which picks up text before and after the word 'need'.

If you tell Eliza:
'(Shadow and I need a vacation),
the program will match the input with the pattern above, thus ..
(pat-match '((?* ?P) need (?* ?X)) '(Shadow and I need a vacation))
to create a binding
'((?P SHADOW AND I) (?X A VACATION))       ;   (dotted pair) binding
which can then be passed to the output-generating pattern. And so on.

---

But we're not so much interested in Eliza and that Rogerian psychoanalyst. We want Shadow, our much-missed departed cat (RIP July 1st 2016).

The first step is to change the rules: less talk of vacations and how you're feeling about your parents, more about voles. And being sick on the carpet.

The Eliza architecture was criticised, correctly, for being totally vacuous. The emptiness of the 'conversation' led to bored withdrawal after a period depending upon the narcissism of the user.

We can do better.

To add intelligence to Shadow (such a bright cat!) we have to give him knowledge (in the knowledge lies the power) together with reasoning capability.

Peter Norvig helpfully gives us an equation (chapter 16, p. 548 or thereabouts):
Expert System = Prolog + uncertainty + caching + questions + explanations
The Prolog part powers the knowledge-base capturing Shadow's deep understanding of his own likes, light-hearted escapades and more lethal habits; the Q&A allows for his more sensitive, introspective side.

Peter Norvig has a detailed chapter (11 - Logic Programming) where he explains how to implement Prolog in Lisp (interpreted).

I think this is the way to go with chatbots: combine Eliza-style interaction with a little knowledge-based reasoning to add interest and depth, and to steer the conversation. Perhaps a semantic grammar in there somewhere to help extract meaning from the user's input, though personally, given the ungrammaticality of dialogue, I've always put semantics/pragmatics first.

Anyway, watch this space. It won't be quick .. but we will bring him back!

---

* We spent the morning strolling in the sun around Cheddar reservoir.

Monday, August 08, 2016

Black sludge

The cat is buried in that plot in the back garden previously occupied by the cat toilet.

That was an innovatory concept, due to Clare, which involved digging a shallow trench, filling it with copious spare cat litter, and then dusting it off with a layer of sand mixed with soil.

I was not consulted, but had I been, I would have observed that cat litter is very absorbent, gets heavy when wet .. and in that state is never used by cats.

The cat toilet was never used.

The cat passed on a month or so ago. The sodden cat litter was dug out and placed in a large canvas bag (previously containing a ton of gravel). The cat was placed in the hole, covered with soil and is currently the favoured spot for grass cuttings disposal.

Today, Alex and myself transferred that canvas bag, now filled with evil-smelling black sludge, to the local dump. Getting its sheer dead weight into the car was almost beyond our joint abilities. At the dump we had to shovel the disgusting slurry into the skip.

As I write, the car has been decontaminated, our clothes have been through a heavy-duty cycle and we have both been hosed down.

RIP Shadow.

Thursday, July 21, 2016

Five advantages of a dead cat



  1. The carpets are so much cleaner; hoovering is a doddle.
  2. Doors can be closed at will without consequences.
  3. Less greasy meat-pieces strewn around the floor; fewer flies.
  4. Can go on trips without making arrangements.
  5. Ripped furniture, clothes and skin a thing of the past.

You know, we should have had this idea years ago ...

Monday, July 04, 2016

Shadow: August 2000 - July 1st 2016

#TheCatDied    #ShadowPassedOver

He'd been off-colour for a week or so, spending much of his time sleeping. On his last day he vanished into the garden before returning in the evening to rest in his basket. Clare put the electric heater under his towel there to ease his swollen stomach.

Just after 8.30 pm he stood up, as if he wanted to experience nature one last time. We put him outside the front door and he looked around. Then, with an effort, he walked up the steps and into the hall. There he stood panting, before collapsing onto his side. The unblinking eyes delivered the news, although the odd twitch continued for a while.

He was placed (and buried) on a copy of The Guardian.

It is what he would have wanted.

Shadow, moments after his passing

Saturday, January 09, 2016

Home security: a failure to launch

D-Link home surveillance camera

Here's a surprise: in 2016 we'll be taking a few holidays.

The last time we had an extended break (France/Italy 2014) we left ample dry food for the cat and monitored his feeding habits remotely through the D-Link home security cameras I'd purchased.

The cat survived 14 days human deprivation but appeared to be psychologically-scarred. At the end of the holiday, as Clare entered the front door, it pawed at her feet emitting piteous screams of relief (or that was how it was interpreted).

As a consequence, Clare has engaged a young lady named Susie to pop around daily during our forthcoming absence to feed/mentor/soothe the animal; Susie met with us at home this afternoon.

I draw a different lesson as regards our prospective holidays. My thoughts rather tend to the optimal placement of security cameras so I can check the house (and possibly the pet) during our absence. This morning, I brought one of the cameras into the living room, thinking to attach it to the router next to the TV. Sadly, after a few minutes, Clare caught sight of the wiring.

"What's all this?" she exclaimed, the frown of suspicion on her face.

Difficult to explain one's security deployment concepts when the demerits of surveillance of the cat-visitor are rather forcefully being brought to one's attention. Our little discussion - rather one way in truth - was brought to an end by Clare confiscating and then hiding the offending camera, power supply and ethernet cable.

I got it back this afternoon by grovelling, but apparently European human rights best practice will be applied in future: no surveillance!

---

Technical note: the cameras I have do not record. They provide live streaming when I open the smartphone app ... .

Yeah, like that would work!

Thursday, September 10, 2015

Two Dialogues Concerning the Cat

You may wonder why I have inflicted on you something so bland and indeed so tedious as the conversations below. I have several responses:
  1. This is exactly what talking to a cat would be like.
  2. These conversations are typical of general f/b and twitter chat.
  3. Few, if any AI/chatbot system today could chat like this.
  4. There are a number of technical issues (for AI) which I mention at the end.
  5. ... and finally, the cat asked me to.


Designing the simulation of our cat, Shadow, requires test data. So today, Clare conducted two interviews, or dialogues, with the cat which will be analysed in computational terms in a future post. The idea is that Virtual Shadow should be able to participate in conversations like this.
Dialogue 1

1. Clare: Hi Puss.
    Cat: Hi Clare.
2. Clare: You been asleep?
    Cat: I sleep all day.
3. Clare: Do you prowl all night?
    Cat: I like to meet with my friends.
4. Clare: How many?
    Cat: There’s the big cat who chases me.
5. Clare: Go on.
    Cat: Then there’s the badger, who chases me.
6. Clare: And ...
    Cat: And then there are lots of voles.
7. Clare: I like voles.
    Cat: Tasty, aren’t they.
8. Clare: I also like badgers.
    Cat: Yes, they seem to like me, too.
9. Clare: Do you eat with the badgers?
    Cat: As far away as possible.
10. Clare: Do you play chase with the badgers?
      Cat: Less about the badgers, please!
11. Clare: Do you like living here?
      Cat: Could be better.
12. Clare: How?
      Cat: A fridge I could open.
13. Clare: Would you like a friend cat in the house?
      Cat: I wouldn’t mind a minion!
14. Clare: See ya!
      Cat: Miaow!

Dialogue 2

1. Clare: Hi Puss.
    Cat: Miaow!
2. Clare: I’m really sick of Nigel today!
    Cat: Just today, then?
3. Clare: Yes, just today.
    Cat: Perhaps he’ll clean it up.
4. Clare: You know him very well!
    Cat: How has he irritated you?
5. Clare: He’s had his nose in his computer for six hours.
    Cat: And what were you doing?
6. Clare: Talking.
    Cat: To yourself?
7. Clare: To Nigel!
    Cat: You mean his tablet! Time to confiscate it!
8. Clare: Perhaps you could walk on the screen?
    Cat: What’s for dinner tonight?
9. Clare: For me or for you?
    Cat: I’m a cat: think about it.
10. Clare: For you – Whiskers chicken bits.
      Cat: I like variety.
11. Clare: You say you don’t get variety?
      Cat: Chicken, chicken, chicken!
12. Clare: Spoilt!
      Cat: I’m a cat.
13. Clare: Most cats have dried food, you little brat.
      Cat: Not so little, these days!
14. Clare: What about brain food? What would you like?
      Cat: Brains, minced, should do it.
15. Clare: Sorry, no can do.
      Cat: Miaow!
You may be surprised at how many difficult issues of vocabulary, grammar, parsing, reference, topic management and knowledge representation are raised by these apparently simple dialogues.

Friday, September 04, 2015

Clare vs. 'the Cat'

This afternoon I programmed my very first simulation of the family pet, Shadow. In this simplistic iteration, the cat plays a game with the user. The idea is to stack 20 cans of cat food. The user and the cat take turns to stack 1, 2 or three cans at a time: the first to 20 wins.

Here is a transcript of the start of play. The cat's moves are between asterisks ***; the user's moves are signposted with -->.

Miaow, my name is Shadow. The game is to stack 20 cans of cat food. You can choose 1 or 2 or 3 cans at each turn. Me too! First to 20 wins.

Do you want to play first? type y for yes, n for no followed by return.

So, do you want to play first (y/n and press return)? n

*** My move is 2 cans. Total number of cans = 2 ***

enter your number 1, 2 or 3 |: 2

--> You entered 2 cans. Total number of cans = 4

*** My move is 1 cans. Total number of cans = 5 ***

enter your number - 1, 2 or 3: |:  ...

And here is a video of my guinea pig, Clare, playing the cat. What was it that Kipling said about winning and losing? (You may have to double-click on video to get full screen).



The game was an exercise from 'The Art of Prolog' and it took me a while to develop the game-play to program. Here is the folder containing the Prolog program by the way: you may use it to infer the winning strategy.

Friday, May 16, 2014

Cat up to his old tricks

Dead and drowned
Adrian threw the corpse out of the kitchen last night; it ended up in the mop bucket. Clare tipped it out this afternoon. A young life tragically cut short.

Thursday, September 29, 2011

A Breakfast Vole

I was eating breakfast in the kitchen at half past eight this morning. It was very quiet - Adrian had long since left for work at the cheese factory and Clare was still asleep upstairs, as was the cat in the back bedroom. My eye was caught by a small furry ball ambling nonchalantly into the kitchen (below).


For a moment our eyes locked as I imagined what a tiring night the vole must have had being chased around the house and juggled by the cat. I slowly got up and unlocked the kitchen and patio doors to let the poor thing escape. When I returned to my cereal the vole had hidden somewhere.

Five spoonfuls later my curiosity took control. I wandered over to the computer equipment to see if I could find the poor thing. There it was, snuggled up on top of a warm power supply block. I poked it - it wouldn't move. So I leaned down and picked it up; it still didn't move a muscle. The vole was deposited on the grass outside, and was last seen scuttling into the bushes.


You may infer a certain degree of non-verisimilitude in the above images. To be honest, I was a little too occupied to play around with the camera, so this was what I believe is called in CSI-speak a 'reconstruction'?

Friday, May 13, 2011

Why we have an avian lodger problem

Clare has long been mystified as to why birds haven't colonised her bird-box in the back garden. She is convinced that despite his longtime vole habit, the cat is temperamentally uninterested in birds. This afternoon I caught the following sequence - what do you think?

Yes, I do predate birds

Any little ones home?

On my way down - nobody noticed, right?

Friday, February 16, 2007