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(Grammar $grammar, private CompletionCosts $costs)

Reuses the grammar's unconstrained fixed point for pruning completed constraint prefixes.

Parameters

Test cases 15
Calls 5
public function minimum(
    list<Symbol> $symbols,
    GenerationPlan<bool> $plan,
    array<string, int> $occurrences,
    bool $nonEmpty,
    int $budget,
): int

Finds the exact constrained minimum before a plan compiler draws its expansion budget.

Parameters

$symbolslist<Symbol>
$planGenerationPlan<bool>
$occurrencesarray<string, int>
$nonEmptybool
$budgetint

Returns

int
Test cases 13
Called from 1
Calls 1
public function within(
    list<Symbol> $symbols,
    GenerationPlan<bool> $plan,
    array<string, int> $occurrences,
    bool $nonEmpty,
    int $budget,
): bool

Stops at the first affordable witness when derivation only needs feasibility, not another shortest proof.

Parameters

$symbolslist<Symbol>
$planGenerationPlan<bool>
$occurrencesarray<string, int>
$nonEmptybool
$budgetint

Returns

bool
Test cases 1
Called from 1
Calls 1
public function complete(
    list<Symbol> $symbols,
    GenerationPlan<bool> $plan,
    array<string, int> $occurrences,
    bool $nonEmpty,
    int $budget,
    bool $minimum,
): int

Reuses completion proofs for equivalent pending forms and pattern counters.

Parameters

$symbolslist<Symbol>
$planGenerationPlan<bool>
$occurrencesarray<string, int>
$nonEmptybool
$budgetint
$minimumbool

Returns

int
Test cases 14
Called from 2
Calls 10
public function search(
    list<Symbol> $symbols,
    GenerationPlan<bool> $plan,
    array<string, int> $occurrences,
    bool $nonEmpty,
    int $budget,
    bool $minimum,
): int

Searches finite frontiers within the caller's expansion budget, without generating or retrying SQL.

Parameters

$symbolslist<Symbol>
$planGenerationPlan<bool>
$occurrencesarray<string, int>
$nonEmptybool
$budgetint
$minimumbool

Returns

int
Test cases 15
Called from 1
Calls 14

Private surface 5§

Implementation details, listed for orientation only.

private CompletionReduction $reduction
private CompletionMemo $memo
private CompletionWitness $witness
private PatternProductions $productions
private CompletionCosts $costs

Test cases 35§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 16
Other tests reaching this symbol 19

Relations§

Instantiated in 2
Method calls 2
Type declarations 1