SpreadAct Spreading Activation Module of the

English and Russian bilingual ghost.pl AI in Perl

Mens Latina in Latin -- MindForth for robots


1. Diagram of the SpreadAct Spreading Activation 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. Purpose of the SpreadAct Spreading Activation Module

The purpose of SpreadAct is to spread activation from one concept to another concept or from one idea to another idea.


3. Algorithm of the SpreadAct Spreading Activation Mind-Module

3.A 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.

3.B Using SpreadAct to answer Who-Is or Who-Are queries.

3.C Using SpreadAct to ask users about a new concept.

3.D 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.

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

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


4. Code of SpreadAct() from ghost302.pl AI source code in Perl


# $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. 
  # 2018-11-04: segment of SpreadAct() activates a prepositional phrase.
  if ($tselp > 0 && $prep > 0 && $wherecon == 0) {  # 2018-11-04: for prepositional phrase
    my @k=split(',',$psy[$tselp]);  # 2018-11-04: examine the @Psy concept array...
    $tselo = $k[13];  # 2018-11-04: time of selection of object of preposition.
    $aud = $k[14];  # 2018-11-04: fetch the $aud tag for sake of Speech()
    if ($aud > 0) { Speech() }  # 2018-11-04: speak the preposition.
    EnArticle();  # 2018-11-04: say "A" or "THE" before object of [preposition.
    @k=split(',',$psy[$tselo]);  # 2018-11-04: examine the @Psy concept array...
    $aud = $k[14];  # 2018-11-04: fetch the $aud tag for sake of Speech()
    if ($aud > 0) { Speech() }  # 2018-11-04: speak the object of the preposition.
    $aud = 0;    # 2018-11-04: reset for safety.
    $prep = 0;   # 2018-11-04: reset for safety.
    $tselo = 0;  # 2018-11-04: reset for safety.
    $tselp = 0;  # 2018-11-04: reset for safety.
    return;  # 2018-11-04: skip the remainder of SpreadAct()
  }  # 2018-11-04: end of test for time-point and concept-number of preposition.

  # 2018-11-01: segment of SpreadAct() responds to where-queries.
  if ($wherecon == 1)  {  # 2018-11-01: if answering a where-query...
    if ($qv1psi > 0) {  # 2018-11-01: if there is an activand subject...
      for (my $i=$tpu; $i>$midway; $i--) {  # 2018-11-01: search backwards in time.
        my @k=split(',',$psy[$i]);  # 2018-11-01: examine the @Psy concept array...
        if ($k[1] == $qv1psi && $k[13] > 0) {  # 2018-11-01: require verblock.
          if ($k[1]==$qv1psi && $k[12]==$qv2psi) {  # 2018-11-01: if correct verb
            $k[3] = ($k[3] + 256);  # 2018-11-01: impose an overriding activation.
            $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"
            . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2018-11-01
          }  # 2018-11-01: end of test for finding both subject and verb of query.
        }  # 2018-11-01: end of test for presence of a k13 tkb verblock.
      }  # 2018-11-01: end of (for loop) searching for $qv1psi subject concept.
    }  # 2018-11-01: end of test for a positive $qv1psi. 
    return;  # 2018-11-01: skip the remainder of SpreadAct()
  }  # 2018-11-01: end of test for a positive "$wherecon".

  # 2018-11-01: segment of SpreadAct() responds to who-queries.
  if ($whocon > 0 && $qvdocon == 0) {  # 2018-09-30: 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],"
            . "$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. 
    $whocon = 0;  # 2019-03-30: reset to prevent carry-over.
    return;  # 2018-06-27: skip the remainder of SpreadAct()
  }  # 2017-09-22: end of test of $qucon to indicate processing of a query.

  # 2018-11-01: segment of SpreadAct() responds to what-think-queries.
  if ($whatcon > 0 && $qv2psi==886) {  # 2018-12-10: for a what-think query...
    for (my $i=$tpu; $i>$midway; $i--) {  # 2018-09-29: exclude current-most input.
      my @k=split(',',$psy[$i]);  # 2018-09-29: inspect @psy flag-panel 
      if ($k[1]==$qv1psi && $k[13]==0 && $qv2psi == 886) {  # 2018-12-10: 886=THINK
        $actpsi = 0;  # 2018-09-29: prevent other calls to SpreadAct; TEST
         $k[3] = ($k[3] + 32);  # 2018-09-30: impose activation on the found subject.
         $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"
         . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2018-09-29
      }  # 2018-09-29: end of first test, for match with query-subject qv1psi
      if ($k[1]==886) {  # 2018-12-10: 886=THINK
         $k[3] = ($k[3] + 64);  # 2018-12-10: impose activation on 886=THINK
        $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"
        . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-11-27
      }  # 2018-12-10: end of test for 886=THINK
    }  # 2018-09-29: end of (for loop) searching for $qv1psi subject-noun concept.
    return;  # 2018-09-29: skip the remainder of SpreadAct()
  } # 2018-09-29: end of test of $whatcon so as to answer a what-query.

  # 2018-11-01: segment of SpreadAct() responds to what-queries.
  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=$tpu; $i>$midway; $i--) {  # 2018-09-29: search backwards in time.
      my @k=split(',',$psy[$i]);  # 2018-09-29: inspect @psy flag-panel
      if ($k[1]==$qv1psi && $k[12]==$qv2psi) {  # 2018-09-30: subj. with query-verb
        $dunnocon = 0;  # 2018-09-30: even one correct answer disables $dunnocon
        if ($k[3] < 64) {  # 2019-01-28: avoid runaway activation
          $k[3] = ($k[3] + 24);  # 2019-01-28: impose a medium activation.
        }  # end of test to prevent excessive activation.
        $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"
        . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2018-09-29
      }  # 2018-09-29: end of test for subject answer-concept
    }  # 2017-11-27: end of (for loop) searching for $qv1psi subject-noun concept.
    $catsubj = $qv1psi;  # 2019-01-28: chain-subject to be omitted for sake of "AND"
    $catverb = $qv2psi;  # 2019-01-28: chain-verb to be omitted for sake of "AND".
    return;  # 2018-06-27: skip the remainder of SpreadAct()
  } # 2017-11-27: end of test of $whatcon so as to answer a what-query.

  # 2018-11-01: segment of SpreadAct() responds to who+verb+dir.object queries.
  if ($qvdocon > 0) {  # 2017-10-22: for a who+verb+dir.object query... 
    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],"
          . "$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?
    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) {  # 2018-12-24: if subject is found...
        if ($k[12]==$qv2psi) {  # 2018-12-24: if "seq" is the query-verb...
          $k[3] = ($k[3] + 64);  # 2017-09-26: impose an overriding activation.
          $k[3] = ($k[0] + $k[3]);  # 2018-12-24: favor engrams with high "tru" value. 
          $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"
          . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-09-2
        }  # 2018-12-24: end of test for query-verb as "seq" of the query-subject.
      }  # 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. 

  # 2018-11-01: segment of SpreadAct() will respond to who+verb+indir.object queries.
  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. 

  # 2018-11-01: segment of SpreadAct() asks questions about new concepts.
  if ($hlc == 1) {  # 2018-09-27: 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; # 2018-09-14: LEAVE in Forth; "break" in JavaScript to exit from loop. 
        }  # 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()
          $bias = 5;  # 2018-11-15: assume that the new concept is a noun.
          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. 

  # 2018-11-01: segment of SpreadAct() dealing with basic spreading of activation.
  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[10] > 0) {  # 2019-03-30: if "pre" exists...
        $prepsi = $k[10];  # 2019-03-30: briefly hold onto "pre" as $prepsi.
        $prepsi = 0;  # 2019-03-30: reset to prevent carry-over.
      }  # 2019-03-30: end of test for a "pre" associated with the $actpsi concept.
      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.
#      if ($k[6] == 5) {  # 2019-01-22: activate only pos=5 nouns...
       if ($k[6] == 5 || $k[6] == 7) {  # 2019-01-22: activate nouns or pronouns
#       $k[3] = ($k[3] + 32);  # 2017jun08: impose less than half of subj-inhibition. 
#       $k[3] = 24;  # 201-01-22: spread not a relative but an absolute activation.
#       $k[3] = ($k[3] + 24);  # 2019-06-03: spread a relative activation
        $k[3] = ($k[3] + 32);  # 2019-06-03: spread a relative activation
#       $k[3] = ($k[3] + 64);  # 2019-01-19: change of subject requires high activation.
#       $k[3] = ($k[3] + 96);  # 2019-01-19: change of subject requires high activation.
#       $k[3] = ($k[3] + 128); # 2019-01-19: change of subject requires high activation.
#       $k[3] = ($k[3] + 256); # 2019-01-19: change of subject requires high activation.
        $psy[$i]="$k[0],$k[1],$k[2],$k[3],$k[4],$k[5],$k[6],"
        . "$k[7],$k[8],$k[9],$k[10],$k[11],$k[12],$k[13],$k[14]"; # 2017-06-08
       }  # 2019-01-22: end of test of k6 part-of-speech of actpsi concept.
      }  # 2016apr12: end of diagnostic test
    }  # 2016apr11: end of (for loop) searching for actpsi concept.
  }  # 2016apr11: end of test for a positive $actpsi.
  $act = 0;     # 2019-01-22: reset for safety.
  $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-11-01: SpreadAct() returns to various calling modules.

5. Variables

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

$aud -- is an associative tag leading to the typically most recent engram of a word stored in the @ear array of the auditory memory channel.

$bias -- a variable holding the numeric value of the part of speech (POS) expected to be input next and parsed next on the basis of preceding parts of speech.

$catsubj -- conCATenated (chained) SUBJect flag for syncopating sentences, that is, for joining and shortening sentences.

$catverb -- conCATenated (chained) VERB flag for syncopating sentences, that is, for joining and shortening sentences.

$dunnocon -- is a flag used in SpreadAct() to permit the AI Mind to respond to a who+verb+object query with "I DO NOT KNOW" if no correct answer is found.

$hlc -- human-language code; 1=en; 2=de; 3=ru. Eventually may be ubject to override by the $engov or $degov or $rugov flag, so that thinking in one governing language will not be switched into another language by a single word of a different language. Since SpreadAct is more the module of a central nervous system than the module of a linguistic superstructure for any particular language, over time different parts of SpreadAct will need to be segregated by language. There need not be a particular SpreadAct module for each human language coexisting with other languages in the AI Mind. Some SpreadAct code-segments may eventually deal with the spread of activation from concepts in one language to concepts in another language, especially for purposes of Machine Translation (MT).

$moot -- is a flag to prevent the formation of associative tags during mental operations which are not truly a part of cognition, such as the processing of an input query, the formation of a silent inference, or the creation of an output query.

$nucon -- -- new-condition – segregates SpreadAct() code to respond to the passage through NewConcept of an unknown word by asking the user a question about the new concept being learned by the AI Mind. This feature may require further work to turn it into a low-priority function that operates only when no more pressing mental activity is predominating.

$prep -- a preposition used in the EnPrep mind-module for English prepositions.

$prepsi -- is the identifier of a "pre" concept for the purpose of spreading activation sideways from a direct object to its governing verb and then further sideways to the subject of the verb. This process may be tested by an AI coder or by an AI Mind Maintainer by entering one noun into the running AI software to see if some other noun is output as part of a remembered idea involving the noun being tested for. Activation spreading sideways is an important feature for the evolution of AI Minds able to ruminate endlessly and able to think interminably about all possible subjects contained as an accumulation of concepts in the AI knowledge base.

$qucon -- query-condition – segregates SpreadAct() code to respond to the input of who-queries.

$qv1psi -- concept for SpreadAct to seek as a subject, so that the AI will try to remember knowledge about the concept.

$qv2psi -- concept for SpreadAct to seek as a verb, so that the AI may remember ideas containing the same verb.

$qvdocon -- query-condition for who+verb+direct-object – segregates SpreadAct() code to respond to input queries similar in form to "Who makes robots?"

$qviocon -- query-condition for who+verb+indirect-object – segregates SpreadAct() code to respond to input queries in a form like "To whom does God give help?"

$tselo -- time of selection of object can be used to insert associative tags linking the preposition itself and its object.

$tselp -- Time of SELection of Preposition - is used in the EnPrep English-preposition module to make sure by calculation that a verb being sought as used with a preposition is in close temporal proximity to the preposition, so that a query may be answered correctly with a response that mentions the query-subject qv1psi and the query-verb qv2psi and the selected preposition at the beginning of a prepositional phrase.

$whatcon (what-condition) -- SpreadAct() flag for the condition of answering a what-query.

$wherecon -- a flag for the condition of answering a where-query. The flag is set to a positive one ("1") if the word "where" passes through the OldConcept module, and serves as a trigger for the EnThink module to call the SpreadAct module, which imposes activation upon the subject-concept whose whereabouts are being sought. Further development must include searching for prepositions likely to disclose where the subject is to be found.

$whocon -- flag for condition of answering a who-query. The InStantiate module sets whocon to a positive one ("1") when the input of the interrogative pronoun "who" is detected.


6. Troubleshooting and Robotic Psychosurgery

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


7. Resources

Please see

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

http://www.sixdegreesofwikipedia.com


8. AiTree of First Working Conceptual AI Mind-Modules


Return to top; or to
Tiananmen Square IV VI
javascript subreddit for AI Mind discussion;
Forth subreddit for MindForth discussion;
Perl subreddit for ghost.pl AI Mind Maintainers.
http://old.reddit.com/r/ControlProblem -- NOT SOLVED.
http://en.wikipedia.org/wiki/Natural_language_understanding -- solved.
Iskusstvenny Intellekt Programming Journal for Artificial Intelligence in Russian Language.
Converting ancient Latin AI into modern Russian AI
http://ai.neocities.org/Dushka.html -- tutorial Russian AI;
If you have any questions about the First Working AGI, please Join the Discussion.
Joint Artificial Intelligence Center (JAIC) -- the AI Manhattan Project.
Subject to change without notice.
Many thanks to NeoCities.
http://neocities.org/blog
http://trollheaven.blogspot.com