Skip to content

Main content

Finite Set Cardinality Update Tool

Update finite-set cardinality for one insertion or deletion given an explicit pre-operation membership flag.

Loading tool…

Description

Choose delta +1 or zero for insertion according to alreadyPresent, and -1 or zero for removal.

A set contains distinct values, so duplicate input items do not contribute additional members. Ordered output is a serialization convention; membership, equality, and the chosen universe determine the underlying set result.

Choose delta +1 or zero for insertion according to alreadyPresent, and -1 or zero for removal.

When to use this tool

Use Finite Set Cardinality Update when you need a deterministic operation on explicitly supplied sets or a finite membership representation.

How to use the tool and how it works

  1. Enter cardinality, alreadyPresent, inserting. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read updatedCardinality, delta. Use the output convention below.

Choose delta +1 or zero for insertion according to alreadyPresent, and -1 or zero for removal. Add it to cardinality, rejecting an asserted present element in an empty set.1

Input fieldMeaning and unitsAccepted input
cardinalityCardinalityRequired. Safe integer; minimum 0.
alreadyPresentAlready PresentRequired. Boolean.
insertingInsertingRequired. Boolean.
Output fieldInterpretationReturned shape
updatedCardinalityUpdated CardinalityRequired. Safe integer.
deltaDeltaRequired. Safe integer.
json
{
  "input": {
    "cardinality": 5,
    "alreadyPresent": false,
    "inserting": true
  },
  "output": {
    "updatedCardinality": 6,
    "delta": 1
  }
}

Limitations and assumptions

  • AlreadyPresent is supplied; no actual set or item identity is inspected.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Specify the universe and equality convention before combining this result with other set operations.

References

  1. Calculation and input contract: set/finite-set-cardinality-update — tool.io

Similar or alternative tools