计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院 www.jiahenglu.net.

Slides:



Advertisements
Similar presentations
Class 3: Rules of Evaluation David Evans cs1120 Fall 2009.
Advertisements

REMOVING LEFT RECURSION AND INDIRECT LEFT RECURSION
15-Dec-14 BNF. Metalanguages A metalanguage is a language used to talk about a language (usually a different one) We can use English as its own metalanguage.
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Regular Expressions, Backus-Naur Form and Reverse Polish Notation.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
Honors Compilers An Introduction to Grammars Feb 12th 2002.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
A basis for computer theory and A means of specifying languages
Slide 1 Chapter 2-b Syntax, Semantics. Slide 2 Syntax, Semantics - Definition The syntax of a programming language is the form of its expressions, statements.
II–2 DC Circuits I Theory & Examples.
The elements of style Ch 1: Elementary rules of usage Ch 2: Elementary principles of composition Ch 3: A few matters of form Ch 4: Words & expressions.
Normal forms for Context-Free Grammars
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
30-Jun-15 BNF. Metalanguages A metalanguage is a language used to talk about a language (usually a different one) We can use English as its own metalanguage.
Describing Syntax and Semantics
Syntax.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 2: Formal Systems and Languages MU!
Linguistic Theory Lecture 3 Movement. A brief history of movement Movements as ‘special rules’ proposed to capture facts that phrase structure rules cannot.
Grammars and Parsing. Sentence  Noun Verb Noun Noun  boys Noun  girls Noun  dogs Verb  like Verb  see Grammars Grammar: set of rules for generating.
Context Free Grammars Reading: Chap 12-13, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
Language and Culture Prof. R. Hickey SoSe 2006 How language works
CAS LX 502 Semantics 3a. A formalism for meaning (cont ’ d) 3.2, 3.6.
Theory Of Automata By Dr. MM Alam
Chpater 3. Outline The definition of Syntax The Definition of Semantic Most Common Methods of Describing Syntax.
Relative clauses Chapter 11.
Chapter P Prerequisites: Fundamental Concepts of Algebra
Linguistics and Language
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
Representations Floyd Nelson A.D 2009 December 28.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
CSE 143 Lecture 11 Maps Grammars slides created by Alyssa Harding
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
Lecture 8: The Meaning of Life, Searching for Truth and The Stuff Primitives are Made Of (and a smattering of Quantum Physics) David Evans
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Introduction to Linguistics Ms. Suha Jawabreh Lecture # 2.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
Chapter 3 Describing Syntax and Semantics
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 2: Formal Systems and Languages MU!
Lecture 2: Formal Systems and Languages MU! CS150: Computer Science
1 LIN 1310B Introduction to Linguistics Prof: Nikolay Slavkov TA: Qinghua Tang CLASS 16, March 6, 2007.
Syntax and Grammars.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Chapter 3 Context-Free Grammars Dr. Frank Lee. 3.1 CFG Definition The next phase of compilation after lexical analysis is syntax analysis. This phase.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
9/15/2010CS485, Lecture 2, Fall Lecture 2: Introduction to Syntax (Revised based on the Tucker’s slides)
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Lecture 3: Rules of Evaluation CS150: Computer Science
7.2 Programming Languages - An Introduction to Informatics WMN Lab. Hye-Jin Lee.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 2: Formal Systems and Languages MU!
Writing 2 ENG 221 Norah AlFayez. Lecture Contents Revision of Writing 1. Introduction to basic grammar. Parts of speech. Parts of sentences. Subordinate.
Week 3. Clauses and Trees English Syntax. Trees and constituency A sentence has a hierarchical structure Constituents can have constituents of their own.
PROGRAMMING LANGUAGES
PROGRAMMING LANGUAGES
Lecture 2: Schreme David Evans
Lambda Calculus Revisited
CSE322 LEFT & RIGHT LINEAR REGULAR GRAMMAR
Lecture 2: Formal Systems and Languages MU! CS200: Computer Science
Logics for Data and Knowledge Representation
Plan for Lecture Review code and trace output
Grammar Infinitive.
Discrete Maths 13. Grammars Objectives
Lecture 23: Computability CS200: Computer Science
Presentation transcript:

计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院

Computer Language System (计算机语言系统) MU!

Outline Nuclear Weapons Questions from Lecture 1 Notes Formal Systems –MIU-system Languages –Scheme

Megabytes vs. Megatons Computing: 30,000,000 times increase in power since 1969 Nuclear weapons?

Tsar Bomba 50 Megaton explosion, island in Arctic Sea, 1961

If Nuclear Weapons followed Moore ’ s Law ( 摩尔定律 )... 30M * 50 Megatons = 1.5 Teratons 1 Megaton TNT = * Joules 1.5 Teratons TNT = 6.3 * Joules Energy from Sun to Earth = 4 x Joules/ Year One bomb today ~ all the energy to reach the Earth from the Sun since 400 AD

Actual Nuclear Weapons (核武器发展) Hiroshima (12kt), Nagasaki (20kt) First H-Bomb (10Mt) Tsar Bomba (largest ever) B83 (1.2Mt), largest in currently active arsenal

If it takes 60 seconds to compute a photomosaic for Problem Set 1 today on a typical PC, estimate how long it will take CS150 students in 2010 to compute the same photomosaic? How long will it take in 2013? > (/ (* ( ) 12) 18) 2 > (/ 60 (* 2 2)) 15 > (/ (* ( ) 12) 18) 4 > (/ 60 (* )) 15/4 > (exact->inexact (/ 60 (* ))) 3.75 Difference in years * 12 = number of months Number of months / 18 = number of doublings according to Moore’s Law 60 seconds today, 2 doublings by seconds in seconds today, 4 doublings by seconds in 2013 Reality check: Moore’s “law” is just an “observation”. We’ll see one reason later today why it won’t continue forever.

Are there any non-recursive natural languages? What would happen to a society that spoke one? Not for humans at least. They would run out of original things to say. Chimps and Dolphins are able to learn non- recursive “languages” (some linguists argue they are not really “languages”), but only humans can learn recursive languages.

Running out of Ideas “ Its all been said before. ” Eventually true for a non-recursive language. Never true for a recursive language. There is always something original left to say!

Production Systems (规约系统)

Production Systems Set of symbols –Primitives Set of rules for manipulating symbols –Hofstadter: Rules of Production, Rules of Inference –Also: Rules of Combination

The MIU System Symbols: M, I, U Rules of Production: –Rule I: If you have a string ending in I, you can add a U at the end. –Rule II: Suppose you have M x. Then you may add M xx to your collection. –Rule III: If III occurs in one of the strings in your collection you may make a new string with U in place of III. –Rule IV: If UU occurs inside one of your strings, you can drop it.

MIU System Example Start with MUI, produce MIU Rules of Production: Rule I: If you have a string ending in I, you can add a U at the end. Rule II: Suppose you have M x. Then you may add M xx to your collection. Rule III: If III occurs in one of the strings in your collection you may make a new string with U in place of III. Rule IV: If UU occurs inside one of your strings, you can drop it.

Languages

What is a language? Webster: A systematic means of communicating ideas or feelings by the use of conventionalized signs, sounds, gestures, or marks having understood meanings.

Linguist ’ s Definition A description of pairs (S, M), where S stands for sound, or any kind of surface forms, and M stands for meaning. A theory of language must specify the properties of S and M, and how they are related. (Charles Yang)

Languages and Formal Systems What is the difference between a formal system and a language? With a language, the surface forms have meaning. Caveat: computer scientists often use language to mean just a set of surface forms.

What are languages made of? Primitives (almost all languages have these) –The simplest surface forms with meaning Means of Combination (all languages have these) –Like Rules of Production for Formal Systems –Ways to make new surface forms from ones you already have Means of Abstraction (all powerful languages have these) –Ways to use simple surface forms to represent complicated ones

Does English have these? Primitives –Words (?) e.g., “ antifloccipoccinihilipilification ” – not a primitive –Morphemes – smallest units of meaning e.g., anti- ( “ opposite ” ) Means of combination –e.g., Sentence ::= Subject Verb Object –Precise rules, but not the ones you learned in grammar school Ending a sentence with a preposition is something up with which we will not put. Winston Churchill

Does English have these? Means of abstraction –Pronouns: she, he, it, they, which, etc. –Confusing since they don ’ t always mean the same thing, it depends on where they are used. The “ these ” in the slide title is an abstraction for the three elements of language introduced 2 slides ago. The “ they ” in the confusing sentence is an abstraction for pronouns.

How should we describe languages?

Backus Naur Form ( BN 范式) symbol ::= replacement We can replace symbol with replacement nonterminal – symbol that appears on left side of rule terminals – symbol that never appears on the left side of a rule A ::= B means anywhere you have an A, you can replace it with a B.

BNF Example Sentence ::= NP Verb NP ::= Noun Noun ::= Dave Noun ::= Scheme Verb ::= rocks Verb ::= sucks How many different things can we express with this language? What are the terminals? Dave, Scheme, rocks, sucks 4, but only 2 are true.

BNF Example Sentence ::= NP Verb NP ::= Noun NP ::= Noun and NP Noun ::= Dave Noun ::= Scheme Verb ::= rocks Verb ::= sucks How many different things can we express with this language? Infinitely many! Recursion is powerful.

Most Essential Scheme Expr ::= PrimitiveExpr PrimitiveExpr ::= Number PrimitiveExpr ::= + | * | <= |... Expr ::= Name Expr ::= ApplicationExpr ApplicationExpr ::= (Expr MoreExprs) MoreExprs ::= MoreExprs ::= Expr MoreExprs This is enough for everything you need to write for PS1

课后作业与上机 Problem Set 1: due Monday Lab Hours: posted on website –Now and Sunday 4-5:30, 8-9:30 –Take advantage of them! –If you can, follow us to lab now