TOC Toolkit API - v0.1.0
    Preparing search index...

    toc-toolkit/decisions/context-free

    Budgeted decision procedures on checked context-free grammars and supported pushdown classes. Screens admit a class, preparation checks its shape, and certificates keep the original operands.

    • DPDA against regular languages. Decides both inclusion directions and equivalence of a DPDA and a DFA, NFA or regex, and DPDA universality over an explicit alphabet. A typed API port supplies complement and regular intersection. Positive answers carry Composite evidence whose checker reconstructs both constructions. Negative answers carry a Word checked on the original operands. (createDpdaRegularProcedure, createDpdaInclusionProcedure, createDpdaUniversalityProcedure)
    • Greibach bisimulation. Builds a finite relation on variable sequences by closing all pairs of same-terminal successors. It checks the empty start production and declines when a proposed pair cannot be matched. A budget stop reports exhaustion. (decideGreibachBisimulation, greibachBisimulationProcedure)

    • Census equality. Proves equality from two original LL(1) or LR(1) unambiguity certificates, one induction inclusion and exact algebraic coefficients through an independently derived degree bound. The count system keeps nullable multiplicities and weighted unit paths. Budget exhaustion leaves the question undecided. (Chomsky and Schützenberger 1963; Balaji et al. 2023; decideCensus, censusProcedure)

    • Isomorphism. Proves two grammars equivalent by a bijection of their variables that preserves every production, found as a graph isomorphism of an encoding of variables, productions and symbol positions. (decideIsomorphism, isomorphismProcedure)

    • Orbit equality. Tries normalizations including reduction, concatenation closure, unit closure and the Chomsky normal form trace, and compares the endpoints by isomorphism. A session caches checked positive proofs by canonical grammar hashes. Reuse checks an exact renaming of each operand and joins the proofs by transitivity. (decideOrbit, orbitProcedure)

    • Synchronized linear equality. Decides equality of linear grammars whose context-bearing productions share one ratio of prefix to suffix length. It encodes words by blocks of that ratio, which gives automata that are compared with HKC (Bonchi and Pous, POPL 2013). (decideLinearSynchronized, linearSynchronizedProcedure)

    • Composition and closure. Proves equality of disjoint unions and concatenations from their parts, and of balanced grammars by direct closure. (decideComposition, decideTypeClosure)

    • Visible pushdown equality. Admits height-deterministic pushdown pairs with one verified shared visible partition, empty initial and accepting stacks, and no rejecting controls. It builds the balanced return grammars and keeps both original machines in the checked type-closure claim. (prepareTypeClosure, decideTypeClosure)

    • Bounded equality. Proves equality inside envelopes of distinct or supported repeated tokens by exact covers. The optional third argument selects an arithmetic Backend, with Cooper as the default. A fourth backend requests corroboration and yields CrossChecked trust on agreement. Disagreement declines the attempt. (decideBounded)

    • Periodic word bounds. Proposes the primitive roots of literal runs in derivation order, proves containment in a proposed word envelope with a regular invariant, and tries equality with the existing induction prover. The prefix failure function computes roots over atomic terminals. A proposal alone proves nothing. (discoverWordBounds, primitiveRoot, proveWordBound)

    • Supplied word envelopes. Compares two grammars after proving containment in a supplied product of word stars. A typed construction port supplies the inverse homomorphisms and their intersections with the ordered block tokens. Exact covers give a Semilinear equality certificate. A separating exponent vector gives an original-word BlockExponents certificate. Unsupported count components and failed covers decline the attempt. (envelopeEquality, EnvelopePort)

    • Boundedness recognition. Returns a proved candidate word bound, a direct same-side pumping witness of unboundedness, an unknown result or resource exhaustion. The unbounded witness names two noncommuting terminal contexts at the start variable and a terminal base production. An independent checker verifies those original production identities. The recognizer is incomplete outside these cases. (recognizeBounded, BoundedRecognitionStatus)

    • Finite versus grammar. Decides equality of a finite language and a grammar by two inclusions. Each finite word is parsed with the grammar, and a shortest-yield product of the grammar with a trie of the finite words searches for a word outside the finite set. (decideFiniteVersusGrammar, finiteVersusGrammarProcedure)

    • Finite languages. Compares two finite languages by enumeration, and compares finiteness and emptiness. (decideFiniteBoth, decideFiniteness, decideFinitenessDifference, decideEmptiness)

    • Minimum length. Separates two grammars when their minimum word lengths differ, with a shortest word of the smaller side as the witness. (decideMinLength, minLengthProcedure)
    • Exact slices. Searches increasing word lengths on the reduced Chomsky normal forms and returns a word of the first length in which the complete slices differ. The default limit on word length is 64, far above what the Fuel reaches, so the Fuel and the Words limit end the search. The procedure runs its first grant only to length 8 and keeps its tables, so a pair of equal languages leaves its Fuel to the provers of the Class and General lanes, and the Final lane resumes the search at the lengths that the remaining Fuel pays for. The tables build each length while its estimated Fuel and words fit. When the next length would not fit the Words limit, a deep scan compares that length and the longer ones, and the search resumes where it stopped. The deep scan enumerates the words of the side with fewer candidate words from the stored shorter words, tests every sixteenth on the other grammar with the prepared Earley recognizer, enumerates the other side, and compares the two sets. (refuteBySlices, slicesProcedure)
    • Sampling. Refutes equivalence with sampled derivations. It starts above the longest length that the slices compared, which the procedures of one decision share, reads its sizes from one derivation count table, tests each sample on the other grammar with the prepared Earley recognizer, and reaches length 40 before it starts again with new seeds. (refuteBySampling)
    • Parikh separation. Separates grammars whose exact count images differ. Its search charges the caller's budget and reports the number of candidates tested when that budget stops the search. A stop in an ancestor budget belongs to that ancestor. Its screen refuses a grammar whose count image the bounded solver cannot reach, and its first attempt has a Fuel ceiling. An optional third argument selects a Backend, with Cooper as the default, to test the proposed separating vector against the target image. A fourth backend requests CrossChecked trust and disagreement declines. It also shares completed Parikh formulas for the same reference grammar, pool and coordinate identities. (decideParikhSeparation, parikhFormula)
    • Induction. Proves two grammars equal by two inclusions, each by induction on derivations. It computes the exact words of every variable up to a short length, keeps for each variable of the contained grammar the forms of the other grammar whose words include them, and searches by backtracking for sets of forms that cover each useful variable. It checks every combination of forms in each useful production. Concatenation lemmas support the closure, and a unary count guard proves a singleton inclusion when the target derives the counted word. The proof is a checked certificate of the Induction kind. It runs in the General lane. (decideInduction, inductionProcedure)
    • Valuation separation. Finds integer weights on the terminals and a value for each variable that show one grammar derives only words of one weight, then finds a word of the other grammar with another weight. A value solves the linear system of the useful productions over the integers. The grammar for twice as many a as b has the weights 1 and -2. (decideValuation, valuationProcedure)
    • Regular separation. Separates two grammars with a proved regular superset of one that excludes a derivation of the other. (decideRegularSeparation)
    • Noncanonical unambiguity. Searches flagged original-production position pairs and proves that their closed reachable set has no conflicting completion. The successor relation includes distinct exposed reductions. Potential ambiguity declines the procedure. (Schmitz 2007; decideNoncanonical, noncanonicalProcedure)

    • Regular overlap unambiguity. Computes closed first-token, last-token and capped-length summaries at precision 1. Every original alternative pair and split carries a regular-invariant emptiness proof of its regular overlap. (Brabrand, Giegerich and Møller 2010; decideApproximation, approximationProcedure)

    • Tree census ambiguity. Compares exact original tree counts with complete word slices and extracts two original-production trees when the counts differ. Useful zero-length cycles decline this procedure. (decideAmbiguityCensus, ambiguityCensusProcedure)

    • Regular invariant. Proves that a grammar is contained in the language of a DFA by assigning each variable a relation on the DFA states, closed under relational composition of every production, with the start relation ending in accepting states. (decideRegularInvariant, regularInvariantProcedure)

    • Simple grammars. Decides equivalence of two simple grammars, whose productions are a terminal followed by variables with at most one production for each variable and terminal (Korenjak and Hopcroft 1966). It accepts grammars whose variables all derive words, and builds a finite base of equations between leading variables by cutting each obligation at a shortest word. The search records a congruence derivation for the start and for each successor pair, as a Bisimulation certificate of the form SimpleGrammar. A separate search finds a word that one grammar accepts and the other rejects, as a Word certificate. Both searches charge the caller budget. It runs in the Class lane. (decideSimpleGrammar, simpleGrammarProcedure)

    • One-counter automata. Decides equivalence of two real-time deterministic pushdown automata that have one bottom symbol and one counter symbol and accept by state (Valiant and Paterson 1975; Böhm, Göller and Jančar 2013). It reads each machine as moves that depend on the state, the letter and whether the counter is zero, and drops moves into states that cannot reach an accepting state. A search in order of word length over pairs of configurations gives a shortest word that one automaton accepts and the other rejects, as a Word certificate. When none exists in the searched pairs, it builds a bisimulation from single pairs of small counters and from families of pairs whose counters grow together. A family needs one check for all its members because every move keeps both counters positive. The relation is a Bisimulation certificate of the form OneCounter. The proof covers the automata whose counters keep a fixed distance once they are large, which includes a machine and any renamed or state-split copy of it. It does not build the periodic relation of the general case, so a pair outside that fragment stays undecided. It runs in the Class lane. (decideOneCounter, oneCounterProcedure)

    • Inclusion between two grammars. Decides whether the language of one grammar lies inside the language of another. It walks the words of the smaller grammar in order of length, from the exact word table of its useful normal form, and tests each on the Earley recognizer of the larger grammar. The first rejected word refutes the inclusion with a Word certificate. When the words up to length 6 are all accepted, it runs the induction prover for one direction and, on success, returns an Induction certificate with the forward proof alone. Otherwise it compares words up to length 14. A pair with no short counterexample and no induction stays undecided. It runs in the General lane. (decideGrammarInclusion, grammarInclusionProcedure)

    • Inclusion in a regular language. Refutes inclusion of a grammar in a regular language. (decideInclusionInRegular)

    • Nonmembership. Proves that a word is outside a grammar when the Earley recognizer rejects it. (decideNonMember, nonmemberProcedure)

    • Membership. Parses a word with Earley's algorithm and lifts one parse tree to a leftmost derivation over original production IDs. (membershipProcedure)

    • Rewrite nonmembership. Rejects a word for context-sensitive and unrestricted grammars when a complete search finds no derivation. (decideRewriteNonMember)

    • Ambiguity. Proves a grammar unambiguous from a conflict-free LL(1), LALR(1) or canonical LR(1) table. It finds ambiguity from useful nullable-aware unit cycles, from unifying parser conflicts and from two distinct trees of one word found in slices. Each witness carries original production IDs. (decideAmbiguityLl1, decideAmbiguityLr1, decideAmbiguityCycle, decideAmbiguityCounterexample, decideAmbiguitySlices)

    • Balanced presentations. Finds and compiles a matched presentation of a grammar and recognizes words with it. (discoverBalanced, compileBalanced, recognizeBalancedWord)

    • Syntactic screens. Answer "no" before any preparation when a grammar pair is outside a procedure's class. Linear synchronization needs linear grammars, the finite procedures need a side that no pumping cycle makes infinite, and Parikh separation needs count images that the bounded solver reaches. A screen refuses only when the procedure would decline.

    • Scheduler adapters. Wrap the remaining expert functions for the scheduler. They cover composition, emptiness, finiteness of one grammar and of a pair, comparison of two finite languages, sampling, inclusion in a regular language, the five ambiguity engines, bounded equality, type closure, Parikh separation and regular separation. (compositionProcedure, emptinessProcedure, finitenessProcedure, finitenessPairProcedure, finiteBothProcedure, samplingProcedure, inRegularProcedure, grammarInclusionProcedure, simpleGrammarProcedure, oneCounterProcedure, ambiguitySlicesProcedure, ambiguityLl1Procedure, ambiguityLr1Procedure, ambiguityCycleProcedure, ambiguityCounterexampleProcedure, boundedProcedure, typeClosureProcedure, parikhSeparationProcedure, regularSeparationProcedure, rewriteNonmemberProcedure)

    • Reason explanation. Explains a local refusal in words and maps it to the code of the scheduler. Counter preparation keeps the failed restriction in CounterRefusal, recognised by isCounterRefusal and explained by explainCounterRefusal. (explainContextFreeReason, inapplicableOf)

    • Parikh encoding dump. Prints the coordinate mappings and the formula graph of an encoding. (dumpParikhEncoding)

    • Prepared operands. Dense grammars and their original checked models, captured before a search. (prepareCfg, prepareCfgPair, CfgPair)
    • Parikh encoding. The formula of a grammar with its terminal coordinates. (ParikhEncoding)
    • Prepared questions. Checked operands of one question family, each tied to its original claim. (prepareCfgQuestion, PreparedCfg, prepareComposition, prepareFinitenessQuestion, PreparedFiniteness, prepareInRegular, InRegularPrepared, prepareRegularInvariant, PreparedRegularInvariant, prepareAmbiguityQuestion, PreparedAmbiguity, prepareTypeClosure, PreparedTypeClosure, prepareMembershipQuestion, PreparedMembership, prepareRewriteMembership, PreparedRewriteMembership)
    • Balanced presentation. A matched presentation of a grammar, complete after compilation. (BalancedPresentation)
    • Word bound. An ordered list of nonempty terminal words whose stars form a proposed envelope, with a stable JSON dump. (WordBound, dumpWordBound)
    • Enumerations. Name the closed sets of strings that the types and the wire data of the package use. (ContextFreeProcedureId, ContextFreeReason, CounterRefusalReason)

    Counter preparation funds isRealTime and reports an epsilon move through its existing refusal code. The simple-grammar screen continues to inspect grammars. Its existing terminal-first production restriction excludes epsilon rules and requires one consumed terminal for each grammar step.