ArticleslgStudy

science

Terminal and nonterminal symbols

Terminal and nonterminal symbols is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Terminal and nonterminal symbols rather than just read about it. In short: In formal languages, terminal and nonterminal symbols are parts of the vocabulary under a formal grammar. Vocabulary is a finite, nonempty set of symbols.

Terminal and nonterminal symbols — main illustration
Terminal and nonterminal symbols — illustration

Key takeaways

  • Terminal and nonterminal symbols belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Terminal and nonterminal symbols to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Terminal and nonterminal symbols from memory before moving on to harder problems.

Reference excerpt

In formal languages, terminal and nonterminal symbols are parts of the vocabulary under a formal grammar. Vocabulary is a finite, nonempty set of symbols. Terminal symbols are symbols that cannot be replaced by other symbols of the vocabulary. Nonterminal symbols are symbols that can be replaced by other symbols of the vocabulary by the production rules under the same formal grammar. A formal grammar defines a formal language over the vocabulary of the grammar. In the context of formal language, the term vocabulary is more commonly known as alphabet. Nonterminal symbols are also called syntactic variables.

Terminal symbols Terminal symbols are those symbols that can appear in the formal language defined by a formal grammar. The process of applying the production rules successively to a start symbol might not terminate, but if it terminates when there is no more production rule can be applied, the output string will consist only of terminal symbols. For example, consider a grammar defined by two rules. In this grammar, the symbol Б is a terminal symbol and Ψ is both a nonterminal symbol and the start symbol. The production rules for creating strings are as follows:

The symbol Ψ can become БΨ The symbol Ψ can become Б Here Б is a terminal symbol because no rule exists to replace it with other symbols. On the other hand, Ψ has two rules that can change it, thus it is nonterminal. The rules define a formal language that contains countably infinite many finite-length words by the fact that we can apply the first rule any countable times as we wish. Diagram 1 illustrates a string that can be produced with this grammar.

Nonterminal symbols Nonterminal symbols are those symbols that cannot appear in the formal language defined by a formal grammar. A formal grammar includes a start symbol, which is a designated member of the set of nonterminal symbols. We can derive a set of strings of only terminal symbols by successively applying the production rules. The generated set is a formal language over the set of terminal symbols. Context-free grammars are those grammars in which the left-hand side of each production rule consists of only a single nonterminal symbol. This restriction is non-trivial; not all languages can be generated by context-free grammars. Those that can are called context-free languages. These are exactly the languages that can be recognized by a non-deterministic push down automaton. Context-free languages are the theoretical basis for the syntax of most programming languages.

Production rules A grammar is defined by production rules (or just 'productions') that specify which symbols can replace which other symbols; these rules can be used to generate strings, or to parse them. Each such rule has a head, or left-hand side, which consists of the string that can be replaced, and a body, or right-hand side, which consists of a string that can replace it. Rules are often written in the form head → body; e.g., the rule a → b specifies that a can be replaced by b. In the classic formalization of generative grammars first proposed by Noam Chomsky in the 1950s, a grammar G consists of the following components:

A finite set N of nonterminal symbols. A finite set Σ of terminal symbols that is disjoint from N. A finite set P of production rules, each rule of the form

V ∗ N V ∗ → V ∗ {\displaystyle V^{*}NV^{*}\rightarrow V^{*}}

where V ∗ {\displaystyle V^{*}} denotes the set of all possible finite-length strings over the vocabulary V = Σ ∪ N {\displaystyle V=\Sigma \cup N} using Kleene star. That is, each production rule replaces one string of symbols that contains at least one nonterminal symbol with another. In the case that the body consists solely of the empty string, it can be denoted with a special notation (often Λ, e or ε) to avoid confusion. A distinguished symbol S ∈ N {\displaystyle S\in N} that is the start symbol. A grammar is formally defined as the ordered quadruple ⟨ N , Σ , P , S ⟩ {\displaystyle \langle N,\Sigma ,P,S\rangle } . Such a formal grammar is often called a rewriting system or a phrase structure grammar in the literature.

Example Backus–Naur form is a notation for expressing certain grammars. For instance, the following production rules in Backus-Naur form are used to represent an integer (which can be signed):

In this example, terminal symbols are { − , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } {\displaystyle \{-,0,1,2,3,4,5,6,7,8,9\}} , and nonterminal symbols are { {\displaystyle \{} <digit>, <integer> } {\displaystyle \}} .

Another example is:

S ⟶ cAd {\displaystyle {\ce {S -> cAd}}}

A ⟶ a | ab {\displaystyle {\ce {A -> a | ab}}}

In this example, terminal symbols are { a , b , c , d } {\displaystyle \{\mathrm {a,b,c,d} \}} , and nonterminal symbols are { S , A } {\displaystyle \{\mathrm {S,A} \}} .

See also Alphabet (formal languages) Chomsky Hierarchy Recursive grammar

Notes

References

Illustrations

Terminal and nonterminal symbols: The string "the dog ate the bone" was created using production rules that replaced nonterminal with terminal symbols.[1]
The string "the dog ate the bone" was created using production rules that replaced nonterminal with terminal symbols.[1]
Terminal and nonterminal symbols: Diagram 1. The string Б Б Б Б was formed by the grammar defined by the given production rules. This grammar can create strings with any number of the symbol Б
Diagram 1. The string Б Б Б Б was formed by the grammar defined by the given production rules. This grammar can create strings with any number of the symbol Б

Worked examples

Example 1 — a first encounter with Terminal and nonterminal symbols

Start with the simplest possible case. Write down what Terminal and nonterminal symbols claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Terminal and nonterminal symbols before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Terminal and nonterminal symbols ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Terminal and nonterminal symbols

In research
Terminal and nonterminal symbols appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Terminal and nonterminal symbols in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Terminal and nonterminal symbols is common in secondary-school and first-year university syllabi. It links to neighbouring topics Formal languages, Pattern matching, so understanding it makes those chapters shorter.
In everyday life
Look for Terminal and nonterminal symbols outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Terminal and nonterminal symbols” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Terminal and nonterminal symbols in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Terminal and nonterminal symbols means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Terminal and nonterminal symbols out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Terminal and nonterminal symbols in simple terms?

In formal languages, terminal and nonterminal symbols are parts of the vocabulary under a formal grammar. Vocabulary is a finite, nonempty set of symbols.

Why does Terminal and nonterminal symbols matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Terminal and nonterminal symbols?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Terminal and nonterminal symbols.

Tags

  • Formal languages
  • Pattern matching

Keep exploring