02-syntax-semantics

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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 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 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 Section Outline Defining Programming Languages Inductive definitions Defining syntax Defining semantics Ben Hardekopf () Syntax and Semantics Winter 2011 3 / 51 Induction The first problem we encounter is that there are an infinite number of legal programs in a languageyet 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 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 Inductive Definitions Induction and recursion are closely related. You can think of them as two sides of the same coinrecursion 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 ....
View Full Document

Page1 / 66

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

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online