CSNB143 – Discrete Structure Topic 11 – Language.

Slides:



Advertisements
Similar presentations
REMOVING LEFT RECURSION AND INDIRECT LEFT RECURSION
Advertisements

C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
Grammars, Languages and Parse Trees. Language Let V be an alphabet or vocabulary V* is set of all strings over V A language L is a subset of V*, i.e.,
Fall 2008Programming Development Techniques 1 Topic 9 Symbol Manipulation Generating English Sentences Section This is an additional example to symbolic.
COGN1001: Introduction to Cognitive Science Topics in Computer Science Formal Languages and Models of Computation Qiang HUO Department of Computer.
Grammars.
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Syntax LING October 11, 2006 Joshua Tauberer.
Chapter 3: Formal Translation Models
Specifying Languages CS 480/680 – Comparative Languages.
COP4020 Programming Languages
Context-free Grammars
Syntactic Pattern Recognition Statistical PR:Find a feature vector x Train a system using a set of labeled patterns Classify unknown patterns Ignores relational.
Meaning and Language Part 1.
Languages and Grammars MSU CSE 260. Outline Introduction: E xample Phrase-Structure Grammars: Terminology, Definition, Derivation, Language of a Grammar,
English Jeopardy! Created by: Mr. Erickson Created by: Mr. Erickson.
Grammars.
Lecture 21: Languages and Grammars. Natural Language vs. Formal Language.
1 INFO 2950 Prof. Carla Gomes Module Modeling Computation: Languages and Grammars Rosen, Chapter 12.1.
Copyright © Cengage Learning. All rights reserved.
Languages & Strings String Operations Language Definitions.
Modeling Computation Rosen, ch. 12.
ICS611 Introduction to Compilers Set 1. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Introduction Syntax: form of a sentence (is it valid) Semantics: meaning of a sentence Valid: the frog writes neatly Invalid: swims quickly mathematics.
What is a Sentence? By Jaye Lynn Trapp.
CSI 3120, Grammars, page 1 Language description methods Major topics in this part of the course: –Syntax and semantics –Grammars –Axiomatic semantics (next.
CAS LX 502 8b. Formal semantics A fragment of English.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
A sentence (S) is composed of a noun phrase (NP) and a verb phrase (VP). A noun phrase may be composed of a determiner (D/DET) and a noun (N). A noun phrase.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Grammars CPSC 5135.
Discrete Structure Li Tak Sing( 李德成 ) Lectures
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
ELIMINATING LEFT RECURSIVENESS. Abbreviation. “cfg” stands for “context free grammar” Definition. A cfg is left recursive if it contains a production.
Parsing Introduction Syntactic Analysis I. Parsing Introduction 2 The Role of the Parser The Syntactic Analyzer, or Parser, is the heart of the front.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Rules, Movement, Ambiguity
Chapter 3 Describing Syntax and Semantics
Artificial Intelligence: Natural Language
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
Parsing and Code Generation Set 24. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program,
Programming Languages and Design Lecture 2 Syntax Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Lecture 16: Modeling Computation Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output.
Formal Languages and Grammars
GRAMMARS & PARSING. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program, referred to as a.
1 LIN 1310B Introduction to Linguistics Prof: Nikolay Slavkov TA: Qinghua Tang CLASS 11, Feb 9, 2007.
Formal Language. A formal language is defined by two components: -Alphabet -Rules of syntax.
Chapter 4: Syntax analysis Syntax analysis is done by the parser. –Detects whether the program is written following the grammar rules and reports syntax.
Think of a sentence to go with this picture. Can you use any of these words? then if so while though since when Try to use interesting adjectives, powerful.
NATURAL LANGUAGE PROCESSING
Composing Music with Grammars. grammar the whole system and structure of a language or of languages in general, usually taken as consisting of syntax.
7.2 Programming Languages - An Introduction to Informatics WMN Lab. Hye-Jin Lee.
Syntax Analysis By Noor Dhia Syntax analysis:- Syntax analysis or parsing is the most important phase of a compiler. The syntax analyzer considers.
King Faisal University جامعة الملك فيصل Deanship of E-Learning and Distance Education عمادة التعلم الإلكتروني والتعليم عن بعد [ ] 1 King Faisal University.
Formal Languages and Automata FORMAL LANGUAGES FINITE STATE AUTOMATA.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesAlgebraic.
PROGRAMMING LANGUAGES
PROGRAMMING LANGUAGES
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
System Software Unit-1 (Language Processors) A TOY Compiler
Classification of Languages
Context-Free Languages
CSE322 LEFT & RIGHT LINEAR REGULAR GRAMMAR
CSE 311: Foundations of Computing
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Teori Bahasa dan Automata Lecture 9: Contex-Free Grammars
Languages and Grammer In TCS
Presentation transcript:

CSNB143 – Discrete Structure Topic 11 – Language

Learning Outcomes Student should identify the basic components in language Students should be able to produce phrase structure grammar

Topic 11 – Language Understanding Language If set W = {all characters from a, b, c, …….., z, A, B, C, ……., Z}, then set W* = {all words that can be formed from W} = {aabb, bus, lamp, pqrs, ….}, either it has any meaning or not. Let say set S = {all possible words} = W*, then Then set S* = {all possible sentences that can be formed from S} = {I like to play, the dog is running, aabb shine pqrst, ….}, either it has any meaning or not. Then we can say that language consists of three basic things, that are: – S; a set of all possible words, – S*; a set of properly constructed sentences, (this is what we called as syntax, that differentiate between a properly constructed sentence and not a properly constructed sentence.) – The meaning of the sentences (referred to as semantic)

Topic 11 – Language Understanding Language Example 1 : Consider the two sentences below: Going to the store John George to sing. This sentence is a valid sentence in S*, but it doesn’t constructed properly. The order of noun and verb is not valid. Noiseless blue sounds sit cross-legged under the mountaintop. This sentence is correct in structure, but it doesn’t have any meaning.

Topic 11 – Language Understanding Language The need to identify syntax has expanding the formal language, to a new set of rules, we determine that: – Sentence must be built from noun phrase and verb phrase. – Noun phrase must be built from an article and adjective, followed by noun. – Noun phrase must be built from an article and noun. – Verb phrase must be built from verb and adverb. – Verb phrase must be built from verb. – Article is either a or the – Adjective is either large or hungry – Noun is either rabbit or doctor – Verb is either eats or hops – Adverb is either quickly or wildly

Topic 11 – Language Understanding Language Can make sentence using the order of valid replacement Other sentences are: – a hungry doctor eats wildly – a large doctor hops wildly – the hungry rabbit eats quickly,.....and so on.

Topic 11 – Language Phrase Structure Grammar Syntax being used to produce valid sentences with meaning Referred to as G, that consists of four elements: – V; a finite set of elements, consists of S together with some other symbols – S; a subset of V that consists of terminal symbols, S is a set of all allowed words in a language. – v 0 ; where v 0  V – S, it is the element v 0 of V is the starting point for substitution –  a finite relation on V*. The relation  on V* specifies allowable replacements, e.g if w  w’, we may replace w with w’ whenever string w occurs, either alone or as combination with other string. We call  the production relation. Phase Structure Grammar is written as G = (V, S, v 0,  ) Traditionally, the statement w  w’ called a production of G. w and w’ are termed the left and right sides of the production.

Topic 11 – Language Phrase Structure Grammar Example: G = (V, S, v 0,  ) Let S = {John, Jill, drives, jogs, carelessly, rapidly, frequently}; N = {sentence, noun, verbphrase, verb, adverb} and V = S  N. Let v 0 = sentence (starting point of substitution) and relation  on V* (all possible sentence that can be formed from the words) are defined as: – Noun  John – Noun  Jill – Verbphrase  verb + adverb – Verb  drives – Verb  jogs – Adverb  carelessly – Adverb  rapidly – Adverb  frequently

Topic 11 – Language Phrase Structure Grammar Answer: Then we can have few sentences that syntactically correct, for example:

Topic 11 – Language Phrase Structure Grammar - the language of G, L(G) In phrase structure grammars G, correct syntax simply refers to the process by which a sentence is formed. A set of all properly constructed sentences that can be produced using a grammar G is called the language of G, denoted by L (G)

Topic 11 – Language The language of G, L(G) Example: Let V = {v 0, w, a, b, c}; S = {a, b, c} and  is relations on V* given by : (1) v 0  aw(2) w  bbw(3) w  c Derive a proper L(G) (can use substitution approach and derivation tree approach)

Topic 11 – Language The language of G, L(G) Answer: Let V = {v 0, w, a, b, c}; S = {a, b, c} and  is relations on V* given by : (1) v 0  aw(2) w  bbw(3) w  c Derive a proper L(G). To derive the language of L(G), necessary to perform successive substitution, until all symbols are eliminated other than the terminal symbols (in this case a,b,c). Since v 0 is the substitution starting point, we will usually start with production (1), v 0  aw. Result after trying both substitution and tree derivation approach, the L(G) obtained will be a(bb) n c