When adding a rule to PyReason, custom_thresholds allow you to enforce quantitative requirements on the clauses in the rule's body.
In a rule like ViewedByAll(y) <- HaveAccess(x,y), Viewed(x), if you provide two thresholds, PyReason maps them to the clauses in the body sequentially:
- The first threshold applies to the first clause (
HaveAccess(x,y)). - The second threshold applies to the second clause (
Viewed(x)).
This allows for complex logic, such as requiring that at least one person has access AND that 100% of those with access have viewed the item before the head (ViewedByAll(y)) is satisfied.
import pyreason as pr
# Example rule with thresholds applied to body clauses
pr.add_rule(
pr.Rule(
"ViewedByAll(y) <- HaveAccess(x,y), Viewed(x)",
"viewed_by_all_rule",
custom_thresholds=user_defined_thresholds,
)
)