learning indirectly

A common thing when having a conversation is to have a set of variables keeping track of who you are talking about. The simplest is "you".
So, in my scheme how can we learn something about you?
We can't simply do:
-- first define context:
sa: context learn you
sa: |you> => |Fred>
sa: age |you> => |age: 29>

Here is why:
sa: dump
----------------------------------------
|context> => |context: learn you>

 |you> => |Fred>
age |you> => |age: 29>
----------------------------------------
We really wanted Fred to be 29, not "you".

So, it took some coding! but we have a new construct:
OP SUPERPOSITION-1 => SUPERPOSITION-2
which maps to:
OP KET => SUPERPOSITION-2
for all kets in SUPERPOSITION-1

Example:
-- see the current definition of "you"
sa: "" |you>
|Fred>
-- so it is "Fred"

-- let's learn his age:
sa: age "" |you> => |age: 29>

-- see what we know:
sa: dump
----------------------------------------
|context> => |context: learn you>

 |you> => |Fred>
age |you> => |age: 29>

age |Fred> => |age: 29>
----------------------------------------
-- success!

Now, swap "you" to "Sam", and learn his age:
sa: |you> => |Sam>
sa: age "" |you> => |age: 34>

sa: dump
----------------------------------------
|context> => |context: learn you>

age |you> => |age: 29>
 |you> => |Sam>

age |Fred> => |age: 29>

age |Sam> => |age: 34>
----------------------------------------
-- again, success!

Now for another example, learn daily closing times for a shop:
sa: context shop closing time

sa: |weekday: _list> => |Monday> + |Tuesday> + |Wednesday> + |Thursday> + |Friday>
sa: |weekend: _list> => |Saturday> + |Sunday>

sa: closing-time "" |weekday: _list> => |time: 6pm>
sa: closing-time "" |weekend: _list> => |time: 4:30pm>

sa: dump
----------------------------------------
|context> => |context: shop closing time>

 |weekday: _list> => |Monday> + |Tuesday> + |Wednesday> + |Thursday> + |Friday>

 |weekend: _list> => |Saturday> + |Sunday>

closing-time |Monday> => |time: 6pm>

closing-time |Tuesday> => |time: 6pm>

closing-time |Wednesday> => |time: 6pm>

closing-time |Thursday> => |time: 6pm>

closing-time |Friday> => |time: 6pm>

closing-time |Saturday> => |time: 4:30pm>

closing-time |Sunday> => |time: 4:30pm>
----------------------------------------

More later!

Update: with my new pretty print table code, we can now do this:
sa: table[day,closing-time] ("" |weekday: _list> + "" |weekend: _list>)
+-----------+--------------+
| day       | closing-time |
+-----------+--------------+
| Monday    | time: 6pm    |
| Tuesday   | time: 6pm    |
| Wednesday | time: 6pm    |
| Thursday  | time: 6pm    |
| Friday    | time: 6pm    |
| Saturday  | time: 4:30pm |
| Sunday    | time: 4:30pm |
+-----------+--------------+
Update: we can tidy up the operator names a little so they are more like natural English:
  list-of |week days> => |Monday> + |Tuesday> + |Wednesday> + |Thursday> + |Friday>
  list-of |weekend days> => |Saturday> + |Sunday>
  closing-time list-of |week days> => |time: 6pm>
  closing-time list-of |weekend days> => |time: 4:30pm>
  table[day,closing-time] list-of (|week days> + |weekend days>)
+-----------+--------------+
| day       | closing-time |
+-----------+--------------+
| Monday    | 6pm          |
| Tuesday   | 6pm          |
| Wednesday | 6pm          |
| Thursday  | 6pm          |
| Friday    | 6pm          |
| Saturday  | 4:30pm       |
| Sunday    | 4:30pm       |
+-----------+--------------+
Update: we can also make the learn-you more like natural English:
  name-of |you> => |Fred>
  age-of name-of |you> => |age: 29>
  name-of |you> => |Sam>
  age-of name-of |you> => |age: 34>
  dump
----------------------------------------
|context> => |context: sw console>

name-of |you> => |Sam>

age-of |Fred> => |age: 29>

age-of |Sam> => |age: 34>
----------------------------------------
Update: another more interesting learning indirectly example. This time one extra operator deep:
  the-third |US President> => |Thomas Jefferson>
  the-party-of the-third |US President> => |party: Democratic-Republican>
  the-dissolution-date-of the-party-of the-third |US President> => |year: 1825>

sa: dump
----------------------------------------
|context> => |context: sw console>

the-third |US President> => |Thomas Jefferson>

the-party-of |Thomas Jefferson> => |party: Democratic-Republican>

the-dissolution-date-of |party: Democratic-Republican> => |year: 1825>
----------------------------------------
ie, inching ever closer to natural language. And I think we can get even closer still!


Home
previous: exponentiating operators
next: supported ops and apply

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org