SpreadAct Module of First Working AGI

SpreadAct module of the

First Working AGI Mind in JavaScript

MindForth for robots -- Ghost.pl for webservers

1. Diagram of SpreadAct Mind-Module

A process of spreading activation engenders thought.

  t = time
              |      | |   |      |      | | | |      |
100           |      +------------+------------+      |
              |   cats |   |      |      | | | fish   |
200           +-------------------+-------------------+
              |        |   |      |      | | |        |
300           |        +----------+----------+        |
              |   horses   |      |      | | hay      |
400           +-------------------+--------+          |
              |            |      |      | worms      |
500           |            +------+------+            |
              |         dogs      |      meat         |
            fish                 eat                bugs


2. Algorithm

2.1 Using SpreadAct to answer What-queries.

First InStantiate detects the input of the interrogative 781=WHAT pronoun and sets the $whatcon flag to a positive one ("1"). Then InStantiate also assigns the verb to $qv2psi and the subject of the query to $qv1psi for SpreadAct.

2.2 Using SpreadAct to answer Who-Is or Who-Are queries.

2.3 Using SpreadAct to ask users about a new concept.

2.4 Using SpreadAct to answer Who+Verb+Direct-Object queries.

When a human user asks the Perlmind Strong AI, "Who has a child?", the InStantiate() module detects the input of the 791=WHO concept and sets the $qucon variable to a positive one ("1") as a flag to invoke the special treatment of an input query by the mechanisms of spreading activation in the SpreadAct() module. Once the $qucon flag has been set, if a verb other than 800=BE comes into InStantiate(), the $qvdocon variable is set to a positive one ("1") as a flag for the special treatment in SpreadAct() of an input query composed of the query-word "who" and a verb taking a direct object, as in, "Who makes robots?" The $qv2psi variable is loaded with the @psy concept-number of the verb in the query, so that the SpreadAct() module may search for the particular verb taking a particular direct object in the lifelong knowledge base (KB) of the potentialy immortal Strong AI Mind. Next the $qv4psi variable is set with the concept number of the direct object stated in the input query, so that SpreadAct() may search for, find, and activate the specific combination of a known fact or assertion combining a subject with the particular verb and the particular direct object. The retrieval of the known fact or assertion becomes a response by the AI to the query input by the human user.

2.5 Using SpreadAct to answer Who+Verb+Indirect-Object queries.

2.6 Using SpreadAct to engender a chain of thought after a direct object.


3. Code

# $act 33-48 = consciousness tier where concepts win selection.
# $act 17-32 = subconscious where concepts remain available. 
# $act  1-16 = noise tier below logical association threshold.
sub SpreadAct() {  # http://ai.neocities.org/SpreadAct.html
  PsiDecay();  # 2016may01: reduce conceptual activation in general. 
  if ($qucon > 0 && $qvdocon == 0) {  # 2017-09-26: only for 800=BE who-queries.
    if ($qv1psi > 0) {  # 2017-09-17: if there is an activand subject...
      for (my $i=$t; $i>$midway; $i--) {  # 2017-09-17: search backwards in time.
        my @k=split(',',$psy[$i]);  # 2017-09-17: inspect @psy flag-panel 
        if ($k[1] == $qv1psi && $k[13] > 0) {  # 2017-09-17: require verblock.
          if ($k[1] == $qv1psi && $k[12] == $qv2psi) { # 2017-09-18: if correct verb...
            $k[3] = ($k[3] + 64);  # 2017-09-26: impose an overriding activation.
            $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-09-17
            . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-09-17
          }  # 2017-09-18: end of test for finding both subject and verb of query.
        }  # 2017-09-18: end of test for presence of a k13 $tkb verblock.
      }  # 2017-09-18: end of (for loop) searching for $qv1psi subject concept.
    }  # 2017-09-17: end of test for a positive $qv1psi. 
    return;  # 2018-06-27: skip the remainder of SpreadAct()
  }  # 2017-09-22: end of test of $qucon to indicate processing of a query.
  if ($whatcon > 0) {  # 2017-11-27: for a what-query... 
    $dunnocon = 1;  # 2017-11-27: set positive so long as no answer emerges.
    for (my $i=($t-12); $i>$midway; $i--) {  # 2017-11-27: skip time of query
      my @k=split(',',$psy[$i]);  # 2017-11-27: inspect @psy flag-panel 
      if ($k[1]==$qv1psi && $k[12]==$qv2psi && $k[13]>0) { #2017-11-27: SVO?
        $dunnocon = 0;  # 2017-11-27: even one correct answer disables $dunnocon
        $k[3] = ($k[3] + 32);  # 2017-11-27: impose activation on the found subject.
        if ($qv2psi==840) { $ictus = 50 }  # 2017-12-28: for ConJoin() 310=THAT
        $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-11-27
        . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-11-27
      } else {  # 2017-12-28: if $qv2psi = 840=THINK or 850=KNOW...
        if ($qv2psi==840) {  # 2017-12-28: 840=THINK
          for (my $i=($t-12); $i>$midway; $i--) {  # 2017-12-28: skip time of query
            if ($k[1]==$qv1psi) {  # 2017-12-28: $qv1psi is the subject
              $k[3] = ($k[3] + 48);  # 2017-12-28: impose activation on subject
              $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-12-28
              . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-12-28
              $dunnocon = 0;  # 2017-12-28: a good answer disables $dunnocon
            }  # 2017-12-28: end of test for finding the subject to activate it. 
            if ($k[1]==840) {  # 2017-12-28: 840=THINK
              $k[3] = ($k[3] + 32);  # 2017-12-28: impose activation on 840=THINK
              $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-12-28
              . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-12-28
              $dunnocon = 0;  # 2017-12-28: a good answer disables $dunnocon
            }  # 2017-12-28: end of test for finding the 840=KNOW verb to activate it. 
            if ($k[1]==850) {  # 2017-12-28: 850=KNOW
              $k[3] = ($k[3] + 32);  # 2017-12-28: impose activation on 850=KNOW
              $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-12-28
              . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-12-28
              $dunnocon = 0;  # 2017-12-28: a good answer disables $dunnocon
            }  # 2017-12-28: end of test for finding the 850=KNOW verb to activate it. 
            if ($k[1]==310) {  # 2017-12-28: 310=THAT conjunction
              $k[3] = ($k[3] + 32);  # 2017-12-28: impose activation on 310=THAT
              $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-12-28
              . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-12-28
              $dunnocon = 0;  # 2017-12-28: a good answer disables $dunnocon
            }  # 2017-12-28: end of test for finding 310=THAT to activate it. 
          }  # 2017-12-28: end of for-loop to search for 840=KNOW and 850=THINK.
        } # 2017-12-28: end of treatment of 840=THINK and 850=KNOW
      }  # 2017-12-28: end of test for what-think-query or what-know-query.
    }  # 2017-11-27: end of (for loop) searching for $qv1psi subject-noun concept.
    return;  # 2018-06-27: skip the remainder of SpreadAct()
  } # 2017-11-27: end of test of $whatcon so as to answer a what-query.
  if ($qvdocon > 0) {  # 2017-10-22: for a who+verb+dir.object query... 
    $dunnocon = 1;  # 2017-11-25: set positive so long as no answer emerges.
    for (my $i=($t-12); $i>$midway; $i--) {  # 2017-11-25: skip time of query
      my @k=split(',',$psy[$i]);  # 2017-09-26: inspect @psy flag-panel 
      if ($k[1]==$qv2psi && $k[10]>0 && $k[12]==$qv4psi && $k[13]>0) { #2017-11-25:
        $dunnocon = 0;  # 2017-11-25: even one correct answer disables $dunnocon
          $qv2num = $k[8];   # 2017-10-22: latch onto k8 $num of the response-verb.
          $qv1psi = $k[10];  # 2017-09-26: latch onto k10 $pre as the subject (answer)
          $k[3] = ($k[3] + 32);  # 2017-09-26: impose less than half of subj-inhibition. 
          $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-09-26
          . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-09-26
      }  # 2017-09-26: end of test for presence of a k13 $tkb nounlock.
    }  # 2017-09-26: end of (for loop) searching for $qv2psi verb concept.
    $qucon = 0;  # 2017-09-26: prevent infinite loop?
    if ($dunnocon == 1) { print "I DO NOT KNOW \n"} # 2017-11-25
    for (my $i=$tpu; $i>$midway; $i--) {  # 2018-06-28: search from Time PenUltimate.
      my @k=split(',',$psy[$i]);  # 2017-09-26: inspect @psy flag-panel 
        if ($k[1]==$qv1psi && $k[8]==$qv2num) {  # 2017-10-22: if correct subj & num(ber)
          if ($rsvplock==0) { $rsvplock = $i }  # 2017-10-24: TEST; REMOVE
          $aud = $k[14];  # 2017-09-26: fetch auditory recall tag for Speech()
          Speech();  # 2017-12-08: speak the answer concept, thus activating it.
          last; # 2017-09-26: one utterance is enough.
      }  # 2017-09-26: end of test for subject answer-concept
    }  # 2017-09-26: end of (for loop) searching for the subject answer-concept.
    for (my $i=$t; $i>$midway; $i--) {  # 2017-09-26: search backwards in time.
      my @k=split(',',$psy[$i]);  # 2017-09-26: inspect @psy flag-panel 
      if ($k[1]==$qv1psi && $k[12]==$qv4psi) {  # 2017-09-26: subj. with dir.obj.
        $k[3] = ($k[3] + 64);  # 2017-09-26: impose an overriding activation.
        $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-09-26
        . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-09-2
      }  # 2017-09-26: end of test for subject answer-concept
    }  # 2017-09-26: end of (for loop) searching for the subject answer-concept.
    return;  # 2018-06-27: skip the remainder of SpreadAct()
  }  # 2017-09-26: end of test for who+verb+direct-object query condition. 
  if ($qviocon > 0) {  # 2017-09-26: Segregate portions of SpreadAct() from others.
    return;  # 2018-06-27: skip the remainder of SpreadAct()
  }  # 2017-09-26: end of test for who+verb+indirect-object query condition. 
 if ($hlc eq "en") {  # 2017-12-20: restrict to English until Russsian is ready.
  if ($nucon > 0) {  # 2017-09-22: Segregate portions of SpreadAct() from others.
    $moot = 1;  # 2017-09-22: prevent associative tags within question.
    for (my $i=$t; $i>$midway; $i--) {  # 2017-09-22: search backwards in time.
      my @k=split(',',$psy[$i]);  # 2017-09-22: inspect @psy flag-panel 
        if ($k[1] == 781 && $k[13] == 0) {  # 2017-09-22: WHAT without verblock.
          $aud = $k[14];  # 2017-09-22: fetch auditory recall tag for Speech()
          Speech();  # 2017-09-22: speak the 781=WHAT
          last; # 2017-09-22: one utterance is enough.
      }  # 2017-09-22: end of test for 781=WHAT with no overriding verblock.
    }  # 2017-09-18: end of (for loop) searching for 781=WHAT concept.
    for (my $i=$t; $i>$midway; $i--) {  # 2017-09-22: search backwards in time.
      my @k=split(',',$psy[$i]);  # 2017-09-22: inspect @psy flag-panel 
        if ($k[1]==800 && $k[7]==3 && $k[8]==$num) {  # 2017-09-22: dba=3rd num=?
          $aud = $k[14];  # 2017-09-22: fetch auditory recall tag for Speech()
          Speech();  # 2017-09-22: speak the 800=BE
          last; # 2017-09-22: one utterance is enough.
      }  # 2017-09-22: end of test for 800=BE
    }  # 2017-09-18: end of (for loop) searching for correct form of 800=BE.
    for (my $i=$t; $i>$midway; $i--) {  # 2017-09-22: search backwards in time.
      my @k=split(',',$psy[$i]);  # 2017-09-22: inspect @psy flag-panel 
        if ($k[1]==$qusub) {  # 2017-09-22: look for the new concept.
          $aud = $k[14];  # 2017-09-22: fetch auditory recall tag for Speech()
          Speech();  # 2017-09-22: speak the new concept
          last; # 2017-09-22: one utterance is enough.
      }  # 2017-09-22: end of test for new concept
    }  # 2017-09-18: end of (for loop) searching for the new concept.
    $moot = 0;  # 2017-09-22: finish preventing associative tags within question.
    return;  # 2018-06-27: skip the remainder of SpreadAct()
    # 2017-09-26: $impetus may be used in future to let Volition() ask questions.
  } # 2017-09-22: end of test of $nucon so as to cause asking of a question. 
 }  # 2017-12-20: end of restriction to English pending code for Russian. 
  if ($actpsi > 0 && $qucon == 0) {  # 2017-09-29: not with who-queries
    for (my $i=$t; $i>$midway; $i--) {  # 2016apr12: search backwards in time.
      my @k=split(',',$psy[$i]);  # 2016apr11: inspect @psy flag-panel
      if ($k[1] == $actpsi && $k[12] > 0) { $seqpsi = $k[12] } #2017-06-08: if seq, seqpsi
      if ($k[1] == $actpsi && $k[13] > 0) {  # 2017jun8: require verblock.
        $k[3] = ($k[3] + 32);  # 2017jun08: impose less than half of subj-inhibition. 
        $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6]," # 2017-06-08: $tru, $mtx
        . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-06-08
      }  # 2016apr12: end of diagnostic test
    }  # 2016apr11: end of (for loop) searching for actpsi concept.
  }  # 2016apr11: end of test for a positive $actpsi.
  $actpsi = 0;  # 2016apr12: reset for safety. 
  $qucon = 0;   # 2017-09-17: reset for safety.
  $qvdocon = 0; # 2017-09-26: reset for safety.
  $qviocon = 0; # 2017-09-26: reset for safety.
}  # 2018-06-27: SpreadAct() returns to direct-object area of EnVerbPhrase().


4. Troubleshooting and Robotic Psychosurgery

4.1.a. Symptom: (Something goes wrong.)
4.1.b. Solution: (AI Mind Maintainer devises solution.)

5. Variables

$actpsi -- psi concept from which activation is to be spread.


6. Resources

Please see

http://mind.sourceforge.net/spredact.html

http://www.sixdegreesofwikipedia.com


7. AiTree of First Working AGI Mind-Modules




Return to top; or to
javascript subreddit for AI Mind discussion;
Forth subreddit and robotics subreddit for MindForth discussion;
Perl subreddit for ghost.pl AI Mind Maintainers.