Skip to content
dainiuskreivenas edited this page Oct 29, 2019 · 12 revisions

Syntax

Rules are consturcted in the following sytanx:

'("{name}", {conditions}, {operations})'

  • {name} - is the name of the rule
  • {conditions} - is an array of conditions for the rule:
    • condition syntax: ({positive}, "{name}", {properties}, {binding)
      • {positive} - bool determines if the conditons has to be true or false
      • {name} - name of the fact group
      • {properties} - is a tuple of fact properties
        • can be any value
        • "?" - symbol matches any value
        • "?var" - matches any value, keeps it for operations under the same name
      • {binding} - used for retractions to specify which fact to retract (see below)
  • {operations} - there 2 different operations:
    • assert - turns on state, syntax: ("assert",("{name}",{properties})):
      • {name} - name of the fact group
      • {properties} - is a tuple of fact properties
        • can be any value
        • "?var" - will use a value found in preconditions
    • retract - turns off state, syntax ("retract","{binding}")
      • {binding} - name of the condition that matches the fact (see above)

Example:

(
   "grab-fruit",
   [
      (True, "monkey-can-reach", ("banana",), "a")
   ],
   [
      ("assert", ("monkey-has", ("banana",))),
      ("retract", "a")
   ]
)

Operations

+,-,/,* Operations can be perfomed in Test conditions and Asserting new items.

Operation:

("assert, ("factName", (("+",2,2),"Attribute2")))

Will assert a fact: ("factName", (4,"Attribute"))

Test Conditions

Test conditions perform checks against values or rule variables.

("test", ({operator},{leftValue},{rightValue}))

  • {operator} - <,>,=,<>
  • {leftValue} - left value of the test operation
  • {rightValue} - right value of the test operation

Example: ("test", ("<", 1, 2))

Similary, the attribute values in the Assert statements can be calculated values:

("test",({operator},({calcOperator}, {leftValue}, {rightValue1}),{rightValue2}))

  • {operator} - <,>,=,<>
  • ({calcOperator}, {leftValue}, {rigthValue}) - left value of Test operation
    • {calcOperator} - +,-,/,*
    • {leftValue} - left value of calculation
    • {rightValue} - right value of calculation
  • {rightValue2} - right value of Test Operation

Example: ("test", ("<", ("-", 2, 1), 2))

Bases

[TODO]

Properties

[TODO]

Relationships

[TODO]

Associations

[TODO]

Clone this wiki locally