Grammars Grammars express languages Example the English language
- Slides: 68
Grammars
Grammars express languages Example: the English language
A derivation of “the dog walks”:
A derivation of “a cat runs”:
Language of the grammar: L = { “a cat runs”, “a cat walks”, “the cat runs”, “the cat walks”, “a dog runs”, “a dog walks”, “the dog runs”, “the dog walks” }
Notation Production Rules Variable Terminal
Another Example Grammar: Derivation of sentence :
Grammar: Derivation of sentence :
Other derivations:
Language of the grammar
More Notation Grammar Set of variables Set of terminal symbols Start variable Set of Production rules
Example Grammar :
More Notation Sentential Form: A sentence that contains variables and terminals Example: Sentential Forms sentence
We write: Instead of:
In general we write: If:
By default:
Example Grammar Derivations
Example Grammar Derivations
Another Grammar Example Grammar Derivations: :
More Derivations
Language of a Grammar For a grammar with start variable : String of terminals
Example For grammar Since: :
A Convenient Notation
Linear Grammars
Linear Grammars with at most one variable at the right side of a production Examples:
A Non-Linear Grammar Number of : in string
Another Linear Grammar :
Right-Linear Grammars All productions have form: or Example: string of terminals
Left-Linear Grammars All productions have form: or Example: string of terminals
Regular Grammars
Regular Grammars A regular grammar is any right-linear or left-linear grammar Examples:
Observation Regular grammars generate regular languages Examples:
Regular Grammars Generate Regular Languages
Theorem Languages Generated by Regular Grammars Regular Languages
Theorem - Part 1 Languages Generated by Regular Grammars Regular Languages Any regular grammar generates a regular language
Theorem - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by a regular grammar
Proof – Part 1 Languages Generated by Regular Grammars Regular Languages The language generated by any regular grammar is regular
The case of Right-Linear Grammars Let be a right-linear grammar We will prove: Proof idea: is regular We will construct NFA with
Grammar Example: is right-linear
Construct NFA such that every state is a grammar variable: special final state
Add edges for each production:
NFA Grammar
In General A right-linear grammar has variables: and productions: or
We construct the NFA each variable such that: corresponds to a node: special final state
For each production: we add transitions and intermediate nodes ………
For each production: we add transitions and intermediate nodes ………
Resulting NFA It holds that: looks like this:
The case of Left-Linear Grammars Let be a left-linear grammar We will prove: is regular Proof idea: We will construct a right-linear grammar with
Since is left-linear grammar the productions look like:
Construct right-linear grammar Left linear Right linear
Construct right-linear grammar Left linear Right linear
It is easy to see that: Since Regular Language is right-linear, we have: Regular Language
Proof - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by some regular grammar
Any regular language is generated by some regular grammar Proof idea: Let be the NFA with Construct from such that . a regular grammar
Since is regular there is an NFA such that Example:
Convert to a right-linear grammar
In General For any transition: Add production: variable terminal variable
For any final state: Add production:
Since is right-linear grammar is also a regular grammar with
- Which grammar generates regular language
- Linear grammar
- Unrestricted grammer
- Questions on context free grammar
- Removal of epsilon productions
- Unrestricted grammar is also known as
- New zealand national sport
- Aotearoa the land of the long white cloud
- Levels of language knowledge
- Hình ảnh bộ gõ cơ thể búng tay
- Frameset trong html5
- Bổ thể
- Tỉ lệ cơ thể trẻ em
- Chó sói
- Tư thế worms-breton
- Chúa yêu trần thế alleluia
- Môn thể thao bắt đầu bằng chữ f
- Thế nào là hệ số cao nhất
- Các châu lục và đại dương trên thế giới
- Công của trọng lực
- Trời xanh đây là của chúng ta thể thơ
- Mật thư anh em như thể tay chân
- 101012 bằng
- Phản ứng thế ankan
- Các châu lục và đại dương trên thế giới
- Thơ thất ngôn tứ tuyệt đường luật
- Quá trình desamine hóa có thể tạo ra
- Một số thể thơ truyền thống
- Cái miệng bé xinh thế chỉ nói điều hay thôi
- Vẽ hình chiếu vuông góc của vật thể sau
- Nguyên nhân của sự mỏi cơ sinh 8
- đặc điểm cơ thể của người tối cổ
- Ví dụ giọng cùng tên
- Vẽ hình chiếu đứng bằng cạnh của vật thể
- Vẽ hình chiếu vuông góc của vật thể sau
- Thẻ vin
- đại từ thay thế
- điện thế nghỉ
- Tư thế ngồi viết
- Diễn thế sinh thái là
- Các loại đột biến cấu trúc nhiễm sắc thể
- Số nguyên tố là
- Tư thế ngồi viết
- Lời thề hippocrates
- Thiếu nhi thế giới liên hoan
- ưu thế lai là gì
- Sự nuôi và dạy con của hươu
- Sự nuôi và dạy con của hươu
- Hệ hô hấp
- Từ ngữ thể hiện lòng nhân hậu
- Thế nào là mạng điện lắp đặt kiểu nổi
- Node js
- English speak lesson
- Spoken english and broken english summary
- Language change
- Who is father of english drama
- Old english vs modern english
- Napkin british english
- British and american english
- Old english vs modern english
- Bella said i speak english
- 2000 in old english
- Spoken english and broken english summary
- Rhodic english
- Why do individual languages vary among places
- Assembly languages list
- Multithreaded languages
- Turing unrecognizable languages
- Love tank test