Every generated word satisfies
where count occurrences of the indicated terminal symbols. To see this, follow the unique chain of occurrences in a parse tree. Each use of introduces one from , at least one from its rightmost , and possibly one further from . Each use of adds one and no . The terminating contributes neither. Hence no generated word has more symbols than symbols.
Also, for every , the word is generated: apply exactly times, choose each time, then use and all remaining .
Suppose were a regular language, and let be a pumping length from the pumping lemma for regular languages. Apply it to . Every allowed decomposition with and has for some . Pumping twice gives
which violates the proved counting inequality and hence is not generated. This contradicts the pumping lemma for regular languages. Therefore is not a regular language. Ambiguity was not used: the obstruction is the unbounded constraint on symbol counts.
Use the standard conversion of a context-free grammar to a pushdown automaton, implementing a leftmost derivation on a stack. Take control states , input alphabet , stack alphabet , initial control state , initial stack symbol , and sole final control state . The symbol is a fresh stack bottom marker. As in part (a), the top of the stack is written on the left.
Initialize with
In control state , replace a top nonterminal symbol by one of its production rule right-hand sides:
The replacements are written in the order in which they are to be processed. For example, replacing by leaves on top; an implementation using individual push operations pushes , then , then .
Match and pop top terminal symbols by
Finally include
All unlisted transitions have no choices; has no outgoing transitions. This is acceptance by final state, leaving the bottom marker on the stack. Taking the last transition too early cannot cause false acceptance, because an unread input suffix remains and cannot consume it.
For correctness, after initialization the stack contains the unprocessed part of a sentential form. Expanding a top nonterminal symbol simulates one step of a leftmost derivation, and popping a matching terminal symbol transfers it to the already-read input prefix. Thus if the input prefix consumed so far is and the stack above is , then . Acceptance gives for the entire input .
Conversely, any leftmost derivation of specifies choices of these transitions: expand the next nonterminal symbol, and read each resulting leading terminal symbol when it reaches the top. After all symbols of are consumed, only remains, enabling the move to . The nondeterministic pushdown automaton therefore recognizes exactly . The empty word is accepted by choosing after initialization.
The word has these two leftmost derivations:
In the first grammar derivation, supplies an extra ; the remaining goes directly to the empty word. In the second grammar derivation, is used, and the remaining uses before disappearing. Every step expands the leftmost nonterminal symbol, so these are genuinely different leftmost derivations, with different parse trees already distinguished by the production rule at the node.
Therefore is an ambiguous grammar, witnessed by .
A context-free grammar is an ambiguous grammar if some word in its generated formal language has two distinct parse trees. Equivalently, that word has two distinct leftmost derivations from the start nonterminal symbol. A leftmost derivation always expands the leftmost remaining nonterminal symbol.
Two arbitrary grammar derivations of the same word do not by themselves prove ambiguity: expanding independent nonterminal symbols in a different order can describe the same parse tree. Requiring distinct parse trees, or distinct leftmost derivations, avoids that issue.
Use state elimination for finite automata, with regular expression labels on a generalized finite automaton. Add a fresh initial automaton state with , and a fresh final automaton state with . Only is now accepting. Missing labels represent the empty language, and parallel alternatives are combined by union.
When eliminating an internal automaton state , update every surviving label by
The added regular expression describes entering , traversing its loop zero or more times by Kleene star, and leaving it. This accounts for exactly the graph paths newly bypassing .
First eliminate . Its only incoming and outgoing labels are both , and it has no loop. The graph path through it contributes , so the label from to becomes
The other relevant labels are still , , and .
Next eliminate . It has no loop, so the new loop at and the new label to are
Finally eliminate . The label from to is
Thus an equivalent regular expression is
For an independent interpretation, every completed return to consumes either or : the latter traverses before returning. The last visit to consumes either nothing or . Consequently every run of ones has length exactly two, and successive such runs require at least one zero between them. In particular, consecutive copies of without a separating zero are not accepted.
For , there is an accepting graph path
Its nonempty labels spell , and its last automaton state is accepting. Therefore is accepted. The last epsilon transition matters: finishing the consumed input at does not prevent a subsequent move to .
For , track all possible automaton states, including their epsilon closure, after each input prefix:
Input prefixPossible automaton states after epsilon closure
The final set contains no accepting automaton state, and has no outgoing epsilon transition. Therefore is rejected.
Lucy's happiness is a single antecedent, while the conclusion applies to everyone:
Since does not occur in the antecedent, this is equivalent to . The universal quantifier does not assert that everyone is happy; it is the merriness conclusion that is universal.
The same person must both love and be loved by :
Equivalently, use . There is no restriction that and be distinct; this matters when the later ground resolution proof considers Lucy loving herself.
The property of loving at least one person is the antecedent:
An equivalent first-order sentence, useful for Skolemization, is . The person loved in the antecedent need not be Lucy; the conclusion concerns Lucy specifically.
The existential quantifier supplies the person loved, with a choice that may depend on :
The outer universal quantifier ranges over everyone. The logical disjunction is inclusive; it permits a person both to be happy and to love somebody.
The halting problem is an unconditional example:
Reduce SAT to it as follows. Given a Boolean formula , construct a Turing machine that ignores its input, enumerates all Boolean valuations of , and halts if it finds a satisfying one. If none satisfies , it enters an infinite loop after the enumeration. Then
The construction of the machine description takes polynomial time; the potentially exponential running time of the constructed machine is irrelevant to the time needed to compute the polynomial-time reduction. Since SAT is NP-complete, this proves NP-hardness of the halting problem.
Every problem in NP is decidable, by enumerating the finitely many polynomial-length certificates and running the verifier. The halting problem is undecidable, so it is outside NP and therefore cannot be NP-complete.
For polynomial-time many-one reductions, an unconditional example is the empty language:
A procedure that rejects every input decides it in constant time, so it belongs to P and hence NP. It is not NP-hard: the nonempty formal language belongs to NP, but no many-one reduction can satisfy
The right-hand side is always false. Thus the hardness condition fails without assuming . Giving an ordinary nontrivial problem in P would not establish the requested separation unconditionally, because that would require excluding the possibility .
Add the ground atom
Together with the three rules above, this is the Datalog with negation knowledge base . There are no supplied divisibility facts and no other year facts. In particular, nothing in this knowledge base asserts or .
The remaining classification rule is
The positive premise restricts the rule to years. Its negation as failure premise is evaluated by stable model semantics; it does not assert a separately stored negative fact. This gives a stratified Datalog program: divisibility and year facts are inputs, leap status is computed next, and common status last.
Use not for negation as failure, rather than classical logical negation. The disjunctive condition is expressed by two separate Datalog with negation rules:
The positive premise restricts the rule to years and makes the variable explicitly safe. The divisibility relation is input data; the integer-looking constants do not make arbitrary arithmetic facts true automatically.
Absorb (4) using the equivalence
Thus we can take
Here is a primitive inclusion, handled by adding whenever labels a node. For literal substitution-based TBox unfolding, introduce a fresh description logic concept and replace the primitive inclusion by
This preserves the original models after forgetting : any model of the primitive inclusion extends by taking , and any model of the new definition satisfies the primitive inclusion. The fresh name is important. Replacing by alone would incorrectly assert that every non- element is an element.
An initial split into an acyclic definition and the remaining general concept inclusions is
The definition of is suitable for TBox unfolding: its right-hand side does not depend on , and has only this defining left-hand side. The other displayed general concept inclusions do not initially have an atomic defined left-hand side. In particular, can be rewritten for TBox absorption, but is not already an atomic definition.
An exponential increase is unavoidable for an equivalent conjunctive normal form over the original variables. Consider the linear-size Boolean formula
Distributing gives the Boolean clauses
To prove that the growth is necessary, fix one choice . Let make every false and its partner true. Each pair then contains a false variable, so is false. Any equivalent conjunctive normal form must contain a Boolean clause falsified by and entailed by .
Every individual term entails , because that term implies . After tautological Boolean clauses are discarded, this forces to contain a positive or positive for every : otherwise set both variables in that pair true and independently falsify all Boolean literals of , contradicting the entailment. Since is false at , it must contain the false member , never its true partner. Consequently the same cannot be false at any different . The different assignments therefore require at least different Boolean clauses.
Writing the answer already takes . This obstruction applies to first-order logic as well, since the example can be expressed using ground unary atomic formulas. It concerns exact equivalence without auxiliary symbols. A Tseytin transformation can produce a polynomial-size equisatisfiable conjunctive normal form with auxiliary variables, so the statement must not be extended to that different task.
The usual transformation to clausal normal form preserves . Removing implications and distributing logical conjunction and logical disjunction preserve logical equivalence. Skolemization introduces new symbols and chooses witnesses as functions of preceding universally quantified variables.
For example,
On the domain , let be equality. Then is true. Expand this same first-order structure by interpreting as the constant function with value . The resulting first-order structure falsifies at . Interpreting as the identity instead satisfies .
Thus every model of has a reduct satisfying , and a model of can be expanded with suitable witnesses to satisfy . That model-expansion property gives equisatisfiability, not logical equivalence for every interpretation of the added function. If “CNF” means a conjunctive matrix with existential quantifiers retained, Skolemization has not yet happened and an equivalent form is possible; this is why the convention must be specified.
For resolution, a first-order sentence is in clausal normal form when it is a universally quantified logical conjunction of first-order clauses:
where every is a first-order literal, meaning an atomic formula or the logical negation of an atomic formula. The quantifiers are often left implicit and the first-order clauses treated as a set. The empty first-order clause represents falsity; an empty set of first-order clauses represents truth.
A convention that allows an arbitrary quantifier prefix followed by a conjunctive matrix is weaker: that is a prenex normal form with a conjunctive matrix. The elimination of existential quantifiers by Skolemization is the extra step relevant to resolution and to part (ii).

There are unlisted articles, also show them or only show them.