Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

=?utf-8?q?Re=3A_=5Bclipsrules=3Adiscussion=5D_Re=3A_Rule_matching?= =?utf-8?q?_problem_with_exists_and_test?=

Help
vranoch
2014-01-29
2014-02-02
  • vranoch
    vranoch
    2014-01-29

    I discovered a problem (inconsistency) in BLOADing the previously BSAVEd
    image. This occurs under quite a specific conditions, however it shows some internal inconsistency.

    I have the following CLIPS code (extremely simplified):

    (defrule x_ba6 
        (Doklad KodDokladu ?V163_TV9040)
        (Doklad KodDokladu ?V163_TV9043)
        (or  
           (test (eq  ?V163_TV9040 "36")) 
           (test (eq  ?V163_TV9043 "37"))
        )
        =>
    )
    
    (defrule x_ba8   ; FIRST OCCURRENCE OF A RULE
        =>
    )
    
    (defrule x_baa 
        =>
    )
    
    (defrule x_ba8  ; SECOND OCCURRENCE  in a reality created by a mistake but may exist
        =>
    )
    

    For CLIPS 6.30 x86, when performing    load – bsave – clear – bload , the bload hangs in an infinite loop trying to read definitions of rules. If the rules are reordered, the condition of the first rule is changed (e.g. only one expression in OR, changing OR to AND, etc.) the bload is performed without problems. Please try to investigate this as it may manifest some internal inconsistency which can be difficult to discover.

    Thanks Vranoch

     
    Last edit: vranoch 2014-01-29
  • Gary Riley
    Gary Riley
    2014-02-02

    I've checked in a fix.

     
    • vranoch
      vranoch
      2014-02-02

      Thanks a lot - You fixed it very quickly. What was the problem? I did some testing and all my existing tests completed OK. Thanks again.

       
  • Gary Riley
    Gary Riley
    2014-02-02

    Rules with or conditional elements create several rules (one disjunct for each possible combination of the or CEs). There's a list of rules, but for each rule there's also a list of the disjuncts for each rule. When a rule was being deleted, the preceding rule had its pointer to the next rule updated, but if that rule had any disjuncts, the next pointer for these was not updated. Bsave has to traverse the entire rule network to generate the output, so the incorrect pointers were preventing the correct amount of information to be written out to the binary file. The error will not occur for any deleted rule, just one where the preceding rule used an or conditional element.