Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 2 of 2

Prove a limit of a language-expression grammar

Use finite and cofinite length sets as a structural invariant of a small log-filter language, then distinguish expressibility from decidability.

Loading your saved responses…

Try the optional starting-point checks and targeted refreshers. You can continue directly into this lesson.

Try

A small synthetic log-filter language records only repeated occurrences of one marker, a. A run of length n is the word aⁿ; length zero is the empty word ε. A filter is a set of accepted words, called a language. Its universe U consists of every finite run, including ε.

The filter editor offers three constants: the empty language ∅, the singleton {ε}, and the singleton {a}. You may combine expressions by union, complement relative to U, and concatenation. Every expression must be a finite tree built with these operations. Repeating an operation an unspecified number of times is not an additional permitted constructor.

Can this editor accept exactly the runs whose lengths have remainder one on division by three? A scanning program could count modulo three. That observation does not yet produce an expression in this particular editor. Our goal is to prove a limitation of its expression vocabulary, rather than report that several attempted expressions failed.

Predict

Distinguish the object ε from the language {ε}. Concatenating a word with ε leaves it unchanged. Concatenating a language with {ε} therefore leaves that language unchanged; concatenating it with ∅ gives ∅ because no factor can be selected from the empty set.

A language is finite when it contains finitely many words. It is cofinite when its complement in U is finite. On this unary alphabet, cofinite means all sufficiently large lengths are accepted. It does not require every earlier length to be excluded. Predict whether union, complement and concatenation preserve the property “finite or cofinite.” Try especially the case in which a finite operand is empty: choosing one of its elements would be an invalid proof step.

Experiment

Build a worked filter A accepting lengths zero and three. Its expression is {ε} union three concatenated copies of {a}. Build B as the complement of the singleton length one. Before reading the table, determine which lengths AB accepts. Concatenation adds lengths, but one resulting word can have more than one factorization.

LengthABABRemainder-one target
0yesyesyesno
1nononoyes
2noyesyesno
3yesyesyesno
4noyesyesyes
5noyesyesno
6noyesyesno

In fact AB=B: the zero-length factor already produces all of B, while adding three to an accepted B length never produces the sole missing length one. Length three has two factorizations, 0+3 and 3+0. Counting factor pairs would count its single output word twice.

Change A to ∅, then to {ε}, without changing B. Explain both resulting languages from their definitions. Finally extend the table through length ten. A longer table remains finite evidence; the proof below covers arbitrary expression depth and every length.

Understand

Prove closure before invoking induction

Identify a unary language with its set of lengths in the nonnegative integers. Concatenation becomes the sumset A+B, consisting of all i+j with i in A and j in B. This identification uses the one-letter alphabet: there is exactly one word of each length.

Complement exchanges finite and cofinite sets. A union of two finite sets is finite. If either operand is cofinite, the complement of their union is a subset of a finite complement, so their union is cofinite. These arguments cover every Boolean-operation case.

For concatenation, first handle an empty operand: the result is empty. Two finite operands have only finitely many factor pairs, hence finitely many sums. Now suppose A is finite and nonempty, and B includes every length at least N. Choose any r in A. Every n≥r+N can be written r+(n−r), with n−r in B, so the sumset contains a complete tail. It is cofinite. If instead B is finite and nonempty while A contains all lengths at least N, choose s in B and use threshold N+s. This explicitly handles both operand orders.

Finally suppose A contains all lengths at least N and B all lengths at least M. Every n≥N+M is N+(n−N), with the first term in A and the second in B. Thus A+B is cofinite. These are sufficient thresholds, not necessarily minimal ones. The finitely many earlier lengths can include some accepted words; our conclusion does not assert that the result is exactly a tail with no exceptions.

Lift the invariant to every expression

The three constant expressions denote finite languages. Assume the property for the child expressions of a constructor. The preceding closure arguments prove it for their union, complement or concatenation. Structural induction on the finite syntax tree now establishes that every permitted expression denotes a finite or cofinite language. The induction concerns expressions, not a presumed list of all resulting languages; different expressions may denote the same language.

The target includes lengths 1,4,7,… and excludes lengths 0,3,6,…. Both collections are infinite. It is neither finite nor cofinite, so the invariant rules out every expression in the stated grammar. This conclusion does not rest on the failure of a search through small expressions.

An invariant normally supplies only a necessary condition. Here a converse can be proved separately: length n has a singleton expression made from n copies of {a}, with {ε} used for n=0. Finite unions describe every finite language, and ∅ supplies the empty case. Complementing an expression for a finite excluded set describes every cofinite language. Thus this particular grammar denotes exactly the finite and cofinite unary languages. The converse required a construction; it was not automatic from preservation.

Apply

Choose a testing cutoff M. List the target’s accepted lengths up to M and construct the finite union of their singleton expressions. This filter agrees with the target throughout the test range. Nevertheless, it rejects every word longer than M, while the target accepts infinitely many such words. Explain why passing every test in a finite prefix cannot establish global equivalence.

Now add a new grammar constructor, star. For a language L, L∗ permits concatenating any finite number of its words, including zero words. The zero-fold product contributes ε. Let C be the singleton length three. Then C∗ accepts lengths divisible by three, and {a}C∗ accepts exactly the target. This is a valid expression in the extended grammar, not a counterexample to the old theorem. The old invariant fails at the new constructor: finite C can have a star that is neither finite nor cofinite.

Check the boundary languages: ∅∗={ε}, because only the zero-fold product contributes a word; {ε}∗={ε}, because every concatenation remains empty. Do not confuse either result with ∅.

For a separate computational solution, scan the input word while maintaining a remainder in three states. Start at zero, advance the remainder once per marker, and accept state one at the end. Every finite input terminates. This proves decidable membership without claiming an expression in the original grammar or that the star extension can express every possible language.

Continue

Return to generated sets and unique parsing for structural induction over constructions, or sets and double inclusion for membership-based equality arguments. Keep the alphabet, complement universe and permitted constructors explicit when transferring this proof. With more than one letter, many words share a length, so the sumset argument alone no longer identifies an entire language.

Apply · explain · revise

Practice and reasoning

Drafts save locally as you type. Reveal worked solutions when useful; the site remembers that exposure. Automatic matches check the requested answer, while written arguments require review against the rubric.

Let A={ε,a²} and B=U\{ε,a}. Show that A and B can be expressed using the permitted grammar. Determine AB and the complement of A∪B. Distinguish ε, {ε} and ∅, and explain why counting pairs of factors can overcount output words.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Prove that the union and complement of finite/cofinite subsets of U are finite or cofinite. Give an explicit tail threshold for a union when at least one operand contains every length at least its threshold. Explain why a threshold does not determine the earlier membership values.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Identify unary languages with their length sets A,B⊆N₀. Prove A+B={i+j:i∈A,j∈B} is finite or cofinite whenever both operands are finite or cofinite. Treat an empty operand, finite/finite, finite nonempty/cofinite in both orders, and cofinite/cofinite. Supply explicit sufficient tail thresholds.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Prove by structural induction that every expression in the specified grammar denotes a finite or cofinite language. Deduce that the log filter accepting exactly lengths congruent to one modulo three has no expression. Explain why a terminating membership algorithm for that filter does not contradict the conclusion.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Prove separately that every finite or cofinite unary language is expressible in this grammar. Include the singleton ε and empty language. Then, for arbitrary M≥0, construct an expressible language agreeing with the nondefinable residue-one filter on every length from zero to M. What can and cannot be inferred from such finite agreement?

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Extend the grammar by a Kleene-star constructor L*=∪ₖ≥₀Lᵏ, with L⁰={ε}. Use it to express the residue-one filter and determine ∅* and {ε}*. Explain exactly where the previous structural-induction proof fails, and whether every language is now known to be expressible.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Reflect and continue

Before marking this lesson complete, explain one key idea without the worked solution and identify a condition that matters. Marking complete records participation, not independent mastery.