1 Category Theory

Total Page:16

File Type:pdf, Size:1020Kb

1 Category Theory {-# LANGUAGE RankNTypes #-} module AbstractNonsense where import Control.Monad 1 Category theory Definition 1. A category consists of • a collection of objects • and a collection of morphisms between those objects. We write f : A → B for the morphism f connecting the object A to B. • Morphisms are closed under composition, i.e. for morphisms f : A → B and g : B → C there exists the composed morphism h = f ◦ g : A → C1. Furthermore we require that • Composition is associative, i.e. f ◦ (g ◦ h) = (f ◦ g) ◦ h • and for each object A there exists an identity morphism idA such that for all morphisms f : A → B: f ◦ idB = idA ◦ f = f Many mathematical structures form catgeories and thus the theorems and con- structions of category theory apply to them. As an example consider the cate- gories • Set whose objects are sets and morphisms are functions between those sets. • Grp whose objects are groups and morphisms are group homomorphisms, i.e. structure preserving functions, between those groups. 1.1 Functors Category theory is mainly interested in relationships between different kinds of mathematical structures. Therefore the fundamental notion of a functor is introduced: 1The order of the composition is to be read from left to right in contrast to standard mathematical notation. 1 Definition 2. A functor F : C → D is a transformation between categories C and D. It is defined by its action on objects F (A) and morphisms F (f) and has to preserve the categorical structure, i.e. for any morphism f : A → B: F (f(A)) = F (f)(F (A)) which can also be stated graphically as the commutativity of the following dia- gram: F (f) F (A) F (B) f A B Alternatively we can state that functors preserve the categorical structure by the requirement to respect the composition of morphisms: F (idC) = idD F (f) ◦ F (g) = F (f ◦ g) 1.2 Natural transformations Taking the construction a step further we can ask for transformations between functors. This idea is captured by the notion of a natural transformation. Definition 3. A natural transformation η : F → G between functors F : C → D and G : C → D associates to each object A of C a morphism ηA such that for each morphism f : A → B the following diagram commutes: F (f) F (A) F (B) ηA ηB G(f) G(A) G(B) The collection of all functors again forms a category with the natural transfor- mations as morphisms. This is enough notation to get us started and we can now look at how category theory applies to Haskell. 2 The catgeory Hask 2.1 Data types The category Hask of Haskell has data types as its objects. The morphisms f : T → U are simply given by function, i.e. programs, of the specified types, e.g. showSquare :: Int -> String showSquare x = show (x*x) 2 is a morphism between Int and String. Composition of morphisms is given by standard function composition (written as . in Haskell) which is associative and for any f :: a → b2 we have f . (id :: a) = (id :: b) . f 2.2 Problems of lazyness In the category Hask morphisms are themselves objects of the corresponding function type, e.g. showSquare :: (Int → String)3. Unfortunately, many of the required constructions fail in Hask due to laziness. Consider for example the notion of a product. The product A × B of objects A and B is defined by two morphisms fst : A × B → B and snd : A × B → B such that for all morphisms f : C → A and g : C → B the following diagram commutes C g h f A A × Bsnd B fst with a unique morphism h : C → A × B. This is an example of a so called universal construction and the uniques of the morphism h implies that the product is unique (up to isomorphism). Proof. Assume there exists a second product A׈ B such that the above diagram commutes with a unique morphism hˆ. Then by identifying C with A׈ B and A × B from the corresponding diagrams we obtain unique morphisms times : A׈ B → A × B and times : A × B → A׈ B respectively. Now, by composition d we know that times ◦ times : A × B → A × B. Thus, times is an isomorphism d with inverse times. Furthermore, this isomorphism is unique. d In Hask each data type contains an additional value ⊥ corresponding to the failing or non-terminating computation. This leads to problems when we try to identify the tuple type with the categorical product. fst :: (A,B) -> A snd :: (A,B) -> B f :: C -> A g :: C -> B delta :: (C -> A) -> (C -> B) -> (C -> (A,B)) delta f g = \x -> (f x, g x) 2Note that Haskell uses lower case letters to denote type variables and function composition is defined from right to left. 3A category with this and additional properties (products, terminal object, . ) is called cartesian closed. The category Set is another example since mappings between sets are themselves sets. 3 h :: C -> (A,B) h = delta f g The commutativity of the diagram requires f = fst . h and g = snd . h which holds with the provided definitions. Unfortunately h is not unique for special empty types A, B and C. data A data B data C instance Show A where show _ = "A" instance Show B where show _ = "B" instance Show C where show _ = "C" f :: C -> A f _ = undefined g :: C -> B g _ = undefined h :: C -> (A,B) h _ = (undefined,undefined) h’ :: C -> (A,B) h’ _ = undefined Both h and h′ are valid candidates, but due to laziness they can be distinguished: check tup = case tup of (_,_) -> True _ -> False 2.3 Practical issues Usually this sublety is ignored by assuming the category of strict computations. In this sense and for all practical purposes Hask forms a nice category where the standard constructions can be identified with certain type constructors: Initial object data Empty Terminal object data () = () Coproduct data Either a b = Left a | Right b Product data (a,b) = (,) { fst :: a, snd :: b} 4 3 Functors and polymorphic functions 3.1 Functors In Haskell no function ever leaves the Haskell data types. Thus only endo- functors from Hask into (a subset of) Hask can be defined. Consider for example the subcategory Lst which only contains data types [A] that are lists of some type A. The idea is that the type constructor [] for lists forms a functor [] : Hask → Lst. Every object A of Hask is transformed to an object [A] of Lst. What about a morphism f : A → B? In Haskell this corresponds to a function f :: a -> b. We now need a new function f[] :: [a] → [b] which suggest to look at map f :: [a] -> [b]. To define a proper functor this new function map f has to respect function compo- sition, i.e. map id = id map f . map g = map (f . g) Indeed, these are the so called functor laws and the type class functor is defined as follows: class Functor’ f where fmap’ :: (a -> b) -> (f a -> f b) instance Functor’ [] where fmap’ = map instance Functor’ Maybe where fmap’ f (Just x) = Just (f x) fmap’ f Nothing = Nothing Basically any composed data structure which has a meaningful notion of ap- plying a function to its parts can implement a functor instance. Nevertheless, it is important to check the functor laws since the are used internally by the compiler for optimizations, e.g. the second law allows to fuse two traversals into one! Exercise: 1. Define a Functor instance for binary trees, .i.e data Tree a = Leaf | Branch a (Tree a) (Tree a) and check the functor laws. 3.2 Natural transformations What are natural transformations in Haskell? Consider two functors, e.g. [] and Maybe. A natural transformation is a morphism η between those types such that: η :: [a] → Maybea 5 and for any type a and function f :: a− >b we require the following commuta- tivity: (fmap f :: Maybe a -> Maybe b) . (eta :: [a] -> Maybe a) \ = (eta :: [b] -> Maybe b) . (fmap f :: [a] -> [b]) fmap f . eta = eta . fmap f Interestingly, this property ensures that η cannot look inside its arguments, i.e. it cannot behave differently depending on the type that the list contains. It really captures the notion of a polymorphic function that works for any type and relates the structure of the functors, i.e. data constructors. eta [] = Nothing eta (x:_) = Just x Exercise: 1. Show that this definition gives a natural transformation. 2. Define a natural transformation from binary trees to lists and vice versa 4 Monads Basically, a monad is a functor with additional structure that resembles prop- erties of a monoid (therefore the name). Definition 4. A monad on a category C is a functor T : C → C together with two natural transformations η :1C → T and µ : T 2 → T (where T 2 is the functor T ◦ T : C → C. The following diagrams have to commute for each object A of C: T (µA) ηT (A) T (T (T (A))) T (T (A)) T (A) T (T (A)) µT (A) µA) T (ηA) µA µA µA T (T (A)) T (A) T (T (A)) T (A) 4.1 Monads in Haskell For reasons that hopefully become clear later, the natural transformations of a monad are called return and join in Haskell. class Functor m => Monad’ m where return’ :: a -> m a join’ :: m (m a) -> m a The commutativity of the above diagrams corresponds to the following monad laws: 6 join . join = join . fmap join join .
Recommended publications
  • Ambiguity and Incomplete Information in Categorical Models of Language
    Ambiguity and Incomplete Information in Categorical Models of Language Dan Marsden University of Oxford [email protected] We investigate notions of ambiguity and partial information in categorical distributional models of natural language. Probabilistic ambiguity has previously been studied in [27, 26, 16] using Selinger’s CPM construction. This construction works well for models built upon vector spaces, as has been shown in quantum computational applications. Unfortunately, it doesn’t seem to provide a satis- factory method for introducing mixing in other compact closed categories such as the category of sets and binary relations. We therefore lack a uniform strategy for extending a category to model imprecise linguistic information. In this work we adopt a different approach. We analyze different forms of ambiguous and in- complete information, both with and without quantitative probabilistic data. Each scheme then cor- responds to a suitable enrichment of the category in which we model language. We view different monads as encapsulating the informational behaviour of interest, by analogy with their use in mod- elling side effects in computation. Previous results of Jacobs then allow us to systematically construct suitable bases for enrichment. We show that we can freely enrich arbitrary dagger compact closed categories in order to capture all the phenomena of interest, whilst retaining the important dagger compact closed structure. This allows us to construct a model with real convex combination of binary relations that makes non-trivial use of the scalars. Finally we relate our various different enrichments, showing that finite subconvex algebra enrichment covers all the effects under consideration.
    [Show full text]
  • Avoiding the Undefined by Underspecification
    Avoiding the Undefined by Underspecification David Gries* and Fred B. Schneider** Computer Science Department, Cornell University Ithaca, New York 14853 USA Abstract. We use the appeal of simplicity and an aversion to com- plexity in selecting a method for handling partial functions in logic. We conclude that avoiding the undefined by using underspecification is the preferred choice. 1 Introduction Everything should be made as simple as possible, but not any simpler. --Albert Einstein The first volume of Springer-Verlag's Lecture Notes in Computer Science ap- peared in 1973, almost 22 years ago. The field has learned a lot about computing since then, and in doing so it has leaned on and supported advances in other fields. In this paper, we discuss an aspect of one of these fields that has been explored by computer scientists, handling undefined terms in formal logic. Logicians are concerned mainly with studying logic --not using it. Some computer scientists have discovered, by necessity, that logic is actually a useful tool. Their attempts to use logic have led to new insights --new axiomatizations, new proof formats, new meta-logical notions like relative completeness, and new concerns. We, the authors, are computer scientists whose interests have forced us to become users of formal logic. We use it in our work on language definition and in the formal development of programs. This paper is born of that experience. The operation of a computer is nothing more than uninterpreted symbol ma- nipulation. Bits are moved and altered electronically, without regard for what they denote. It iswe who provide the interpretation, saying that one bit string represents money and another someone's name, or that one transformation rep- resents addition and another alphabetization.
    [Show full text]
  • A Quick Algebra Review
    A Quick Algebra Review 1. Simplifying Expressions 2. Solving Equations 3. Problem Solving 4. Inequalities 5. Absolute Values 6. Linear Equations 7. Systems of Equations 8. Laws of Exponents 9. Quadratics 10. Rationals 11. Radicals Simplifying Expressions An expression is a mathematical “phrase.” Expressions contain numbers and variables, but not an equal sign. An equation has an “equal” sign. For example: Expression: Equation: 5 + 3 5 + 3 = 8 x + 3 x + 3 = 8 (x + 4)(x – 2) (x + 4)(x – 2) = 10 x² + 5x + 6 x² + 5x + 6 = 0 x – 8 x – 8 > 3 When we simplify an expression, we work until there are as few terms as possible. This process makes the expression easier to use, (that’s why it’s called “simplify”). The first thing we want to do when simplifying an expression is to combine like terms. For example: There are many terms to look at! Let’s start with x². There Simplify: are no other terms with x² in them, so we move on. 10x x² + 10x – 6 – 5x + 4 and 5x are like terms, so we add their coefficients = x² + 5x – 6 + 4 together. 10 + (-5) = 5, so we write 5x. -6 and 4 are also = x² + 5x – 2 like terms, so we can combine them to get -2. Isn’t the simplified expression much nicer? Now you try: x² + 5x + 3x² + x³ - 5 + 3 [You should get x³ + 4x² + 5x – 2] Order of Operations PEMDAS – Please Excuse My Dear Aunt Sally, remember that from Algebra class? It tells the order in which we can complete operations when solving an equation.
    [Show full text]
  • Lecture 10. Functors and Monads Functional Programming
    Lecture 10. Functors and monads Functional Programming [Faculty of Science Information and Computing Sciences] 0 Goals I Understand the concept of higher-kinded abstraction I Introduce two common patterns: functors and monads I Simplify code with monads Chapter 12 from Hutton’s book, except 12.2 [Faculty of Science Information and Computing Sciences] 1 Functors [Faculty of Science Information and Computing Sciences] 2 Map over lists map f xs applies f over all the elements of the list xs map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (x:xs) = f x : map f xs > map (+1)[1,2,3] [2,3,4] > map even [1,2,3] [False,True,False] [Faculty of Science Information and Computing Sciences] 3 mapTree _ Leaf = Leaf mapTree f (Node l x r) = Node (mapTree f l) (f x) (mapTree f r) Map over binary trees Remember binary trees with data in the inner nodes: data Tree a = Leaf | Node (Tree a) a (Tree a) deriving Show They admit a similar map operation: mapTree :: (a -> b) -> Tree a -> Tree b [Faculty of Science Information and Computing Sciences] 4 Map over binary trees Remember binary trees with data in the inner nodes: data Tree a = Leaf | Node (Tree a) a (Tree a) deriving Show They admit a similar map operation: mapTree :: (a -> b) -> Tree a -> Tree b mapTree _ Leaf = Leaf mapTree f (Node l x r) = Node (mapTree f l) (f x) (mapTree f r) [Faculty of Science Information and Computing Sciences] 4 Map over binary trees mapTree also applies a function over all elements, but now contained in a binary tree > t = Node (Node Leaf 1 Leaf) 2 Leaf > mapTree (+1) t Node
    [Show full text]
  • Nearly Locally Presentable Categories Are Locally Presentable Is Equivalent to Vopˇenka’S Principle
    NEARLY LOCALLY PRESENTABLE CATEGORIES L. POSITSELSKI AND J. ROSICKY´ Abstract. We introduce a new class of categories generalizing locally presentable ones. The distinction does not manifest in the abelian case and, assuming Vopˇenka’s principle, the same happens in the regular case. The category of complete partial orders is the natural example of a nearly locally finitely presentable category which is not locally presentable. 1. Introduction Locally presentable categories were introduced by P. Gabriel and F. Ulmer in [6]. A category K is locally λ-presentable if it is cocomplete and has a strong generator consisting of λ-presentable objects. Here, λ is a regular cardinal and an object A is λ-presentable if its hom-functor K(A, −): K → Set preserves λ-directed colimits. A category is locally presentable if it is locally λ-presentable for some λ. This con- cept of presentability formalizes the usual practice – for instance, finitely presentable groups are precisely groups given by finitely many generators and finitely many re- lations. Locally presentable categories have many nice properties, in particular they are complete and co-wellpowered. Gabriel and Ulmer [6] also showed that one can define locally presentable categories by using just monomorphisms instead all morphisms. They defined λ-generated ob- jects as those whose hom-functor K(A, −) preserves λ-directed colimits of monomor- phisms. Again, this concept formalizes the usual practice – finitely generated groups are precisely groups admitting a finite set of generators. This leads to locally gener- ated categories, where a cocomplete category K is locally λ-generated if it has a strong arXiv:1710.10476v2 [math.CT] 2 Apr 2018 generator consisting of λ-generated objects and every object of K has only a set of strong quotients.
    [Show full text]
  • AN INTRODUCTION to CATEGORY THEORY and the YONEDA LEMMA Contents Introduction 1 1. Categories 2 2. Functors 3 3. Natural Transfo
    AN INTRODUCTION TO CATEGORY THEORY AND THE YONEDA LEMMA SHU-NAN JUSTIN CHANG Abstract. We begin this introduction to category theory with definitions of categories, functors, and natural transformations. We provide many examples of each construct and discuss interesting relations between them. We proceed to prove the Yoneda Lemma, a central concept in category theory, and motivate its significance. We conclude with some results and applications of the Yoneda Lemma. Contents Introduction 1 1. Categories 2 2. Functors 3 3. Natural Transformations 6 4. The Yoneda Lemma 9 5. Corollaries and Applications 10 Acknowledgments 12 References 13 Introduction Category theory is an interdisciplinary field of mathematics which takes on a new perspective to understanding mathematical phenomena. Unlike most other branches of mathematics, category theory is rather uninterested in the objects be- ing considered themselves. Instead, it focuses on the relations between objects of the same type and objects of different types. Its abstract and broad nature allows it to reach into and connect several different branches of mathematics: algebra, geometry, topology, analysis, etc. A central theme of category theory is abstraction, understanding objects by gen- eralizing rather than focusing on them individually. Similar to taxonomy, category theory offers a way for mathematical concepts to be abstracted and unified. What makes category theory more than just an organizational system, however, is its abil- ity to generate information about these abstract objects by studying their relations to each other. This ability comes from what Emily Riehl calls \arguably the most important result in category theory"[4], the Yoneda Lemma. The Yoneda Lemma allows us to formally define an object by its relations to other objects, which is central to the relation-oriented perspective taken by category theory.
    [Show full text]
  • Undefinedness and Soft Typing in Formal Mathematics
    Undefinedness and Soft Typing in Formal Mathematics PhD Research Proposal by Jonas Betzendahl January 7, 2020 Supervisors: Prof. Dr. Michael Kohlhase Dr. Florian Rabe Abstract During my PhD, I want to contribute towards more natural reasoning in formal systems for mathematics (i.e. closer resembling that of actual mathematicians), with special focus on two topics on the precipice between type systems and logics in formal systems: undefinedness and soft types. Undefined terms are common in mathematics as practised on paper or blackboard by math- ematicians, yet few of the many systems for formalising mathematics that exist today deal with it in a principled way or allow explicit reasoning with undefined terms because allowing for this often results in undecidability. Soft types are a way of allowing the user of a formal system to also incorporate information about mathematical objects into the type system that had to be proven or computed after their creation. This approach is equally a closer match for mathematics as performed by mathematicians and has had promising results in the past. The MMT system constitutes a natural fit for this endeavour due to its rapid prototyping ca- pabilities and existing infrastructure. However, both of the aspects above necessitate a stronger support for automated reasoning than currently available. Hence, a further goal of mine is to extend the MMT framework with additional capabilities for automated and interactive theorem proving, both for reasoning in and outside the domains of undefinedness and soft types. 2 Contents 1 Introduction & Motivation 4 2 State of the Art 5 2.1 Undefinedness in Mathematics .
    [Show full text]
  • 1. Language of Operads 2. Operads As Monads
    OPERADS, APPROXIMATION, AND RECOGNITION MAXIMILIEN PEROUX´ All missing details can be found in [May72]. 1. Language of operads Let S = (S; ⊗; I) be a (closed) symmetric monoidal category. Definition 1.1. An operad O in S is a collection of object fO(j)gj≥0 in S endowed with : • a right-action of the symmetric group Σj on O(j) for each j, such that O(0) = I; • a unit map I ! O(1) in S; • composition operations that are morphisms in S : γ : O(k) ⊗ O(j1) ⊗ · · · ⊗ O(jk) −! O(j1 + ··· + jk); defined for each k ≥ 0, j1; : : : ; jk ≥ 0, satisfying natural equivariance, unit and associativity relations. 0 0 A morphism of operads : O ! O is a sequence j : O(j) ! O (j) of Σj-equivariant morphisms in S compatible with the unit map and γ. Example 1.2. ⊗j Let X be an object in S. The endomorphism operad EndX is defined to be EndX (j) = HomS(X ;X), ⊗j with unit idX , and the Σj-right action is induced by permuting on X . Example 1.3. Define Assoc(j) = ` , the associative operad, where the maps γ are defined by equivariance. Let σ2Σj I Com(j) = I, the commutative operad, where γ are the canonical isomorphisms. Definition 1.4. Let O be an operad in S. An O-algebra (X; θ) in S is an object X together with a morphism of operads ⊗j θ : O ! EndX . Using adjoints, this is equivalent to a sequence of maps θj : O(j) ⊗ X ! X such that they are associative, unital and equivariant.
    [Show full text]
  • Categories of Coalgebras with Monadic Homomorphisms Wolfram Kahl
    Categories of Coalgebras with Monadic Homomorphisms Wolfram Kahl To cite this version: Wolfram Kahl. Categories of Coalgebras with Monadic Homomorphisms. 12th International Workshop on Coalgebraic Methods in Computer Science (CMCS), Apr 2014, Grenoble, France. pp.151-167, 10.1007/978-3-662-44124-4_9. hal-01408758 HAL Id: hal-01408758 https://hal.inria.fr/hal-01408758 Submitted on 5 Dec 2016 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Distributed under a Creative Commons Attribution| 4.0 International License Categories of Coalgebras with Monadic Homomorphisms Wolfram Kahl McMaster University, Hamilton, Ontario, Canada, [email protected] Abstract. Abstract graph transformation approaches traditionally con- sider graph structures as algebras over signatures where all function sym- bols are unary. Attributed graphs, with attributes taken from (term) algebras over ar- bitrary signatures do not fit directly into this kind of transformation ap- proach, since algebras containing function symbols taking two or more arguments do not allow component-wise construction of pushouts. We show how shifting from the algebraic view to a coalgebraic view of graph structures opens up additional flexibility, and enables treat- ing term algebras over arbitrary signatures in essentially the same way as unstructured label sets.
    [Show full text]
  • Complex Analysis Class 24: Wednesday April 2
    Complex Analysis Math 214 Spring 2014 Fowler 307 MWF 3:00pm - 3:55pm c 2014 Ron Buckmire http://faculty.oxy.edu/ron/math/312/14/ Class 24: Wednesday April 2 TITLE Classifying Singularities using Laurent Series CURRENT READING Zill & Shanahan, §6.2-6.3 HOMEWORK Zill & Shanahan, §6.2 3, 15, 20, 24 33*. §6.3 7, 8, 9, 10. SUMMARY We shall be introduced to Laurent Series and learn how to use them to classify different various kinds of singularities (locations where complex functions are no longer analytic). Classifying Singularities There are basically three types of singularities (points where f(z) is not analytic) in the complex plane. Isolated Singularity An isolated singularity of a function f(z) is a point z0 such that f(z) is analytic on the punctured disc 0 < |z − z0| <rbut is undefined at z = z0. We usually call isolated singularities poles. An example is z = i for the function z/(z − i). Removable Singularity A removable singularity is a point z0 where the function f(z0) appears to be undefined but if we assign f(z0) the value w0 with the knowledge that lim f(z)=w0 then we can say that we z→z0 have “removed” the singularity. An example would be the point z = 0 for f(z) = sin(z)/z. Branch Singularity A branch singularity is a point z0 through which all possible branch cuts of a multi-valued function can be drawn to produce a single-valued function. An example of such a point would be the point z = 0 for Log (z).
    [Show full text]
  • Control Systems
    ECE 380: Control Systems Course Notes: Winter 2014 Prof. Shreyas Sundaram Department of Electrical and Computer Engineering University of Waterloo ii c Shreyas Sundaram Acknowledgments Parts of these course notes are loosely based on lecture notes by Professors Daniel Liberzon, Sean Meyn, and Mark Spong (University of Illinois), on notes by Professors Daniel Davison and Daniel Miller (University of Waterloo), and on parts of the textbook Feedback Control of Dynamic Systems (5th edition) by Franklin, Powell and Emami-Naeini. I claim credit for all typos and mistakes in the notes. The LATEX template for The Not So Short Introduction to LATEX 2" by T. Oetiker et al. was used to typeset portions of these notes. Shreyas Sundaram University of Waterloo c Shreyas Sundaram iv c Shreyas Sundaram Contents 1 Introduction 1 1.1 Dynamical Systems . .1 1.2 What is Control Theory? . .2 1.3 Outline of the Course . .4 2 Review of Complex Numbers 5 3 Review of Laplace Transforms 9 3.1 The Laplace Transform . .9 3.2 The Inverse Laplace Transform . 13 3.2.1 Partial Fraction Expansion . 13 3.3 The Final Value Theorem . 15 4 Linear Time-Invariant Systems 17 4.1 Linearity, Time-Invariance and Causality . 17 4.2 Transfer Functions . 18 4.2.1 Obtaining the transfer function of a differential equation model . 20 4.3 Frequency Response . 21 5 Bode Plots 25 5.1 Rules for Drawing Bode Plots . 26 5.1.1 Bode Plot for Ko ....................... 27 5.1.2 Bode Plot for sq ....................... 28 s −1 s 5.1.3 Bode Plot for ( p + 1) and ( z + 1) .
    [Show full text]
  • Algebraic Structures Lecture 18 Thursday, April 4, 2019 1 Type
    Harvard School of Engineering and Applied Sciences — CS 152: Programming Languages Algebraic structures Lecture 18 Thursday, April 4, 2019 In abstract algebra, algebraic structures are defined by a set of elements and operations on those ele- ments that satisfy certain laws. Some of these algebraic structures have interesting and useful computa- tional interpretations. In this lecture we will consider several algebraic structures (monoids, functors, and monads), and consider the computational patterns that these algebraic structures capture. We will look at Haskell, a functional programming language named after Haskell Curry, which provides support for defin- ing and using such algebraic structures. Indeed, monads are central to practical programming in Haskell. First, however, we consider type constructors, and see two new type constructors. 1 Type constructors A type constructor allows us to create new types from existing types. We have already seen several different type constructors, including product types, sum types, reference types, and parametric types. The product type constructor × takes existing types τ1 and τ2 and constructs the product type τ1 × τ2 from them. Similarly, the sum type constructor + takes existing types τ1 and τ2 and constructs the product type τ1 + τ2 from them. We will briefly introduce list types and option types as more examples of type constructors. 1.1 Lists A list type τ list is the type of lists with elements of type τ. We write [] for the empty list, and v1 :: v2 for the list that contains value v1 as the first element, and v2 is the rest of the list. We also provide a way to check whether a list is empty (isempty? e) and to get the head and the tail of a list (head e and tail e).
    [Show full text]