BAHASA Languages TEORI BAHASA DAN OTOMATA Sulistyo Puspitodjati
BAHASA (Languages) TEORI BAHASA DAN OTOMATA Sulistyo Puspitodjati sulistyo@staff. gunadarma. ac. id
BAHASA Huruf: adalah simbol/karakter yang digunakan dalam suatu bahasa Bahasa (Language): Kumpulan untai Untai/kata (String/word): urutan/rangkaian/aliran dari simbol dari suatu alfabet Contoh: alafbet Strings: cat, dog, house Language: {cat, dog, house} Costas Busch - RPI 2
Bahasa sering digunakan untuk menjelaskan masalah komputasi: Alphabet: Costas Busch - RPI 3
Alfabet dan Untai (string) Alfabet adalah himpunan simbol Contoh Alphabet: Untai adalah urutan simbol dari suatu alfabet Contoh untai Costas Busch - RPI 4
Alfabet bilanga desimal Alfabet bilanga biner Costas Busch - RPI 5
Unary numbers alphabet Unary number: Decimal number: Costas Busch - RPI 6
String Operations Penyandingan (Concatenation) Costas Busch - RPI 7
Reverse = memutar balik Costas Busch - RPI 8
Panjang Untai (String Length) Panjang (Length): Contoh: Costas Busch - RPI 9
Panjang hasil Penyandingan (Length of Concatenation) Contoh: Costas Busch - RPI 10
Untai Hampai (Empty String) = Untai yang tidak mengandung huruf Observations: Costas Busch - RPI 11
Substring of string: n a subsequence of consecutive characters String Substring Costas Busch - RPI 12
Prefix and Suffix Contoh untuk string (untai): Prefixes Suffixes prefix suffix Costas Busch - RPI 13
The * Operation (Kleene Closure) : the set of all possible strings from alphabet Costas Busch - RPI 15
The + Operation (Positve Closure) : the set of all possible strings from alphabet except Costas Busch - RPI 16
Languages Bahasa atas alfabet Examples: adalah subeset dari Language: Costas Busch - RPI 17
Contoh Bahasa Alphabet Contoh: bahasa tak hingga (infinite language) Costas Busch - RPI 18
Prime numbers Alphabet Language: Costas Busch - RPI 19
Even and odd numbers Alphabet Costas Busch - RPI 20
Unary Addition Alphabet: Language: Costas Busch - RPI 21
Squares Alphabet: Language: Costas Busch - RPI 22
Note that: Sets Set size String length Costas Busch - RPI 23
Operasi pada Bahasa Opersi biasa seperti pada himpunan Complement: Costas Busch - RPI 24
Reverse Definition: Examples: Costas Busch - RPI 25
Concatenation Definition: Example: Costas Busch - RPI 26
Operasi Pangkat Definition Special case: Costas Busch - RPI 27
Costas Busch - RPI 28
Star-Closure (Kleene *) Adalah semua untai yang dapat dibentuk dari Definisi: Contoh: Costas Busch - RPI 29
Positive Closure Definisi: Sama dengan tapi tanpa Costas Busch - RPI 30
grammar The theory of formal languages finds its applicability extensively in the fields of Computer Science. Noam Chomsky gave a mathematical model of grammar in 1956 which is effective for writing computer languages.
Grammar G can be formally written as a 4 -tuple (N, T, S, P) where − N or VN is a set of variables or non-terminal symbols. T or ∑ is a set of Terminal symbols. S is a special variable called the Start symbol, S ∈ N P is Production rules for Terminals and Nonterminals. A production rule has the form α → β, where α and β are strings on VN ∪ ∑ and least one symbol of α belongs to VN.
Example Grammar G 1 = ({S, A, B}, {a, b}, S, {S → AB, A → a, B → b}) Here, S, A, and B are Non-terminal symbols; a and b are Terminal symbols S is the Start symbol, S ∈ N Productions, P : S → AB, A → a, B → b
Example Grammar G 2 = (({S, A}, {a, b}, S, {S → a. Ab, a. A → aa. Ab, A → ε } ) Here, S and A are Non-terminal symbols. a and b are Terminal symbols. ε is an empty string. S is the Start symbol, S ∈ N Production P : S → a. Ab, a. A → aa. Ab, A→ε
Derivations from a Grammar Strings may be derived from other strings using the productions in a grammar. If a grammar G has a production α → β, we can say that x α y derives x β y in G. This derivation is written as − x α y ⇒G x β y
Example Let us consider the grammar − G 2 = ({S, A}, {a, b}, S, {S → a. Ab, a. A → aa. Ab, A → ε } ) Some of the strings that can be derived are − S ⇒ a. Ab using production S → a. Ab ⇒ aa. Abb using production a. A → a. Ab ⇒ aaa. Abbb using production a. A → a. Ab ⇒ aaabbb using production A → ε
- Slides: 35