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

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

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