SlideShare a Scribd company logo
Function type
Dmytro Mitin
https://stepik.org/course/Introduction-to-programming-
with-dependent-types-in-Scala-2294/
March 2017
Dmytro Mitin Function type
Sets
Relation
R ⊂ A × B
a R b ⇐⇒ (a, b) ∈ R
Function
f : A → B
y = f (x) ⇐⇒ x f y ⇐⇒ (x, y) ∈ f
∀x ∈ A ∃! y ∈ B y = f (x)
Dmytro Mitin Function type
Function type
1 Type Formation
Γ A : ∗ Γ B : ∗
Γ A → B : ∗
2 Constructor
Γ, x : A b : B Γ B : ∗
Γ λx.b : A → B
3 Eliminator
Γ f : A → B Γ a : A
Γ f a : B
Dmytro Mitin Function type
Function type
4 Computation rule (β-reduction)
Γ, x : A b : B Γ a : A Γ B : ∗
Γ (λx.b) a ≡ b[x ← a] : B
5 Uniqueness principle (η-conversion)
Γ f : A → B
Γ λx. f x ≡ f : A → B
Dmytro Mitin Function type
Haskell, Scala and Java
Haskell
f :: a -> b
f = undefined
Scala
def f[A, B](x: A): B = ???
def g[A, B]: Function1[A, B] = ???
def h[A, B]: A => B = ???
Java
public <A, B> B f(A x) {
return null;
}
public <A, B> Function<A, B> g() {
return null;
}
import java.util.function.Function;
Dmytro Mitin Function type
ProvingGround
git clone https://github.com/siddhartha-gadgil/ProvingGround.git
cd ProvingGround
sbt mantle/test:console
val A = "A" :: Type
val B = "B" :: Type
val f = "f" :: A ->: B
val a = "a" :: A
val b = f (a) !: B
val g = a :-> a !: A ->: A
import ScalaRep.
import NatInt.rep
val h = ((x: Int) => x * x).term !: NatInt ->: NatInt
h(2.term) == 4.term
Dmytro Mitin Function type

More Related Content

What's hot

Function presentation
Function presentationFunction presentation
Function presentation
jamil sadiq
 
2) quadratics gral form
2) quadratics gral form2) quadratics gral form
2) quadratics gral form
estelav
 
Module 6.7
Module 6.7Module 6.7
Module 6.7
mathwithcoachhall
 
Ib maths sl derivatives of transcendental functions
Ib maths sl derivatives of transcendental functionsIb maths sl derivatives of transcendental functions
Ib maths sl derivatives of transcendental functionsestelav
 
โจทย์ Java
โจทย์ Javaโจทย์ Java
โจทย์ Javaxuou888
 
Forms of Quadratics
Forms of QuadraticsForms of Quadratics
Forms of Quadratics
mrodolewicz
 
5.8 rectilinear motion
5.8 rectilinear motion5.8 rectilinear motion
5.8 rectilinear motiondicosmo178
 
5.5 optimization
5.5 optimization5.5 optimization
5.5 optimizationdicosmo178
 
5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theoremdicosmo178
 
5.2 first and second derivative test
5.2 first and second derivative test5.2 first and second derivative test
5.2 first and second derivative testdicosmo178
 
Please show a screenshot of the code. Thank you. Solve the function F= 25x^2...
Please show a screenshot of the code. Thank you.  Solve the function F= 25x^2...Please show a screenshot of the code. Thank you.  Solve the function F= 25x^2...
Please show a screenshot of the code. Thank you. Solve the function F= 25x^2...
hwbloom3
 

What's hot (15)

Function presentation
Function presentationFunction presentation
Function presentation
 
2) quadratics gral form
2) quadratics gral form2) quadratics gral form
2) quadratics gral form
 
Module 6.7
Module 6.7Module 6.7
Module 6.7
 
Ib maths sl derivatives of transcendental functions
Ib maths sl derivatives of transcendental functionsIb maths sl derivatives of transcendental functions
Ib maths sl derivatives of transcendental functions
 
โจทย์ Java
โจทย์ Javaโจทย์ Java
โจทย์ Java
 
Activity 02
Activity 02Activity 02
Activity 02
 
Forms of Quadratics
Forms of QuadraticsForms of Quadratics
Forms of Quadratics
 
Activity 2
Activity 2Activity 2
Activity 2
 
5.8 rectilinear motion
5.8 rectilinear motion5.8 rectilinear motion
5.8 rectilinear motion
 
5.5 optimization
5.5 optimization5.5 optimization
5.5 optimization
 
Ch17 25
Ch17 25Ch17 25
Ch17 25
 
5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem
 
5.2 first and second derivative test
5.2 first and second derivative test5.2 first and second derivative test
5.2 first and second derivative test
 
0411 ch 4 day 11
0411 ch 4 day 110411 ch 4 day 11
0411 ch 4 day 11
 
Please show a screenshot of the code. Thank you. Solve the function F= 25x^2...
Please show a screenshot of the code. Thank you.  Solve the function F= 25x^2...Please show a screenshot of the code. Thank you.  Solve the function F= 25x^2...
Please show a screenshot of the code. Thank you. Solve the function F= 25x^2...
 

Similar to 11 - Scala. Function type

15 - Scala. Dependent function type (Π-type)
15 - Scala. Dependent function type (Π-type)15 - Scala. Dependent function type (Π-type)
15 - Scala. Dependent function type (Π-type)
Roman Brovko
 
09 - Scala. Product type
09 - Scala. Product type09 - Scala. Product type
09 - Scala. Product type
Roman Brovko
 
Eliminators into dependent types
Eliminators into dependent typesEliminators into dependent types
Eliminators into dependent types
Dmytro Mitin
 
19 - Scala. Eliminators into dependent types (induction)
19 - Scala. Eliminators into dependent types (induction)19 - Scala. Eliminators into dependent types (induction)
19 - Scala. Eliminators into dependent types (induction)
Roman Brovko
 
Sigma type
Sigma typeSigma type
Sigma type
Dmytro Mitin
 
13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)
Roman Brovko
 
03 - Scala. Boolean type
03 - Scala. Boolean type03 - Scala. Boolean type
03 - Scala. Boolean type
Roman Brovko
 

Similar to 11 - Scala. Function type (7)

15 - Scala. Dependent function type (Π-type)
15 - Scala. Dependent function type (Π-type)15 - Scala. Dependent function type (Π-type)
15 - Scala. Dependent function type (Π-type)
 
09 - Scala. Product type
09 - Scala. Product type09 - Scala. Product type
09 - Scala. Product type
 
Eliminators into dependent types
Eliminators into dependent typesEliminators into dependent types
Eliminators into dependent types
 
19 - Scala. Eliminators into dependent types (induction)
19 - Scala. Eliminators into dependent types (induction)19 - Scala. Eliminators into dependent types (induction)
19 - Scala. Eliminators into dependent types (induction)
 
Sigma type
Sigma typeSigma type
Sigma type
 
13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)
 
03 - Scala. Boolean type
03 - Scala. Boolean type03 - Scala. Boolean type
03 - Scala. Boolean type
 

More from Roman Brovko

Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task Networking
Roman Brovko
 
Networking essentials lect3
Networking essentials lect3Networking essentials lect3
Networking essentials lect3
Roman Brovko
 
Gl embedded starterkit_ethernet
Gl embedded starterkit_ethernetGl embedded starterkit_ethernet
Gl embedded starterkit_ethernet
Roman Brovko
 
Networking essentials lect2
Networking essentials lect2Networking essentials lect2
Networking essentials lect2
Roman Brovko
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1
Roman Brovko
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flash
Roman Brovko
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
Roman Brovko
 
Glesk worshop
Glesk worshopGlesk worshop
Glesk worshop
Roman Brovko
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
Roman Brovko
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensor
Roman Brovko
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwm
Roman Brovko
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttons
Roman Brovko
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_world
Roman Brovko
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisites
Roman Brovko
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advanced
Roman Brovko
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advanced
Roman Brovko
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advanced
Roman Brovko
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
Roman Brovko
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advanced
Roman Brovko
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basics
Roman Brovko
 

More from Roman Brovko (20)

Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task Networking
 
Networking essentials lect3
Networking essentials lect3Networking essentials lect3
Networking essentials lect3
 
Gl embedded starterkit_ethernet
Gl embedded starterkit_ethernetGl embedded starterkit_ethernet
Gl embedded starterkit_ethernet
 
Networking essentials lect2
Networking essentials lect2Networking essentials lect2
Networking essentials lect2
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flash
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
 
Glesk worshop
Glesk worshopGlesk worshop
Glesk worshop
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensor
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwm
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttons
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_world
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisites
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advanced
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advanced
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advanced
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advanced
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basics
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 

11 - Scala. Function type