SIE 550 – Formal Languages Lecture for SIE 550 Matt Dube Doctoral Student – Spatial IGERT Fellow.

Slides:



Advertisements
Similar presentations
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Math 191: Mathematics and Geometry for Designers Lecture Notes Based on The Book Mathematics in Our World by Allan G. Bluman.
Grammars.
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
Python Programming Chapter 1: The way of the program Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Honors Compilers An Introduction to Grammars Feb 12th 2002.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
A basis for computer theory and A means of specifying languages
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
Python Programming Chapter 2: Variables, expressions, and statements Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Programming Languages An Introduction to Grammars Oct 18th 2002.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Specifying Languages CS 480/680 – Comparative Languages.
Text-To-Speech System for Marathi Miss. Deepa V. Kadam Indian Institute of Technology, Bombay.
Elements for achieve coherence in an essay. coherence Correct use of pronouns Correct use of nouns Correct use of puntuation Correct use of transition.
Language Translation Principles Part 1: Language Specification.
Grammars and Parsing. Sentence  Noun Verb Noun Noun  boys Noun  girls Noun  dogs Verb  like Verb  see Grammars Grammar: set of rules for generating.
Data vs. Information OUTPUTOUTPUT Information Data PROCESSPROCESS INPUTINPUT There are 10 types of people in this world those who read binary and those.
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
Grammars.
Lecture 21: Languages and Grammars. Natural Language vs. Formal Language.
Theory Of Automata By Dr. MM Alam
ITEC 380 Organization of programming languages Lecture 2 – Grammar / Language capabilities.
English: Thursday, May 22, 2014 Lit Books! 1.Handouts: * Grammar #52 (Diagramming Simple Subjects and Simple Predicates) 2.Homework: * Grammar #52 (Diagramming.
Formal Languages, Part Two SIE 550 Lecture Matt Dube Doctoral Student – Spatial.
General Programming Introduction to Computing Science and Programming I.
Graphophonemic System – Phonics
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.
Just Words Review Unit 1 About English: Every human community has a language, or a way to speak to each other with understanding Every human community.
CSNB143 – Discrete Structure Topic 11 – Language.
Parsing Lecture 5 Fri, Jan 28, Syntax Analysis The syntax of a language is described by a context-free grammar. Each grammar rule has the form A.
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
PROGRAMMING In. Objectives  We’re learning to develop basic code with the use of the correct syntax and variables. Outcomes  Explain what syntax is.
Grammars Grammars can get quite complex, but are essential. Syntax: the form of the text that is valid Semantics: the meaning of the form – Sometimes semantics.
D Goforth COSC Translating High Level Languages Note error in assignment 1: #4 - refer to Example grammar 3.4, p. 126.
Chapter 3 Describing Syntax and Semantics
1 California State University, Fullerton Chapter 5 Information System Software.
May 2008CLINT-LIN Regular Expressions1 Introduction to Computational Linguistics Regular Expressions (Tutorial derived from NLTK)
GRAMMARS & PARSING Lecture 8 CS2110 – Spring If you are going to form a group for A2, please do it before tomorrow (Friday) noon.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen October 29,2015.
Compiler Construction By: Muhammad Nadeem Edited By: M. Bilal Qureshi.
SM2220 – Class 06 Finite Automata. SM2220 – Class 06 Topic in theoretical computing. A subset of computation machines. Closely related to formal language.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Syntax Analysis - Parsing Compiler Design Lecture (01/28/98) Computer Science Rensselaer Polytechnic.
Syntax and Semantics Form and Meaning of Programming Languages Copyright © by Curt Hill.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
September1999 CMSC 203 / 0201 Fall 2002 Week #14 – 25/27 November 2002 Prof. Marie desJardins clip art courtesy of
End of the beginning Let’s wrap up some details and be sure we are all on the same page Good way to make friends and be popular.
NATURAL LANGUAGE PROCESSING
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Spring
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Autumn 2012 CSE
7.2 Programming Languages - An Introduction to Informatics WMN Lab. Hye-Jin Lee.
Introduction to Spreadsheets The ‘Quick’ and ‘Easy’ guide to using Microsoft Excel.
Compiler Construction Lecture Five: Parsing - Part Two CSC 2103: Compiler Construction Lecture Five: Parsing - Part Two Joyce Nakatumba-Nabende 1.
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
BNF A CFL Metalanguage Some Variations Particular View to SLK Copyright © 2015 – Curt Hill.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
System Software Unit-1 (Language Processors) A TOY Compiler
A Simple Syntax-Directed Translator
What does it mean? Notes from Robert Sebesta Programming Languages
Presentation transcript:

SIE 550 – Formal Languages Lecture for SIE 550 Matt Dube Doctoral Student – Spatial IGERT Fellow

Languages What do we think of when we think of languages? lettersnumberspunctuation syllables words parts of speech grammar phrases sentences BUILDING BLOCKS BUILDINGS IN THE LANGUAGE

What are we going to do today? Not quite what you bargained for We are going to learn how to write in a foreign language that none of us can actually speak We will then use that language to set up the constructs that govern computers and database constructs

The Language Is…. KOREAN

Korean Words 말하다 This is a one word English physical action. So everyone take a guess by doing a physical action. SPEAK

Now That You Understand Korean… (pause for raucous laughter) Korean appears to be a graphical language, like Chinese and quite unlike English Looks are very deceiving though 말하다

KOREAN ALPHABET Korean is an alphabetical language! ConsonantsVowels

ConsonantsVowels 말하다 But wait….Those characters aren’t in the alphabet! Let’s take a closer look: So what exactly is each character in the phrase “speak”?

Syllables Each character in written Korean is actually a syllable! Any patterns?

ConsonantsVowels 말하다

Syllables Korean characters are syllables! Any patterns? –Consonant followed by a vowel –Consonant followed by a vowel followed by a consonant All characters in written Korean follow either of those two patterns A syllable is thus a composite of characters in a specified order (and they all exist ironically enough). Words, phrases, sentences, etc. are composite of syllables.

What About English? NOT SO SIMPLE!

Example What then does “qeb” mean? ABSOLUTELY NOTHING! “dog” CUTE, CUDDLY, FURRY ANIMAL THAT BARKS

English Language Syllables do not work with our alphabet Thus some are not valid Syllables are phonetically based Korean is a phonetically based language English is the hardest language to learn Korean is the easiest language to learn

Why Did We Do That? Necessity Computers and databases need a “Korean” type of language as opposed to an English type of language –Parsing –Relevancy Korean is a formal language

Formal Languages Characters –Letters, numbers, punctuation –Building blocks –We call these terminal symbols or axioms Uses of characters –Syllables, words, phrases, grammar, sentences, etc. –Buildings –We call these non-terminal symbols or production rules or predicates

Where do we find them? Music Mathematics World Languages Art Computer Languages Almost Anywhere

Conventions The production rules form the syntax (grammar/spelling) of a language Valid combinations under the syntax are called well formed formulas (sentences) Example: –Jack in the box –We should say: Jack is in the box. JACK BOX IN

Forming a WFF Operators are needed for these languages: | = exclusive or ::= = is replaced by [ ] = optional (0 or 1) { } = optional (0 to many) “ ” = designators of terminal symbols Examples of situations for these? Assigning a sign (+ or -) Fullname ::= First Last Area code Letters in a name

Programming Korean Syllables Start with what we are trying to create

Korean Syllables start ::= syllable start “is replaced by” syllable

Programming Korean Syllables Start with what we are trying to create Establish the form of the creation

Korean Syllables start ::= syllable syllable ::= consonant vowel [consonant] consonant followed by a vowel another consonant if necessary

Programming Korean Syllables Start with what we are trying to create Establish the form of the creation Establish the terminal symbols

Korean Syllables can be substituted for consonant can be substituted for vowel start ::= syllable syllable ::= consonant vowel [consonant] consonant ::= “A” | “B” | “C” | “D” | “E” | “F” | “G” | “H” | “I” | “J” | “K” | “L” | “M” | “N” vowel ::= “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”

Let’s Try to Program Korean Syllables Start with what we are trying to create Establish the form of the creation Establish the terminal symbols Congratulations! We can now generate any Korean syllable mechanically Let’s test a few examples

start ::= syllable syllable ::= consonant vowel [consonant] consonant ::= “A” | “B” | “C” | “D” | “E” | “F” | “G” | “H” | “I” | “J” | “K” | “L” | “M” | “N” vowel ::= “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9” Korean Syllables A3A?100? AAA?K9?M4? O7K? 3D? C3P0?

Syllables aren’t enough though… We speak and write in words What do we need to do to make our program generate possible Korean words?

Korean Words start ::= word word ::= {syllable} arbitrary number of syllables What is wrong with this? A word can have 0 syllables??? How can we deal with this?

Korean Words Revised start ::= word word ::= syllable {syllable} one syllable 0 to n more possible Now add the lines from syllable

Korean Words start ::= word word ::= syllable {syllable} syllable ::= consonant vowel [consonant] consonant ::= “A” | “B” | “C” | “D” | “E” | “F” | “G” | “H” | “I” | “J” | “K” | “L” | “M” | “N” vowel ::= “0” | “1” | “2” | “3” | “4” | “5” | “6” | “7” | “8” | “9”

This goes to show that semantics are not accounted for in a formal language. The Problem with English… DOGSHYBEEAXE QEV No matter what, we can’t define syllables or words such that we get all “words” as results (provided we don’t code all words in)! start ::= syllable syllable ::= consonant vowel [consonant] consonant ::= “B” | “C” | “D” | “F” | “G” | “H” | “J” | “K” | “L” | “M” | “N” | “P” | “Q” | “R” | “S” | “T” | “V” | “W” | “X” | “Y” | “Z” | vowel ::= “A” | “E” | “I” | “O” | “U”

Positive Integers Let’s construct a language for positive integers on the board.

Why Formal Languages? Mathematical Induction –How many syllables exist in Korean? 14 Consonants * 10 Vowels * (14 Consonants + 1 Blank) = 2,100 –How many syllables in English? Can’t tell without counting one by one

Why Formal Languages? Parsing –Conversion to other useful information Φ = “ph” 1/2 = ½

Why Formal Languages? Grafiti Palm Pilots –Allow for symbolic recognition –Writing on a small object easier than typing on one (texting on a cell phone)

Why Formal Languages? Sequential Operations on a Computer –Selecting text –Drawing –Menu browsing

Why Formal Languages? Mechanical recognition of commands –Spell checkers –Proper commands in DOS prompt

To think about Won’t be collected, but for your own exercise: Create a formal language that will output addition and subtraction questions for positive integers, namely 4+9-7=? –Should be able to do arbitrary amount of calculations –No leading zeroes for a number Discuss on Friday