02-syntax-semantics

02-syntax-semantics - Course Outline Part 1 Functional...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Course Outline Part 1: Functional Language Interpreter I Defining a language: syntax and semantics I Starting small: the lambda calculus I Building up: defining fun I Exploring functional programming topics Part 2: Adding a Type System Part 3: Exploring Memory Management Part 4: State and OOP Ben Hardekopf () Syntax and Semantics Winter 2011 1 / 51
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Defining Programming Languages Before we make a language interpreter, we need to know how to define a language. To define a programming language we must specify two things: Syntax : the way a program looks Semantics : the way a program behaves Ben Hardekopf () Syntax and Semantics Winter 2011 2 / 51
Image of page 2
Defining Programming Languages Before we make a language interpreter, we need to know how to define a language. To define a programming language we must specify two things: Syntax : the way a program looks Semantics : the way a program behaves Note that these two things are orthogonal. For example: which of the following statements are most alike? Java a [25] C a [25] Haskell a [25] Scheme (vector-ref a 25) Ben Hardekopf () Syntax and Semantics Winter 2011 2 / 51
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Section Outline Defining Programming Languages Inductive definitions Defining syntax Defining semantics Ben Hardekopf () Syntax and Semantics Winter 2011 3 / 51
Image of page 4
Induction The first problem we encounter is that there are an infinite number of legal programs in a language—yet we must describe them all using a finite representation. The mathematical tool we use to describe an infinite set of objects is induction . Clarification Remember that mathematical induction is very different from the philosophical notion of inductive reasoning . Mathematical induction is a form of deductive reasoning. Inductive reasoning draws a general conclusion from a finite set of observations (e.g., “The sun has risen every morning so far, therefore it will rise every morning”). Inductive reasoning may lead to false conclusions (see the Problem of Induction); mathematical reasoning will always yield a true result. Ben Hardekopf () Syntax and Semantics Winter 2011 4 / 51
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A Quick Reminder Definition (Mathematical Induction) To prove proposition P holds for all natural numbers, show the following: P (0) is true if P (n) is true, then P (n+1) must be true We can then conclude that P must hold for all natural numbers. Using this technique we can prove a property for an infinite set of objects using only a finite number of steps. This is very similar to what we need to do: define the appearance and behavior of an infinite number of programs using a finite number of rules. Ben Hardekopf () Syntax and Semantics Winter 2011 5 / 51
Image of page 6
Inductive Definitions Induction and recursion are closely related. You can think of them as two sides of the same coin—recursion starts at a certain point and works backwards to a base case, while induction starts at a base case and works forward. We can use this characteristic to define infinite sets; this is called inductive definition .
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern