SlideShare a Scribd company logo
Class 4:
Making
Procedures


cs1120 Fall 2011
David Evans
30 August 2011
Announcements
PS1 is due Monday (electronic submission and
  paper submission): donā€™t wait to get started!
Quiz 1 is Wednesday (in class)
  Chapters 1-4 of Course Book
  Chapters 1-3 of The Information
  Classes 1-5 (including questions from class
  notes)
   I havenā€™t forgotten about answering your questions from PS0.
                 I will post my answers by tomorrow.
Recap: 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. If we have a meaning rule for each grammar rule, we can
determine the meaning of every Scheme program.

                                                                              3
Evaluation Rules: Last Class
PrimitiveExpression ::= Number | true | false| PrimitiveProcedure
    Rule 1: If the expression is a primitive, it evaluates to its pre-
    defined value.
NameExpression ::= Name
     Rule 2: A name evaluates to the value associated with that name.
ApplicationExpression ::= (Expression MoreExpressions)
MoreExpressions ::= Īµ | Expression MoreExpressions
     Rule 3: To evaluate 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.

                                                                                       4
Last class: 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.
          This only makes sense if we know what a constructed procedure is!

                                                                              5
Constructing Procedures
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)




                                                                             6
Constructing Procedures
 lambda means ā€œmake a procedureā€

Expression ::= ProcedureExpression
ProcedureExpression ::=
       (lambda (Parameters) Expression)
Parameters ::= Īµ
Parameters ::= Name Parameters

                                          7
Evaluation Rule 4: Lambda
A lambda expression evaluates to a
procedure that takes the given
parameters and has the expression as
its body.

ProcedureExpression ::= (lambda (Parameters) Expression)
Parameters     ::= Īµ | Name Parameters




                                                           8
Lambda Expressions
(lambda () true)

(lambda (x) (* x x))

(lambda (a)
  (lambda (b)
    (+ a b)))
Applying Compound Procedures
              Rule 3: To evaluate an application expression:
((lambda ()    (a) Evaluate all the subexpressions (in any
               order)
    true)      (b) Apply the value of the first subexpression
               to the values of all the other subexpressions.
 1120)
              Apply Rule for constructed procedures:
              Evaluate the body of the procedure with each
              parameter name bound to the corresponding
              input expression value.

              Evaluation Rule 4. A lambda expression
              evaluates to a procedure that takes the given
              parameters and has the expression as its body.
Applying Compound Procedures
                  Rule 3: To evaluate an application expression:
((lambda (x)       (a) Evaluate all the subexpressions (in any
                   order)
    (+ x 1000))    (b) Apply the value of the first subexpression
                   to the values of all the other subexpressions.
 120)
                  Apply Rule for constructed procedures:
                  Evaluate the body of the procedure with each
                  parameter name bound to the corresponding
                  input expression value.

                  Evaluation Rule 4. A lambda expression
                  evaluates to a procedure that takes the given
                  parameters and has the expression as its body.
Applying Compound Procedures
                  Rule 3: To evaluate an application expression:
((lambda (x)       (a) Evaluate all the subexpressions (in any
                   order)
    (+ x 1000))    (b) Apply the value of the first subexpression
                   to the values of all the other subexpressions.
 x)
                  Apply Rule for constructed procedures:
                  Evaluate the body of the procedure with each
                  parameter name bound to the corresponding
                  input expression value.

                  Evaluation Rule 4. A lambda expression
                  evaluates to a procedure that takes the given
                  parameters and has the expression as its body.
Applying Compound Procedures
                 Rule 3: To evaluate an application expression:
((lambda (a)      (a) Evaluate all the subexpressions (in any
                  order)
   (lambda (b)    (b) Apply the value of the first subexpression
                  to the values of all the other subexpressions.
     (+ a b)))
                 Apply Rule for constructed procedures:
 5)              Evaluate the body of the procedure with each
                 parameter name bound to the corresponding
                 input expression value.

                 Evaluation Rule 4. A lambda expression
                 evaluates to a procedure that takes the given
                 parameters and has the expression as its body.
Applying Compound Procedures
                 Rule 3: To evaluate an application expression:
(((lambda (a)     (a) Evaluate all the subexpressions (in any
                  order)
   (lambda (b)    (b) Apply the value of the first subexpression
                  to the values of all the other subexpressions.
     (+ a b)))
                 Apply Rule for constructed procedures:
  5)             Evaluate the body of the procedure with each
                 parameter name bound to the corresponding
 6)              input expression value.

                 Evaluation Rule 4. A lambda expression
                 evaluates to a procedure that takes the given
                 parameters and has the expression as its body.
Do we have everything we
   need to describe all
     computations?
Language Elements
        Question from Class 2:
When learning a foreign language, which
     elements are hardest to learn?

Primitives
Means of Combination
Means of Abstraction


                                          16
Primitives: lots of them, and hard to learn real meaning (but its
   just memorization)
Means of Combination
  Complex, but, all natural languages have similar ones [Chomsky]
  Sentence ::= Subject Object Verb (45%)

  Sentence ::= Subject Verb Object (42%)        Welsh: ā€œLladdodd y ddraig y dyn.ā€
  Sentence ::= Verb Subject Object (9%)

  Sentence ::= Object Subject Verb (<1%)

  Scheme:
Means of Abstraction: few of these, but tricky to learn
 differences across languages
  Tok Pisin (Papua New Guinea): mi (I), mitupela (he/she and I), mitripela
        (both of them and I), mipela (all of them and I), yumitupela (you and
        I), yumitripela (both of you and I), yumipela (all of you and I)
  Scheme:
                                                                                    17
Charge
PS1: Due Monday
  Wednesdays, 5-6:30pm (Jiamin, Rice 1xx)
  Thursdays, 9:45-11am (Dave, Rice 507)
  Thursdays, 10-11:30am (Peter, Rice 1xx)
  Thursdays, 1-2:30pm (Joseph, Rice 1xx)
  Thursdays, 4:30-6pm (Jonathan, Rice 1xx)
  Thursdays, 6-7:30pm (Jiamin, Rice 1xx)
By Friday
  Finish reading Chapters 1-4, Gleick Chapters 1-3
Quiz 1: Wednesday

More Related Content

What's hot

String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)Ravi Kant Sahu
Ā 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 Bdplunkett
Ā 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Shakti Singh Rathore
Ā 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6dplunkett
Ā 
Operators in java
Operators in javaOperators in java
Operators in javaRavi_Kant_Sahu
Ā 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
Abdul Hannan
Ā 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2dplunkett
Ā 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
Ā 
Chapter 13 - Recursion
Chapter 13 - RecursionChapter 13 - Recursion
Chapter 13 - RecursionAdan Hubahib
Ā 
Ap Power Point Chpt4
Ap Power Point Chpt4Ap Power Point Chpt4
Ap Power Point Chpt4dplunkett
Ā 
Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Adi Bolboaca
Ā 
M C6java3
M C6java3M C6java3
M C6java3mbruggen
Ā 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
Srajan Mor
Ā 
Lab5
Lab5Lab5

What's hot (20)

Ch09
Ch09Ch09
Ch09
Ā 
Ch08
Ch08Ch08
Ch08
Ā 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
Ā 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 B
Ā 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Ā 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
Ā 
Ch03
Ch03Ch03
Ch03
Ā 
Operators in java
Operators in javaOperators in java
Operators in java
Ā 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
Ā 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
Ā 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
Ā 
Ch05
Ch05Ch05
Ch05
Ā 
Chapter 13 - Recursion
Chapter 13 - RecursionChapter 13 - Recursion
Chapter 13 - Recursion
Ā 
Ch02
Ch02Ch02
Ch02
Ā 
Ap Power Point Chpt4
Ap Power Point Chpt4Ap Power Point Chpt4
Ap Power Point Chpt4
Ā 
Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16
Ā 
Ch06
Ch06Ch06
Ch06
Ā 
M C6java3
M C6java3M C6java3
M C6java3
Ā 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
Ā 
Lab5
Lab5Lab5
Lab5
Ā 

Similar to Class 4: Making Procedures

evaluation rules
evaluation rulesevaluation rules
evaluation rules
Rajendran
Ā 
procedures
proceduresprocedures
procedures
Rajendran
Ā 
Class 32: Interpreters
Class 32: InterpretersClass 32: Interpreters
Class 32: Interpreters
David Evans
Ā 
expressions
expressionsexpressions
expressions
Rajendran
Ā 
Rspec 101
Rspec 101Rspec 101
Rspec 101
Jason Noble
Ā 
Ecet 370 week 1 lab
Ecet 370 week 1 labEcet 370 week 1 lab
Ecet 370 week 1 lab
agevpaswind1984
Ā 
7 Methods and Functional Programming
7  Methods and Functional Programming7  Methods and Functional Programming
7 Methods and Functional Programming
Deepak Hagadur Bheemaraju
Ā 
Ap Power Point Chpt5
Ap Power Point Chpt5Ap Power Point Chpt5
Ap Power Point Chpt5dplunkett
Ā 
Computer programming 2 Lesson 10
Computer programming 2  Lesson 10Computer programming 2  Lesson 10
Computer programming 2 Lesson 10
MLG College of Learning, Inc
Ā 
Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismEelco Visser
Ā 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Kurmendra Singh
Ā 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
amanabr
Ā 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docx
mccormicknadine86
Ā 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docx
bissacr
Ā 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
Amr E. Mohamed
Ā 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
GovindUpadhyay25
Ā 
Thesis Talk
Thesis TalkThesis Talk
Thesis TalkBhavyaRawal
Ā 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
georgejustymirobi1
Ā 
C# p8
C# p8C# p8
C# p8
Renas Rekany
Ā 

Similar to Class 4: Making Procedures (20)

evaluation rules
evaluation rulesevaluation rules
evaluation rules
Ā 
procedures
proceduresprocedures
procedures
Ā 
Class 32: Interpreters
Class 32: InterpretersClass 32: Interpreters
Class 32: Interpreters
Ā 
expressions
expressionsexpressions
expressions
Ā 
11 ruby methods
11 ruby methods11 ruby methods
11 ruby methods
Ā 
Rspec 101
Rspec 101Rspec 101
Rspec 101
Ā 
Ecet 370 week 1 lab
Ecet 370 week 1 labEcet 370 week 1 lab
Ecet 370 week 1 lab
Ā 
7 Methods and Functional Programming
7  Methods and Functional Programming7  Methods and Functional Programming
7 Methods and Functional Programming
Ā 
Ap Power Point Chpt5
Ap Power Point Chpt5Ap Power Point Chpt5
Ap Power Point Chpt5
Ā 
Computer programming 2 Lesson 10
Computer programming 2  Lesson 10Computer programming 2  Lesson 10
Computer programming 2 Lesson 10
Ā 
Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: Polymorphism
Ā 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
Ā 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
Ā 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docx
Ā 
Chi-squared Goodness of Fit Test Project Overview and.docx
Chi-squared Goodness of Fit Test Project  Overview and.docxChi-squared Goodness of Fit Test Project  Overview and.docx
Chi-squared Goodness of Fit Test Project Overview and.docx
Ā 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
Ā 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
Ā 
Thesis Talk
Thesis TalkThesis Talk
Thesis Talk
Ā 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
Ā 
C# p8
C# p8C# p8
C# p8
Ā 

More from David Evans

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
David Evans
Ā 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
David Evans
Ā 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
David Evans
Ā 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in Bitcoin
David Evans
Ā 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm Confirmations
David Evans
Ā 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting Transactions
David Evans
Ā 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in Paradise
David Evans
Ā 
Bitcoin Script
Bitcoin ScriptBitcoin Script
Bitcoin Script
David Evans
Ā 
Mining Economics
Mining EconomicsMining Economics
Mining Economics
David Evans
Ā 
Mining
MiningMining
Mining
David Evans
Ā 
The Blockchain
The BlockchainThe Blockchain
The Blockchain
David Evans
Ā 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More Paranoid
David Evans
Ā 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key Signatures
David Evans
Ā 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
David 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 Masses
David Evans
Ā 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of Reserve
David Evans
Ā 
Silk Road
Silk RoadSilk Road
Silk Road
David 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, Permacoin
David Evans
Ā 

More from David Evans (20)

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
Ā 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Ā 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
Ā 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in Bitcoin
Ā 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm Confirmations
Ā 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting Transactions
Ā 
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
Ā 

Recently uploaded

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
Ā 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
Ā 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
Ā 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
Ā 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
Ā 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
Ā 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
Ā 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
Ā 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
Ā 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
Ā 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
Ā 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
Ā 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
Ā 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
Ā 
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
UiPathCommunity
Ā 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
Ā 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
Ā 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
Ā 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
Ā 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
Ā 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
Ā 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Ā 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Ā 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Ā 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Ā 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Ā 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
Ā 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
Ā 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ā 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Ā 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
Ā 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
Ā 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Ā 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Ā 
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Ā 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Ā 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Ā 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Ā 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
Ā 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Ā 

Class 4: Making Procedures

  • 1. Class 4: Making Procedures cs1120 Fall 2011 David Evans 30 August 2011
  • 2. Announcements PS1 is due Monday (electronic submission and paper submission): donā€™t wait to get started! Quiz 1 is Wednesday (in class) Chapters 1-4 of Course Book Chapters 1-3 of The Information Classes 1-5 (including questions from class notes) I havenā€™t forgotten about answering your questions from PS0. I will post my answers by tomorrow.
  • 3. Recap: 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. If we have a meaning rule for each grammar rule, we can determine the meaning of every Scheme program. 3
  • 4. Evaluation Rules: Last Class PrimitiveExpression ::= Number | true | false| PrimitiveProcedure Rule 1: If the expression is a primitive, it evaluates to its pre- defined value. NameExpression ::= Name Rule 2: A name evaluates to the value associated with that name. ApplicationExpression ::= (Expression MoreExpressions) MoreExpressions ::= Īµ | Expression MoreExpressions Rule 3: To evaluate 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. 4
  • 5. Last class: 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. This only makes sense if we know what a constructed procedure is! 5
  • 6. Constructing Procedures 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) 6
  • 7. Constructing Procedures lambda means ā€œmake a procedureā€ Expression ::= ProcedureExpression ProcedureExpression ::= (lambda (Parameters) Expression) Parameters ::= Īµ Parameters ::= Name Parameters 7
  • 8. Evaluation Rule 4: Lambda A lambda expression evaluates to a procedure that takes the given parameters and has the expression as its body. ProcedureExpression ::= (lambda (Parameters) Expression) Parameters ::= Īµ | Name Parameters 8
  • 9. Lambda Expressions (lambda () true) (lambda (x) (* x x)) (lambda (a) (lambda (b) (+ a b)))
  • 10. Applying Compound Procedures Rule 3: To evaluate an application expression: ((lambda () (a) Evaluate all the subexpressions (in any order) true) (b) Apply the value of the first subexpression to the values of all the other subexpressions. 1120) Apply Rule for constructed procedures: Evaluate the body of the procedure with each parameter name bound to the corresponding input expression value. Evaluation Rule 4. A lambda expression evaluates to a procedure that takes the given parameters and has the expression as its body.
  • 11. Applying Compound Procedures Rule 3: To evaluate an application expression: ((lambda (x) (a) Evaluate all the subexpressions (in any order) (+ x 1000)) (b) Apply the value of the first subexpression to the values of all the other subexpressions. 120) Apply Rule for constructed procedures: Evaluate the body of the procedure with each parameter name bound to the corresponding input expression value. Evaluation Rule 4. A lambda expression evaluates to a procedure that takes the given parameters and has the expression as its body.
  • 12. Applying Compound Procedures Rule 3: To evaluate an application expression: ((lambda (x) (a) Evaluate all the subexpressions (in any order) (+ x 1000)) (b) Apply the value of the first subexpression to the values of all the other subexpressions. x) Apply Rule for constructed procedures: Evaluate the body of the procedure with each parameter name bound to the corresponding input expression value. Evaluation Rule 4. A lambda expression evaluates to a procedure that takes the given parameters and has the expression as its body.
  • 13. Applying Compound Procedures Rule 3: To evaluate an application expression: ((lambda (a) (a) Evaluate all the subexpressions (in any order) (lambda (b) (b) Apply the value of the first subexpression to the values of all the other subexpressions. (+ a b))) Apply Rule for constructed procedures: 5) Evaluate the body of the procedure with each parameter name bound to the corresponding input expression value. Evaluation Rule 4. A lambda expression evaluates to a procedure that takes the given parameters and has the expression as its body.
  • 14. Applying Compound Procedures Rule 3: To evaluate an application expression: (((lambda (a) (a) Evaluate all the subexpressions (in any order) (lambda (b) (b) Apply the value of the first subexpression to the values of all the other subexpressions. (+ a b))) Apply Rule for constructed procedures: 5) Evaluate the body of the procedure with each parameter name bound to the corresponding 6) input expression value. Evaluation Rule 4. A lambda expression evaluates to a procedure that takes the given parameters and has the expression as its body.
  • 15. Do we have everything we need to describe all computations?
  • 16. Language Elements Question from Class 2: When learning a foreign language, which elements are hardest to learn? Primitives Means of Combination Means of Abstraction 16
  • 17. Primitives: lots of them, and hard to learn real meaning (but its just memorization) Means of Combination Complex, but, all natural languages have similar ones [Chomsky] Sentence ::= Subject Object Verb (45%) Sentence ::= Subject Verb Object (42%) Welsh: ā€œLladdodd y ddraig y dyn.ā€ Sentence ::= Verb Subject Object (9%) Sentence ::= Object Subject Verb (<1%) Scheme: Means of Abstraction: few of these, but tricky to learn differences across languages Tok Pisin (Papua New Guinea): mi (I), mitupela (he/she and I), mitripela (both of them and I), mipela (all of them and I), yumitupela (you and I), yumitripela (both of you and I), yumipela (all of you and I) Scheme: 17
  • 18. Charge PS1: Due Monday Wednesdays, 5-6:30pm (Jiamin, Rice 1xx) Thursdays, 9:45-11am (Dave, Rice 507) Thursdays, 10-11:30am (Peter, Rice 1xx) Thursdays, 1-2:30pm (Joseph, Rice 1xx) Thursdays, 4:30-6pm (Jonathan, Rice 1xx) Thursdays, 6-7:30pm (Jiamin, Rice 1xx) By Friday Finish reading Chapters 1-4, Gleick Chapters 1-3 Quiz 1: Wednesday