SlideShare a Scribd company logo
Dependent pair type (Σ-type)
Dmytro Mitin
https://stepik.org/course/Introduction-to-programming-
with-dependent-types-in-Scala-2294/
March 2017
Dmytro Mitin Dependent pair type (Σ-type)
Sets
Union of set family
α∈A
Bα = b ∃α ∈ A b ∈ Bα
Disjoint union of set family
α∈A
Bα = (α, b) α ∈ A , b ∈ Bα
Dmytro Mitin Dependent pair type (Σ-type)
Dependent pair type (Σ-type)
1 Type Formation
Γ A : ∗ Γ, x : A B : ∗
Γ
x:A
B : ∗
2 Constructor
Γ a : A Γ, x : A B : ∗ Γ b : B[x ← a]
Γ (a, b) :
x:A
B
3 Eliminators
Γ p :
x:A
B
Γ fst p : A
Γ p :
x:A
B
Γ snd p : B[x ← fst p]
Dmytro Mitin Dependent pair type (Σ-type)
Dependent pair type (Σ-type)
4 Computation rules (”β-reduction“)
Γ a : A Γ, x : A B : ∗ Γ b : B[x ← a]
Γ fst(a, b) ≡ a : A
Γ a : A Γ, x : A B : ∗ Γ b : B[x ← a]
Γ snd(a, b) ≡ b : B
5 Uniqueness principle (”η-conversion“)
Γ p :
x:A
B
Γ (fst p, snd p) ≡ p :
x:A
B
Dmytro Mitin Dependent pair type (Σ-type)
Partial case
Partial case of
x:A
B
is sum type (coproduct)
B1 + B2
Dmytro Mitin Dependent pair type (Σ-type)
Idris
data DepPair : (a : Type) -> (P : a -> Type) -> Type where
MakeDepPair : {P : a -> Type} -> (x : a) -> P x -> DepPair a P
depType : Int -> Type
depType 0 = Int
depType 1 = String
depType = Bool
x : DepPair Int (n => depType n)
x = MakeDepPair 1 "a"
x1 : DepPair Int (n => depType n)
x1 = MakeDepPair 0 10
x2 : DepPair Int (n => depType n)
x2 = MakeDepPair 2 True
Dmytro Mitin Dependent pair type (Σ-type)
Idris
x3 : DepPair Int (n => depType n)
x3 = MakeDepPair 0 "a"
Dmytro Mitin Dependent pair type (Σ-type)
Scala
sealed trait Nat {
type This >: this.type <: Nat
type ++ = Succ[This]
}
final object Zero extends Nat {
type This = Zero
}
type Zero = Zero.type
final class Succ[N <: Nat] extends Nat {
type This = Succ[N]
}
Dmytro Mitin Dependent pair type (Σ-type)
Scala
type 0 = Zero
type 1 = 0 # ++
type 2 = 1 # ++
type 3 = 2 # ++
val 0: 0 = Zero
val 1: 1 = new Succ[ 0]
val 2: 2 = new Succ[ 1]
val 3: 3 = new Succ[ 2]
Dmytro Mitin Dependent pair type (Σ-type)
Scala
sealed trait DepType[N <: Nat] { type T }
implicit object depType0 extends DepType[ 0] { type T = Int }
implicit object depType1 extends DepType[ 1] { type T = String }
implicit def depType[N <: Nat] = new DepType[Succ[Succ[N]]] {
type T = Boolean }
case class DepPair[N <: Nat, V](x: N, value: V)(implicit
depType: DepType[N] { type T = V })
DepPair( 0, 10)
DepPair( 1, "aaa")
DepPair( 2, true)
DepPair( 2, "bbb") // error
DepPair( 3, false)
Dmytro Mitin Dependent pair type (Σ-type)
ProvingGround. Built-in type
git clone https://github.com/siddhartha-gadgil/ProvingGround.git
cd ProvingGround
sbt mantle/test:console
val A = "A" :: Type
val B = "B( : A)" :: A ->: Type
val a = "a" :: A
val b = "b" :: B(a)
val pair = mkPair(a, b) !: Sgma(a !: A, B(a))
val recSABA = Sgma(a !: A, B(a)).rec(A)
val first = recSABA(a :∼> (b :-> a))
first(pair) == a
val recSABSAB = Sgma(a !: A, B(a)).rec(Sgma(a !: A, B(a)))
val id = recSABSAB(a :∼> (b :->
mkPair(a, b).asInstanceOf[DepPair[Term, Term]]))
id(pair) == pair
Dmytro Mitin Dependent pair type (Σ-type)
ProvingGround. Custom type
import TLImplicits.
import shapeless.
val A = "A" :: Type
val B = "B( : A)" :: A ->: Type
val a = "a" :: A
val b = "b" :: B(a)
val SigmaAB = "Sigma(a : A, B(a))" :: Type
val SigmaInd = ("mkPair" ::: a ∼>>: (B(a) ->>: SigmaAB))
=: SigmaAB
val makePair :: HNil = SigmaInd.intros
val pair = makePair(a)(b) !: SigmaAB
val recSABA = SigmaInd.rec(A)
val first = recSABA(a :∼> (b :-> a))
first(pair) == a
val recSABSAB = SigmaInd.rec(SigmaAB)
val id = recSABSAB(a :∼> (b :-> makePair(a)(b)))
id(pair) == pair
Dmytro Mitin Dependent pair type (Σ-type)

More Related Content

What's hot

Monoids, monoids, monoids
Monoids, monoids, monoidsMonoids, monoids, monoids
Monoids, monoids, monoids
Luka Jacobowitz
 
Oh, All the things you'll traverse
Oh, All the things you'll traverseOh, All the things you'll traverse
Oh, All the things you'll traverse
Luka Jacobowitz
 
Type classes
Type classesType classes
Type classes
Dmytro Mitin
 
16 - Scala. Type of length-indexed vectors
16 - Scala. Type of length-indexed vectors16 - Scala. Type of length-indexed vectors
16 - Scala. Type of length-indexed vectors
Roman Brovko
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
Brendan Eich
 
Testing in the World of Functional Programming
Testing in the World of Functional ProgrammingTesting in the World of Functional Programming
Testing in the World of Functional Programming
Luka Jacobowitz
 
oop presentation note
oop presentation note oop presentation note
oop presentation note
Atit Patumvan
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Brendan Eich
 
Kotlin Delegates: Reduce the boilerplate
Kotlin Delegates: Reduce the boilerplateKotlin Delegates: Reduce the boilerplate
Kotlin Delegates: Reduce the boilerplate
Dmytro Zaitsev
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
Selvin Josy Bai Somu
 
Constructors
ConstructorsConstructors
Constructors
shravani2191
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
Johan Tibell
 
Review constdestr
Review constdestrReview constdestr
Review constdestr
rajudasraju
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScript
Brendan Eich
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Kamal Acharya
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
Web futures
Web futuresWeb futures
Web futures
Brendan Eich
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS Responsibilities
Brendan Eich
 

What's hot (18)

Monoids, monoids, monoids
Monoids, monoids, monoidsMonoids, monoids, monoids
Monoids, monoids, monoids
 
Oh, All the things you'll traverse
Oh, All the things you'll traverseOh, All the things you'll traverse
Oh, All the things you'll traverse
 
Type classes
Type classesType classes
Type classes
 
16 - Scala. Type of length-indexed vectors
16 - Scala. Type of length-indexed vectors16 - Scala. Type of length-indexed vectors
16 - Scala. Type of length-indexed vectors
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
 
Testing in the World of Functional Programming
Testing in the World of Functional ProgrammingTesting in the World of Functional Programming
Testing in the World of Functional Programming
 
oop presentation note
oop presentation note oop presentation note
oop presentation note
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
 
Kotlin Delegates: Reduce the boilerplate
Kotlin Delegates: Reduce the boilerplateKotlin Delegates: Reduce the boilerplate
Kotlin Delegates: Reduce the boilerplate
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 
Constructors
ConstructorsConstructors
Constructors
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Review constdestr
Review constdestrReview constdestr
Review constdestr
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScript
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Web futures
Web futuresWeb futures
Web futures
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS Responsibilities
 

Viewers also liked

Moodboard as
Moodboard asMoodboard as
Moodboard as
ellendavi
 
Dental courses in delhi
Dental courses in delhiDental courses in delhi
Dental courses in delhi
Rajat Sachdeva
 
Cетевое общество. Духовно-нравственное развитие личности
Cетевое общество. Духовно-нравственное развитие личностиCетевое общество. Духовно-нравственное развитие личности
Cетевое общество. Духовно-нравственное развитие личности
Мобильное Электронное Образование
 
погоріла о. с.
погоріла о. с.погоріла о. с.
погоріла о. с.
semyurihor
 
стецько н. б.
стецько н. б.стецько н. б.
стецько н. б.
semyurihor
 
туркула л. в.
туркула л. в.туркула л. в.
туркула л. в.
semyurihor
 
тима о. о.
тима о. о.тима о. о.
тима о. о.
semyurihor
 
Hotdesking Feedback
Hotdesking FeedbackHotdesking Feedback
Hotdesking Feedback
j1huntridgedixon
 
Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...
Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...
Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...
Ekonomikas ministrija/ Dzīvo siltāk
 
Viruses, worms, and trojan horses
Viruses, worms, and trojan horsesViruses, worms, and trojan horses
Viruses, worms, and trojan horses
EILLEN IVY PORTUGUEZ
 
Data Science Portugal Meetup 7 - Machine Learning & Data Science Safety Remi...
Data Science Portugal  Meetup 7 - Machine Learning & Data Science Safety Remi...Data Science Portugal  Meetup 7 - Machine Learning & Data Science Safety Remi...
Data Science Portugal Meetup 7 - Machine Learning & Data Science Safety Remi...
Rui Quintino
 
Cloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi dati
Cloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi datiCloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi dati
Cloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi dati
Aruba S.p.A.
 
Interpolation
InterpolationInterpolation
Interpolation
Dmytro Mitin
 
Scala dreaded underscore
Scala dreaded underscoreScala dreaded underscore
Scala dreaded underscore
RUDDER
 
Rubyからscalaに変えるべき15の理由
Rubyからscalaに変えるべき15の理由Rubyからscalaに変えるべき15の理由
Rubyからscalaに変えるべき15の理由
Yukishige Nakajo
 
3Com 3C400050
3Com 3C4000503Com 3C400050
3Com 3C400050
savomir
 
Boosting your SW development with Devops
Boosting your SW development with DevopsBoosting your SW development with Devops
Boosting your SW development with Devops
Timo Stordell
 
Resolución del Juez Bonadio
Resolución del Juez BonadioResolución del Juez Bonadio
Resolución del Juez Bonadio
Corrientesaldia
 
3Com 3C10384VCX
3Com 3C10384VCX3Com 3C10384VCX
3Com 3C10384VCX
savomir
 

Viewers also liked (19)

Moodboard as
Moodboard asMoodboard as
Moodboard as
 
Dental courses in delhi
Dental courses in delhiDental courses in delhi
Dental courses in delhi
 
Cетевое общество. Духовно-нравственное развитие личности
Cетевое общество. Духовно-нравственное развитие личностиCетевое общество. Духовно-нравственное развитие личности
Cетевое общество. Духовно-нравственное развитие личности
 
погоріла о. с.
погоріла о. с.погоріла о. с.
погоріла о. с.
 
стецько н. б.
стецько н. б.стецько н. б.
стецько н. б.
 
туркула л. в.
туркула л. в.туркула л. в.
туркула л. в.
 
тима о. о.
тима о. о.тима о. о.
тима о. о.
 
Hotdesking Feedback
Hotdesking FeedbackHotdesking Feedback
Hotdesking Feedback
 
Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...
Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...
Dzīvojamā fonda atjaunošanas problēmas, risinājumi un ieguvumi iedzīvotājiem ...
 
Viruses, worms, and trojan horses
Viruses, worms, and trojan horsesViruses, worms, and trojan horses
Viruses, worms, and trojan horses
 
Data Science Portugal Meetup 7 - Machine Learning & Data Science Safety Remi...
Data Science Portugal  Meetup 7 - Machine Learning & Data Science Safety Remi...Data Science Portugal  Meetup 7 - Machine Learning & Data Science Safety Remi...
Data Science Portugal Meetup 7 - Machine Learning & Data Science Safety Remi...
 
Cloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi dati
Cloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi datiCloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi dati
Cloud Backup e Cloud Object Storage: come mettere in sicurezza i tuoi dati
 
Interpolation
InterpolationInterpolation
Interpolation
 
Scala dreaded underscore
Scala dreaded underscoreScala dreaded underscore
Scala dreaded underscore
 
Rubyからscalaに変えるべき15の理由
Rubyからscalaに変えるべき15の理由Rubyからscalaに変えるべき15の理由
Rubyからscalaに変えるべき15の理由
 
3Com 3C400050
3Com 3C4000503Com 3C400050
3Com 3C400050
 
Boosting your SW development with Devops
Boosting your SW development with DevopsBoosting your SW development with Devops
Boosting your SW development with Devops
 
Resolución del Juez Bonadio
Resolución del Juez BonadioResolución del Juez Bonadio
Resolución del Juez Bonadio
 
3Com 3C10384VCX
3Com 3C10384VCX3Com 3C10384VCX
3Com 3C10384VCX
 

Similar to Sigma type

10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)
Roman Brovko
 
09 - Scala. Product type
09 - Scala. Product type09 - Scala. Product type
09 - Scala. Product type
Roman Brovko
 
04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers
Roman Brovko
 
22 - Scala. Type-level programming. Shapeless
22 - Scala. Type-level programming. Shapeless22 - Scala. Type-level programming. Shapeless
22 - Scala. Type-level programming. Shapeless
Roman Brovko
 
FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)
FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)
FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)
François Sarradin
 
08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum
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
 
11 - Scala. Function type
11 - Scala. Function type11 - Scala. Function type
11 - Scala. Function type
Roman Brovko
 
05 - Scala. List type
05 - Scala. List type05 - Scala. List type
05 - Scala. List type
Roman Brovko
 
12 - Scala. Empty and unit types
12 - Scala. Empty and unit types12 - Scala. Empty and unit types
12 - Scala. Empty and unit types
Roman Brovko
 
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love StoryUser Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
Databricks
 
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love StoryUser Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
Databricks
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
Dr. Volkan OBAN
 
Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.
Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.
Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.
Dr. Volkan OBAN
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
Ruslan Shevchenko
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
Hermann Hueck
 
Document Classification In PHP - Slight Return
Document Classification In PHP - Slight ReturnDocument Classification In PHP - Slight Return
Document Classification In PHP - Slight Return
Ian Barber
 
Зависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим ТалдыкинЗависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим Талдыкин
Юрий Сыровецкий
 
SacalaZa #1
SacalaZa #1SacalaZa #1
SacalaZa #1
Hiroki Mizuno
 

Similar to Sigma type (20)

10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)10 - Scala. Co-product type (sum type)
10 - Scala. Co-product type (sum type)
 
09 - Scala. Product type
09 - Scala. Product type09 - Scala. Product type
09 - Scala. Product type
 
04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers04 - Scala. Type of natural numbers
04 - Scala. Type of natural numbers
 
22 - Scala. Type-level programming. Shapeless
22 - Scala. Type-level programming. Shapeless22 - Scala. Type-level programming. Shapeless
22 - Scala. Type-level programming. Shapeless
 
FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)
FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)
FLATMAP ZAT SHIT : les monades expliquées aux geeks (Devoxx France 2013)
 
08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum08 - Scala. Type classes. Simulacrum
08 - Scala. Type classes. Simulacrum
 
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)
 
11 - Scala. Function type
11 - Scala. Function type11 - Scala. Function type
11 - Scala. Function type
 
05 - Scala. List type
05 - Scala. List type05 - Scala. List type
05 - Scala. List type
 
12 - Scala. Empty and unit types
12 - Scala. Empty and unit types12 - Scala. Empty and unit types
12 - Scala. Empty and unit types
 
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love StoryUser Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
 
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love StoryUser Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
 
Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.
Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.
Plot3D package in R-package-for-3d-and-4d-graph-Data visualization.
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
 
Document Classification In PHP - Slight Return
Document Classification In PHP - Slight ReturnDocument Classification In PHP - Slight Return
Document Classification In PHP - Slight Return
 
Зависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим ТалдыкинЗависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим Талдыкин
 
SacalaZa #1
SacalaZa #1SacalaZa #1
SacalaZa #1
 

Recently uploaded

GBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of ProteinsGBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of Proteins
Areesha Ahmad
 
Medical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptxMedical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptx
terusbelajar5
 
8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf
by6843629
 
aziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobelaziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobel
İsa Badur
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
KrushnaDarade1
 
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdfwaterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
LengamoLAppostilic
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
RitabrataSarkar3
 
Equivariant neural networks and representation theory
Equivariant neural networks and representation theoryEquivariant neural networks and representation theory
Equivariant neural networks and representation theory
Daniel Tubbenhauer
 
Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
Leonel Morgado
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
Sharon Liu
 
Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...
Leonel Morgado
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
European Sustainable Phosphorus Platform
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
MaheshaNanjegowda
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
Aditi Bajpai
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
pablovgd
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
University of Maribor
 
ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...
ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...
ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...
Advanced-Concepts-Team
 
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
Sérgio Sacani
 
The debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically youngThe debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically young
Sérgio Sacani
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
muralinath2
 

Recently uploaded (20)

GBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of ProteinsGBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of Proteins
 
Medical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptxMedical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptx
 
8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf
 
aziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobelaziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobel
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
 
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdfwaterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
 
Equivariant neural networks and representation theory
Equivariant neural networks and representation theoryEquivariant neural networks and representation theory
Equivariant neural networks and representation theory
 
Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
 
Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
 
ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...
ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...
ESA/ACT Science Coffee: Diego Blas - Gravitational wave detection with orbita...
 
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
EWOCS-I: The catalog of X-ray sources in Westerlund 1 from the Extended Weste...
 
The debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically youngThe debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically young
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
 

Sigma type

  • 1. Dependent pair type (Σ-type) Dmytro Mitin https://stepik.org/course/Introduction-to-programming- with-dependent-types-in-Scala-2294/ March 2017 Dmytro Mitin Dependent pair type (Σ-type)
  • 2. Sets Union of set family α∈A Bα = b ∃α ∈ A b ∈ Bα Disjoint union of set family α∈A Bα = (α, b) α ∈ A , b ∈ Bα Dmytro Mitin Dependent pair type (Σ-type)
  • 3. Dependent pair type (Σ-type) 1 Type Formation Γ A : ∗ Γ, x : A B : ∗ Γ x:A B : ∗ 2 Constructor Γ a : A Γ, x : A B : ∗ Γ b : B[x ← a] Γ (a, b) : x:A B 3 Eliminators Γ p : x:A B Γ fst p : A Γ p : x:A B Γ snd p : B[x ← fst p] Dmytro Mitin Dependent pair type (Σ-type)
  • 4. Dependent pair type (Σ-type) 4 Computation rules (”β-reduction“) Γ a : A Γ, x : A B : ∗ Γ b : B[x ← a] Γ fst(a, b) ≡ a : A Γ a : A Γ, x : A B : ∗ Γ b : B[x ← a] Γ snd(a, b) ≡ b : B 5 Uniqueness principle (”η-conversion“) Γ p : x:A B Γ (fst p, snd p) ≡ p : x:A B Dmytro Mitin Dependent pair type (Σ-type)
  • 5. Partial case Partial case of x:A B is sum type (coproduct) B1 + B2 Dmytro Mitin Dependent pair type (Σ-type)
  • 6. Idris data DepPair : (a : Type) -> (P : a -> Type) -> Type where MakeDepPair : {P : a -> Type} -> (x : a) -> P x -> DepPair a P depType : Int -> Type depType 0 = Int depType 1 = String depType = Bool x : DepPair Int (n => depType n) x = MakeDepPair 1 "a" x1 : DepPair Int (n => depType n) x1 = MakeDepPair 0 10 x2 : DepPair Int (n => depType n) x2 = MakeDepPair 2 True Dmytro Mitin Dependent pair type (Σ-type)
  • 7. Idris x3 : DepPair Int (n => depType n) x3 = MakeDepPair 0 "a" Dmytro Mitin Dependent pair type (Σ-type)
  • 8. Scala sealed trait Nat { type This >: this.type <: Nat type ++ = Succ[This] } final object Zero extends Nat { type This = Zero } type Zero = Zero.type final class Succ[N <: Nat] extends Nat { type This = Succ[N] } Dmytro Mitin Dependent pair type (Σ-type)
  • 9. Scala type 0 = Zero type 1 = 0 # ++ type 2 = 1 # ++ type 3 = 2 # ++ val 0: 0 = Zero val 1: 1 = new Succ[ 0] val 2: 2 = new Succ[ 1] val 3: 3 = new Succ[ 2] Dmytro Mitin Dependent pair type (Σ-type)
  • 10. Scala sealed trait DepType[N <: Nat] { type T } implicit object depType0 extends DepType[ 0] { type T = Int } implicit object depType1 extends DepType[ 1] { type T = String } implicit def depType[N <: Nat] = new DepType[Succ[Succ[N]]] { type T = Boolean } case class DepPair[N <: Nat, V](x: N, value: V)(implicit depType: DepType[N] { type T = V }) DepPair( 0, 10) DepPair( 1, "aaa") DepPair( 2, true) DepPair( 2, "bbb") // error DepPair( 3, false) Dmytro Mitin Dependent pair type (Σ-type)
  • 11. ProvingGround. Built-in type git clone https://github.com/siddhartha-gadgil/ProvingGround.git cd ProvingGround sbt mantle/test:console val A = "A" :: Type val B = "B( : A)" :: A ->: Type val a = "a" :: A val b = "b" :: B(a) val pair = mkPair(a, b) !: Sgma(a !: A, B(a)) val recSABA = Sgma(a !: A, B(a)).rec(A) val first = recSABA(a :∼> (b :-> a)) first(pair) == a val recSABSAB = Sgma(a !: A, B(a)).rec(Sgma(a !: A, B(a))) val id = recSABSAB(a :∼> (b :-> mkPair(a, b).asInstanceOf[DepPair[Term, Term]])) id(pair) == pair Dmytro Mitin Dependent pair type (Σ-type)
  • 12. ProvingGround. Custom type import TLImplicits. import shapeless. val A = "A" :: Type val B = "B( : A)" :: A ->: Type val a = "a" :: A val b = "b" :: B(a) val SigmaAB = "Sigma(a : A, B(a))" :: Type val SigmaInd = ("mkPair" ::: a ∼>>: (B(a) ->>: SigmaAB)) =: SigmaAB val makePair :: HNil = SigmaInd.intros val pair = makePair(a)(b) !: SigmaAB val recSABA = SigmaInd.rec(A) val first = recSABA(a :∼> (b :-> a)) first(pair) == a val recSABSAB = SigmaInd.rec(SigmaAB) val id = recSABSAB(a :∼> (b :-> makePair(a)(b))) id(pair) == pair Dmytro Mitin Dependent pair type (Σ-type)