## Saturday, 29 November 2014

### linearity of operators

One of the powerful features of BKO is the linearity of (most) operators.
op1 |x> => |a> + |b> + |c>
Then:
op2 op1 |x>
= op2 (|a> + |b> + |c>)
= op2 |a> + op2 |b> + op2 |c>

Let's do a simple example in the console:
-- enter in some knowledge:
sa: friends |Fred> => |Sam> + |Mary> + |Bella>
sa: age |Sam> => |age: 39>
sa: age |Mary> => |age: 42>
sa: age |Bella> => |age: 36>

-- see what we know:
-- who are Fred's friends?
sa: friends |Fred>
|Sam> + |Mary> + |Bella>

-- how old are Fred's friends?
sa: age friends |Fred>
|age: 39> + |age: 42> + |age: 36>

-- enter in some more knowledge:
sa: friends |Sam> => |Liz> + |Rob>
sa: friends |Bella> => |Joan> + |Tom>

-- who are Sam's friends?
sa: friends |Sam>
|Liz> + |Rob>

-- who are Mary's friends?
sa: friends |Mary>
|>
-- in English |> means "I don't know anything about that".
-- so instead of bugging out if you ask it something it doesn't know, it just quietly returns |> (the empty ket)

-- who are Bella's friends?
sa: friends |Bella>
|Joan> + |Tom>

And now finally:
-- who are Fred's friends of friends?
sa: friends friends |Fred>
|Liz> + |Rob> + |Joan> + |Tom>

And note that it quietly made use of:
"superposition + |> = |> + superposition = superposition"
ie, |> is the identity element for superpositions.
So even though we don't know who's Mary's friends are, the code didn't bug out, and replied best it could.
I like to think humans do something similar.

-- what are the ages of Fred's friends of friends?
sa: age friends friends |Fred>
|>
-- ie, we don't know!

Then finally, let's look at what we now know:
sa: dump
----------------------------------------
|context> => |context: sw console>

friends |Fred> => |Sam> + |Mary> + |Bella>

age |Sam> => |age: 39>
friends |Sam> => |Liz> + |Rob>

age |Mary> => |age: 42>

age |Bella> => |age: 36>
friends |Bella> => |Joan> + |Tom>
----------------------------------------
(and we forgot to set context when we started, so it used the default context "sw console")

And that's it for now!