samples/basic/tutorial/shapes.kb
The values of facts can be mathematical expressions. Those expressions can refer to other facts. And, in keeping with its goal-seeking behavior, when the reasoning engine needs to evaluate an expression that refers to another fact, it will set a sub-goal of finding a value for that fact.
We'll see this behavior with a toy system that computes the area and perimeter of a variety of shapes.
conditions |
value |
shape = "circle" |
pi * radius ** 2 |
shape = "rectangle" |
height * width |
conditions |
value |
shape = "circle" |
2 * pi * radius |
shape = "rectangle" |
2 * (height + width) |
Mathematical expressions like these can be used pretty much anywhere a straight value can be used.