iduartgomez / simag

An experimental, under development, agent-based AI framework
Mozilla Public License 2.0
5 stars 2 forks source link

Evaluate assertions at time intervals [time calculus] #5

Closed iduartgomez closed 4 years ago

iduartgomez commented 7 years ago

Add new synthax to allow evaluation of truth values of an statement during time intervals

iduartgomez commented 5 years ago

Partially implemented with the merge of f28cc23

iduartgomez commented 5 years ago

For future self reference... I added most functionality but having problems with some hideous bug. In trying to find the problem I fixed a couple problems along the way specially with the parameter substitution and unification iterator, so now the behavior is consistent (which is good news and this rules out concurrency problems most likely).

This test fails:

// Test 02
    let test_02 = "
        (( let x, y, t1: time=\"2014-07-05T10:25:00Z\", t2: time)
            ( ( dog[x,u=1] && meat[y,u=1] && fat(t2=time)[x,u=1] && fn::time_calc(t1<t2) )
            := fn::eat(time=t1)[y,u=1;x]
            )
        )
        ( dog[$Pancho,u=1] )
        ( meat[$M1,u=1] )
        ( fat(time=\"2015-07-05T10:25:00Z\")[$Pancho,u=1] )
    ";
    let mut rep = Representation::new();
    rep.tell(test_02).unwrap();
    let q02_01 = "(fn::eat(time='now')[$M1,u=1;$Pancho])";
    let result = rep.ask(q02_01).unwrap().get_results_single();
    assert_eq!(result, Some(true));

The (consistant) trace for the execution is:

[2019-10-20T10:55:29.057517380Z TRACE simag_core::agent::kb::tracing] Start querying for: eat[$M1,u=Some(1.0);$Pancho;None]
[2019-10-20T10:55:29.057798722Z TRACE simag_core::agent::kb::tracing] Querying sentence: Sentence(id:133197473295513508,Conditional(n0:Conjunction(n0:Predicate(dog),n1:Conjunction(n0:Predicate(meat),n1:Conjunction(n0:Predicate(fat),n1:Predicate(time_calc)))),n1:Predicate(eat)))
[2019-10-20T10:55:29.058736597Z TRACE simag_core::agent::kb::tracing] Params (hash: 15256099184944921114): [(x: Normal, $Pancho), (y: Normal, $M1)]
[2019-10-20T10:55:29.059505719Z TRACE simag_core::agent::kb::tracing] Start querying for: eat[$M1,u=Some(1.0);$Pancho;None]
[2019-10-20T10:55:29.059640089Z TRACE simag_core::agent::kb::tracing] Querying sentence: Sentence(id:133197473295513508,Conditional(n0:Conjunction(n0:Predicate(dog),n1:Conjunction(n0:Predicate(meat),n1:Conjunction(n0:Predicate(fat),n1:Predicate(time_calc)))),n1:Predicate(eat)))
[2019-10-20T10:55:29.060370173Z TRACE simag_core::agent::kb::tracing] Params (hash: 15256099184944921114): [(x: Normal, $Pancho), (y: Normal, $M1)]

Is run twice (why? it shouldn't), and after the first unification result should be 'true'.

iduartgomez commented 4 years ago

Fixed by #10