0% found this document useful (0 votes)
18 views

Lecture01 Intro

This document provides an overview of a course on formal languages and automata. The course covers fundamental concepts like formal languages, grammars, regular expressions, types of automata (regular, context-free, Turing machines), and properties of languages. It discusses natural versus formal languages and why we study automata. Examples are provided to illustrate language definitions and grammars. The mathematical foundations and basic concepts around languages, grammars, alphabets, derivation, and language recognition are also explained.

Uploaded by

ana42145577
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lecture01 Intro

This document provides an overview of a course on formal languages and automata. The course covers fundamental concepts like formal languages, grammars, regular expressions, types of automata (regular, context-free, Turing machines), and properties of languages. It discusses natural versus formal languages and why we study automata. Examples are provided to illustrate language definitions and grammars. The mathematical foundations and basic concepts around languages, grammars, alphabets, derivation, and language recognition are also explained.

Uploaded by

ana42145577
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Formal Languages and Automata

Text Book:
“Theory of Computation an Introduction" by James L. Hein, Jones & Bartlett
Publishers 1996; ISBN: 0-86720-497-4.

1
Course details

2
The course content

◼ What is formal language and automata?

◼ Grammar and meaning of ambiguity.


◼ Regular languages and types of automata.
◼ Regular expressions.
◼ Pumping lemma for non- regular expression
◼ Context free language and CFG.
◼ Push down automata.
◼ Turing machines.
3
Formal Languages and Automata

◼ What is natural language?


A natural language is a set of finite alphabet and a grammar. With the set
of the alphabet we can get an infinite set of words after then with the
associated grammar we can get an infinite set of sentences. The natural
language charactarized by: High expressiveness, No extra learning,
Ambiguity, Vagueness, Longish style, Consistency hard to check.

4
Formal Languages and Automata
What and why?
◼ What is formal language?
A formal language is a set of words, i.e. finite strings of letters, symbols,
or tokens. The set from which these letters are taken is called the
alphabet over which the language is defined. A formal language is often
defined by means of a formal grammar (also called its formation rules);
accordingly, words that belong to a formal language are sometimes
called well-formed words (or well-formed formulas).

formal languages are characterized by:


- Well-defined syntax - Unambiguous semantics
- Can be processed by a computer - Large problems can be solved
- Learning effort high - Limited expressiveness
- Low acceptance

5
Formal Languages and Automata
What and why?
◼ What is Automata?
• Automata : the plural of automaton: self operating machine.
the automata can be used to test whether a particular expression is in fact
part of the language.
• Languages in turn, can be described by regular expressions and
grammars. Regular expressions denote the structure of data, especially text
strings. For example, as part of a calculator, you might want to have a rule
like S → S | S + S, which states that an expression can be formed by taking
any two expressions and connecting them by a plus sign.

◼ Why we study Automata?


The theory provides principles and concepts of the compiler &
programming languages and digital design.

6
Mathematical background

7
Basic Concepts (language, grammar, automata)
◼ Language: is a set of strings.
- If A is an alphabet, then a language over A is a collection of all
strings over A.

- A* is the biggest possible language over A, and every other


language over A is a subset of A*.

◼ Example
If A={a} then the following are simple examples of languages
over an alphabet A:
{Ф}, {}, {a}, and A* ={, a, aa, aaa, ………}.

8
Example
Let the alphabet be  = {a, b } then,
- * = {, a, b, aa, ab, ba, bb, aaa, bbb, …} - + = * - {}
- L1 = { a, aa, bbb} finite
- L2 = {anbn : n>= 0} infinite
- L1 = *- L1
- LR = {wR: w  L}
- L0={}
- L1 L2 = {xy: x  L1, y  L2}

if L = {anbn : n>= 0}
L2 = {anbnambm : n>= 0, m>= 0} → (L.L)
LR = {bnan : n>= 0}
L* = Lo  L1  L2 …
L+ = L1  L2  L3 …

9
Basic Concepts
◼ Grammar: is a set of production rules used to define the structure of the
strings in a language.
◼ If L is a language over the alphabet A, then a grammar for L consists of a
set of grammar rules of the form:
∝→ß,
Where ∝ and ß denotes strings of symbols taken from A and from a set of
grammar symbols denoted as the non-terminals set N.
◼ Every grammar has a special grammar symbol called a start symbol S, and
at least one production with the left side consisting of only the start symbol.
◼ For example if the start symbol is S, then the production rule will be:
S→ß,

10
Basic Concepts
◼ Example
Let A={a,b,c}, then the grammar for the A* language can be described by
the following production rules:
S→ 
S→aS
S→bS
S→cS.
◼ How do we know that this grammar describes the
language A*?
We must be able to describe each string of the language in terms of the
grammar rules.
◼ Prove that the string aacb is in A*???

11
Basic Concepts
The grammar consists of the following four parts:
◼ An alphabet N of grammar symbols called nonterminals.

◼ An alphabet T of symbols called terminals, which must be


distincit from nonterminals.
◼ A specific nonterminal symbol called the start state.

◼ A finite set of production rules of the form ∝→ß , where


∝, ß are strings over the alphabet N∪T and ∝ is not the
empty string 
◼ we can define the language L over the grammar G as:

L(G)={w| w ∊ T* and S ⇒+ w }..

12
Basic Concepts
◼ Example
If A={a,b,c}, and the production rules is the set P the
grammar G=<N,T,S,P> ≡ <{S,A,B}, {a,b,c}, S, P>,
where P ≡ S→AB A→  |aA B→  |bB.
◼ Let us derive the string aab:

S⇒AB⇒aAB⇒aaAB⇒aaB⇒aabB⇒aab.

◼ Note: that the language can have more than one grammar.
So we should not be surprised when two people come up
with two different grammars for the same language.

13
Basic Concepts

What is the grammar of the following languages?


◼ {a,ab,abb,abbb} …?

◼ {,a,aa,…,an,…} …?

◼ {b, bbb, …, b2n+1,…}…?

◼ {b,abc,aabcc,….,anbcn,…}…?

◼ {ac,abc,abbc,…,abnc,….}…?

14
Combining grammars
Suppose M and N are languages whose grammars have disjoint sets of
non-terminals. Suppose also that the start symbols for the grammars M
and N are A and B respectively. We can obtain the following new
languages and grammars:

Union Rule: the language M ∪ N starts with the production rule


S→A|B.

Product Rule: the language M ∙ N starts with the production


S → A B.

Closure Rule: the language M* starts with the production


S →AS | .

15
Combining grammars

Examples
Describe the combined grammars in each L of the following
1- If L = {,a,b,aa,bb,……, an,bn,……}????
2- If L = {ambn | m,n ∊ ℕ}????
3- If L={aa,bb}*, write the grammar for L?????

16
Thank You!

17

You might also like