| Title: Gateway
Description: None
Copyright (c) 1999 Steven J. Metsker.
Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
A Gateway is a structure that can prove its truth at most
once before failing.
Examples of gateways are comparisons, negations, and
mathematical evaluations. For example, Age >
18 is either true or not, it cannot prove itself in
more than one way. Also, not married(X) is
true only if the structure married(X) cannot
prove itself at all.
The fact that gateways can be true only once is important
in rules. For example, a rule might contain:
..., plays(jim, Game, Rating),
Rating >= 7, likes(jane, Game), ...
As this rule proves itself, if it finds a game that Jim
plays with a rating of, say, 8, the rule will accept that
Rating >= 7 . The rule will then proceed to
prove the structures after the comparison. The rule may
succeed with the latter structures many times, but
eventually these structures will run out of proofs, and the
rule will fail back to the comparison structure.
On failing back, the rule will ask the comparison for its
next proof. This amounts to asking if there is a different
way to prove that 8 is greater than or equal to 7. Since
the comparison has already succeeded once, which allowed
the rule to check the latter structures, on failing back
the comparison will fail. This will cause the rule to fail
back to the preceding plays structure, which
may be able to find other proofs.
If a preceding structure succeeds, the rule will move
forward again, and ask a gateway to prove itself. Since the
gateway has failed, it will try again to prove itself.
author: Steven J. Metsker version: 1.0 |