# Rule Declaration Language

The rule declaration language supports two types of rules: Decision rule or a Score rule.

#### Score rule:

* A Score rule is composed of one or many rule sets.
* Each rule-set computes a sub-score and is applied a weight.
* The total score then would be the sum of all the individual scores of all the rule sets belonging to a rule.
* A rule set is composed of one or many rule rows.
* You can ‘roughly’ think of each Rule Row as a Conditional evaluation of the facts (a.k.a antecedent) & a score based on these conditions (a.k.a consequent).

<figure><img src="https://user-images.githubusercontent.com/15995686/193492161-71f5faf5-e206-4543-a005-7681b79fe689.png" alt=""><figcaption></figcaption></figure>

#### Decision rule:

* A Decision rule is always composed of only one rule set.
* A rule set is composed of one or many rule rows.
* You can ‘roughly’ think of each Rule Row as a Conditional evaluation of the facts (a.k.a antecedent) & a decision based on these conditions (a.k.a consequent).
* A decision rule always arrives at a single decision at the end of parsing.
* The decision can be anything (a numeric, a string such as YES/NO or even a JSON)
* Once a Rule Row evaluates to True, the corresponding decision is returned immediately.

<figure><img src="https://user-images.githubusercontent.com/15995686/193492209-52bfa8fa-eb27-4805-bf95-cc7723b26a51.png" alt=""><figcaption></figcaption></figure>

#### Antecedent and Consequent

* An antecedent at the core is an evaluator. It evaluates one or many facts through an operator.
* For evaluating numeric facts, a numeric operator is used. It can be one of (<=, <, >, >=, ==, <>, between, is\_none)
* For evaluating string facts, a string operator is used. It can be one of (in\_list, contains, is\_none, equals)
* You can mix evaluation of more than one fact & combine the result with an “and” or “or” condition.
* You can perform complex evaluations involving multiple facts combining AND and OR conditions recursively in the antecedent. See [Examples](/simple-rule-engine/examples.md).
* A rule can be part of another rule. See [Examples](/simple-rule-engine/examples.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jeyabalajis.gitbook.io/simple-rule-engine/rule-declaration-language.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
