Save this PDF as:

Size: px
Start display at page:

Transcription

1 Computational lambda-calculus and monads Eugenio Moggi Lab. for Found. of Comp. Sci. University of Edinburgh EH9 3JZ Edinburgh, UK On leave from Univ. di Pisa Abstract The λ-calculus is considered an useful mathematical tool in the study of programming languages. However, if one uses βη-conversion to prove equivalence of programs, then a gross simplification 1 is introduced. We give a calculus based on a categorical semantics for computations, which provides a correct basis for proving equivalence of programs, independent from any specific computational model. Introduction This paper is about logics for reasoning about programs, in particular for proving equivalence of programs. Following a consolidated tradition in theoretical computer science we identify programs with the closed λ-terms, possibly containing extra constants, corresponding to some features of the programming language under consideration. There are three approaches to proving equivalence of programs: The operational approach starts from an operational semantics, e.g. a partial function mapping every program (i.e. closed term) to its resulting value (if any), which induces a congruence relation on open terms called operational equivalence (see e.g. [10]). Then the problem is to prove that two terms are operationally equivalent. The denotational approach gives an interpretation of the (programming) language in a mathematical structure, the intended model. Then the problem is to prove that two terms denote the same object in the intended model. Research partially supported by EEC Joint Collaboration Contract # ST2J-0374-C(EDB). 1 Programs are identified with total functions from values to values. The logical approach gives a class of possible models for the language. Then the problem is to prove that two terms denotes the same object in all possible models. The operational and denotational approaches give only a theory (the operational equivalence and the set T h of formulas valid in the intended model respectively), and they (especially the operational approach) deal with programming languages on a rather case-by-case basis. On the other hand, the logical approach gives a consequence relation (Ax A iff the formula A is true in all models of the set of formulas Ax), which can deal with different programming languages (e.g. functional, imperative, non-deterministic) in a rather uniform way, by simply changing the set of axioms Ax, and possibly extending the language with new constants. Moreover, the relation is often semidecidable, so it is possible to give a sound and complete formal system for it, while T h and are semidecidable only in oversimplified cases. We do not take as a starting point for proving equivalence of programs the theory of βη-conversion, which identifies the denotation of a program (procedure) of type A B with a total function from A to B, since this identification wipes out completely behaviours like non-termination, non-determinism or side-effects, that can be exhibited by real programs. Instead, we proceed as follows: 1. We take category theory as a general theory of functions and develop on top a categorical semantics of computations based on monads. 2. We consider how the categorical semantics should be extended to interpret λ-calculus. At the end we get a formal system, the computational lambda-calculus (λ c -calculus for short), for proving equivalence of programs, which is sound and complete w.r.t. the categorical semantics of computations. 1

2 The methodology outlined above is inspired by [13] 2, and it is followed in [11, 8] to obtain the λ p -calculus. The view that category theory comes, logically, before the λ-calculus led us to consider a categorical semantics of computations first, rather than to modify directly the rules of βη-conversion to get a correct calculus. A type theoretic approach to partial functions and computations is attempted in [1] by introducing a type constructor Ā, whose intuitive meaning is the set of computations of type A. Our categorical semantics is based on a similar idea. Constable and Smith, however, do not adequately capture the general axioms for computations (as we do), since they lack a general notion of model and rely instead on operational, domainand recursion-theoretic intuition. 1 A categorical semantics of computations The basic idea behind the semantics of programs described below is that a program denotes a morphism from A (the object of values of type A) to T B (the object of computations of type B). This view of programs corresponds to call-by-value parameter passing, but there is an alternative view of programs as functions from computations to computations corresponding to call-by-name (see [10]). In any case, the real issue is that the notions of value and computation should not be confused. By taking callby-value we can stress better the importance of values. Moreover, call-by-name can be more easily represented in call-by-value than the other way around. There are many possible choices for T B corresponding to different notions of computations, for instance in the category of sets the set of partial computations (of type B) is the lifting B + { } and the set of non-deterministic computations is the powerset P(B). Rather than focus on specific notions of computations, we will identify the general properties that the object T B of computations must have. The basic requirement is that programs should form a category, and the obvious choice for it is the Kleisli category for a monad. Definition 1.1 A monad over a category C is a triple (T, η, µ), where T : C C is a functor, η: Id C. 2 I am trying to find out where λ-calculus should come from, and the fact that the notion of a cartesian closed category is a late developing one (Eilenberg & Kelly (1966)), is not relevant to the argument: I shall try to explain in my own words in the next section why we should look to it first. T and µ: T 2. T are natural transformations and the following equations hold: µ T A ; µ A = T (µ A ); µ A η T A ; µ A = id T A = T (η A ); µ A A computational model is a monad (T, η, µ) satisfying the mono requirement: η A is a mono for every A C. There is an alternative description of a monad (see [7]), which is easier to justify computationally. Definition 1.2 A Kleisli triple over C is a triple (T, η, ), where T : Obj(C) Obj(C), η A : A T A, f : T A T B for f: A T B and the following equations hold: η A = id T A η A ; f = f f ; g = (f; g ) Every Kleisli triple (T, η, ) corresponds to a monad (T, η, µ) where T (f: A B) = (f; η B ) and µ A = id T A. Intuitively η A is the inclusion of values into computations and f is the extension of a function f from values to computations to a function from computations to computations, which first evaluates a computation and then applies f to the resulting value. The equations for Kleisli triples say that programs form a category, the Kleisli category C T, where the set C T (A, B) of morphisms from A to B is C(A, T B), the identity over A is η A and composition of f followed by g is f; g. Although the mono requirement is very natural there are cases in which it seems appropriate to drop it, for instance: it may not be satisfied by the monad of continuations. Before going into more details we consider some examples of monads over the category of sets. Example 1.3 Non-deterministic computations: T ( ) is the covariant powerset functor, i.e. T (A) = P(A) and T (f)(x) is the image of X along f η A (a) is the singleton {a} µ A (X) is the big union X Computations with side-effects: T ( ) is the functor ( S) S, where S is a nonempty set of stores. Intuitively a computation takes a store and returns a value together with the modified store.

3 η A (a) is (λs: S. a, s ) µ A (f) is (λs: S.eval(fs)), i.e. the computation that given a store s, first computes the pair computation-store f, s = fs and then returns the pair value-store a, s = f s. Continuations: T ( ) is the functor R R( ), where R is a nonempty set of results. Intuitively a computation takes a continuation and returns a result. η A (a) is (λk: R A.ka) µ A (f) is (λk: R A.f(λh: R RA.hk)) One can verify for himself that other notions of computation (e.g. partial, probabilistic or non-deterministic with side-effects) fit in the general definition of monad. 1.1 A simple language We introduce a programming language (with existence and equivalence assertions), where programs denote morphisms in the Kleisli category C T corresponding to a computational model (T, η, µ) over a category C. The language is oversimplified (for instance terms have exactly one free variable) in order to define its interpretation in any computational model. The additional structure required to interpret λ-terms will be introduced incrementally (see Section 2), after computations have been understood and axiomatized in isolation. The programming language is parametric in a signature (i.e. a set of base types and unary command symbols), therefore its interpretation in a computational model is parametric in an interpretation of the symbols in the signature. To stress the fact that the interpretation is in C T (rather than C), we use τ 1 τ 2 (instead of τ 1 τ 2 ) as arities and : τ (instead of = : T τ) as equality of computations of type τ. Given an interpretation [A] for any base type A, i.e. an object of C T, then the interpretation of a type τ : : = A T τ is an object [τ ] of C T defined in the obvious way, [T τ ] = T [τ ]. Given an interpretation [p] for any unary command p of arity τ 1 τ 2, i.e. a morphism from [τ 1 ] to [τ 2 ] in C T, then the interpretation of a well-formed program x: τ e: τ is a morphism [x: τ e: τ ] in C T from [τ ] to [τ ] defined by induction on the derivation of x: τ e: τ (see Table 1). On top of the programming language we consider equivalence and existence assertions (see Table 2). Remark 1.4 The let-constructor is very important semantically, since it corresponds to composition in the Kleisli category C T. While substitution corresponds to composition in C. In the λ-calculus (let x=e in e ) is usually treated as syntactic sugar for (λx.e )e, and this can be done also in the λ c -calculus. However, we think that this is not the right way to proceed, because it amounts to understanding the let-constructor, which makes sense in any computational model, in terms of constructors that make sense only in λ c -models. On the other hand, (let x=e in e ) cannot be reduced to the more basic substitution (i.e. e [x: = e]) without collapsing C T to C. The existence assertion e means that e denotes a value and it generalizes the existence predicate used in the logic of partial terms/elements, for instance: a partial computation exists iff it terminates; a non-deterministic computation exists iff it gives exactly one result; a computation with side-effects exists iff it does not change the store. 2 Extending the language In this section we describe the additional structure required to interpret λ-terms in a computational model. It is well-known that λ-terms can be interpreted in a cartesian closed categories (ccc), so one expects that a monad over a ccc would suffice, however, there are two problems: the interpretation of (let x=e in e ), when e has other free variables beside x, and the interpretation of functional types. Example 2.1 To show why the interpretation of the let-constructor is problematic, we try to interpret x 1 : τ 1 (let x 2 =e 2 in e): τ, when both x 1 and x 2 are free in e. Suppose that g 2 : τ 1 T τ 2 and g: τ 1 τ 2 T τ are the interpretations of x 1 : τ 1 e 2 : τ 2 and x 1 : τ 1, x 2 : τ 2 e: τ respectively. If T were Id C, then [x 1 : τ 1 (let x 2 =e 2 in e): τ ] would be id τ1, g 2 ; g. In the general case, Table 1 says that ; above is indeed composition in the Kleisli category, therefore id τ1, g 2 ; g becomes id τ1, g 2 ; g. But in id τ1, g 2 ; g there is a type mismatch, since the codomain of id τ1, g 2 is τ 1 T τ 2, while the domain of T g is T (τ 1 τ 2 ).

5 a dual notion of pairing, ψa,b = c A,B ; ψ B,A ; T c B,A (see [5]), which amounts to first evaluating the second argument and then the first. The reason why a functional type A B in a programming language (like ML) cannot be interpreted by the exponential B A (as done in a ccc) is fairly obvious; in fact the application of a functional procedure to an argument requires some computation to be performed before producing a result. By analogy with partial cartesian closed categories (see [8, 11]), we will interpret functional types by exponentials of the form (T B) A. Definition 2.6 A λ c -model over a category C with finite products is a strong monad (T, η, µ, t) together with a T -exponential for every pair A, B of objects in C, i.e. a pair (T B) A, eval A,T B : ((T B) A A) T B satisfying the universal property that for any object C and f: (C A) T B there exists a unique h: C (T B) A, denoted by Λ A,T B,C (f), s.t. f = (Λ A,T B,C (f) id A ); eval A,T B Like p-exponentials, a T -exponential (T B) A can be equivalently defined by giving a natural isomorphism C T (C A, B) = C(C, (T B) A ), where C varies over C. The programming language introduced in Section 1.1 and its interpretation can be extended according to the additional structure available in a λ c -model as follows: there is a new type 1, interpreted by the terminal object of C, and two new type constructors τ 1 τ 2 and τ 1 τ 2 interpreted by the product [τ 1 ] [τ 2 ] and the T -exponent (T [τ 2 ]) [[τ1]] respectively the interpretation of a well-formed program Γ e: τ, where Γ is a sequence x 1 : τ 1,..., x n : τ n, is a morphism in C T from [Γ] (i.e. [τ 1 ]... [τ n ]) to [τ ] (see Table 3) 4. 3 The λ c -calculus In this section we introduce a formal system, the λ c - calculus, with two basic judgements: existence (Γ e τ) and equivalence (Γ e 1 e 2 : τ). 4 In a language with products nonunary commands can be treated as unary commands from a product type. We claim that the formal system is sound and complete w.r.t. interpretation in λ c -models. Soundness amounts to showing that the inference rules are admissible in any λ c -model, while completeness amounts to showing that any λ c -theory has an initial model (given by a term-model construction). The inference rules of the λ c -calculus are partitioned as follows: general rules for terms denoting computations, but with variables ranging over values (see Table 4) 5 the inference rules for let-constructor and types of computations (see Table 5) the inference rules for product and functional types (see Table 6) Remark 3.1 A comparison among λ c -, λ v - and λ p - calculus shows that: the λ v -calculus proves less equivalences between λ-terms, e.g. (λx.x)(yz) (yz) is provable in the λ c - but not in the λ v -calculus the λ p -calculus proves more equivalences between λ-terms, e.g. (λx.yz)(yz) (yz) is provable in the λ p - but not in the λ c -calculus, because y can be a procedure, which modifies the store (e.g. by increasing the value contained in a local static variable) each time it is executed. a λ-term e has a value in the λ c -calculus, i.e. e is provably equivalent to some value (either a variable or a λ-abstraction), iff e has a value in the λ v -calculus/λ p -calculus. So all three calculi are correct w.r.t. call-by-value operational equivalence. Conclusions and further research The main contribution of this paper is the categorytheoretic semantics of computations and the general principle for extending it to more complex languages (see Remark 2.3), while the λ c -calculus is a straightforward fallout, which is easier to understand and relate to other calculi. This semantics of computations corroborates the view that (constructive) proofs and programs are 5 The general rules of sequent calculus, more precisely those for substitution and quantifiers, have to be modified slightly, because variables range over values and types can be empty. These modifications are similar to those introduced in the logic of partial terms (see Section 2.4 in [9]).

6 rather unrelated, although both of them can be understood in terms of functions. For instance, various logical modalities (like possibility and necessity in modal logic or why not and of course of linear logic) are modelled by monads or comonads which cannot have a tensorial strength. In general, one should expect types suggested by logic to provide a more fine-grained type system without changing the nature of computations. Our work is just an example of what can be achieved in the study of programming languages by using a category-theoretic methodology, which free us from the irrelevant detail of syntax and focus our mind on the important structures underlying programming languages. We believe that there is a great potential to be exploited here. The λ c -calculus open also the possibility to develop a new Logic of Computable Functions (see [12]), based on an abstract semantic of computations rather than domain theory, for studying axiomatically different notions of computation and their relations. Acknowledgements My thanks to M. Hyland, A. Kock (and other participants to the 1988 Category Theory Meeting in Sussex) for directing me towards the literature on monads. Discussions with R. Amadio, R. Burstall, J.Y. Girard, R. Harper, F. Honsell, Y. Lafont, G. Longo, R. Milner, G. Plotkin provided useful criticisms and suggestions. Thanks also to M. Tofte and P. Taylor for suggesting improvements to an early draft. References [6] Y. Lafont. The linear abstract machine. Theoretical Computer Science, 59, [7] E. Manes. Algebraic Theories, volume 26 of Graduate Texts in Mathematics. Springer Verlag, [8] E. Moggi. Categories of partial morphisms and the partial lambda-calculus. In Proceedings Workshop on Category Theory and Computer Programming, Guildford 1985, volume 240 of Lecture Notes in Computer Science. Springer Verlag, [9] E. Moggi. The Partial Lambda-Calculus. PhD thesis, University of Edinburgh, [10] G.D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1, [11] G. Rosolini. Continuity and Effectiveness in Topoi. PhD thesis, University of Oxford, [12] D.S. Scott. A type-theoretic alternative to CUCH, ISWIM, OWHY. Oxford notes, [13] D.S. Scott. Relating theories of the λ-calculus. In R. Hindley and J. Seldin, editors, To H.B. Curry: essays in Combinarory Logic, lambda calculus and Formalisms. Academic Press, [14] R.A.G. Seely. Linear logic, -autonomous categories and cofree coalgebras. In Proc. AMS Conf. on Categories in Comp. Sci. and Logic (Boulder 1987), [1] R.L. Constable and S.F. Smith. Partial objects in constructive type theory. In 2nd LICS Conf. IEEE, [2] J.M.E. Hyland and A.M. Pitts. The theory of constructions: Categorical semantics and topostheoretic models. In Proc. AMS Conf. on Categories in Comp. Sci. and Logic (Boulder 1987), [3] P.T. Johnstone and R. Pare, editors. Indexed Categories and their Applications, volume 661 of Lecture Notes in Mathematics. Springer Verlag, [4] G.M. Kelly. Basic Concepts of Enriched Category Theory. Cambridge University Press, [5] A. Kock. Strong functors and monoidal monads. Archiv der Mathematik, 23, 1972.

7 RULE SYNTAX SEMANTICS var let x: τ x: τ = η [[τ]] x: τ e 1 : τ 1 = g 1 x 1 : τ 1 e 2 : τ 2 = g 2 x: τ (let x 1 =e 1 in e 2 ): τ 2 = g 1 ; g2 1 2 x: τ e 1 : τ 1 = g 1 x: τ p(e 1 ): τ 2 = g 1 ; p [ ] µ x: τ e: τ = g x: τ [e]: T τ = g; η T [[τ ]] x: τ e: T τ = g x: τ µ(e): τ = g; µ [[τ ]] Table 1: Programs and their interpretation RULE SYNTAX SEMANTICS eq x: τ 1 e 1 : τ 2 = g 1 x: τ 1 e 2 : τ 2 = g 2 x: τ 1 e 1 e 2 : τ 2 g 1 = g 2 ex x: τ 1 e: τ 2 = g x: τ 1 e τ 2 g factors through η [[τ2]] i.e. there exists (unique) h s.t. g = h; η [[τ2]] Table 2: Atomic assertions and their interpretation

8 RULE SYNTAX SEMANTICS var x 1 : τ 1,..., x n : τ n x i : τ i = π n i ; η [[τ i]] let Γ e 1 : τ 1 = g 1 Γ, x 1 : τ 1 e 2 : τ 2 = g 2 Γ (let x 1 =e 1 in e 2 ): τ 2 = id [[Γ]], g 1 ; t [[Γ]],[[τ1]]; g2 Γ : 1 =! [[Γ]] ; η 1 Γ e 1 : τ 1 = g 1 Γ e 2 : τ 2 = g 2 Γ e 1, e 2 : τ 1 τ 2 = g 1, g 2 ; ψ [[τ1]],[[τ 2]] i Γ e: τ 1 τ 2 = g Γ π i (e): τ 1 = g; T (π i ) λ app Γ, x 1 : τ 1 e 2 : τ 2 = g Γ (λx 1 : τ 1.e 2 ): τ 1 τ 2 = Λ [[τ1]],t [[τ 2]],[[Γ]](g); η [[τ1 τ 2]] Γ e 1 : τ 1 = g 1 Γ e: τ 1 τ 2 = g Γ e(e 1 ): τ 2 = g, g 1 ; ψ (T [[τ2]]) [[τ 1 ]],[[τ ; (eval 1]] [[τ 1]],T [[τ 2]]) Table 3: Interpretation in a λ c -model We write [x: = e] for the substitution of x with e in. E.x Γ x τ subst Γ e τ Γ, x: τ A Γ A[x: = e] is an congruence relation Table 4: General rules

9 We write (let x=e in e) for (let x 1 =e 1 in (... (let x n =e n in e)...)), where n is the lenght of the sequence x (and e). In particular, (let = in e) stands for e. unit Γ (let x=e in x) e: τ ass Γ (let x 2 =(let x 1 =e 1 in e 2 ) in e) (let x 1 =e 1 in (let x 2 =e 2 in e)): τ let.β Γ (let x 1 =x 2 in e) e[x 1 : = x 2 ]: τ let.p Γ p(e) (let x=e in p(x)): τ x 1 FV(e) E.[ ] Γ [e] T τ T.β Γ µ([e]) e: τ T.η Γ [µ(x)] x: T τ Table 5: rules for let and computational types E. Γ 1 1.η Γ x: 1 E. Γ x 1, x 2 τ 1 τ 2 let. Γ e 1, e 2 (let x 1, x 2 =e 1, e 2 in x 1, x 2 ): τ 1 τ 2 E.π i Γ π i (x) τ i.β Γ π i ( x 1, x 2 ) x i : τ i.η Γ π 1 (x), π 2 (x) x: τ 1 τ 2 E.λ Γ (λx: τ 1.e) τ 1 τ 2 β Γ (λx 1 : τ 1.e 2 )(x 1 ) e 2 : τ 2 η Γ (λx 1 : τ 1.x(x 1 )) x: τ 1 τ 2 Table 6: rules for product and functional types

Notions of computation and monads Eugenio Moggi Abstract The λ-calculus is considered an useful mathematical tool in the study of programming languages, since programs can be identified with λ-terms. However,

Basic Category Theory for Models of Syntax (Preliminary Version)

Basic Category Theory for Models of Syntax (Preliminary Version) R. L. Crole ( ) Department of Mathematics and Computer Science, University of Leicester, Leicester, LE1 7RH, U.K. Abstract. These notes

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic Lars Birkedal Rasmus Ejlers Møgelberg Rasmus Lerchedahl Petersen IT University Technical Report Series TR-00-7 ISSN 600 600 February 00

Linear Types for Continuations

1/28 Linear Types for Continuations Alex Simpson LFCS, School of Informatics University of Edinburgh, UK Joint work with: Jeff Egger (LFCS, Edinburgh) Rasmus Møgelberg (ITU, Copenhagen) Linear Types for

Linearly Used Effects: Monadic and CPS Transformations into the Linear Lambda Calculus

Linearly Used Effects: Monadic and CPS Transformations into the Linear Lambda Calculus Masahito Hasegawa Research Institute for Mathematical Sciences, Kyoto University hassei@kurimskyoto-uacjp Abstract

Sets and functions. {x R : x > 0}.

Sets and functions 1 Sets The language of sets and functions pervades mathematics, and most of the important operations in mathematics turn out to be functions or to be expressible in terms of functions.

f(x) is a singleton set for all x A. If f is a function and f(x) = {y}, we normally write

Math 525 Chapter 1 Stuff If A and B are sets, then A B = {(x,y) x A, y B} denotes the product set. If S A B, then S is called a relation from A to B or a relation between A and B. If B = A, S A A is called

Equality and dependent type theory

Thierry Coquand 24th AILA meeting, Bologna, February 2-4 Equality and dependent type theory This talk: comments on V. Voevodsky Univalent Foundation for Mathematics A refinement of the propositions-as-types

A set is a Many that allows itself to be thought of as a One. (Georg Cantor)

Chapter 4 Set Theory A set is a Many that allows itself to be thought of as a One. (Georg Cantor) In the previous chapters, we have often encountered sets, for example, prime numbers form a set, domains

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 1 9/3/2008 PROBABILISTIC MODELS AND PROBABILITY MEASURES

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 1 9/3/2008 PROBABILISTIC MODELS AND PROBABILITY MEASURES Contents 1. Probabilistic experiments 2. Sample space 3. Discrete probability

CHAPTER 7 GENERAL PROOF SYSTEMS

CHAPTER 7 GENERAL PROOF SYSTEMS 1 Introduction Proof systems are built to prove statements. They can be thought as an inference machine with special statements, called provable statements, or sometimes

KAN EXTENSIONS AND NONSENSICAL GENERALIZATIONS

KAN EXENSIONS AND NONSENSICAL GENERALIZAIONS ADAM ANDERSON Abstract. he categorical concept of Kan extensions form a more general notion of both limits and adjoints. he general definition of Kan extensions

The Consistency of the Continuum Hypothesis Annals of Mathematical Studies, No. 3 Princeton University Press Princeton, N.J., 1940.

TWO COMPUTATIONAL IDEAS Computations with Sets Union, intersection: computable Powerset: not computable Basic operations Absoluteness of Formulas A formula in the language of set theory is absolute if

Summary Last Lecture. Automated Reasoning. Outline of the Lecture. Definition sequent calculus. Theorem (Normalisation and Strong Normalisation)

Summary Summary Last Lecture sequent calculus Automated Reasoning Georg Moser Institute of Computer Science @ UIBK Winter 013 (Normalisation and Strong Normalisation) let Π be a proof in minimal logic

Nominal Sets. c 2011 Andrew M. Pitts

Nominal Sets c 2011 Andrew M. Pitts Contents Preface page v 1 Permutations 1 1.1 The category of G-sets 1 1.2 Products and coproducts 3 1.3 Natural numbers 5 1.4 Functions 5 1.5 Power sets 6 1.6 Partial

Satisfiability Checking

Satisfiability Checking First-Order Logic Prof. Dr. Erika Ábrahám RWTH Aachen University Informatik 2 LuFG Theory of Hybrid Systems WS 14/15 Satisfiability Checking Prof. Dr. Erika Ábrahám (RWTH Aachen

From Sets to Types to Categories to Sets

From Sets to Types to Categories to Sets Steve Awodey Three different styles of foundations of mathematics are now commonplace: set theory, type theory, and category theory. How do they relate, and how

Topology and Convergence by: Daniel Glasscock, May 2012

Topology and Convergence by: Daniel Glasscock, May 2012 These notes grew out of a talk I gave at The Ohio State University. The primary reference is [1]. A possible error in the proof of Theorem 1 in [1]

(What I Know about) the History of the Identity Type

(What I Know about) the History of the Identity Type Peter Dybjer Chalmers University, Göteborg, Sweden Workshop on Identity Types Uppsala, 13 November, 2006 When was the identity type born? Martin-Löf

CHAPTER 2. Inequalities

CHAPTER 2 Inequalities In this section we add the axioms describe the behavior of inequalities (the order axioms) to the list of axioms begun in Chapter 1. A thorough mastery of this section is essential

1. Sigma algebras. Let A be a collection of subsets of some fixed set Ω. It is called a σ -algebra with the unit element Ω if. lim sup. j E j = E.

Real Analysis, course outline Denis Labutin 1 Measure theory I 1. Sigma algebras. Let A be a collection of subsets of some fixed set Ω. It is called a σ -algebra with the unit element Ω if (a), Ω A ; (b)

Seminal Research Articles in Programming Languages

Seminal Research Articles in Programming Languages Abstract The research articles listed here cover the period 1963 to the present. They are all important articles, and they are relevant to this offering

A CPS-Translation of the λµ-calculus

A CPS-Translation of the λµ-calculus Philippe de Groote INRIA-Lorraine CRIN CNRS Campus Scientifique - BP 239 54506 Vandœuvre-lès-Nancy Cedex FRANCE e-mail: degroote@loriafr Abstract We present a translation

Rigorous Software Development CSCI-GA 3033-009

Rigorous Software Development CSCI-GA 3033-009 Instructor: Thomas Wies Spring 2013 Lecture 11 Semantics of Programming Languages Denotational Semantics Meaning of a program is defined as the mathematical

Chapter 7: Functional Programming Languages

Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language

Sets and Cardinality Notes for C. F. Miller

Sets and Cardinality Notes for 620-111 C. F. Miller Semester 1, 2000 Abstract These lecture notes were compiled in the Department of Mathematics and Statistics in the University of Melbourne for the use

Domain Theory: An Introduction

Domain Theory: An Introduction Robert Cartwright Rebecca Parsons Rice University This monograph is an unauthorized revision of Lectures On A Mathematical Theory of Computation by Dana Scott [3]. Scott

Probabilità e Nondeterminismo nella teoria dei domini

Probabilità e Nondeterminismo nella teoria dei domini Daniele Varacca ENS, Paris BRICS, Aarhus Parma, 15 giugno 2004 Probabilità e Nondeterminismo nella teoria dei domini p.1 Road Map Motivation Domain

The Basic Concepts of the Theory of Operads

CHAPTER The Basic Concepts of the Theory of Operads The main purpose of this chapter is to explain the definition of an operad. We make this definition explicit in the first section of the chapter (.).

Fibonacci Numbers Modulo p

Fibonacci Numbers Modulo p Brian Lawrence April 14, 2014 Abstract The Fibonacci numbers are ubiquitous in nature and a basic object of study in number theory. A fundamental question about the Fibonacci

NOTES ON CATEGORIES AND FUNCTORS

NOTES ON CATEGORIES AND FUNCTORS These notes collect basic definitions and facts about categories and functors that have been mentioned in the Homological Algebra course. For further reading about category

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

Higher-Order Logic Specification and Verification with Higher-Order Logic Arnd Poetzsch-Heffter Software Technology Group Fachbereich Informatik Technische Universität Kaiserslautern Sommersemester 2010

SOME SUPER-INTUITIONISTIC LOGICS AS THE LOGICAL FRAGMENTS OF EQUATIONAL THEORIES 1

Tatsuya Shimura Nobu-Yuki Suzuki SOME SUPER-INTUITIONISTIC LOGICS AS THE LOGICAL FRAGMENTS OF EQUATIONAL THEORIES 1 Kripke frame semantics is used as a concise and convenient apparatus for the study of

CARDINALITY, COUNTABLE AND UNCOUNTABLE SETS PART ONE

CARDINALITY, COUNTABLE AND UNCOUNTABLE SETS PART ONE With the notion of bijection at hand, it is easy to formalize the idea that two finite sets have the same number of elements: we just need to verify

Math 223 Abstract Algebra Lecture Notes

Math 223 Abstract Algebra Lecture Notes Steven Tschantz Spring 2001 (Apr. 23 version) Preamble These notes are intended to supplement the lectures and make up for the lack of a textbook for the course

MATHS 315 Mathematical Logic

MATHS 315 Mathematical Logic Second Semester, 2006 Contents 2 Formal Statement Logic 1 2.1 Post production systems................................. 1 2.2 The system L.......................................

Non-deterministic Semantics and the Undecidability of Boolean BI

1 Non-deterministic Semantics and the Undecidability of Boolean BI DOMINIQUE LARCHEY-WENDLING, LORIA CNRS, Nancy, France DIDIER GALMICHE, LORIA Université Henri Poincaré, Nancy, France We solve the open

Equality and dependent type theory. Oberwolfach, March 2 (with some later corrections)

Oberwolfach, March 2 (with some later corrections) The Axiom of Univalence, a type-theoretic view point In type theory, we reduce proof-checking to type-checking Hence we want type-checking to be decidable

Students in their first advanced mathematics classes are often surprised

CHAPTER 8 Proofs Involving Sets Students in their first advanced mathematics classes are often surprised by the extensive role that sets play and by the fact that most of the proofs they encounter are

Notes on Modal Logic

Notes on Modal Logic Notes for Philosophy 151 Eric Pacuit January 28, 2009 These short notes are intended to supplement the lectures and text ntroduce some of the basic concepts of Modal Logic. The primary

in quantum computation

in computation Kestrel Institute and Oxford University - Oxford, August 2008 Outline Quantum programming λ- Abstraction with pictures Consequences - Abstraction in Category of measurements - Outline Quantum

Direct models of the computational lambda-calculus

Electronic Notes in Theoretical Computer Science 20 (1999) URL: http://www.elsevier.nl/locate/entcs/volume20.html 49 pages Direct models of the computational lambda-calculus Carsten Führmann 1 Division

A Propositional Dynamic Logic for CCS Programs

A Propositional Dynamic Logic for CCS Programs Mario R. F. Benevides and L. Menasché Schechter {mario,luis}@cos.ufrj.br Abstract This work presents a Propositional Dynamic Logic in which the programs are

Formal Borel sets a proof-theoretic approach

1/29 Formal Borel sets a proof-theoretic approach Alex Simpson LFCS, School of Informatics University of Edinburgh, UK Formal Borel sets a proof-theoretic approach 2/29 Context of talk Domain theory Topological

Complete Axioms for Categorical Fixed-point Operators

Complete Axioms for Categorical Fixed-point Operators Alex Simpson and Gordon Plotin LFCS, Division of Informatics, University of Edinburgh, JCMB, King s Buildings, Edinburgh, EH9 3JZ {als,gdp}@dcs.ed.ac.u

4 Domain Relational Calculus

4 Domain Relational Calculus We now present two relational calculi that we will compare to RA. First, what is the difference between an algebra and a calculus? The usual story is that the algebra RA is

3. Recurrence Recursive Definitions. To construct a recursively defined function:

3. RECURRENCE 10 3. Recurrence 3.1. Recursive Definitions. To construct a recursively defined function: 1. Initial Condition(s) (or basis): Prescribe initial value(s) of the function.. Recursion: Use a

Semantic Theory Lecture 2: Type theory

Semantic Theory Lecture 2: Type theory M. Pinkal / A. Koller Summer 2006 Logic as a framework for NL semantics Approximate NL meaning as truth conditions. Logic supports precise, consistent and controlled

A Complete Characterization of Complete Intersection-Type Preorders

A Complete Characterization of Complete Intersection-Type Preorders M. DEZANI-CIANCAGLINI Università di Torino and F. HONSELL and F. ALESSI Università di Udine We characterize those type preorders which

Module MA1S11 (Calculus) Michaelmas Term 2016 Section 3: Functions

Module MA1S11 (Calculus) Michaelmas Term 2016 Section 3: Functions D. R. Wilkins Copyright c David R. Wilkins 2016 Contents 3 Functions 43 3.1 Functions between Sets...................... 43 3.2 Injective

Recursion Theory in Set Theory

Contemporary Mathematics Recursion Theory in Set Theory Theodore A. Slaman 1. Introduction Our goal is to convince the reader that recursion theoretic knowledge and experience can be successfully applied

Category Theory for Dummies (I)

Category Theory for Dummies (I) James Cheney Programming Languages Discussion Group March 12, 2004 1 Not quite everything you ve ever wanted to know... You keep hearing about category theory. Cool-sounding

, A A {(A (B C))}, ((A B) C) {A}, (B A) {(A A)}, A {(A B), ( A C))}, (B C)

1. Axioms and rules of inference for propositional logic. Suppose T = L, A, R is a formal theory. Whenever H is a finite subset of L and C L it is evident that H, C R H C. Fix a set X of propositional

Outline. Database Theory. Perfect Query Optimization. Turing Machines. Question. Definition VU , SS Trakhtenbrot s Theorem

Database Theory Database Theory Outline Database Theory VU 181.140, SS 2016 4. Trakhtenbrot s Theorem Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 4.

Cartesian Products and Relations

Cartesian Products and Relations Definition (Cartesian product) If A and B are sets, the Cartesian product of A and B is the set A B = {(a, b) :(a A) and (b B)}. The following points are worth special

MAT2400 Analysis I. A brief introduction to proofs, sets, and functions

MAT2400 Analysis I A brief introduction to proofs, sets, and functions In Analysis I there is a lot of manipulations with sets and functions. It is probably also the first course where you have to take

Chapter Three. Functions. In this section, we study what is undoubtedly the most fundamental type of relation used in mathematics.

Chapter Three Functions 3.1 INTRODUCTION In this section, we study what is undoubtedly the most fundamental type of relation used in mathematics. Definition 3.1: Given sets X and Y, a function from X to

ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS

PROCEEDINGS OF THE YEREVAN STATE UNIVERSITY Physical and Mathematical Sciences 2012 1 p. 43 48 ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS I nf or m at i cs L. A. HAYKAZYAN * Chair of Programming and Information

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 11

CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note Conditional Probability A pharmaceutical company is marketing a new test for a certain medical condition. According

Affine Planes: An Introduction to Axiomatic Geometry

Affine Planes: An Introduction to Axiomatic Geometry Here we use Euclidean plane geometry as an opportunity to introduce axiomatic systems. Keep in mind that the axiomatic approach is not the only approach

3. Some commutative algebra Definition 3.1. Let R be a ring. We say that R is graded, if there is a direct sum decomposition, M n, R n,

3. Some commutative algebra Definition 3.1. Let be a ring. We say that is graded, if there is a direct sum decomposition, = n N n, where each n is an additive subgroup of, such that d e d+e. The elements

Chapter 2 Mathematical Background

Chapter 2 Mathematical Background We start this chapter with a summary of basic concepts and notations for sets and first-order logic formulas, which will be used in the rest of the book. Our aim is to

Fundamentals of Mathematics Lecture 6: Propositional Logic

Fundamentals of Mathematics Lecture 6: Propositional Logic Guan-Shieng Huang National Chi Nan University, Taiwan Spring, 2008 1 / 39 Connectives Propositional Connectives I 1 Negation: (not A) A A T F

Encoding Mathematics in First-Order Logic

Applied Logic Lecture 19 CS 486 Spring 2005 Thursday, April 14, 2005 Encoding Mathematics in First-Order Logic Over the past few lectures, we have seen the syntax and the semantics of first-order logic,

Elementary Number Theory We begin with a bit of elementary number theory, which is concerned

CONSTRUCTION OF THE FINITE FIELDS Z p S. R. DOTY Elementary Number Theory We begin with a bit of elementary number theory, which is concerned solely with questions about the set of integers Z = {0, ±1,

Problem Set. Problem Set #2. Math 5322, Fall December 3, 2001 ANSWERS

Problem Set Problem Set #2 Math 5322, Fall 2001 December 3, 2001 ANSWERS i Problem 1. [Problem 18, page 32] Let A P(X) be an algebra, A σ the collection of countable unions of sets in A, and A σδ the collection

SEMINAR NOTES: G-BUNDLES, STACKS AND BG (SEPT. 15, 2009)

SEMINAR NOTES: G-BUNDLES, STACKS AND (SEPT. 15, 2009) DENNIS GAITSGORY 1. G-bundles 1.1. Let G be an affine algebraic group over a ground field k. We assume that k is algebraically closed. Definition 1.2.

Lecture 4 -- Sets, Relations, Functions 1

Lecture 4 Sets, Relations, Functions Pat Place Carnegie Mellon University Models of Software Systems 17-651 Fall 1999 Lecture 4 -- Sets, Relations, Functions 1 The Story So Far Formal Systems > Syntax»

Course 421: Algebraic Topology Section 1: Topological Spaces

Course 421: Algebraic Topology Section 1: Topological Spaces David R. Wilkins Copyright c David R. Wilkins 1988 2008 Contents 1 Topological Spaces 1 1.1 Continuity and Topological Spaces...............

Higher-Order Minimal Function Graphs

Higher-Order Minimal Function Graphs Neil D Jones and Mads Rosendahl Datalogisk Institut, University of Copenhagen Universitetsparken 1, DK-2100 Copenhagen Ø Denmark {neil, rose}@diku.dk Abstract. We present

Regular Languages and Finite Automata

Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

1. R In this and the next section we are going to study the properties of sequences of real numbers.

+a 1. R In this and the next section we are going to study the properties of sequences of real numbers. Definition 1.1. (Sequence) A sequence is a function with domain N. Example 1.2. A sequence of real

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence 7. Propositional Logic Rational Thinking, Logic, Resolution Wolfram Burgard, Bernhard Nebel and Martin Riedmiller Albert-Ludwigs-Universität Freiburg Contents 1 Agents

If we observe choices x at 4 and y at 1 then we have x y and y x. No one made choices like this.

1 Experiment Did the subjects make choices as if they had a preference relation over bundles of (IC, HB)? If so, could we infer and predict future choices or offer advice about choices? In situation 2

Software Verification and Testing. Lecture Notes: Z I

Software Verification and Testing Lecture Notes: Z I Motivation so far: we have seen that properties of software systems can be specified using first-order logic, set theory and the relational calculus

MATH 433 Applied Algebra Lecture 13: Examples of groups.

MATH 433 Applied Algebra Lecture 13: Examples of groups. Abstract groups Definition. A group is a set G, together with a binary operation, that satisfies the following axioms: (G1: closure) for all elements

7.1 An Axiomatic Approach to Mathematics

Chapter 7 The Peano Axioms 7.1 An Axiomatic Approach to Mathematics In our previous chapters, we were very careful when proving our various propositions and theorems to only use results we knew to be true.

Functional Programming Techniques for Philosophy and Linguistics Chris Barker and Jim Pryor, NASSLLI 2016 JP's Thursday Handout

Functional Programming Techniques for Philosophy and Linguistics Chris Barker and Jim Pryor, NASSLLI 2016 JP's Thursday Handout Remember Polymorphic Types? id : α. α α (we'll usually suppress prenex α

Discrete Mathematics Lecture 5. Harper Langston New York University

Discrete Mathematics Lecture 5 Harper Langston New York University Empty Set S = {x R, x 2 = -1} X = {1, 3}, Y = {2, 4}, C = X Y (X and Y are disjoint) Empty set has no elements Empty set is a subset of

Computability Theory

CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

Coalgebraic Description of Generalized Binary Methods

Under consideration for publication in Math. Struct. in Comp. Science Coalgebraic Description of Generalized Binary Methods Furio Honsell 1, Marina Lenisa 1, Rekha Redamalla 1,2 1 Dipartimento di Matematica

System BV is NP-complete

System BV is NP-complete Ozan Kahramanoğulları 1,2 Computer Science Institute, University of Leipzig International Center for Computational Logic, TU Dresden Abstract System BV is an extension of multiplicative

Chapter 1 LOGIC AND PROOF

Chapter 1 LOGIC AND PROOF To be able to understand mathematics and mathematical arguments, it is necessary to have a solid understanding of logic and the way in which known facts can be combined to prove

mywbut.com Propositional Logic inference rules

Propositional Logic inference rules 1 5.5 Rules of Inference Here are some examples of sound rules of inference. Each can be shown to be sound once and for all using a truth table. The left column contains

A Brief Overview of Agda A Functional Language with Dependent Types

A Brief Overview of Agda A Functional Language with Dependent Types Ana Bove, Peter Dybjer, and Ulf Norell e-mail: {bove,peterd,ulfn}@chalmers.se Chalmers University of Technology, Gothenburg, Sweden Abstract.

Classical Analysis I

Classical Analysis I 1 Sets, relations, functions A set is considered to be a collection of objects. The objects of a set A are called elements of A. If x is an element of a set A, we write x A, and if

University of Ostrava. Reasoning in Description Logic with Semantic Tableau Binary Trees

University of Ostrava Institute for Research and Applications of Fuzzy Modeling Reasoning in Description Logic with Semantic Tableau Binary Trees Alena Lukasová Research report No. 63 2005 Submitted/to

First-Order Predicate Logic (2)

First-Order Predicate Logic (2) Predicate Logic (2) Understanding first-order predicate logic formulas. Satisfiability and undecidability of satisfiability. Tautology, logical consequence, and logical

18.312: Algebraic Combinatorics Lionel Levine. Lecture 8

18.312: Algebraic Combinatorics Lionel Levine Lecture date: March 1, 2011 Lecture 8 Notes by: Christopher Policastro Remark: In the last lecture, someone asked whether all posets could be constructed from

The Strong Markov Property

The Strong Markov Property Throughout, X := {X } denotes a Lévy process on with triple (σ), and exponent Ψ. And from now on, we let { } denote the natural filtration of X, all the time remembering that,

This chapter describes set theory, a mathematical theory that underlies all of modern mathematics.

Appendix A Set Theory This chapter describes set theory, a mathematical theory that underlies all of modern mathematics. A.1 Basic Definitions Definition A.1.1. A set is an unordered collection of elements.

If f is a 1-1 correspondence between A and B then it has an inverse, and f 1 isa 1-1 correspondence between B and A.

Chapter 5 Cardinality of sets 51 1-1 Correspondences A 1-1 correspondence between sets A and B is another name for a function f : A B that is 1-1 and onto If f is a 1-1 correspondence between A and B,

Lecture 12. More algebra: Groups, semigroups, monoids, strings, concatenation.

V. Borschev and B. Partee, November 1, 2001 p. 1 Lecture 12. More algebra: Groups, semigroups, monoids, strings, concatenation. CONTENTS 1. Properties of operations and special elements...1 1.1. Properties

Solving equations in a language with control operators

Solving equations in a language with control operators Stephane Le Roux, Pierre Lescanne LIP, École Normale Supérieure de Lyon, Lyon, France {Stephane.Le.Roux,Pierre.Lescanne}@ens-lyon.fr 1 Introduction

Equivalence relations

Equivalence relations A motivating example for equivalence relations is the problem of constructing the rational numbers. A rational number is the same thing as a fraction a/b, a, b Z and b 0, and hence

Change of Continuous Random Variable

Change of Continuous Random Variable All you are responsible for from this lecture is how to implement the Engineer s Way (see page 4) to compute how the probability density function changes when we make

o-minimality and Uniformity in n 1 Graphs

o-minimality and Uniformity in n 1 Graphs Reid Dale July 10, 2013 Contents 1 Introduction 2 2 Languages and Structures 2 3 Definability and Tame Geometry 4 4 Applications to n 1 Graphs 6 5 Further Directions

NOTES ON MEASURE THEORY. M. Papadimitrakis Department of Mathematics University of Crete. Autumn of 2004

NOTES ON MEASURE THEORY M. Papadimitrakis Department of Mathematics University of Crete Autumn of 2004 2 Contents 1 σ-algebras 7 1.1 σ-algebras............................... 7 1.2 Generated σ-algebras.........................