SlideShare uma empresa Scribd logo
1 de 5
;; Towards a Scheme Interpreter for the Lambda Calculus -- Part
1: Syntax
;; 5 points
;; , and pre-requisite for all subsequent parts of the project
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;
;; All programming is to be carried out using the pure functional
sublanguage of R5RS Scheme.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;
;; You might want to have a look at
http://www.cs.unc.edu/~stotts/723/Lambda/overview.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;
;; 1. The lambda calculus is a particularly simple programming
language consisting only of
;; variable references, lambda expressions with a single formal
parameter, and function
;; applications. A BNF definition of lambda calculus
expressions is
;; ::= | (lambda ( ) ) | ( )
;; Design a data type for the lambda calculus, with constructors,
selectors, and classifiers.
;; For concrete representation, use Scheme, as follows: an
identifier should be represented as
;; a quoted Scheme variable, a lambda expression (lambda (x)
E) as the quoted 3-element list
;; '(lambda (x) [list representing E]), and an application (E1
E2) as the quoted 2-element list
;; '([list representing E1] [list representing E2])
;; 2. In (lambda () ), we say that is a binder that
;; binds all occurrences of that variable in the body, , unless
some intervening
;; binder of the same variable occurs. Thus in (lambda (x) (x
(lambda (x) x))),
;; the first occurrence of x binds the second occurrence of x, but
not
;; the fourth. The third occurrence of x binds the fourth
occurrence of x.
;; A variable x occurs free in an expression E if there is some
occurrence of x which is not
;; bound by any binder of x in E. A variable x occurs bound in
an expression E if it is
;; not free in E. Thus x occurs free in (lambda (y) x), bound in
(lambda (x) x), and both
;; free and bound in (lambda (y) (x (lambda (x) x))).
;; As a consequence of this definition, we can say that a variable
x occurs free in a
;; lambda calculus expression E iff one of the following holds:
;; (i) E = x
;; (ii) E = (lambda (y) E'), where x is distinct from y and x
occurs free in E'
;; (iii) E = (E' E'') and x occurs free in E' or x occurs free in E''
;; Observe that this is an inductive definition, exploiting the
structure of lambda calculus
;; expressions.
;; Similarly, a variable x occurs bound in a lambda calculus
expression E iff one of the
;; following holds:
;; (i) E = (lambda (x) E') and x occurs free in E'
;; (ii) E = (lambda (y) E'), and x occurs bound in E': here, y
may be x, or distinct from x
;; (iii) E = (E1 E2) and x occurs bound in either E1 or E2
;; Develop and prove correct a procedure free-vars that inputs a
list representing a lambda calculus
;; expression E and outputs a list without repetitions (that is, a
set) of the variables occurring
;; free in E.
;; Develop and prove correct a procedure bound-vars that inputs
a list representing a lambda calculus
;; expression E and outputs the set of variables which occur
bound in E.
;; 3. Define a function all-ids which returns the set of all
symbols -- free or bound variables,
;; as well as the lambda identifiers for which there are no bound
occurrences -- which occur in
;; a lambda calculus expression E.

Mais conteúdo relacionado

Mais de taishao1

8B20M017 Teaching Note SOBEYS—PROJECT SUNRIS.docx
8B20M017  Teaching Note  SOBEYS—PROJECT SUNRIS.docx8B20M017  Teaching Note  SOBEYS—PROJECT SUNRIS.docx
8B20M017 Teaching Note SOBEYS—PROJECT SUNRIS.docx
taishao1
 
81Journal of International Studies© Foundation .docx
81Journal of International Studies© Foundation .docx81Journal of International Studies© Foundation .docx
81Journal of International Studies© Foundation .docx
taishao1
 
82916 f_ch02.docx 45 Chapter 2 From Public Regulat.docx
82916 f_ch02.docx  45 Chapter 2 From Public Regulat.docx82916 f_ch02.docx  45 Chapter 2 From Public Regulat.docx
82916 f_ch02.docx 45 Chapter 2 From Public Regulat.docx
taishao1
 
8. On the likely aftermath and long term effects of the coronavi.docx
8. On the likely aftermath and long term effects of the coronavi.docx8. On the likely aftermath and long term effects of the coronavi.docx
8. On the likely aftermath and long term effects of the coronavi.docx
taishao1
 
776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx
776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx
776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx
taishao1
 
8 New Scientist 4 January 2020THE tropics are the most.docx
8  New Scientist  4 January 2020THE tropics are the most.docx8  New Scientist  4 January 2020THE tropics are the most.docx
8 New Scientist 4 January 2020THE tropics are the most.docx
taishao1
 
7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx
7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx
7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx
taishao1
 
78 CONTRADICTIONS The development of the cotton expo.docx
78  CONTRADICTIONS The development of the cotton expo.docx78  CONTRADICTIONS The development of the cotton expo.docx
78 CONTRADICTIONS The development of the cotton expo.docx
taishao1
 
68 En glish Journal 103.4 (2014) 68– 75wanted to write a.docx
68 En glish Journal  103.4 (2014) 68– 75wanted to write a.docx68 En glish Journal  103.4 (2014) 68– 75wanted to write a.docx
68 En glish Journal 103.4 (2014) 68– 75wanted to write a.docx
taishao1
 
7-27Security Guide One-Stop ShoppingCopyright ©.docx
7-27Security Guide One-Stop ShoppingCopyright ©.docx7-27Security Guide One-Stop ShoppingCopyright ©.docx
7-27Security Guide One-Stop ShoppingCopyright ©.docx
taishao1
 

Mais de taishao1 (20)

8B20M017 Teaching Note SOBEYS—PROJECT SUNRIS.docx
8B20M017  Teaching Note  SOBEYS—PROJECT SUNRIS.docx8B20M017  Teaching Note  SOBEYS—PROJECT SUNRIS.docx
8B20M017 Teaching Note SOBEYS—PROJECT SUNRIS.docx
 
875 words Include citations for all unoriginal ideas, .docx
875 words Include citations for all unoriginal ideas, .docx875 words Include citations for all unoriginal ideas, .docx
875 words Include citations for all unoriginal ideas, .docx
 
81Journal of International Studies© Foundation .docx
81Journal of International Studies© Foundation .docx81Journal of International Studies© Foundation .docx
81Journal of International Studies© Foundation .docx
 
82916 f_ch02.docx 45 Chapter 2 From Public Regulat.docx
82916 f_ch02.docx  45 Chapter 2 From Public Regulat.docx82916 f_ch02.docx  45 Chapter 2 From Public Regulat.docx
82916 f_ch02.docx 45 Chapter 2 From Public Regulat.docx
 
8.1 What is the difference between RFC 5321 and RFC 53228.docx
8.1 What is the difference between RFC 5321 and RFC 53228.docx8.1 What is the difference between RFC 5321 and RFC 53228.docx
8.1 What is the difference between RFC 5321 and RFC 53228.docx
 
8. On the likely aftermath and long term effects of the coronavi.docx
8. On the likely aftermath and long term effects of the coronavi.docx8. On the likely aftermath and long term effects of the coronavi.docx
8. On the likely aftermath and long term effects of the coronavi.docx
 
8 pagesSelect an agency of the US government and a specific pu.docx
8 pagesSelect an agency of the US government and a specific pu.docx8 pagesSelect an agency of the US government and a specific pu.docx
8 pagesSelect an agency of the US government and a specific pu.docx
 
8 pages Select an agency of the US government and a specific p.docx
8 pages Select an agency of the US government and a specific p.docx8 pages Select an agency of the US government and a specific p.docx
8 pages Select an agency of the US government and a specific p.docx
 
8-1 Discussion Immigration LawsIt is a violation of the immigra.docx
8-1 Discussion Immigration LawsIt is a violation of the immigra.docx8-1 Discussion Immigration LawsIt is a violation of the immigra.docx
8-1 Discussion Immigration LawsIt is a violation of the immigra.docx
 
776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx
776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx
776! CHAPTER 26 Rococo to Neoclassicism The 18th Century in E.docx
 
8 New Scientist 4 January 2020THE tropics are the most.docx
8  New Scientist  4 January 2020THE tropics are the most.docx8  New Scientist  4 January 2020THE tropics are the most.docx
8 New Scientist 4 January 2020THE tropics are the most.docx
 
7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx
7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx
7 HYPOTHETICALS AND YOU TESTING YOUR QUESTIONS7 MEDIA LIBRARY.docx
 
78 CONTRADICTIONS The development of the cotton expo.docx
78  CONTRADICTIONS The development of the cotton expo.docx78  CONTRADICTIONS The development of the cotton expo.docx
78 CONTRADICTIONS The development of the cotton expo.docx
 
68 En glish Journal 103.4 (2014) 68– 75wanted to write a.docx
68 En glish Journal  103.4 (2014) 68– 75wanted to write a.docx68 En glish Journal  103.4 (2014) 68– 75wanted to write a.docx
68 En glish Journal 103.4 (2014) 68– 75wanted to write a.docx
 
7.1 What is the basic building block of an 802.11 WLAN7.2 Def.docx
7.1 What is the basic building block of an 802.11 WLAN7.2 Def.docx7.1 What is the basic building block of an 802.11 WLAN7.2 Def.docx
7.1 What is the basic building block of an 802.11 WLAN7.2 Def.docx
 
7-1 Discussion Discovery and Judicial EfficiencyAfter reviewing.docx
7-1 Discussion Discovery and Judicial EfficiencyAfter reviewing.docx7-1 Discussion Discovery and Judicial EfficiencyAfter reviewing.docx
7-1 Discussion Discovery and Judicial EfficiencyAfter reviewing.docx
 
7.4 - Discussion Aircraft SystemsIn this video, Professor S.docx
7.4 - Discussion Aircraft SystemsIn this video, Professor S.docx7.4 - Discussion Aircraft SystemsIn this video, Professor S.docx
7.4 - Discussion Aircraft SystemsIn this video, Professor S.docx
 
7-27Security Guide One-Stop ShoppingCopyright ©.docx
7-27Security Guide One-Stop ShoppingCopyright ©.docx7-27Security Guide One-Stop ShoppingCopyright ©.docx
7-27Security Guide One-Stop ShoppingCopyright ©.docx
 
7.  According to scientists; our personality is set by the time we.docx
7.  According to scientists; our personality is set by the time we.docx7.  According to scientists; our personality is set by the time we.docx
7.  According to scientists; our personality is set by the time we.docx
 
7.1 What is the basic building block of an 802.11 WLAN7.2.docx
7.1 What is the basic building block of an 802.11 WLAN7.2.docx7.1 What is the basic building block of an 802.11 WLAN7.2.docx
7.1 What is the basic building block of an 802.11 WLAN7.2.docx
 

Último

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

;; Towards a Scheme Interpreter for the Lambda Calculus -- Part 1 S.docx

  • 1. ;; Towards a Scheme Interpreter for the Lambda Calculus -- Part 1: Syntax ;; 5 points ;; , and pre-requisite for all subsequent parts of the project ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;; ;; All programming is to be carried out using the pure functional sublanguage of R5RS Scheme. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;; ;; You might want to have a look at http://www.cs.unc.edu/~stotts/723/Lambda/overview.html ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;; ;; 1. The lambda calculus is a particularly simple programming language consisting only of ;; variable references, lambda expressions with a single formal parameter, and function
  • 2. ;; applications. A BNF definition of lambda calculus expressions is ;; ::= | (lambda ( ) ) | ( ) ;; Design a data type for the lambda calculus, with constructors, selectors, and classifiers. ;; For concrete representation, use Scheme, as follows: an identifier should be represented as ;; a quoted Scheme variable, a lambda expression (lambda (x) E) as the quoted 3-element list ;; '(lambda (x) [list representing E]), and an application (E1 E2) as the quoted 2-element list ;; '([list representing E1] [list representing E2]) ;; 2. In (lambda () ), we say that is a binder that ;; binds all occurrences of that variable in the body, , unless some intervening ;; binder of the same variable occurs. Thus in (lambda (x) (x (lambda (x) x))), ;; the first occurrence of x binds the second occurrence of x, but not
  • 3. ;; the fourth. The third occurrence of x binds the fourth occurrence of x. ;; A variable x occurs free in an expression E if there is some occurrence of x which is not ;; bound by any binder of x in E. A variable x occurs bound in an expression E if it is ;; not free in E. Thus x occurs free in (lambda (y) x), bound in (lambda (x) x), and both ;; free and bound in (lambda (y) (x (lambda (x) x))). ;; As a consequence of this definition, we can say that a variable x occurs free in a ;; lambda calculus expression E iff one of the following holds: ;; (i) E = x ;; (ii) E = (lambda (y) E'), where x is distinct from y and x occurs free in E' ;; (iii) E = (E' E'') and x occurs free in E' or x occurs free in E'' ;; Observe that this is an inductive definition, exploiting the structure of lambda calculus ;; expressions.
  • 4. ;; Similarly, a variable x occurs bound in a lambda calculus expression E iff one of the ;; following holds: ;; (i) E = (lambda (x) E') and x occurs free in E' ;; (ii) E = (lambda (y) E'), and x occurs bound in E': here, y may be x, or distinct from x ;; (iii) E = (E1 E2) and x occurs bound in either E1 or E2 ;; Develop and prove correct a procedure free-vars that inputs a list representing a lambda calculus ;; expression E and outputs a list without repetitions (that is, a set) of the variables occurring ;; free in E. ;; Develop and prove correct a procedure bound-vars that inputs a list representing a lambda calculus ;; expression E and outputs the set of variables which occur bound in E. ;; 3. Define a function all-ids which returns the set of all symbols -- free or bound variables, ;; as well as the lambda identifiers for which there are no bound occurrences -- which occur in
  • 5. ;; a lambda calculus expression E.