Showing posts with label The Mote in God's Eye. Show all posts
Showing posts with label The Mote in God's Eye. Show all posts

Thursday, March 16, 2017

My theorem-prover is (basically) working

My resolution theorem prover is working: find the documentation and code here.

My initial, rather simple test data concerns Sally Fowler's situation aboard the battleship MacArthur ('The Mote in God's Eye').



Who does Sally like: ←  (LIKES SALLY ?WHO)

Well, here are the Prolog-style facts.
 (LIKES ROD HORVATH) ←
 (LIKES SALLY RENNER) ←
 (LIKES SALLY ROD) ←
 (LIKES HARDY RENNER) ←
 (LIKES HARDY ROD) ←
 (AMUSING HARDY) ←
 (LIKES HORVATH MOTIES) ←
 (LIKES SALLY ?X) ← (LIKES ?X MOTIES)
 (LIKES ROD ?X) ← (LIKES ?X RENNER) (LIKES ?X ROD)
 (LIKES ?X ?Y) ← (AMUSING ?Y) (LIKES ROD ?Y)
 (LIKES ?X ?X) ←
Based on the above, the theorem-prover offers the following five responses. I doubt you are overwhelmed ... but then, test data is designed to be easy to understand.
1, Because everyone likes themselves, Sally likes Sally.

2. Because it's mentioned Sally likes Rod, she does.

3. Because it's mentioned Sally likes Renner, she does.

4. Sally likes those who like Moties. Moties like Moties because everyone likes themselves. So Sally likes Moties.

5. Sally likes people who like Moties. Horvath like Moties.  So Sally likes Horvath.
More precisely, after a little editing (inserted line-breaks), this is what was printed out.
((((<- ((LIKES SALLY SALLY))))
  (((13 NIL NIL) ((LIKES ?X ?X) <-))
   ((14 NIL NIL) (<- ((LIKES SALLY ?WHO))))
   ((19 14 13) +EMPTY-CLAUSE+)))

 (((<- ((LIKES SALLY ROD))))
  (((5 NIL NIL) ((LIKES SALLY ROD) <-))
   ((14 NIL NIL) (<- ((LIKES SALLY ?WHO))))
   ((16 14 5) +EMPTY-CLAUSE+)))

 (((<- ((LIKES SALLY RENNER))))
  (((4 NIL NIL) ((LIKES SALLY RENNER) <-))
   ((14 NIL NIL) (<- ((LIKES SALLY ?WHO))))
   ((15 14 4) +EMPTY-CLAUSE+)))

 (((<- ((LIKES SALLY MOTIES))))
  (((13 NIL NIL) ((LIKES ?X ?X) <-))
   ((10 NIL NIL) ((LIKES SALLY ?X) <- ((LIKES ?X MOTIES))))
   ((14 NIL NIL) (<- ((LIKES SALLY ?WHO))))
   ((17 14 10) (<- ((LIKES ?WHO MOTIES))))
   ((24 17 13) +EMPTY-CLAUSE+)))

 (((<- ((LIKES SALLY HORVATH))))
  (((9 NIL NIL) ((LIKES HORVATH MOTIES) <-))
   ((10 NIL NIL) ((LIKES SALLY ?X) <- ((LIKES ?X MOTIES))))
   ((14 NIL NIL) (<- ((LIKES SALLY ?WHO))))
   ((17 14 10) (<- ((LIKES ?WHO MOTIES))))
   ((20 17 9) +EMPTY-CLAUSE+)))

Figure 1
---

Q&A.

1. Isn't this just Prolog?

Prolog is encountered as a black box. You provide a program and a query (as above) and you get back bindings, like this:
?- likes(sally, W).

W = sally;
W = rod;
... and so on

If you want proofs, to add the 'occurs check' or to change the order in which resolution steps are tried (the search strategy) - well tough: all those things are both fixed and opaque in Prolog. To make them explicit for modification, you have to write an explicit theorem-prover in Prolog (which can of course be done).

2. You are using Horn clauses?

Yes. I initially thought to implement a general clausal prover, but Horn clauses make the resolution step particularly simple (just one positive literal to match) and you lose neither generality nor expressive power. But since everything in the code is both modular and explicit, it would be easy to extend the program.

3. The style is functional?

Yes. Resolution theorem provers on the Internet are heavily optimised with clever, imperative algorithms and direct access data structures such as hash tables. This makes the code efficient but obscure - very hard to understand.

I didn't want to do that. This is a tool-kit and I'm not trying to create thousands of logical inferences per second. My intended application area (simple inference over an ever-changing knowledge-base for a chatbot) never requires massive inferential chains so clarity and easy modifiability was my objective.

4. What was hard?

The program is architected at three levels.

(a) Unification

This is basically already quite modular and straightforward. I re-used Peter Norvig's code.

(b) Resolution

Binary resolution itself - specially with Horn clauses - is a straightforward procedure - as you will see when I publish the code. There are some subtleties with bindings and substitutions, but once you realise that resolution is fundamentally a local operation it's not too difficult.

(c) Control and proof construction

The process of creating new goals and resolving them with the axioms is somewhat complex although again, sticking with Horn clauses makes it a lot easier: just think of a naive Prolog execution model.

However, if you want to return proofs, you need to number the axioms and number-and-archive goals as you process them, capturing the resulting tree of inferences. At the end, for each empty-clause = successful proof, you need to trace that index-tree backwards to recover the proof steps. That's what created figure 1 above. I found it a bit intricate.

5. What's next?

In theory you can do anything with a theorem-prover (Prolog being the existence proof) but it's not necessarily the best architecture. For a planner, where state changes are part of the problem definition, I need to adapt the tool-kit to a design centred around actions with pre- and post-condition in the context of a goal-state and an updating world-state. Such a dynamic model can be used both for actions in a (virtual) world and conversation planning via speech acts.

The theorem-prover remains optimal as a separate module, managing the crystallized knowledge base using inference to draw conclusions - for example to drive questions and answers.

I'm thinking of using the already-programmed Eliza front-end as a robust conversational interface. Doesn't matter if it's bluffing some of the time if it can use learning, inference and planning often enough.

Onwards to the GOFAI smart chatbot ...

---

Here is the documentation and code.

Saturday, March 04, 2017

And perhaps the horse will learn to sing

The empire is a monarchy run by a hereditary aristocracy with traditional gender roles. It is in the throes of civil war, fighting to re-integrate secessionists and 'outies'. And then it discovers the moties, seemingly pleasant and civilised - and keen to expand into the empire's territory.

Shouldn't we welcome these charming immigrants, with so much potential for diversity, cultural enrichment and trade?

---

I read aloud (and recorded) "The Mote in God's Eye" over thirty eight evenings in sessions ranging from 30 minutes to more than an hour.

Clare often falls asleep, and you may hear her snoring. Sometimes we're interrupted by phone calls and people at the door. The clock chimes tend to stop me in my tracks. Sometimes I get quite emotional. I can't do Scottish accents.

Quality stuff then.

The format is .m4a and the app I used to record and playback is Easy Voice Recorder Pro.

You can listen to the chapters here. Ideal for those long car journeys or at bedtime.

---

Trigger warning: everything about this book is liable to offend prevailing mores.

Jerry Pournelle quotes (including this post's title).

Thursday, February 23, 2017

Liberals meet the Moties: high-K vs. high-r

My current after-dinner read to Clare is that wonderful old (1974) classic, "The Mote in God's Eye" by Larry Niven and Jerry Pournelle.

Amazon Link

Here's a brief plot summary (it's surely OK now for spoilers).
"An alien spaceship using a light sail to fly at speeds below the speed of light appears in the human system of New Caledonia. The ship has been traveling for at least 135 years.

The Viceroy ruling the New Caledonia system, the Emperor's appointed representative, determines that a mission of two ships will be sent to the alien system that sent out the pod. Both species are wary, protective, and secretive.

Communication is established; understanding, however, remains more distant. One of the warships is invaded by a lower alien species and must be destroyed. Three Midshipmen end up alone on the planet, uncovering the aliens' desperate secrets of uncontrollable population explosion and giving their lives to protect Empire secrets.

Three aliens are sent to accompany the remaining human ship and crew back to New Caledonia as ambassadors."
The Moties are an example of an r-selected species which, via their technological civilization, solve the high death-rate problem - at least until their numbers hit ultimate carrying capacity.

From Wikipedia:
"As the name implies, r-selected species are those that place an emphasis on a high growth rate, and, typically exploit less-crowded ecological niches, and produce many offspring, each of which has a relatively low probability of surviving to adulthood (i.e., high r, low K).

In unstable or unpredictable environments, r-selection predominates due to the ability to reproduce quickly. There is little advantage in adaptations that permit successful competition with other organisms, because the environment is likely to change again. Among the traits that are thought to characterize r-selection are high fecundity, small body size, early maturity onset, short generation time, and the ability to disperse offspring widely.

By contrast, K-selected species display traits associated with living at densities close to carrying capacity, and typically are strong competitors in such crowded niches, investing more heavily in fewer offspring, each of which has a relatively high probability of surviving to adulthood (i.e., low r, high K). ...

In stable or predictable environments, K-selection predominates as the ability to compete successfully for limited resources is crucial and populations of K-selected organisms typically are very constant in number and close to the maximum that the environment can bear (unlike r-selected populations, where population sizes can change much more rapidly).

Traits that are thought to be characteristic of K-selection include large body size, long life expectancy, and the production of fewer offspring, which often require extensive parental care until they mature. ... Organisms with K-selected traits include large organisms such as elephants, humans and whales, but also smaller, long-lived organisms such as Arctic terns. ...

The r/K dichotomy can be re-expressed as a continuous spectrum using the economic concept of discounted future returns, with r-selection corresponding to large discount rates and K-selection corresponding to small discount rates."

The novel revolves around the debate between liberals and conservatives as to how to deal with the Moties (who pretend to be high-K liberals). It's an eerie book to read, weirdly analogous to contemporary debates in the media. It's been suggested on a regular basis that it would make a stupendous film, but until Hollywood learns to love The Donald, I fear their immune system makes that prospect stillborn.

---

Advanced capitalist countries have been carrying out an interesting experiment with effective birth control over the last fifty years or so. A possible result has been a decline in fertility leading to projected population collapses: Japan is often mentioned as a trend-setter.

Birth control is a central theme in the novel too. The treatment is very game-theoretic: over their history, some Motie continents under strong political leadership did in fact practice population control. They were simply outbred and then conquered by their more numerous competitors.

Thursday, January 26, 2017

Diary: books + Clare's health

Not many posts for the next few days as we have a visitor: my 'study' reverts to its ur-status as bedroom.

I ordered Sean Carroll's book (which should be arriving tomorrow or Saturday) ..


.. on account that one reviewer (3 stars) complained it was 'too hard'. I'll try to let you know.

---

Strange how hard it is to predict another's taste in books. I really appreciated Scott Bakker's "The Disciple of the Dog" but all that inline philosophy slowed it down way too much for Clare.

It's been replaced - amazingly - by the famous "The Mote in God's Eye" which she is lapping up as I read it to her.



We haven't even reached the gripping alien lightsail contact event yet; still in the early chapters of Niven's and Pournelle's backstory building, usually condemned as 'boring'.

---

I remain a fan of Scott Bakker and have purchased (Kindle) this: (start of a mega-epic) ..



.. which seems awfully complicated. I have dipped my toe in.

---

My third ordered volume is "The Genome Factor: What the Social Genomics Revolution Reveals About Ourselves, Our History, and the Future" by Dalton Conley and Jason Fletcher.



I'm hyper-wary of the fluffy-bunny pleasantries of the Standard Social Science Model, but it seems well-regarded so I'm taking the risk. Should be out some time in late February.

---

Do you hear that hacking cough from the bedroom? Clare is much recovered today but the sub-zero windchill of our lunchtime shopping trip to Waitrose has sapped her energy .. and she has retired to bed. Still, direction of progress is positive.

---

Well, enough time here. I think it's time to re-acquaint myself with J. A Robinson's exemplary treatment of unification with those substitution subtleties ... .