Saturday, February 25, 2017

"The Last Days of New Paris" - China Miéville

Amazon link

This is a novella which rewards your imagination, creativity, and openness to experience. There is a plot, after a fashion, though as usual with this author, it's the journey not the destination. We soon learn of two timelines in the alternate reality wherein resides 'New Paris'.

Vichy Marseilles in 1941 sees a gathering of Surrealists fighting fascism through their works. The atmosphere positively fizzes with their dangerous, subversive 'art of the unconscious'. To hand is an American scientist (and occultist), Jack Parsons, who will bottle this energy in a 'battery' of his own devising to further his own plans to fight fascism. Unfortunately, the thoroughly-charged battery is stolen and ends up in New Paris where it detonates: the S-bomb.

In New Paris 1950, the city is blockaded as Surrealist manifestations stalk the arrondissements aided by the Surrealist underground, La Main à plume. Trapped Nazis and Gestapo agents contract with the denizens of Hell to combat them. The Germans have a top-secret plan: Fall Rot. But what is it? Thibaut, a leader of La Main à plume, has to find out.

The afterword purports to document a meeting between an aged Thibaut and Mr Miéville in a London hotel where the story is recounted in frenzied haste. At the end you will find detailed notes on most of the surrealist works of art which 'manifested themselves' in New Paris. Of particular note is the Surrealist publication/manifesto, "Le Surréalisme au service de la révolution", seeming to serve as a blueprint for the S-bomb.

You may spend most of the novella wondering where all this is going. It does, however, resolve; there is an overarching theme. I might wish it had been a little more subtle than the banality of evil. However, Miéville can make even Manicheanism look chic.

Friday, February 24, 2017

Something to conjure with

This post serves as an ideal introduction for my review of "The Last Days of New Paris" by China Miéville.

The Ritual's first outing is today, by the way. If you're keen you'd better rush to hit the shops for that orange candle stub. I somehow feel the baby carrot just won't cut it.

From here via Charles Stross.


A Spell to Bind Donald Trump and All Those Who Abet Him (version 2.0)

To be performed at midnight on every waning crescent moon until he is removed from office. The first ritual takes place Friday evening, February 24th, at the stroke of midnight. This binding spell is open source, and may be modified to fit your preferred spiritual practice or magical system — the critical elements are the simultaneity of the working (midnight, EST—DC, Mar-a-Lago, and Trump Tower NYC time) and the mass energy of participants. ...

Some lodges/covens are doing a variation of this as a group working, while a number of solitary practitioners are planning to connect and live-stream via Facebook, Twitter, and other social media.

Components
  • Unflattering photo of Trump (small)
  • Tower tarot card (from any deck)
  • Tiny stub of an orange candle (cheap via Amazon)
  • Pin or small nail (to inscribe candle)
  • White candle (any size), representing the element of Fire
  • Small bowl of water, representing elemental Water
  • Small bowl of salt, representing elemental Earth
  • Feather (any), representing the element of Air
  • Matches or lighter
  • Ashtray or dish of sand

Optional
  • Piece of pyrite (fool’s gold)
  • Sulfur
  • Black thread (for traditional binding variant)
  • Baby carrot (as substitute for orange candle stub)

Preparation
  • Write “Donald J. Trump” on the orange candle stub with a pin or nail
  • Arrange other items in a pleasing circle in front of you
  • Lean the Tower card against something so that it’s standing up (vertically)
  • Say a prayer for protection and invoke blessing from your preferred spirit or deity. Reading the 23rd Psalm aloud is common in Hoodoo/Conjure/Rootwork traditions. Experienced magicians may perform an appropriate banishing ritual.

RITUAL (v. 2.1)

(Light white candle)

Hear me, oh spirits
Of Water, Earth, Fire, and Air
Heavenly hosts
Demons of the infernal realms
And spirits of the ancestors

(Light inscribed orange candle stub)

I call upon you
To bind
Donald J. Trump
So that he may fail utterly
That he may do no harm
To any human soul
Nor any tree
Animal
Rock
Stream
or Sea

Bind him so that he shall not break our polity
Usurp our liberty
Or fill our minds with hate, confusion, fear, or despair
And bind, too,
All those who enable his wickedness
And those whose mouths speak his poisonous lies

I beseech thee, spirits, bind all of them
As with chains of iron
Bind their malicious tongues
Strike down their towers of vanity

(Invert Tower tarot card)

I beseech thee in my name

(Say your full name)

In the name of all who walk
Crawl, swim, or fly
Of all the trees, the forests,
Streams, deserts,
Rivers and seas
In the name of Justice
And Liberty
And Love
And Equality
And Peace

Bind them in chains
Bind their tongues
Bind their works
Bind their wickedness

(Light the small photo of Trump from the flame of the orange candle stub and hold carefully above the ashtray)

(Speak the following loudly and with increasing passion as the photo burns to ashes)

So mote it be!
So mote it be!
So mote it be!

(Blow out orange candle, visualizing Trump blowing apart into dust or ash)

(Pinch or snuff out the white candle, ending the ritual)

In a spirit of ecumenicalism or something, I imagine that you could replace Trump in this ritual with any other celebrity you have a problem with. Bono, .. or Shami Chakrabarti, for example.

Domestic servants: a modest proposal

I have fond memories of our Roomba, spinning mindlessly around our previous house, unable to empty itself and needing help to escape from under the bed. Didn't work in our current home - carpets too thick.

We're as far as ever from artificial general intelligence (AGI). But why try to solve a thousand problems of mental and physical agility when biology has already done the work for us over 400 million years?

"Wait!", I hear you say. Domestic servitude died out with the Edwardians. Besides, the idea of all those servants observing and judging your every move. It's so creepy. No privacy. It's like your home isn't your own.

But that was before CRISPR ...
"She paused. "Just out of curiosity, what's planned fo' the serfs along these lines?"

He relaxed. "Oh, much less. That was debated at the highest levels of authority, an' they decided to do very little beyond selectin' within the normal human range.

"Same sort of cleanup on things like hereditary diseases. Average height about 50 millimeters lower than ours. No IQs below 90, which'll bring the average up to 110. No improvements or increase in lifespan so they'll be closer to the original norm than the Race.

"Some selection within the personality spectrum: toward gentle, emotional, nonaggressive types. About what you'd expect."
If they like serving you, can it really be slavery?

---



More about the Draka.

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.

Wednesday, February 22, 2017

Perhaps no-one understands Maxwell's equations

"Microsoft CEO Satya Nadella spoke at a public event in India on Monday ...

"The first time I put on a HoloLens was to see something Cleveland Clinic [a non-profit academic medical center] had built for medical innovation... As an electrical engineer who never understood Maxwell's equations, I thought if I had a HoloLens, I would have been a better electrical engineer. Overall I feel that augmented reality is perhaps the ultimate computer," he said.
From here.

Actually, the article was entitled, "Microsoft CEO says artificial intelligence is the 'ultimate breakthrough'", but I was struck by his confession of ignorance about the foundational theory of classical electromagnetism.



Maxwell's equations

This looks bad, of course. But let's cut the CEO some slack: Maxwell's equations are notoriously unintuitive, as I observed in this post.

You can use the equations, solving them for particular physical configurations. But what picture do they give of the nature of the field(s) themselves?

What are we to make of the fact that a stationary observer of a motionless charged ball sees a static spherical electric field E, while an observer moving past that same ball sees electric and magnetic fields (E' and B')?

The magnetic field is a relativistic effect.

The charge is at rest in frame F, so this observer notes a static electric field. An observer in another frame F′ moves with velocity v relative to F, and notices the charge to move with velocity −v with an altered electric field E due to length contraction and a magnetic field B due to the motion of the charge. (Wikipedia).

That's implicit in Maxwell's equations, but don't tell me it's obvious. For that, you need to write the equations in a manifestly covariant form, but they don't teach you that in undergraduate electrical engineering.

---

Oh, and he's surely right about augmented reality being the main deliverable from the current state of the art in artificial neural net technologies. The Holy Grail of AGI will be a product of mastering situated social cognition, a post for another day (but see here).

Tuesday, February 21, 2017

"From Eternity to Here" - Sean Carroll

Amazon Link

Just finished Sean Carroll's 2011 book, which - after an exhaustive exploration of all other options - locates the origin of 'the arrow of time' in the quantum-fluctuation emergence of super-low-entropy 'baby universes' from a preceding high-entropy de Sitter universe.

Yep, that would be the baby universe in which I'm sitting writing this post.

This may seem extravagant, to explain why eggs produce omelettes but not the reverse, but he refutes all the simpler explanations.

It presently seems unclear, however, whether a de Sitter universe could even make baby universes, absent a better theory of quantum gravity.

Carroll's latest thinking tends in a different direction, suggesting that framing the issue within the spacetime realm may itself be a mistake; the true nature of reality may be Hilbert space with Schrödinger equation dynamics. Spacetime, with its arrow of time, may be emergent.

Strange that the weirdest ideas of modern physics - the MWI, emergent spacetime - seem to be the most plausible.

This is a fine book, and an excellent introduction for the smart non-physicist to general relativity, quantum theory (QM/QFT) and cosmology.

Monday, February 20, 2017

The deep state *is* the state

Much excitement in the States (but also in Brexit Britain) about elements of the state apparatus actively working to undermine the policies of an 'insurgent' government.

The governments in question are of the right, not the extreme left, but the founders of Marxism were clear that a truly revolutionary government cannot just take over the 'controls' of a 'neutral' state apparatus. They will be thwarted at every turn.

This is, of course, true of all bureaucracies. Successful 'turnaround' CEOs bring their own posse of senior managers - and waste no time clearing out the old regime. If they don't, their mission is toast. The political right, in order to to secure their victory, will have to purge the state of their enemies and repopulate it with supporters in their own ideological image.

Marxists, however, are seldom called out on what they think should replace the bourgeois state. Lenin and Trotsky, following the model of the Paris Commune, thought that the mobilised masses, organised in soviets (councils), would constitute a non-bureaucratic socialist state - a social formation not separate from broader society.

Marx himself never wrote much about it.

Yet the state is neither a contingent formation nor just 'bodies of armed men' safeguarding existing property relations. The state has an enormous, and under-analysed, role in social-coordination.

---

Turn now to the economy. All Marxists agree that their post-capitalist economic model will replace private decision-making about the allocation of resources with 'consciously democratic', centrally-planned directives.

Given the complex and highly-technical nature of policy-making and implementation, both as regards the state and the putative planned-economy, this is not going to something managed by the masses through their councils. Nor is it going to be that old favourite, the mere 'administration of things, not of people'.

The PDF version is here

It's hard to resist the conclusion that - until the AIs take over (and where does that leave us?) - the post-capitalist state will continue to be large, bureaucratic and unresponsive. Much like the bourgeois state.

History tends to support that view.

I would guess that Marxists would not agree, but for people proposing a radical makeover of society's fundamentals, they seem remarkably coy about their proposed replacement model.

Such studied casualness wouldn't work in engineering.

Why does the far left get a free pass on something of such fundamental importance?

Sunday, February 19, 2017

People are boring - so what chance chatbots?




The BBC's Dave Lee writes:
"It's been nearly a year since Microsoft's Satya Nadella proclaimed "bots are the new apps".

"Yet despite the promise of a revolution in how we interact with services and companies online, progress has been utterly miserable - the vast majority of chatbots are gimmicky, pointless or just flat out broken. ...

The CNN news chatbot, for example, is worse at giving you the news than any of CNN’s other products. ...

"Google's AI-powered messaging app Allo, since being launched to much fanfare last year, has failed to make even a minor dent in a messaging app market dominated by Whatsapp and Facebook Messenger.

"And that's because there's no compelling reason to bother with Allo. None of its features - like asking it for directions - provide enough of a benefit beyond what you'd get from just tapping in your request the "old fashioned" way. Users have an incredibly short fuse for chatbots not working exactly as we expect."
---

We have a special name for those few people who we (mostly) don't find boring.

Friends.

We don't much enjoy extended interactions with random folk. People who, nevertheless:
  • have been completely socialised into our culture for decades, 
  • come with detailed background knowledge of the world,
  • are endowed with common sense and full conversational abilities.
So why did the AI companies think we'd enjoy interacting with chatbots, which are cognitively impoverished in every conceivable way?

It's a good question and I'm not sure of the answer.
- Were they over-impressed by their mighty artificial neural nets? But they're only fantastic recognisers and classifiers, a far cry from artificial general intelligences (AGI).

- Did they think that we're all keen to have conversational, hands-free interaction with our pocket devices? In fact that's socially way too intrusive most of the time, plus we're talking to conversational muppets.

- Was there a belief that in some narrow, vertical and tightly-constrained domains there might be a niche for a conversational interface? There's almost certainly something to that - but we don't yet know what.
My own feeling is that the successful mass consumer chatbot can be nothing less than a truly effective virtual friend. To that end it will have to posses AGI and be malleable to your own personality and 'friend-preferences'.

We'll have starships before we have that; I haven't seen the first clue we're on that road.

---

All of the above presupposes peer-relationships, typically with kids or adults. Those conversations - most of the time! - exhibit an irreducible core of rational and relevant 'aboutness'.

So hard to replicate for an artefact.

But there are natural agents around without much cognitive competence: babies, small children and pets. The bond here is emotional .. and so is the interaction.

So if you're in the business of designing chatbots which could conceivably bond with your customers, you might want to take note .. .*

---

* In the old days, we called them 'dolls', and they came without batteries.

Saturday, February 18, 2017

Diary: my day with a Prolog interpreter in Lisp

The subject: implementing a Prolog interpreter in Common Lisp, using an excellent - if rather old-fashioned - textbook as my guide. I had copied-and-pasted the code across (it never quite works first time) and was debating this morning: finally get Peter Norvig's code to run, or strike out in my own direction?

There's a lot in Chapter 11 of "Paradigms of Artificial Intelligence programming" to be wary of:
  • For efficiency reasons he stores the clauses on clause-head-predicate property lists
  • He uses destructive operations such as nconc
  • The resolution inference step and depth-first control strategy are interwoven.
I'd prefer to keep the clause database as an explicit object to be transformed and analysed throughout the proof. I'd also like to modularise the 'which clauses to try to resolve next' strategy, trying different things such as unit preference, set-of-support, hyperresolution. And it would be good to extract a proof tree, not just the final question-answering bindings.

All these things demand a rewrite.

But I was glad I persevered, because Peter Norvig's code finally came good this afternoon and I was able to successfully run it on a serious logic puzzle - the Zebra problem.

Where it ran remarkably quickly - forty times faster than in Dr Norvig's textbook-writing days. I was reminded of AI programming back in the late 1980s, when everything was slow and hard.

I imagined him developing his code on some ancient VAX 11/780 (as I used to do).

A simple Prolog interpreter in Lisp

I happen to think that the code for 'prove' et al below is extremely opaque. You will search in vain for any clear modularisation into:
  • Resolution operation
  • Depth-first control strategy
  • Bindings and solution management.
For conceptual, pedagogical and tool-creation reasons, a rational reconstruction is necessary. When this is completed, I will post a link to the rewritten - and hopefully clearer code - here.

; ---- Lisp code starts here ---
;
;;;  Prolog in Lisp:  February 14th 2017 - February 18th 2017
;;;
;;;  From Peter Norvig's book: Chapter 11
;;; "Paradigms of Artificial Intelligence Programming"
;;;
;;; Unification, Prolog, Resolution, inference control strategies
;;;
;;; Posted:
; http://interweave-consulting.blogspot.co.uk/2017/02/a-simple-prolog-interpreter-in-lisp.html
;;;
;;;  Reminder: (how to load and access files)
;;;
; (load  "C:\\Users\\HP Owner\\Google Drive\\Lisp\\Prog-Prolog\\Prolog-in-Lisp.lisp")

;;;
;;; --- Unification ---
;;;
;;;  Bindings: a list of dotted pairs created by unify

(defconstant +fail+ nil "Indicates pat-match failure.")

(defconstant +no-bindings+ '((t . t))
"Indicates pat-match success but with no variables.")

(defun variable-p (x)    ; Symbol -> Bool
  "Is x a variable, a symbol beginning with '?'"
  (and (symbolp x) (equal (char (symbol-name x) 0) #\? )))

(defun get-binding (var bindings)
  "Find a (variable . value) pair in a binding list."
  (assoc var bindings))

(defun binding-val (binding)
  "Get the value part of a single binding."
  (cdr binding))

(defun lookup (var bindings)
  "Get the value part (for var) from a binding list."
  (binding-val (get-binding var bindings) ))

(defun extend-bindings (var val bindings)
  "Add a (var . value) pair to a binding list, remove (t . t)"
  (cons (cons var val) (if (equal bindings +no-bindings+) nil bindings)))

(defparameter *occurs-check* t "Should we do the occurs check? If yes, t")

(defun unify (x y &optional (bindings +no-bindings+))   ; -> Bindings
  "See if x and y match with given bindings"
  (cond ((eq bindings +fail+) +fail+)
        ((eql x y) bindings)
        ((variable-p x) (unify-variable x y bindings))
        ((variable-p y) (unify-variable y x bindings))
        ((and (consp x) (consp y))
         (unify (rest x) (rest y)
                (unify (first x) (first y) bindings) ) )
        (t +fail+) ) )

(defun unify-variable (var x bindings)              ; -> Bindings
  "Unify var with x, using (and maybe extending) bindings"
  (cond ((get-binding var bindings)
                  (unify (lookup var bindings) x bindings))
            ((and (variable-p x) (get-binding x bindings))
                  (unify var (lookup x bindings) bindings))
              ((and *occurs-check* (occurs-check var x bindings))
                  +fail+)
            (t (extend-bindings var x bindings))))

(defun occurs-check (var x bindings)             ; -> Bool
  "Does var occur anywhere 'inside x'? Returns t if it does (so fail)"
  (cond ((eq var x) t)
        ((and (variable-p x) (get-binding x bindings))
         (occurs-check var (lookup x bindings) bindings))
        ((consp x) (or (occurs-check var (first x) bindings)
                       (occurs-check var (rest x) bindings)))
        (t nil)))


(defun unifier (x y )
  "Return something that unifies with both x and y (or +fail+)"
  (subst-bindings (unify x y) x ) )


(defun subst-bindings (bindings x)   ; Bindings x Term -> Term
  "Substitute the value of variables in bindings into x,
taking recursively bound variables into account"
  (cond ((eql bindings +fail+) +fail+ )
        ((eql bindings +no-bindings+) x)
        ((and (variable-p x) (get-binding x bindings))
              (subst-bindings bindings (lookup x bindings) ))
        ((atom x) x)
        ( t (cons (subst-bindings bindings (car x))
                        (subst-bindings bindings (cdr x )) ) ) ) )


;;; -------------------------- Theorem Prover -----------------
;;;
;;; Clauses are represented as (head . body) cons cells: example clauses
;;;
;;;  ( (member ?item (?item . rest))) )                         ; fact
;;;  ( (member ?item (?x . ?rest)) . ((member ?item ?rest)))    ; rule


(defun clause-head (clause) (first clause))     ; Clause -> Literal

(defun clause-body (clause) (rest clause))      ; Clause -> Literal-list

;; Clauses are stored on the predicate's plist

(defun get-clauses (pred) (get pred 'clauses)) ; symbol -> Clause-list

(defun predicate (literal) (first literal))    ; Literal -> Symbol (predicate)

(defvar *db-predicates* nil
  "A list of all predicates stored in the database")

(defun replace-?-vars (exp)
  "Replace any ? within exp with a var of the form ?123"
  (cond ((eq exp '?) (gensym "?"))
        ((atom exp) exp)
        (t (cons (replace-?-vars (first exp))
                 (replace-?-vars (rest exp))) ))  )


(defun add-clause (clause)
  "Add a clause to the data base, indexed by head's predicate"
  ;; The predicate must be a non-variable symbol.
  (let* ((clause1 (replace-?-vars clause))
         (pred (predicate (clause-head clause1))))
    (assert (and (symbolp pred) (not (variable-p pred))))
    (pushnew pred *db-predicates*)
    (setf (get pred 'clauses)
          (append (get-clauses pred) (list clause1))) pred) )   ; changed nconc to append

; (setf clause '((P ?x ?y) . ((Q ?x ?y))))
; (add-clause clause)                       ; => P
; *db-predicates*                           ; => (P)
; (get 'P 'clauses)                         ; (((P ?X ?Y) (Q ?X ?Y)))

(defun show-all-clauses ()   ; *db-predicates*  -> Clause-list    (new function)
    "Retrieve all the clauses in the knowledge-base"
     (apply #'append (mapcar #'get-clauses *db-predicates*)))

(defun clear-db ()
  "Remove all clauses (for all predicates) from the database"
  (mapc #'clear-predicate *db-predicates*))

(defun clear-predicate (predicate)
  "Remove the clauses for a single predicate"
  (setf (get predicate 'clauses) nil) )

(defun test ()
  (clear-db)
  (setf *db-predicates* nil)
  (add-clause '((likes Kim Robin)))
  (add-clause '((likes Sandy Lee)))
  (add-clause '((likes Sandy Kim)))
  (add-clause '((likes Robin cats)))
  (add-clause '((likes Sandy ?x) (likes ?x cats)))
  (add-clause '((likes Kim ?x) (likes ?x Lee) (likes ?x Kim)))
  (add-clause '((likes ?x ?x)))
  (format t "~&Predicate database *db-predicates* = ~a" *db-predicates*)
  (terpri)
  (pprint (show-all-clauses))
  (terpri)
  (prove '(likes Sandy ?who) +no-bindings+) )

(defun prove (goal b)    ; Literal x Bindings -> Bindings
  "Return a list of possible solutions to goal"
  (let ((kb-clauses (get-clauses (predicate goal))))  ; kb clauses which match goal
    (apply #'append (mapcar #'(lambda (kb-clause1)
                                (let* ((kb-clause       (rename-variables kb-clause1))
                                       (kb-clause-head  (clause-head kb-clause))
                                       (kb-clause-body  (clause-body kb-clause))
                                       (goal-bindings   (unify goal kb-clause-head b)))
                                  (prove-all kb-clause-body goal-bindings)))
                            kb-clauses)) ) )

(defun prove-all (goals goal-bindings) ; Literal-list x Bindings -> Bindings
  "Return a list of solutions to the conjunction of goals"
  (cond ((eql goal-bindings +fail+) +fail+)
        ((null goals) (list goal-bindings))
        (t  (let* ((next-bindings (prove (car goals) goal-bindings)))
              (apply #'append (mapcar #'(lambda (b) (prove-all (cdr goals) b))
                                      next-bindings)) ) ) ) )


(defun rename-variables (x)       ; clause -> clause (with vars renamed)
  "Replace all variables in x with new ones"
  (sublis (mapcar #'(lambda (var) (cons var (gensym (string var))))
                  (variables-in x))
          x))

;;; --- Example ---
#|
(add-clause '((likes Kim Robin)))
(add-clause '((likes Sandy Lee)))
(add-clause '((likes Sandy Kim)))
(add-clause '((likes Robin cats)))
(add-clause '((likes Sandy ?x) (likes ?x cats)))
(add-clause '((likes Kim ?x) (likes ?x Lee) (likes ?x Kim)))
(add-clause '((likes ?x ?x)))

(prove '(likes Sandy ?who) +no-bindings+)   ; =>

; (((?WHO . LEE))
;  ((?WHO . KIM))
;  ((#:?X846 . ROBIN)
;  (?WHO . #:?X846))
;  ((#:?X850 . CATS) (#:?X847 . CATS) (#:?X846 . SANDY) (?WHO . #:?X846))
;  ((#:?X855 . CATS) (#:?X846 . #:?X855) (?WHO . #:?X846))
;  ((?WHO . SANDY) (#:?X857 . SANDY)))
;
; - End Example
|#

;;; --- Prolog-like macros - defined also in Zebra-Puzzle ---
;
(defmacro <- (&rest clause)
  "Add a clause to the database"
  `(add-clause ',clause))

; (macroexpand-1 '(<- (likes Kim Robin)))    ; =>
; (ADD-CLAUSE (QUOTE ((LIKES KIM ROBIN))))   ; which is correct.

 (defmacro ?- (&rest goals) `(top-level-prove ',(replace-?-vars goals)))

; (macroexpand-1 '(?- goals))

;;; --- Prove removing spurious bindings ---

(defun variables-in (exp)
  "Return a list of all the variables in exp"
  (unique-find-anywhere-if #'variable-p exp))

(defun unique-find-anywhere-if (predicate tree &optional found-so-far)
  "Return a list of leaves of tree satisfying predicate, with duplicates removed"
  (if (atom tree)
      (if (funcall predicate tree) (adjoin tree found-so-far) found-so-far)
      (unique-find-anywhere-if predicate (first tree)
                            (unique-find-anywhere-if predicate (rest tree) found-so-far)
 )))

(defun top-level-prove (goals)
  "Prove the goals, and print variables readably"
  (show-prolog-solutions (variables-in goals) (prove-all goals +no-bindings+)))

(defun show-prolog-solutions (vars solutions)
  "Print the variables in each of the solutions"
  (if (null solutions)
      (format t "~&No.")
      (mapc #'(lambda (solution) (show-prolog-vars vars solution)) solutions))
  (values))

(defun show-prolog-vars (vars bindings)
  "Print each variable with its binding"
  (if (null vars)
      (format t "~&Yes")
    (dolist (var vars)
      (format t "~&~a = ~a" var (subst-bindings bindings var))))
  (princ ";"))

;
;;; --- Zebra Puzzle  ---
; (load  "C:\\Users\\HP Owner\\Google Drive\\Lisp\\Prog-RTP\\Zebra-Puzzle.lisp")
;
;;; --- Zebra Puzzle  ---
;
#| Begin comments

Here is an example of something Prolog is very good at: a logic puzzle. There are
fifteen facts, or constraints, in the puzzle:

1. There are five houses in a line, each with an owner, a pet, a cigarette, a drink,
and a color.
2. The Englishman lives in the red house.
3. The Spaniard owns the dog.
4. Coffee is drunk in the green house.
5. The Ukrainian drinks tea.
6. The green house is immediately to the right of the ivory house.
7. The Winston smoker owns snails.
8. Kools are smoked in the yellow house.
9. Milk is drunk in the middle house.
10. The Norwegian lives in the first house on the left.
11. The man who smokes Chesterfields lives next to the man with the fox.
12. Kools are smoked in the house next to the house with the horse.
13. The Lucky Strike smoker drinks orange juice.
14. The Japanese smokes Parliaments.
15. The Norwegian lives next to the blue house.

The questions to be answered are: who drinks water and who owns the zebra?

End comments
|#

(<- (member ?item (?item . ?rest )))
(<- (member ?item (?x . ?rest) ) (member ?item ?rest))

(<- (nextto ?x ?y ?list) (iright ?x ?y ?list))
(<- (nextto ?x ?y ?list) (iright ?y ?x ?list))

(<- (iright ?left ?right (?left ?right . ?rest)))
(<- (iright ?left ?right (?x . ?rest)) (iright ?left ?right ?rest))
(<- (= ?x ?x))

;; Each house is of the form:
;; (house nationality pet cigarette drink house-color)
;; ?h is the variable representing the list of the five houses

(<- (zebra ?h ?w ?z)

  (= ?h ((house norwegian ? ? ? ?) ? (house ? ? ? milk ?) ? ? ) )   ; 1, 10, 9
  (member (house englishman ? ? ? red) ?h)                                 ; 2
  (member (house spaniard dog ? ? ?) ?h)                                     ; 3
  (member (house ? ? ? coffee green) ?h)                                     ; 4
  (member (house ukrainian ? ? tea ?) ?h)                                    ; 5
  (iright (house ? ? ? ? ivory)                                                        ; 6
          (house ? ? ? ? green) ?h)
  (member (house ? snails winston ? ?) ?h)                                  ; 7
  (member (house ? ? kools ? yellow) ?h)                                     ; 8
  (nextto (house ? ? chesterfield ? ?)                                             ; 11
          (house ? fox ? ? ?) ?h)
  (nextto (house ? ? kools ? ?)                                                       ; 12
          (house ? horse ? ? ?) ?h)
  (member (house ? ? luckystrike orange-juice ?) ?h)                  ; 13
  (member (house japanese ? parliaments ? ?) ?h)                       ; 14
  (nextto (house norwegian ? ? ? ?)                                              ; 15
          (house ? ? ? ? blue) ?h)

;; Now for the questions:

   (member (house ?w ? ? water ?) ?h)                                        ; Q1
   (member (house ?z zebra ? ? ?) ?h) )                                        ; Q2

; Here's the query

;  (?- (zebra ?houses ?water-drinker ?zebra-owner))

; .. and here's the result

; ?HOUSES = ((HOUSE NORWEGIAN FOX KOOLS WATER YELLOW)
; (HOUSE UKRAINIAN HORSE CHESTERFIELD TEA BLUE)
; (HOUSE ENGLISHMAN SNAILS WINSTON MILK RED)
; (HOUSE SPANIARD DOG LUCKYSTRIKE ORANGE-JUICE IVORY)
; (HOUSE JAPANESE ZEBRA PARLIAMENTS COFFEE GREEN))
; ?WATER-DRINKER = NORWEGIAN
; ?ZEBRA-OWNER = JAPANESE.
; No.
;
; ------------------------------------------------------------------------------------------------------------
; The Zebra Puzzle is at:
;
;  http://interweave-consulting.blogspot.co.uk/2017/02/the-zebra-puzzle-prolog-in-lisp.html
;
;                                            ----------------- End ------------------

The Zebra Puzzle (Prolog in Lisp)

I am delighted to have got Peter Norvig's Lisp interpreter for Prolog working (in its simplest form) from Chapter 11 of his book, "Paradigms of Artificial Intelligence programming".



I tested it on his Zebra puzzle, where he states:
"This took 278 seconds, and profiling (see page 288) reveals that the function prove was called 12,825 times. A call to prove has been termed a logical inference, so our system is performing 12825/278 = 46 logical inferences per second, or LIPS.

Good Prolog systems perform at 10,000 to 100,000 LIPS or more, so this is barely limping along."
On my Windows 10 HP laptop, the computation took 7 seconds with 29,272 calls to 'prove'.

I guess that's 4,182 LIPS for compiled Lisp from LispWorks - program totally unoptimised.

His book is rather old (1992).

---

The Zebra puzzle

"Here is an example of something Prolog is very good at: a logic puzzle. There are fifteen facts, or constraints, in the puzzle:
1. Five houses in a line, each with an owner, a pet, a cigarette, a drink, and a color.
2. The Englishman lives in the red house.
3. The Spaniard owns the dog.
4. Coffee is drunk in the green house.
5. The Ukrainian drinks tea.
6. The green house is immediately to the right of the ivory house.
7. The Winston smoker owns snails.
8. Kools are smoked in the yellow house.
9. Milk is drunk in the middle house.
10. The Norwegian lives in the first house on the left.
11. The man who smokes Chesterfields lives next to the man with the fox.
12. Kools are smoked in the house next to the house with the horse.
13. The Lucky Strike smoker drinks orange juice.
14. The Japanese smokes Parliaments.
15. The Norwegian lives next to the blue house.
The questions to be answered are: who drinks water and who owns the zebra?"

The translation into Prolog in Lisp uses a Lisp-like syntax for Prolog facts and rules (both are clauses). Here's the Prolog 'program' coding the above problem.

;;; --- Lisp code follows - comments from Norvig's book  ---
;;;
;;; To solve this puzzle, we first define the relations nextto (for "next to") and
;;;  iright (for 'immediately to the right of'). They are closely related to member,
;;; which is repeated here.
;;;

(<- (member ?item (?item . ?rest )))
(<- (member ?item (?x . ?rest) ) (member ?item ?rest))

(<- (nextto ?x ?y ?list) (iright ?x ?y ?list))
(<- (nextto ?x ?y ?list) (iright ?y ?x ?list))

(<- (iright ?left ?right (?left ?right . ?rest)))
(<- (iright ?left ?right (?x . ?rest)) (iright ?left ?right ?rest))
(<- (= ?x ?x))

;;; We also defined the identity relation, =. It has a single clause that says that any x is
;;; equal to itself. One might think that this implements eq or equal. Actually, since
;;; Prolog uses unification to see if the two arguments of a goal each unify with ?x, this
;;; means that = is unification.

;;; Each house is of the form:
;;; (house nationality pet cigarette drink house-color)
;;; ?h is the variable representing the list of the five houses

(<- (zebra ?h ?w ?z)

  (= ?h  ((house norwegian ? ? ? ?) ? (house ? ? ? milk ?) ? ? ) )              ; 1, 10, 9
  (member (house englishman ? ? ? red) ?h)                                             ; 2
  (member (house spaniard dog ? ? ?) ?h)                                                 ; 3
  (member (house ? ? ? coffee green) ?h)                                                  ; 4
  (member (house ukrainian ? ? tea ?) ?h)                                                 ; 5
  (iright (house ? ? ? ? ivory)                                                                     ; 6
             (house ? ? ? ? green) ?h)
  (member (house ? snails winston ? ?) ?h)                                               ; 7
  (member (house ? ? kools ? yellow) ?h)                                                 ; 8
  (nextto (house ? ? chesterfield ? ?)                                                         ; 11
             (house ? fox ? ? ?) ?h)
  (nextto (house ? ? kools ? ?)                                                                   ; 12
              (house ? horse ? ? ?) ?h)
  (member (house ? ? luckystrike orange-juice ?) ?h)                              ; 13
  (member (house japanese ? parliaments ? ?) ?h)                                   ; 14
  (nextto (house norwegian ? ? ? ?)                                                          ; 15
              (house ? ? ? ? blue) ?h)

;; Now for the questions:

   (member (house ?w ? ? water ?) ?h)                                                     ; Q1
   (member (house ?z zebra ? ? ?)  ?h) )                                                   ; Q2

; Here's the query

  (?- (zebra ?houses ?water-drinker ?zebra-owner))

; .. and here's the result

?HOUSES = ((HOUSE NORWEGIAN FOX KOOLS WATER YELLOW)
                       (HOUSE UKRAINIAN HORSE CHESTERFIELD TEA BLUE)
                       (HOUSE ENGLISHMAN SNAILS WINSTON MILK RED)
                       (HOUSE SPANIARD DOG LUCKYSTRIKE ORANGE-JUICE IVORY)
                       (HOUSE JAPANESE ZEBRA PARLIAMENTS COFFEE GREEN))
?WATER-DRINKER = NORWEGIAN
?ZEBRA-OWNER = JAPANESE;

---

I'll publish the Lisp code for the Prolog interpreter separately (here):

http://interweave-consulting.blogspot.co.uk/2017/02/a-simple-prolog-interpreter-in-lisp.html


Friday, February 17, 2017

Le terrible dilemme de la glorieuse France



Prior to Germany's unification in the mid-nineteenth century, France had regularly been top dog in Europe for a thousand years. From Charlemagne through the Sun King to Bonaparte, the French do not forget.

After the second world war, with Germany both beaten and shamed, the French seized upon the idea of the EEC/EU. They would lead an exhausted continent, and the humiliated Germans would pay.

This vision of the EU as a greater, more glorious France endured for fifty years. It took the post-Cold War reunification of Germany and a new generation of Germans with declining guilt, to parlay Germany's economic power into European political leadership.

Who can forget those pictures of Angela Merkel, striding into power-summits with a diminutive Francois Hollande trotting beside her, as if a handbag dog?

A Germany coming into its own will have its natural satellites: Austria, parts of Eastern Europe. But France? Here is the dilemma. The EU project has become a suffocating straitjacket for France, forcing it into subservience to Germany. German-interest policies inflicted upon the whole EU have created popular discontent within France as elsewhere.

The result has been the collapse of the establishment parties in France, the Socialists and the Republicans, and the emergence of a Tony Blair-lite politician (Emmanuel Macron) along with the nationalist Front National as the main contenders for power.

The French establishment is solidly pro-EU, and as defeatist as the British powers-that-be. Its 'realistic' view is that the economic realities cannot be denied and that the best France can hope for is German satellite status with influence.

Marine Le Pen speaks for a France which, like Brexit UK, decouples from German domination.

It's not clear whether the upcoming Presidential election will coincide with a decisive rupture in the dynamics of French politics, which could hand Le Pen the victory. But the tensions between la glorieuse France and its default deferential future will only grow.

If not this time, then the next.

Thursday, February 16, 2017

Stonehenge in the February rain

Perverse to visit Stonehenge yesterday, with heavy rain forecast for most of the day. Perhaps it was only Bristol Water, turning off our supply for 8 hours for 'urgent repairs', who could have forced us out.

Anyway, a chance to see the new Visitor Centre and admire the A303 before it vanishes into a tunnel forever.

Clare approaches the new Visitor Centre - henge-themed

An ancestor of Trevor Eve was found here 5,000 years ago
(click on image to make larger and read the caption).

Never have I seen such bedraggled sheep

Traffic jams on the A303 .. oh, and some rocks

Clare was sampling something from the local druids I guess

We did have a conversation about it.



Afterwards we took a late lunch in Warminster. Much as I would like the town to be associated with the heavy military presence on the adjacent Salisbury Plain, in fact:
"The town's name has evolved over time, known as Worgemynstre in approximately 912 and it was referred to in the Domesday Book in 1086 as Guerminstre.

The town name of Warminster is thought to derive from the River Were, a tributary of River Wylye which runs through the town, and from an Anglo-Saxon minster or monastery, which existed in the area of St Denys's Church.

The river's name, "Were" may derive from the Old English "worian" to wander."

Wednesday, February 15, 2017

The problem of dialogue as regards chatbots

Me: "So here's my plan."

Clare: "OK."

Me: "I've copied Peter Norvig's chapter 11 code for a Prolog interpreter in Lisp into a Notepad file. Unfortunately copying from PDF introduces all kinds of formatting errors, so it takes a while to get it into a compilable state."

Clare: "?"

Me: "I need to work through his main functions - principally to exactly understand his unification algorithm to start with. I may modify the code a bit, make it more transparent."

Clare: "??"

Me (oblivious): "And then I'm not sure I like the way he's storing clauses as plists on the clause head predicate. I think an assoc list would be clearer, if less efficient. Also, I need to do a few paper and pen examples to understand exactly the rationale for variable-renaming between clauses during resolution."

Clare: "???"

Me: "I'll get his standard Prolog depth-first search to work first of course. But I think it would be a good idea to explicitly break out the resolution procedure as a standalone function, and then parameterise the proof procedure by a range of possible search methods including breadth-first and best-first."

Clare: "????"

Me: "Of course, all this is just to get a series of tools in place for my speech-act planner, the one that's going to make my chatbot able to steer a conversation."

Clare: "?????"

Me: "I really think this could be a stellar app. I can see it on Google Play. The trouble is, 'in the knowledge lies the power' is just as relevant here and I might need to spend way too much time just data-filling various knowledge-bases, ... hmm, unless I can get it to safely learn from users. That's where Google does have an advantage ..."

[Pause]

Clare: "Is that Mr Bullfinch I see on the fat block?"

Tuesday, February 14, 2017

The Outstanding Leader is unwell ..



The BBC website reports:
"The half-brother of North Korean leader Kim Jong-un has been killed in Malaysia, South Korean and Malaysian sources say.

Kim Jong-nam, 45, is said to have been targeted at the airport in Kuala Lumpur, the capital. A source close to the Malaysian PM's office told the BBC that Mr Kim was killed in the city, saying his body was now undergoing an autopsy. Kim Jong-nam is the eldest son of former North Korean leader Kim Jong-il."
---

The US President Mr Trump says 'something will be done' about North Korea's somewhat provocative ballistic missile tests. Perhaps one imagines a pre-emptive strike on military facilities?

Easily done, but it's hard not to see the Chinese reacting badly.

Something a little more subtle is needed. Some virus, engineered to attach to cells expressing a certain genotype. Thanks to CRISPR, that kind of virus-editing seems quite practicable. A weaponised flu variant should do it.

How to get a copy of the Dear Leader's genome? You can go a long way with a half brother.

The other half of the mission is transportation. The US authorities should not be relying on a pandemic. A long range stealth-drone delivering a miniature RPV close to the OL should do it: something disposable and wasp-like.

Send a swarm: only way to be sure.

What are the chances the CIA has this mission design in front of the President as we speak?

---

Greg Cochran was writing about jihadis, but the principle seems to apply.

Monday, February 13, 2017

"The Genome Factor" - Conley and Fletcher

Amazon link

For decades the Standard Social Science Model has dominated academic social science and mainstream elite thinking. Broadly speaking, the model states: (i) there are no innate precursors for cognitive traits such as personality, intelligence, character and interests - everything is environmental; and (ii) consequentially, there are no innate psychological differences between women and men - or between blacks, whites, east asians or the Ashkenazim.

Since everything is environmental (the 'blank slate' hypothesis) then any observed differences must be due to selective discrimination which can therefore be addressed by public policy. The consequence is a litany of discriminations with which we are all familiar: sexism, racism and various phobias.

Plainly there are differences in the physical realm. Some sports are gender-segregated, for example. But even acknowledging that makes people nervous. Physical differences are played down as inconsequential.

Less well-educated folk know that the blank-slate hypothesis is rubbish. A little experience of families, a little observation both of everyday life and of the world at large will convince most people that it is more likely that the moon truly is made of green cheese.

So what explains the astonishing durability of the SSSM?

Plainly it speaks to that powerful liberal sense of compassion and fairness highlighted in Jonathan Haidt's Moral Foundations Theory.  Most western democracies are multiracial, patchwork 'internal-empires' - the legacy of centuries of immigration and in some cases slavery. Race- and gender-blind application of legislation and social norms is considerably enhanced by taking the view that formal social and legal equality is also biological equality. Once the argument for population-genetic differences is admissible, it seems to liberals that the floodgates of discrimination would be opened once again.

The ideology of the SSSM also makes it easy to justify generic immigration: high, low and zero-skilled ('everyone is the same'). This can be very convenient for company executives who suffer few of the frequently-negative social consequences of the latter.

Recent advances in genetic sequencing over very large populations pose a grave threat to the convenient untruths of the SSSM. It is already known that almost all psychological and behavioural traits of interest to social scientists are heritable at c. 50-60%. This means that about half the trait-variation in the population is attributable to genetic differences, the rest being due to differences in contemporary shared and personal environments.

Apart from hands-on confirmation of these heritability results, genomics also adds personalisation. Once we understand how to map a person's genome to such phenotypic attributes as IQ, personality, character and a myriad of narrower traits (such as political orientation) with high precision - and correlational accuracies of 0.7-0.9 seem potentially in reach - then it seems that genome truly is life-destiny. And most likely this is the case. The life-history similarities of twins, even when raised apart, tends to show the way.

Social scientists mostly ignore the incoming tsunami of new research. But the genomic telescope has been invented, it's not going to go away. A more sophisticated strategy is deployed in "The Genome Factor" by Conley and Fletcher. The authors are sociologists by profession but research the social science implications of genomic surveys. They had a choice - to go with the trend of such research to transcend the SSSM - or to find ever more intricate arguments to preserve it.

In choosing the latter approach, their strategy is to freely accept the theoretical results of population genetics and the empirical data of GWAS (genome-wide association studies) where this does not threaten blank-slatism. They then labour to find fault in every study which might cast it into doubt while feeding plenty of slack to the many purported environment-only explanations of race and gender differences. You will see plenty of uncritical space given to: continuing discrimination and poor institutions (pp. 107 ff.); subconscious bias, priming and stereotype threat (appendix 5).

In chapter 4, the authors address the claims of Herrnstein and Murray's seminal 1994 book, The Bell Curve. The three theses they wish to 'take seriously' are (to summarise): (i) increasing genetic stratification due to cognitive meritocracy; (ii) increasing assortative mating for intelligence; (iii) cognitive dysgenics via reduced fertility in the cognitive elite.

They announce, to their evident satisfaction, that none of these theses is born out by the evidence. But how convinced should we be by their arguments? The answer is, not very. There are many confounding variables - particular the massive changes in education and employment practices over the decades relevant to analysis - as Conley and Fletcher themselves spell out. In some cases the phenotypic attributes measured do, in fact, accord with Herrnstein and Murray's theses but the authors rapidly draw our attention to their underlying genetic correlates, as derived from GWAS.

Here they find no such trends. But unfortunately, we do not yet know the genetic markers for the relevant cognitive traits. Instead, the genomic indicator the authors use is the incredibly noisy 'polygenic score' (PGS). All we can really conclude is that the effects are small, and that as far as Herrnstein and Murray's proposed theses are concerned, it's too early to be sure.

Chapter 6, 'The Wealth of Nations', engages with Ashraf and Galor's 'Goldilocks' hypothesis of correlations between degrees of genetic diversity (too much in Africa?) and higher income and growth. Yet the correlations are poor (p. 124).  I wish they had engaged with work such as Garett Jones' 'Hive Mind', which focuses on ideas that country differences in IQ and size of the 'smart fraction' have something to do with it. Jones finds remarkably high correlations. But you can see the dangers.

So this is a book with an agenda although I think it's subconscious bias. The authors take too much pleasure in 'refuting' challenges to the core doctrines of the SSSM to make me think they're just doing so to protect their positions.

There are things to learn from this book. As critics they look for every conceivable flaw in twin and GWAS studies - this is socially useful. They also explain various techniques such as GWAS well, although the book is too technical and too dry for both the general public and mainstream social science academics.

In all, I regard this book as a missed opportunity.

Sunday, February 12, 2017

Chatbots: conversation as AI planning

I just love those YouTube videos of Internet-connected dolls. They're Wifi-linked to IBM's Watson, or some similar AI-in-the-cloud.

You'd think that the conversation would be scintillating - insofar as talking to a small child might have its moments.

But no, in the clip the adorable child is always shown asking the doll, "How far away is the Moon?" and the doll shows its conversational prowess by reciting Wikipedia.

Surely we can do better.

It's good to recall that we converse in order to achieve objectives. Sometime those objectives are indeed objective - as when we wonder how far away is the Moon.

Most of the time, though, the objectives are more about our more basic human desires. The need for sympathy, approbation, bonding against a third party, humiliation and revenge.

Oh dear, I've been listening to Cersei Lannister again..

Cersei and Margaery

Conversation is composed of speech acts directed towards goals, the goals often being the alteration of emotional states. Real-life chat is therefore very dependent on the accurate reading of emotional cues: facial expressions, tone of voice or other body language. No wonder email and WhatsApp chats go awry so often.

This suggests that a chatbot (a better Eliza) should treat conversation as an AI planning task.*

Naturally I'm not the first to realise that - this 1980 article - but it's the next place to go.

This relatively recent Stanford review - Conversational Agents - is quite illuminating (PDF slides).

---

Call me an old GOFAI-nostalgic but bottom-up number-crunching the stats is subject to diminishing returns as we move to higher cognitive tasks. Which is why I'm less than impressed by the tedious Google Assistant in Allo.

---

* I mean like GPS. Most conversational chatbots - like Google Assistant - cope with the extreme difficulties of unrestricted natural language input by giving a series of response-text buttons for the user to select ("Tell me a joke").

In a formalised conversational model, the chatbot should treat the conversation as a two-person game-tree. The opponent (user) has a choice of possible conversational rejoinders ('moves') which the program has a chance of understanding, and which propel the conversation forward in some direction.

Best to look at the planner conversation 'speech-act' rule-base and list the possible responses (need a way to flag input-variables) so as to guide the user.

Example:

Chatbot>: "What's your brother's name?

[I understand best:
   1. <first-name>
   2. <first-name> <second-name>
   3. <name> but we call him <nickname>
   4. I don't have a brother.
   5. Could we move on to another topic?
You can enter the response number if there's no information to give.]

User>:  Jimmie.

"When I am dead, my dearest"

Poignant poem in The Sunday Times today: by Christina Rossetti, (1830 - 1894).


When I am dead, my dearest,
    Sing no sad songs for me;
Plant thou no roses at my head,
    Nor shady cypress tree:
Be the green grass above me
    With showers and dewdrops wet;
And if thou wilt, remember,
    And if thou wilt, forget.

I shall not see the shadows,
   I shall not feel the rain;
I shall not hear the nightingale
   Sing on, as if in pain:
And dreaming through the twilight
    That doth not rise nor set,
Haply I may remember,
    And haply may forget.

---

I think that's a realistic view of death and its aftermath, beautifully stated.

Saturday, February 11, 2017

Diary: snow + books + chatbot backstory

We last had snow here back in December 2010 (when it was heavy). This morning only the lightest dusting .. and as I write, it's gone.

A light dusting of snow in our garden this morning
---

This new book by Dalton Conley and Jason Fletcher should be arriving today.

Amazon link

Expect a review in due course if it's any good.

Update: it's now arrived and I've had a peek. The authors are both sociology professors, which rings alarm bells. And they have an agenda. They're here to defend the standard social science model against the unsettling results of recent DNA sequencing programs and GWAS (genome-wide association studies). Their idea is to make the most minimal concessions to evidence while still preserving the traditional social-sciences advocacy-based value system. So races don't exist, racial genetic differences in cognition don't exist, and most else which might disturb the liberal agenda of the irrelevance of genetics for outcomes is explained away.

Depressing.

[Update (Sunday): my first impressions were wrong. The book is both more honest and more erudite than had appeared from a first skim. The authors may be billed as sociologists but they are both genetics research practitioners. Once you have absorbed the theory and methodology, it's harder to be agenda-driven - if you're honest. I think a review will be in order once I've finished.]

[Update (Monday): Finished. It was as my first impressions. A sophisticated attempt to save the SSSM from those pesky geneticists. Sophistry rules: don't waste your money. Review here.]

---

Genetics, especially human genomics, is the one area of contemporary science most at odds with prevailing western ideology. Most of the time this didn't matter - you can believe whatever you like if it has no practical consequences: in fact most human beliefs are like that.

But with emergent technologies for DNA sequencing, embryo selection and genome-editing, the science soon will matter. You will be able, in principle, to improve attributes (such as the health, emotional stability and intelligence) of your children. The issues will be regulation. cost and your desire to do so.

I anticipate, with no joy, decades of screaming hysteria.

I'm also working my way through Sean Carroll's book on entropy and the 'Past Hypothesis',



and Stephen Cohen's excellent biography of Bukharin,




not to mention Scott Bakker's 'Prince of Nothing'.




It's hard to timeshare: particularly when one is programming.

Incidentally, just as it is said that no-one feels hunger pangs when stepping out of a plane to do a parachute jump, an afternoon programming tends to obscure the fact you've skipped lunch. Just over 68kg this morning (10st 10.4lb) as the abdominal bulge recedes somewhat.

I'm pleased.

---

Just a short note-to-self about the chatbot stuff. The next thing (after the recent Eliza-style vacuity) is to capture the 'aboutness' of conversation. In chatting, each conversational partner brings some backstory to a discussion.

The essence of being an effective chatbot is:
  1. Manage a dynamic back-story of your own,
  2. Engage with the backstory of your human conversational partner.
If the chatbot is a cat, the backstory can be quite constrained - for example, nocturnal adventures in the garden with other cats, badgers, voles, birds, food and vomiting. I was looking at Peter Norvig's GPS reconstruction (previously discussed here) as a possible route to writing a dynamic simulation model.

The various entities I mentioned (cats, badgers, voles, ..) should have actions which require their preconditions in the garden knowledge-base (KB) to hold, and which then assert their post conditions in the next KB iteration. Make actions probabilistic and you've got an interesting simulation.

GPS doesn't quite work in this forward-chaining mode so it's not a case of just adapting his existing code. But the Eliza pattern-matching engine can be the reusable heart of it.

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.