It’s known that Prolog have a powerful feature that new operands can be defined.
Assume that my program defined a set of new boolean operands such as bool1, bool2, bool3, my_and.
:-op(500, yfx, [bool1, bool2, bool3]).
:-op(700, xfx, [my_and]). (my_and == logic and)
now, for this equation for example:
a bool1 b my_and c bool2 d Prolog will translate it into
my_and(bool1(a, b), bool2(c, d)).
Also, if I will look at this as a binary tree it supposed to look like this:
my_and / \ bool1 bool2 / \ / \ a b c d
- Is there any way to print the equation as a binary tree?
- Is there any way to split the equation into sub equations?
- Assume that my program gets new fact every minute. it is possible to check only the right part of the equation and not all of it?
For the equation:
a bool1 b my_and c bool2 d
at time 0 the program get
a- the equation will return false since
a bool1 bnot happened.
at time 1 the program get
a bool1 bis true) - the equation still return false since the right side is still false.
at time 2 the program get
c- the equation will return false (same reason as time 1).
at time 3 the program get
c bool2 dis true) - the equation return true since the left and the right are true.
In each new time that new fact was inserted the program check the for whole equation, even the left side already was true since time 1.
Thank you for your time and help.