SlideShare a Scribd company logo
1 of 20
Verified Subtyping with Traits
and Mixins
Asankhaya Sharma
National University of Singapore
Object Oriented Design
• S – Single Responsibility
• O – Open Close
• L – Liskov Substitution
• I – Interface Segregation
• D – Dependency Inversion
First proposed by Robert C. Martin in
comp.object newsgroup in March 1995
2/17/2016 FSFMA 2014 2
Liskov Substitution Principle
“Let q(x) be a property provable about objects x
of type T. Then q(y) should be provable for
objects y of type S where S is a subtype of T”
- Barbara Liskov and Jeannette Wing
2/17/2016 FSFMA 2014 3
Behavior Subtyping
• Useful to reason about design of class
hierarchies
• Stronger notion than typical subtyping of
functions defined in type theory
– Function subtyping is based on contravariance of
argument types and covariance of the return type
• Behavioral subtyping is trivially undecidable
– If the property is “this method always terminates”
2/17/2016 FSFMA 2014 4
Contributions
• Subtyping with Traits and Mixins in Scala
– By checking entailments in separation logic
• Extend Scala with a domain specific language
(SLEEK DSL)
– Allows Scala programmers to insert subtyping
checks in their programs
• Case study on subtyping in Scala Standard
Library
– Verified subtyping in 67% of Mixins
2/17/2016 FSFMA 2014 5
Traits and Mixins
• Traits
– Fine grained unit of reuse
– Similar to abstract classes but some methods can
have implementations as well
• Mixin Composition (Mixin)
– A class which contains a combination of methods
from other traits and classes
– Similar to multiple inheritance if the combination
contains all methods of combined classes
2/17/2016 FSFMA 2014 6
Traits Example
trait ICell {
def get() : Int
def set(x : Int)
}
trait BICell extends ICell {
private var x : Int = 0
def get() { x }
def set(x : Int) { this.x = x }
}
Similar to an
Abstract Class
Implementation
of ICell
2/17/2016 FSFMA 2014 7
Traits Example (cont.)
trait Double extends ICell {
abstract override def set(x : Int) {
super.set(2*x)
}
}
trait Inc extends ICell {
abstract override def set(x : Int) {
super.set(x+1)
}
}
2/17/2016 FSFMA 2014 8
Mixins Example
• OddICell (odd values)
– class OddICell extends BICell with Inc with Double
• EvenICell (even values)
– class EvenICell extends BICell with Double with Inc
OddICellDoubleIncBICell
EvenICellIncDoubleBICell
Class
Linearization
2/17/2016 FSFMA 2014 9
Scala doesn’t enforce Subtyping
def m (c: BICell with Inc with Double) : Int { c.get
}
val oic = new OddICell
val eic = new EvenICell
m(oic)
m(eic)
Both calls are allowed
by the type system
Only object oic is subtype of c
2/17/2016 FSFMA 2014 10
Verified Subtyping
• A mixin can be represented as a separation
logic predicate based on class linearization
OddICellDoubleIncBICell
OddICell<this> == BICell<this,p> * Inc<p,q> * Double<q,null>
EvenICellIncDoubleBICell
EvenICell<this> == BICell<this,p> * Double<p,q> * Inc<q,null>
2/17/2016 FSFMA 2014 11
From Subtyping to Entailment
• Subtyping can be reduced to checking
entailment between the predicates
m(oic)
OddICell<oic> |- BICell<c,p> * Inc<p,q> * Double<q,null>
m(eic)
EvenICell<eic> |- BICell<c,p> * Inc<p,q> * Double<q,null>
Valid
Invalid
2/17/2016 FSFMA 2014 12
SLEEK DSL
• Implementation based on SLEEK
– An existing separation logic based entailment
prover
– Supports user defined predicates and user
specified lemmas
– With Shape, Size, and Bag properties
2/17/2016 FSFMA 2014 13
Implementation Overview
SLEEK exesleek.lib
sleek.dsl sleek.inter
Scala
Programs
Scala
Interpreter
2/17/2016 FSFMA 2014 14
Scala with SLEEK DSL
def m (c: BICell with Inc with Double) : Int { c.get }
val oic = new OddICell
val eic = new EvenICell
if (OddICell<oic> |- BICell<c,p> * Inc<p,q> * Double<q,null> )
m(oic)
if (EvenICell<eic> |- BICell<c,p> * Inc<p,q> * Double<q,null>)
m(eic)
• Insert checks in Scala programs to verify
subtyping using SLEEK DSL
2/17/2016 FSFMA 2014 15
Experiments
• Scala Standard Library
• Considered four class hierarchies
– Exceptions
– Maths
– Parser Combinators
– Collections
2/17/2016 FSFMA 2014 16
Results
Class
Hierarchy
Mixins in the
Hierarchy
Mixins with
Verified Subtyping
Percentage
Exceptions 11 11 100
Maths 5 4 80
Combinators 6 6 100
Collections 27 12 44
Total 49 33 67
Traits provide more flexibility, 33% of Mixins use Traits in a way
that does not conform to subytping
2/17/2016 FSFMA 2014 17
Conclusions
• We use entailment proving in separation logic
to check subtyping with Traits and Mixins
• A domain specific language based on SLEEK to
check entailments from Scala programs
• Case study based on Scala Standard Library
2/17/2016 FSFMA 2014 18
Perspectives
• Lays the foundation for verifying OO Scala
programs
– Specification reuse with traits and mixins
– Inheritance verification
• Static and Dynamic Specifications for traits
and mixins
– Avoid re-verification
– Compositional and modular
2/17/2016 FSFMA 2014 19
Thank You !
• Questions ?
• Scala with SLEEK DSL
– Web Tool, Source Code and Sample Programs
– http://loris-
7.ddns.comp.nus.edu.sg/~project/SLEEKDSL/
• Contact
– asankhaya@nus.edu.sg
2/17/2016 FSFMA 2014 20

More Related Content

What's hot

JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS ResponsibilitiesBrendan Eich
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scalapt114
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptBrendan Eich
 
On the Scalability of Graph Kernels Applied to Collaborative Recommenders
On the Scalability of Graph Kernels Applied to Collaborative RecommendersOn the Scalability of Graph Kernels Applied to Collaborative Recommenders
On the Scalability of Graph Kernels Applied to Collaborative RecommendersJérôme KUNEGIS
 
Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project LambdaRahman USTA
 
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 progressBrendan Eich
 
Linear Regression Parameters
Linear Regression ParametersLinear Regression Parameters
Linear Regression Parameterscamposer
 

What's hot (13)

Presentation on machine learning
Presentation on machine learningPresentation on machine learning
Presentation on machine learning
 
Vectors,squence & list
Vectors,squence & listVectors,squence & list
Vectors,squence & list
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS Responsibilities
 
Sorting
SortingSorting
Sorting
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scala
 
Scilab
ScilabScilab
Scilab
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScript
 
On the Scalability of Graph Kernels Applied to Collaborative Recommenders
On the Scalability of Graph Kernels Applied to Collaborative RecommendersOn the Scalability of Graph Kernels Applied to Collaborative Recommenders
On the Scalability of Graph Kernels Applied to Collaborative Recommenders
 
Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project Lambda
 
02 Stack
02 Stack02 Stack
02 Stack
 
14. Linked List
14. Linked List14. Linked List
14. Linked List
 
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
 
Linear Regression Parameters
Linear Regression ParametersLinear Regression Parameters
Linear Regression Parameters
 

Viewers also liked

SplunkLive! Analytics with Splunk Enterprise
SplunkLive! Analytics with Splunk EnterpriseSplunkLive! Analytics with Splunk Enterprise
SplunkLive! Analytics with Splunk EnterpriseSplunk
 
Rúbrica de evaluación para la participación en foros
Rúbrica de evaluación para la participación en forosRúbrica de evaluación para la participación en foros
Rúbrica de evaluación para la participación en forosmgoc1210
 
3 diferencia entre aritmetica y algebra
3 diferencia entre aritmetica  y algebra3 diferencia entre aritmetica  y algebra
3 diferencia entre aritmetica y algebraOROREAL111
 
DIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated RecoveryDIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated RecoveryAsankhaya Sharma
 
interiordesign20112
interiordesign20112interiordesign20112
interiordesign20112Celina Lugo
 
20 Times Square renderings
20 Times Square renderings20 Times Square renderings
20 Times Square renderingsbreakfastagency
 
Why is asbestos so dangerous ?
Why is asbestos so dangerous ?Why is asbestos so dangerous ?
Why is asbestos so dangerous ?SharpLaw
 
Foros LupitaOrozco
Foros LupitaOrozcoForos LupitaOrozco
Foros LupitaOrozcomgoc1210
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled PresentationOROREAL111
 
Emeging Leader's Insitute
Emeging Leader's InsituteEmeging Leader's Insitute
Emeging Leader's InsituteAustin Mckain
 
Déroulement journée type
Déroulement journée typeDéroulement journée type
Déroulement journée typeYvon Brasseur
 
FM training program
FM training program FM training program
FM training program Eric Etapa
 
A brief look at my work ...
A brief look at my work ...A brief look at my work ...
A brief look at my work ...erinmburke
 
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_heRecon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_heLiang Chen
 

Viewers also liked (20)

Hq pixton nte rm
Hq pixton nte rmHq pixton nte rm
Hq pixton nte rm
 
SplunkLive! Analytics with Splunk Enterprise
SplunkLive! Analytics with Splunk EnterpriseSplunkLive! Analytics with Splunk Enterprise
SplunkLive! Analytics with Splunk Enterprise
 
Rúbrica de evaluación para la participación en foros
Rúbrica de evaluación para la participación en forosRúbrica de evaluación para la participación en foros
Rúbrica de evaluación para la participación en foros
 
3 diferencia entre aritmetica y algebra
3 diferencia entre aritmetica  y algebra3 diferencia entre aritmetica  y algebra
3 diferencia entre aritmetica y algebra
 
Brochure Costamare
Brochure Costamare Brochure Costamare
Brochure Costamare
 
DIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated RecoveryDIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated Recovery
 
interiordesign20112
interiordesign20112interiordesign20112
interiordesign20112
 
20 Times Square renderings
20 Times Square renderings20 Times Square renderings
20 Times Square renderings
 
Why is asbestos so dangerous ?
Why is asbestos so dangerous ?Why is asbestos so dangerous ?
Why is asbestos so dangerous ?
 
Foros LupitaOrozco
Foros LupitaOrozcoForos LupitaOrozco
Foros LupitaOrozco
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
SayCheese Ad
SayCheese AdSayCheese Ad
SayCheese Ad
 
Emeging Leader's Insitute
Emeging Leader's InsituteEmeging Leader's Insitute
Emeging Leader's Insitute
 
Déroulement journée type
Déroulement journée typeDéroulement journée type
Déroulement journée type
 
FM training program
FM training program FM training program
FM training program
 
A brief look at my work ...
A brief look at my work ...A brief look at my work ...
A brief look at my work ...
 
Metro
MetroMetro
Metro
 
Promote Chamber
Promote ChamberPromote Chamber
Promote Chamber
 
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_heRecon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
 
FM Leadership Issue
FM Leadership IssueFM Leadership Issue
FM Leadership Issue
 

Similar to Verified Subtyping with Traits and Mixins in Scala

The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San FranciscoMartin Odersky
 
Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014
Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014
Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014Roger Huang
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java ProgrammersEric Pederson
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With ScalaMeetu Maltiar
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyTypesafe
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Languageleague
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaScala Italy
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With ScalaKnoldus Inc.
 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark Summit
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvmIsaias Barroso
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuHavoc Pennington
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with ScalaNeelkanth Sachdeva
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos3Pillar Global
 

Similar to Verified Subtyping with Traits and Mixins in Scala (20)

The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
 
Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014
Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014
Intro to Apache Spark and Scala, Austin ACM SIGKDD, 7/9/2014
 
Scala 20140715
Scala 20140715Scala 20140715
Scala 20140715
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With Scala
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With Scala
 
ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Language
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With Scala
 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin Odersky
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on Heroku
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with Scala
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos
 

More from Asankhaya Sharma

9 types of people you find on your team
9 types of people you find on your team9 types of people you find on your team
9 types of people you find on your teamAsankhaya Sharma
 
Design and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageDesign and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageAsankhaya Sharma
 
Securing Open Source Code in Enterprise
Securing Open Source Code in EnterpriseSecuring Open Source Code in Enterprise
Securing Open Source Code in EnterpriseAsankhaya Sharma
 
Secure Software Development
Secure Software DevelopmentSecure Software Development
Secure Software DevelopmentAsankhaya Sharma
 
Specifying compatible sharing in data structures
Specifying compatible sharing in data structuresSpecifying compatible sharing in data structures
Specifying compatible sharing in data structuresAsankhaya Sharma
 
Exploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic executionExploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic executionAsankhaya Sharma
 
Developer-focused Software Security
Developer-focused Software SecurityDeveloper-focused Software Security
Developer-focused Software SecurityAsankhaya Sharma
 
Visualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with BokehVisualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with BokehAsankhaya Sharma
 
Crafting a Successful Engineering Career
Crafting a Successful Engineering CareerCrafting a Successful Engineering Career
Crafting a Successful Engineering CareerAsankhaya Sharma
 
Certified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationCertified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationAsankhaya Sharma
 

More from Asankhaya Sharma (11)

9 types of people you find on your team
9 types of people you find on your team9 types of people you find on your team
9 types of people you find on your team
 
Design and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageDesign and Implementation of the Security Graph Language
Design and Implementation of the Security Graph Language
 
Securing Open Source Code in Enterprise
Securing Open Source Code in EnterpriseSecuring Open Source Code in Enterprise
Securing Open Source Code in Enterprise
 
Secure Software Development
Secure Software DevelopmentSecure Software Development
Secure Software Development
 
Specifying compatible sharing in data structures
Specifying compatible sharing in data structuresSpecifying compatible sharing in data structures
Specifying compatible sharing in data structures
 
Exploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic executionExploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic execution
 
Developer-focused Software Security
Developer-focused Software SecurityDeveloper-focused Software Security
Developer-focused Software Security
 
Visualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with BokehVisualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with Bokeh
 
Crafting a Successful Engineering Career
Crafting a Successful Engineering CareerCrafting a Successful Engineering Career
Crafting a Successful Engineering Career
 
Certified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationCertified Reasoning for Automated Verification
Certified Reasoning for Automated Verification
 
Last Days of Academy
Last Days of AcademyLast Days of Academy
Last Days of Academy
 

Recently uploaded

Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 

Recently uploaded (20)

Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 

Verified Subtyping with Traits and Mixins in Scala

  • 1. Verified Subtyping with Traits and Mixins Asankhaya Sharma National University of Singapore
  • 2. Object Oriented Design • S – Single Responsibility • O – Open Close • L – Liskov Substitution • I – Interface Segregation • D – Dependency Inversion First proposed by Robert C. Martin in comp.object newsgroup in March 1995 2/17/2016 FSFMA 2014 2
  • 3. Liskov Substitution Principle “Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T” - Barbara Liskov and Jeannette Wing 2/17/2016 FSFMA 2014 3
  • 4. Behavior Subtyping • Useful to reason about design of class hierarchies • Stronger notion than typical subtyping of functions defined in type theory – Function subtyping is based on contravariance of argument types and covariance of the return type • Behavioral subtyping is trivially undecidable – If the property is “this method always terminates” 2/17/2016 FSFMA 2014 4
  • 5. Contributions • Subtyping with Traits and Mixins in Scala – By checking entailments in separation logic • Extend Scala with a domain specific language (SLEEK DSL) – Allows Scala programmers to insert subtyping checks in their programs • Case study on subtyping in Scala Standard Library – Verified subtyping in 67% of Mixins 2/17/2016 FSFMA 2014 5
  • 6. Traits and Mixins • Traits – Fine grained unit of reuse – Similar to abstract classes but some methods can have implementations as well • Mixin Composition (Mixin) – A class which contains a combination of methods from other traits and classes – Similar to multiple inheritance if the combination contains all methods of combined classes 2/17/2016 FSFMA 2014 6
  • 7. Traits Example trait ICell { def get() : Int def set(x : Int) } trait BICell extends ICell { private var x : Int = 0 def get() { x } def set(x : Int) { this.x = x } } Similar to an Abstract Class Implementation of ICell 2/17/2016 FSFMA 2014 7
  • 8. Traits Example (cont.) trait Double extends ICell { abstract override def set(x : Int) { super.set(2*x) } } trait Inc extends ICell { abstract override def set(x : Int) { super.set(x+1) } } 2/17/2016 FSFMA 2014 8
  • 9. Mixins Example • OddICell (odd values) – class OddICell extends BICell with Inc with Double • EvenICell (even values) – class EvenICell extends BICell with Double with Inc OddICellDoubleIncBICell EvenICellIncDoubleBICell Class Linearization 2/17/2016 FSFMA 2014 9
  • 10. Scala doesn’t enforce Subtyping def m (c: BICell with Inc with Double) : Int { c.get } val oic = new OddICell val eic = new EvenICell m(oic) m(eic) Both calls are allowed by the type system Only object oic is subtype of c 2/17/2016 FSFMA 2014 10
  • 11. Verified Subtyping • A mixin can be represented as a separation logic predicate based on class linearization OddICellDoubleIncBICell OddICell<this> == BICell<this,p> * Inc<p,q> * Double<q,null> EvenICellIncDoubleBICell EvenICell<this> == BICell<this,p> * Double<p,q> * Inc<q,null> 2/17/2016 FSFMA 2014 11
  • 12. From Subtyping to Entailment • Subtyping can be reduced to checking entailment between the predicates m(oic) OddICell<oic> |- BICell<c,p> * Inc<p,q> * Double<q,null> m(eic) EvenICell<eic> |- BICell<c,p> * Inc<p,q> * Double<q,null> Valid Invalid 2/17/2016 FSFMA 2014 12
  • 13. SLEEK DSL • Implementation based on SLEEK – An existing separation logic based entailment prover – Supports user defined predicates and user specified lemmas – With Shape, Size, and Bag properties 2/17/2016 FSFMA 2014 13
  • 14. Implementation Overview SLEEK exesleek.lib sleek.dsl sleek.inter Scala Programs Scala Interpreter 2/17/2016 FSFMA 2014 14
  • 15. Scala with SLEEK DSL def m (c: BICell with Inc with Double) : Int { c.get } val oic = new OddICell val eic = new EvenICell if (OddICell<oic> |- BICell<c,p> * Inc<p,q> * Double<q,null> ) m(oic) if (EvenICell<eic> |- BICell<c,p> * Inc<p,q> * Double<q,null>) m(eic) • Insert checks in Scala programs to verify subtyping using SLEEK DSL 2/17/2016 FSFMA 2014 15
  • 16. Experiments • Scala Standard Library • Considered four class hierarchies – Exceptions – Maths – Parser Combinators – Collections 2/17/2016 FSFMA 2014 16
  • 17. Results Class Hierarchy Mixins in the Hierarchy Mixins with Verified Subtyping Percentage Exceptions 11 11 100 Maths 5 4 80 Combinators 6 6 100 Collections 27 12 44 Total 49 33 67 Traits provide more flexibility, 33% of Mixins use Traits in a way that does not conform to subytping 2/17/2016 FSFMA 2014 17
  • 18. Conclusions • We use entailment proving in separation logic to check subtyping with Traits and Mixins • A domain specific language based on SLEEK to check entailments from Scala programs • Case study based on Scala Standard Library 2/17/2016 FSFMA 2014 18
  • 19. Perspectives • Lays the foundation for verifying OO Scala programs – Specification reuse with traits and mixins – Inheritance verification • Static and Dynamic Specifications for traits and mixins – Avoid re-verification – Compositional and modular 2/17/2016 FSFMA 2014 19
  • 20. Thank You ! • Questions ? • Scala with SLEEK DSL – Web Tool, Source Code and Sample Programs – http://loris- 7.ddns.comp.nus.edu.sg/~project/SLEEKDSL/ • Contact – asankhaya@nus.edu.sg 2/17/2016 FSFMA 2014 20