Aturan Produksi dan Grammar

Dewi Soyusiawaty
1 Jan 202212:34

Summary

TLDRThis video discusses the rules of production and grammar, focusing on terminal and non-terminal symbols, production rules, and the different types of grammars according to the Chomsky hierarchy. Terminal symbols are those that cannot be broken down further, while non-terminal symbols can still be expanded. The video outlines four grammar types: unrestricted, context-sensitive, context-free, and regular grammars. Each type defines specific rules and structures, with examples provided for each. The video explains how these grammar types are recognized by automata, including Turing machines and pushdown automata.

Takeaways

  • 📚 Terminal symbols are symbols that cannot be further derived, such as lowercase alphabet letters and operators like + and -.
  • 🔤 Non-terminal symbols are symbols that can be derived into either terminal or other non-terminal symbols, typically represented by uppercase letters or specific strings.
  • ➡️ Production rules are written as 'Alpha produces Beta', where Alpha is on the left-hand side and Beta is on the right-hand side, consisting of terminal or non-terminal symbols.
  • 🔄 Applying production rules allows a grammar to generate strings within a language, which collectively form the language defined by that grammar.
  • 🧠 Chomsky's hierarchy of grammars includes four types: Type 0 (Unrestricted Grammar), Type 1 (Context-Sensitive Grammar), Type 2 (Context-Free Grammar), and Type 3 (Regular Grammar).
  • ⚙️ Type 0 (Unrestricted Grammar) has no restrictions on production rules and can generate languages recognized by Turing machines.
  • 📏 Type 1 (Context-Sensitive Grammar) imposes a restriction where the left-hand side (Alpha) must have fewer or equal symbols compared to the right-hand side (Beta).
  • 📜 Type 2 (Context-Free Grammar) allows only one non-terminal symbol on the left-hand side, and is recognized by nondeterministic pushdown automata.
  • ✅ Type 3 (Regular Grammar) requires the left-hand side to have one non-terminal symbol, and if a non-terminal appears in Beta, it must be at the rightmost position, recognized by finite state automata.
  • 🧩 Grammar defines a formal structure for generating valid strings or sentences in a language, based on terminal and non-terminal symbols and production rules.

Q & A

  • What is a terminal symbol in the context of production rules?

    -A terminal symbol is a symbol that cannot be further broken down or derived. Examples include lowercase alphabet letters such as 'a', 'b', 'c', operators like '+', '-', and punctuation marks.

  • What is a non-terminal symbol?

    -A non-terminal symbol can be derived into terminal symbols or other non-terminal symbols. Examples include uppercase alphabet letters like 'A', 'B', 'C', and symbols such as 'S' for the start symbol.

  • What is a production rule?

    -A production rule specifies how symbols in a formal grammar can be replaced with other symbols. It is typically written in the form 'Alpha produces Beta,' where Alpha is on the left-hand side and Beta on the right.

  • How does a production rule help in defining a grammar?

    -A production rule helps in defining how to generate valid strings within a language by specifying how non-terminal symbols can be replaced by other symbols, ultimately leading to terminal symbols that form strings.

  • What is the hierarchy of grammar types according to Chomsky?

    -Chomsky’s hierarchy classifies grammars into four types: Type 0 (unrestricted grammar), Type 1 (context-sensitive grammar), Type 2 (context-free grammar), and Type 3 (regular grammar).

  • What defines a Type 0 (unrestricted) grammar?

    -Type 0 grammars have no restrictions on the production rules. The left-hand side of the production rule can consist of terminal or non-terminal symbols, and it must contain at least one non-terminal symbol.

  • What is a key characteristic of Type 1 (context-sensitive) grammar?

    -In Type 1 grammars, the length of the string on the left-hand side of a production rule must be less than or equal to the length of the string on the right-hand side, ensuring that the number of symbols does not decrease.

  • What is a context-free grammar (Type 2)?

    -A context-free grammar allows production rules where the left-hand side consists of a single non-terminal symbol. The right-hand side can contain terminal or non-terminal symbols without restrictions.

  • What is the difference between Type 2 and Type 3 grammar?

    -While both types have constraints, Type 3 (regular) grammar requires that the non-terminal symbol in a production rule must appear at the far right of the rule, if present. This makes regular grammars more restrictive.

  • What is the significance of automata in relation to different grammar types?

    -Different types of grammars correspond to different types of automata. For example, Type 0 grammars are recognized by Turing machines, while Type 1 grammars are recognized by linear bounded automata. Type 2 grammars are associated with pushdown automata, and Type 3 grammars are recognized by finite state automata.

Outlines

00:00

📚 Introduction to Production Rules and Grammar

The first paragraph introduces the video topic, focusing on production rules and grammar. It explains the difference between terminal and non-terminal symbols. Terminal symbols are elements that cannot be further reduced, such as lowercase letters (e.g., 'a', 'b', 'c') or operators (e.g., plus, minus). Non-terminal symbols, on the other hand, can be further reduced into either terminal or non-terminal symbols, such as uppercase letters or specific expressions (e.g., 'S', 'XPR'). The paragraph also explains production rules, represented as 'Alpha produces Beta', where Alpha can consist of terminal or non-terminal symbols. Applying these rules allows a grammar to generate a set of strings, which forms a language. A few examples of production rules are provided, illustrating different possibilities, such as 'E produces T or E produces T+E'.

05:02

🧩 Chomsky's Hierarchy and Type-0 Grammars

This paragraph discusses the Chomsky Hierarchy, focusing on Type-0 or unrestricted grammars. These grammars have no restrictions on production rules, meaning that both the left and right sides of the rule can consist of terminal or non-terminal strings. The only requirement is that the left-hand side must include at least one non-terminal. An example of a Type-0 production rule is provided ('S produces AC AB'), and it is clarified that the terminal symbols cannot be reduced further. Type-0 grammars are recognized by Turing machines, a type of computational automaton capable of recognizing such languages.

10:05

🔄 Context-Sensitive and Context-Free Grammars

This section compares Type-1 (context-sensitive) and Type-2 (context-free) grammars. Type-1 grammars introduce a restriction where the number of symbols on the left-hand side of the production rule must be less than or equal to the number on the right-hand side. These grammars are recognized by linear bounded automata. In contrast, Type-2 grammars (context-free) limit the left-hand side to a single non-terminal symbol but have no restrictions on the right-hand side. These grammars generate languages recognizable by pushdown automata. Examples illustrate the rules for both types of grammars, emphasizing their differences.

🔗 Regular Grammars and Automata

This final paragraph describes Type-3 grammars, also known as regular grammars. In this grammar type, the left-hand side consists of a single non-terminal symbol, and the right-hand side can consist of terminal symbols or a terminal followed by a non-terminal, but any non-terminal must appear on the far right. Regular grammars generate languages recognized by finite state automata (FSA). An example is given to demonstrate how the production rule operates, emphasizing the unique position of non-terminal symbols. The hierarchy concludes with a summary of how each grammar type is recognized by different automata.

Mindmap

Keywords

💡Terminal Symbol

A terminal symbol is a symbol in a grammar that cannot be further broken down or replaced by other symbols. It represents the final elements of a string in a formal language. In the video, terminal symbols are exemplified by lowercase letters like 'a', 'b', 'c', and operators such as '+', '-'. These symbols are essential as they form the basic elements that cannot be reduced further in the production rules of a grammar.

💡Non-Terminal Symbol

A non-terminal symbol can be replaced by terminal or other non-terminal symbols according to the grammar's production rules. They help in generating terminal symbols and structure the grammar. For example, in the video, non-terminal symbols include uppercase letters like 'A', 'B', 'S', or expressions like 'Expr' and 'Stmt', which can be expanded into other symbols. They are crucial in defining the syntax structure of a formal language.

💡Production Rule

A production rule is a formal rule used to replace a symbol (typically non-terminal) with a string of other symbols. In the video, it is defined as 'Alpha produces Beta', where Alpha is replaced by Beta. The rule is essential for the generation of strings in a language. For instance, a rule might specify that 'S produces aB', where S is a non-terminal replaced by a terminal and another non-terminal.

💡Grammar

Grammar refers to the formal set of rules that define the structure of a language. It includes terminal symbols, non-terminal symbols, and production rules. In the video, grammar is central to generating strings in a language. The speaker explains different types of grammars, such as context-free or context-sensitive grammars, and their role in defining the syntax of formal languages.

💡Chomsky Hierarchy

The Chomsky hierarchy is a classification of grammars based on their generative power, consisting of four types: Type-0 (Unrestricted), Type-1 (Context-Sensitive), Type-2 (Context-Free), and Type-3 (Regular). In the video, the speaker discusses how each type of grammar produces different classes of languages, from unrestricted grammars that can be recognized by Turing machines to regular grammars recognized by finite state automata.

💡Unrestricted Grammar (Type-0)

Unrestricted grammar, or Type-0 grammar, has no restrictions on its production rules. It can generate any string, provided the left-hand side of a production contains at least one non-terminal. In the video, this type of grammar is said to generate languages recognized by Turing machines, demonstrating its flexibility in defining languages.

💡Context-Sensitive Grammar (Type-1)

Context-sensitive grammar, or Type-1 grammar, restricts its production rules such that the number of symbols on the left-hand side is less than or equal to the number of symbols on the right-hand side. This ensures that the grammar grows in complexity as strings are produced. In the video, this type of grammar is recognized by linear bounded automata, a type of computational model.

💡Context-Free Grammar (Type-2)

Context-free grammar (CFG) is a type of grammar where each production rule has a single non-terminal on the left-hand side, and the right-hand side can contain terminals and/or non-terminals. In the video, CFG is highlighted for its role in generating languages recognized by pushdown automata, making it important for programming language syntax, such as in compilers.

💡Regular Grammar (Type-3)

A regular grammar is the simplest type of grammar in the Chomsky hierarchy, where the left-hand side of a production rule contains one non-terminal, and the right-hand side contains a terminal followed by at most one non-terminal. In the video, regular grammar is described as producing languages recognized by finite state automata, commonly used in pattern matching and lexical analysis.

💡Turing Machine

A Turing machine is a theoretical computational model capable of simulating any algorithm's logic. In the video, the Turing machine is mentioned as the computational model that recognizes languages produced by Type-0 grammars. It plays a vital role in understanding the limits of computation and the most powerful grammars in the hierarchy.

Highlights

Introduction to production rules and grammar, focusing on terminal and non-terminal symbols.

Terminal symbols are symbols that cannot be further reduced, such as lowercase letters (a, b, c) and operators (+, -, etc.).

Non-terminal symbols can be further reduced to terminal or other non-terminal symbols, such as uppercase letters (A, B, C) or specific strings like 'expr' and 'stmt'.

Production rules: How strings are generated in a language through rules such as alpha producing beta.

A grammar can generate a set of strings, which forms the language defined by that grammar.

Example of a production rule: E produces T or T+E, illustrating the 'or' operator using vertical bars.

Introduction to formal grammars: Defined by terminal symbols, starting symbols, and production rules.

Chomsky hierarchy: Four levels of grammars—Type 0 (unrestricted), Type 1 (context-sensitive), Type 2 (context-free), and Type 3 (regular grammars).

Type 0 grammar (unrestricted grammar) allows both terminal and non-terminal symbols in production rules, recognized by Turing machines.

Type 1 grammar (context-sensitive) restricts production rules so that the length of symbols on the left-hand side is less than or equal to those on the right.

Type 1 languages are recognized by linear-bounded automata.

Type 2 grammar (context-free grammar) restricts the left-hand side of production rules to only one non-terminal symbol.

Type 2 languages are recognized by pushdown automata.

Type 3 grammar (regular grammar) has specific rules, where the left-hand side must be a non-terminal symbol, and the right-hand side can contain terminals with non-terminals at the far right.

Regular grammars are recognized by finite state automata (FSA).

Transcripts

play00:00

Halo

play00:02

assalamualaikum warahmatullah

play00:03

wabarakatuh

play00:05

pada video kali ini saya akan

play00:07

menyampaikan materi tentang aturan

play00:11

produksi dan grammar

play00:14

Hai nah beberapa poin yang

play00:18

terkait dengan aturan produksi dan

play00:21

grammar yaitu yang pertama adalah

play00:24

yaitu simbol Terminal dan simbol

play00:27

nonterminal Apa yang dimaksud dengan

play00:30

simbol Terminal simbol terminal adalah

play00:33

simbol yang dapat diturunkan lagi

play00:37

Hai nah yang termasuk simbol terminal

play00:39

adalah Misalnya contohnya adalah huruf

play00:42

kecil alfabet misalnya a b dan c

play00:46

kemudian simbol-simbol operator misalnya

play00:50

plus-minus kemudian ada simbol tanda

play00:53

baca

play00:55

dan juga sering yang tercetak tebal

play00:58

misalnya IV dan dan l

play01:02

itu adalah beberapa contoh yang termasuk

play01:04

simbol Terminal nah kemudian selanjutnya

play01:08

adalah simbol non Terminal

play01:11

Simbolon terminal adalah simbol yang

play01:14

masih bisa diturunkan menjadi simbol

play01:16

Terminal Atau nonterminal lainnya

play01:20

yang termasuk simbol nonton final adalah

play01:23

huruf besar alfabet misalnya a besar b

play01:28

besar dan C besar

play01:30

atau huruf s sebagai simbol awal atau

play01:35

misalnya string yang tercetak miring

play01:36

guys ia

play01:38

xpr dan STMT ekspresi dan statement

play01:43

nah ini adalah contoh-contoh simbol non

play01:47

terminal ya

play01:48

kemudian

play01:52

adalah aturan produksi

play01:55

nah aturan produksi

play01:58

dinyatakan di dalam bentuk seperti ini

play02:00

ya yaitu Alfa

play02:03

menghasilkan beta Alfa adalah menyatakan

play02:08

simbol-simbol pada ruas kiri aturan

play02:11

produksi sedangkan beta adalah

play02:14

menyatakan simbol-simbol pada ruas kanan

play02:16

aturan produksi ya dibacanya adalah Alfa

play02:21

menghasilkan beta

play02:23

nah simbol-simbol ini dapat berupa

play02:26

simbol Terminal ataupun non terminal

play02:30

jadi disini bisa terdiri atas Terminal

play02:32

atau nonton final ya yaitu aturan

play02:36

produksi Hai kemudian

play02:40

dengan menerapkan aturan produksi maka

play02:43

suatu tata bahasa bisa menghasilkan

play02:47

sejumlah string ya jadi aturan produksi

play02:51

adalah bagaimana aturan untuk

play02:52

menghasilkan suatu string ya dalam suatu

play02:55

bahasa menghasilkan suatu kalimat

play02:58

nah himpunan semua string adalah bahasa

play03:02

yang didefinisikan oleh tata bahasa

play03:05

tersebut

play03:06

itu adalah aturan produksi ya

play03:09

Nah contoh aturan produksi Seperti apa

play03:13

yaitu pertama bisa kita lihat di sini ya

play03:16

tadi bahwa aturan produksi dinyatakan

play03:18

dengan alfa menghasilkan beta maka di

play03:21

sini bisa kita lihat kalau contoh aturan

play03:24

produksinya seperti ini artinya kita

play03:25

bisa membacanya dengan P menghasilkan A

play03:30

atau bentuk lain ya ini ada huruf besar

play03:33

e-pemerintahan apa Nah teh kemudian ada

play03:36

garis lurus plus e-nano contoh aturan

play03:40

seperti ini itu dibacanya adalah eh

play03:43

menghasilkan T

play03:45

atau jadi ini adalah atau ya Eh

play03:50

menghasilkan ttplus

play03:52

e-jade disini tanda garis tegak ini

play03:55

menyatakan

play03:57

alternatif lain ya

play04:00

dari aturan produksi tersebut ya bahwa e

play04:04

bisa menghasilkan T atau Eh bisa

play04:06

menghasilkan t +

play04:09

e-nano itu untuk penulisan aturan

play04:11

produksi

play04:13

nah kemudian selanjutnya

play04:17

eh cramer ya di awal kita sudah

play04:19

mengetahui definisi tentang grammar atau

play04:21

tata bahasa yaitu

play04:24

didefinisikan secara formal jadian

play04:27

dikatakan dengan tata bahasa atau

play04:28

grammar adalah bagaimana kita bisa

play04:31

mendefinisikan secara formal kumpulan

play04:34

dari himpunan-himpunan

play04:37

Hai simbol Terminal

play04:40

simbol awal yang dibatasi oleh

play04:43

aturan-aturan produksi

play04:45

naiknya dikatakan dengan suatu grammar

play04:49

ya

play04:50

Nah

play04:52

terdapat empat tingkatan tatabahasa

play04:55

menurut chomsky dinyatakan dengan

play04:58

istilah hirarki chomsky ya yaitu yang

play05:01

pertama ada tipe nol ya dinyatakan

play05:04

dengan tipe nol yaitu and restricted

play05:06

grammar mudah ada tipe satu yaitu

play05:09

konteks sensitif grammar kemudian ada

play05:12

tipe2 konteks free grammar mudah ada

play05:16

tipe tiga yaitu regular grammar nah ini

play05:19

adalah tingkatan tatabahasa ya

play05:23

Nah kita lihat dulu untuk type 0 yaitu

play05:26

unrestricted grammar nah disini

play05:30

aturan produksinya tidak memiliki

play05:32

batasan ya Nah dikatakan bahwa disini

play05:36

untuk penulisan Nova menghasilkan beta

play05:39

Alfa dalah bisa string Terminal atau non

play05:42

terminal jadi Disini di posisi Alfa itu

play05:45

bisa string Terminal atau non Terminal

play05:48

dengan setidaknya 16 Terminal

play05:51

ini setidaknya ada satu nonton binal

play05:54

kemudian b adalah rangkaian simbol

play05:56

Terminal dan nonton final itu ya Nah

play05:59

untuk penulisan seperti itu dikatakan

play06:00

dia termasuk bahasa type-0 atau angin

play06:05

restricted greenlot

play06:09

contoh ya Nah Contohnya seperti ini

play06:15

untuk tipe 0s menghasilkan AC ab ya tadi

play06:21

dikatakan bahwa di sebelah kiri Alfan

play06:23

adalah minimal satu eh ada 10 Terminal

play06:27

Ya setidaknya 10 Terminal ini yang di

play06:30

sebelah kiri maka disini kalau nonton

play06:32

final tadi dinyatakan dengan huruf besar

play06:34

ya Ini

play06:35

nah setidaknya ada non Terminal udah di

play06:40

sini cara membaca adalah es menghasilkan

play06:42

AC AB na di kolom beta dibagian kanan di

play06:47

sisi kanan ini

play06:49

ya bahwa beta bisa terdiri atas baik itu

play06:53

Terminal atau nonterminal ya sini AC

play06:58

abte yang huruf kecil adalah Terminal

play07:01

ini atau terminal yang tidak bisa

play07:02

diturunkan kembali sedangkan a besar c

play07:06

besar b besar adalah

play07:08

eh

play07:10

tuh ya Maaf yang tadi ini adalah

play07:12

terminal ya aku kecilnya adalah Terminal

play07:15

sedangkan a besar c besar adalah

play07:18

nonterminal

play07:20

nah ini adalah contoh Untuk penulisan

play07:23

aturan produksi dengan tipe nol Nah

play07:27

untuk type 0 ini atau and restricted

play07:29

gram merica ada akan menghasilkan bahasa

play07:31

yang dikenal oleh mesin turing jadi

play07:34

mesin turing adalah merupakan salah satu

play07:36

bagian jenis daripada otomata ya

play07:39

maka bahasa yang dikenal oleh masuknya

play07:42

itu bahasa type-0 atau and restricted

play07:45

grammar

play07:47

kemudian ada tipe satu yaitu konteks

play07:50

sensitif cramer

play07:52

aturan produksi sama dengan tipe nol

play07:54

namun Nah di sini ada batasan bahwa

play07:57

aturannya adalah Jumlah dari Alfa itu

play08:00

harus lebih sedikit dan sama dengan dari

play08:03

jumlah betanya jadi jumlah simbol di

play08:07

ruas kiri harus lebih kecil atau sama

play08:10

dengan dengan jumlah simbol diruas kanan

play08:12

tidak boleh lebih ya maka

play08:16

contohnya adalah ini ya

play08:20

yang di sebelah kiri itu harus lebih

play08:22

kecil

play08:24

jumlahnya dibandingkan yang sebelah

play08:26

kanan lain ngerti sudah lebih kecil ya

play08:29

sc1 ya Jin juga varian nonton ala2 sudah

play08:33

lebih kecil dibanding daripada yang

play08:35

dikarenakan gitu ini boleh ya bisa

play08:39

minimal sama

play08:41

Ken Iya Nah untuk konteks sensitif

play08:44

greenmar akan menghasilkan bahasa yang

play08:46

dikenali oleh linear Bondet automata nah

play08:50

ini automata yang nya LBH ini adalah

play08:53

juga merupakan jenis otomata yang dapat

play08:55

mengenali

play08:58

konteks sensitif grammar ya

play09:00

tingkatan bahasa tipe satu

play09:04

kemudian

play09:07

selanjutnya adalah tipe dua yaitu

play09:10

konteks free grammar tata bahasa bebas

play09:13

konteks ya konteks free grammar tata

play09:16

bahasa bebas konteks

play09:18

disini adalah aturan produksi sama

play09:20

dengan tipe nol namun

play09:22

Alfa di sisi kiri hanya boleh memiliki

play09:25

satu variabel nonterminal

play09:27

dan b tidak memiliki batasan jadi disini

play09:31

untuk

play09:34

Alfa yaitu hanya boleh satu simbol

play09:39

nonterminal tidak boleh lebih sementara

play09:42

yang dibagian kanan yaitu beta

play09:46

itu bisa

play09:48

lebih yaitu tidak memiliki batasannya di

play09:51

beta dapat berupa rangkaian atau simbol

play09:55

Terminal dan non Terminal

play09:57

itu untuk konteks free grammar

play10:00

contohnya nah ini seperti ini ya minimal

play10:05

satu variabel nonterminal di sebelah

play10:08

kiri

play10:15

maksimalnya bukan minimal ini maksimal

play10:17

di sebelah kiri satu variabel non

play10:20

Terminal itu maksimal di sebelah kiri

play10:23

Nah untuk tipe 2 ini atau tata bahasa

play10:27

bebas konteks ini akan menghasilkan

play10:29

bahasa yang dikenali oleh automata

play10:34

nondeterministic pucay atau Dea ya

play10:38

pushdown automata

play10:41

nah modern type 3 yang terakhir

play10:44

tingkatan bahasa grafir yaitu regular

play10:47

grammar

play10:51

disini adalah dinyatakan bahwa Alpha

play10:55

adalah sebuah simbol nonterminal

play10:57

ini adalah simbol nonton binal sedangkan

play11:00

beta adalah simbol Terminal atau simbol

play11:06

pohon ini simbol Terminator simbol

play11:08

terminal ya dengan sebuah simbol

play11:10

variabel yang jika ada terletak pada

play11:13

posisi paling kanan jadi disini pasti

play11:16

nonton Minal sedangkan disini adalah

play11:17

bisa Terminal atau nonton final namun

play11:20

jika 6 Terminal itu adalah

play11:22

simbol nonton final terletak pada posisi

play11:25

yang paling kanan gitu ya

play11:28

itu untuk

play11:31

tata bahasa reguler

play11:33

Contohnya seperti ini nah tata bahasa

play11:36

reguler nah

play11:38

akan menghasilkan bahasa dikenali oleh

play11:41

fsa

play11:42

jadi

play11:44

untuk out Om Vincent automata itu akan

play11:48

bisa menghasilkan atau akan bisa

play11:50

mengenali

play11:53

atau bahasa ya dengan formula seperti

play11:57

ini yang dikatakan deleu bahwa sebagai

play11:59

tata bahasa reguler ya tipe tiga regu

play12:03

ler grammar nafsu Contohnya seperti ini

play12:06

ya Ini adalah non Terminal modern peta

play12:09

yang tidak ada batasan tapi jika ada

play12:11

didalamnya ada variabel non Terminal

play12:13

maka dia akan terletak di paling kanan

play12:16

Ok seperti itu untuk

play12:19

beberapa

play12:20

tingkatan bahasa mulai dari type-0 Tipe

play12:24

1 tipe 2 tipe 3 menurut hirarki chomsky

play12:29

terima kasih

Rate This

5.0 / 5 (0 votes)

Étiquettes Connexes
Production RulesGrammar TypesChomsky HierarchyTerminal SymbolsNon-terminal SymbolsContext-FreeAutomata TheoryTuring MachinesGrammar TheoryLanguage Rules
Besoin d'un résumé en anglais ?