# Linear lambda calculus and PTIME-completeness

Size: px
Start display at page:

Transcription

1 Under consideration for publication in J. Functional Programming 1 Linear lambda calculus and PTIME-completeness HARRY G. MAIRSON Computer Science Department Volen Center for Complex Numbers Brandeis University Waltham, Massachusetts ( Abstract We give transparent proofs of the PTIME-completeness of two decision problems for terms in the λ-calculus. The first is a reproof of the theorem that type inference for the simplytyped λ-calculus is PTIME-complete. Our proof is interesting because it uses no more than the standard combinators Church knew of some 70 years ago, in which the terms are linear affine each bound variable occurs at most once. We then derive a modification of Church s coding of Booleans that is linear, where each bound variable occurs exactly once. A consequence of this construction is that any interpreter for linear λ-calculus requires polynomial time. The logical interpretation of this consequence is that the problem of normalizing proofnets for multiplicative linear logic (MLL) is also PTIME-complete. 1 Type inference for simply typed λ-calculus The Circuit Value Problem (CVP) is to determine the output of a circuit, given an input to that circuit. CVP is complete for PTIME, because polynomial-time computations can be described by polynomial-sized circuits (Ladner, 1975). The Cook-Levin NP-completeness theorem, it should be noticed, merely augments these circuits with extra inputs which correspond to nondeterministic choices during a polynomial-time computation. We show how to code CVP into simply-typed λ- terms, where both type inference and term evaluation are synonymous with circuit evaluation. The programs we write to evaluate circuits are not perverse: they are completely natural, and are built out of the standard Church coding of Boolean logic; see, e.g., (Hindley & Seldin, 1986). We use ML as a presentation device, without exploiting its let-polymorphism. That is, we use the convenience of naming to identify λ- terms of constant size, used to build circuits. Had we expanded the definitions, the term representing the circuit would grow by only a constant factor, and become harder to read. Here, then, are the standard, classical combinators, coded in ML:

2 2 H. G. Mairson - fun True x y= x; val True = fn : a -> b -> a - fun False x y= y; val False = fn : a -> b -> b - fun Not p= p False True; val Not = fn: (( a -> b -> b) -> ( c -> d -> c) -> e) -> e - fun And p q= p q False; val And = fn : ( a -> ( b -> c -> c) -> d) -> a -> d - fun Or p q= p True q; val Or = fn : (( a -> b -> a) -> c -> d) -> c -> d Read True as the constant if true, where if true then x else y reduces to x. Similarly, read the body of And as if p then q else False. Observe that True and False have different types. Notice the read-eval-print loop where the interpreter reads untyped code, and then returns procedures with inferred type information automatically computed. We already know from our study of the untyped λ-calculus how these terms work to code Boolean functions. However, when these functions are used, notice that they output functions as values; moreover, the principal types (i.e., the most general types, constrained only by the typing rules of the simplytyped lambda calculus, and nothing else) of these functions identify them uniquely as True or False: - Or False True; val True = fn : a -> b -> a - And True False; val False = fn : a -> b -> b - Not True; val False = fn : a -> b -> b As a consequence, while the compiler does not explicitly reduce the above expressions to normal form, hence computing an answer, its type inference mechanism implicitly carries out that reduction to normal form, expressed in the language of first-order unification. The computations over Boolean values can be understood in the context of the graph representations of the types (see Figure 1). Notice how the nodes in the type for And can be associated uniquely with subterms from the code for And a linearity very much in the spirit of linear logic. We now observe a certain weirdness: namely, that nonlinearity destroys the isomorphism between terms and types. Suppose we define a function Same that is a kind of identity function: - fun Same p= p True False; val Same = fn : (( a -> b -> a) -> ( c -> d -> d) -> e) -> e - Same True; val it = fn : a -> b -> a - Same False; val it = fn : a -> b -> b

3 Journal of Functional Programming 3 and p true false q pq x false pq false x y y Fig. 1. Graph representations of the terms and principal types of And, True, False or not true p p true q p true q false p true p false p false true Fig. 2. Graph representations of the terms and principal types of Or, Not. Now define a nonlinear function Weird that uses its input twice: - fun K x y= x; val K = fn : a -> b -> a - fun Weird p= K (Same p) (Not p); val Weird = fn : (( a -> a -> a) -> ( b -> b -> b) -> c) -> c - Weird True; val it = fn : a -> a -> a - Weird False; val it = fn : a -> a -> a Even though (Weird p) reduces to p, its type is not a function of p; thus the principal type no longer identifies the normal form. The problem with Weird is that its input occurs twice, and that each occurrence must have the same type. Thus the types of Same and Not are unified: each gets type (( a -> a -> a) -> ( b -> b -> b) -> c) -> c. And then Same p returns a value (True or False),

4 4 H. G. Mairson but always of type a -> a -> a. Notice also that defining fun AlsoWeird p= Or p p will produce a type error, for similar reasons. We fix this problem with a functional fanout gate which we callcopy, in the spirit of the duplication in the exponentials of linear logic: - fun Pair x y z= z x y; val Pair = fn : a -> b -> ( a -> b -> c) -> c - fun Copy p= p (Pair True True) (Pair False False); val Copy = fn : (((( a -> b -> a) -> ( c -> d -> c) -> e) -> e) -> ((( f -> g -> g) -> ( h -> i -> i) -> j) -> j) -> k) -> k - Copy True; val it = fn : (( a -> b -> a) -> ( c -> d -> c) -> e) -> e - Copy False; val it = fn : (( a -> b -> b) -> ( c -> d -> d) -> e) -> e Copy restores the linearity of terms, so that each variable occurs at most once. Now we can again compute unweirdly: - fun Unweird p= (Copy p) (fn p1=> fn p2=> K (Same p1) (Not p2)); val Unweird = fn : (((( a -> b -> a) -> ( c -> d -> c) -> e) -> e) -> ((( f -> g -> g) -> ( h -> i -> i) -> j) -> j) -> ((( k -> l -> k) -> ( m -> n -> n) -> o) -> (( p -> q -> q) -> ( r -> s -> r) -> t) -> o) -> u) -> u - Unweird True; val it = fn : a -> b -> a - Unweird False; val it = fn : a -> b -> b In this coding, Copy p produces a pair of values, each β-equivalent to p, but not sharing any type variables. The elements of the pair are bound to p1 and p2 respectively, and the computation thus proceeds linearly. A Boolean circuit can now be coded as a λ-term by labelling its (wire) edges and traversing them bottom-up, inserting logic gates and fanout gates appropriately. We consider the circuit example shown in Figure 3; the circuit is realized by the ML code - fun circuit e1 e2 e3 e4 e5 e6= let val e7= And e2 e3 in let val e8= And e4 e5 in let val (e9,e10)= Copy (And e7 e8) in let val e11= Or e1 e9 in let val e12= Or e10 e6 in Or e11 e12 end end end end end;

5 Journal of Functional Programming 5 e 1 e 2 e 3 e 4 e 5 e 6 ^ ^ e 7 e 8 ^ e 9 e 10 e 11 e 12 Fig. 3. Labelling of a Boolean circuit Removing the syntactic sugar of let, this essentially straight-line code compiles to the less comprehensible simply-typed term - fun circuit e1 e2 e3 e4 e5 e6= (fn e7=> (fn e8=> (Copy (And e7 e8)) (fn e9=> fn e10=> (fn e11=> (fn e12=> Or e11 e12) (Or e10 e6)) (Or e1 e9))) (And e4 e5)) (And e2 e3); The use of procedure naming is incidental: we could just plug in the code for the logic gates instead of using their names. We can now plug inputs into the circuit, and the type inference mechanism is forced to evaluate the circuit: - circuit False True True True True False; val it = fn : a -> b -> a The output is True True is the only closed, normal form with the given type! We can make the code for the circuit look even more like straight-line code by introducing the continuation-passing version of unary and binary Boolean functions: - fun cp1 fnc p k= k (fnc p); val cp1 = fn : ( a -> b) -> a -> ( b -> c) -> c - fun cp2 fnc p q k= k (fnc p q); val cp2 = fn : ( a -> b -> c) -> a -> b -> ( c -> d) -> d

6 6 H. G. Mairson - val Notgate= cp1 Not; val it = fn : (( a -> b -> b) -> ( c -> d -> c) -> e) -> ( e -> f) -> f - val Andgate= cp2 And; val it = fn : ( a -> ( b -> c -> c) -> d) -> a -> ( d -> e) -> e - val Orgate= cp2 Or; val it = fn : (( a -> b -> a) -> c -> d) -> c -> ( d -> e) -> e We now write instead: - fun circuit e1 e2 e3 e4 e5 e6= (Andgate e2 e3 (fn e7=> (Andgate e4 e5 (fn e8=> (Andgate e7 e8 (fn f=> Copy f (fn e9=> fn e10=> (Orgate e1 e9 (fn e11=> (Orgate e10 e6 (fn e12=> Or e11 e12)))))); val circuit = fn : (( a -> b -> a) -> c -> ( d -> e -> d) -> f -> g) -> ( h -> ( i -> j -> j) -> k -> ( l -> m -> m) -> ((( n -> o -> n) -> ( p -> q -> p) -> r) -> r) -> ((( s -> t -> t) -> ( u -> v -> v) -> w) -> w) -> ( c -> (( x -> y -> x) -> z -> f) -> g) -> ba) -> h -> ( bb -> ( bc -> bd -> bd) -> k) -> bb -> z -> ba - circuit False True True True True False; val it = fn : a -> b -> a Why does the above contruction imply a PTIME-completeness result for type inference? Containment in PTIME is well known for this problem, because type inference is synonymous with finding the solution to a set of first-order constraints over type variables, possibly constants, and the binary contructor. The PTIME-hardness is more interesting: a property φ is PTIME-hard if, given any fixed PTIME Turing machine M and an input x, the computation of M on x can be compiled, using O(log x ) space, into a problem instance I, where I has property φ iff M accepts x. The circuit value problem is such a problem: given circuit C and input v, is the output of C true? Such a circuit can be computed by a compiler using only logarithmic space, and a further logarithmic space algorithm (which we have essentially given here) compiles C and v into a λ-term E, where E has the principal type of True iff C outputs true on v. Composing these two compilers gives the PTIME-hardness of type inference. 2 Linear λ-calculus and multiplicative linear logic The above coding uses K-redexes as well as linearity in an essential way: the codings of True and False each discard one of their arguments. Now we construct Boolean terms and associated gates where each bound argument is used exactly once, so that we have constructions in linear λ-calculus. We then see that the process of normalizing terms is complete for PTIME.

7 Journal of Functional Programming 7 - fun True x y= Pair x y; val True = fn : a -> b -> ( a -> b -> c) -> c - fun False x y= Pair y x; val False = fn : a -> b -> ( b -> a -> c) -> c Observe that the Booleans are now coded by abstract pairs, where the first component is our old, real value, and the second is some kind of garbage that preserves linearity. Negation is easy: - fun Not P x y= P y x; val Not = fn : ( a -> b -> c) -> b -> a -> c - Not True; val False = fn : a -> b -> ( b -> a -> c) -> c - Not False; val True = fn : a -> b -> ( a -> b -> c) -> c Now consider what happens if we code Or P Q as P True Q it doesn t work. Observe that Or True False = True True False = Pair True False. In general, Or P Q will equal Pair (P Q) (P Q). The second component of the pair is garbage: we need to dispose of it while preserving linearity. The function id below turns Boolean garbage into the identity function: - fun I x= x; val I = fn : a -> a - fun id B= B I I I; val id = fn : (( a -> a) -> ( b -> b) -> ( c -> c) -> d) -> d - id True; val it = fn : a -> a - id False; val it = fn : a -> a We use id to collect garbage in Boolean gates: - fun Or P Q= P True Q (fn u=> fn v=> (id v) u); val Or = fn : (( a -> b -> ( a -> b -> c) -> c) -> d -> ( e -> (( f -> f) -> ( g -> g) -> ( h -> h) -> e -> i) -> i) -> j) -> d -> j - Or True False; val it = fn : a -> b -> ( a -> b -> c) -> c - Or False False; val it = fn : a -> b -> ( b -> a -> c) -> c - fun And P Q= P Q False (fn u=> fn v=> (id v) u); val And = fn : ( a -> ( b -> c -> ( c -> b -> d) -> d) -> ( e -> (( f -> f) -> ( g -> g) -> ( h -> h) -> e -> i) -> i) -> j) -> a -> j - And True True; val it = fn : a -> b -> ( a -> b -> c) -> c - And False True; val it = fn : a -> b -> ( b -> a -> c) -> c

8 8 H. G. Mairson Again, we have a gate that copies Boolean values, with a slightly more complicated garbage collector: - fun Copy P= P (Pair True True) (Pair False False) (fn U=> fn V=> U (fn u1=> fn u2=> V (fn v1=> fn v2=> (Pair ((id v1) u1) ((id v2) u2))))); val Copy = fn : (((( a -> b -> ( a -> b -> c) -> c) -> ( d -> e -> ( d -> e -> f) -> f) -> g) -> g) -> ((( h -> i -> ( i -> h -> j) -> j) -> ( k -> l -> ( l -> k -> m) -> m) -> n) -> n) -> ((( o -> p -> q) -> r) -> (((( s -> s) -> ( t -> t) -> ( u -> u) -> o -> v) -> (( w -> w) -> ( x -> x) -> ( y -> y) -> p -> z) -> ( v -> z -> ba) -> ba) -> q) -> r) -> bb) -> bb Now we take the continuation-passing versions of the logic gates: - val Notgate= cp1 Not; val Notgate = fn : ( a -> b -> c) -> (( b -> a -> c) -> d) -> d - val Orgate= cp2 Or; val Orgate = fn : (( a -> b -> ( a -> b -> c) -> c) -> d -> ( e -> (( f -> f) -> ( g -> g) -> ( h -> h) -> e -> i) -> i) -> j) -> d -> ( j -> k) -> k - val Andgate= cp2 And; val Andgate = fn : ( a -> ( b -> c -> ( c -> b -> d) -> d) -> ( e -> (( f -> f) -> ( g -> g) -> ( h -> h) -> e -> i) -> i) -> j) -> a -> ( j -> k) -> k Once again, we have a circuit simulator: - fun circuit e1 e2 e3 e4 e5 e6= Andgate e2 e3 (fn e7=> Andgate e4 e5 (fn e8=> Andgate e7 e8 (fn f=> Copy f (fn e9=> fn e10=> Orgate e1 e9 (fn e11=> Orgate e10 e6 (fn e12=> Or e11 e12)))))); val circuit = fn : (( a -> b -> ( a -> b -> c) -> c) -> d -> ( e -> (( f -> f) -> ( g -> g) -> ( h -> h) -> e -> i) -> i) -> ( j -> k -> ( j -> k -> l) -> l) -> m -> ( n -> (( o -> o) -> ( p -> p) -> ( q -> q) -> n -> r) -> r) -> s) -> ( t -> ( u -> v -> ( v -> u -> w) -> w) -> ( x -> (( y -> y) -> ( z -> z) -> ( ba -> ba) -> x -> bb) -> bb) -> bc -> ( bd -> be -> ( be -> bd -> bf) -> bf) -> ( bg -> (( bh -> bh) -> ( bi -> bi) -> ( bj -> bj) -> bg -> bk) -> bk) -> ((( bl -> bm -> ( bl -> bm -> bn) -> bn) -> ( bo -> bp -> ( bo -> bp -> bq) -> bq) -> br) -> br) -> ((( bs -> bt -> ( bt -> bs -> bu) -> bu) -> ( bv -> bw -> ( bw -> bv -> bx) -> bx) -> by) -> by) -> ((( bz -> ca -> cb) -> cc) -> (((( cd -> cd) -> ( ce -> ce) -> ( cf -> cf) -> bz -> cg) ->

9 Journal of Functional Programming 9 (( ch -> ch) -> ( ci -> ci) -> ( cj -> cj) -> ca -> ck) -> ( cg -> ck -> cl) -> cl) -> cb) -> cc) -> ( d -> (( cm -> cn -> ( cm -> cn -> co) -> co) -> cp -> ( cq -> (( cr -> cr) -> ( cs -> cs) -> ( ct -> ct) -> cq -> cu) -> cu) -> m) -> s) -> cv) -> t -> ( cw -> ( cx -> cy -> ( cy -> cx -> cz) -> cz) -> ( da -> (( db -> db) -> ( dc -> dc) -> ( dd -> dd) -> da -> de) -> de) -> bc) -> cw -> cp -> cv It is said that the proof of the pudding is in the tasting; here, the proof of the coding is in the testing: - circuit False True True True True False; val it = fn : a -> b -> ( a -> b -> c) -> c We further assert the following pearl theorem: the βη-normal form of any simplytyped, linear λ-term E, with or without free variables and K-redexes, may be inferred from only its principal type σ. Moreover, every linear term is simply typable (Hindley, 1989). Notice that it is the multiple occurrence of variables, (for example, in iterators such as Church numerals) which weakens this pearl theorem, and all that is left is parametricity, where the type indicates a property instead of identifying the exact normal form; see for instance (Mairson, 1991; Wadler, 1989). Multiple occurrences of a variable are also the way to make this problem one of typability; for example, in the non-affine coding presented in this section, we may define - fun Test p u v= (p u v) (fn a=> fn b=> b u); val Test = fn : ( a -> b -> ( c -> ( a -> d) -> d) -> e) -> a -> b -> e Then Test True has a type, but Test False does not. We conclude by mentioning some more technical connections of the above constructions to the normalization of proofs in linear logic. Every typed linear λ-term represents a proof in multiplicative linear logic (MLL) (Girard, 1987), where the conclusions of the proof represent the types of the free variables and output of a term, and the structure of the proof represents the term. Here is the logic: Γ, A, A Axiom A, A Γ, Cut Γ, A, B Γ,, A B Γ, A, B Γ, A B These rules can type graphs and graph reduction for linear λ-calculus, an expressive subset of MLL proofnets. A wire (Axiom rule) has (expression) type A in one direction, and (continuation) type A in the other. The Cut connects an expression to a continuation. The pairs a continuation and input for a function, and thus represents an application node. The unpairs them, representing a λ- node; the associated function can be thought of dually as either transforming the continuation, or the expression.

10 10 H. G. Mairson The reduction rule for this logic is like β-reduction in the λ-calculus. We negate variables appropriately to make this analogy transparent. Γ, B, A Γ,, B A Γ, Σ, Σ, A, B Σ, A B Cut Γ, B Σ, A, B Cut Γ, Σ, A, A Cut Γ, Σ, This says: to reduce the connecting of a function (of type A B) to an application context (of type B A), connect the output of the function (B) to the continuation (B ), and the input (A) to the parameter request of the function (A ). Every time an MLL proof is reduced, the proof gets smaller. Reduction is then easily seen to be polynomial time. Given that our circuit simulation is a linear λ-term, it is representable by an MLL proof. Thus proof(net) normalization for multiplicative linear logic is complete for polynomial time. We observe finally that with the introduction of second-order quantification in the style of System F (Girard, 1972), we can define the linear type Bool = α.α α α α, and give binary Boolean functions the uniform type Bool Bool Bool. The programming techniques we have described above then let us code projection functions of type Bool Bool Bool and duplication functions Bool Bool Bool, without weakening or contraction. In this limited way, we recover the features of exponentials from linear logic. This analysis is generalized in (Mairson & Terui, 2003), where the types other than Bool for which exponentials can be simulated are characterized; in addition, we show that light multiplicative linear logic, a proper subset of light affine logic (where copying is restricted), can represent all the PTIME functions. At this point, however, the discussion is no longer a pearl. Historical note. The analysis of type inference through linear λ-calculus is something I understood while working on this subject roughly a decade ago. While the linear features were very apparent, it is only recently that I saw the real connection with linear logic. The results of Section 1 were outlined in more technical terms in a paper joint with Fritz Henglein (Henglein & Mairson, 1994), where they were used to derive lower bounds on type inference for Systems F and F ω. I wish to acknowledge both his collaboration in this presentation, as well as the previous appearance of these ideas in this very Journal. I take the liberty of repeating them here it is not for nothing that this endeavor is called research not only because the ideas form a pearl that deserves to be known more widely, but also because the clarity of the original version in the Journal was lost due to numerous production errors.

11 Journal of Functional Programming 11 3 Acknowledgements I am deeply grateful to Kazushige Terui, whose invited lecture at the 2002 Linear Logic workshop in Copenhagen (Terui, 2002), as well as continued discussions afterwards, have inspired me to think more about many of these issues. References Girard, Jean-Yves (1972) Interprétation fonctionnelle et élimination des coupures de l arithmétique d ordre supérieur. Thèse de doctorat d état, Université Paris VII. Girard, Jean-Yves (1987) Linear logic. Theoretical Computer Science, 50. Henglein, Fritz, & Mairson, Harry G. (1994) The complexity of type inference for higherorder typed lambda calculi. Journal of Functional Programming, 4(4), Hindley, J. Roger (1989) BCK-combinators and linear lambda-terms have types. Theoretical Computer Science, 64(1), Hindley, J. Roger, & Seldin, Jonathan P. (1986) Introduction to combinatory logic and lambda calculus. Cambridge University Press. Ladner, Richard (1975) The circuit value problem is log space complete for P. SIGACT News (ACM Special Interest Group on Automata and Computability Theory), 7. Mairson, Harry G. (1991) Outline of a proof theory of parametricity. Proceedings of the International Conference on Functional Programming Languages and Computer Architecture, LNCS 523, Mairson, Harry G., & Terui, Kazushige (2003) On the computational complexity of cut elimination in linear logic. Proceedings of the 2003 Italian Conference on Theoretical Computer Science, LNCS 2841, Terui, Kazushige (2002) On the complexity of cut-elimination in linear logic (invited lecture). Federated Logic Conference (FLOC) 2002, Workshop on Linear Logic, Copenhagen. Wadler, Philip (1989) Theorems for free! Proceedings of the International Conference on Functional Programming Languages and Computer Architecture, ACM Press,

### 22ND CENTURY_J1.xls Government Site Hourly Rate

Escalation rate 000 AA0 Administrative Assistant Level I 000 AA0 Administrative Assistant Level II 000 AB0 Application Engineer Level I 000 AB0 Application Engineer Level II 000 AC0 Application Programmer

### Appendix 5-1: Attachment J.1 Pricing Table -1: IMS Ceiling Loaded Rates at Contractor Site

Appendix 5-1: Attachment J.1 Pricing Table -1: IMS Ceiling Loaded Rates at Contractor Site Escalation rate 4.6% 4.6% 4.6% 4.6% 4.6% 4.6% 4.6% 4.6% 4.6% 0001 AA01 Administrative Assistant Level I \$51.00

### SPARE CONNECTORS KTM 2014

SPAREPARTSCATALOG: // ENGINE ART.-NR.: 3208201EN CONTENT CONNECTORS FOR WIRING HARNESS AA-AN CONNECTORS FOR WIRING HARNESS AO-BC CONNECTORS FOR WIRING HARNESS BD-BQ CONNECTORS FOR WIRING HARNESS BR-CD

### SPAREPARTSCATALOG: CONNECTORS SPARE CONNECTORS KTM ART.-NR.: 3CM EN

SPAREPARTSCATALOG: CONNECTORS ART.-NR.: 3CM3208201EN CONTENT SPARE CONNECTORS AA-AN SPARE CONNECTORS AO-BC SPARE CONNECTORS BD-BQ SPARE CONNECTORS BR-CD 3 4 5 6 SPARE CONNECTORS CE-CR SPARE CONNECTORS

### Flow Analysis, Linearity and PTIME. David Van Horn and Harry Mairson

Flow Analysis, Linearity and PTIME David Van Horn and Harry Mairson What is a lower bound? Higher-order control-flow analysis in retrospect: Lessons learned, lessons abandoned. Shivers, Best of PLDI retrospective:

### Computer Science 190 (Autumn Term, 2010) Semantics of Programming Languages

Computer Science 190 (Autumn Term, 2010) Semantics of Programming Languages Course instructor: Harry Mairson (mairson@brandeis.edu), Volen 257, phone (781) 736-2724. Office hours Monday and Wednesday,

### DETAIL SPECIFICATION SHEET

INCH-POUND MIL-DTL-55302/128D 18 April 2013 SUPERSEDING MIL-DTL-55302/128D 4 June 2004 DETAIL SPECIFICATION SHEET CONNECTORS, PRINTED CIRCUIT SUBASSEMBLY AND ACCESSORIES: RECEPTACLE, DOUBLE ROW, 4 THROUGH

### Definability and full abstraction in lambda-calculi

Definability and full abstraction in lambda-calculi Antonio Bucciarelli Laboratoire Preuves, Programmes et Systèmes Université Paris Diderot Outline 1 Introduction 2 The full abstraction problem for PCF

### Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.

Goal Understand what this interface means and why it matters: CS152: Programming Languages Lecture 15 Parametric Polymorphism Dan Grossman Spring 2011 type a mylist; val mt_list : a mylist val cons : a

### Level instruments. Communications and Displays SITRANS RD200. 5/306 Siemens FI Technical specifications. Overview

Overview The is a universal input, panel mount remote digital display for process instrumentation. Benefits Easy setup and programming via front panel buttons or remotely using RD software Display readable

### Relating Complexity and Precision in Control Flow Analysis

Relating Complexity and Precision in Control Flow Analysis David Van Horn Harry G. Mairson Brandeis University {dvanhorn,mairson}cs.brandeis.edu Abstract We analyze the computational complexity of kcfa,

### Lecture slides & distribution files:

Type Theory Lecture slides & distribution files: http://www.cs.rhul.ac.uk/home/zhaohui/ttlectures.html Zhaohui Luo Department of Computer Science Royal Holloway, University of London April 2011 2 Type

### Parts List, Charging Chart, Wiring Diagrams

Parts List, Charging Chart, Wiring Diagrams PHH150, PHH180 3 Phase PACKAGE HEAT PUMP UNITS TABLE OF CONTENTS PARTS LIST------------ 2-5 PARTS DRAWING - - - - - - -6-16 CHARGING CHARTS - - - - - - - 17

### Lecture 5: The Untyped λ-calculus

Lecture 5: The Untyped λ-calculus Syntax and basic examples Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Pratikakis (CSD) Untyped λ-calculus I CS49040,

### 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

### 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

### 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

### n λxy.x n y, [inc] [add] [mul] [exp] λn.λxy.x(nxy) λmn.m[inc]0 λmn.m([add]n)0 λmn.n([mul]m)1

LAMBDA CALCULUS 1. Background λ-calculus is a formal system with a variety of applications in mathematics, logic, and computer science. It examines the concept of functions as processes, rather than the

### 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

### Industrial Wireway & Trough

308 Lay-In Wireway 1485 Series - NEMA 12... 310-319 Wiring Trough 1486 Series - NEMA 12... 320 Pull Through Wireway 1487 Series - NEMA 12... 322-328 309 1485 Series Lay-In Wireway - NEMA 12 Lay-In Wireway

### A New Proof of P-time Completeness of Linear Lambda Calculus

A New Proof of P-time Completeness of Linear Lambda Calculus National Institute of Advanced Industrial Science and Technology (AIST), 1-1-1 Umezono, Tsukuba, Ibaraki, 305-8563 Japan arxiv:1301.2763v1 [cs.lo]

### NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT 3SAT The 3SAT problem is the following. INSTANCE : Given a boolean expression E in conjunctive normal form (CNF) that is the conjunction of clauses, each

### An Introduction to Type Inference

Sebastian Zimmeck An Introduction to Type Inference Professor Alfred V. Aho - COMS E6998-2 Advanced Topics in Programming Languages and Compilers November 29, 2011 Presentation Overview 1. Introduction

### Working with Data sent to a Computer or Flash Stick

Working with Data sent to a Computer or Flash Stick File Names and File Formats Data sent to a flash stick is saved as a.txt file. The file name for the saved file is in the format: DATA FILE TYPE Send

### ILOC is a suite of three hierarchical software tools. At the core, the Boundary Logic Engine (Losp) provides Boolean minimization of logic function

PUN FORMAT William Bricken August 2003 CONTENTS ILOC Models Modeling Circuits The Advantage of Boundary Logic Representations Parens Notation Parens Semantics Pun Notation Majority Example Dnets Extruded

### Construction. Quality Products. Service Excellence.

1485 Series - NEMA 12 www.hammondmfg.com Application Designed to enclose and protect electrical wiring from dirt, dust, oil and water. All sections and fi ttings are completely open on each side to allow

### A. All equipment and materials used shall be standard components that are regularly manufactured and used in the manufacturer s system.

ENDURA EE500 SERIES ENDURAXPRESS TECHNICAL SPECIFICATIONS SECURITY SYSTEM DIVISION 28 ELECTRONIC SAFETY AND SECURITY LEVEL 1_28 20 00 ELECTRONIC SURVEILLANCE LEVEL 2_28 23 00 VIDEO SURVEILLANCE LEVEL 3_28

### 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

### 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,

### Type Checking and Type Inference

Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled

### 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

### 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

### NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

CS 787: Advanced Algorithms NP-Hardness Instructor: Dieter van Melkebeek We review the concept of polynomial-time reductions, define various classes of problems including NP-complete, and show that 3-SAT

### An LCF-Style Interface between HOL and First-Order Logic

An LCF-Style Interface between HOL and First-Order Logic Joe Hurd Computer Laboratory University of Cambridge, joe.hurd@cl.cam.ac.uk 1 Introduction Performing interactive proof in the HOL theorem prover

### Where is ML type inference headed?

1 Constraint solving meets local shape inference September 2005 2 Types are good A type is a concise description of the behavior of a program fragment. Typechecking provides safety or security guarantees.

### 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

### 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

### ML Has Principal Typings

Electronic Notes in Theoretical Computer Science 38 (2005) URL: http://www.elsevier.nl/locate/entcs/volume38.html ML Has Principal Typings Carlos Camarão and Lucília Figueiredo Abstract Is there a type

### 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

### Type Checking and Inference Are Equivalent in Lambda Calculi with Existential Types

Type Checking and Inference Are Equivalent in Lambda Calculi with Existential Types Yuki Kato and Koji Nakazawa Graduate School of Informatics, Kyoto University, Kyoto 606-8501, Japan Abstract. This paper

### SMAJ SERIES 400 Watts Suface Mount Transient Voltage Suppressor SMA/DO-214AC. RoHS. Features

Pb RoHS COMPLIANCE creat by art SMAJ SERIES 4 Watts Suface Mount Transient Voltage Suppressor SMA/DO-214AC Features UL Recognized File # E-326243 Low profile package Built-in strain relief Glass passivated

### 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.

### BOOK-IT 8.0. SIP2 implementation in the Z39.70 server

BOOK-IT 8.0 2015-07-29 Axiell Sverige AB, Box 24014, 224 21 LUND. Besöksadress: Fältspatsvägen 4, 224 78 LUND Tel 046-270 04 00, e-post: axiellsverige@axiell.com, www.axiell.se Table of contents 1 Introduction...

### CSE-321 Programming Languages 2010 Final

Name: Hemos ID: CSE-321 Programming Languages 2010 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 18 28 16 12 36 40 150 There are six problems on 16 pages, including two work sheets, in

### 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,

### 2-Type Series Pressurized Closures

2-Type Series Pressurized Closures A complete pressure tight reenterable closure system for enclosing spliced connections of communications cables in a wide variety of applications. The 2-type Closure

### 6.896 Topics in Algorithmic Game Theory March 1, Lecture 8

6.896 Topics in Algorithmic Game Theory March 1, 2010 Lecture 8 Lecturer: Constantinos Daskalakis Scribe: Alan Deckelbaum, Anthony Kim NOTE: The content of these notes has not been formally reviewed by

### Harvard School of Engineering and Applied Sciences Computer Science 152

Harvard School of Engineering and Applied Sciences Computer Science 152 Lecture 17 Tuesday, March 30, 2010 1 Polymorph means many forms. Polymorphism is the ability of code to be used on values of different

### 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,

### Recursive Definitions, Fixed Points and the Combinator

Recursive Definitions, Fixed Points and the Combinator Dr. Greg Lavender Department of Computer Sciences University of Texas at Austin Recursive Self-Reference Recursive self-reference occurs regularly

### dynamically typed dynamically scoped

Reference Dynamically Typed Programming Languages Part 1: The Untyped λ-calculus Jim Royer CIS 352 April 19, 2018 Practical Foundations for Programming Languages, 2/e, Part VI: Dynamic Types, by Robert

### (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

### W[1]-hardness. Dániel Marx 1. Hungarian Academy of Sciences (MTA SZTAKI) Budapest, Hungary

W[1]-hardness Dániel Marx 1 1 Institute for Computer Science and Control, Hungarian Academy of Sciences (MTA SZTAKI) Budapest, Hungary School on Parameterized Algorithms and Complexity Będlewo, Poland

### 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.

### 9.1 Cook-Levin Theorem

CS787: Advanced Algorithms Scribe: Shijin Kong and David Malec Lecturer: Shuchi Chawla Topic: NP-Completeness, Approximation Algorithms Date: 10/1/2007 As we ve already seen in the preceding lecture, two

### Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Suggested Reading: Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.438 Algorithms For Inference Fall 2014 Probabilistic Modelling and Reasoning: The Junction

### DATA SUPPORT SPECIALIST CERTIFICATE PRODUCTIVITY SOFTWARE CERTIFICATE

Requirements DATA SUPPORT SPECIALIST CERTIFICATE Required s (C25500A) 18 BAS 110 3 Business Analytics I CTI 110 3 Web, Programming and DB Foundations DBA 110 3 Database Concepts DBA 120 3 Database Programming

### Writing code that I'm not smart enough to write. A funny thing happened at Lambda Jam

Writing code that I'm not smart enough to write A funny thing happened at Lambda Jam Background "Let s make a lambda calculator" Rúnar Bjarnason Task: write an interpreter for the lambda calculus Lambda

### Lecture 14: Lower Bounds for Tree Resolution

IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Advanced Course on Computational Complexity Lecture 14: Lower Bounds for Tree Resolution David Mix Barrington and Alexis Maciel August

### Lecture 15 CIS 341: COMPILERS

Lecture 15 CIS 341: COMPILERS Announcements HW4: OAT v. 1.0 Parsing & basic code generation Due: March 28 th No lecture on Thursday, March 22 Dr. Z will be away Zdancewic CIS 341: Compilers 2 Adding Integers

### A Quick Overview. CAS 701 Class Presentation 18 November Department of Computing & Software McMaster University. Church s Lambda Calculus

A Quick Overview CAS 701 Class Presentation 18 November 2008 Lambda Department of Computing & Software McMaster University 1.1 Outline 1 2 3 Lambda 4 5 6 7 Type Problem Lambda 1.2 Lambda calculus is a

### Topic 3: Propositions as types

Topic 3: Propositions as types May 18, 2014 Propositions as types We have seen that the main mathematical objects in a type theory are types. But remember that in conventional foundations, as based on

### Lecture 3: Recursion; Structural Induction

15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion

### 1 Definition of Reduction

1 Definition of Reduction Problem A is reducible, or more technically Turing reducible, to problem B, denoted A B if there a main program M to solve problem A that lacks only a procedure to solve problem

### Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)

Fundamentals and lambda calculus Deian Stefan (adopted from my & Edward Yang s CSE242 slides) Logistics Assignments: Programming assignment 1 is out Homework 1 will be released tomorrow night Podcasting:

### Types and Type Inference

CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of

Advances in Programming Languages Lecture 4: Higher Polymorphism Ian Stark School of Informatics The University of Edinburgh Friday 30 September 2016 Semester 1 Week 2 https://blog.inf.ed.ac.uk/apl16 Topic:

### 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

### Second-Order Type Systems

#1 Second-Order Type Systems Homework 5 Summary Student : 37.9704 Student : 44.4466 ORIGINAL : 50.2442 Student : 50.8275 Student : 50.8633 Student : 50.9181 Student : 52.1347 Student : 52.1633 Student

### W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

1 W[1]-hardness Dániel Marx Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017 2 Lower bounds So far we have seen positive results: basic algorithmic techniques for fixed-parameter

### Simply-Typed Lambda Calculus

#1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What

### 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

### The Encoding Complexity of Network Coding

The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

### Recitation 4: Elimination algorithm, reconstituted graph, triangulation

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.438 Algorithms For Inference Fall 2014 Recitation 4: Elimination algorithm, reconstituted graph, triangulation

Loop Qualification Bulk Loader Carrier Services Frontier Communications Rochester, NY Effective: 06/18/2017 Revised: 10/26/2017 Contents Overview... 3 Bulk Loader Window... 4 Bulk Loader File Status...

### Categorical models of type theory

1 / 59 Categorical models of type theory Michael Shulman February 28, 2012 2 / 59 Outline 1 Type theory and category theory 2 Categorical type constructors 3 Dependent types and display maps 4 Fibrations

### Control Flow Analysis with SAT Solvers

Control Flow Analysis with SAT Solvers Steven Lyde, Matthew Might University of Utah, Salt Lake City, Utah, USA Abstract. Control flow analyses statically determine the control flow of programs. This is

### CS 6110 S11 Lecture 12 Naming and Scope 21 February 2011

CS 6110 S11 Lecture 12 Naming and Scope 21 February 2011 In this lecture we introduce the topic of scope in the context of the λ-calculus and define translations from λ-cbv to FL for the two most common

### Type Inference with Inequalities

Type Inference with Inequalities Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department Aarhus University Ny Munkegade DK-8000 Århus C, Denmark Abstract Type inference can be phrased as constraint-solving

### 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)

### 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

### FINDING SEMI-TRANSITIVE ORIENTATIONS OF GRAPHS

FINDING SEMI-TRANSITIVE ORIENTATIONS OF GRAPHS MEGAN GALLANT Abstract. Given any graph, how do we determine whether it is semi-transitive or not. In this paper, I give a method to determine the semi-transitive

### SAT-CNF Is N P-complete

SAT-CNF Is N P-complete Rod Howell Kansas State University November 9, 2000 The purpose of this paper is to give a detailed presentation of an N P- completeness proof using the definition of N P given

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

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

### Exceptions Are Strictly More Powerful Than Call/CC

Exceptions Are Strictly More Powerful Than Call/CC Mark Lillibridge July 1995 CMU CS 95 178 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Also appears as Fox Memorandum CMU-CS-FOX-95-03.

### Proofs-Programs correspondance and Security

Proofs-Programs correspondance and Security Jean-Baptiste Joinet Université de Lyon & Centre Cavaillès, École Normale Supérieure, Paris Third Cybersecurity Japanese-French meeting Formal methods session

### MLL normalization and transitive closure: circuits, complexity, and Euler tours. Harry Mairson

MLL normalization and transitive closure: circuits, complexity, and Euler tours Harry Mairson Problem: Given a proofnet in multiplicative linear logic (MLL), what is the computational complexity of determining

### Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

20170926 CNF-SAT: CNF-SAT is a problem in NP, defined as follows: Let E be a Boolean expression with m clauses and n literals (literals = variables, possibly negated), in which - each clause contains only

### How Computers Work. Processor and Main Memory. Roger Young

How Computers Work Processor and Main Memory Roger Young Copyright 2001, Roger Stephen Young All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted by

### More Lambda Calculus and Intro to Type Systems

More Lambda Calculus and Intro to Type Systems Plan Heavy Class Participation Thus, wake up! Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems Overview Static, Dyamic

### NP-completeness of 4-incidence colorability of semi-cubic graphs

Discrete Mathematics 08 (008) 0 www.elsevier.com/locate/disc Note NP-completeness of -incidence colorability of semi-cubic graphs Xueliang Li, Jianhua Tu Center for Combinatorics and LPMC, Nankai University,

### 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

### Higher-Order Logic. Specification and Verification with Higher-Order Logic

Higher-Order Logic Specification and Verification with Higher-Order Logic Arnd Poetzsch-Heffter (Slides by Jens Brandt) Software Technology Group Fachbereich Informatik Technische Universität Kaiserslautern

### CS 6110 S14 Lecture 1 Introduction 24 January 2014

CS 6110 S14 Lecture 1 Introduction 24 January 2014 1 Introduction What is a program? Is it just something that tells the computer what to do? Yes, but there is much more to it than that. The basic expressions

### Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,

Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety

### Functional Languages. Hwansoo Han

Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm