Abstract:
An incremental forward-chaining reasoning rule based system is used where data tuples and rules can be inserted and deleted in runtime. The example method does not require storing or calculating a dependency tree in order to re-reason new implicit tuples. All tuples are associated with an inference counter to provide an efficient delete operation for tuples, without the need of re-calculate existing reasoning results.

Description:
FIELD 
     An exemplary embodiment relates to semantic web in a very general level. More specifically it belongs to a field of expert systems, especially to runtime forward-chaining reasoning method utilization of data tuples. 
     An exemplary embodiment relates also to a system that uses the method in the system and/or a system element, thereof. The exemplary embodiment relates also to use of such system elements. In other words, the exemplary embodiments of the invention are related to an expert system, a system element of knowledge representation system (KR) and a semantic web system and to methods for inferencing more data from explicitly given data using a set of rules. Rule processing also shares common characteristics with traditional formal description logic languages. 
     BACKGROUND 
     The Semantic Web is considered as an extension of the World Wide Web having information linked up in such a way as to be easily processable by machines. The Semantic Web is generally built on syntaxes which use URIs (Universal Resource Identifier) to refer data, usually in triple based structures, like RDF (Resource Description Framework). Information about the data, called metadata, is something that benefits especially from reasoning. Inferred metadata often reduces required human interaction and can also help with interoperability issues faced when combining or utilizing different data sources at the same time. 
     In the Semantic Web, rules about the data are often expressed as ontologies that describe the characteristics of the data by giving a shared vocabulary to express knowledge. Such ontology languages are for example Web Ontology Language (OWL) and RDF Schema (RDFS). 
     The delete operation is often seen as not being part of the Semantic Web systems, mostly because of the open world subsumption where everything is expected to be true unless stated otherwise. The subsumption makes deleting of a fact pointless, as the operation will not make the fact false. In real application use cases in most application domains, the delete operation can be seen as “undoing the insertion of the fact”. With this definition, the delete operation must also “undo” the inference triggered by the inserted fact. This kind of behavior is needed, for example, when correcting erroneous data or when the data has changed over time. 
     An Expert System 
     An Expert System is considered to be a computer program structure that, when executed, uses symbolic knowledge and inference to reach conclusions (Mercadal, 1990, ss. 96-97). It derives most of its power from its knowledge. The key components of an expert system are an inference engine and a knowledge base. The separation of control (the inference engine) from knowledge (knowledge base) is a hallmark of an expert system. Other components of an expert system include a user interface, a knowledge-acquisition module, and an explanatory interface. Data tuples and horn clause rules as such are used in known expert systems. 
     Forward Chaining 
     The forward chaining inference is one of the two main methods of reasoning when using inference rules as such. The opposite of forward chaining is backward chaining. Forward chaining reasoning starts from the available tuples and the rules (the antecedent) and produces more data tuples (the consequent). Forward chaining suits well in reasoning systems where large number of data queries are made concurrently and query performance is important as all inferencing takes place together with data modification operations. 
     In forward chaining inference the most common strategy is to use total materialization where all implicit tuples are inferred into and from the tuple space during data modification operations. 
     One commonly used inference algorithm is the Rete algorithm (Forgy, 1979) that provides a generalized logical description of an implementation of functionality responsible for matching data tuples against rules by creating and maintaining a network of nodes consisting of rules and facts. As it is suitable for relatively small datasets with highly computational rules, it scales poorly when the data size increases. Also the working memory requirements are high as the whole Rete network must be kept in memory for maximum performance. 
     Decision tree learning, used in statistics, data mining and machine learning, uses a decision tree as a predictive model which maps observations about an item to conclusions about the item&#39;s target value. In these tree structures, leaves represent class labels and branches represent conjunctions of features that lead to those class labels. Similarly in reasoning, the decision tree branches are combinations of implicit or explicit tuples with a rule that produces implicit tuples the leaf nodes present. Use of decision trees leads to a computational complexity that can lead into performance and scalability issues with larger data sets and with complex rules. Also memory requirements are high as the decision tree must be stored and kept accessible all the time. 
     Known Methods for Delete 
     The most common approach for implementing a delete operation in the Semantic Web is to remove inferred tuples and re-infer all inferred tuples again. This approach may be valid in systems where data changes rarely and modifications to the data are mainly done in a batch operation, for example once a day. The time spent for re-inference can be lowered by partitioning the data and re-inferencing only the corresponding partitions, but it still may take a long time preventing read operations to occur simultaneously. For operational data that changes constantly this approach is intolerable as it requires exclusive write access to the tuple space and thus restricts concurrent queries and may take a long time to finish. 
     BRIEF SUMMARY OF EXEMPLARY EMBODIMENTS 
     Embodiments described below are combinable in suitable part. 
     A Runtime forward-chaining reasoning method of data tuples and/or rules to be inserted and/or deleted according to an exemplary embodiment comprises: keeping record of inference counters for each data tuple to provide a delete operation that does not require re-calculation of tuples inferred earlier. 
     The method according to an exemplary embodiment comprises re-running the method every time the set of explicit data tuples or rule set is changed. 
     The method according to an exemplary embodiment comprises at least one of the following: insertion of a tuple, deletion of a tuple, insertion of a rule, deletion of a rule. 
     The method according to an exemplary embodiment comprises changes of tuples and/or rules being arranged to be inputted so that they avoid re-inference of an existing implicit tuple. 
     The method according to an exemplary embodiment comprises inferring all implicit tuples when an ensemble of all explicit data tuples and/or an ensemble of all explicit rules have/has been inserted into the system. 
     The method according to an exemplary embodiment comprises making accessible at least one of the tuples of all explicit data tuples by using the terms of tuple pattern search. 
     The method according to an exemplary embodiment comprises loading a sub-ensemble of all implicit or explicit data tuples into the working memory used by the system. 
     The method according to an exemplary embodiment comprises at least one of the following: 
     evaluating sequentially at least one rule of the rules in the system, 
     inserting resulting implicit tuples, 
     deleting resulting implicit tuples and 
     updating inference counters. 
     The method according to an exemplary embodiment comprises a variable substitution for tuple pattern searches to search relevant tuples for any of the operations of an embodiment. 
     The method according to an exemplary embodiment comprises a selection of the appropriate existing rules to be evaluated. 
     The method according to an exemplary embodiment comprises identifying a number of loops and/or repeating the evaluation until the system will not change anymore. 
     The method according to an exemplary embodiment comprises stopping recursion of a tuple as a response to an initiative of observation of having the same explicit tuple and rule combination being processed already. 
     The method according to an exemplary embodiment comprises distributing at least one method step into another processing node than the executing node before distributing. 
     The method according to an exemplary embodiment comprises providing another node with an individual working memory, shared access to a rule set and/or right to execute a tuple pattern search against shared tuple data. 
     A system according to an exemplary embodiment is configured to execute the method according to an embodiment. 
     A system element according to an exemplary embodiment in an embodied system comprises executing means to perform a method step of a previous method claim. 
     A codec or a decoder according to an exemplary embodiment means of an embodied system element. 
     A codec or a decoder according to an exemplary embodiment comprises a data base module to access to a data base of rules, tuples and/or configuration data. 
     An inference engine according to an exemplary embodiment is configured to execute a method. 
     An expert system according to an exemplary embodiment comprises a system element wherein the system comprises at least one element of the following: 
     user interface, 
     a knowledge-base, 
     a knowledge acquisition module and 
     an explanatory interface. 
     The expert system according to an exemplary embodiment comprises at least one of the system elements of an embodied element. 
     A software product according to an exemplary embodiment comprises software structure that are configured to load a computer code into a memory of a computer to be executed in a processor connected to said memory, a computer code arranged to execute an embodied method. 
     The exemplary embodiments are free from certain restrictions and thus not restricted to a particular language, thus also support other formal semantics than description logic (DL). The exemplary method uses monotonic logic to infer new knowledge using data tuples and horn clause rules. 
     The exemplary method does not need Rete networks or decision trees to operate at all. Decision trees are shown in the examples to demonstrate the inference counters used by the method embodied but they are not used by the actual exemplary method in any way. 
     In the exemplary embodied method variants, the data consists of an ordered list of elements whose structure as such is known, e.g. the data tuples (Guth, 1998 as such). The data is a tuple space as an associative memory accessible in the embodied method. In an exemplary embodied method, in a Semantic web the tuples have often at least three elements: a subject, a predicate and an object. A skilled person in the art knows that the number of elements is exemplary and thus the number of elements is not limited only to the exemplified three. In the embodied method, a Semantic web tuple space can be expressed as a graph where each subject and object are nodes and predicates are directed links between the subject node and the object node. 
     A method according to an exemplary embodiment practices incremental forward chaining reasoning in a rule based system where data tuples and rules can be inserted and deleted in runtime. The exemplary embodied method does not require storing or calculating a dependency tree in order to reason new implicit tuples. All tuples are associated with an inference counter to provide an efficient delete operation for tuples without the need for re-calculating existing reasoning results. Thus, the dependency tree for reasoning for new tuples can be omitted to use less memory and computing capacity thus saved, in addition to which the subsequent data modification operations do not require updating the dependency tree. 
     A side effect from this is that the pruning of the above mentioned tree is not needed either, as the whole tree treatment can be omitted and even more computing capacity is saved as well as time. 
     Services and applications that need to constantly execute data requests and data modification operations as such in the known techniques, like OLTP (On-Line Transaction Processing) and data routing systems, benefit from the incremental nature of the method embodied by the invention, because it allows shorter response times as re-calculation of implicit tuples or modifications of the inference dependency tree are not required. 
     An application area that greatly benefits from real-time reasoning and reduced computational complexity is news routing into subscribed customers. Routing news often involves complex rules to be evaluated in order to decide which customers are interested in receiving the particular piece of news. Also news routing and delivery is concurrent by nature, processing large amount of incoming news constantly that makes long computation pauses and nightly preprocessing intolerable. 
     According to an exemplary embodiment a system element is configured to implement the method according to an exemplary embodiment. According to an exemplary embodiment, the system element is a news system element. According to an exemplary embodiment, a news server is implemented within a system according to an exemplary embodiment. 
     Saving computing capacity, memory and/or time is advantageous in general, especially in portable devices and embedded systems, where processing power is limited due to power consumption and size limitations. 
     The method according to an exemplary embodiment uses tuple pattern searches to access the existing fact/inferred data tuples that makes it possible to use external memory, like a hard disk, to store data tuples. It also makes it possible to use index data structures to efficiently evaluate the pattern match queries. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       In the following, a reference is made to the figures and the symbols therein to explain exemplary embodiments via the so indicated examples described in the embodiments. The same reference numerals do not denote necessarily an identical object in another figure, but a skilled person in the art can deduce the potential difference, if any, from the shown context. 
         FIG. 1  illustrates interference counter and tuples according to an exemplary embodiment, 
         FIGS. 2-3  illustrate how tuple changes change an imaginary dependency tree for an exempla embodiment, 
         FIGS. 4-5  illustrate how tuple changes change an imaginary dependency tree for an exemplary embodiment. 
     
    
    
     DETAILED DESCRIPTION OF EXEMPLARY EMBODIMENTS 
     The rules are horn logic clauses (Horn, 1951) that can be expressed as an implication formula:
 
(p 0               p   1              . . .              p   n )→ p   0  

     For simplicity reasons, the embodied method allows more than one positive literal in the disjunction because it can be easily seen that as such horn clauses having identical negative elements p but different positive element p′ can be combined into an implication formula:
 
( p   0               p   1              . . .              p   n )→( p   0   ′             p   1   ′              . . .              p   m ′)

     The method according to an exemplary embodiment works per tuple basis, e.g. in an embodiment, each applicable rule is evaluated for every data tuple inserted or deleted. The method will continue to process new operations until, based on the inference counters, no new reasoning is required. 
     Tuples are unique in the tuple space and therefore identical tuples cannot be present in the same space. Distinction between explicit tuples (i.e. facts) and implicit tuples (i.e. inferred tuples) is important in certain cases, for example in the delete operation: an implicit tuple cannot be explicitly deleted from the space as it would make the tuple space inconsistent with the current rules. However, the exemplary method does not restrict explicitly adding a tuple that is already inferred, or will be inferred, causing the same tuple to occur as an implicit and an explicit tuple at the same time, Also deletion of a rule or an explicit tuple may cause implicit tuples to be deleted if and only if they are not inferred by some other rules and tuples still in the space. Therefore explicit tuples and implicit tuples are considered embodied by this method as distinct tuples, notated as A.sup.F (fact tuple A) and A.sup.I (inferred tuple A), even if they are in context of the tuple space representing exactly the same tuple A. 
     An advantage of exemplary embodiments is that rules can be added to the system, and especially also removed when needed so that a re-deduction is not necessarily needed at all. 
     The rules in the embodied method are horn logic clauses that can be expressed as an implication formula:
 
 R :( L   0               L   1              . . .              L   n )→( L   0   ′             L   1   ′              . . .              L   m ′), where
 
 L   k =( v   0   , . . . , v   i ), v =(variable|constant)

     Literals in the rules must be of same length as the tuples in the tuple space. Rules for a tuple space with tuples length of three must have literals that have also length of three. For example:
 
 L   1 =(? x :knows? y )
 
     In the example above, the literal L 1  has two variables (marked with ?-prefix) and a constant value “knows” (marked with :−prefix). A constant can be any value of any form depending on the application area and value space used for the values of tuples. Textual constants like predicate “:knows” are presented without intention to limit the scope of related embodiments. Let data tuple F and rule R be:
 
 F =( t   0   , . . . ,t   i )
 
 R :( L   0               L   1              . . .              L   n )→ L′ 

     According to an exemplary embodiment, the rule R is considered applicable for a tuple F if and only if: 
     A method according to an exemplary embodiment uses a rule rewrite based on tuples inserted and removed. In an embodiment of the invention, an ensemble of literals comprising variables of at least one literal are substituted with the values from the actual tuple and results are calculated based on all variations of the rewritten rules. 
     A rule rewriter is a subsystem that executes the variable substituting. Substituting a rule R with values from fact F
 
 R :( L   1               L   1              . . .              L   n )→ L   0 ′

     produces the following rule applications R 1 ′ . . . R n ′: 
                 R     1   ⁢   ′       :     (         F       Λ         L   2   ′         Λ       …         Λ   ⁢           ⁢     L   n   ′             )       -&gt;     L   0   ′               …                 R     n   ⁢           ⁢   ′       :     (           L   1     n   ⁢           ⁢   ′           Λ         L   1     n   ⁢           ⁢   ′           Λ       …       Λ         L     n   -   1       n   ⁢           ⁢   ′           Λ       F         )       -&gt;     L   0     n   ⁢           ⁢   ′             
where one of the negative literals L i  is replaced with the fact F and all variables occurring in L i  are substituted from other literals (negative and positive) with the values from tuple F:
 
 L   i =( v   0   i   , . . . , v   j   i )
 
 k≠i:L   k ′=( v   0   k   , . . . ,t   m   , . . . , v   j   k ), where v m   k   =v   m   i  
 
     For example, a rule R 1  contains two literals L 1  and L 2  as antequents and a L 3 ′ as a consequent: 
     
       
         
           
             
               R 
               1 
             
             = 
             
               
                 
                   
                     ( 
                     
                       ? 
                       
                         x 
                         ⁢ 
                         
                           : 
                         
                         ⁢ 
                         
                           childOf 
                           ? 
                           y 
                         
                       
                     
                     ) 
                   
                   ⁢ 
                   
                     Λ 
                     ⁡ 
                     
                       ( 
                       
                         ? 
                         
                           x 
                           ⁢ 
                           
                             : 
                           
                           ⁢ 
                           
                             childOf 
                             ? 
                             x 
                           
                         
                       
                       ) 
                     
                   
                 
                 -&gt; 
                 
                   
                     ( 
                     
                       ? 
                       
                         x 
                         ⁢ 
                         
                           : 
                         
                         ⁢ 
                         
                           grandParent 
                           ? 
                           z 
                         
                       
                     
                     ) 
                   
                   ⁢ 
                   
                     
 
                   
                   ⇔ 
                   
                     
 
                   
                   ⁢ 
                   
                     R 
                     1 
                   
                 
               
               = 
               
                 
                   
                     L 
                     1 
                   
                   ⁢ 
                   Λ 
                   ⁢ 
                   
                       
                   
                   ⁢ 
                   
                     L 
                     2 
                   
                 
                 -&gt; 
                 
                   L 
                   3 
                   ′ 
                 
               
             
           
         
       
     
     Together with fact
 
 F   1 =(: p 1:childOf : p 2)
 
rule R 1  will produce the following rewritten rule applications R 1   1 ′ and R 1   2 ′:
         1) Substitute variables in literal L 1  using values from fact F 1 :
 
 R   1   1 ′=(: p 1:childOf: p 2)         (: p 2:childOf? z )→(: p 1:grandParent? z )
   2) Substitute variables in literal L 2  using values from fact F 1 :
 
 R   1   2 ′=(? x :childOf: p 1)         (: p 1:childOf: p 2)→(? x :grandParent: p 2)
       

     In an exemplary embodiment, these rewritten rules R 1   1′  and R 1   2′  are evaluated against the tuple space to get a table of variable bindings. Implicit tuples are constructed using the variable bindings and the right side of the rewritten rule application. 
     Let execution of left side of R 1   1 ′ return the following variable bindings: 
     
       
         
           
             
               ? 
               z 
             
             
               
                 
                   
                     : 
                     
                       p 
                       ⁢ 
                       
                           
                       
                       ⁢ 
                       3 
                     
                   
                 
               
               
                 
                   
                     : 
                     
                       p 
                       ⁢ 
                       
                           
                       
                       ⁢ 
                       4 
                     
                   
                 
               
             
           
         
       
     
     Using these bindings, the following implicit tuples can be constructed from the right side of the implication in R 1   1′  : 
     As a result of the exemplary method implicit tuples I 1  and I 2  are under consideration for insert, delete or updating inference counters depending on the operation at hand. 
     Some of the rewritten rule applications can be left out immediately in an exemplary embodiment, if they are not compatible with the rule.
 
 R   2 =(? x :knows? y ) → (? y :knows? x)  
 
     For example rule R 2  has no tuple patterns that would match for the tuple F 7  making rule R 2  unnecessary to be executed when inserting or deleting tuple F 1 . 
     Inference Counters 
     In an exemplary embodiment, the reasoning can result in same tuples from different rules and different fact tuples. Inferred tuples can also be inserted as a fact too, in an exemplary embodiment. These characteristics apply using counters (e.g. variable data associated with each node) to keep a record of which inferenced tuples can be removed and which can not. 
     An inference subsystem is a part of the system that evaluates inference, modifies the tuple space and maintains inference counters. 
     For every inferred tuple the inference counter c&gt;=1 indicates the number of rewritten rule applications that produce the inferred tuple. For inferred tuple A I  with inference counter c=n, there are exactly n distinct rule applications R′ that produce A I  when executed. 
     When represented as an inference tree, the counter c can be seen (in  FIGS. 1-4 ) as the number of incoming arrows to the inferenced node. 
     An example of tuple I 0  with inference counter c=2 (two incoming arrows) is indicated in  FIG. 1 . 
     Comparing the inference counters as together with the inference tree commonly used with reasoning, two significant characteristics should be noted: 1) during an insert or delete operation, the actual tuple space is edited only if the existence of the tuple changes and 2) inference counters of implicit triples far lower in the dependency tree (if one such would be used) do not need to be changed if the counters upper in the dependency tree change. Complex rules and rules that tend to produce the same output, like inferencing an instance type based on property values, do not require more computation or modifications in situations where a dependency tree would be very complex and the length of the sub-tree large. 
     Insert Operation 
     The inference subsystem is responsible for tuple and rule insertion operations. 
     Insertion of an explicit tuple or a rule contains at least one of the following operations: 
     1. assertion that the tuple is not already present in the tuple space as a fact, 
     2. assertion that the rule is not already present in the system, 
     3. if the tuple is already present as an implicit tuple, mark it as an explicit tuple, 
     4. if the tuple is not present in the tuple space, add it and execute inference embodied by the method for the tuple, 
     5. if rule is not present in the system, add rule into the system, 
     6. if rule is not present in the system, execute the literals of left side of the rule without any variable substitution, construct tuples based on results and the right side of the rule and add them as new implicit tuples. 
     For every implicit tuple inferred by the method, one of the following operations takes place: 
     1. If the tuple is already present, increase the inference counter of the tuple, 
     2. If the tuple is not already present, insert it into the tuple space, set inference counter to 1 and execute inference as embodied by the method. 
     Let us consider the following example where reasoning is presented as a tree in accordance with the embodied method, by referring to  FIG. 2  and  FIG. 3 . In an exemplary embodiment, it infers tuple B from rule R1 and fact A and tuple D from tuple B and rule R2. Inference counter is c=1 for both inferenced tuples B and D (as there is only one arrow pointing to the node when represented as a dependency tree). 
     An imaginary dependency tree after insert of a tuple A, explicit tuples B and D inferred and their inference counters is indicated to illustrate an example via  FIG. 2 . 
     An imaginary dependency tree after inserting explicit tuple C, inserted implicit tuple A and updated inference counter of implicit tuple B is indicated to illustrate an example via  FIG. 3 . 
     Let us insert a fact C together with a rule R3 ( FIG. 3 ): 
     According to an exemplary embodiment, the tuple A is inferred from C and now tuple A is at the same time a fact and also an inferred tuple. Inserting inferred tuple A causes counter of B to be increased. This will not trigger any new inference to be run and also inference counter of tuple D will not be increased as the tuple B is already present in the tuple space as an inferred tuple. 
     An example is given how to insert a tuple T according to an exemplary embodiment. In the example, also a rule insertion is indicated in the pseudo code notation. 
     According to an exemplary embodiment, the Implementation tracks the path from deleted explicit tuple to the end of the chain to make sure same tuple is not processed multiple times. 
                                                           Inserting tuple T:                insert(T):            insert(T, emptyList)           insert(T, previousTuples):            if T is not a fact:             if previousTuples contains T:              return             ++counterFor(T)            if repository contains T:             return            insert T into repository            for each rule R:             if rule R has no compatible antequent triple patterns with T:              break             for each unique rewritten rule application R′ of R(T):              S = execute(R′)              for each tuple T2 in S:               add T2 into previousTuples               insert(T2, previousTuples)               remove T2 from previousTuples            Inserting rule R:                insert(R):            if repository contains R:             return            S = execute(R)            for each tuple T in S:             insert(T)            insert rule R                        
Delete Operation
 
     The inference subsystem is responsible for tuple and rule deletion operations. 
     Deletion of an explicit tuple or a rule contains at least one of the following operations:
         1. assertion that the tuple is present in the tuple space as a fact,   2. assertion that the rule is present in the system,   3. if the tuple is present in the tuple space as an implicit tuple, remove explicit tuple mark for it and execute inference embodied by the method for the tuple,   4. if the tuple is present in the tuple space as a fact and not as an implicit tuple, remove the tuple from tuple space and execute inference embodied by the method for the tuple,   5. if the rule is present in the system, remove rule from the system,   6. if the rule is present in the system, execute the literals of left side of the rule without any variable substitution, construct tuples based on results and the right side of the rule and remove them as implicit tuples.       

     For every implicit tuple inferred by the method at least one of the following operations takes place:
         1. If the tuple is present, decrease the inference counter of the tuple   2. If the inference counter of the tuple is (after decrement) zero (c=0), execute inference as embodied by the method,   3. If the tuple is not present as an explicit tuple and inference counter of the tuple is (after decrement) zero (c=0), remove tuple from the tuple space       

     As an example, let us consider a deletion of a fact tuple A from the tuple space shown in the  FIG. 2  as an imaginary dependency tree. As in the embodiment, the fact status of tuple A will be removed, but it is still inferred from tuple C. Removing the fact A (step  1 ) causes inference to occur (step  2 ), and as a result counter of B to be decreased (step  3 ). Counter of D will not be changed as B will not be removed (c is still positive). 
     An imaginary dependency tree after deleting explicit tuple A and updated inference counter of implicit tuple B is indicated to illustrate an example via  FIG. 4 . 
     And let us finally delete fact tuple C ( FIG. 5 ). The deletion of C (step  1 ) will cause deletion of an inferred tuple A (step  2 ) as inference counter of A hits 0. Deletion of inferred tuple A will also cause deletion of B (step  3 ) and finally deletion of D (step  4 ). 
     An imaginary dependency tree after deletion of fact tuple C and deletion of inferred tuples A, B and D is indicated to illustrate an example via  FIG. 5 . 
     According to an exemplary embodiment, the Implementation must track the path from deleted explicit tuple to the end of the chain to make sure the same tuple is not processed multiple times. 
     
       
         
               
             
               
               
             
               
             
               
               
             
           
               
                   
               
             
             
               
                 Deleting tuple T: 
               
             
          
           
               
                   
                 delete(T): 
               
               
                   
                  delete(T, emptyList) 
               
               
                   
                 delete(T, previousTuples): 
               
               
                   
                  if repository doesn&#39;t contain T: 
               
               
                   
                   return 
               
               
                   
                  if T is not a fact: 
               
               
                   
                   if previousTuples contains T: 
               
               
                   
                    return 
               
               
                   
                   if −−counterFor(T) &gt; 0: 
               
               
                   
                    return 
               
               
                   
                  for each rule R: 
               
               
                   
                   if rule R has no compatible antequent triple patterns with T: 
               
               
                   
                    break 
               
               
                   
                  for each unique rewritten rule application R′ of R(T): 
               
               
                   
                   S = execute(R′) 
               
               
                   
                   for each tuple T2 in S: 
               
               
                   
                    add T2 into previousTuples 
               
               
                   
                    delete(T2, previousTuples) 
               
               
                   
                    delete T2 from previousTuples 
               
               
                   
                  delete T from repository 
               
             
          
           
               
                 Deleting rule R: 
               
             
          
           
               
                   
                 insert(R): 
               
               
                   
                  if repository doesn&#39;t contain R: 
               
               
                   
                   break 
               
               
                   
                  S = execute(R) 
               
               
                   
                  for each tuple T in S: 
               
               
                   
                   delete(T) 
               
               
                   
                  remove rule R 
               
               
                   
                   
               
             
          
         
       
     
     An exemplary method can be realized by a device that is capable of automatically routing information, like news, to other nodes in the network by using complex and general routing rules. 
     A coding system comprises a codec/decoder The codec of the coding system comprises coding means that are arranged to form a tuple space of sets of incoming information. The codec also comprises coding means for rules additions and deletions received by the device. 
     According to an exemplary embodiment, the device infers routing information using the rule set in the device, the tuple space in the device and the encoded information as tuples. The routing information is used to determine which nodes in the network are subscribed for this kind of information. The device decodes the information from the tuple space and transmits it into the corresponding nodes in the network. 
     List of Abbreviations and Symbols 
     
       
         
               
               
             
           
               
                   
               
               
                 Symbol/ 
                   
               
               
                 abbreviation 
                 Definition 
               
               
                   
               
             
             
               
                 p n   
                 n:th literal in an implication formula 
               
               
                 p n ′ 
                 n:th negative literal in an implication formula. 
               
               
                   
                 Negative literals exist by definition in the 
               
               
                   
                 right side of the implication formula 
               
               
                 R 
                 a rule expressed as a horn logic clause visualized an 
               
               
                   
                 implication formula 
               
               
                 R n   
                 n:th rule 
               
               
                 L 
                 literal of a rule 
               
               
                 L n   
                 n:th positive literal in the rule. Positive literals construct 
               
               
                   
                 the left side of the rule 
               
               
                 L n ′ 
                 n:th negative literal in the rule. Negative literals 
               
               
                   
                 construct the right side of the rule 
               
               
                 L′ 
                 abbreviation for all negative literals L 0 ′ . . . L n ′ in the rule 
               
               
                 v n   
                 n:th variable or constant in a literal L that represents a 
               
               
                   
                 tuple pattern 
               
               
                 v n   k   
                 n:th variable or constant in a literal L k   
               
               
                 ? x 
                 tuple pattern variable “x” that can be part of a literal L 
               
               
                 : value 
                 tuple pattern constant “value” that can be part of a literal L. 
               
               
                   
                 Constant can be of any textual or non-textual value 
               
               
                   
                 depending on the value space used for the tuple space 
               
               
                 F 
                 tuple that is explicitly inserted into the tuple space, e.g. 
               
               
                   
                 an explicit tuple 
               
               
                 F n   
                 n:th explicit tuple 
               
               
                 I 
                 tuple that is implicitly inferred into the tuple space, e.g. 
               
               
                   
                 an implicit tuple 
               
               
                 I n   
                 n:th implicit tuple 
               
               
                 t n   
                 n:th value in a tuple 
               
               
                 A F   
                 tuple A that is an explicit tuple 
               
               
                 A l   
                 tuple A that is an implicit tuple 
               
               
                 R n   k ′ 
                 k:th rule application of rule R n  that has all variables 
               
               
                   
                 occurring in n:th literal substituted with values 
               
               
                 R n ′ 
                 a rule application or rule applications of rule R n   
               
               
                 R′ 
                 a rule application or rule applications of rule R 
               
               
                 c 
                 inference counter for an implicit tuple 
               
               
                   
               
             
          
         
       
     
     BIBLIOGRAPHY 
     
         
         Forgy, C. (1979).  On the efficient implementation of production systems . Ph.D. Thesis, Carnegie-Mellon University. 
         Guth, R. (1998, August). More than just another pretty name: Sun&#39;s Jini opens up a new world of distributed computer systems.  Sun World.    
         Horn, A. (1951). On sentences which are true of direct unions of algebras.  Journal of Symbolic Logic,  16, 14-21. 
         Mercadal, D. (1990).  Dictionary of artificial intelligence . New York, N.Y: Van Nostrand Reinhold.