# Multiset counts check

`multiset-counts-check` · version 1.0.0 · Numbers & math · free, no key needed

Check an exact claimed multiplicity table for canonical JSON scalars in first-occurrence order.

**Use when you need to: check multiset counts claim · validate multiplicity table · audit bag frequency certificate.**

## Decide before calling

Read the [versioned contract](/v1/tools/multiset-counts-check/versions/1.0.0) and the supported scope below. Reuse `multiset-counts-check@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `multiset-counts-check@1.0.0` for check multiset counts claim. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- check multiset counts claim
- validate multiplicity table
- audit bag frequency certificate
- check duplicate count table
- verify scalar occurrence counts
- validate claimed histogram

## Not supported

- return a computed replacement table
- count nested JSON objects

## Behavior

- The claim has one entry per distinct scalar, in first source occurrence order; count is a canonical decimal integer string.
- Scalar identity uses RFC 8785 JSON serialization, including -0 equal to 0; duplicate claim entries are malformed rather than silently combined.
- The first differing claim position is returned, and the caller claim is never repaired.
- Every output names ISO/IEC 9075-2:2023 multiset terminology; RFC 8785 (JCS), June 2020.

## Input

- `source` (array of string or number or boolean or null, required): max items 10000
- `claim` (array of object, required): max items 10000

## Output

- `valid` (boolean, required)
- `reason` (one of "claim_mismatch", optional)
- `discrepancy` (object, optional)
- `reference_version` (constant "ISO/IEC 9075-2:2023 multiset terminology; RFC 8785 (JCS), June 2020", required)

## Limits

- max items: 10000
- max distinct: 10000
- max count: 10000

## Example

Request input:

```json
{
  "source": [
    null,
    "x",
    null
  ],
  "claim": [
    {
      "value": null,
      "count": "2"
    },
    {
      "value": "x",
      "count": "1"
    }
  ]
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reference_version": "ISO/IEC 9075-2:2023 multiset terminology; RFC 8785 (JCS), June 2020"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "multiset-counts-check",
  "version": "1.0.0",
  "input": {
    "source": [
      null,
      "x",
      null
    ],
    "claim": [
      {
        "value": null,
        "count": "2"
      },
      {
        "value": "x",
        "count": "1"
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/multiset-counts-check/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"source":[null,"x",null],"claim":[{"value":null,"count":"2"},{"value":"x","count":"1"}]}'
```

The machine-readable contract is at [/v1/tools/multiset-counts-check/versions/1.0.0](/v1/tools/multiset-counts-check/versions/1.0.0).

### CLI

```sh
node cli.mjs run multiset-counts-check 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Multiset equality check](/tools/multiset-equality-check): Check whether a claimed array has exactly the same canonical JSON scalar multiplicities as a source array.
- [Sample histogram check](/tools/sample-histogram-check): Check claimed histogram counts, outside count and densities for exact edges and an edge rule; returns the first bad bin.
- [Multiset difference check](/tools/multiset-difference-check): Check claimed left-only and right-only scalar bag differences in deterministic source order.
- [Coloring count check](/tools/coloring-count-check): Check a proper indexed coloring and an exact canonical-decimal claim for its number of distinct colors.
- [Unique key claim check](/tools/unique-key-claim-check): Check an exact uniqueness claim and first-duplicate certificate under an explicit SQL null policy.
- [Candidate key claim check](/tools/candidate-key-claim-check): Check an exact candidate-key claim, including uniqueness and minimality, under an explicit SQL null policy.
