# Multiset equality check

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

Check whether a claimed array has exactly the same canonical JSON scalar multiplicities as a source array.

**Use when you need to: check multiset equality claim · validate bag equality · compare scalar multiplicities.**

## Decide before calling

Read the [versioned contract](/v1/tools/multiset-equality-check/versions/1.0.0) and the supported scope below. Reuse `multiset-equality-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-equality-check@1.0.0` for check multiset equality 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 equality claim
- validate bag equality
- compare scalar multiplicities
- check unordered array equality
- verify duplicate counts match
- test claimed bag equivalence

## Not supported

- compare JSON objects or arrays as elements
- repair or reorder a claim

## Behavior

- Elements are null, booleans, strings, or finite JSON numbers; equality uses their RFC 8785 JSON serialization, so -0 equals 0.
- Order does not affect equality; duplicates do. The first mismatch follows first source occurrence, then first extra claim occurrence.
- A false claim is returned unchanged as valid false; the tool never supplies a repaired claim.
- 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 string or number or boolean or null, 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

## Example

Request input:

```json
{
  "source": [
    1,
    null,
    1
  ],
  "claim": [
    null,
    1,
    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-equality-check",
  "version": "1.0.0",
  "input": {
    "source": [
      1,
      null,
      1
    ],
    "claim": [
      null,
      1,
      1
    ]
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Multiset counts check](/tools/multiset-counts-check): Check an exact claimed multiplicity table for canonical JSON scalars in first-occurrence order.
- [Multiset difference check](/tools/multiset-difference-check): Check claimed left-only and right-only scalar bag differences in deterministic source order.
- [Dedupe first check](/tools/dedupe-first-check): Check an exact first-wins SameValueZero deduplication claim and report its first discrepancy.
- [Dedupe keyed check](/tools/dedupe-keyed-check): Check an exact keyed Map deduplication claim and report its first discrepancy.
- [Dedupe last check](/tools/dedupe-last-check): Check an exact last-wins SameValueZero deduplication claim and report its first discrepancy.
- [Permutation values check](/tools/permutation-values-check): Check whether claimed values are a SameValueZero multiset permutation, reporting the first source-order discrepancy.
