You are on page 1of 21

LANGUAGES

And
GRAMMARS

What is Language?
Language
The method of human communication, either
spoken or written, consisting of the use of wor
ds in a structured and conventional way.
The system of communication used by partic
ular community or country.

What is Grammar?
Grammar
The whole system and structure of a languag
e, usually taken as consisting of syntax and m
orphology and sometimes also phonology and
semantics

Introduction
Words in the English language can be combined in various ways.
Grammar of English tells us whether a combination of words is a valid sentence.

Introduction
Words in the English language can be combined in various ways.
Grammar of English tells us whether a combination of words is a valid sentence.

the frog writes neatly


the - an article
frog - noun
writes - verb
neatly - adverb

Mathematics swims quickly

Natural versus Formal Language


Natural languages
are the languages that people speak, such
as English, Spanish, and French. They were
not designed by people they evolved
naturally.

Natural versus Formal Language


Formal languages
are languages that are designed by people
for specific applications.

Two Classes of Problem


How can we determine whether a combination of words is a valid sentence in a formal
language?
How can we generate the valid sentences of
a formal language?

1. a sentence is made up of a noun phrase


followed by a verb phrase;
2. a noun phrase is made up of an article
followed by an adjective followed by a noun,
or
3. noun phrase is made up of an article followed
by a noun;
4. a verb phrase is made up of a verb followed
by an adverb, or
5. a verb phrase is made up of a verb;

6. an article is a, or
7. an article is the;
8. an adjective is large, or
9. an adjective is hungry;
10. a noun is rabbit, or
11. a noun is mathematician;
12. a verb is eats, or
13. a verb is hops;
14. an adverb is quickly, or
15. an adverb is wildly.

sentence
noun phrase verb phrase
article adjective noun verb phrase
article adjective noun verb adverb
the adjective noun verb adverb
the large noun verb adverb
the large rabbit verb adverb
the large rabbit hops adverb
the large rabbit hops quickly

VOCABULARY
(alphabet) V
is a finite, nonempty set of elements called
symbols.
Word (or sentence ) over V is a string of finite
length of elements of V . The empty string
or null string, denoted by , is the string contai
ning no symbols. The set of all words over V is
denoted by V. A language over V is a subset o
f V.

PHRASE-STRUCTURE GRAMMAR

G = (V, T, S, P)
The set V T is denoted by N. Elements of N
are called nonterminal symbols.
Every production in P must contain at least on
e nonterminal on its left side.

Example:
Let G = (V, T, S, P),
where
V = { a, b, A, B, S }
T = { a, b },
S is the start symbol
P = { ?????}
G is an example of a phrase-structure
grammar.

Let G = (V, T, S, P) be a phrase-structure gramma


r. Let w0 = lz0r and w1 = lz1r be strings over V.
If z0 z1 is a production of G, we say that w1 is
directly derivable from w0 and we write w0 w
1. If w0,w1, . . . ,wn are strings over V such that
w0 w1,w1 w2, . . . ,wn1 wn, then we say
that wn is derivable from w0, and we write

w0 wn. The sequence of steps used to obtain


wn from w0 is called a

derivation.

Example:
The string Aaba is directly derivable from ABa in
the grammar because
B ab is a production in the grammar.
The string abababa is derivable from ABa because
ABa Aaba BBaba Bababa abababa,
using the productions B ab,A BB,
B ab, and B ab in succession.

Let G = (V, T, S, P)
be a phrase-structure grammar.
The language generated by G (or the language of
G),
denoted by L(G), is the set of all strings of
terminals that are derivable from the starting stat
e S.
In other words,

| S w}.

L(G) = {w T

THANK
YOU!
I am SURGEON

You might also like