Rules-based reasoning
At the core of every PyRel model is the rules-based reasoning that turns your model’s facts into reusable business logic. This overview gives you a high-level introduction to what rules-based reasoning is, when to use it, and how to approach writing complex logic in PyRel.
What rules-based reasoning is
Section titled “What rules-based reasoning is”Rules-based reasoning uses declarative definitions to express business logic in a semantic model that every query can leverage without needing to re-implement the logic. In practice, this means writing definitions that:
- Derive new facts based on existing facts in your model.
- Encapsulate logic in reusable concepts and relationships.
- Enforce rules and policies by requiring certain conditions to be met.
Using rules-based reasoning, you can build a rich semantic layer that can be queried and operationalized. It is a powerful way to encode domain knowledge and business rules in a way that is transparent, reusable, and easy to maintain.
When to use rules-based reasoning
Section titled “When to use rules-based reasoning”Use rules-based reasoning when you need to:
- Encode business policy for consistent application across teams and use cases.
- Standardize definitions for key concepts across workflows.
- Consistently handle edge cases and data quality issues across applications.
You can start with exploratory queries and ad-hoc logic for initial analysis and validation. If you start copying and pasting the same logic, or you need it to behave consistently across use cases, it’s time to move that logic into a reusable definition.
Where to go next
Section titled “Where to go next”Pick a guide below to start using rules-based reasoning in your model: