The theory behind Functional Programming Functional: based on lambda calculus / combinators, recursion theory, category theory. By contrast with other.

Slides:



Advertisements
Similar presentations
Discrete Structures Chapter 5 Pigeonhole Principle Nurul Amelina Nasharuddin Multimedia Department.
Advertisements

I. Homomorphisms & Isomorphisms II. Computing Linear Maps III. Matrix Operations VI. Change of Basis V. Projection Topics: Line of Best Fit Geometry of.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Taylor Expansion Diagrams (TED): Verification EC667: Synthesis and Verification of Digital Systems Spring 2011 Presented by: Sudhan.
modified from UCI ICS/Math 6D, Fall Sets+Functions-1 Sets “Set”=Unordered collection of Objects “Set Elements”
1 Category Theory in a ( E,M ) -category Some aspects of category theory, in particular related to universality, can be developed in any finitely complete.
Partially Ordered Sets (POSets)
Relations Chapter 9.
The Relationship between Topology and Logic Dr Christopher Townsend (Open University)
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Composition and Substitution: Learning about Language from Algebra Ken Presting University of North Carolina at Chapel Hill.
Category Theory By: Ashley Reynolds. HISTORY OF CATEGORY THEORY  In 1942–45, Samuel Eilenberg and Saunders Mac Lane introduced categories, functors,
Math 3121 Abstract Algebra I Lecture 3 Sections 2-4: Binary Operations, Definition of Group.
Mathematics. Session Functions, Limits and Continuity-1.
Solving fixpoint equations
Hierarchied Categories Abelian categories, hierarchied abelian categories, graded hierarchied tensor categories Abelian categories, hierarchied abelian.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
2 2.1 © 2016 Pearson Education, Inc. Matrix Algebra MATRIX OPERATIONS.
Chapter 3 Functions Functions provide a means of expressing relationships between variables, which can be numbers or non-numerical objects.
Categories and Computer Science
MA5209 Algebraic Topology Wayne Lawton Department of Mathematics National University of Singapore S ,
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Sets and Functions Contents  Set language  Basic knowledge on sets  Intervals  Functions (Mappings)
Chapter 5 – Relations and Functions. 5.1Cartesian Products and Relations Definition 5.1: For sets A, B  U, the Cartesian product, or cross product, of.
Triangulated Categories. Jaber Akbari May 2015.
Unit 3.2 Properties of Real Functions ‘Real function’ refers to a function whose domain and range are sets of real numbers.
Relations and their Properties
AGC DSP AGC DSP Professor A G Constantinides©1 Signal Spaces The purpose of this part of the course is to introduce the basic concepts behind generalised.
Mathematical Preliminaries
Projective Geometry Hu Zhan Yi. Entities At Infinity The ordinary space in which we lie is Euclidean space. The parallel lines usually do not intersect.
DISCRETE COMPUTATIONAL STRUCTURES
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
Relation. Combining Relations Because relations from A to B are subsets of A x B, two relations from A to B can be combined in any way two sets can be.
Problem Statement How do we represent relationship between two related elements ?
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
Great Theoretical Ideas in Computer Science.
Chapter 2 Functions and Graphs Copyright © 2014, 2010, 2007 Pearson Education, Inc Combinations of Functions; Composite Functions.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Point in Polygon Analysis for Moving Objects Farid Karimipour Mahmoud R. Delavar Andrew U. Frank Hani Rezayan University of Tehran, Iran Technical University.
Lecture 3: Object Concepts as Categories Nick Rossiter, Computing Science, Newcastle University, England
Chapter 6- LINEAR MAPPINGS LECTURE 8 Prof. Dr. Zafer ASLAN.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
Zigzag Persistent Homology Survey
Unit-III Algebraic Structures
Applied Discrete Mathematics Week 2: Functions and Sequences
Axioms for a category of spaces
Warm-up (10 min. – No Talking)
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
… and the following mathematical appetizer is about…
Functions.
Functions.
… and the following mathematical appetizer is about…
Combinations of Functions; Composite Functions
Denotational Semantics (Denotational Semantics)
DISCRETE COMPUTATIONAL STRUCTURES
Relations and their Properties
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
… and the following mathematical appetizer is about…
Functions Rosen 6th ed., §2.3.
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Properties of Relations
Category theory and structuralism
Properties of Numbers Review Problems.
Presentation transcript:

The theory behind Functional Programming Functional: based on lambda calculus / combinators, recursion theory, category theory. By contrast with other paradigms: Functions ONLY! Defining functions Defining data types

Category Theory Abstract view of functions as “arrows” with domains and codomains as their “source” and “target” objects Things to watch: How we compose arrows Which arrows can be composed How objects can be seen as identity arrows How we connect categories with functors

Resources on Category Theory +Category+Theory+&ie=utf-8&oe=utf- 8&aq=t&rls=org.mozilla:en- US:official&client=firefox-a

Definition of a Category Tw classes: Objects A,B,C,… and Arrows f,g,h,… For each arrow f : A->B, two objects A=dom(f) B=cod(f) If f:A->B and g:B->C, their composition, denoted g. f : A->C exists For each object A the arrow 1_A : A->A exists For arrows f:A->B,g:B->C,h:C->D composition is associative: h. (g. f) = (h. g).f For f:A->B, 1_A is a unit arrow: f. 1_A=f=1_B. f

Examples of Categories Finite sets with functions Groups with group homomorphisms Vector spaces with linear mappings Graphs with graph homomorphisms Topological spaces with continuous functions Posets and monotone functions

Functional programming seen as a category Objects: monomorphic data types: Integer, Boolean, records of employees Arrows: functions between data types Id:: a -> a provides 1_a for each type a “.” provides composition – and it is defined if types match Function composition is associative

Functors a (covariant) functor F : C → D: – for each object x in C, an object F(x) in D – for each arrow f : x → y in C, an arrow F(f) : F(x) → F(y), such that the following two properties hold: – For every object x in C, F(1 x ) = 1 F(x) ; – For all morphisms f : x → y and g : y → z, F(g ∘ f) = F(g) ∘ F(f). Of special interest: endofunctors F:C->C

The Initial Algebra Semantics for polymorphic data types (1) F-algebra: can be used to represent data structures used in programming, such as lists and trees. Defined such that the following diagram commutes:data structuresprogramminglists

The Initial Algebra Semantics for polymorphic data types (2) the functor F: Set -> Set that sends a set X to 1+X + denotes the usual coproduct (also called “sum”) given by disjoint union, and 1 is a terminal object (i.e. any singleton set) the set N of natural numbers together with the function succ : 1+N->N, is the + of the functions zero : 1->N (whose image is 0) and succ : 1+N->N (which sends an integer n to n+1) is an initial F- algebra

The Initial Algebra Semantics for polymorphic data types (3) Types defined by using least fixed point construct with functor F can be regarded as an initial F- algebra, provided that parametricity holds for the typeleast fixed pointparametricity Examples: data N = Zero | Succ N data List a = Nil | Cons a (List a) map provides the functor definition for lists: it preserves the structure while changing its payload

More Functors Folds