Class 3:   Rules of   EvaluationDavid Evanscs1120 Fall 2011
MenuDescribing LanguagesQuestions from Notes  Computing photomosaics, non-recursive languages,    hardest language element...
Code written by     humans                                  Compiler translates                                  from code...
John BackusChemistry major at UVA  (entered 1943)Flunked out after second  semesterJoined IBM as programmer  in 1950Develo...
IBM 704 Fortran manual, 1956
Describing LanguagesFortran language was described using English   Imprecise   Verbose, lots to read   Ad hoc      DO 10 I...
Backus Naur Form  symbol ::= replacement    We can replace symbol with replacement        A ::= B means anywhere you have ...
Recap: Zero, One, Infinityword ::= anti-word               This rule can make 0 words.word ::= hippopotomonstrosesquipedal...
Simple BNF Grammars ::= 0ss ::= 0                            9
Rapid Exponential GrowthQuestion from Class 1: What other things have changed asmuch as (or more that!) computing power in...
http://www.wolframalpha.com/input/?i=india+china+brazil+usa+gdp+1990-2011                                                 ...
1991 value   2011 value       Growth     Doubling timeEnergy Consumption (world              102,300      142,300 (2008)  ...
Genome Sequencing1990: Human Genome Project starts, estimate$3B to sequence one genome ($0.50/base)2000: HumanGenome Proje...
$100,000,000                                                                                                Cost to sequen...
$100,000,000                                                                                                Cost to sequen...
Doubling time: 38000 in 2 years = 48 daysHuman Genome Sequencing Using Unchained Base Reads on Self-Assembling DNA Nanoarr...
Rules ofEvaluation
Scheme GrammarProgram           ::= ε | ProgramElement ProgramProgramElement ::= Expression | DefinitionDefinition        ...
Assigning MeaningsProgram ::= ε | ProgramElement ProgramProgramElement ::= Expression | DefinitionDefinition ::= (define N...
Expressions and Values  Expression    ::= PrimitiveExpression | NameExpression                   | ApplicationExpression  ...
Primitive ExpressionsPrimitiveExpression ::= Number | true | false | PrimitiveProcedure                                   ...
Evaluation Rule 1: PrimitivesIf the expression is a primitive, itevaluates to its pre-defined value. >2               Prim...
Name ExpressionsExpression ::= NameExpressionNameExpression ::= Name                                23
Evaluation Rule 2: NamesA name evaluates to the value associatedwith that name.    > (define two 2)    > two    2         ...
Application ExpressionsExpression ::= Application ExpressionApplicationExpression           ::= (Expression MoreExpression...
Evaluation Rule 3: Application3. To evaluation an application expression:  a) Evaluate all the subexpressions (in any orde...
Rules for Application1. Primitives. If the procedure to apply is a   primitive procedure, just do it.2. Constructed Proced...
Eval and Apply aredefined recursively.                           EvalWithout Eval, therewould be no            ApplyApply,...
Language Elements   When learning a foreignlanguage, which elements are      hardest to learn?                           29
ChargeWe will cover the rest of the rules  Wednesday, then you will know enough to  describe every possible computation!Re...
Upcoming SlideShare
Loading in …5
×

Lecture 3: Rules of Evaluation

623 views

Published on

Backus-Naur Form
Exponential Growth (Genome Sequencing)
Scheme Grammar and Evaluation Rules

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
623
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Lecture 3: Rules of Evaluation

  1. 1. Class 3: Rules of EvaluationDavid Evanscs1120 Fall 2011
  2. 2. MenuDescribing LanguagesQuestions from Notes Computing photomosaics, non-recursive languages, hardest language elements to learnScheme: Grammar and Rules of Evaluation 2
  3. 3. Code written by humans Compiler translates from code in a high-Compiler/Interpreter level language to machine code.Code machine can run Scheme uses an interpreter. An interpreter is like a compiler, except it runs quickly and quietly on small bits of code at a time.
  4. 4. John BackusChemistry major at UVA (entered 1943)Flunked out after second semesterJoined IBM as programmer in 1950Developed Fortran, first commercially successful programming language and compiler John Backus, 1924 – 2007
  5. 5. IBM 704 Fortran manual, 1956
  6. 6. Describing LanguagesFortran language was described using English Imprecise Verbose, lots to read Ad hoc DO 10 I=1.10 Assigns 1.10 to the variable DO10I DO 10 I=1,10 Loops for I = 1 to 10 (Often incorrectly blamed for loss of Mariner-I)Backus wanted a precise way of describing a language
  7. 7. Backus Naur Form symbol ::= replacement We can replace symbol with replacement A ::= B means anywhere you have an A, you can replace it with a B. nonterminal – symbol that appears on left side of rule terminals – symbol that never appears on the left side of a ruleNote: this is named for John Backus for being the first person to advocate using it fordescribing programming languages, but linguists were using similar techniques much earlier. 7
  8. 8. Recap: Zero, One, Infinityword ::= anti-word This rule can make 0 words.word ::= hippopotomonstrosesquipedaliophobia This rule can make 1 word.word ::= anti-wordword ::= hippopotomonstrosesquipedaliophobia These two rules can make infinitely many words, enough to express all ideas in the universe! 8
  9. 9. Simple BNF Grammars ::= 0ss ::= 0 9
  10. 10. Rapid Exponential GrowthQuestion from Class 1: What other things have changed asmuch as (or more that!) computing power in your lifetime? Communication (global IP traffic, PB/month) (Alex) Energy Consumption (world energy use, TW) (Filip) Human (number of cells) (Ouamdwipwaw) Knowledge (Tyson’s measure) (Deirdre Regan) National Debt (Michael) TV (number of pixels) (gtc5sn) Wealth (world GDP) (Chris Smith) 10
  11. 11. http://www.wolframalpha.com/input/?i=india+china+brazil+usa+gdp+1990-2011 11
  12. 12. 1991 value 2011 value Growth Doubling timeEnergy Consumption (world 102,300 142,300 (2008) 1.39 38 yearsenergy use, TW) (Filip) Communication (global IP traffic, PB/month) (Alex)Wealth (world GDP) (Chris $21T $60T (2008) 2.67 12 yearsSmith)Energy Consumption (world energy use, TW) (Filip) Human (number of cells) (Ouamdwipwaw)Knowledge (Tyson’s measure) 15 years(Deirdre Regan) (Tyson’s measure) (Deirdre Regan) KnowledgeNational Debt Debt (Michael) National (Michael) $3.2T (56% $14.7T (93% of 4.6 9 years of GDP) GDP) TV (number of pixels) (gtc5sn)TV (number of pixels) (gtc5sn) 486x243, 3 1920×1080, 500 2926 1.73 years Wealth (world GDP) (Chris Smith) channels = channels = 354292 1036800000Computing Power/Dollar 18 months(Moore’s Law)Communication (global IP 0.001 20,197 20M 9.9 monthstraffic, PB/month) (Alex)Human (number of cells) 1 50 Trillion 50 5.3 months(Ouamdwipwaw) Trillion 12
  13. 13. Genome Sequencing1990: Human Genome Project starts, estimate$3B to sequence one genome ($0.50/base)2000: HumanGenome Projectdeclaredcomplete, cost~$300M Whitehead Institute, MIT 13
  14. 14. $100,000,000 Cost to sequence human genome Moore’s Law prediction (halve every 18 months) $10,000,000 $1,000,000 $100,000 $10,000 Jun 2010 Jun 2005 Sep 2001 Feb 2002 Sep 2006 Feb 2007 May 2003 Apr 2006 Aug 2004 May 2008 Aug 2009 Mar 2004 Jan 2005 Nov 2005 Mar 2009 Jan 2010 Dec 2002 Dec 2007 Jul 2002 Jul 2007 Oct 2003 Oct 2008 14 Data from National Human Genome Research Institute: http://www.genome.gov/sequencingcosts
  15. 15. $100,000,000 Cost to sequence human genome Moore’s Law prediction (halve every 18 months) $10,000,000 $1,000,000 $100,000 $10,000 Ion torrent Personal Genome Machine Sep 2001 Feb 2002 Sep 2006 Feb 2007 May 2003 Aug 2004 Nov 2005 Apr 2006 May 2008 Aug 2009 Mar 2004 Jan 2005 Mar 2009 Dec 2002 Jun 2005 Jan 2010 Jun 2010 Dec 2007 Jul 2002 Oct 2003 Jul 2007 Oct 2008 15 Data from National Human Genome Research Institute: http://www.genome.gov/sequencingcosts
  16. 16. Doubling time: 38000 in 2 years = 48 daysHuman Genome Sequencing Using Unchained Base Reads on Self-Assembling DNA Nanoarrays. RadojeDrmanac, Andrew B. Sparks, Matthew J. Callow, Aaron L. Halpern, Norman L. Burns, Bahram G. Kermani, PaoloCarnevali, Igor Nazarenko, Geoffrey B. Nilsen, George Yeung, Fredrik Dahl, Andres Fernandez, Bryan Staker,Krishna P. Pant, Jonathan Baccash, Adam P. Borcherding, Anushka Brownley, Ryan Cedeno, Linsu Chen, DanChernikoff, Alex Cheung, Razvan Chirita, Benjamin Curson, Jessica C. Ebert, Coleen R. Hacker, Robert Hartlage,Brian Hauser, Steve Huang,Church (Personal Genome Project)Calvin Kong, Tom Landers, Catherine Le, George Yuan Jiang, Vitali Karpinchyk, Mark Koenig,Jia Liu, Celeste E. McBride, Matt Morenzoni, Robert E. Morey, Karl Mutch, Helena Perazich, Kimberly Perry, BrockA. Peters, Joe Peterson, Charit L. Pethiyagoda, Kaliprasad Pothuraju, Claudia Richter, Abraham M. Rosenbaum,Shaunak Roy, Jay Shafto, Uladzislau Sharanhovich, Karen W. Shannon, Conrad G. Sheppy, Michel Sun, Joseph V.Thakuria, Anne Tran, Dylan Vu, Alexander Wait Zaranek, Xiaodi Wu, Snezana Drmanac, Arnold R. Oliphant,William C. Banyai, Bruce Martin, Dennis G. Ballinger, George M. Church, Clifford A. Reid. Science, January 2010.
  17. 17. Rules ofEvaluation
  18. 18. Scheme GrammarProgram ::= ε | ProgramElement ProgramProgramElement ::= Expression | DefinitionDefinition ::= (define Name Expression)Expression ::= PrimitiveExpression | NameExpression | ApplicationExpression | ProcedureExpression | IfExpressionPrimitiveExpression ::= Number | true | false | PrimitiveProcedureNameExpression ::= NameApplicationExpression ::= (Expression MoreExpressions)MoreExpressions ::= ε | Expression MoreExpressionsProcedureExpression ::= (lambda (Parameters) Expression)Parameters ::= ε | Name ParametersIfExpression ::= (if ExpressionPred ExpressionConsequent ExpressionAlt) 18
  19. 19. Assigning MeaningsProgram ::= ε | ProgramElement ProgramProgramElement ::= Expression | DefinitionDefinition ::= (define Name Expression)Expression ::= PrimitiveExpression | NameExpression | ApplicationExpression | ProcedureExpression | IfExpressionPrimitiveExpression ::= Number | true | false| PrimitiveProcedureNameExpression ::= NameApplicationExpression ::= (Expression MoreExpressions)MoreExpressions ::= ε | Expression MoreExpressionsProcedureExpression ::= (lambda (Parameters) Expression)Parameters ::= ε | Name ParametersIfExpression ::= (if ExpressionPred ExpressionConsequent ExpressionAlt) This grammar generates (nearly) all surface forms in the Scheme language. What do we need to do to know the meaning of every Scheme program? 19
  20. 20. Expressions and Values Expression ::= PrimitiveExpression | NameExpression | ApplicationExpression | ProcedureExpression | IfExpressionWhen an expression with a value is evaluated, avalue is producedOur goal is to define a meaning function, Eval, thatdefines the value of every Scheme expression: Eval(Expression) ValueToday we do this informally with rules in English.(In PS7 we will do it with a program.) 20
  21. 21. Primitive ExpressionsPrimitiveExpression ::= Number | true | false | PrimitiveProcedure 21
  22. 22. Evaluation Rule 1: PrimitivesIf the expression is a primitive, itevaluates to its pre-defined value. >2 Primitives are the 2 smallest units of > true meaning: they can’t #t be broken down >+ further, you need to #<primitive:+> know what they mean. 22
  23. 23. Name ExpressionsExpression ::= NameExpressionNameExpression ::= Name 23
  24. 24. Evaluation Rule 2: NamesA name evaluates to the value associatedwith that name. > (define two 2) > two 2 Caveat: this simple rule only works if the value associated with a name never changes (until PS5). 24
  25. 25. Application ExpressionsExpression ::= Application ExpressionApplicationExpression ::= (Expression MoreExpressions)MoreExpressions ::= εMoreExpressions ::= Expression MoreExpressions 25
  26. 26. Evaluation Rule 3: Application3. To evaluation an application expression: a) Evaluate all the subexpressions (in any order) b) Apply the value of the first subexpression to the values of all the other subexpressions. (Expression0 Expression1 Expression2 … )
  27. 27. Rules for Application1. Primitives. If the procedure to apply is a primitive procedure, just do it.2. Constructed Procedures. If the procedure is a constructed procedure, evaluate the body of the procedure with each parameter name bound to the corresponding input expression value. 27
  28. 28. Eval and Apply aredefined recursively. EvalWithout Eval, therewould be no ApplyApply, withoutApply there wouldbe no Eval! 28
  29. 29. Language Elements When learning a foreignlanguage, which elements are hardest to learn? 29
  30. 30. ChargeWe will cover the rest of the rules Wednesday, then you will know enough to describe every possible computation!Reading: should be finished with Chapter 3 now, Chapter 4, Gleick Ch 1-3 by FridayPS1 is Due Monday: Find your assigned partner Get started earlier and take advantage of scheduled help hours 30

×