Prezentacja programu PowerPoint



Download 66 Kb.
bet1/2
Sana04.06.2022
Hajmi66 Kb.
#636216
  1   2

Formal grammars

  • A formal grammar is a system for defining the syntax of a language by specifying sequences of symbols or sentences that are considered grammatical.
  • Grammatical sentences of a language may be very large or infinite, therefore they are usually derived by a recursive definition.

Definition of the formal grammar G

  • G = < V, Σ, P, σ >
  • V – set of terminal symbols
  • Σ – set of nonterminal symbols with the restriction
  • that V and Σ are disjoint
  • σ – start symbol
  • P – set of production rules in a form:
    • A –> B
  • where:
    • A – is a sequence of symbols having at least one
    • nonterminal,
    • B – is the result of replacing some nonterminal symbol
    • A with a sequence of symbols (possibly empty)
    • from V and Σ

Small subset of English grammar

  • V = {“the”, ”a”, ”cat”, ”dog”, ”saw”, “chased“}
  •  = {S, NP, VP, D, N, V}
  • S – sentence D – determiner
  • NP – noun phrase N – noun
  • VP – verb phrase V – verb
  •  = S
  • P = {
  • S –> NP VP,
  • NP –> D N,
  • VP –> V NP,
  • D –> ”the”, D –> “a”,
  • N –> ”cat”, N –> ”dog”,
  • V –> “saw”, V –> “chased”
  • }

Derivation

  • Example of a leftmost derivation:
  • S –> NP VP
  • –> D N VP
  • –> “the” N VP
  • –> “the” “cat” VP
  • –> “the” “cat” V NP
  • –> “the” “cat” “chased” NP
  • –> “the” “cat” “chased” D N
  • –> “the” “cat” “chased” “a” N
  • –> “the” “cat” “chased” “a” “dog”

Parse trees

  • S
  • NP
  • D
  • V
  • NP
  • “the”
  • N
  • “cat”
  • VP
  • “chased”
  • D
  • “a”
  • N
  • “dog”

Backus notation for production rules

  • ::= – is defined as
  • | – separates alternatives
  • <> – denotes nonterminal symbols
  • Production rules for the small subset of English grammar
  • P = {
  • ::= ,
  • ::= ,
  • ::= ,
  • ::= ”the” | “a”,
  • ::= ”cat” | ”dog”,
  • ::= “saw” | “chased”
  • }

Classification of formal grammars

  • Type
  • Name
  • Production rules
  • Recognizing automaton /
  • Storage required /
  • Parsing complexity
  • 3
  • Regular grammars,
  • Finite state grammars
  • A –> xB
  • C –> y
  • A, B, C – non-terminal symbols
  • x, y – terminal symbols
  • Finite state automaton /
  • Finite storage /
  • O (n)
  • 2
  • Context free grammars
  • A –> BC…D
  • A – non-terminal symbols
  • BC…D – any sequence of terminal or non-terminal symbols
  • Pushdown automaton /
  • Pushdown stack /
  • O (n3)
  • 1
  • Context sensitive grammars
  • aAz –> aBC…Dz
  • A – non-terminal symbols
  • a, z – sequences of zero or more terminal or non-terminal symbols
  • BC…D – any sequence of terminal or non-terminal symbols
  • Linear bounded automaton
  • (non-deterministic Turing machine) /
  • Tape being a linear multiple of input length /
  • NP Complete
  • 0
  • Unrestricted grammars,
  • General rewrite grammars
  • Allows the production rules to transform any sequence of symbols into any other sequence of symbols.
  • To convert context-sensitive grammar into unrestricted grammar, replacement of any non-terminal symbol A with an empty sequence needs to be allowed.
  • Turing machine /
  • Infinite tape /
  • Undecidable

Download 66 Kb.

Do'stlaringiz bilan baham:
  1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish