A Decision Result and a Witness

A decision answers whether a condition is satisfied. A witness supplies the object or positions making a positive answer verifiable.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Try a pair-sum query
  2. Choose the promised output
  3. Verify proposed evidence with independent checks
  4. Explain the different meaning of a negative answer

Try a pair-sum query

For values 3, 5, and 8 a rule asking for a pair summing to thirteen can return true, or positions one and two as a witness. The positions preserve evidence when values repeat. The pair lookup can store that information.

Choose the promised output

A caller may need one witness, the cheapest witness, or every witness. These can have very different costs and algorithms. State the selection rule in the function contract.[1]

Verify proposed evidence with independent checks

A pair-sum decision can answer true for data [4, 12, 8] and target twenty. The witness (1,2) identifies twelve and eight. Verifying a witness requires checking both indices in range, distinctness and the numerical equality. See function postconditions.

Candidate (1,2): 12 + 8 = 20 → valid
Candidate (0,0): repeated position → invalid
Candidate (1,3): index 3 absent → invalid

Explain the different meaning of a negative answer

Failure to find a witness under a complete search proves absence within the model. Failure under a timeout gives an unknown outcome. An interface that returns only a boolean can hide the distinction unless it defines its completion guarantees.

References

  1. Jeff Erickson, Algorithms ↩