CSE S. Tanimoto Introduction to ML

Slides:



Advertisements
Similar presentations
Functional Programming Lecture 10 - type checking.
Advertisements

Cs776 (Prasad)L4Poly1 Polymorphic Type System. cs776 (Prasad)L4Poly2 Goals Allow expression of “for all types T” fun I x = x I : ’a -> ’a Allow expression.
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Copyright © Cengage Learning. All rights reserved.
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Functional Design and Programming Lecture 1: Functional modeling, design and programming.
1 Lecture 3 Topics –Languages –Language classes –Closure properties.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
Introduction to ML You will be responsible for learning ML on your own. Today I will cover some basics Read Robert Harper’s notes on “an introduction to.
Sets 1.
Sets 1.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
The Recursion Theorem Pages 217– ADVANCED TOPICS IN C O M P U T A B I L I T Y THEORY.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
CSE S. Tanimoto Introduction to ML 1 Introduction to ML History Special features Interacting with ML ML’s basic types ML’s composite types Math.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
PZ03EX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03EX - ML Programming Language Design and Implementation.
A Third Look At ML Chapter NineModern Programming Languages, 2nd ed.1.
CompSci 102 Discrete Math for Computer Science
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
1 Alex Proctor and Brian Lee for CSCI 431 at UNCA, Fall 2002 ML (Meta Language) a brief introduction Alex Proctor and Brian Lee For CSCI 431 at the University.
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
Homogeneous tuples What are they? –S 2 = S x S –S n = S x S x … x S Cardinalities –#(S 2 )= (#S) 2 –#(S n )= (#S) n –#(S 0 )= (#S) 0 =1 What is S 0 ? –It.
Chapter 2 With Question/Answer Animations. Section 2.1.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Type Checking and Type Inference
CSE341: Programming Languages Lecture 11 Type Inference
ML: a quasi-functional language with strong typing
CS 326 Programming Languages, Concepts and Implementation
Representation, Syntax, Paradigms, Types
A lightening tour in 45 minutes
ML Programming Language Design and Implementation (4th Edition)
CSE 3302 Programming Languages
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
FP Foundations, Scheme In Text: Chapter 14.
Representation, Syntax, Paradigms, Types
Applied Discrete Mathematics Week 6: Relations/Digraphs
CSE 341 Section 5 Winter 2018.
CSE S. Tanimoto Introduction to ML
CSE341: Programming Languages Lecture 11 Type Inference
ML’s Type Inference and Polymorphism
Mathematical Background 1
Representation, Syntax, Paradigms, Types
Mathematical Background 1
CSE S. Tanimoto Paradigms
CSE S. Tanimoto Introduction to ML
MCS680: Foundations Of Computer Science
ML’s Type Inference and Polymorphism
Representation, Syntax, Paradigms, Types
Mathematical Background
The Data Element.
Sub-system interfaces
CSE S. Tanimoto Turing Completeness
CSE341: Programming Languages Lecture 11 Type Inference
CSE S. Tanimoto Introduction to ML
ML’s Type Inference and Polymorphism
The Data Element.
ML’s Type Inference and Polymorphism
CSE341: Programming Languages Lecture 11 Type Inference
Drew Wyborski Programming Languages
Terminology and Symbols
Presentation transcript:

CSE 341 -- S. Tanimoto Introduction to ML History Special features Interacting with ML ML’s basic types ML’s composite types Math. background for type description. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML History Early 1970s: Design and implementation of ML by Milner, Morris, and Wadsworth at the Univ. of Edinburgh, Scotland. ML: Metalanguage of the Edinburgh LCF system. LCF = Logic for Computable Functions Gordon, Michael, Robin Milner, and Christopher Wadsworth. "Edinburgh LCF: A Mechanized Logic of Computation," Lecture Notes in Computer Science, Vol.78, Springer-Verlag, NY, 1979. Mid 1980s: Standardization of ML. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Special Features A higher-order functional language. Statically type-checked, but polymorphic. Incorporates automatic type inference. Incorporates pattern matching. Garbage-collected. Has a formal semantics. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Interaction with ML ML, like Lisp, provides a READ-EVAL-PRINT loop. Whenever ML prints the value of an expression, it also prints the TYPE of the value. ML keeps track of the types of variables and functions by solving systems of constraints. ML does not use assignment. On the other hand, it does use binding. Thus it uses the ‘=‘ sign in a mathematical sense. val flavor = "strawberry" ; binds a string to an identifier. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Sample Interactions 3 * 5 ; val it = 8 : int real(8); val it = 8.0 : real 8.0 + real(1); val it = 9.0 : real CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML ML’s Basic Types 3 * 5 ; val it = 8 : int 3.0 * 5.0 ; val it = 8.0 : real true ; val it = true : bool "rock" ^ "candy" ; val it = "rockcandy" : string #"a" ; val it = #"a" : char CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML ML’s Composite Types Tuples: val mytuple = (26, "Oct." , 2001); val mytuple = (26, "Oct." , 2001) : int * string * int Each component can have a different type. Lists: [1, 2, 3] ; val it = [1, 2, 3] : int list ["nice"]; val it = ["nice"] : string list All components must have the same type. CSE 341 -- S. Tanimoto Introduction to ML

Math Background to Formal Representation of Types Set: a collection of items. Binary relation: a set of ordered pairs, whose elements come from a first set and a second set, which may be identical, partially overlapping, or disjoint. Cartesian product S1  S2  ...  Sn of sets S1, S2, ..., Sn. Function: A special kind of binary relation. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Set A collection of items. Must be well-defined, so that there is, in principle, a criterion that can be used to decide the membership of any item in the set. The set of all letters of the English alphabet. The set of all positive integers. NOT: The set of all sets that are not members of themselves. (SOASTANMOT). Is SOASTANMOT in SOASTANMOT? If so, then SOASTANMOT violates its own definition; if not,then it SHOULD be in SOASTANMOT. This is known as Russell’s paradox. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Binary Relation A set of ordered pairs. First element comes from a set called the domain. Second element comes from a set called the codomain. D1 = {a, b, c} C1 = {0, 1} B1 = {(a, 0), (a, 1), (c, 0), (c, 1)} B1 is a binary with domain D1 and codomain C1. Often, however, the domain and codomain are identical. D2 = C2 = {a, b, c} B2 = { (a, a), (b, b), (c, c), (a, c), (c, a)} B2 is a binary relation on D2. CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Cartesian Product A way to combine sets to get new sets. Let S1 = {a, b, c} Let S2 = {1, 2} S1  S2 = { (a,1), (a,2), (b,1), (b,2), (c,1), (c,2) } A three-way cartesian product: S2  S2  S2 = { (1,1,1), (1,1,2), (1,2,1), (1,2,2), (2,1,1), (2,1,2), (2,2,1), (2,2,2) } This is not equivalent to (S2  S2 )  S2 or S2  (S2  S2 ). CSE 341 -- S. Tanimoto Introduction to ML

CSE 341 -- S. Tanimoto Introduction to ML Function Function: A binary relation whose first components are from a set called the domain, and whose second components are from a set called the range, and such that each domain element is paired with one and only one range element. D = {a, b, c}; R = {0, 1} F = { (a,0), (b,0), (c,1)} is a function from D to R. F: D  R B = { (a,0), (a,1), (b,0), (c,0) } is not a function. CSE 341 -- S. Tanimoto Introduction to ML