Proceedings of the Sixth International Workshop on Graph Transformation and Visual Modeling Techniques (GT-VMT 2007)

Size: px
Start display at page:

Download "Proceedings of the Sixth International Workshop on Graph Transformation and Visual Modeling Techniques (GT-VMT 2007)"

Transcription

1 Electronic Communications o the EASST Volume X (2007) Proceedings o the Sixth International Workshop on Graph Transormation and Visual Modeling Techniques (GT-VMT 2007) Visual Programming with Recursion Patterns in Interaction Nets Ian Mackie, Jorge Sousa Pinto and Miguel Vilaça 12 pages Guest Editors: Karsten Ehrig, Holger Giese Managing Editors: Tiziana Margaria, Julia Padberg, Gabriele Taentzer ECEASST Home Page: ISSN

2 ECEASST Visual Programming with Recursion Patterns in Interaction Nets Ian Mackie 1, Jorge Sousa Pinto 2 and Miguel Vilaça 2 1 LIX, École Polytechnique, Palaiseau Cedex, France 2 Departamento de Inormática, Universidade do Minho, 4710 Braga, Portugal Abstract: In this paper we propose to use Interaction Nets as a ormalism or Visual Functional Programming. We consider the use o recursion patterns as a programming idiom, and introduce a suitable archetype/instantiation mechanism or interaction agents, which allows one to deine agents whose behaviour is based on recursion patterns. Keywords: Interaction nets 1 Introduction This paper is about visual programming with Interaction Nets, a graph-rewriting ormalism introduced by Laont [9], inspired by Proo-nets or Multiplicative Linear Logic. In Interaction Nets, a program consists o a number o interaction rules and an initial net that will be reduced by repeated application o the rules. The ormalism combines the usual advantages o visual programming languages, but with the ollowing additional eatures: Programs and data structures are represented in the same ramework, which is useul or tracing and debugging purposes; All aspects o computations, such as duplication and garbage-collection, are explicit. Interaction Nets have been extensively used or unctional programming as an eicient intermediate (or implementation) language. In particular, unctional programs can be encoded in Interaction Nets, using one o the many encodings o the λ-calculus. Section 3 reviews how a unctional language can be encoded in Interaction Nets ollowing this approach, without entering the details o any particular encoding o β-reduction. The ocus o this paper will be the adequate treatment o inductive datatypes, pattern-matching, and recursive unction deinitions. The remaining sections o the paper introduce and systematise the use o a unctional style or programming with Interaction Nets with recursion patterns, and introduce a new construct (the archetype, Section 4) which captures the behaviour o recursion patterns. We claim that this style is a good choice or deining and executing visual unctional programs. The style o programming we reer to is widely used by unctional programmers: it is based on programs that perorm iteration on their arguments, usually known in the ield as olds, and (the dual notion) programs that construct results by co-iteration, unolds. Among other advantages o using olds and unolds or programming, they can be composed to construct complex recursive programs, and they are particularly adequate or equational reasoning: proos o equality can be done using a usion law instead o recursion. The body o theoretical work on recursion patterns comes rom the ield o datatype-generic programming (see [4] or an introduction), which studies these patterns in a datatype-parameterized 1 / 12 Volume X (2007)

3 Visual Programming with Recursion Patterns in Interaction Nets way. The examples in the paper use lists, but it is straightorward to generalize the ideas to arbitrary regular datatypes. Section 5 introduces interaction net programming with recursion patterns; Section 6 and Section 7 then present archetypes or olds and unolds respectively. Section 8 concludes and discusses uture work. 2 Background Recursion Patterns. The ideas developed in this paper or Interaction Nets are very much inspired by Functional Programming. One undamental aspect that we will use extensively is the ability to use a set o recursion patterns or each datatype. For instance ew Haskell programmers would write a list sum program with explicit recursion as sum [] = 0 sum (x:xs) = x + (sum xs) Most would deine sum = oldr (+) 0, where oldr is a recursion pattern encoded as the ollowing higher-order unction: oldr z [] = z oldr z (x:xs) = x (oldr z xs) A unction like sum is oten called a old. The use o recursion patterns has the advantage o being appropriate or program transormation and reasoning using the so-called calculationbased style [1]. To see how less obvious olds can be deined, consider the list append unction: app :: [a] -> [a] -> [a] app [] l = l app (x:xs) l = x:(app xs l) This is a higher-order old that iterates over its irst argument to produce a unction (id is the identity unction): app = oldr (\x r l -> x:(r l)) id. The dual notion o old is the co-recursive unold that allows one to produce lists whose tails are constructed recursively by the unction being deined. For instance the Haskell unction downrom 0 = [] downrom (n+1) = (n+1):(downrom n) can be written alternatively as downrom = unold (==0) id pred where pred is the predecessor unction, and unold is deined as ollows unold :: (t -> Bool) -> (t -> a) -> (t -> t) -> t -> [a] unold p g x = i p x then [] else x : unold p g (g x) One o the reasons why unolds are important [5] is that together with olds they give us back the power o arbitrary recursion: the composition o a old with an unold is a unction (known as a hylomorphism [14]) whose recursion tree is the intermediate structure constructed by the unold. In a language with a suiciently rich type system, most useul recursive unctions can be deined in this way. Proc. GT-VMT / 12

4 ECEASST Interaction Nets. An interaction net system [9] is speciied by giving a set Σ o symbols, and a set R o interaction rules. Each symbol α Σ has an associated (ixed) arity. An occurrence o a symbol α Σ will be called an agent. I the arity o α is n, then the agent has n + 1 ports: a distinguished one called the principal port, and n auxiliary ports labelled x 1,...,x n. A net built on Σ is a graph (not necessarily connected) where the nodes are agents. The edges between nodes o the graph are connected to ports in the agents, such that there is at most one edge connected to every port in the net. Edges may be connected to two ports o the same agent. Principal ports o agents are depicted by an arrow. The ports o agents that have no edge connected are called the ree ports o the net. The set o ree ports deine the interace o the net. The dynamics o Interaction Nets are based on the notion o active pair: any pair o agents (α, β) in a net, with an edge connecting together their principal ports. An interaction rule ((α,β) = N) R replaces an occurrence o the active pair (α,β) by the net N. Rules must satisy two conditions: the interaces o the let-hand side and right-hand side are equal (this implies that the ree ports are preserved during reduction), and there is at most one rule or each pair o agents, so there is no ambiguity regarding which rule to apply. I a net does not contain any active pairs then we say that it is in normal orm. We use the notation = or one-step reduction and = or its transitive relexive closure. Additionally, we write N N i there is a sequence o interaction steps N = N, such that N is a net in normal orm. The strong constraints on the deinition o interaction rules imply that reduction is strongly commutative (the one-step diamond property holds), and thus conluence is easily obtained. equently, any normalizing interaction net is strongly normalizing. As an example, we show a system or representing lists o numbers. Lists are inductively deined by an agent o arity 0 representing the empty list, and an agent o arity 2 representing a cell in the list, containing an element and a tail list. Lists are constructed such that the principal port o each agent corresponds to the root o the list. To implement, or instance, list concatenation, we need an additional binary agent app. Concatenation is deined recursively on one o the argument lists, as expected. As such, the principal port o the agent must be used or interacting with this argument. The necessary interaction rules are given in Figure 1, together with an example net, representing the concatenation o lists [1,2] and [3,4]. app app app 1 3 app 2 4 Figure 1: Interaction rules o agent app and an example net Thus, an implementation o list concatenation can be obtained by Σ containing {,, app}, with arity 0, 2, 2 respectively, and R consisting o the rules in Figure 1. 3 / 12 Volume X (2007)

5 Visual Programming with Recursion Patterns in Interaction Nets Related Work: Visual Functional Programming. Work in this area has addressed dierent aspects o visual programming. The Pivotal project [6] oers a visual notation (and Haskell programming environment) or data structures, not programs. Reekie s Visual Haskell [15] more or less stands at the opposite side o the spectrum o possibilities: this is a datalow-style visual notation or Haskell programs, which allows programmers to deine their programs visually (with the assistance o a tool) and then have them translated automatically to Haskell code. Kelso s VFP system [7] is a complete environment that allows one to deine unctional programs visually and then reduce them step by step. Finally, VisualLambda [2] is a ormalism based on graphrewriting: programs are deined as graphs whose reduction mimics the execution o a unctional program. As ar as we know none o these systems is widely used. Visual Haskell and VisualLambda have in common that unctions are represented as boxes with input ports or the arguments and an output port or the result; the contents o the box correspond to the body o the unction. They dier in that Visual Haskell uses variables to reer to unction arguments, while VisualLambda uses a purely graphical notation based on arrows. Kelso s VFP uses a notation without boxes, more inspired by the traditional representations o unctional programs used in implementation-oriented abstract machines (see Section 5). In particular, it allows or named unctions but also or λ-abstractions, and an explicit application node exists. Variables are used or arguments, as in Visual Haskell. Higher-order programming is a undamental eature o unctional programming. A unction can take unction g as an argument and g can then applied within the body o. Expressing this eature is easy i variables are used as in Visual Haskell and VFP; in VisualLambda a special box would be used as a placeholder or g (in the body o ) to be instantiated later, and an arrow would link an input port in the box o to the box o g. The work presented in the present paper uses a pure visual representation o programs, without variables. In this aspect it resembles VisualLambda, however our work diers signiicantly rom this in that no boxes are used, and all the graph-rewriting operations are local in the sense that only two nodes o the graph are involved in each step. A second diiculty arising rom the higher-order nature o programs is that a (curried) unction o two arguments may receive only its irst argument and return as result a unction. In a boxbased representation this means that it must be possible or a box to lose its input ports one by one a complicated process. Interaction nets treat this problem naturally as will become clear. Moreover in this paper we introduce a new notion (the archetype), which captures precisely the behaviour o many typical curried unctions. 3 Visual Functional Programming with Interaction Nets Using Explicit Abstraction and Application Nodes In this section we explain how a very simple unctional programming language can be encoded in Interaction Nets. The language has inductive types, pattern-matching on these types, and explicit recursion. We irst review the basic principle shared by most well-known encodings [13, 12, 16] o the λ-calculus into Interaction Nets, and show how this basic language can easily be extended to cover other eatures o unctional languages. Proc. GT-VMT / 12

6 ECEASST The usual way o representing unctional programs with interaction nets is based on a pair o symbols o arity 2, such that a β-reduction step corresponds to an interaction between an agent λ and an These representations are based on an explicit depiction o the λ-abstractions in the program, as well as applications o unctions to arguments. While this may be visually more complicated than the boxes used by some o the systems reviewed in Section 2, it certainly solves the higher-order problem in a natural way, since unction arguments are treated like any other arguments. The deinition o the application unction ap x = x illustrates this point (see Figure 2 let). λ Figure 2: App deinition (let) and β rule (right) We only discuss the eatures o the linear λ-calculus here, which is shared by all encodings. It is beyond the scope o this paper to unclude the details o the non-linear aspects, but reer the reader to [12, 13] or the encodings o the ull λ-calculus. ider an interaction system containing the symbols {@,λ} as explained above, as well as the β interaction rule o Figure 2 (right). This system deines the visual programming language or the linear λ-calculus. A visual unctional program consists o this interaction system, together with a closed unctional expression to be evaluated, represented by a net with a single ree port. We now outline how other eatures can be introduced in the interaction system to enrich this core language. The next eature is Inductive Types and Pattern-matching. ider a datatype T with constructors C 1...C n, with arities a 1...a n. This can be modelled in a straightorward way by an interaction system containing n agents labelled C i with arity a i, i = 1...n ; values o type T correspond to closed trees built exclusively rom these agents (in a tree all principal ports are oriented in the same direction). In a constructor agent, auxiliary ports are input ports, and the principal port is an output port. An example o this is the datatype o lists with constructors and, as in Figure 1. Pattern-matching over an inductive type T can be implemented by a special agent Tcase. For instance, the ListCase agent has arity 5, and its behaviour is deined by the two rules: List Case List Case Here two dierent nets are connected to the ListCase agent. One is a net to be returned when the argument list is empty, and the other is a net with three ports, used to combine the head and 5 / 12 Volume X (2007)

7 Visual Programming with Recursion Patterns in Interaction Nets tail o a non-empty list. Observe that one o these nets is not used in each rule, and must be erased with agents. The interaction o an agent with any other agent erases the latter and propagates new agents along its auxiliary ports. The approach outlined above allows or unnamed unctions only. In a visual language one would like to have the possibility o deining named unctions, which would most naturally correspond to agents in the interaction system. A special agent de can be used or unolding named unction deinitions. For instance a unction isempty can be deined by the ollowing interaction rule or the agent de: de λ is Empty List Case True False The ollowing igureshows the reduction o the visual program corresponding to the application o isempty to the List Case False de is Empty 1 2 λ List Case True False False True 1 2 True This agent also allows or a visually appealing treatment o recursion: it suices that the righthand side o interaction rules involving de reintroduces an active pair (the let-hand side o the rule) as a sub-net. To sum up, Interaction Nets allow to visually represent unctional programs and data structures in the same very simple ormalism; moreover higher-order eatures, which are a typical diiculty in the visual setting, are treated in a natural way, and the execution o the program can be eiciently implemented within the ormalism. 4 Agent Archetypes Although no standard programming language exists as a ront-end or programming with Interaction Nets, it is generally well accepted that any such language should contain some orm o support or modularity and reusability. In particular, a mechanism should exist to acilitate the deinition o interaction rules that ollow identical patterns. To illustrate, consider again the app agent o Figure 1. It is deined by case analysis on the structure o the argument, and in act any other agent deined in this way must have two interaction rules with a similar structure to those in Figure 1. We now introduce a concept designed precisely to isolate this structure, which we designate archetype. The ListCase archetype given Proc. GT-VMT / 12

8 ECEASST below should be interpreted as ollows: any agent that its this archetype interacts with both and, and the right hand sides o the corresponding rules are nets to be instantiated, that will be called respectively N, and N,. Archetype ListCase N, N, To deine a new agent ollowing the archetype, an instance is created, by simply providing the nets in the right-hand side o the interaction rules. This implicitly includes the agent declaration, as well as the instantiated interaction rules or this agent, in the interaction system being deined. As an example, the isempty agent (and its behaviour) is deined as an instance o the ListCase archetype. agents are used to explicitly erase the head and tail o the list, which are not used in the result. Instance ListCase isempty N iszero, N iszero, = True = False For a second example, take the agent de used in Section 5 or unction deinitions. We create an archetype or deined unctions, whose only mandatory rule is or interaction with de, with the right-hand side to be instantiated. Recursive archetypes are most interesting, and will be very useul in the rest o the paper (in Section 6 a recursive archetype will be given or the app agent). Although archetypes can be useul or programming with interaction nets in general, our examples o using them here concern eatures o unctional programming languages. The ListCase example shows that archetypes allow or a natural treatment o higher-order concepts: ListCase can be seen as a unction that takes certain arguments (the instantiated nets) and returns another unction (an agent with its own rules) as result. 5 Interaction Net Programming with Recursion Patterns Section 3 was about using Interaction Nets or encoding unctional programs, with the practical goal o producing eicient unctional compilers. From the point o view o visual programming, the drawbacks o this approach are that the introduction o explicit abstraction and application nodes complicates the visual representation o programs (the same is true o explicit case constructs), and also raises the matching duplicators problem. Solving this problem implies introducing in the system machinery that destroys the clean visual representation o terms. 7 / 12 Volume X (2007)

9 Visual Programming with Recursion Patterns in Interaction Nets Our goal in this paper is to propose a number o principles and extensions or direct visual programming with Interaction Nets, in a unctional style. To see what we mean by direct, consider again the interaction rules given in Figure 1. It is easy to see that both deine a behaviour or the agent app similar to the standard list concatenation unction, which can be written in Haskell as shown in Section 2. In both cases, a program consists o a collection o unction deinitions encoded directly as interaction rules in a particular interaction system, together with a closed unctional expression to be evaluated in the context o those deinitions, represented by a net with a single ree port. While in the second approach a unction deinition corresponds to interaction rules or a special agent de, in Figure 1 there is a direct correspondence between the clauses in the deinition o a unction and the interaction rules deining the behaviour o the agent. A comparison o both deinitions reveals that the irst approach is visually simpler, and thus more appropriate or representing programs, than the second, standard approach. Naturally, there are important limitations to the class o programs with which the simpliied representation can be used. The example above takes advantage o a undamental aspect o Interaction Nets, which is that pattern-matching on the outermost constructor is built-in through the rule selection mechanism (in the deinition o app in Figure 1, only the outermost constructor is matched). Matching deeper constructors, or matching more than one argument in the same clause, would orce us to use an explicit case agent. For a certain class o patterns (match-sequential systems [17]) there are known transormations which result in a system which examines arguments one at a time. We can use this transormation to obtain an explicit system. We reer the reader to [8] or a detailed presentation o one such transormation. It will now be shown that the use o a programming style based on recursion patterns allows precisely or the direct representation to be used, since these operators perorm pattern-matching on a single top-level constructor. Iteration: Fold Agents. The simplest orm o recursion is iteration, which substitutes the datatype constructors by some given unctions. Taking lists as an example, a old is a unction that combines the head o the list with the result o recursively applying the unction to the tail o the list, to produce the result (a given value is returned at the end o the list). Since this requires matching on the outermost constructor only, iteration neatly its the interaction paradigm. The ollowing is the deinition o the product old, which computes the product o all the numbers in a list (it uses an agent or multiplication o numbers; we assume the arithmetics to be correctly implemented in the current interaction system). prod S prod * 0 prod It is easy to see that other, more powerul recursion patterns on an inductive type can be captured in the same way. For instance, primitive recursion on a list would allow or the tail o the list itsel to be used as well. Proc. GT-VMT / 12

10 ECEASST Co-recursion Patterns: Unold Agents. Co-recursive unctions provide structured ways to construct values o recursive types. Taking lists as an example again, the unold co-recursion pattern, which is the dual o old, corresponds to unctions that construct lists by giving an element to be placed at the head position, together with a seed used as an argument to recursively construct the tail o the list. This is the simplest orm o co-recursion. Let us consider an unold agent downrom (d) which interacts with a natural number n to construct the list containing all the numbers rom n down to 1, in this order. Its rules are the ollowing d d * 0 S * S d 6 Fold Archetypes The rules that characterize the behaviour o a old agent (on a particular inductive type) can be described by a recursive archetype, in the sense that the parameterized agent occurs in the right-hand side o one o the rules. Taking the case o lists, interaction rules must be deined or to interact with both and. The archetype is Archetype oldr N, N, where interaction with results in an arbitrary net, and interaction with sends an agent along the tail o the argument list, and a net N, then combines the head o the list with the recursive result. As an example, the agent prod can be alternatively deined as the ollowing instance. Instance oldr prod N prod, = S 0 N prod, = * The principles developed above can be applied to olds over any regular inductive type. 9 / 12 Volume X (2007)

11 Visual Programming with Recursion Patterns in Interaction Nets Higher-order Folds. Our current deinition o a old agent is still not satisactory, and will now be generalized. ider again the list append unction. As seen in Section 2, this is a higher-order unction o two arguments, deined by recursion on its irst argument. This old can be deined with Interaction Nets as a binary agent (see Figure 1), which clearly does not match our current deinition o the old archetype. Functions o more than one argument deined as olds over one o the arguments lead us to the generalization o the oldr archetype, as shown in the ollowing igure. This is parameterized by the number o extra arguments o the old agent; our previous deinition is o course a particular case o this where k = 0. Archetype oldr (k) N, args args' k args N, k args head tail k args head rec. result k k The deinition o append as an instance o this archetype, or k = 1, can be seen below. The open wire in the net N app, corresponds to the act that the second argument o the old is preserved in the recursive call. Instance oldr app(1) N app, y N app, = = y y' y head rec. result head rec. result y y' 7 Unold Archetypes It is less obvious to deine an archetype or unolds. ider again the case o lists; it is clear that there must be two rules (to produce empty and non-empty lists respectively); the contents o the right-hand side o each interaction rule is also clear (with a parameter net appearing in the second rule). However, since the arguments o an unold are arbitrary, the two rules cannot correspond to interactions between the unold and its arguments. Instead, we will consider two special agents that interact with the unold. Archetype unold u Instance unold du u u c1 c2 u N du = g N u Proc. GT-VMT / 12

12 ECEASST Now observe that an instance o this archetype does not immediately behave as an unold; it must be connected to the net N u. To take downrom as an example again, this net is in this case simply an agent (see right o previous igure) whose behaviour is given by the rules on the let in the ollowing. Then the ollowing macro (on the right) can be deined: g 0 c1 g S S c2 d' = du g 8 Conclusions and Future Work One o our long-term goals is to develop a ull environment or interaction net programming a tool is currently being developed. We are currently working on the archetype deinition and instantiation mechanismsubsequently, we plan to incorporate in the programming environment a mechanism that generates the appropriate archetype or a given user-deined inductive type. This paper opens a number o other research questions at the theoretical level. One o the main reasons or using recursion patterns and datatype-generic programming is that this style o programming is good or reasoning about programs equationally. The work in this paper allows us to reason about unctional programs visually. In [11] we derive a usion law or the old archetype, that already makes it possible to transpose to the visual setting classic program transormation techniques such as the introduction o accumulators or tupling. A dierent approach that we intend to explore is to establish a ormal correspondence between a core unctional language with recursion patterns and an interaction system or that language. This will allows us to be more precise in the study o the calculation laws or visual programs. At the level o the programming environment, the graphical notation then becomes an alternative to writing unctional programs textually. The environment should be able to translate between visual programs and textual programs, and all operations perormed on programs at the visual level correspond closely to the same operations at the expression level. Acknowledgements: The work o Vilaça was granted by FCT (SFRH/BD/18874/2004). Bibliography [1] R. Bird. The Promotion and Accumulation Strategies in Transormational Programming, ACM Transactions on Programming Languages and Systems, 6(4), October 1984, [2] L. Dami and D. Vallet. Higher-order unctional composition in visual orm. Technical report, University o Geneva, [3] M. Fernández. Type assignment and termination o interaction nets. Mathematical Structures in Computer Science, 8(6): , / 12 Volume X (2007)

13 Visual Programming with Recursion Patterns in Interaction Nets [4] J. Gibbons. Calculating Functional Programs. In Proceedings o ISRG/SERG Research Colloquium. School o Computing and Mathematical Sciences, Oxord Brookes University, [5] J. Gibbons and G. Jones. The Under-appreciated Unold. In Proceedings o the 3rd ACM SIGPLAN International Conerence on Functional Programming (ICFP 98), pages ACM Press, [6] K. Hanna. Interactive Visual Functional Programming. In S. P. Jones, editor, Proc. Intnl Con. on Functional Programming, pages ACM, October [7] J. Kelso. A Visual Programming Environment or Functional Languages. PhD thesis, Murdoch University, [8] J.R. Kennaway. Implementing term rewrite languages in DACTL. Theoretical Computer Science, 72: , [9] Y. Laont. Interaction Nets. In Proceedings o the 17th ACM Symposium on Principles o Programming Languages (POPL 90), pages ACM Press, Jan [10] M. Fernández and I. Mackie. Coinductive techniques or operational equivalence o interaction nets. In Proceedings o the 13th Annual IEEE Symposium on Logic in Computer Science (LICS 98), pages IEEE Computer Society Press, June [11] I. Mackie, J. S. Pinto, and M. Vilaça. Functional programming and program transormation with interaction nets. Technical Report DI-PURe , Universidade do Minho, [12] I. Mackie. YALE: Yet another lambda evaluator based on interaction nets. In Proceedings o the 3rd ACM SIGPLAN International Conerence on Functional Programming (ICFP 98), pages ACM Press, September [13] I. Mackie. Eicient λ-evaluation with interaction nets. In V. van Oostrom, editor, Proceedings o Rewriting Techniques and Applications: 15th International Conerence (RTA 2004), volume 3091 o Lecture Notes in Computer Science. Springer-Verlag, [14] E. Meijer, M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In J. Hughes, editor, Proceedings o the 5th ACM Conerence on Functional Programming Languages and Computer Architecture (FPCA 91), volume 523 o LNCS. Springer-Verlag, [15] H. J. Reekie. Realtime Signal Processing Datalow, Visual, and Functional Programming. PhD thesis, University o Technology at Sydney, [16] F.-R. Sinot. Token-passing Nets: Call-by-need or Free. In Proceedings o the 1st. International Workshop on Developments in Computational Models (DCM 05), [17] S. Thatte. A reinement o strong sequentiality or term rewriting systems with constructors. Inormation and Computation, 72:46 65, Proc. GT-VMT / 12

Token-Passing Nets: Call-by-Need for Free

Token-Passing Nets: Call-by-Need for Free Electronic Notes in Theoretical Computer Science 135 (2006) 129 139 www.elsevier.com/locate/entcs Token-Passing Nets: Call-by-Need for Free François-Régis Sinot 1,2 LIX, Ecole Polytechnique, 91128 Palaiseau,

More information

Visual Programming with Interaction Nets

Visual Programming with Interaction Nets Visual Programming with Interaction Nets Abubakar Hassan, Ian Mackie, and Jorge Sousa Pinto 1 Department of Informatics, Universit of Susse, Falmer, Brighton BN1 9QJ, UK 2 LIX, École Poltechnique, 91128

More information

Interaction Nets vs. the ρ-calculus: Introducing Bigraphical Nets

Interaction Nets vs. the ρ-calculus: Introducing Bigraphical Nets Interaction Nets vs. the ρ-calculus: Introducing Bigraphical Nets Maribel Fernández 1 Ian Mackie 1 François-Régis Sinot 2 1 DCS, King s College London 2 LIX, École Polytechnique Rho-Calculus Workshop,

More information

MATRIX ALGORITHM OF SOLVING GRAPH CUTTING PROBLEM

MATRIX ALGORITHM OF SOLVING GRAPH CUTTING PROBLEM UDC 681.3.06 MATRIX ALGORITHM OF SOLVING GRAPH CUTTING PROBLEM V.K. Pogrebnoy TPU Institute «Cybernetic centre» E-mail: vk@ad.cctpu.edu.ru Matrix algorithm o solving graph cutting problem has been suggested.

More information

Connecting Definition and Use? Tiger Semantic Analysis. Symbol Tables. Symbol Tables (cont d)

Connecting Definition and Use? Tiger Semantic Analysis. Symbol Tables. Symbol Tables (cont d) Tiger source program Tiger Semantic Analysis lexical analyzer report all lexical errors token get next token parser construct variable deinitions to their uses report all syntactic errors absyn checks

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

Binary recursion. Unate functions. If a cover C(f) is unate in xj, x, then f is unate in xj. x

Binary recursion. Unate functions. If a cover C(f) is unate in xj, x, then f is unate in xj. x Binary recursion Unate unctions! Theorem I a cover C() is unate in,, then is unate in.! Theorem I is unate in,, then every prime implicant o is unate in. Why are unate unctions so special?! Special Boolean

More information

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the

the application rule M : x:a: B N : A M N : (x:a: B) N and the reduction rule (x: A: B) N! Bfx := Ng. Their algorithm is not fully satisfactory in the The Semi-Full Closure of Pure Type Systems? Gilles Barthe Institutionen for Datavetenskap, Chalmers Tekniska Hogskola, Goteborg, Sweden Departamento de Informatica, Universidade do Minho, Braga, Portugal

More information

Extending the Interaction Nets Calculus by Generic Rules

Extending the Interaction Nets Calculus by Generic Rules Extending the Interaction Nets Calculus by Generic Rules Eugen Jiresch jiresch@logic.at Institute for Computer Languages Vienna University of Technology Abstract. We extend the textual calculus for interaction

More information

From functional programs to interaction nets via the Rewriting Calculus New evaluation strategies for functional languages

From functional programs to interaction nets via the Rewriting Calculus New evaluation strategies for functional languages WRS 2006 From functional programs to interaction nets via the Rewriting Calculus New evaluation strategies for functional languages Horatiu Cirstea a, Germain Faure a, Maribel Fernández b, Ian Mackie b,c,1

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

Chapter 11 :: Functional Languages

Chapter 11 :: Functional Languages Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative

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

Ad-hoc Workflow: Problems and Solutions

Ad-hoc Workflow: Problems and Solutions Ad-hoc Worklow: Problems and Solutions M. Voorhoeve and W. van der Aalst Dept. o Mathematics and Computing Science Eindhoven University o Technology Eindhoven, The Netherlands, 5600MB Abstract The paper

More information

The Typed Racket Guide

The Typed Racket Guide The Typed Racket Guide Version 5.3.6 Sam Tobin-Hochstadt and Vincent St-Amour August 9, 2013 Typed Racket is a family of languages, each of which enforce

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

Graphical Untyped Lambda Calculus Interactive Interpreter

Graphical Untyped Lambda Calculus Interactive Interpreter Graphical Untyped Lambda Calculus Interactive Interpreter (GULCII) Claude Heiland-Allen https://mathr.co.uk mailto:claude@mathr.co.uk Edinburgh, 2017 Outline Lambda calculus encodings How to perform lambda

More information

Haskell 98 in short! CPSC 449 Principles of Programming Languages

Haskell 98 in short! CPSC 449 Principles of Programming Languages Haskell 98 in short! n Syntax and type inferencing similar to ML! n Strongly typed! n Allows for pattern matching in definitions! n Uses lazy evaluation" F definition of infinite lists possible! n Has

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

Chapter 3 Image Enhancement in the Spatial Domain

Chapter 3 Image Enhancement in the Spatial Domain Chapter 3 Image Enhancement in the Spatial Domain Yinghua He School o Computer Science and Technology Tianjin University Image enhancement approaches Spatial domain image plane itsel Spatial domain methods

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

Formalizing Cardinality-based Feature Models and their Staged Configuration

Formalizing Cardinality-based Feature Models and their Staged Configuration Formalizing Cardinality-based Feature Models and their Staged Coniguration Krzyszto Czarnecki, Simon Helsen, and Ulrich Eisenecker 2 University o Waterloo, Canada 2 University o Applied Sciences Kaiserslautern,

More information

Lecture 4: Higher Order Functions

Lecture 4: Higher Order Functions Lecture 4: Higher Order Functions Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 26, 2017 HIGHER ORDER FUNCTIONS The order of a function

More information

Lambda Calculus. CS 550 Programming Languages Jeremy Johnson

Lambda Calculus. CS 550 Programming Languages Jeremy Johnson Lambda Calculus CS 550 Programming Languages Jeremy Johnson 1 Lambda Calculus The semantics of a pure functional programming language can be mathematically described by a substitution process that mimics

More information

The λ-calculus. 1 Background on Computability. 2 Some Intuition for the λ-calculus. 1.1 Alan Turing. 1.2 Alonzo Church

The λ-calculus. 1 Background on Computability. 2 Some Intuition for the λ-calculus. 1.1 Alan Turing. 1.2 Alonzo Church The λ-calculus 1 Background on Computability The history o computability stretches back a long ways, but we ll start here with German mathematician David Hilbert in the 1920s. Hilbert proposed a grand

More information

Lambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6

Lambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6 Lambda calculus Advanced functional programming - Lecture 6 Wouter Swierstra and Alejandro Serrano 1 Today Lambda calculus the foundation of functional programming What makes lambda calculus such a universal

More information

Typed Racket: Racket with Static Types

Typed Racket: Racket with Static Types Typed Racket: Racket with Static Types Version 5.0.2 Sam Tobin-Hochstadt November 6, 2010 Typed Racket is a family of languages, each of which enforce that programs written in the language obey a type

More information

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dk The most popular purely functional, lazy programming language Functional programming language : a program

More information

foldr CS 5010 Program Design Paradigms Lesson 5.4

foldr CS 5010 Program Design Paradigms Lesson 5.4 oldr CS 5010 Program Design Paradigms Lesson 5.4 Mitchell Wand, 2012-2014 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. 1 Introduction In this lesson,

More information

Lists. Michael P. Fourman. February 2, 2010

Lists. Michael P. Fourman. February 2, 2010 Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce

More information

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

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 18 Thursday, March 29, 2018 In abstract algebra, algebraic structures are defined by a set of elements and operations

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

4/19/2018. Chapter 11 :: Functional Languages

4/19/2018. Chapter 11 :: Functional Languages Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Historical Origins The imperative and functional models grew out of work undertaken by Alan Turing, Alonzo Church, Stephen

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

More information

An introduction introduction to functional functional programming programming using usin Haskell

An introduction introduction to functional functional programming programming using usin Haskell An introduction to functional programming using Haskell Anders Møller amoeller@cs.au.dkau Haskell The most popular p purely functional, lazy programming g language Functional programming language : a program

More information

Encryption as an Abstract Datatype:

Encryption as an Abstract Datatype: June 2003 1/18 Outline Encryption as an Abstract Datatype: an extended abstract Dale Miller INRIA/Futurs/Saclay and École polytechnique 1. Security protocols specified using multisets rewriting. 2. Eigenvariables

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

LECTURE 16. Functional Programming

LECTURE 16. Functional Programming LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative

More information

1.3. Conditional expressions To express case distinctions like

1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

More information

Programming Language Concepts: Lecture 14

Programming Language Concepts: Lecture 14 Programming Language Concepts: Lecture 14 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 14, 11 March 2009 Function programming

More information

A Fault Model Centered Modeling Framework for Self-healing Computing Systems

A Fault Model Centered Modeling Framework for Self-healing Computing Systems A Fault Model Centered Modeling Framework or Sel-healing Computing Systems Wei Lu 1, Yian Zhu 1, Chunyan Ma 1, and Longmei Zhang 2 1 Department o Sotware and Microelectronics, Northwestern Polytechnical

More information

Introduction to Programming, Aug-Dec 2006

Introduction to Programming, Aug-Dec 2006 Introduction to Programming, Aug-Dec 2006 Lecture 3, Friday 11 Aug 2006 Lists... We can implicitly decompose a list into its head and tail by providing a pattern with two variables to denote the two components

More information

Regenerating Codes for Errors and Erasures in Distributed Storage

Regenerating Codes for Errors and Erasures in Distributed Storage Regenerating Codes or Errors and Erasures in Distributed Storage K V Rashmi, Nihar B Shah, Kannan Ramchandran, Fellow, IEEE, and P Vijay Kumar, Fellow, IEEE arxiv:0050v csit] 3 May 0 Abstract Regenerating

More information

Neighbourhood Operations

Neighbourhood Operations Neighbourhood Operations Neighbourhood operations simply operate on a larger neighbourhood o piels than point operations Origin Neighbourhoods are mostly a rectangle around a central piel Any size rectangle

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

Programming with Math and Logic

Programming with Math and Logic .. Programming with Math and Logic an invitation to functional programming Ed Morehouse Wesleyan University The Plan why fp? terms types interfaces The What and Why of Functional Programming Computing

More information

A Typed Calculus Supporting Shallow Embeddings of Abstract Machines

A Typed Calculus Supporting Shallow Embeddings of Abstract Machines A Typed Calculus Supporting Shallow Embeddings of Abstract Machines Aaron Bohannon Zena M. Ariola Amr Sabry April 23, 2005 1 Overview The goal of this work is to draw a formal connection between steps

More information

Structural polymorphism in Generic Haskell

Structural polymorphism in Generic Haskell Structural polymorphism in Generic Haskell Andres Löh andres@cs.uu.nl 5 February 2005 Overview About Haskell Genericity and other types of polymorphism Examples of generic functions Generic Haskell Overview

More information

Introduction to the λ-calculus

Introduction to the λ-calculus Announcements Prelim #2 issues: o Problem 5 grading guide out shortly o Problem 3 (hashing) issues Will be on final! Friday RDZ office hours are 11-12 not 1:30-2:30 1 Introduction to the λ-calculus Today

More information

Type-safe Functional Strategies

Type-safe Functional Strategies Chapter 1 Type-safe Functional Strategies Ralf Lämmel 1 and Joost Visser 1 Abstract: We demonstrate how the concept of strategies originating from term rewriting can be introduced in a typed, functional

More information

CS 161: Design and Analysis of Algorithms

CS 161: Design and Analysis of Algorithms CS 161: Design and Analysis o Algorithms Announcements Homework 3, problem 3 removed Greedy Algorithms 4: Human Encoding/Set Cover Human Encoding Set Cover Alphabets and Strings Alphabet = inite set o

More information

15 212: Principles of Programming. Some Notes on Continuations

15 212: Principles of Programming. Some Notes on Continuations 15 212: Principles of Programming Some Notes on Continuations Michael Erdmann Spring 2011 These notes provide a brief introduction to continuations as a programming technique. Continuations have a rich

More information

A Proposed Approach for Solving Rough Bi-Level. Programming Problems by Genetic Algorithm

A Proposed Approach for Solving Rough Bi-Level. Programming Problems by Genetic Algorithm Int J Contemp Math Sciences, Vol 6, 0, no 0, 45 465 A Proposed Approach or Solving Rough Bi-Level Programming Problems by Genetic Algorithm M S Osman Department o Basic Science, Higher Technological Institute

More information

Functional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur

Functional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur Functional Programming and λ Calculus Amey Karkare Dept of CSE, IIT Kanpur 0 Software Development Challenges Growing size and complexity of modern computer programs Complicated architectures Massively

More information

Lecture Notes on Static Single Assignment Form

Lecture Notes on Static Single Assignment Form Lecture Notes on Static Single Assignment Form 15-411: Compiler Design Frank Pfenning Lecture 6 September 12, 2013 1 Introduction In abstract machine code of the kind we have discussed so far, a variable

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

COMP 382: Reasoning about algorithms

COMP 382: Reasoning about algorithms Spring 2015 Unit 2: Models of computation What is an algorithm? So far... An inductively defined function Limitation Doesn t capture mutation of data Imperative models of computation Computation = sequence

More information

10. SOPC Builder Component Development Walkthrough

10. SOPC Builder Component Development Walkthrough 10. SOPC Builder Component Development Walkthrough QII54007-9.0.0 Introduction This chapter describes the parts o a custom SOPC Builder component and guides you through the process o creating an example

More information

CSCC24 Functional Programming Scheme Part 2

CSCC24 Functional Programming Scheme Part 2 CSCC24 Functional Programming Scheme Part 2 Carolyn MacLeod 1 winter 2012 1 Based on slides from Anya Tafliovich, and with many thanks to Gerald Penn and Prabhakar Ragde. 1 The Spirit of Lisp-like Languages

More information

Accurate Step Counting

Accurate Step Counting Accurate Step Counting Catherine Hope and Graham Hutton School of Computer Science and IT University of Nottingham, UK {cvh,gmh}@cs.nott.ac.uk Abstract Starting with an evaluator for a language, an abstract

More information

4.5 Pure Linear Functional Programming

4.5 Pure Linear Functional Programming 4.5 Pure Linear Functional Programming 99 4.5 Pure Linear Functional Programming The linear λ-calculus developed in the preceding sections can serve as the basis for a programming language. The step from

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

Functional Programming

Functional Programming Functional Programming Overview! Functional vs. imperative programming! Fundamental concepts! Evaluation strategies! Pattern matching! Higher order functions! Lazy lists References! Richard Bird, Introduction

More information

A Requirement Specification Language for Configuration Dynamics of Multiagent Systems

A Requirement Specification Language for Configuration Dynamics of Multiagent Systems A Requirement Speciication Language or Coniguration Dynamics o Multiagent Systems Mehdi Dastani, Catholijn M. Jonker, Jan Treur* Vrije Universiteit Amsterdam, Department o Artiicial Intelligence, De Boelelaan

More information

PROGRAMMING IN HASKELL. Chapter 2 - First Steps

PROGRAMMING IN HASKELL. Chapter 2 - First Steps PROGRAMMING IN HASKELL Chapter 2 - First Steps 0 The Hugs System Hugs is an implementation of Haskell 98, and is the most widely used Haskell system; The interactive nature of Hugs makes it well suited

More information

Generic Programming With Dependent Types: II

Generic Programming With Dependent Types: II Generic Programming With Dependent Types: II Generic Haskell in Agda Stephanie Weirich University of Pennsylvania March 2426, 2010 SSGIP Generic-Haskell style generic programming in Agda Dependently-typed

More information

Accurate Step Counting

Accurate Step Counting Accurate Step Counting Catherine Hope and Graham Hutton University of Nottingham Abstract Starting with an evaluator for a language, an abstract machine for the same language can be mechanically derived

More information

CS Lecture 6: Map and Fold. Prof. Clarkson Spring Today s music: Selections from the soundtrack to 2001: A Space Odyssey

CS Lecture 6: Map and Fold. Prof. Clarkson Spring Today s music: Selections from the soundtrack to 2001: A Space Odyssey CS 3110 Lecture 6: Map and Fold Prof. Clarkson Spring 2015 Today s music: Selections from the soundtrack to 2001: A Space Odyssey Review Course so far: Syntax and semantics of (most of) OCaml Today: No

More information

The λ-calculus. 1 Background on Computability. 2 Programming Paradigms and Functional Programming. 1.1 Alan Turing. 1.

The λ-calculus. 1 Background on Computability. 2 Programming Paradigms and Functional Programming. 1.1 Alan Turing. 1. The λ-calculus 1 Background on Computability The history o computability stretches back a long ways, but we ll start here with German mathematician David Hilbert in the 1920s. Hilbert proposed a grand

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

Shell CSCE 314 TAMU. Haskell Functions

Shell CSCE 314 TAMU. Haskell Functions 1 CSCE 314: Programming Languages Dr. Dylan Shell Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions can

More information

Piecewise polynomial interpolation

Piecewise polynomial interpolation Chapter 2 Piecewise polynomial interpolation In ection.6., and in Lab, we learned that it is not a good idea to interpolate unctions by a highorder polynomials at equally spaced points. However, it transpires

More information

Typed Scheme: Scheme with Static Types

Typed Scheme: Scheme with Static Types Typed Scheme: Scheme with Static Types Version 4.1.1 Sam Tobin-Hochstadt October 5, 2008 Typed Scheme is a Scheme-like language, with a type system that supports common Scheme programming idioms. Explicit

More information

CFRP issues: Restart (2)

CFRP issues: Restart (2) ITU FRP 2010 Lecture 2: Yampa: Arrows-based FRP Henrik Nilsson School of Computer Science University of Nottingham, UK Outline CFRP issues Introduction to Yampa Arrows A closer look at Yampa CFRP issues:

More information

Lecture 5: Declarative Programming. The Declarative Kernel Language Machine. September 12th, 2011

Lecture 5: Declarative Programming. The Declarative Kernel Language Machine. September 12th, 2011 Lecture 5: Declarative Programming. The Declarative Kernel Language Machine September 12th, 2011 1 Lecture Outline Declarative Programming contd Dataflow Variables contd Expressions and Statements Functions

More information

Introduction. chapter Functions

Introduction. chapter Functions chapter 1 Introduction In this chapter we set the stage for the rest of the book. We start by reviewing the notion of a function, then introduce the concept of functional programming, summarise the main

More information

COMP3151/9151 Foundations of Concurrency Lecture 8

COMP3151/9151 Foundations of Concurrency Lecture 8 1 COMP3151/9151 Foundations of Concurrency Lecture 8 Liam O Connor CSE, UNSW (and data61) 8 Sept 2017 2 Shared Data Consider the Readers and Writers problem from Lecture 6: Problem We have a large data

More information

Introduction to Functional Programming in Haskell 1 / 56

Introduction to Functional Programming in Haskell 1 / 56 Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order

More information

CSE 3302 Programming Languages Lecture 8: Functional Programming

CSE 3302 Programming Languages Lecture 8: Functional Programming CSE 3302 Programming Languages Lecture 8: Functional Programming (based on the slides by Tim Sheard) Leonidas Fegaras University of Texas at Arlington CSE 3302 L8 Spring 2011 1 Functional Programming Languages

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

Towards a Safe Partial Evaluation of Lazy Functional Logic Programs

Towards a Safe Partial Evaluation of Lazy Functional Logic Programs WFLP 2007 Towards a Safe Partial Evaluation of Lazy Functional Logic Programs Sebastian Fischer 1 Department of Computer Science, University of Kiel Olshausenstr. 40, D-24098, Kiel, Germany Josep Silva

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

CS Lecture 6: Map and Fold. Prof. Clarkson Fall Today s music: Selections from the soundtrack to 2001: A Space Odyssey

CS Lecture 6: Map and Fold. Prof. Clarkson Fall Today s music: Selections from the soundtrack to 2001: A Space Odyssey CS 3110 Lecture 6: Map and Fold Prof. Clarkson Fall 2014 Today s music: Selections from the soundtrack to 2001: A Space Odyssey Review Features so far: variables, operators, let expressions, if expressions,

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

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

9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete

9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati Why study? Lambda calculus Syntax Evaluation Relationship to programming languages Church Rosser theorem Completeness of Lambda Calculus: Turing

More information

CS 440: Programming Languages and Translators, Spring 2019 Mon

CS 440: Programming Languages and Translators, Spring 2019 Mon Haskell, Part 4 CS 440: Programming Languages and Translators, Spring 2019 Mon 2019-01-28 More Haskell Review definition by cases Chapter 6: Higher-order functions Revisit currying map, filter Unnamed

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

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

Programming Language Pragmatics

Programming Language Pragmatics Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott Historical Origins The imperative and functional models grew out of work undertaken Alan Turing, Alonzo Church, Stephen

More information

Larger K-maps. So far we have only discussed 2 and 3-variable K-maps. We can now create a 4-variable map in the

Larger K-maps. So far we have only discussed 2 and 3-variable K-maps. We can now create a 4-variable map in the EET 3 Chapter 3 7/3/2 PAGE - 23 Larger K-maps The -variable K-map So ar we have only discussed 2 and 3-variable K-maps. We can now create a -variable map in the same way that we created the 3-variable

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

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

Lesson 4 Typed Arithmetic Typed Lambda Calculus

Lesson 4 Typed Arithmetic Typed Lambda Calculus Lesson 4 Typed Arithmetic Typed Lambda 1/28/03 Chapters 8, 9, 10 Outline Types for Arithmetic types the typing relation safety = progress + preservation The simply typed lambda calculus Function types

More information

Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Booleans and Short-Circuit Evaluation. Tuples as Values.

Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Booleans and Short-Circuit Evaluation. Tuples as Values. Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421d # true;; - : bool = true # false;; - : bool =

More information

Multi-paradigm Declarative Languages

Multi-paradigm Declarative Languages Michael Hanus (CAU Kiel) Multi-paradigm Declarative Languages ICLP 2007 1 Multi-paradigm Declarative Languages Michael Hanus Christian-Albrechts-University of Kiel Programming Languages and Compiler Construction

More information

Imperative Functional Programming

Imperative Functional Programming Imperative Functional Programming Uday S. Reddy Department of Computer Science The University of Illinois at Urbana-Champaign Urbana, Illinois 61801 reddy@cs.uiuc.edu Our intuitive idea of a function is

More information

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, "hi", 3.2), c 4, a 1, b 5} 9/10/2017 4

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, hi, 3.2), c 4, a 1, b 5} 9/10/2017 4 Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a # true;; - : bool = true # false;; - : bool

More information

Functional dependencies versus type families and beyond

Functional dependencies versus type families and beyond Functional dependencies versus type families and beyond Martin Sulzmann National University of Singapore Joint work with Tom Schrijvers Functional dependencies versus type families and beyond p.1 What

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