SlideShare a Scribd company logo
1 of 30
Class 3:
   Rules of
   Evaluation


David Evans
cs1120 Fall 2011
Menu
Describing Languages
Questions from Notes
  Computing photomosaics, non-recursive languages,
    hardest language elements to learn
Scheme: Grammar and Rules of Evaluation




                                                     2
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.
John Backus
Chemistry major at UVA
  (entered 1943)
Flunked out after second
  semester
Joined IBM as programmer
  in 1950
Developed Fortran, first
  commercially successful
  programming language
  and compiler              John Backus, 1924 – 2007
IBM 704 Fortran manual, 1956
Describing Languages
Fortran 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
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 rule
Note: this is named for John Backus for being the first person to advocate using it for
describing programming languages, but linguists were using similar techniques much earlier.
                                                                                              7
Recap: Zero, One, Infinity

word ::= anti-word               This rule can make 0 words.



word ::= hippopotomonstrosesquipedaliophobia
                                   This rule can make 1 word.

word ::= anti-word
word ::= hippopotomonstrosesquipedaliophobia
          These two rules can make infinitely many words,
          enough to express all ideas in the universe!
                                                                8
Simple BNF Grammar
s ::= 0s
s ::= 0




                            9
Rapid Exponential Growth
Question from Class 1: What other things have changed as
much 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
http://www.wolframalpha.com/input/?i=india+china+brazil+usa+gdp+1990-2011




                                                                            11
1991 value   2011 value       Growth     Doubling time
Energy Consumption (world              102,300      142,300 (2008)   1.39       38 years
energy use, TW) (Filip)
      Communication (global IP traffic, PB/month) (Alex)
Wealth (world GDP) (Chris        $21T           $60T (2008)          2.67       12 years
Smith)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)
      Knowledge
National 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       1036800000
Computing Power/Dollar                                                          18 months
(Moore’s Law)
Communication (global IP               0.001        20,197           20M        9.9 months
traffic, PB/month) (Alex)
Human (number of cells)                1            50 Trillion      50         5.3 months
(Ouamdwipwaw)                                                        Trillion

                                                                                                12
Genome Sequencing
1990: Human Genome Project starts, estimate
$3B to sequence one genome ($0.50/base)

2000: Human
Genome Project
declared
complete, cost
~$300M


                         Whitehead Institute, MIT
                                                    13
$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
$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
Doubling time: 38000 in 2 years = 48 days




Human Genome Sequencing Using Unchained Base Reads on Self-Assembling DNA Nanoarrays. Radoje
Drmanac, Andrew B. Sparks, Matthew J. Callow, Aaron L. Halpern, Norman L. Burns, Bahram G. Kermani, Paolo
Carnevali, 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, Dan
Chernikoff, 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, Brock
A. 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.
Rules of
Evaluation
Scheme Grammar
Program           ::= ε | ProgramElement Program
ProgramElement ::= Expression | Definition
Definition        ::= (define Name Expression)
Expression        ::= PrimitiveExpression | NameExpression
                      | ApplicationExpression
                      | ProcedureExpression | IfExpression
PrimitiveExpression ::= Number | true | false
                           | PrimitiveProcedure
NameExpression ::= Name
ApplicationExpression ::= (Expression MoreExpressions)
MoreExpressions ::= ε | Expression MoreExpressions
ProcedureExpression ::= (lambda (Parameters) Expression)
Parameters        ::= ε | Name Parameters
IfExpression ::= (if ExpressionPred ExpressionConsequent ExpressionAlt)
                                                                          18
Assigning Meanings
Program ::= ε | ProgramElement Program
ProgramElement ::= Expression | Definition
Definition ::= (define Name Expression)
Expression ::= PrimitiveExpression | NameExpression
               | ApplicationExpression | ProcedureExpression | IfExpression
PrimitiveExpression ::= Number | true | false| PrimitiveProcedure
NameExpression ::= Name
ApplicationExpression ::= (Expression MoreExpressions)
MoreExpressions ::= ε | Expression MoreExpressions
ProcedureExpression ::= (lambda (Parameters) Expression)
Parameters              ::= ε | Name Parameters
IfExpression ::= (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
Expressions and Values
  Expression    ::= PrimitiveExpression | NameExpression
                   | ApplicationExpression
                   | ProcedureExpression | IfExpression

When an expression with a value is evaluated, a
value is produced
Our goal is to define a meaning function, Eval, that
defines the value of every Scheme expression:
       Eval(Expression) Value
Today we do this informally with rules in English.
(In PS7 we will do it with a program.)

                                                           20
Primitive Expressions
PrimitiveExpression ::= Number | true | false | PrimitiveProcedure




                                                                     21
Evaluation Rule 1: Primitives
If the expression is a primitive, it
evaluates 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
Name Expressions
Expression ::= NameExpression
NameExpression ::= Name




                                23
Evaluation Rule 2: Names
A name evaluates to the value associated
with 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
Application Expressions
Expression ::= Application Expression
ApplicationExpression
           ::= (Expression MoreExpressions)
MoreExpressions ::= ε
MoreExpressions ::= Expression MoreExpressions




                                                 25
Evaluation Rule 3: Application
3. 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 … )
Rules for Application
1. 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
Eval and Apply are
defined recursively.
                           Eval

Without Eval, there
would be no            Apply
Apply, without
Apply there would
be no Eval!

                                  28
Language Elements

   When learning a foreign
language, which elements are
      hardest to learn?



                           29
Charge
We 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 Friday
PS1 is Due Monday: Find your assigned partner
  Get started earlier and take advantage of
      scheduled help hours

                                                  30

More Related Content

More from David Evans

How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in ParadiseDavid Evans
 
Mining Economics
Mining EconomicsMining Economics
Mining EconomicsDavid Evans
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More ParanoidDavid Evans
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key SignaturesDavid Evans
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyDavid Evans
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?David Evans
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the MassesDavid Evans
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of ReserveDavid Evans
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!David Evans
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinDavid Evans
 
Alternate Cryptocurrencies
Alternate CryptocurrenciesAlternate Cryptocurrencies
Alternate CryptocurrenciesDavid Evans
 
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
Quiz 2: Bitcoin Protocol, Mining, SupsersizingQuiz 2: Bitcoin Protocol, Mining, Supsersizing
Quiz 2: Bitcoin Protocol, Mining, SupsersizingDavid Evans
 
Mostly About Superfish
Mostly About SuperfishMostly About Superfish
Mostly About SuperfishDavid Evans
 
Mining Pools and Profits
Mining Pools and ProfitsMining Pools and Profits
Mining Pools and ProfitsDavid Evans
 

More from David Evans (20)

How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in Paradise
 
Bitcoin Script
Bitcoin ScriptBitcoin Script
Bitcoin Script
 
Mining Economics
Mining EconomicsMining Economics
Mining Economics
 
Mining
MiningMining
Mining
 
The Blockchain
The BlockchainThe Blockchain
The Blockchain
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More Paranoid
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key Signatures
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the Masses
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of Reserve
 
Silk Road
Silk RoadSilk Road
Silk Road
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
 
Alternate Cryptocurrencies
Alternate CryptocurrenciesAlternate Cryptocurrencies
Alternate Cryptocurrencies
 
Script
ScriptScript
Script
 
Selfish Mining
Selfish MiningSelfish Mining
Selfish Mining
 
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
Quiz 2: Bitcoin Protocol, Mining, SupsersizingQuiz 2: Bitcoin Protocol, Mining, Supsersizing
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
 
Mostly About Superfish
Mostly About SuperfishMostly About Superfish
Mostly About Superfish
 
Mining Pools and Profits
Mining Pools and ProfitsMining Pools and Profits
Mining Pools and Profits
 

Recently uploaded

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Lecture 3: Rules of Evaluation

  • 1. Class 3: Rules of Evaluation David Evans cs1120 Fall 2011
  • 2. Menu Describing Languages Questions from Notes Computing photomosaics, non-recursive languages, hardest language elements to learn Scheme: Grammar and Rules of Evaluation 2
  • 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. John Backus Chemistry major at UVA (entered 1943) Flunked out after second semester Joined IBM as programmer in 1950 Developed Fortran, first commercially successful programming language and compiler John Backus, 1924 – 2007
  • 5. IBM 704 Fortran manual, 1956
  • 6. Describing Languages Fortran 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. 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 rule Note: this is named for John Backus for being the first person to advocate using it for describing programming languages, but linguists were using similar techniques much earlier. 7
  • 8. Recap: Zero, One, Infinity word ::= anti-word This rule can make 0 words. word ::= hippopotomonstrosesquipedaliophobia This rule can make 1 word. word ::= anti-word word ::= hippopotomonstrosesquipedaliophobia These two rules can make infinitely many words, enough to express all ideas in the universe! 8
  • 9. Simple BNF Grammar s ::= 0s s ::= 0 9
  • 10. Rapid Exponential Growth Question from Class 1: What other things have changed as much 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
  • 12. 1991 value 2011 value Growth Doubling time Energy Consumption (world 102,300 142,300 (2008) 1.39 38 years energy use, TW) (Filip) Communication (global IP traffic, PB/month) (Alex) Wealth (world GDP) (Chris $21T $60T (2008) 2.67 12 years Smith)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) Knowledge National 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 1036800000 Computing Power/Dollar 18 months (Moore’s Law) Communication (global IP 0.001 20,197 20M 9.9 months traffic, PB/month) (Alex) Human (number of cells) 1 50 Trillion 50 5.3 months (Ouamdwipwaw) Trillion 12
  • 13. Genome Sequencing 1990: Human Genome Project starts, estimate $3B to sequence one genome ($0.50/base) 2000: Human Genome Project declared complete, cost ~$300M Whitehead Institute, MIT 13
  • 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. $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. Doubling time: 38000 in 2 years = 48 days Human Genome Sequencing Using Unchained Base Reads on Self-Assembling DNA Nanoarrays. Radoje Drmanac, Andrew B. Sparks, Matthew J. Callow, Aaron L. Halpern, Norman L. Burns, Bahram G. Kermani, Paolo Carnevali, 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, Dan Chernikoff, 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, Brock A. 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.
  • 18. Scheme Grammar Program ::= ε | ProgramElement Program ProgramElement ::= Expression | Definition Definition ::= (define Name Expression) Expression ::= PrimitiveExpression | NameExpression | ApplicationExpression | ProcedureExpression | IfExpression PrimitiveExpression ::= Number | true | false | PrimitiveProcedure NameExpression ::= Name ApplicationExpression ::= (Expression MoreExpressions) MoreExpressions ::= ε | Expression MoreExpressions ProcedureExpression ::= (lambda (Parameters) Expression) Parameters ::= ε | Name Parameters IfExpression ::= (if ExpressionPred ExpressionConsequent ExpressionAlt) 18
  • 19. Assigning Meanings Program ::= ε | ProgramElement Program ProgramElement ::= Expression | Definition Definition ::= (define Name Expression) Expression ::= PrimitiveExpression | NameExpression | ApplicationExpression | ProcedureExpression | IfExpression PrimitiveExpression ::= Number | true | false| PrimitiveProcedure NameExpression ::= Name ApplicationExpression ::= (Expression MoreExpressions) MoreExpressions ::= ε | Expression MoreExpressions ProcedureExpression ::= (lambda (Parameters) Expression) Parameters ::= ε | Name Parameters IfExpression ::= (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. Expressions and Values Expression ::= PrimitiveExpression | NameExpression | ApplicationExpression | ProcedureExpression | IfExpression When an expression with a value is evaluated, a value is produced Our goal is to define a meaning function, Eval, that defines the value of every Scheme expression: Eval(Expression) Value Today we do this informally with rules in English. (In PS7 we will do it with a program.) 20
  • 21. Primitive Expressions PrimitiveExpression ::= Number | true | false | PrimitiveProcedure 21
  • 22. Evaluation Rule 1: Primitives If the expression is a primitive, it evaluates 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. Name Expressions Expression ::= NameExpression NameExpression ::= Name 23
  • 24. Evaluation Rule 2: Names A name evaluates to the value associated with 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. Application Expressions Expression ::= Application Expression ApplicationExpression ::= (Expression MoreExpressions) MoreExpressions ::= ε MoreExpressions ::= Expression MoreExpressions 25
  • 26. Evaluation Rule 3: Application 3. 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. Rules for Application 1. 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. Eval and Apply are defined recursively. Eval Without Eval, there would be no Apply Apply, without Apply there would be no Eval! 28
  • 29. Language Elements When learning a foreign language, which elements are hardest to learn? 29
  • 30. Charge We 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 Friday PS1 is Due Monday: Find your assigned partner Get started earlier and take advantage of scheduled help hours 30