In my class I have been taught the Prolog backtracking algorithm and the Rete forprop algorithm, but I have also been told that Rete can be used to do backprop.
How does that work? In which ways is it similar / different to Prolog backtracking?
For example, this is one of the exercises I have been given:
(R1) 24fingers and antennas => origin(mars)
(R2) shy and 5feet => origin(mars)
(R3) shy and 4arms => origin(venus)
(R4) looksDownWhenTalking => shy
(R5) fleesWhenSeen => shy
The goal is given the following facts find the origin of the alien:
(F1) fleesWhenSeen
(F2) 4arms
In Prolog, we would solve it by pattern matching the goal origin(X)
against the RHS of the rules. The rule matches against R1, R2 and R3, so first R1 will be triggered, and we would try to resolve the subgoals 24fingers and antennas
which would fail.
Then we would go backtrack to the beginning and trigger R2, which eventually will fail, and finally backtrack and trigger R3, which succeeds.
So X
ends up binded to venus
in a successful query, and the algorithm ends.
Now, how would we solve the same exercise using the rete backprop algorithm?
I naively assume that we would use a list of subgoals, starting with origin(X)
, to start triggering rules whose RHS matches the subgoals.
But it isn't clear to me how the Rete algorithm would take care of backtracking when some subgoals fail, or how would it know that it has succeed once it resolves a certain subset of goals.
frog => green
means that all frogs are green. In this world there are no brown frogs. Inductive reasoning on this rule would propose that a given object that is green may (!) be a frog. Yet in this world there may be also other objects that are green and a green object that is not a frog is perfectly consistent with a world based on this rule. – Mairamaire