1 / 17

Introduction to Formal Languages

Introduction to Formal Languages. CSC 333. Introduction. A programming language like Java has rules of syntax that a programmer must obey in order for his program to compile. Likewise, a natural language, such as english or spanish , has syntax rules.

ian-stanley
Download Presentation

Introduction to Formal Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Formal Languages CSC 333

  2. Introduction • A programming language like Java has rules of syntax that a programmer must obey in order for his program to compile. • Likewise, a natural language, such as english or spanish, has syntax rules. • Without following them, some combinations of valid words would be meaningless or, worse, could convey the wrong meaning.

  3. Definitions Alphabet Word Language

  4. Definitions Alphabet Word Language Grammar – a system of rules that defines the structure of a language.

  5. Definitions Grammar – a system of rules that defines the structure of a language. Generative grammar – a description in the form of a set of rules for producing grammatical sentences of a language.

  6. Noam Chomsky • American linguist born in 1928 • Professor emeritus of linguistics at MIT • (also: an anarchist) • 1950’s – Developed theory of generative grammar in order to model natural languages.

  7. Noam Chomsky • American linguist born in 1928 • Professor emeritus of linguistics at MIT • (also: an anarchist) • 1950’s – Developed theory of generative grammar in order to model natural languages. • Note that one can start with a grammar definition and derive a language, or one can attempt to define a grammar that can sufficiently describe an existing language. • Defining a grammar to describe a natural language can be quite difficult. Consider Example 40.

  8. Examples Programming languages - 41 Use of Backus-Naur form (BNF) - 42

  9. Chomsky Hierarchy Type 0 – unrestricted grammars Type 1- context-sensitive Type 2 – context- free Type 3 – regular

  10. Definition A phrase-structure (type 0) grammar G is a 4-tuple, G = (V, VT, S, P), where V = vocabulary VT = a set of terminals S = the start symbol P = a set of productions (see p. 667)

  11. Formal Languages Formal languages are languages that can be derived from grammars formally defined as in the manner of Example 36. As stated before, one can start with a grammar definition and derive a language, or one can attempt to define a grammar that can sufficiently describe an existing language.

  12. The Erasing Convention Productions resulting in lambda, the empty string, have the effect of erasing symbols. See Example 44. The restricted Chomsky grammars obey the erasing convention, which says that if erasing is allowed, it is confined to S -> λ.

  13. Grammars in the Chomsky Hierarchy Type 0 – unrestricted grammars. Type 1- context-sensitive: A grammar that obeys the erasing convention, and for every production α -> β (except S -> λ), the word β is at least as long as the word α. Type 2 – context- free Type 3 – regular

  14. Grammars in the Chomsky Hierarchy Type 0 – unrestricted grammars. Type 1- context-sensitive: A grammar that obeys the erasing convention, and for every production α -> β (except S -> λ), the word β is at least as long as the word α. Type 2 – context- free: A grammar that also has the restriction that for a production α -> β, α is a single nonterminal. Type 3 – regular

  15. Grammars in the Chomsky Hierarchy Type 0 – unrestricted grammars. Type 1- context-sensitive: A grammar that obeys the erasing convention, and for every production α -> β (except S -> λ), the word β is at least as long as the word α. Type 2 – context- free: A grammar that also has the restriction that for a production α -> β, α is a single nonterminal. Type 3 – regular: A grammar that adds the restriction that β is of the form t or tW, where t is a terminal and W is a nonterminal.

  16. Grammar Relationships Consider the examples of grammar types cited on p. 674. See Figure 8.21.

  17. Languages and Computational Devices FSMs recognize regular languages (type 3). PDAs recognize context-free languages (type 2). LBAs recognize context-sensitive languages. Turing machines recognize type 0 languages.

More Related