SlideShare a Scribd company logo
1 of 33
Download to read offline
Subtyping
Machines
Ori Roth
1
Overview
Goal
Investigate the connection between subtyping and
tree languages
Method
Formalize the computability of subtyping with the
subtyping machine
2/21
Subtyping
Scope
Declaration-site nominal subtyping with variance
(Kennedy and Pierce 2007)
What is subtyping?
A type system decision problem
t1 <: t2
3/21
Subtyping
class b : a {}
a x = new b(); ✓ // b <: a
x = new Set(); ✗
Subtyping is everywhere
• Variable assignments
• Method arguments
4/21
Subtyping
Subtyping with type parameters
Collection<b> x = new List<b>(); ✓
List<a> list_b = new List<b>(); ???
5/21
Subtyping
Subtyping with type parameters
Collection<b> x = new List<b>(); ✓
List<a> list_b = new List<b>(); ✗
list_b.add(new a()); ✗
5/21
Subtyping
Subtyping with type parameters
Collection<b> x = new List<b>(); ✓
List<a> list_b = new List<b>(); ✗
list_b.add(new a()); ✗
5/21
List<b> list_a = new List<a>(); ✗
b y = list_a.get(0); ✗
Variance
Covariance
More derived type arguments
ReadOnlyList<a> x = new ReadOnlyList<b>(); ✓
a y = x.get(0); ✓
6/21
Variance
interface ReadOnlyList<out x> {
x get(int i);
}
Covariance
More derived type arguments
ReadOnlyList<a> x = new ReadOnlyList<b>(); ✓
a y = x.get(0); ✓
6/21
Variance
Contravariance
Less derived type arguments
WriteOnlyList<b> x = new WriteOnlyList<a>(); ✓
x.add(new b()); ✓
7/21
Variance
interface WriteOnlyList<in x> {
void add(x x);
}
Contravariance
Less derived type arguments
WriteOnlyList<b> x = new WriteOnlyList<a>(); ✓
x.add(new b()); ✓
7/21
Decidability of Subtyping
(Kennedy and Pierce 2007)
Abstract subtyping type system
Undecidable—reduced to PCP
Tractable type system fragments
Restricted subtyping semantics are decidable
How complex are these fragments?
8/21
Types Are Trees
A set of types is a set of trees
• Also called a tree language or a forest
• Defined by a tree grammar
a<b<c>, d>
a
b
c
d
9/21
Tree Grammars
Generalize “word” grammars for trees
Productions are tree/term rewrite rules
Class of tree grammars (regular, context-free, etc.)
Defined by a restriction on the form of productions
10/21
Subtyping Machines
Subtyping programs that recognize tree languages
b : a
c(x) : d(x, x), b
…
Class table
Subtyping
query
11/21
t1 <: t2
Subtyping
machine
(constant) Machine
input
(changing)
Subtyping Machines
Subtyping programs that recognize tree languages
b : a
c(x) : d(x, x), b
…
11/21
t1 <: t2
Subtyping
machine
(constant) Machine
input
(changing)
Subtyping Machines
Subtyping programs that recognize tree languages
b : a
c(x) : d(x, x), b
…
11/21
t1 <: t2
Results
class a<x> : b<a<b<x>>> {}
Expansively recursive inheritance
The expansion of types through inheritance is unlimited
12/21
a<c> → b<a<b<c>>>
Results
class a<x> : b<a<b<x>>> {}
Expansively recursive inheritance
The expansion of types through inheritance is unlimited
12/21
a<c> → b<a<b<c>>> → a<b<c>>
Results
class a<x> : b<a<b<x>>> {}
Expansively recursive inheritance
The expansion of types through inheritance is unlimited
12/21
a<c> → b<a<b<c>>> → a<b<c>> → b<a<b<b<c>>>>
Results
class a<x> : b<a<b<x>>> {}
Expansively recursive inheritance
The expansion of types through inheritance is unlimited
12/21
a<c> → b<a<b<c>>> → a<b<c>> → b<a<b<b<c>>>>
→ a<b<b<c>>>
Results
class a<x> : b<a<b<x>>> {}
Expansively recursive inheritance
The expansion of types through inheritance is unlimited
12/21
a<c> → b<a<b<c>>> → a<b<c>> → b<a<b<b<c>>>>
→ a<b<b<c>>> → … (a<c> → a<b*<c>>)
Results
Non-expansive subtyping is regular
Subtyping machines with non-expansive class tables
recognize regular forests
interface σ<+x> {}
interface v : σ<v> {}
13/21
Results
Example: Cons-lists of Peano numbers
Nat ::= z | s(Nat)
3 s(s(s(z)))
List ::= nil | cons(Nat, List)
[2,1,0] cons(s(s(z)),
cons(s(z),
cons(z,
nil)))
14/21
Results
Example: Cons-lists of Peano numbers
// Grammar terminals
interface z {} interface s<out x> {} interface nil {}
interface cons<out x1, out x2> {}
15/21
Results
Example: Cons-lists of Peano numbers
// Grammar terminals
interface z {} interface s<out x> {} interface nil {}
interface cons<out x1, out x2> {}
// Nat ::= z | s(Nat)
interface Nat : z, s<Nat> {}
// List ::= nil | cons(Nat, List)
interface List : nil, cons<Nat, List> {}
15/21
Results
Example: Cons-lists of Peano numbers
// Grammar terminals
interface z {} interface s<out x> {} interface nil {}
interface cons<out x1, out x2> {}
// Nat ::= z | s(Nat)
interface Nat : z, s<Nat> {}
// List ::= nil | cons(Nat, List)
interface List : nil, cons<Nat, List> {}
// List <: [2,1,0]
cons<s<s<z>>, cons<s<z>, cons<z, nil>>> t = (List) null; ✓
15/21
Results
Non-contravariant subtyping is context-free (GNF)
Subtyping machines without contravariance recognize
context-free forests with grammars in Greibach normal form
interface σ<+x> {}
interface v(x) : σ<τ> {}
16/21
Results
Example: Palindromes
// Grammar terminals
interface a<out x> {} interface b<out x> {} interface E {}
// v0(x) ::= a(v0(a(x))) | a(a(x)) | a(x) | b(v0(b(x))) | …
class v0<x> : a<v0<a<x>>>,a<a<x>>,a<x>,b<v0<b<x>>>,b<b<x>>,b<x> {}
// “abbabba” is a palindrome
a<b<b<a<b<b<a<E>>>>>>> w1 = new v0<E>(); ✓
// “abbabaa” is not a palindrome
a<b<b<a<b<a<a<E>>>>>>> w2 = new v0<E>(); ✗
17/21
Subtyping Metaprogramming
Some APIs have context-free usage protocols
“It is an error to call Restore() more times than
Save() was called.”
- Android’s Canvas API
Canvas ::= Save Canvas Restore Canvas
| Save Canvas
18/21
Subtyping Metaprogramming
Canvas.Draw();
Canvas.Save();
Canvas.Draw();
Canvas.Restore();
Canvas.Restore(); // Runtime exception
Can this exception be detected at compile-time?
19/21
Treetop
• Input: A context-free grammar G describing a domain-specific
language or an API protocol
• Output: A C# fluent API encoding L(G) using a subtyping machine
var shape = Canvas.Draw().Save().Draw().
Restore().Restore().
Done<Canvas>(); ✗ // Subtyping constraint
20/21
In Conclusion
• There is a correspondence between nominal subtyping and
formal forests
• Subtyping machines formalize subtyping computations
• Subtyping metaprogramming?
• Context-free languages can be recognized at compile-time in a
decidable type system fragment
21/21

More Related Content

What's hot

Garbage Collection
Garbage CollectionGarbage Collection
Garbage CollectionEelco Visser
 
CS2303 Theory of computation April may 2015
CS2303 Theory of computation April may  2015CS2303 Theory of computation April may  2015
CS2303 Theory of computation April may 2015appasami
 
Cs2303 theory of computation november december 2015
Cs2303 theory of computation november december 2015Cs2303 theory of computation november december 2015
Cs2303 theory of computation november december 2015appasami
 
Meetup C++ A brief overview of c++17
Meetup C++  A brief overview of c++17Meetup C++  A brief overview of c++17
Meetup C++ A brief overview of c++17Daniel Eriksson
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programmingizahn
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generationIffat Anjum
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
8. R Graphics with R
8. R Graphics with R8. R Graphics with R
8. R Graphics with RFAO
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna universitysangeethajames07
 
COMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONCOMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONAnil Pokhrel
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersappasami
 
C programming - String
C programming - StringC programming - String
C programming - StringAchyut Devkota
 
[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using Haskell[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using HaskellFunctional Thursday
 

What's hot (20)

Garbage Collection
Garbage CollectionGarbage Collection
Garbage Collection
 
CS2303 Theory of computation April may 2015
CS2303 Theory of computation April may  2015CS2303 Theory of computation April may  2015
CS2303 Theory of computation April may 2015
 
STACK Applications in DS
STACK Applications in DSSTACK Applications in DS
STACK Applications in DS
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Cs2303 theory of computation november december 2015
Cs2303 theory of computation november december 2015Cs2303 theory of computation november december 2015
Cs2303 theory of computation november december 2015
 
Meetup C++ A brief overview of c++17
Meetup C++  A brief overview of c++17Meetup C++  A brief overview of c++17
Meetup C++ A brief overview of c++17
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
8. R Graphics with R
8. R Graphics with R8. R Graphics with R
8. R Graphics with R
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna university
 
COMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONCOMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTION
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papers
 
C programming - String
C programming - StringC programming - String
C programming - String
 
Basics of objective c
Basics of objective cBasics of objective c
Basics of objective c
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Pointers
PointersPointers
Pointers
 
L6
L6L6
L6
 
Arrays
ArraysArrays
Arrays
 
[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using Haskell[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using Haskell
 

Similar to Study of the Subtyping Machine of Nominal Subtyping with Variance

JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experienceJAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experiencejazoon13
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...openCypher
 
"That scripting language called Prolog"
"That scripting language called Prolog""That scripting language called Prolog"
"That scripting language called Prolog"Sergei Winitzki
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsFrançois Garillot
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type ClassesTapio Rautonen
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisSilvio Cesare
 
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18Olga Zinkevych
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name ResolutionEelco Visser
 
Finding similar items in high dimensional spaces locality sensitive hashing
Finding similar items in high dimensional spaces  locality sensitive hashingFinding similar items in high dimensional spaces  locality sensitive hashing
Finding similar items in high dimensional spaces locality sensitive hashingDmitriy Selivanov
 
Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...
Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...
Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...Mail.ru Group
 
Decision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersDecision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersAlexander Jung
 
Introduction to Deep Generative Models
Introduction to Deep Generative ModelsIntroduction to Deep Generative Models
Introduction to Deep Generative ModelsHao-Wen (Herman) Dong
 
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...Iosif Itkin
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Piotr Paradziński
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Scalac
 
Dependent dynamic rules
Dependent dynamic rulesDependent dynamic rules
Dependent dynamic rulesEelco Visser
 
Ch4.mapreduce algorithm design
Ch4.mapreduce algorithm designCh4.mapreduce algorithm design
Ch4.mapreduce algorithm designAllenWu
 

Similar to Study of the Subtyping Machine of Nominal Subtyping with Variance (20)

Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experienceJAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
 
"That scripting language called Prolog"
"That scripting language called Prolog""That scripting language called Prolog"
"That scripting language called Prolog"
 
Scala Collections : Java 8 on Steroids
Scala Collections : Java 8 on SteroidsScala Collections : Java 8 on Steroids
Scala Collections : Java 8 on Steroids
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type Classes
 
Gate-Cs 1996
Gate-Cs 1996Gate-Cs 1996
Gate-Cs 1996
 
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow AnalysisDetecting Bugs in Binaries Using Decompilation and Data Flow Analysis
Detecting Bugs in Binaries Using Decompilation and Data Flow Analysis
 
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name Resolution
 
Finding similar items in high dimensional spaces locality sensitive hashing
Finding similar items in high dimensional spaces  locality sensitive hashingFinding similar items in high dimensional spaces  locality sensitive hashing
Finding similar items in high dimensional spaces locality sensitive hashing
 
Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...
Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...
Дмитрий Селиванов, OK.RU. Finding Similar Items in high-dimensional spaces: L...
 
Decision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersDecision Trees and Bayes Classifiers
Decision Trees and Bayes Classifiers
 
Introduction to Deep Generative Models
Introduction to Deep Generative ModelsIntroduction to Deep Generative Models
Introduction to Deep Generative Models
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
 
Dependent dynamic rules
Dependent dynamic rulesDependent dynamic rules
Dependent dynamic rules
 
Ch4.mapreduce algorithm design
Ch4.mapreduce algorithm designCh4.mapreduce algorithm design
Ch4.mapreduce algorithm design
 

Recently uploaded

zoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistanzoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistanzohaibmir069
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxyaramohamed343013
 
Luciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxLuciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxAleenaTreesaSaji
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.k64182334
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)DHURKADEVIBASKAR
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 

Recently uploaded (20)

zoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistanzoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistan
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docx
 
Luciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptxLuciferase in rDNA technology (biotechnology).pptx
Luciferase in rDNA technology (biotechnology).pptx
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.Genomic DNA And Complementary DNA Libraries construction.
Genomic DNA And Complementary DNA Libraries construction.
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 

Study of the Subtyping Machine of Nominal Subtyping with Variance

  • 2. Overview Goal Investigate the connection between subtyping and tree languages Method Formalize the computability of subtyping with the subtyping machine 2/21
  • 3. Subtyping Scope Declaration-site nominal subtyping with variance (Kennedy and Pierce 2007) What is subtyping? A type system decision problem t1 <: t2 3/21
  • 4. Subtyping class b : a {} a x = new b(); ✓ // b <: a x = new Set(); ✗ Subtyping is everywhere • Variable assignments • Method arguments 4/21
  • 5. Subtyping Subtyping with type parameters Collection<b> x = new List<b>(); ✓ List<a> list_b = new List<b>(); ??? 5/21
  • 6. Subtyping Subtyping with type parameters Collection<b> x = new List<b>(); ✓ List<a> list_b = new List<b>(); ✗ list_b.add(new a()); ✗ 5/21
  • 7. Subtyping Subtyping with type parameters Collection<b> x = new List<b>(); ✓ List<a> list_b = new List<b>(); ✗ list_b.add(new a()); ✗ 5/21 List<b> list_a = new List<a>(); ✗ b y = list_a.get(0); ✗
  • 8. Variance Covariance More derived type arguments ReadOnlyList<a> x = new ReadOnlyList<b>(); ✓ a y = x.get(0); ✓ 6/21
  • 9. Variance interface ReadOnlyList<out x> { x get(int i); } Covariance More derived type arguments ReadOnlyList<a> x = new ReadOnlyList<b>(); ✓ a y = x.get(0); ✓ 6/21
  • 10. Variance Contravariance Less derived type arguments WriteOnlyList<b> x = new WriteOnlyList<a>(); ✓ x.add(new b()); ✓ 7/21
  • 11. Variance interface WriteOnlyList<in x> { void add(x x); } Contravariance Less derived type arguments WriteOnlyList<b> x = new WriteOnlyList<a>(); ✓ x.add(new b()); ✓ 7/21
  • 12. Decidability of Subtyping (Kennedy and Pierce 2007) Abstract subtyping type system Undecidable—reduced to PCP Tractable type system fragments Restricted subtyping semantics are decidable How complex are these fragments? 8/21
  • 13. Types Are Trees A set of types is a set of trees • Also called a tree language or a forest • Defined by a tree grammar a<b<c>, d> a b c d 9/21
  • 14. Tree Grammars Generalize “word” grammars for trees Productions are tree/term rewrite rules Class of tree grammars (regular, context-free, etc.) Defined by a restriction on the form of productions 10/21
  • 15. Subtyping Machines Subtyping programs that recognize tree languages b : a c(x) : d(x, x), b … Class table Subtyping query 11/21 t1 <: t2
  • 16. Subtyping machine (constant) Machine input (changing) Subtyping Machines Subtyping programs that recognize tree languages b : a c(x) : d(x, x), b … 11/21 t1 <: t2
  • 17. Subtyping machine (constant) Machine input (changing) Subtyping Machines Subtyping programs that recognize tree languages b : a c(x) : d(x, x), b … 11/21 t1 <: t2
  • 18. Results class a<x> : b<a<b<x>>> {} Expansively recursive inheritance The expansion of types through inheritance is unlimited 12/21 a<c> → b<a<b<c>>>
  • 19. Results class a<x> : b<a<b<x>>> {} Expansively recursive inheritance The expansion of types through inheritance is unlimited 12/21 a<c> → b<a<b<c>>> → a<b<c>>
  • 20. Results class a<x> : b<a<b<x>>> {} Expansively recursive inheritance The expansion of types through inheritance is unlimited 12/21 a<c> → b<a<b<c>>> → a<b<c>> → b<a<b<b<c>>>>
  • 21. Results class a<x> : b<a<b<x>>> {} Expansively recursive inheritance The expansion of types through inheritance is unlimited 12/21 a<c> → b<a<b<c>>> → a<b<c>> → b<a<b<b<c>>>> → a<b<b<c>>>
  • 22. Results class a<x> : b<a<b<x>>> {} Expansively recursive inheritance The expansion of types through inheritance is unlimited 12/21 a<c> → b<a<b<c>>> → a<b<c>> → b<a<b<b<c>>>> → a<b<b<c>>> → … (a<c> → a<b*<c>>)
  • 23. Results Non-expansive subtyping is regular Subtyping machines with non-expansive class tables recognize regular forests interface σ<+x> {} interface v : σ<v> {} 13/21
  • 24. Results Example: Cons-lists of Peano numbers Nat ::= z | s(Nat) 3 s(s(s(z))) List ::= nil | cons(Nat, List) [2,1,0] cons(s(s(z)), cons(s(z), cons(z, nil))) 14/21
  • 25. Results Example: Cons-lists of Peano numbers // Grammar terminals interface z {} interface s<out x> {} interface nil {} interface cons<out x1, out x2> {} 15/21
  • 26. Results Example: Cons-lists of Peano numbers // Grammar terminals interface z {} interface s<out x> {} interface nil {} interface cons<out x1, out x2> {} // Nat ::= z | s(Nat) interface Nat : z, s<Nat> {} // List ::= nil | cons(Nat, List) interface List : nil, cons<Nat, List> {} 15/21
  • 27. Results Example: Cons-lists of Peano numbers // Grammar terminals interface z {} interface s<out x> {} interface nil {} interface cons<out x1, out x2> {} // Nat ::= z | s(Nat) interface Nat : z, s<Nat> {} // List ::= nil | cons(Nat, List) interface List : nil, cons<Nat, List> {} // List <: [2,1,0] cons<s<s<z>>, cons<s<z>, cons<z, nil>>> t = (List) null; ✓ 15/21
  • 28. Results Non-contravariant subtyping is context-free (GNF) Subtyping machines without contravariance recognize context-free forests with grammars in Greibach normal form interface σ<+x> {} interface v(x) : σ<τ> {} 16/21
  • 29. Results Example: Palindromes // Grammar terminals interface a<out x> {} interface b<out x> {} interface E {} // v0(x) ::= a(v0(a(x))) | a(a(x)) | a(x) | b(v0(b(x))) | … class v0<x> : a<v0<a<x>>>,a<a<x>>,a<x>,b<v0<b<x>>>,b<b<x>>,b<x> {} // “abbabba” is a palindrome a<b<b<a<b<b<a<E>>>>>>> w1 = new v0<E>(); ✓ // “abbabaa” is not a palindrome a<b<b<a<b<a<a<E>>>>>>> w2 = new v0<E>(); ✗ 17/21
  • 30. Subtyping Metaprogramming Some APIs have context-free usage protocols “It is an error to call Restore() more times than Save() was called.” - Android’s Canvas API Canvas ::= Save Canvas Restore Canvas | Save Canvas 18/21
  • 31. Subtyping Metaprogramming Canvas.Draw(); Canvas.Save(); Canvas.Draw(); Canvas.Restore(); Canvas.Restore(); // Runtime exception Can this exception be detected at compile-time? 19/21
  • 32. Treetop • Input: A context-free grammar G describing a domain-specific language or an API protocol • Output: A C# fluent API encoding L(G) using a subtyping machine var shape = Canvas.Draw().Save().Draw(). Restore().Restore(). Done<Canvas>(); ✗ // Subtyping constraint 20/21
  • 33. In Conclusion • There is a correspondence between nominal subtyping and formal forests • Subtyping machines formalize subtyping computations • Subtyping metaprogramming? • Context-free languages can be recognized at compile-time in a decidable type system fragment 21/21