Spatiotemporal Inference

From OpenCog
Jump to: navigation, search

Here are few toy examples of spatiotemporal inference coded in PLN. Note that the numerical calculations are either simplified or left out since PLN has not yet been completed with what is necessary to run these examples in the PLN inference engine.

Spatiotemporal Rules and Notations

Notations

Some shorthands are used like

ForAll VAR1 ... VARn

which stands for

ForAll
    ListLink
        VAR1
        ...
        VARn

Or

PredicateName(ARG1, ..., ARGn)

which stands for

EvaluationLink
    PredicateName
    ListLink
        ARG1
        ...
        ARGn

Spatiotemporal rules

The rules are reduced to the strict minimum needed for the examples

1. At T, if X is inside Y and Y is inside Z then X is inside Z

ForAll $T, $X, $Y, $Z
    ImplicationLink
        AND
            AtTime(inside($X,$Y), $T)
            AtTime(inside($Y,$Z), $T)
        AtTime(inside($X,$Z), $T)

2. If a small object $X is over $Y and $Y is far from $Z then $X is far from $Z

ForAll
    Implication
        AND
            Small($X)
            Over($X,$Y)
            Far($Y)
        Far($X)

That rule is expressed in a crisp way but again is to be understood in an uncertain way, although we haven't worked out the exact formulae.

The laptop is safe from the rain

A laptop is over the desk in the hotel room, the desk is far from the window.

Note that the truth values are ignored but each concept is to be understood as fuzzy, that is having a PLN Fuzzy Truth Value but the numerical calculation are left out.

Target Theorem

The laptop is far from the window

Far(Window, Laptop)

Axioms

1. The laptop is small

Small(Laptop)

2. The laptop is over the desk

Over(Laptop, Desk)

3. The desk is far from the window

Far(Desk, Window)

Inference Trail

1. using axioms 1, 2, 3 and PLN AND

AND
    Small(Laptop)
    Over(Laptop, Desk)
    Far(Desk, Window)

2. using spatiotemporal rule 2, instantiated with $X = Laptop, $Y = Desk and $Z = Window

Implication
    AND
        Small(Laptop)
        Over(Laptop, Desk)
        Far(Desk, Window)
    Far(Laptop, Window)

3. using the result of previous step as premise with PLN implication rule

Far(Laptop, Window)

Setting the alarm clock at 5am guaranties I'll in the airport on Time

Assessing the probability of being in the airport an hour before my flight, considering that I set my alarm clock at 5am.

Note that to make that example short we make to simplications 1. we consider only probability without confidence 2. the probability is only affected to the event, like getting a cab 5mn after waking up, instead of having an envelop of probability depending on the time I get a cab after waking up (the probability would be low when the time short, say < 5mn, and increase to 1 as the time increase).

Target Theorem

AtTime(inside(self, airport), 6am) <?>

Axioms

1. The alarm clock is set at 5am

AtTime(alarm_clock, 5am) <1>

2. I wake up 5mn after the alarm clock with probability 0.9

ForAll $T
    ImplicationLink <0.9>
        AtTime(alarm_clock, $T)
        AtTime(waking_up, $T+5mn)

3. I grab a cab 25mn after waking up with probability 0.9

ForAll $T
    ImplicationLink <0.9>
        AtTime(waking_up, $T)
        AtTime(grab_a_cab, $T+25mn)

4. I am inside the parking of the airport 30mn after grabing a cab with probability 0.8

ForAll $T
    ImplicationLink <0.8>
        AtTime(grab_a_cab, $T)
        AtTime(inside(self, airport_parking), $T+30mn)

5. The parking of the airport is inside the airport

ForAll $T
    AtTime(inside(airport_parking, airport), $T) <1>

6. The flight is at 7am (that axioms is actually not used)

AtTime(flight, 7am) <1>

Inference Trail

1. Instantiate axiom 2 with $T=5am

ImplicationLink <0.9>
    AtTime(alarm_clock, 5am)
    AtTime(waking_up, 5:05am)

2. Apply axiom 1 as premise of previous inference step

AtTime(waking_up, 5:05am) <0.9>

3. Instantiate axiom 3 with $T=5:05am

ImplicationLink <0.9>
    AtTime(waking_up, 5:05am)
    AtTime(grab_a_cab, 5:30am)

4. Apply the result of step 2 as premise of the previous step

AtTime(grab_a_cab, 5:30am) <0.81>

5. Instantiate axiom 4 with $T=5:30am

ImplicationLink <0.8>
    AtTime(grab_a_cab, 5:30am)
    AtTime(inside(self, airport_parking), 6am)

6. Apply the result of step 4 as premise of the previous step

AtTime(inside(self, airport_parking), 6am) <0.73>

7. Instantiate axiom 5 with $T=6am

 AtTime(inside(airport_parking, airport), 6am) <1>

8. Apply sub-target theorem and previous step (standard probability theory)

AND <0.73>
    AtTime(inside(self,airport_parking), 6am)
    AtTime(inside(airport_parking,airport), 6am)

9. Instantiate spatiotemporal rule 1, with $T=6am, $X=self, $Y=airport_parking and $Z=parking

ImplicationLink <1>
    AND
        AtTime(inside(self,airport_parking), 6am)
        AtTime(inside(airport_parking,airport), 6am)
    AtTime(inside(self,airport), 6am)

10. Apply step 8 as premise of previous step

AtTime(6am, inside(self, airport), 6am) <0.73>

So the probability of being in the airport 1 hour before the flight is 0.73

Susie was at the same place as Jane last week

Suppose Susie and Jane use the same daycare center, but Jane uses it everyday, whereas Susie only uses it when she has important meetings (otherwise she works at home with her child). Suppose Susie sends a message stating that Tuesday she has a big meeting with a potential funder for her business. Inference is needed to figure out that on Tuesday she’s likely to put her child in daycare, and hence (depending on the time of the meeting!) potentially to be at the same place as Jane sometime on Tuesday. To further estimate the probability of the two women being in the same place, one has to do inference based on the times Jane usually picks up and drops off her child, and the time Susie is likely to do so based on the time of her meeting. So: how do we use PLN to infer the truth value of the proposition that Susie was at the same Place as Jane last week?

Target Theorem

Formally, in PLN notation our target theorem looks like:

ThereExists $Place, $TimeInterval1, $TimeInterval2
    AND
        AtTime(AtPlace(Susie, $Place), $TimeInterval1)
        AtTime(AtPlace(Jane, $Place), $TimeInterval2)
        OverlapTime($TimeInterval1, $TimeInterval2)
        During($TimeInterval1, LastWeek)
        During($TimeInterval2, LastWeek)

where atPlace is a predicate that indicates if a given person is at a given place.

Axioms

Axioms Related to Jane

1. “Jane is at the daycare center everyday of the week between 7am and 7:30am and between 16pm and 16:30pm (when she brings and fetch her child).”

1.a)

ForAll $Day
    AND
        IsWeekDay($Day)
        AtTime(AtPlace(Jane, daycare), [$Day:7am, $Day:7:30am])

1.b)

ForAll $Day
    AND
        IsWeekDay($Day)
        AtTime(AtPlace(Jane, daycare), [$Day:16am, $Day:16:30am])

Axioms Related to Susie

2. “When Susie has an important meeting at time interval T, she will be in the daycare center during 30 minutes an hour before the beginning of T and after the end of T”

Implication
    AtTime(ImportantMeeting(Susie), T)
    AND
        AtTime
            AtPlace(Susie, daycare)
            [beginning(T)-1h, beginning(T)-1:30h]
        AtTime
            AtPlace(Susie, daycare)
            [end(T)+1h, end(T)+1:30h]

3. “Susie had an important meeting last Tuesday between 1:30pm and 3:15pm”

AtTime
    ImportantMeeting(Susie)
    [LastTuesday:1:30pm, LastTuesday:3:15pm]

Inference Trail

1. “Susie was at the daycare center Tuesday between 4:15pm and 4:45pm”. Using axioms 2 and 3:

AND
    AtTime
        AtPlace(Susie, daycare)
        [LastTuesday:12:30pm, LastTuesday:1pm]
    AtTime
        AtPlace(Susie, daycare)
        [LastTuesday:4:15pm, LastTuesday:4:45pm]

Then using PLN inference rules to deal with AND

AtTime
    AtPlace(Susie, daycare)
    [LastTuesday:4:15pm, LastTuesday:4:45pm]

2. “Jane was at the daycare center Tuesday between 4:pm and 4:30pm”. Using axioms 1.b

AND
    isWeekDay(Tuesday)
    AtTime
        AtPlace(Jane, daycare)
        [LastTuesday:4pm, LastTuesday:4:45pm]

Then using PLN inference rules to deal with AND

AtTime
    AtPlace(Jane, daycare)
    [LastTuesday:4pm, LastTuesday:4:45pm]

3. Then we can infer an instance of the target theorem using the conclusion of inference step 1 and 3 + other temporal rules to assess the overlap and that the intervals of last Tuesday were last week

AND
    AtTime
        AtPlace(Susie, daycare)
        [LastTuesday:4:15pm, LastTuesday:4:45pm]
    AtTime
        AtPlace(Jane, daycare)
        [LastTuesday:4pm, LastTuesday:4:45pm]
    OverlapTime
        [LastTuesday:4:15pm, LastTuesday:4:45pm]
        [LastTuesday:4pm, LastTuesday:4:45pm]
    During
        [LastTuesday:4:15pm, LastTuesday:4:45pm]
        LastWeek
    During
        [LastTuesday:4pm, LastTuesday:4:45pm]
        LastWeek

4. And the target theorem is reached using step 3 and PLN existential quantifier axioms, by setting

$Place=daycare
$TimeInterval1=[LastTuesday:4:15pm, LastTuesday:4:45pm]
$TimeInterval2=[LastTuesday:4pm, LastTuesday:4:45pm]

and thus concluding

ThereExists $Place, $TimeInterval1, $TimeInterval2
    AND
        AtTime(AtPlace(Susie, $Place), $TimeInterval1)
        AtTime(AtPlace(Jane, $Place), $TimeInterval2)
        OverlapTime($TimeInterval1, $TimeInterval2)
        During($TimeInterval1, LastWeek)
        During($TimeInterval2, LastWeek)