Source: https://guthlabs.ai/docs/instruments/hamming-distance-error-detection-calculator/implementation/

instrument implementation / implementation-contract

# Hamming Distance / Error-Detection Calculator implementation

A source-bound implementation contract for Hamming Distance / Error-Detection Calculator; deployment and executable qualification remain separate.

Status: **VERIFIED_CLEAN**Lifecycle: **implementation-contract**

## Binding contract

This record describes what an executable surface must bind and validate. It does not claim that a public calculator, package, or production route is deployed.

**Record owner**: Guth Instruments

**Lifecycle**: verified-clean

**Evidence ID**: t4-266

**Effect**: Computation or source lookup only

## Input and validation requirements

- Unequal-length inputs must be rejected before comparison; silently truncating, padding, or comparing only the overlapping prefix would produce an invalid result.

- The detection and correction capabilities are not validly determined from an arbitrary pairwise distance unless that distance is known to be the code's minimum distance.

- For d=0, the raw formulas produce −1 for both capabilities, which is not a meaningful error-detection or correction guarantee; capability outputs need a validity constraint such as d≥1 and a defined code minimum distance.

- Text handling is ambiguous for Unicode strings: code units, code points, and user-perceived characters can yield different lengths and distances.

- Empty strings produce distance 0 and require explicit handling.

- No division-by-zero hazard exists in the stated formulas.

## Required corrections

No binding erratum is attached to this unique-name record. Implementers must still preserve the declared units, domain, and failure behavior.

## Inspectable interface fixture

The sample below is evidence for interface and validation tests, not a production implementation.

````
{
  "inputs": {
    "x": "0000",
    "y": "0001"
  },
  "expected_outputs": {
    "hamming_distance": 1,
    "differing_positions": [
      4
    ],
    "detects_up_to_errors": 0,
    "corrects_up_to_errors": 0
  },
  "working": "Compare positions: 1: 0=0, no difference; 2: 0=0, no difference; 3: 0=0, no difference; 4: 0≠1, one difference. Therefore d=0+0+0+1=1. Detection: d−1=1−1=0. Correction: floor((d−1)/2)=floor(0/2)=0."
}
````

## Other records

[01**Overview**](<https://guthlabs.ai/docs/instruments/hamming-distance-error-detection-calculator/>)[02**Mechanism**](<https://guthlabs.ai/docs/instruments/hamming-distance-error-detection-calculator/mechanism/>)[04**Qualification**](<https://guthlabs.ai/docs/instruments/hamming-distance-error-detection-calculator/qualification/>)

## Sources and evidence

These pointers bind the page to evidence. They do not grant authority or collapse verification into deployment.

- `VERIFIED_LEDGER.json`

- `evidence-tranche4/tranche4-results.json`
