# is all with min max

When attaching `min N`, or `max M`, or both to a declaration, we limit the number of Instances that are expected to be present in a Case.

### Syntax

`VARIABLE is all ONTOLOGY, ROLE_1, ... ROLE_N min N max M`

A match with the name `VARIABLE` is created for an Instance that has the Ontology `ONTOLOGY` and all the roles (`ROLE_1` to `ROLE_N`), and the number of Instances found in the Case are no less than `N` and no more than `M`.

Both `min` and `max` are optional attachments to a declaration. The declaration would still be valid with neither, both or only one of them.

### Examples: min

```python
ps is all Person min 3
```

If there are at least 3 Instances of `Person` in the Case, `ps` will hold a list of at least 3 `Person` Instances.

### Examples: max

```python
ps is all Person max 5
```

If there are at most 5 Instances of `Person` in the Case, `ps` will hold a list of at most 5 `Person` Instances.

### Examples: min and max

```python
ps is all Person min 3 max 5
```

If the number of `Person` Instances in the Case is between, but including 3 and 5, `ps` will hold a list of 3 to 5 `Person` Instances.

### Examples: min, max and Roles

```python
ps is all Person, AccountHolder min 3 max 5
```

If the number of `Person` Instances with the Role `AccountHolder` in the Case is between, but including 3 and 5, `ps` will hold a list of 3 to 5 `Person` Instances.


---

# 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://docs.atfinity.io/rule-language/declarations/is-all-with-min-max.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.
