Finding the First True Value of a Predicate
Binary boundary search can find the earliest true value in an ordered domain when all later values are also true.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a threshold
Suppose a budget from 0 through 100 becomes sufficient at 37. A test at 50 succeeds, so the first success is at or below 50. A test at 25 fails, so the first success is above 25. The assumption is monotonicity.
Handle no successful input
If budget 100 fails, every budget in this domain fails. Return a documented missing result or an outside boundary. Binary search traces show similar behavior when a sorted list has no value meeting a threshold.[1]
Build a predicate that stays true after a threshold
Suppose capacities are integers and a configuration needs at least eleven units. Feasibility is false through ten and true from eleven on. Testing a midpoint that is true lets you keep that candidate and discard all higher candidates when seeking the minimum. See monotone predicates.
Candidates 0 through 16
Test 8: false → keep 9..16
Test 12: true → keep 9..12
Test 10: false → keep 11..12
Test 11: true → answer 11
Define outcomes if no feasible capacity exists
A bounded search can return an explicit absence or an exclusive sentinel beyond the domain. Verify the upper boundary before treating it as feasible. A predicate with gaps in truth does not support this elimination logic.