classConstrainedCompletion
final class ConstrainedCompletion
Finds the cheapest completion respecting occurrence-specific patterns and pending siblings. Unconstrained grammar costs are an admissible lower bound, never a claimed constrained minimum.
Methods§
public function __construct(private Grammar $grammar, private CompletionCosts $costs)Reuses the grammar's unconstrained fixed point for pruning completed constraint prefixes.
Parameters
$grammar | Grammar | |
$costs | CompletionCosts |
Calls 5
public function minimum(
list<Symbol> $symbols,
GenerationPlan<bool> $plan,
array<string, int> $occurrences,
bool $nonEmpty,
int $budget,
): intFinds the exact constrained minimum before a plan compiler draws its expansion budget.
Parameters
$symbols | list<Symbol> | |
$plan | GenerationPlan<bool> | |
$occurrences | array<string, int> | |
$nonEmpty | bool | |
$budget | int |
Returns
intTest cases 3
Called from 1
Calls 1
- method-call ConstrainedCompletion::complete() line 42
public function within(
list<Symbol> $symbols,
GenerationPlan<bool> $plan,
array<string, int> $occurrences,
bool $nonEmpty,
int $budget,
): boolStops at the first affordable witness when derivation only needs feasibility, not another shortest proof.
Parameters
$symbols | list<Symbol> | |
$plan | GenerationPlan<bool> | |
$occurrences | array<string, int> | |
$nonEmpty | bool | |
$budget | int |
Returns
boolTest cases 1
Called from 1
Calls 1
- method-call ConstrainedCompletion::complete() line 53
public function complete(
list<Symbol> $symbols,
GenerationPlan<bool> $plan,
array<string, int> $occurrences,
bool $nonEmpty,
int $budget,
bool $minimum,
): intReuses completion proofs for equivalent pending forms and pattern counters.
Parameters
$symbols | list<Symbol> | |
$plan | GenerationPlan<bool> | |
$occurrences | array<string, int> | |
$nonEmpty | bool | |
$budget | int | |
$minimum | bool |
Returns
intTest cases 2
Called from 2
Calls 10
- method-call CompletionCosts::hasTerminalOutput() line 64
- function-call
array_valuesline 65 - function-call
array_filterline 65 - method-call CompletionState::key() line 66
- new CompletionState line 66
- method-call GenerationPlan::patternState() line 66
- method-call CompletionMemo::recall() line 67
- method-call CompletionWitness::complete() line 71
- method-call ConstrainedCompletion::search() line 72
- method-call CompletionMemo::remember() line 73
public function search(
list<Symbol> $symbols,
GenerationPlan<bool> $plan,
array<string, int> $occurrences,
bool $nonEmpty,
int $budget,
bool $minimum,
): intSearches finite frontiers within the caller's expansion budget, without generating or retrying SQL.
Parameters
$symbols | list<Symbol> | |
$plan | GenerationPlan<bool> | |
$occurrences | array<string, int> | |
$nonEmpty | bool | |
$budget | int | |
$minimum | bool |
Returns
intTest cases 1
Called from 1
Calls 15
- method-call GenerationPlan::hasRemainingPatterns() line 85
- method-call CompletionCosts::completion() line 86
- new Production line 86
- new CompletionFrontier line 88
- method-call CompletionFrontier::offer() line 89
- method-call GenerationPlan::patternState() line 89
- method-call CompletionFrontier::take() line 90
- method-call ConstrainedCompletion::witness() line 92
- static-call CompletionCosts::add() line 96
- method-call CompletionMemo::recall() line 98
- method-call CompletionReduction::reduce() line 105
- method-call Grammar::sourceRule() line 109
- method-call GenerationPlan::patternAt() line 111
- method-call PatternProductions::matching() line 113
- function-call
array_sliceline 114
public function witness(
CompletionState $state,
GenerationPlan<bool> $plan,
int $total,
int $budget,
): intShares each suffix of the actual successful path, not unrelated visited branches or a sampled impossibility claim.
Parameters
$state | CompletionState | |
$plan | GenerationPlan<bool> | |
$total | int | |
$budget | int |
Returns
intTest cases 1
Called from 2
Calls 2
- method-call CompletionMemo::remember() line 127
- method-call CompletionState::key() line 127
Private surface 6§
Implementation details, listed for orientation only.
private CompletionReduction $reductionprivate CompletionMemo $memoprivate CompletionWitness $witnessprivate PatternProductions $productionsprivate Grammar $grammarprivate CompletionCosts $costsTest cases 28§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
ConstrainedCompletionTest::testCompleteCachesNormalizedPendingFormsWithoutLosingAlreadyEmittedOutputcallsConstrainedCompletionTest::testMinimumCountsOnlyTheUnconsumedPatternSuffixcallsConstrainedCompletionTest::testMinimumIncludesDescendantsSiblingsAndRecursiveOccurrenceConstraintscallsConstrainedCompletionTest::testSearchRetainsAFirstWitnessAsFeasibilityInsteadOfAMinimumProofcallsConstrainedCompletionTest::testWithinRejectsARequiredOutputThatIndependentEmptySubtreesCannotSupplycallsConstrainedCompletionTest::testWitnessCachesOnlyTheChosenSuffixAndKeepsMinimumQueriesIndependentcalls
Other tests reaching this symbol 22
BytePlanCompilerTestcallsBytePlanEncoderTestcallsPlanBuilderTestcallsCompletionMemoTestcallsCompletionReductionTestcallsConstraintDependenciesTestcallsDerivationTestcallsDerivationTraceTestcallsTokenGeneratorTestcallsLexemeSequenceTestcallsCandidateResolverTestcallsSqlGeneratorTestcallsTerminalSequenceTestcallsGenerationContextTestcallsSqlGeneratorFactoryTestcallsMySqlProviderTestcallsGenerationContextTestcallsSqlGeneratorFactoryTestcallsPostgreSqlProviderTestcallsGenerationContextTestcallsSqlGeneratorFactoryTestcallsSqliteProviderTestcalls