When is a port the same?
A port preserves a promise when the two implementations agree on the observations the promise covers, for every input it admits.
Choose the observation first
Identify the input range and the output or side effect people rely on. Then ask whether the original and its replacement agree throughout that range.
For every admitted input x:
observe(old, x) = observe(new, x)
This expresses equivalence for one chosen observation. If a specification allows several correct outputs, a replacement may narrow the set while still keeping its promise. See the list example.
One port that fails
Suppose a Java program doubles a signed 32-bit int. For input 1,500,000,000, the Java result wraps to −1,294,967,296. The same multiplication on a Python integer returns 3,000,000,000. On smaller inputs they may agree. The admissible range determines whether this difference matters.
Java integer operations · Python integers
A different problem across releases
Now suppose both implementations do identical arithmetic. One reads the policy approved for Shop A and the other reads Shop B’s. Type checking can succeed in both. Establish the identity of the shop, the applicable revision and the authorized decision before comparing the outputs. If two candidate promises still fit all the evidence, an exact answer requires another record or a decision by the owner.