AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

issue with propagation in custom query
 
 

I seem to have to create a fact with (s member o) in order to get propagate to work in phase 3 of a query. The doc in query.txt states that the propagate can use a any tagset I want but my experience is that the propagate only works if there are (s member o) facts.

My scenario:

I have goals which can have subgoals which in turn can have subgoals.
goal1 requires subgoal2 and subgoal3. Subgoal2 requires transgoal22, etc.

given goal1 I want to get back subgoal2, subgoal3, and transgoal22 since all are required to accomplish the goal.

My Example:
Given facts:

(~goal1 member ~gfgoals) (~subgoal2 member ~gfgoals) ( ~subgoal3 member ~gfgoals ) (~transgoal22 member ~gfgoals)
(~
subgoal2 requiredby ~goal1) (~transgoal22 requiredby ~subgoal2) (~subgoal3 requiredby ~goal1
queryextended-required-topics "1oQ 2'requiredby.t 3'member.t 4~gfgoals.t: queue o : match v2 o1 <2 : walk ss V3 O4" 

only produces:(~subgoal2 member ~gfgoals) ( ~subgoal3 member ~gfgoals )

I thought the <2 in phase 3 of the query would say “for each fact in the phase 2 queue, propagate from object to subject where the verb is tagged in group 2 (requiredby).

however, if I add the following facts to the mix

(~subgoal2 member ~goal1) (~transgoal22 member ~subgoal2) (~subgoal3 member ~goal1

and change the propagate to use ‘member’ instead of ‘requiredby’

queryextended-required-topics "1oQ 2'requiredby.t 3'member.t 4~gfgoals.t: queue o : match v2 o1 <3 : walk ss V3 O4" 

I get the transient fact also
(~subgoal2 member ~gfgoals) ( ~subgoal3 member ~gfgoals ) ( ~transgoal22 member ~gfgoals)

I understand why the second query works. Can anyone tell me why my propagate using ‘requiredby’ verb does not work?

Stephen G.

 

 

 
  [ # 1 ]

the propagate mechanism in phase 3 seems to not make sense.


GIVEN FACTS:

86372: ( subtopic2 member topic1 )
86381: ( transtopic22 member subtopic2 )
86375: ( subtopic3 member topic1 )
86378: ( subtopic3 member topic2 )

86371: ( subtopic2 requiredby topic1 )
86380: ( transtopic22 requiredby subtopic2 )
86374: ( subtopic3 requiredby topic1 )
86377: ( subtopic3 requiredby topic2 

I want

from topic 2  ( subtopic3 requiredby topic2 )

from topic 1   ( subtopic2 requiredby topic1 )
                    ( transtopic22 requiredby subtopic2 )
                    ( subtopic3 requiredby topic1 )


regardless of the propagate arrow
# query: learn-propagate “1oQ 2’requiredby.t 3’member.t 4~gfgoals.t: queue o : match v2 <3 “
# query: learn-propagate “1oQ 2’requiredby.t 3’member.t 4~gfgoals.t: queue o : match v2 >3 “

I am getting….

for topic 2 ( subtopic3 requiredby topic2 )
        ( subtopic3 requiredby topic1 )
        ( subtopic2 requiredby topic1 )
        ( transtopic22 requiredby subtopic2 )

for topic 1 ( subtopic3 requiredby topic1 )
        ( subtopic2 requiredby topic1 )
        ( subtopic3 requiredby topic2 )
        ( transtopic22 requiredby subtopic2 )\r\n


Here is info from the :trace query

##### propagate up ####################
@@@ Control2 queue use:
@@@ 
Control3 match requirements<3
 verb must be 
#2  propogate on verb #< Start processing loop
86379: ( subtopic3 usedby topic2 )
86378: ( subtopic3 member topic2 )

 
propogate

(topic2=>)  subtopic3+
(
subtopic3=>)  topic1+
86377: ( subtopic3 requiredby topic2 )
    
Found:86377: ( subtopic3 requiredby topic2 x0 )
86385: ( subtopic-o2 usedby topic1 )
86384: ( subtopic-o2 member topic1 
######### propagate down ######################
@@@ Control3 match requirements>3
 verb must be 
#2  propogate on verb #> Start processing loop
86379: ( subtopic3 usedby topic2 )
86378: ( subtopic3 member topic2 )

 
propogate

(topic2=>)  subtopic3+
(
subtopic3=>)  topic1+
86377: ( subtopic3 requiredby topic2 )
    
Found:86377: ( subtopic3 requiredby topic2 x0 )
86385: ( subtopic-o2 usedby topic1 )
86384: ( subtopic-o2 member topic1 

I don’t understand why the propagate is grabbing anything about topic1 when we query about topic 2. I would think that the propagate would do go from topic2 (object) -> subtopic3 (subject) and stop because there is no facts with subtopic3 as an object.

Likewise, I should get the transient33 from topic 1 via topic1 (object) -> subtopic2 (subject) -> subtopic2 (object) -> transtopic22 (subject)

 

 
  [ # 2 ]

Looking into this more. What seems to be happening is that the propagate doesn’t work like the documentation seems to say (LIVEDATA/queries.txt).

For phase 3 it says

< > = propogate outward from queued item - < means propogate up/left-to-right   > means propogate down/right-to-left (subject)

The examples later in queries.txt add

# Find the fact that leads to object which is a concept - propogate upwards from subject until you get to a fact that leads to the object concept
# given: (soap member ~hygiene_items) and (~hygiene_item member ~personal_items) and (~personal_items member ~drugstore) and (~drugstore member ~storetypes)
# find (~drugstore member ~storetypes) given  ^query(up2set soap ? '~store_type 10 )   - ie, what kind of store sells soap 

I took the two things to mean that it would examine each fact in the queue and if it found the propagate verb it would use it to follow up (o->s) or down (s->o) to gather new facts to add to the queue for processing.

That is not what is happening!

What is happening is it sees the propagate verb and then tags the subject of that fact and adds it, and the things it belongs to via ‘member’, to the marked queue just as if you had done it in phase1. This is nothing like the example’s suggestion of walking the hierarchy of facts up or down based upon the propagate verb. The examples work only because they are using the magic verb ‘member’. If you changed the verb ‘member’ in the sample to ‘belongingverb’ the sample won’t work.

This fits with my results above. Since I am using queue o in phase 2 and (subtopic3 member topic1) exists, topic1 gets added to the queue just like topic2 was.

Furthermore, looking at the code in infer.cpp I find these fragments:

/**
this is where the phase 3 propagate is interpreted
there is no flag set (or used) depending on '<' vs. '<'
^^/
// around line 1065
case '<':  case '>': 
   if (control[1] == '=') // range check
   {
    if (*control == '<')
    {
     rangelow = atof(propogate);
     field = control[2];
    }
    else
    {
     rangehigh = atof(match);
     field = control[2];
    }
    control += 2;
    break;
   }


   if (trace & TRACE_QUERY  && CheckTopicTrace()) Log(STDUSERLOG,(char*)" propogate on verb #%c ",*control);
   propogateVerb = baseMark + (*++control - '0'); //   label of verbs to propogate on
   break;


/**
this is the code where the propagate verb is matched
there does not seem to be any up or down or any actual use of the verb other than for matching
/**
// around line 1409
   else if (!match && propogateVerb && V->inferMark == propogateVerb) // this is not a fact to check, this is a fact to propogate on
   {
    if (trace & TRACE_QUERY  && CheckTopicTrace()) 
    {
     Log(STDUSERLOG,(char*)"\r\n propogate ");
     Log(STDTRACETABLOG,(char*)"");
    }
    if (G->flags & MARKED_FACT) {;} // stored this fact, stop propogation
    else if (AddWord2Scan(QUEUE,OUTGOING,INCOMING,0,0)) SetFactBack(OTHER,INCOMING);  // add object onto queue and provide traceback
    if (trace & TRACE_QUERY  && CheckTopicTrace()) 
    {
     Log(STDUSERLOG,(char*)"\r\n");
     Log(STDTRACETABLOG,(char*)"");
    }
   }
   if (baseOffset == 3) break; // resume with next fact in q rather than any chaining
 

/**
    AddWord2Scan() is a side effect function that is used in phase 1 and 
    the QUEUE flag puts the Incoming word into the queue
**/ 
 

 
  [ # 3 ]

Bruce,

Would you make the propagate in phase 3 work like the examples in queries.txt imply?

Can we have the system walk up and down on these facts:

(nail partof toe) (toe partof foot) (foot partof leg) (leg partof body) (body partof animal)
(nail partof finger) (finger partof hand) (hand partof arm) (arm partof body)

QUERYconstituent-parts " 1oQ 2'partof : queue o : v2 <2 "
^queryconstituent-parts ? ? leg)
====> (
nail partof toe) (toe partof foot) (foot partof leg)

^
queryconstituent-parts ? ? body)
====> (
nail partof toe) (toe partof foot) (foot partof leg)(nail partof finger) (finger partof hand) (hand partof arm

and

QUERYpart-belongs-to " 1sQ 2'partof : queue s : v2 >2 "
^querypart-belongs-to leg ? ?)
======> (
leg partof body) (body partof animal)

^
querypart-belongs-to nail ? ?)
======> 
returns all of the given facts above
 

 
  login or register to react