Manuscript Offprint
arXiv:2611.12618Type-logical grammars and formal languages
1 Introduction
In a recent article, Pshenitsyn (2025, Section 4) provides a new lower bound for the string languages generated grammars in first-order linear logic, showing we can generate grammars in the class , the context-sensitive languages generated in non-deterministic linear time.
The basic idea is modelling context-sensitive rewrites as Lambek calculus formulas , then using the Lambek calculus product to add a constant number of these formulas to each lexical entry of the grammar. So if is a first-order linear logic formula, and are not necessarily different formulas of the form (for all atomic), then we add for all choices of formulas .
This construction adds a number of rewrites to an existing grammar, each rewrite replacing a sequence of atomic formulas by another. Given that at most a constant number of rewrites is added to each word of the input sequence, at most a linear number of rewrites can be added in total. This gives a lower bound on the string languages generated by grammars in first-order linear logic. We know (Book 1978). Given that the context-sensitive languages are generated in non-deterministic linear space, , where equality would entail . So the full picture of the string languages of first-order linear logic is as follows.
What makes the construction work is that in first-order linear logic, we can ensure that the rewrite rules commute freely. At its base, first-order linear logic is a commutative logic, and, where needed, non-commutativity is enforced by the use of string positions.
Given the result by Book (1978) showing that fixed recognition for is NP complete, Pshenitsyn (2025) showed that fixed recognition for MILL1
The first inclusion is strict because the language is not in but is a tree adjoining language, and therefore in MILL1. I conjecture that as well, possibly with a condition that the first-order logic doesn't use term symbols.
grammars is NP complete as well. MILL1 grammars therefore have NP complete fixed recognition together with NP complete universal recognition.
In this paper, we will do two things. First we will show that even though most type-logical grammars operate with a non-commutative base logic, the mechanisms used for common linguistic constructions can be used to adapt the construction of Pshenitsyn (2025) to any modern type-logical grammars which has product formulas, associativity , an extraction operator or any way to prefix constituents, and a non-deterministic infixation operation. We will show that any type-logical grammar formalism having all these ingredients will have NP complete fixed recognition as well.
Second, we will show how the quasi-linear languages , that is, the class of languages generated in non-deterministic linear time (, ) can be generated by grammars in first-order linear logic. The quasi-linear languages are an interesting but powerful class of formal languages. The quasi-linear languages are the smallest abstract family of languages (AFL) closed under intersection. While Pshenitsyn (2025) already showed that MILL1 grammars are closed under intersection, this shows that MILL1 grammars can also generate languages like the exponential language , which can not be generated by intersections of context-free grammars.
This gives us new lower bounds for the class of languages generated by type-logical grammars, for first-order linear logic and for other type-logical grammars.

It would seem that NLIN strictly contains TAL and probably also MCFL. We will see later that at least the iconic mildly context-sensitive languages are in NLIN. We will see that there are also a number of languages outside of these classes which can be generated by NLIN, notably the exponential language and languages whose relation with these classes is currently unknown, such as the generalised MIX languages.
NLIN should be contrasted to the better-known class LOGCFL. LOGCFL is the class of problems which are logspace many-one reducible to the context-free languages. In terms of automata, they can be seen as non-deterministic Turing machines with a single stack (like context-free grammars) and with a logspace auxiliary store (Sudborough 1978). For NLIN, the auxiliary tapes have linear storage, but the time bound for computation is linear as well (Book & Greibach 1970).
Or any form of modally licensed associativity.
The precise relation between NLIN and LOGCFL is unknown and would seem to require important progress in complexity theory to be resolved, notably on the relation between logarithmic space with polynomial time and linear space with linear time.
| Formalism | Storage | Time |
|---|---|---|
| CFL | 1 stack | polynomial |
| LOGCFL | 1 stack, 1 logspace Turing tape | polynomial |
| NLIN | 1 stack, 1 linear Turing tape | linear |
For NLIN, we can see the three stacks as one stack (corresponding to the stack automata, like with context-free grammars) and one Turing tape (since two stacks can emulate one Turing tape). The key question is then whether one linear-space Turing tape with linear time is enough to emulate a log-space stack with polynomial time.
2.1 The linear-time context-sensitive languages
Although most work in formal language theory with applications to formal linguistics has focused on extensions of the context-free languages, some authors, notably Book (1978) and Dahlhaus & Warmuth (1986) have looked at restrictions of the context-sensitive languages instead.
There are a number of equivalent ways of defining context-sensitive grammars. However, since we are interested in linear-time context-sensitive grammars, we choose a very general definition.
Definition 2.1 A context-sensitive grammar is a phrase structure grammars where all rules are of one of the following two forms
Where and are non-empty sequences of non-terminals such that
It is well-known that the context-sensitive languages correspond to linear-bounded Turing machines, that is, the context-sensitive languages can be recognised in .
Book (1978) studies the languages generated by context-sensitive grammars in , a class he calls . He shows that is strictly included in and that fixed recognition for is NP-complete.
Irreversible, asynchronous
Reversible, synchronous
Figure 1: Sequent calculus rules for the Lambek calculus
2.2 The Lambek calculus
The Lambek calculus was introduced by Lambek (1958) as a logic designed for parsing natural language sentences. It is based on the idea that a grammatical sentence corresponds to a theorem in the Lambek calculus, through the intermediary of a lexicon which is a function from words to sets of formulas.
The Lambek calculus starts from a fixed set of atomic formulas. In a linguistic context, these often correspond to basic grammatical categories: n for common noun, np for noun phrase and s for sentence. We can then form complex formulas using three connectives.
The connective looks for a to its right to form an . So a formula looks for a noun to its right to form a noun phrase.
Similarly, the connective looks for a to its left to form an . For example, a formula looks for a noun phrase to its right to form a sentence.
Finally, the connective denotes the concatenation of with . While it is a part of the logic, it is rarely used for grammars.
Figure 1 shows the rules of the (cut-free) sequent calculus for the Lambek calculus.
Now, given a lexicon.
The following proof shows that, given the lexicon above, the sentence ‘a program halts’ is grammatical.
Pentus (1995) proved that Lambek grammars generate exactly the context-free languages, but even before this many authors worked on extensions of the Lambek calculus more suitable for natural language while preserving its good logical properties, such as cut elimination and model theory. I will use the general name type-logical grammars for this research program.
Focusing proof search was introduced for linear logic as a way of eliminating the inessential rule permutations from sequent calculus proof search (Andreoli 2000).
Definition 2.2 A proof is focused if the proofs alternates between reversible and irreversible phases until it reaches the atoms as follows.
-
If our sequent is of the form with an atomic formula, this subproof is correct.
-
If a reversible rule can be applied to the sequent, we apply this rule.
-
If no reversible rules can be applied, select a formula and focus it. We apply irreversible rules on this focused formula and its subformulas until we reach either atoms or reversible subformulas, continuing the proof with step 1.
Lemma 2.3 If is derivable, then it is derivable with a focused proof.
3 Type-logical grammars and linear-time context sensitive languages
In this section we show that all type-logical grammars with the following elements have an NP-complete fixed recognition problem.
-
Associativity, including partial associativity, such as modally licensed versions of associativity
-
The Lambek calculus product rules and
-
Medial extraction
-
Non-deterministic infixation
Items 1 and 2, the product rules and associativity are the standard rules for the Lambek calculus. In what follows, we will first show that a logic having all four of the above elements has an NP-complete fixed recognition problem, using the construction of Pshenitsyn (2025). Then we will show that many prominent type-logical grammars satisfy all these four conditions. The first three are relatively standard, given that most of the extensions of the Lambek calculus have been motivated by giving a better account of medial extraction than the Lambek calculus. While an explicit non-deterministic infixation rule is not as common, we will see that it is relatively easy to implement this behaviour given the standard tools of these logics.
3.1 Extraction and infixation
Moortgat (1988, 1996) proposes the following rules for extraction and infixation in extensions of the Lambek calculus.
He notes that the combination almost behaves like a generalised quantifier, modelling Montague's ‘quantifying in’ operation but in the absence of a mechanism to ensure the noun phrase and the quantifier occur in the same space. In other words, while the following pattern is valid.
However, the rule allows us to insert the np anywhere, not just at the position of the original formula.
Many solutions have been proposed to turn a system with rules like and into a full logic, adding both rules which would correspond to and and a mechanism to ensure identity between the extraction and infixation point in the rule combination shown in 2. We will see a few of those in what follows. The important point is that these extensions still allow us to emulate the and rules and that the non-determinism of the insertion is one of the key elements which allows us to simulate string rewrites.
3.2 String rewrites with extraction and infixation
To simulate the analysis of Pshenitsyn (2025), we use a two-step process. Lexical formulas are assigned formulas of the form where is an atomic formula, and all are formulas which move in two steps. First, the of all lexical entries move a subformula to the front of the sequent, leaving us with a sequent of the following form
Then, each formula inserts a subformula between the allowing it to apply the rewrite . We will write for a formula representing one of this rewrites.
For the first step, we need to show that we can move the to the front of
Moortgat uses where we use (note the swapped argument and result), and where we use . We changed the notation both to distinguish these connectives from the ones in the Displacement calculus and to highlight the similarities.
the sequent while keeping p in place. This is done as follows.
For the second step, we take one of the possible rules and move it to the left of a sequence of atomic formulas which corresponds to the left-hand side of its rule.
If we look at the /L rule in the top left of 4 in more detail, it looks as follows (where is ).
The net result is that we have eliminated one of the rules, and performed one rewrite step.
A lexical entry for a word assigned atomic formula in the lexicon then has the general form
with each of the following form
with representing a rule instance from R.
Now it is easy to establish the following invariant: the atomic formulas represent the current sequence of non-terminal symbols, whereas all subformulas represent the context-sensitive rules still to be applied.
Lemma 3.1 If a sequent containing entries of the form shown in 6 is derivable with goal formula s, then it has a proof which proceeds in the follow three phases.
-
phase, where separate the atomic formulas from the prefixation formulas .
-
A prefixation phase, moving the formulas to the front of the sequent using the and rules as shown in 3.
-
An infixation phrase, moving the subformulas as shown in 4.
Proof Focusing proof search guarantees we can apply all rules first, but also that both the combinations of and of phase 2 and the combination of , , and of phase 3 are a single alternation of irreversible and reversible rules. So we only have to show that any infixations which occur before a prefixation can be permuted. We proceed by induction on the number of infixations which are followed by prefixations. If there are none, we are done. If not, we look at the topmost infixation and the lowest prefixation. This gives the following situation schematically
The top two rules and are the prefixation part and we can move them to be the bottom two rules of the subproof as follows.
The case where the formula is infixed into is symmetric.
3.3 The Displacement calculus
The Displacement calculus of Morrill et al. (2011) provide one way to turn the extraction and infixation connectives of Moortgat (1996) into a full logic. This is implemented by using a 'marker' 1 to indicate the extraction point used by the extraction rule. The infixation rule then replaces this marker by the formula to be infixed. This combination of rules is then used for the treatment of generalised quantifiers and other linguistic phenomena.
However, the Displacement calculus also provides ways both to remove this extraction symbol (necessary for the treatment of extraction) and to add one.
We can simulate as and as as follows.
Both are standard idioms in the Displacement calculus: is used in the analysis of extraction, and for parentheticals (Morrill et al. 2011, Sections 3.2.2–3.2.5).
A lexical entry for a word assigned atomic formula in the lexicon then has the general form
Each is then of the following form.
With representing a rule instance from R.
3.4 The associative logic of scope
Barker & Shan (2014) and Barker (2019) propose the logic the logic of scope . While this logic is non-associative, we are interested here in the version of the logic associativity added, . This translation does not extend to the original, non-associative logic since the formulas rewrite trees of atoms instead of sequences on atoms as required for the translation to work.
The set of rules needed for what follows is listed below. It is a relatively standard multimodal categorical logic with two families of connectives, and a connective representing the empty string. What distinguishes the logic from others are the and rules. Inspired by reduction and expansion for the lambda calculus, these rules allow use to move a constituent into and out of a position marked by lambda abstraction.
For the associative version of Barker's logic of scope, we can define as . As in the Displacement calculus, this is just the standard treatment of extraction in the logic.
Similarly, we can define as
\begin{array}{r l}&{\frac{\Delta,\Delta^{\prime}\vdash C}{\Delta,\epsilon,\Delta^{\prime}\vdash C}\;\epsilon}\\ &{\frac{\epsilon\odot\lambda x.(\Delta,x,\Delta^{\prime})\vdash B}{t\odot\lambda x.(\Delta,x,\Delta^{\prime})\vdash B}\;t L}\\ &{\frac{\lambda x.(\Delta,x,\Delta^{\prime})\vdash t\mathbin{\Downarrow}B}{\Gamma,(A\mathbin{\Downarrow}(t\mathbin{\Downarrow}B))\odot\lambda x.(\Delta,x,\Delta^{\prime}),\Gamma^{\prime}\vdash C}}\;\beta}\\ &{\quad\Gamma,\Delta,A\mathbin{\Downarrow}(t\mathbin{\Downarrow}B),\Delta^{\prime},\Gamma^{\prime}\vdash C}\end{array} \tag{14}A lexical entry for a word assigned atomic formula in the lexicon then has the general form
Each is then of the following form.
With representing a rule instance from R.
3.5 Hybrid type-logical grammars
Hybrid type-logical grammars were introduced by Kubota & Levine (2012, 2020) as a way of combining the standard Lambek calculus connectives with lambda terms for more flexible string operations (Oehrle 1994).
Because of the way lambda calculus connectives connect with the other connectives of the logic, hybrid type-logical grammars do not allow formulas of the form , since the lambda calculus connective cannot have a subformula containing the linear connective . However, we can use lexical entries which would correspond to in the Displacement calculus. This will give us formulas of the following schematic form
Lexical entries of this form use standard quantifying in for the formula, ensuring the formula will return to the place of the full formula, with the connective ensuring that the formulas appear at the front.
This alternative analysis looks as follows in the Displacement calculus.
Compare proof 17 to proof 3 to verify we obtain the same conclusion from the same premisses in both proofs.
Translating this analysis to hybrid type-logical grammars is done as follows. As a first step, the formula above is translated as follows.
Then, will be of the following form.
The missing part is then the lambda term to assign to this formula. For a word in the lexicon, the following term does everything we need.
The first argument of is the word in a standard quantifying-in analysis, then the second argument of simply ensures that the string corresponding to the formula is the empty string. So this term, while looking a bit complicated, is simply the combination of a standard treatment of quantifying-in with a standard treatment of extraction.
The following proof and beta reduction sequence show that everything works as intended.
In full generality, we need multiple formula and therefore the following formula.
with each as before.
The corresponding lambda term then looks as follows, applying the standard extraction pattern to each of the corresponding to and the quantifying in pattern to p.
3.6 Multimodal type-logical grammars
Finally, for multimodal type-logical grammars, we can use a much simpler solution. In a multimodal logic, we can use the idiom to allow a formula to permute throughout the sequent, then function as an formula after its movement.
The key logical and structural rules making this possible are listed below.
This assumes an associative base logic. However, we can adapt to the non-associative case by simple adding a second pair of unary modalities for controlled associativity, as shown by Kurtonina & Moortgat (1997).
We then assign formulas of the following form to the lexical entries.
This analysis is simpler than for previously discussed systems (and close to the way Pshenitsyn (2025) implements this for first-order linear logic) because we have no need of forms lifting to permute subformulas, and we can use the permute modality both to move the formulas corresponding to context-sensitive rules 'out of the way' (so they don't block the application of another context-sensitive rule) and to move them to the correct position when their rule needs to be applied.
Compared to the results of Moot (2002), who gives a tight bound of CSL for multimodal type-logical grammars, we use a more standard and more restricted set of structural rules.
3.7 Corollaries
Pshenitsyn (2025) used Theorem 1 from Book (1978), showing that there are fixed languages in for which the decision problem is NP complete, to show that fixed recognition for string grammars in first-order linear logic is NP complete as well. As a consequence of the translation of grammars into the Displacement calculus, the associative logic of scope, and hybrid type-logical grammars, fixed recognition for all these formalisms is NP-complete as well.
Corollary 3.2 Fixed recognition for type-logical grammars in NP complete
While
Corollary 3.3 Unless , type-logical grammars are more powerful than mildly context-sensitive formalisms.
One of the defining characteristics of mildly context-sensitive formalisms is polynomial fixed recognition
For multimodal type-logical grammars, this gives a lower bound and a CSL upper bound, plus an NP-hard fixed recognition problem. Finding a tight upper bound for the other formalisms remains an important open question.
All these formalisms are therefore quite powerful, and it makes sense to look for restrictions ensuring polynomial or LOGCFL fixed recognition.
The following language is not in (Book 1978).
While some authors prefer polynomial parsing, I prefer polynomial fixed recognition, since it is more clearly a property of classes of formal languages.
In this language, ranges over sequences of , and this sequence is both reversed (indicated by ) and copied. However, this language is a simple tree adjoining language, and can therefore be generated by the type-logical grammars we've discussed in this paper.
3.8 Possible restrictions
Summarising the results so far, we have shown that the results of Pshenitsyn (2025) can be adapted to many other type-logical grammars, showing these formalisms generate a larger class of string languages than was previously known.
The construction pushes the limits of these formalisms by exploding the size of the lexicon.
-
The and are needed for modelling the rewrite rules beyond context-free: is needed for complex right-hand sides of rules, whereas is needed to decompose a previously generated formula into a sequence of atoms so that a next rule can apply.
-
While medial extraction would be difficult to eliminate because of the many linguistic applications, I believe this is less clear for the arbitrary infixation operation exemplified by Moortgat's and Morrill e.a.'s , where applications are more limited. However, is definable as , and we cannot just remove the connective from the Displacement calculus, or from the logic of scope, since these connectives are used for extraction as well.
-
Associativity is needed to model the string rewrites. Switching to a fully non-associative system is possible, but this means losing some of the benefits of associativity for treating linguistic phenomena like right-node raising. Absent associativity, the current construction would amount to a linear-time tree rewrite system, and that still seems powerful.
-
We could restrict the order of formulas in the lexicon. The construction as given in this paper uses formulas with order 5. This is a bit high. In general, order 3 or 4 suffices for grammatical purposes. So unless the construction can be made to work with lower-order formulas, this gives a possible restriction. While the order restriction is reasonable for hybrid type-logical grammars, the Displacement calculus and the associative logic of scope, for multimodal type-logical grammars and first-order linear logic,
This language can be generated in deterministic linear time (LIN): using three pointers , start with at the beginning of the string, move and right until the second , then move and forward, backward and verify all three pointers point to the same symbol, succeed if and are at the same position pointing to and is at the end of the string. Fail in all other cases.
If we calculate the order of formulas containing products in the same way Pentus (2010) does, the order of our formulas becomes 6, since the order of a formula is 2 instead of 1. I like this way of calculating order, since it ensures formulas of order 1 are essentially Horn clauses.
the construction uses formulas of very low order: order 1 according to the standard calculation, and order 2 when using Pentus's additional term for products.
-
Best-case scenario would be a restriction to growing context-sensitive grammars (Dahlhaus & Warmuth 1986). This would guarantee polynomial parsing for fixed grammars and LOGCFL complexity. While this is easy to enforce on formulas of the form by requiring , this restriction would need to be generalised is some way to all formulas in our logic. However, I doubt that there are reasonable restrictions on our logics which would ensure the planarity requirement of proof traces needed for the complexity result of Dahlhaus & Warmuth (1986). That is, restrictions which would enforce the planarity requirement without giving up the expressivity needed for linguistic applications.
-
Another best-case scenario would be an extension of the results of Guerrini (1999) and Murawski & Ong (2000) to show linear time verification of correctness for proof nets in first-order linear logic. This would show that the class of languages generated in first-order linear logic is exactly characterised by the class NLIN.
4 NLIN grammars in first-order linear logic
4.1 NLIN automata and their grammars
Book & Greibach (1970) study the class of formal languages generated by non-deterministic Turing machines in linear time, i.e. . They call this class NLIN, and show that this complexity class corresponds to a number of different classes of automata. They call the class of languages generated by such automata , the quasi-linear languages.
There are multiple equivalent ways to define NLIN automata, using stacks and/or Turing tapes. For simplicity, we use the version which only has stacks. Although we can allow any number of stacks, Book & Greibach (1970) show that we can convert any NLIN machine with stacks into an equivalent machine with 3 stacks, or, equivalently 1 stack and 1 Turing tape (since two stacks can be used to simulate a Turing tape). We will therefore use, without loss of generality, the model with 3 stacks. The model with one stack corresponds to the standard stack automaton used to generate the context-free languages. While we know that machines like this with 2 stacks are already strictly stronger than the ones with only a single stack, it is unknown whether machines with 2 and 3 stacks are equivalent.
It is interesting to contrast NLIN to LOGCFL, a class more often found in mathematical linguistics.
| Class | stack size | Turing tape length | time |
|---|---|---|---|
| CFL | n | none | polynomial |
| NLIN | n | n | linear |
| LOGCFL | n | polynomial |
The main difference is that LOGCFG has a logarithmic space Turing tape and polynomial time for computing, whereas NLIN has a linear space Turing tape and linear time compute.
An NLIN machine only makes a single left-to-right scan of its input, but it can store the input string on one of its stacks. Like a standard multi-tape Turing machine, it has a state and can scan the input symbol and the top symbols of all of the stacks.
Book & Greibach (1970) prove a number of results about NLIN automata and the quasi-linear language generated by them:
-
we can convert any NLINautomaton into an automaton using only a constant number of steps between each scan of an input symbol (Book & Greibach 1970, Theorem 2.1),
-
we can convert any NLINautomaton into an equivalent automaton such that accepts iff accepts using exactly steps (Book & Greibach 1970, Lemma 1.1),
-
the quasi-linear languages are the smallest AFL containing the context-free languages and closed under intersection (an AFL, an abstract family of languages, is a class of languages closed under union, concatenation, Kleene +, non-erasing homomorphic mappings, inverse homomorphism and intersection with regular sets) (Book & Greibach 1970, Corollary 1.2),
4.2 First-order linear logic
Figure 2 gives the cut-free sequent calculus rules for first-order linear logic. The reversible quantifier rules have the standard conditions that the eigenvariable of the eliminated quantifier does not occur free in or . The irreversible quantifier rules and allow us to replace the quantifier variable by any term . In practical theorem provers, we will generally use unification to find the most general term which makes the sequent provable during proof search. Even though complex terms are allowed in first-order linear logic, we only need constants in what follows.
As is clear from the rules, we use the intuitionistic, multiplicative fragment. Antecedents are multisets of formulas, so there is no need for an explicit commutativity rule.
4.3 Multitape online Turing machine
An -tape Turing machine is an -tuple where:
is the finite set of states
Irreversible, asynchronous
Reversible, synchronous
Figure 2: Sequent calculus rules for fist-order linear logic
is the finite set of input symbols
is the number of tapes
is the finite set of tape symbols for tape
is that starting state
is the set of final states
is the transition function.
Let and be, respectively the symbol sets and (for ). Then the transition function is a function from to finite subsets of
An instant description of such a machine is a tuple , where the initial configuration is (for input string and empty stacks ) and final states are of the form (for , an no remaining symbols on the input string and the stacks).
We interpret, given a state , an input symbol , and the top symbols of the stacks, it non-deterministically returns a new state and adds a fixed number of symbols to each stack. The symbol for the input means no symbol is read or removed.
For a machine with stacks, each transition changes a machine state as shown in 18 below.
We look at the input symbol and the top stack symbols ( and some or all of the can be ). Note that we use to convention that the topmost stack symbol is written at the rightmost position.
Scan the input symbol and move right
Pop the top symbol from stack
Push the sequence to stack .
This is a standard definition of a multi-tape, online Turing machine where each tape is a stack. This restriction allows us to simplify the more general definition of Book & Greibach (1970).
4.4 Encoding NLIN machines and states into first-order linear logic
For our encoding we use the following atomic formulas and basic predicates.
word word occurs between positions and on the input string,
head the read head is at position on the input tape,
stack(n, s, n+1) symbol occurs on position , of stack ,
head(n) the head of stack is on position .
, atomic formulas representing the current state of the Turing machine.
By convention, the empty input string corresponds to word, and the empty stack to stack(0, , 0)
Our basic input is going to look like a standard first-order linear logic grammar, with a sequence of input symbols , with each symbol assign position numbers , from which we want to derive a goal goal state state().
4.5 Input sequence and goal formula
We will need to introduce a number of additional formulas, representing the stacks and the Turing machine actions. We add all information for the starting state to the goal (succeedent) formula.
For each symbol on the input sequence, we assign it a formula of the following form
where is the symbol on the input tape between positions and , and the are up to actions from the possible machine transitions.
This ensures we have a standard first-order linear logic lexicon with, by construction, a number of Turing machine operations which is linear on the size of the input string. When is the length of the input string and is the maximum number of operations added to lexical entries, the Turing machine performs at most steps.
The goal formula adds the additional information needed to get the Turing machine into its initial state. We need to do a number of things:
-
enter the machine at its initial state
-
set the head of the input tape to the first position of the input string
-
initialise the three stacks to the empty stacks, with the stack head at the top.
-
have a final state as goal
-
require that the input has been fully read and that all stacks are empty at the end
Empty stack
Initial state (unique)
Final state (non-deterministically chosen from the set of final states ):
Taking everything together, the goal formula will look as follows.
The two atoms in the antecedent and the succedent ensure we start in the initial state and end in a final state .
The word predicate in the antecedent adds at the end of the input string (position ). The subformula in the succedent ensures that the head is at the rightmost position at the end of the computation.
Finally, the formulas in both the antecedent and the succedent of the formula ensure that all stacks start and end empty.
In our representation, , R represents the rightmost (head) position of the stack. The initial position of each stack is 0, other positions are unique variables generated by the quantifier rules.
4.6 Turing machine operations
Now that we have defined the basic structures and inputs, we define the machine operations as first-order linear logic formulas. The push operation adds a number of symbols to one of the stacks, the pop operation remove the top symbol from one of the stacks, and the scan operation reads a symbol from the input string and moves right.
We start with the push operation, which is the most complicated one. First, we define an auxiliary push predicate which we use to build to complete PUSH formula. Given a position , we generate a sequence of symbols as follows
where will be the new stack head.
Push on stack (this is the case).
We can define the operation, which verifies the top symbol of stack k is s and remove it, as. follows.
Check the current input symbol is s and move right.
For convenience we can also add a formula REPL which check the top symbol of stack is , then pops the top element and replace it by (this is just a combination of POP and PUSH).
The final type of formula we use is the state transition
Given two formulas and of the form shown below.
and
We define their composition as follows.
(23)
Now, each machine action is a combination of a state transition, a possible input scan, plus a possible stack operation for each of the three stacks. We should be careful, though, since we cannot just combine the different elementary operations by ‘⊗’ since we need to enforce all different elementary operations which are combined into a single machine action are applied before then next machine action. This is why we combine the operations using composition ‘o’ instead.
Since each elementary machine action is translated by a formula of the form required for composition, we can combine these elementary actions into a single formula representing the transition.
Now let be the formulas corresponding to the transitions in the Turing machine, and let be the constant such that the machine accepts all words in time . The lexicon for our first-order linear logic grammar for each symbol will then be of the set of formulas such that , each is equal to for some . In other words, when the character is part of the input string at position , then we select this word in combination with any number of machine actions up until the bound . Note that it is possible to select the same action multiple times.
Similar to the linear-time context-sensitive languages, the resulting lexicon has a very high number of entries per character: given k machine transitions and linear bound c, there will be different lexical formulas for each character.
Lemma 4.1 Let m be a linear-time Turing machine with three stacks, let l be the grammar in first-order linear logic corresponding to the translation of m, and let be a word. Then m accepts iff the corresponding string is derivable in the first-order linear logic grammar l.
Proof (sketch) The lexicon and the goal formula generate the input configuration plus all linear choices of machine transitions.
The key invariant for showing we correctly implement machine actions like this is most easily shown by using focused proof search for a first-order linear logic. Given the way our translation creates formulas, different choices of focus correspond to different machine actions (among the linear number of action occurrences available at the start of the proof), and at the end of each synchronous phase and its subsequent asynchronous phase in focused proof search, exactly one machine transition has been performed.
Each selection of a focus formula corresponds to selecting which transition to apply. The positive A subformulas will test whether the preconditions of the transition are satisfied. We defocus when we reach a negative or formula. These are removed in the asynchronous phase, with rules creating new positions for material added to the stack, and the rules adding the information of the new machine state.
Example The following automaton, with input state and output state generates the language .
The operation is fairly simple: in its starting state , it scans occurrences of a and pushed the symbol d to the first two stacks for each a encountered.
The transitions in 24 to 29 are translated as linear logic formulas 40 to 45 below.
Fully spelled out, formulas 43 to 45 look as 46 to 48 below.
4.7 Languages in NLIN
We have already seen that we can generate , one of the canonical mildly context-sensitive languages, in NLIN. So the natural question is whether we can do other canonical examples as well.
Counting dependencies First, note that we only needed two stacks for the language , and that we can generalise this to more complex patterns of the form for any , by generalising the following strategy.
Phase 1 Scan a, push a on stack 1
Phase 2 Scan b, pop a from stack 1, push b to stack 2
Phase 3 Scan c, pop b from stack 2, push c to stack 1
Phase 4 Scan d, pop c from stack 1
The basic idea is to change stacks at each change of symbol, pop the stack for the previous symbol to verify it occurs as many time as the current one, and push the current symbol onto the next stack to allow us to verify later it occurs as many times as the next symbol.
The fact that only two stack suffice to generate this entire hierarchy tells us that even when restricted to two stacks NLIN is already a very powerful tool for describing language classes.
Crossed dependencies Another
Phase 1 Scan a, push a on stack 1
Phase 2 Scan b, push b on stack 2
Phase 3 Scan c, pop a from stack 1
Phase 4 Scan d, pop b from stack 2
In this case, it seems we need more than two stacks for the generalised versions of the language, like . Adapting the previous strategy to this more complex example would require 4 stacks, but by Book & Greibach (1970) we know we can reduce that number to 3 (for any number of stacks > 3).
Copy language
Phase 1 Scan a or b, push the scanned symbol on stack 1
Phase 2 Scan a or b, push the scanned symbol on stack 2
Phase 3 Until both stacks are empty, pop the first symbol from both stacks and verify they are equal
Generalising, we can use n stacks for n copies in the same way, and again use Book & Greibach (1970) to limit ourselves to 3 stacks.
MIX The automaton with single state and the following set of transitions generates the MIX language
It operates by pushing each of the symbols a, b, and c to separate stacks, and allowing a pop operation only on all three stacks simultaneously.
As before, we can use n stacks for generalisations of MIX with n symbols in the same way, then use Book & Greibach (1970) to limit ourselves to 3 stacks.
Exponentials A standard non-semilinear language is the language .
We can generate this language using two stacks and successively halving the input as follows.
Succeed if the input tape has a single symbol. Scan the input tape, put every second symbol on stack 1 Fail if there is an odd number of as.
Stack 1 now contains n/2 symbols.
Succeed if stack 1 has a single symbol, if not Pop 2 symbols from stack 1, push 1 symbol on stack 2 Fail if stack 1 contains an odd number of symbols.
Continue alternating between stacks and halving until either a fail or a success state is reached
The total time complexity of this is
5 Discussion
The quasi-linear languages of NLIN are a relatively powerful class of languages and it remains to be seen how NLIN relates to other complexity classes in formal language theory, like LOGCFL, or to other language classes like RCL, the class of languages generated by (positive) Range Concatenation Grammars, another powerful formalism proposed for natural language.
LOGCFL is the class of languages logspace reducible to the context-free languages. It is often considered a natural upper bound on the class of languages adequate for describing natural language.
Given that LOGCFL is a space complexity class and NLIN is a time complexity class, it would seem that proving a definite result relating the two classes would be very hard. It would similarly be hard to show that NLIN is a proper subset of the context-sensitive languages, as this would require showing that non-deterministic linear time is included in linear space.
I believe that NLIN is an interesting alternative to classes like LOGCFL as an upper bound for formalisms intended to be applied to natural languages: the string languages generated by formalisms proposed for natural language should at most be in LOGCFL with respect to space complexity and at most in NLIN with respect to time complexity.
5.1 Properties of formal languages
Mildly context-sensitive languages The mildly context-sensitive languages have a positive part and a negative part in their definition.
The positive defining characteristic are
-
generating the context-free languages.
-
generating a limited set of non-context-free patterns such as , , and .
The negative defining characteristics are
-
polynomial fixed recognition, that is, when the grammar is fixed there is an algorithm in P which decides whether or not strings are in the language.
-
semilinearity, that is, the language generated is permutation-equivalent to a regular language. As a consequence, this means there are no 'gaps' in the length between strings generated in the language
The formalisms we have seen in this paper, with the exception of the Lambek calculus, satisfy the positive characteristics but fail the negative ones yet still appear to be weaker than the context-sensitive languages. To make discussion easier, I will call formalisms which fail one of the two negative characterisations medium context-sensitive and those which fail both to be spicy context-sensitive. We will apply these adjectives only to classes which are subclasses of the context-sensitive languages with a fixed recognition problem in NP.
Given that polynomial fixed recognition generally comes with relatively high polynomials, typically at least , is is not clear to me that this is necessarily better than NP-complete for real-world applications.
I do agree that semilinearity is a desirable property to have and would love to find some restriction to type-logical grammars and first-order linear logic which guarantees it. This necessarily means abandoning intersection, but I believe the case in favour of intersection is much weaker than the case for semilinearity.
Homomorphism One of the defining properties of being an AFL is closure under (non-erasing) homomorphisms. Homomorphisms have a surprisingly strong effect on the expressivity of formalisms like NLIN and RCG, even when homomorphisms are restricted to non-erasing or even letter-to-letter homomorphisms.
Boullier (2000) argues that a polynomial time parsing guarantee requires choosing between intersection and homomorphism and chooses intersection. For example, strings like are logical formulas together with a certificate showing this formula to be decidable (in this case, setting to false and to true). Deciding whether a formula combined with an assignment to all its atomic formulas is satisfiable is something we can do in P and therefore with an RCG. However, the letter-to-letter homomorphism transforms this string to . We have simply erased the assignments turning the strings of the polynomial language into a the classic NP-complete problem of satisfiability. Therefore, unless P=NP, RCG are not closed under homomorphisms.
For NLIN, we know that the intersections of context-free languages form an infinite hierarchy (Liu & Weiner 1973), but that adding letter-to-letter homomorphism collapses this hierarchy at level 3 (Book & Greibach 1970, Theorem 4.1).
It is easy to see that lexicalised formalism like type-logical grammars are closed under letter-to-letter homomorphisms just by applying the homomorphism directly to the lexicon to produce the new grammar.
Permutation closure In type-logical grammars, it has been known since the work of Emms (1993) that adding extraction to the Lambek calculus gives us a simple way to add permutation closure to the generated language. The MIX language, the language consisting of equal numbers of , and in any order, and its generalisations to symbols are the standard example of languages which can be generated under permutation closure. We have seen in Section 4.7 that can generate for all and this is one of the reasons I believe this class is a good fit for first-order linear logic and possibly for other type-logical grammars as well.
In formal language theory, only very powerful formalisms like RCGs have an easy way to generate permutation closures. We know that tree adjoining grammars cannot generate MIX (Kanazawa & Salvati 2012), although multiple context-free grammars can (Salvati 2015). However, it is unclear whether these results generalise to arbitrary permutation closures.
Semilinearity Semilinearity is one of the defining properties of mildly context-sensitive formalisms. Semilinearity means the languages generated by a formalism are permutation equivalent to a regular language. For example, the standard example of a mildly context-sensitive language which is not context-free is the language which is permutation equivalent to the regular language . By definition, semilinearity is invariant under permutation closure, so the MIX language and its generalisations are semilinear. MIX is permutation equivalent to the regular language just like .
Intersection It is well-known that adding intersection to context-free grammars allows us to generate languages which are not semilinear.
For Range Concatenation Grammars, Boullier (2000) makes the choice to give up homomorphisms (and therefore being an AFL) to ensure polynomial parsing, noting that formalisms which have both have an NP-complete fixed recognition problems.
NLIN has homomorphisms and intersection and therefore NP-complete fixed recognition. Given that type-logical grammars trivially have letter-to-letter homomorphisms, the only solution available to avoid NP-complete fixed recognition in these formalisms is not adding intersection. This has the additional advantage of making semilinearity attainable again.
5.2 Open questions
- Can we prove or ?
| semi | lang | fr | ur | ||||
|---|---|---|---|---|---|---|---|
| NLIN | ✓ | ✓ | ✓ | ✕ | spicy | NP-complete | NP-complete |
| MCFG | ✓ | ✕ | ? | ✓ | mild | P | NP-hard |
| RCG | ✕ | ✓ | ✓ | ✕ | medium | P-complete | NP-hard |
| L | ✓ | ✕ | ✕ | ✓ | context-free | P | NP-complete |
| MILL1 | ✓ | ✓ | ✓ | ✕ | spicy | NP-complete | NP-complete |
| TLG | ✓ | ? | ✓ | ✕ | spicy? | NP-complete | NP-hard |
Table 1: Formalisms discussed in this paper together with whether they are closed under homomorphisms , intersection , permutation , whether the formalism only generates semilinear languages (semi) and the complexity of fixed and universal recognition (fr, ur)
-
What is the precise relation between NLIN and other formalisms like LOGCFL and RCL, or even the context-sensitive languages? Are there any languages generated by one of these formalisms but not the others?
-
In formal language theory, can we separate permutation closure from other powerful operations such as copying and intersection? Since permutation closure does not contradict mild context-sensitivity, are there any mildly context-sensitive formalisms which are closed under permutation?
-
Can other type-logical grammars generate the quasi-linear languages? I think this might be possible for the Displacement calculus, using the separator symbols to mark the different stacks.
-
Are there interesting fragments of type-logical grammars with polynomial fixed recognition but which still allow the standard type-logical treatment of linguistic phenomena like extraction and quantification? I conjecture the answer to this question is no, mostly based on the fact that the known polynomial fragments are linguistically very restrictive.
-
Are there interesting restrictions on first-order linear logic formulas and variables such that the resulting fragment is not closed under intersection and maybe even has polynomial fixed recognition? Like with other typological grammars, I am skeptical about polynomial fixed recognition, but I would like to see a fragment which is semilinear (and therefore not closed under intersection). This would necessarily mean NLIN is outside of this fragment.
-
While letter-to-letter homomorphisms are trivial for type-logical grammars, do they actually form an AFL? I conjecture that they form a semi-AFL closed under concatenation but maybe not under Kleene plus as would be required for an AFL. Non-erasing homomorphisms are trivial. The Lambek calculus product makes inverse homomorphisms easy as well. Intersection with regular languages requires combining lexical entries with left-linear rules to .
Union and concatenation are simple as well using set union of the lexicon and disjoint sets of atomic formulas for the different grammars.
6 Conclusions
In this paper, we have shown that type-logical grammars with the standard rules for product, associativity, extraction and infixation have an NP-complete fixed recognition problem, adapting a construction for first-order linear logic from Pshenitsyn (2025).
While NP-complete fixed recognition gives us information about the complexity class, it is not very informative about the class of formal languages generated by grammars in a formalism. Pshenitsyn (2025) already shows that grammars in first-order linear logic are closed under intersection and therefore not semilinear and not mildly context-sensitive. We have strengthened the results of Pshenitsyn (2025) and shown that grammars in first-order linear logic can simulate the quasi-linear grammars of Book & Greibach (1970), the grammars recognised in non-deterministic linear time ( or ). I have argued that is an interesting class of formal languages as well, and a useful upper bound on the time complexity of formalisms used for natural language, just like LOGCFL is a useful upper bound on the space complexity.
Taken together this means that first-order linear logic can be seen as the logic of non-deterministic linear-time string languages, graph languages and automata.
References
Andreoli, J.-M. (2000), 'Focussing and proof construction', Annals of Pure and Applied Logic. to appear.
Barker, C. (2019), 'NL as the logic of scope and movement', Journal of Logic, Language and Information 28(2), 217–237.
Barker, C. & Shan, C. (2014), Continuations and Natural Language, Oxford Studies in Theoretical Linguistics, Oxford University Press.
Book, R. V. (1978), 'On the complexity of formal grammars', Acta Informatica 9(2), 171–181.
Book, R. V. & Greibach, S. A. (1970), 'Quasi-realtime languages', Mathematical systems theory 4(1), 97–111.
Boullier, P. (2000), 'A cubic time extension of context-free grammars', Grammars 3(2), 111–131.
Dahlhaus, E. & Warmuth, M. K. (1986), 'Membership for growing context-sensitive grammars is polynomial', Journal of Computer and System Sciences 33(3), 456–472.
Emms, M. (1993), Extraction covering extensions of the Lambek calculus are not context free, in P. Dekker & M. Stokhof, eds, 'Proceedings 9th Amsterdam Colloquium', pp. 268–286.
Guerrini, S. (1999), Correctness of multiplicative proof nets is linear, in 'Fourteenth Annual IEEE Symposium on Logic in Computer Science', IEEE Computer Science Society, pp. 454–263.
Kanazawa, M. & Salvati, S. (2012), MIX is not a tree-adjoining language, in 'Proceedings of the 50th Annual Meeting of the Association for Computational Linguistics'.
Kubota, Y. & Levine, R. (2012), Gapping as like-category coordination, in D. Béchet & A. Dikovsky, eds, 'Logical Aspects of Computational Linguistics', Vol. 7351 of Lecture Notes in Computer Science, Springer, Nantes, pp. 135–150.
Kubota, Y. & Levine, R. (2020), Type-Logical Syntax, MIT Press.
Kurtonina, N. & Moortgat, M. (1997), Structural control, in P. Blackburn & M. de Rijke, eds, 'Specifying Syntactic Structures', CSLI, Stanford, pp. 75–113.
Lambek, J. (1958), 'The mathematics of sentence structure', American Mathematical Monthly 65, 154–170.
Liu, L. Y. & Weiner, P. (1973), 'An infinite hierarchy of intersections of context-free languages', Mathematical systems theory 7(2), 185–192.
URL: https://doi.org/10.1007/BF01762237
Moortgat, M. (1988), Categorial Investigations: Logical and Linguistic Aspects of The Lambek Calculus, Foris, Dordrecht.
Moortgat, M. (1996), Generalized quantifiers and discontinuous type constructors, in H. Bunt & A. van Horck, eds, 'Discontinuous Constituency', Mouton de Gruyter, Berlin, pp. 181–207.
Moot, R. (2002), Proof Nets for Linguistic Analysis, PhD thesis, Utrecht Institute of Linguistics OTS, Utrecht University.
Morrill, G., Valentín, O. & Fadda, M. (2011), 'The Displacement calculus', Journal of Logic, Language and Information 20(1), 1–48.
Murawski, A. S. & Ong, C.-H. L. (2000), Dominator trees and fast verification of proof nets, in 'Logic in Computer Science', pp. 181–191.
Oehrle, R. T. (1994), 'Term-labeled categorial type systems', Linguistics & Philosophy 17(6), 633–678.
Pentus, M. (1995), Lambek grammars are context free, in 'Proceedings of the Eighth Annual IEEE Symposium on Logic in Computer Science', Montreal, Canada, pp. 429–433.
Pentus, M. (2010), 'A polynomial-time algorithm for Lambek grammars of bounded order', Linguistic Analysis 36(1–4), 441–471. Festschrift for Joachim Lambek, edited by Johan van Benthem and Michael Moortgat.
Pshenitsyn, T. (2025), First-order intuitionistic linear logic and hypergraph languages, in '52nd International Colloquium on Automata, Languages, and Programming (ICALP 2025)', Vol. 334, pp. 170–1.
Salvati, S. (2015), 'MIX is a 2-MCFL and the word problem in Z2 is captured by the IO and the OI hierarchies', Journal of Computer and System Sciences 81(7), 1252–1277.
Sudborough, I. H. (1978), 'On the tape complexity of deterministic context-free languages', Journal of the Association for Computing Machinery 25(3), 405–414.