Programming with Transformation Rules

Size: px
Start display at page:

Download "Programming with Transformation Rules"

Transcription

1 Programming with Transformation Rules Mircea Marin 1 and Temur Kutsia 2 1 Johann Radon Institute for Computational and Applied Mathematics Austrian Academy of Sciences A-4040 Linz, Austria mircea.marin@oeaw.ac.at 2 Research Institute for Symbolic Computation Johannes Kepler University A-4232 Hagenberg, Austria tkutsia@risc.uni-linz.ac.at Abstract. Transformation rules are a convenient means to specify partially defined and nondeterministic computations. We describe a rulebased programming system which has primitive operators for defining elementary rules and for computing with unions, compositions, reflexivetransitive closures, and normal forms of transformation rules. To this end, we have implemented a Mathematica package called FunLog, which provides full support for programming with the primitive operators proposed by us. We give a brief account to the main concepts and constructs for programming with transformation rules, and illustrate their usefulness with some interesting examples. 1 Introduction A transformation rule (rule for short) as an abstraction which enables a convenient and easily understandable way to specify partially defined and nondeterministic computations. More precisely, a rule has a specification of the form lbl :: patt :> rhs (1) where lbl is the rule name, patt is a pattern expression and rhs specifies the computation of a result from the bindings of the variables which occur in patt. The expression patt :> rhs is called the code of the rule lbl. The main usage of rules is to act with them them on various expressions. The attempt to apply a rule of type (1) on an expression expr proceeds as follows: 1. M := enumeration of all matchers between expr and patt. 2. If M = then fail else goto θ := first(m), M := rest(m), V := enumeration of all values of θ(rhs). 4. If V = then goto 3 else return first(v). We write expr lbl if the application of rule lbl to expr fails, and expr lbl if it succeeds. In order to support programming with rules, we have designed and implemented a rule-based system called FunLog. We decided to implement FunLog in the Mathematica language mainly because:

2 1. Mathematica has advanced features for pattern matching and for computing with transformation rules. These features provide a very good support for implementing a full fledged rule-based system, 2. Mathematica has powerful libraries which support symbolic computations, 3. rule-based programming, as envisioned by us, could be used efficiently to implement various reasoners which could be integrated in the Theorema framework [2] for proving, solving and computing. Since Theorema is implemented in Mathematica, a Mathematica implementation of a powerful rule-based system is intended to constitute a convenient programming tool for Theorema developers. There are two sources of non-determinism in FunLog: non-unique matches and non-unique ways to evaluate a partially defined computation. Clearly, the result of an application expr lbl depends on the enumerations of matchers (M) and values (V) which are built into a particular implementation. These enumeration strategies are relevant to the programmer and are described in the specification of the operational semantics of our implementation. In the sequel we write expr 1 lbl expr 2 if we can identify two enumerations, for M and V, which render the result expr 2 for the application expr 1 lbl. Rules can be combined with various combinators into more complex rules which capture the most common ways of programming computations. FunLog provides implementations for the following combinators: choice: expr 1 lbl 1... lbl n expr 2 iff expr 1 lbl i expr 2 for some i {1,..., n} composition: expr 1 lbl 1 lbl 2 expr 2 iff expr 1 lbl 1 expr and expr lbl 2 expr 2 for some expr reflexive-transitive closure: expr 1 Repeat[lbl 1,lbl 2] expr 2 iff expr 1 lbl 1 expr lbl 2 expr 2 where lbl 1 is the reflexive-transitive closure of lbl 1 rewriting: If lbl is declared to be a rewrite rule corresponding to the rule lbl 1 then expr 1 lbl expr 2 iff there exists a position p in expr 1 such that expr 1 p lbl 1 expr and expr 2 = expr 1 [expr] p. Here, expr 1 p is the subexpression of expr at position p, and expr 1 [expr] p is the result of replacing the subexpression at position p by expr in expr 1. normal form: expr 1 NF[lbl] expr 2 iff expr 1 lbl expr 2 and expr 2 lbl. The implementation of FunLog is compositional, i.e., the meaning and enumeration strategy of each program construct can be defined in terms of the meanings and enumeration strategies of the component rules. The rest of this paper is structured as follows. Section 2 explains the main features which underly our rule-based computation: nondeterminism and partially defined computations. The peculiar features of non-unique pattern matching and multiple ways of evaluating an expression are briefly explained and illustrated with examples. In Section 3 we introduce our main programming constructs and describe their intended meaning. Section 4 gives a brief account to some successful applications of FunLog and indicate applications which could be easily and efficiently implemented in FunLog. Section 5 concludes.

3 2 Nondeterminism and Partially Defined Computations The main sources of nondeterminism in FunLog are multiple matches and multiple ways to evaluate a partially defined computation. 2.1 Multiple Matches The pattern matching mechanism of FunLog is essentially the pattern matching mechanism of Mathematica [8, Sect ], which allows to define pattern constructs which have no unique matchers. Such patterns can be specified if we employ sequence variables 1 or alternative patterns via the construct. Example 1. In Mathematica, the pattern {x, 1, y } {y, 2, x } matches the list {a, 2, 1, 2, b} in 3 possible ways: {x a, 2, y 2, b } {y a, x 1, 2, b } {y a, 2, 1, x b }. The symbols x and y in the pattern are followed by 3 underscores, and therefore they denote variables which can be bound to an arbitrary sequence of elements. To improve the readability of matchers, we have written the bindings of sequence variables between and. The first matcher is computed by matching with the first alternative pattern, whereas the last two can be computed by matching with the second alternative pattern. The Mathematica interpreter relies on the following built-in enumeration strategy [8, Sect ]: it tries first those matches that assign the shortest sequences of arguments to the first sequence variables that are encountered while traversing the pattern in a leftmost-innermost manner. Thus, the default enumeration of matches (M) is the enumeration strategy implemented in the Mathematica interpreter. 2.2 Multiple Values of Partially Defined Computations In FunLog, partially defined computations are specified by attaching side conditions to patt or in rhs of (1). We write expr/; cond for an expression expr whose instances θ(expr) are defined iff θ(cond) evaluates to True. The expression cond is called the side condition which determines whether a certain instance of expr is defined or not. Thus, a rule lbl :: patt :> expr/; cond (2) defines a partial computation such that expr 1 lbl expr 2 iff expr 2 = θ(expr 1 ), where θ is a matcher between expr 1 and patt such that θ(cond) yields True. 1 They are called named sequence patterns in the Mathematica book [8].

4 Example 2. The pattern x y/; (IntegerQ[x] IntegerQ[y] (x > y)) specifies a binary subtraction operation : Z Z Z which is defined only for pairs (x, y) Z Z with x > y. It is often desirable to have a mechanism for sharing variables between cond and expr. In particular, we would like to instantiate some variables during the evaluation of cond and, if cond evaluates to True, to employ their values in the evaluation of expr. In FunLog, we achieve this by enclosing the evaluation of expr/; cond in a Block construct which declares the variables shared between expr and cond. For example, the following sequence of pseudo-code Block[{res}, res/; (expr lbl res)] (3) has the variable res shared: if expr lbl holds, the evaluation of the side condition binds res to one of the values v for which expr lbl v and the evaluation of (3) resumes with v. The actual value of v returned by FunLog depends on the enumeration of values for res. In this case, the enumeration depends only on the enumeration of the matchers with the pattern of rule lbl. Example 3. The rule split :: {x, y } :>{x}/; (Length[{x}] > Length[{y}]) takes as input a list L and computes a prefix sublist of L whose length is longer than half the length of L. The attempt to apply rule split to {a, b, c} proceeds as follows: 1. It starts to enumerate the matchers between {a, b, c} and {x, y } in the order which is specific to the Mathematica interpreter, i.e.: {x, y a, b, c }, {x a, y b, c }, {x a, b, y c }, The enumeration is generated until we reach a matcher θ for which the condition θ(length[{x}] > Length[{y}]) holds. In this example, the enumeration stops when it reaches the matcher θ = a, b, y c } and the computation resumes with the value {a, b} of the instance θ({x}). 3 Programming Constructs A rule with name lbl is applied to an expression expr 1 via the call ApplyRule[expr 1, lbl] (4) which behaves as follows: If expr 1 lbl then return expr 1

5 If expr 1 lbl then return the first expr 2 for which expr 1 lbl expr 2. The call ApplyRuleList[expr 1, lbl] (5) returns the list of values {expr 2 expr 1 lbl expr 2 }. FunLog provides a number of useful constructs to build up rules. These constructs are described in the remainder of this section. 3.1 Basic rule A basic rule is a rule named by a string, whose code is given explicitly as a Mathematica transformation rule. A basic rule lbl :: patt :> rhs is declared by DeclareRule[patt :> rhs, lbl] (6) We recall that expr 1 lbl expr 2 iff there is a matcher θ between expr 1 and patt for which θ(rhs) evaluates to expr 2. Enumeration strategy. The enumeration strategy of basic rules depends only on the enumeration strategy of matches. Example 4. The rule perm introduced by the declaration DeclareRule[{x m, y, n, z }/; (m > n) :>{x, n, y, m, z}, perm ] takes as input a list of elements and permutes the elements which occur in descending order. The outcome of the call ApplyRule[{1, 2, 5, 4, 3}, perm ] {1, 2, 4, 5, 3} yields the instance {1, 2, 4, 5, 3} = θ({x, n, y, m, z}) corresponding to the matcher θ = {x 1, 2, m 5, y, n 4, z 3 }. Note that this is the first matcher found by the enumeration strategy of the Mathematica interpreter, for which θ(m > n) holds. 3.2 Choice lbl 1... lbl n denotes a rule whose applicative behavior is given by expr 1 lbl 1... lbl n expr 2 iff expr 1 lbl i expr 2 for some i {1,..., n}. (7)

6 Enumeration strategy. The enumeration of the steps expr 1 lbl 1... lbl n starts with the enumeration of the steps expr 1 lbl 1, followed by the enumeration of the steps expr 1 lbl 2, and so on up to the enumeration of the steps expr 1 lbl n. Example 5. Consider the declarations DeclareRule[{x m, y, n, z } :> False/; (m > n), test ]; DeclareRule[ List :> True, else ]; Here, List is a pattern variable which matches any list structure. Then ApplyRule[L, test else ] yields True iff L is a list with elements in ascending order. This behavior is witnessed by the calls: ApplyRule[{1, 2, 4, 5, 3}, test else ] False ApplyRule[{1, 2, 3, 4, 5}, test else ] True The first call yields False because {1, 2, 4, 5, 3} test False with the matcher θ = {x 1, 2, m 5, y, n 4, z 3 }. The second call yields True because {1, 2, 3, 4, 5} test and {1, 2, 3, 4, 5} else True. 3.3 Composition lbl 1 lbl 2 denotes a rule whose applicative behavior is given by expr 1 lbl 1 lbl 2 expr 2 iff expr 1 lbl 1 expr lbl 2 expr 2 for some expr. (8) Enumeration strategy. The enumeration of values expr 2 for which the relation expr 1 lbl 1 lbl 2 expr 2 holds, proceeds by enumerating all steps expr lbl 2 expr 2 during an enumeration of the steps expr 1 lbl 1 expr. Example 6. The following piece of code DeclareRule[x Real/; x < 0 :> x + 7, f ] DeclareRule[x Real/; x > 0 :> x, g ] defines rules f and g which encode the partially defined functions { f : (, 0.) R, x x + 7, g : (0., ) R, x x. Then g f denotes a rule which encodes the function g f : ( 7, 0) R.

7 3.4 Reflexive-Transitive Closures If lbl {Repeat[lbl 1, lbl 2 ], Until[lbl 2, lbl 1 ]} then expr 1 lbl expr 2 iff expr 1 lbl 1 expr lbl 2 expr 2 for some expr (9) where lbl 1 denotes the reflexive-transitive closure of lbl 1. These two constructs differ only with respect to the enumeration strategy of the possible reduction steps. (See below.) Enumeration strategies. The enumeration of expr 1 Repeat[lbl 1,lbl 2] expr 2 proceeds by unfolding the recursive definition: Repeat[lbl 1, lbl 2 ] = lbl 1 Repeat[lbl 1, lbl 2 ] lbl 2, whereas the enumeration of expr 1 Until[lbl 1,lbl 2] expr 2 proceeds by unfolding the recursive definition: Until[lbl 2, lbl 1 ] = lbl 2 lbl 1 Until[lbl 2, lbl 1 ]. Example 7 (Sorting). Consider the declarations of basic rules DeclareRule[x :> x, Id ]; DeclareRule[{x, m, y, n, z }/; (m > n) :>{x, n, y, m, z}, perm ]; Then the enumeration strategy of Repeat[ perm, Id ] ensures that the application of rule Repeat[ perm, Id ] to any list of integers yields the sorted version of that list. For example ApplyRule[{3, 1, 2}, Repeat[ perm, Id ]] yields {1, 2, 3} via the following sequence of transformation steps {3, 1, 2} perm {1, 3, 2} perm {1, 2, 3} Id {1, 2, 3}. 3.5 Rewrite Rules FunLog provides the following mechanism to define a rule which performs rewriting with respect to a given rule: RWRule[lbl 1, lbl, Traversal..., Prohibit...] (10) This call declares a new rule named lbl such that expr 1 lbl expr 2 iff there exists a position p in expr 1 such that expr 1 p lbl 1 expr and expr 2 = expr 1 [expr] p. Here, expr 1 p is the subexpression of expr at position p, and expr 1 [expr] p is the result of replacing the subexpression at position p by expr in expr 1. The option Traversal defines the enumeration ordering of rewrite steps (see below), whereas the option Prohibit restricts the set of positions allowed for rewriting. If the option Prohibit {f 1,..., f n } is given, then rewriting is prohibited at positions below occurrences of symbols f {f 1,..., f n }. By default, the value of Prohibit is {}, i.e., rewriting can be performed everywhere.

8 Enumeration strategies. The enumeration strategy of rewrite steps can be controlled via the option Traversal which has the default value LeftmostIn. If the option Traversal LeftmostOut is given, then the rewriting steps are enumerated by traversing the rewriting positions in leftmost-outermost order. If Traversal LeftmostIn is given, then the rewriting steps are enumerated by traversing the rewriting positions in leftmost-innermost order. Example 8 (Pure λ-calculus). In λ-calculus, a value is an expression which has no β-redexes outside λ-abstractions. We adopt the following syntax for λ-terms: term ::= terms : x variable app[term 1, term 2 ] application λ[x, term] abstraction β-redexes are eliminated by applications of the β-conversion rule, which can be encoded in FunLog as follows: DeclareRule[app[λ[x, t1 ], t2 ] :> repl[t 1, {x, t2}], β ] where repl[t 1, {x, t2}] replaces all free occurrences of x in t1 by t2. A straightforward implementation of repl in Mathematica is shown below 2 : repl[λ[x, t ], {x, }] := λ[x, t]; repl[x, {x, t }] := t; repl[λ[x, t ], σ ] := λ[x, repl[t, σ]]; repl[app[t1, t2 ], σ ] := app[repl[t1, σ], repl[t2, σ]]; repl[t, ] := t; The computation of a value of a λ-term proceeds by repeated reductions of the redexes which are not inside abstractions. In FunLog, the reduction of such a redex coincides with an application of the rewrite rule β-elim defined by RWRule[ β, β-elim, Prohibit {λ}] The following calls illustrate the behavior of this rule: t := app[z, app[λ[x, app[x, λ[y, app[x, y]]]], λ[z, z]]]; t1 := ApplyRule[t, β-elim ] app[z, app[λ[z, z], λ[y, app[λ[z, z], y]]]] t2 := ApplyRule[t1, β-elim ] app[z, λ[y, app[λ[z, z], y]]] t3 := ApplyRule[t2, β-elim ] app[z, λ[y, app[λ[z, z], y]]] Thus, t2 is a value of t. To compute the value of t directly, we could call ApplyRule[t, Repeat[ β-elim, Id ]] app[z, λ[y, app[λ[z, z], y]]] 2 The Mathematica definitions are tried top-down, and this guarantees a proper interpretation of the replacement operation.

9 3.6 Normal Form NF[lbl] denotes a rule whose applicative behavior is given by expr NF[lbl] expr 2 iff expr 1 lbl expr 2 and expr 2 lbl. (11) Enumeration strategy. The enumeration strategy of NF[lbl] is obtained by unfolding the recursive definition where NFQ[lbl] :: x :> x/; (x lbl ). NF[lbl] = NFQ[lbl] lbl NF[lbl] (12) 3.7 Abstraction The abstraction principle is provided in FunLog via the construct SetAlias[expr, lbl] (13) where lbl is a fresh rule name (a string identifier) and expr is an expression built from names of rules already declared with the operators,, Repeat and Until described before. For example, the call SetAlias[Repeat[ perm, Id ], sort ] declares a rule named sort whose applicative behavior coincides with that of the construct Repeat[ perm, Id ]. 4 Applications Obviously, the range of applications which can be tackled with FunLog is very large. Recently, we employed FunLog to implement various unification procedures in theories with sequence variables, and integrated them in the equational prover of Theorema [4]. These procedures can be described as finite sets of inference rules [3] which have efficient and straightforward implementations in FunLog [7]. When rule applications are viewed as deduction steps then FunLog becomes a deductive system. In this context, FunLog can be employed to generate proof trees which correspond to various deduction strategies. The methods ApplyRule and ApplyRuleList recognize the option TraceStyle which controls the output produced by the call. The default value of TraceStyle is None, and in this case the call yields the value (resp. list of values) corresponding to the rule application. If TraceStyle is "Object" then the methods yield an abstract proof object which contains all information needed to trace the deduction steps which lead to the computation of the corresponding value(s). If TraceStyle is "Notebook" then the methods yield a Mathematica notebook which contains a human-readable presentation of the proof object.

10 5 Conclusions and Future Work The primitive operators implemented in FunLog reflect the most common ways to build up complex computations from simpler ones. But we also expect that our future attempts to solve new problems will reveal new programming constructs which are desirable for making our programming style more expressive. Currently, we investigate how these programming constructs can be employed to explore the search space for proofs in the Theorema system [1, 2]. We also believe that our programming constructs could be used efficiently by the Theorema users and developers to write reasoners. Another direction of future work is to introduce control mechanisms for pattern matching with sequence variables. The current implementation of FunLog relies entirely on the enumeration strategy of matchers which is built into the Mathematica interpreter. However, there are many situations when this enumeration strategy is not desirable. We have already addressed this problem in [5, 6] and implemented the package Sequentica with language extensions which can overwrite the default enumeration strategy of the Mathematica interpreter. The integration of those language extensions in FunLog will certainly increase the expressive power of our rule-based system. We are currently working on integrating Sequentica with FunLog. The current implementation of FunLog can be downloaded from Acknowledgements. Mircea Marin has been supported by the Austrian Academy of Sciences. Temur Kutsia has been supported by the Austrian Science Foundation (FWF) under Project SFB F1302. References 1. Bruno Buchberger, Claudio Dupré, Tudor Jebelean, Franz Kriftner, Koji Nakagawa, Daniela Văsaru, and Wolfgang Windsteiger. The Theorema project: A progress report. In M. Kerber and M. Kohlhase, editors, Symbolic Computation and Automated Reasoning. Proceedings of Calculemus 2000 Conference, pages , St. Andrews, UK, August Bruno Buchberger, Tudor Jebelean, Franz Kriftner, Mircea Marin, Elena Tomuţa, and Daniela Văsaru. A survey of the Theorema project. In W. Küchlin, editor, Proceedings of the International Symposium on Symbolic and Algebraic Computation, ISSAC 97, pages , Maui, Hawaii, US, July ACM Press. 3. Temur Kutsia. Unification with Sequence Variables and Flexible Arity Symbols and its Extension with Pattern-Terms. In J. Calmet, B. Benhamou, O. Caprotti, L. Henocque, and V. Sorge, editors, Artificial Intelligence, Automated Reasoning and Symbolic Computation. Proceedings of Joint AISC 2002 and Calculemus 2002 Conferences, volume 2385 of LNAI, pages , Marseille, France, July Springer Verlag.

11 4. Temur Kutsia. Equational prover of Theorema. In R. Nieuwenhuis, editor, Proceedings of the 14th International Conference on Rewriting Techniques and Applications (RTA 03), volume 2706 of LNCS, pages , Valencia, Spain, 9 11 June Springer Verlag. 5. Mircea Marin. Functional Programming with Sequence Variables: The Sequentica Package. In J. Levy, M. Kohlhase, J. Niehren, and M. Villaret, editors, Proceedings of the 17th International Workshop on Unification (UNIF 2003), pages 65 78, Valencia, June Mircea Marin and Dorin Ţepeneu. Programming with Sequence Variables: The Sequentica Package. In Peter Mitic, Philip Ramsden, and Janet Carne, editors, Challenging the Boundaries of Symbolic Computation. Proceedings of 5th International Mathematica Symposium (IMS 2003), pages 17 24, Imperial College, London, July Imperial College Press. 7. Mircea Marin and Temur Kutsia. On the Implementation of a Rule-Based Programming System and some of its Applications. In Boris Konev and Renate Schmidt, editors, Proceedings of the Fourth International Workshop on the Implementation of Logics, Almaty, Kazakhstan, September To appear. 8. Stephen Wolfram. The Mathematica Book. Wolfram Media, Champaign, Illinois, fourth edition, 1999.

Logicographic Symbols: A New Feature in Theorema

Logicographic Symbols: A New Feature in Theorema Logicographic Symbols: A New Feature in Theorema Bruno Buchberger RISC (Research Institute for Symbolic Computation) A 4232 Schloss Hagenberg, Austria Buchberger@RISC.Uni-Linz.ac.at Abstract: Theorema

More information

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Semantics via Syntax. f (4) = if define f (x) =2 x + 55. 1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)

More information

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 17 Programming in the λ-calculus 10 October 2014 Announcements 2 Foster Office Hours 11-12 Enjoy fall break! Review: Church Booleans 3 We can encode TRUE,

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type

More information

Towards Interoperable Mechanized Reasoning Systems: the Logic Broker Architecture Λ

Towards Interoperable Mechanized Reasoning Systems: the Logic Broker Architecture Λ Towards Interoperable Mechanized Reasoning Systems: the Logic Broker Architecture Λ Alessandro Armando Mechanized Reasoning Group DIST, University of Genoa, Italy armando@dist.unige.it Daniele Zini Mechanized

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.

More information

1 Scope, Bound and Free Occurrences, Closed Terms

1 Scope, Bound and Free Occurrences, Closed Terms CS 6110 S18 Lecture 2 The λ-calculus Last time we introduced the λ-calculus, a mathematical system for studying the interaction of functional abstraction and functional application. We discussed the syntax

More information

Lambda Calculus and Extensions as Foundation of Functional Programming

Lambda Calculus and Extensions as Foundation of Functional Programming Lambda Calculus and Extensions as Foundation of Functional Programming David Sabel and Manfred Schmidt-Schauß 29. September 2015 Lehrerbildungsforum Informatik Last update: 30. September 2015 Overview

More information

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations Outline FP Foundations, Scheme In Text: Chapter 15 Mathematical foundations Functional programming λ-calculus LISP Scheme 2 Imperative Languages We have been discussing imperative languages C/C++, Java,

More information

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions. CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations

More information

(Refer Slide Time: 4:00)

(Refer Slide Time: 4:00) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional

More information

Equational Reasoning in THEOREMA

Equational Reasoning in THEOREMA Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria kutsia@risc.uni-linz.ac.at Workshop on Formal Gröbner Bases Theory. March 8, 2006. Linz, Austria Outline 1 2 Equational

More information

Introduction to the Lambda Calculus

Introduction to the Lambda Calculus Introduction to the Lambda Calculus Overview: What is Computability? Church s Thesis The Lambda Calculus Scope and lexical address The Church-Rosser Property Recursion References: Daniel P. Friedman et

More information

Functional programming with Common Lisp

Functional programming with Common Lisp Functional programming with Common Lisp Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 81 Expressions and functions

More information

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER 2012 2013 MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS Time allowed TWO hours Candidates may complete the front

More information

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions) By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable

More information

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic 3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type

More information

Extracting the Range of cps from Affine Typing

Extracting the Range of cps from Affine Typing Extracting the Range of cps from Affine Typing Extended Abstract Josh Berdine, Peter W. O Hearn Queen Mary, University of London {berdine, ohearn}@dcs.qmul.ac.uk Hayo Thielecke The University of Birmingham

More information

Strategies in PρLog. Temur Kutsia. RISC, JKU Linz, Austria

Strategies in PρLog. Temur Kutsia. RISC, JKU Linz, Austria Strategies in PρLog Besik Dundua RISC, JKU Linz, Austria bdundua@risc.uni-linz.ac.at Temur Kutsia RISC, JKU Linz, Austria kutsia@risc.uni-linz.ac.at Mircea Marin University of Tsukuba, Japan mmarin@cs.tsukuba.ac.jp

More information

Lecture Notes on Data Representation

Lecture Notes on Data Representation Lecture Notes on Data Representation 15-814: Types and Programming Languages Frank Pfenning Lecture 9 Tuesday, October 2, 2018 1 Introduction In this lecture we ll see our type system in action. In particular

More information

Focus Windows: A New Technique for Proof Presentation

Focus Windows: A New Technique for Proof Presentation Focus Windows: A New Technique for Proof Presentation F. Piroi, B. Buchberger RISC-Linz Research Institute for Symbolic Computation A-4232 Hagenberg, Austria {Florina.Piroi, Bruno.Buchberger}@risc.uni-linz.ac.at

More information

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics. Oscar Nierstrasz 7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

More information

Pure Lambda Calculus. Lecture 17

Pure Lambda Calculus. Lecture 17 Pure Lambda Calculus Lecture 17 Lambda Calculus Lambda Calculus (λ-calculus) is a functional notation introduced by Alonzo Church in the early 1930s to formalize the notion of computability. Pure λ-calculus

More information

Programming Lecture 3

Programming Lecture 3 Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements

More information

Functional Logic Programming: From Theory to Curry

Functional Logic Programming: From Theory to Curry Functional Logic Programming: From Theory to Curry Michael Hanus Institut für Informatik, CAU Kiel, D-24098 Kiel, Germany. mh@informatik.uni-kiel.de Abstract. Functional logic programming languages combine

More information

Functional Programming. Overview. Topics. Recall λ-terms. Examples

Functional Programming. Overview. Topics. Recall λ-terms. Examples Topics Functional Programming Christian Sternagel Harald Zankl Evgeny Zuenko Department of Computer Science University of Innsbruck WS 2017/2018 abstract data types, algebraic data types, binary search

More information

CITS3211 FUNCTIONAL PROGRAMMING

CITS3211 FUNCTIONAL PROGRAMMING CITS3211 FUNCTIONAL PROGRAMMING 9. The λ calculus Summary: This lecture introduces the λ calculus. The λ calculus is the theoretical model underlying the semantics and implementation of functional programming

More information

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08 Introduction to Lambda Calculus Lecture 5 CS 565 1/24/08 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

More information

Chapter 2 The Language PCF

Chapter 2 The Language PCF Chapter 2 The Language PCF We will illustrate the various styles of semantics of programming languages with an example: the language PCF Programming language for computable functions, also called Mini-ML.

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Tuesday, February 19, 2013 The lambda calculus (or λ-calculus) was introduced by Alonzo Church and Stephen Cole Kleene in

More information

System Description: Analytica 2

System Description: Analytica 2 System Description: Analytica 2 Edmund Clarke, Michael Kohlhase, Joël Ouaknine, Klaus Sutner Carnegie Mellon University {emc kohlhase ouaknine sutner}@cs.cmu.edu Abstract. The Analytica system is a theorem

More information

VU Semantik von Programmiersprachen

VU Semantik von Programmiersprachen VU Semantik von Programmiersprachen Agata Ciabattoni Institute für Computersprachen, Theory and Logic group (agata@logic.at) (A gentle) Introduction to λ calculus p. 1 Why shoud I studyλcalculus? p. 2

More information

Lambda Calculus. Variables and Functions. cs3723 1

Lambda Calculus. Variables and Functions. cs3723 1 Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can

More information

Lecture Notes on Program Equivalence

Lecture Notes on Program Equivalence Lecture Notes on Program Equivalence 15-312: Foundations of Programming Languages Frank Pfenning Lecture 24 November 30, 2004 When are two programs equal? Without much reflection one might say that two

More information

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 Lecture notes for CS 6110 (Spring 09) taught by Andrew Myers at Cornell; edited by Amal Ahmed, Fall 09. 1 Static vs. dynamic scoping The scope of a variable

More information

Lambda Calculus. Lecture 4 CS /26/10

Lambda Calculus. Lecture 4 CS /26/10 Lambda Calculus Lecture 4 CS 565 10/26/10 Pure (Untyped) Lambda Calculus The only value is a function Variables denote functions Functions always take functions as arguments Functions always return functions

More information

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions. THREE LECTURES ON BASIC TOPOLOGY PHILIP FOTH 1. Basic notions. Let X be a set. To make a topological space out of X, one must specify a collection T of subsets of X, which are said to be open subsets of

More information

Abstract register machines Lecture 23 Tuesday, April 19, 2016

Abstract register machines Lecture 23 Tuesday, April 19, 2016 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 23 Tuesday, April 19, 2016 1 Why abstract machines? So far in the class, we have seen a variety of language features.

More information

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods Course 2D1453, 2006-07 Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Alonzo Church, 1903-1995 Church-Turing thesis First

More information

Pure (Untyped) λ-calculus. Andrey Kruglyak, 2010

Pure (Untyped) λ-calculus. Andrey Kruglyak, 2010 Pure (Untyped) λ-calculus Andrey Kruglyak, 2010 1 Pure (untyped) λ-calculus An example of a simple formal language Invented by Alonzo Church (1936) Used as a core language (a calculus capturing the essential

More information

Introduction to Lambda Calculus. Lecture 7 CS /08/09

Introduction to Lambda Calculus. Lecture 7 CS /08/09 Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

More information

Last class. CS Principles of Programming Languages. Introduction. Outline

Last class. CS Principles of Programming Languages. Introduction. Outline Last class CS6848 - Principles of Programming Languages Principles of Programming Languages V. Krishna Nandivada IIT Madras Interpreters A Environment B Cells C Closures D Recursive environments E Interpreting

More information

This book is licensed under a Creative Commons Attribution 3.0 License

This book is licensed under a Creative Commons Attribution 3.0 License 6. Syntax Learning objectives: syntax and semantics syntax diagrams and EBNF describe context-free grammars terminal and nonterminal symbols productions definition of EBNF by itself parse tree grammars

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Lecture 5: Lazy Evaluation and Infinite Data Structures

Lecture 5: Lazy Evaluation and Infinite Data Structures Lecture 5: Lazy Evaluation and Infinite Data Structures Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense October 3, 2017 How does Haskell evaluate a

More information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

Operational Semantics 1 / 13

Operational Semantics 1 / 13 Operational Semantics 1 / 13 Outline What is semantics? Operational Semantics What is semantics? 2 / 13 What is the meaning of a program? Recall: aspects of a language syntax: the structure of its programs

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2002 Vol. 1, No. 2, July-August 2002 The Theory of Classification Part 2: The Scratch-Built

More information

Formal Semantics. Aspects to formalize. Lambda calculus. Approach

Formal Semantics. Aspects to formalize. Lambda calculus. Approach Formal Semantics Aspects to formalize Why formalize? some language features are tricky, e.g. generalizable type variables, nested functions some features have subtle interactions, e.g. polymorphism and

More information

Theorema 2.0: A Graphical User Interface for a Mathematical Assistant System

Theorema 2.0: A Graphical User Interface for a Mathematical Assistant System Theorema 2.0: A Graphical User Interface for a Mathematical Assistant System Wolfgang Windsteiger RISC, JKU Linz 4232 Hagenberg, Austria Wolfgang.Windsteiger@risc.jku.at www.risc.jku.at/home/wwindste/

More information

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS522 Programming Language Semantics

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS522 Programming Language Semantics CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS522 Programming Language Semantics Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and

More information

Program Calculus Calculational Programming

Program Calculus Calculational Programming Program Calculus Calculational Programming National Institute of Informatics June 21 / June 28 / July 5, 2010 Program Calculus Calculational Programming What we will learn? Discussing the mathematical

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................

More information

A Formalization of Transition P Systems

A Formalization of Transition P Systems Fundamenta Informaticae 49 (2002) 261 272 261 IOS Press A Formalization of Transition P Systems Mario J. Pérez-Jiménez and Fernando Sancho-Caparrini Dpto. Ciencias de la Computación e Inteligencia Artificial

More information

Multi-paradigm Declarative Languages

Multi-paradigm Declarative Languages c Springer-Verlag In Proc. of the International Conference on Logic Programming, ICLP 2007. Springer LNCS 4670, pp. 45-75, 2007 Multi-paradigm Declarative Languages Michael Hanus Institut für Informatik,

More information

From the λ-calculus to Functional Programming Drew McDermott Posted

From the λ-calculus to Functional Programming Drew McDermott Posted From the λ-calculus to Functional Programming Drew McDermott drew.mcdermott@yale.edu 2015-09-28 Posted 2015-10-24 The λ-calculus was intended from its inception as a model of computation. It was used by

More information

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Finite Model Generation for Isabelle/HOL Using a SAT Solver Finite Model Generation for / Using a SAT Solver Tjark Weber webertj@in.tum.de Technische Universität München Winterhütte, März 2004 Finite Model Generation for / p.1/21 is a generic proof assistant: Highly

More information

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Semantics

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Semantics CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS422 Programming Language Semantics Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

LOGIC AND DISCRETE MATHEMATICS

LOGIC AND DISCRETE MATHEMATICS LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information

QIR Specification. Romain Vernoux. January 6, Notations 2

QIR Specification. Romain Vernoux. January 6, Notations 2 QIR Specification Romain Vernoux January 6, 2017 Contents 1 Notations 2 2 Architecture 3 3 QIR data model, expressions and operators 4 3.1 QIR data model.................................... 4 3.2 QIR operators.....................................

More information

CIS 500 Software Foundations Fall September 25

CIS 500 Software Foundations Fall September 25 CIS 500 Software Foundations Fall 2006 September 25 The Lambda Calculus The lambda-calculus If our previous language of arithmetic expressions was the simplest nontrivial programming language, then the

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

If a program is well-typed, then a type can be inferred. For example, consider the program

If a program is well-typed, then a type can be inferred. For example, consider the program CS 6110 S18 Lecture 24 Type Inference and Unification 1 Type Inference Type inference refers to the process of determining the appropriate types for expressions based on how they are used. For example,

More information

Denotational Semantics; Lambda Calculus Basics Section and Practice Problems Week 4: Tue Feb 13 Fri Feb 16, 2018

Denotational Semantics; Lambda Calculus Basics Section and Practice Problems Week 4: Tue Feb 13 Fri Feb 16, 2018 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Denotational Semantics; Lambda Calculus Basics Week 4: Tue Feb 13 Fri Feb 16, 2018 1 Denotational Semantics (a) Give the

More information

CMSC 330: Organization of Programming Languages. Operational Semantics

CMSC 330: Organization of Programming Languages. Operational Semantics CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged

More information

Proving Theorems with Athena

Proving Theorems with Athena Proving Theorems with Athena David R. Musser Aytekin Vargun August 28, 2003, revised January 26, 2005 Contents 1 Introduction 1 2 Proofs about order relations 2 3 Proofs about natural numbers 7 3.1 Term

More information

Computing Fundamentals 2 Introduction to CafeOBJ

Computing Fundamentals 2 Introduction to CafeOBJ Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal Faria, Prof. Heinrich Hußmann. See notes on slides

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

CITS3211 FUNCTIONAL PROGRAMMING. 14. Graph reduction

CITS3211 FUNCTIONAL PROGRAMMING. 14. Graph reduction CITS3211 FUNCTIONAL PROGRAMMING 14. Graph reduction Summary: This lecture discusses graph reduction, which is the basis of the most common compilation technique for lazy functional languages. CITS3211

More information

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion

More information

The Substitution Model

The Substitution Model The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on

More information

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA

Thunks (continued) Olivier Danvy, John Hatcli. Department of Computing and Information Sciences. Kansas State University. Manhattan, Kansas 66506, USA Thunks (continued) Olivier Danvy, John Hatcli Department of Computing and Information Sciences Kansas State University Manhattan, Kansas 66506, USA e-mail: (danvy, hatcli)@cis.ksu.edu Abstract: Call-by-name

More information

Rule Formats for Nominal Modal Transition Systems

Rule Formats for Nominal Modal Transition Systems Rule Formats for Nominal Modal Transition Systems Anke Stüber Universitet Uppsala, Uppsala, Sweden anke.stuber@it.uu.se Abstract. Modal transition systems are specification languages that allow the expression

More information

A Brief Introduction to Scheme (I)

A Brief Introduction to Scheme (I) A Brief Introduction to Scheme (I) Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Scheme Scheme I p.1/44 Scheme: Feature Set A

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description)

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Brigitte Pientka and Joshua Dunfield McGill University, Montréal, Canada {bpientka,joshua}@cs.mcgill.ca Abstract.

More information

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

More information

The Typed λ Calculus and Type Inferencing in ML

The Typed λ Calculus and Type Inferencing in ML Notes on Types S. Arun-Kumar Department of Computer Science and Engineering Indian Institute of Technology New Delhi, 110016 email: sak@cse.iitd.ernet.in April 14, 2002 2 Chapter 1 The Typed λ Calculus

More information

Computer Science 203 Programming Languages Fall Lecture 10. Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus

Computer Science 203 Programming Languages Fall Lecture 10. Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus 1 Computer Science 203 Programming Languages Fall 2004 Lecture 10 Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus Plan Informal discussion of procedures and bindings Introduction

More information

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242 Spring 2013 Foundations Yu Zhang Acknowledgement: modified from Stanford CS242 https://courseware.stanford.edu/pg/courses/317431/ Course web site: http://staff.ustc.edu.cn/~yuzhang/fpl Reading Concepts

More information

Contents. Chapter 1 SPECIFYING SYNTAX 1

Contents. Chapter 1 SPECIFYING SYNTAX 1 Contents Chapter 1 SPECIFYING SYNTAX 1 1.1 GRAMMARS AND BNF 2 Context-Free Grammars 4 Context-Sensitive Grammars 8 Exercises 8 1.2 THE PROGRAMMING LANGUAGE WREN 10 Ambiguity 12 Context Constraints in Wren

More information

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller 09/1 Contents Motivation

More information

Com S 541. Programming Languages I

Com S 541. Programming Languages I Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR

More information

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic

More information

Elementary Recursive Function Theory

Elementary Recursive Function Theory Chapter 6 Elementary Recursive Function Theory 6.1 Acceptable Indexings In a previous Section, we have exhibited a specific indexing of the partial recursive functions by encoding the RAM programs. Using

More information

A Database of Categories

A Database of Categories A Database of Categories Michael Fleming Department of Computer Science University of Waterloo Waterloo, Ont, Canada Ryan Gunther Department of Computer Science University of Waterloo Waterloo, Ont, Canada

More information

3.7 Denotational Semantics

3.7 Denotational Semantics 3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

More information

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types CS 4110 Programming Languages & Logics Lecture 28 Recursive Types 7 November 2014 Announcements 2 Foster office hours 11-12pm Guest lecture by Fran on Monday Recursive Types 3 Many languages support recursive

More information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 4 November 8 November 15, 2006 - version 1.1 The Lambda Calculus The lambda-calculus If our previous language of arithmetic expressions was the simplest nontrivial

More information

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus: Boolean Functions and Expressions CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Objective: To provide students with the concepts and

More information

Lambda Calculus-2. Church Rosser Property

Lambda Calculus-2. Church Rosser Property Lambda Calculus-2 Church-Rosser theorem Supports referential transparency of function application Says if it exists, normal form of a term is UNIQUE 1 Church Rosser Property Fundamental result of λ-calculus:

More information

The Metalanguage λprolog and Its Implementation

The Metalanguage λprolog and Its Implementation The Metalanguage λprolog and Its Implementation Gopalan Nadathur Computer Science Department University of Minnesota (currently visiting INRIA and LIX) 1 The Role of Metalanguages Many computational tasks

More information

On Meaning Preservation of a Calculus of Records

On Meaning Preservation of a Calculus of Records On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract

More information

The Arrow Calculus (Functional Pearl)

The Arrow Calculus (Functional Pearl) The Arrow Calculus (Functional Pearl) Sam Lindley Philip Wadler Jeremy Yallop University of Edinburgh Abstract We introduce the arrow calculus, a metalanguage for manipulating Hughes s arrows with close

More information