SlideShare une entreprise Scribd logo
1  sur  19
Zhiqiang Ren
Boston University
Research Outline
 Goal: Software Development with Verification
 Specification: What is correct anyway?
 Verification: Will the program behave correctly?
 Our Work: Put them together in one language.
What is ATS (statically)?
 http://www.ats-lang.org
 Statically typed programming language that unifies
implementation, formal specification, and proof.
 ML like syntax
 Dependent Types
 Linear Types
 Compiled to C, JavaScript, Erlang
What is ATS (dynamically)?
 As efficient as C/C++ (see The Computer Language
Benchmarks Game for concrete evidence).
 Supports a variety of programming paradigm
(Functional, Imperative, Concurrent, and Modular
programming).
 Feature-Rich practical PL: closure, pattern match,
unboxed data representation, polymorphism
(overloading, template).
 Optional Runtime and GC.
What is ATS good for?
 Building safety critical software without losing
efficiency.
 Direct manipulating native unboxed data representation.
 Tracking resources (e.g. memory) with linear types.
 Integrating with C seamlessly.
 Building program without runtime / gc (good for kernel
development)
 Enforcing correctness via theorem proving.
What has been built using ATS?
 ATS itself, and ATS website (JavaScript)
 Scientific Computing
 Linux Device Driver
 Kernel
 Terrier: OS in development for Panda and Beagle Boards.
 Model Checker for ATS (under construction)
Helloworld in ATS
$ vi helloworld.dats
#include “share/atspre_staload.hats”
val () = println! (“Hello, World!”)
implement main0 () = let
val x = 1 + 3
in
println! (“x = “, x)
end
$ patscc helloworld.dats –o helloworld
$ ./helloworld
Hello, World!
x = 4
ATS Compile Process
ATS source code
Dynamics
Business Logic Proof
Statics
Types integer boolean ……
ATS compiler
Type Check
C source code
Binary
Compile
GCC compiler Compile
Dependent Types (Singleton Type)
#include “share/atspre_staload.hats”
val x = 2 / (1 – 1) // type error
fun mydiv {x,y:int} (a: int x, b: int y): [z:int] int z =
if b != 0 then a / b
else $raise div_by_0_exception
val y = mydiv (2, 1 – 1) // no type error
fun foo {x,y:int} (a:int x, b: int y): int (3 * (x + y)) = let
val v1 = 3 * a
val v2 = 3 * b
in
(v1 + v2)
end
1: int 1
/: {x,y: int | y != 0}
(int x, int y): [z:int] int z
Blue: type indices in the statics
Red: Entities in the dynamics
some types
Dependent Types (array)
// arrayref (a, n) is a type.
// It depends on two indices: type of element, length of array
fun{a:t@ype} array_make_elt{n:int}
(asz: size_t n, elt: a): arrayref (a, n)
fun{a:t@ype} arrayref_get_at {n:int}{i:nat | i < n}
(A: arrayref (a, n), pos: size_t i): a
overload [] with arrayref_get_at
fun{a:t@ype} arrayref_set_at {n:int}{i:nat | i < n}
(A: arrayref (a, n), pos: size_t i, x: a): void
overload [] with arrayref_set_at
typedef Int = [x:int] int x
val arr: arrayref (Int, 3) = arrayref_make_elt<Int> (i2sz(3), 0)
val v = arr[2]
val () = arr[i2sz(v)] := 99
val () = assertloc (v < 3)
val () = assertloc (v >= 0)
prfun fun pure_assert {b:bool}
(bool b): [b == true] void
prval () = pure_assert (v < 3)
prval () = pure_assert (v >= 0)
Specification:
What should a function do?
• SUM (x) = 0 + 1 + 2 + … + x
• relation: y = SUM (x)
y = SUM (x) = 0 if x = 0
y= SUM (x) = x + y1 if SUM (x - 1) = y1
fun sum (x: int): int =
if x = 0 then 0
else x + sum (x – 1)
)(.int:)0.(int: xSUMyyoutputyxinputxx 
No Connection
between two worlds!
Implementation
Specification: Encoding via types
dataprop SUM (int, int) =
| SUMbas (0, 0) of ()
| {x,y1:int} SUMind (x+1, y1+x+1) of SUM (x, y1)
fun sum {x:int | x >= 0} (a: int x):
[y:int] (SUM (x, y) | int y) =
if a = 0 then (SUMbase () | 0)
else let
val (pf1 | s) = sum(a - 1)
prval pf = SUMind (pf1)
in
(pf | s + a)
end
Verification: Theorem Proving
dataprop SUM (int, int) =
| SUMbas (0, 0) of ()
| {x,y1:int} SUMind (x+1, y1+x+1) of SUM (x, y1)
fun sum_mul{x: int | x >= 0} (a: int x):
[s: int] (MUL (x, x+1, s) | int (s/2)) = let
val sum = a * (a + 1)
prval pf = mul_make ()
in
(pf | sum / 2)
end
extern prfun mul2sum {x,s:int | x >= 0}
(pf: MUL (x, x+1,s)): SUM (x, s / 2)
fun sum {x:int | x >= 0} (a: int x):
[y:int] (SUM (x, y) | int y) = let
val (pf_mul | sum) = sum_mul(a)
prval pf_sum = mul2sum (pf_mul)
in
(pf_sum | sum)
end
Linear Type (Intuition)
 Program Entities of linear types can be consumed once
and exactly once.
Creation of
Linear Object
Passing on
Linear Object
Destruction of
Linear Object
Linear Type (viewtype)
 Resource Management: lock, memory, interrupt, …
absviewt@ype lock
extern fun lock_acquire (): lock
extern fun lock_release (l: lock >> _): void
fun foo (): void = let
val l = lock_acquire ()
// ... process
val () = lock_release (l) // must release only once
in
end
Linear Type (View)
fun{a:vt0p} ptr_alloc ()
:<> [l:addr | l > 0]
(
a? @ l, mfree_gc_v (l) | ptr l
)
fun ptr_free {a:t@ype}{l:addr}
(
pfgc: mfree_gc_v (l)
, pfat: a @ l
| p: ptr l
):<> void
a? @ l
mfree_gc_v (l)
ptr l
view
(linear
proof)
Concrete
Code
Can Deference
Can NOT Deference
Program Verification
Prove that the implementation
meets the specification
Theorem Proving
Model Checking
Combining Type Checking and
Model Checking
 Modeling concurrent software system using ATS
 Eliminate bugs in models as much as possible by type
checking
 Verify models by model checking against temporal
properties (e.g. deadlock freeness, atomicity,
specification in linear temporal logic, and etc)
Q & A
 Thank You.
 Questions?

Contenu connexe

Tendances

Creating a MOOC at University of Osnabrück
Creating a MOOC at University of OsnabrückCreating a MOOC at University of Osnabrück
Creating a MOOC at University of OsnabrückOpenEducationEuropa
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4昀 李
 
Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020Luka Jacobowitz
 
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasionsLuka Jacobowitz
 
2) quadratics gral form
2) quadratics gral form2) quadratics gral form
2) quadratics gral formestelav
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13alish sha
 
Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)stasimus
 
One Monad to Rule Them All
One Monad to Rule Them AllOne Monad to Rule Them All
One Monad to Rule Them AllJohn De Goes
 
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 traverseLuka Jacobowitz
 
Linear Convolution using Matlab Code
Linear Convolution  using Matlab CodeLinear Convolution  using Matlab Code
Linear Convolution using Matlab CodeBharti Airtel Ltd.
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13alish sha
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmKapil Pandit
 
Monoids, monoids, monoids
Monoids, monoids, monoidsMonoids, monoids, monoids
Monoids, monoids, monoidsLuka Jacobowitz
 
Turbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingTurbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingHuzaifa Butt
 

Tendances (19)

Creating a MOOC at University of Osnabrück
Creating a MOOC at University of OsnabrückCreating a MOOC at University of Osnabrück
Creating a MOOC at University of Osnabrück
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
 
Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, Monoids, Monoids - ScalaLove 2020
 
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasions
 
Elm
ElmElm
Elm
 
OOP v3
OOP v3OOP v3
OOP v3
 
2) quadratics gral form
2) quadratics gral form2) quadratics gral form
2) quadratics gral form
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)
 
One Monad to Rule Them All
One Monad to Rule Them AllOne Monad to Rule Them All
One Monad to Rule Them All
 
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
 
Sigma type
Sigma typeSigma type
Sigma type
 
Lab 6
Lab 6Lab 6
Lab 6
 
Linear Convolution using Matlab Code
Linear Convolution  using Matlab CodeLinear Convolution  using Matlab Code
Linear Convolution using Matlab Code
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 
Monoids, monoids, monoids
Monoids, monoids, monoidsMonoids, monoids, monoids
Monoids, monoids, monoids
 
Turbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse ProgrammingTurbo C Graphics and Mouse Programming
Turbo C Graphics and Mouse Programming
 

Similaire à ATS Programming

Towards Programming Languages for Reasoning.pptx
Towards Programming Languages for Reasoning.pptxTowards Programming Languages for Reasoning.pptx
Towards Programming Languages for Reasoning.pptxmarkmarron7
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05cKaz Yoshikawa
 
GoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoGoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoEleanor McHugh
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patternsleague
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2Hang Zhao
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Peyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slidePeyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slideTakayuki Muranushi
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗Pofat Tseng
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingSaurabh Singh
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Mattersromanandreg
 
talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013ericupnorth
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
 
Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013aleks-f
 
Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''OdessaJS Conf
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 

Similaire à ATS Programming (20)

Towards Programming Languages for Reasoning.pptx
Towards Programming Languages for Reasoning.pptxTowards Programming Languages for Reasoning.pptx
Towards Programming Languages for Reasoning.pptx
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
GoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoGoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google Go
 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patterns
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Peyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slidePeyton jones-2009-fun with-type_functions-slide
Peyton jones-2009-fun with-type_functions-slide
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗
 
Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional Programming
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Matters
 
talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
 
Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013
 
Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''Christian Gill ''Functional programming for the people''
Christian Gill ''Functional programming for the people''
 
Arduino reference
Arduino   referenceArduino   reference
Arduino reference
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
Cbasic
CbasicCbasic
Cbasic
 

Dernier

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Dernier (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

ATS Programming

  • 2. Research Outline  Goal: Software Development with Verification  Specification: What is correct anyway?  Verification: Will the program behave correctly?  Our Work: Put them together in one language.
  • 3. What is ATS (statically)?  http://www.ats-lang.org  Statically typed programming language that unifies implementation, formal specification, and proof.  ML like syntax  Dependent Types  Linear Types  Compiled to C, JavaScript, Erlang
  • 4. What is ATS (dynamically)?  As efficient as C/C++ (see The Computer Language Benchmarks Game for concrete evidence).  Supports a variety of programming paradigm (Functional, Imperative, Concurrent, and Modular programming).  Feature-Rich practical PL: closure, pattern match, unboxed data representation, polymorphism (overloading, template).  Optional Runtime and GC.
  • 5. What is ATS good for?  Building safety critical software without losing efficiency.  Direct manipulating native unboxed data representation.  Tracking resources (e.g. memory) with linear types.  Integrating with C seamlessly.  Building program without runtime / gc (good for kernel development)  Enforcing correctness via theorem proving.
  • 6. What has been built using ATS?  ATS itself, and ATS website (JavaScript)  Scientific Computing  Linux Device Driver  Kernel  Terrier: OS in development for Panda and Beagle Boards.  Model Checker for ATS (under construction)
  • 7. Helloworld in ATS $ vi helloworld.dats #include “share/atspre_staload.hats” val () = println! (“Hello, World!”) implement main0 () = let val x = 1 + 3 in println! (“x = “, x) end $ patscc helloworld.dats –o helloworld $ ./helloworld Hello, World! x = 4
  • 8. ATS Compile Process ATS source code Dynamics Business Logic Proof Statics Types integer boolean …… ATS compiler Type Check C source code Binary Compile GCC compiler Compile
  • 9. Dependent Types (Singleton Type) #include “share/atspre_staload.hats” val x = 2 / (1 – 1) // type error fun mydiv {x,y:int} (a: int x, b: int y): [z:int] int z = if b != 0 then a / b else $raise div_by_0_exception val y = mydiv (2, 1 – 1) // no type error fun foo {x,y:int} (a:int x, b: int y): int (3 * (x + y)) = let val v1 = 3 * a val v2 = 3 * b in (v1 + v2) end 1: int 1 /: {x,y: int | y != 0} (int x, int y): [z:int] int z Blue: type indices in the statics Red: Entities in the dynamics some types
  • 10. Dependent Types (array) // arrayref (a, n) is a type. // It depends on two indices: type of element, length of array fun{a:t@ype} array_make_elt{n:int} (asz: size_t n, elt: a): arrayref (a, n) fun{a:t@ype} arrayref_get_at {n:int}{i:nat | i < n} (A: arrayref (a, n), pos: size_t i): a overload [] with arrayref_get_at fun{a:t@ype} arrayref_set_at {n:int}{i:nat | i < n} (A: arrayref (a, n), pos: size_t i, x: a): void overload [] with arrayref_set_at typedef Int = [x:int] int x val arr: arrayref (Int, 3) = arrayref_make_elt<Int> (i2sz(3), 0) val v = arr[2] val () = arr[i2sz(v)] := 99 val () = assertloc (v < 3) val () = assertloc (v >= 0) prfun fun pure_assert {b:bool} (bool b): [b == true] void prval () = pure_assert (v < 3) prval () = pure_assert (v >= 0)
  • 11. Specification: What should a function do? • SUM (x) = 0 + 1 + 2 + … + x • relation: y = SUM (x) y = SUM (x) = 0 if x = 0 y= SUM (x) = x + y1 if SUM (x - 1) = y1 fun sum (x: int): int = if x = 0 then 0 else x + sum (x – 1) )(.int:)0.(int: xSUMyyoutputyxinputxx  No Connection between two worlds! Implementation
  • 12. Specification: Encoding via types dataprop SUM (int, int) = | SUMbas (0, 0) of () | {x,y1:int} SUMind (x+1, y1+x+1) of SUM (x, y1) fun sum {x:int | x >= 0} (a: int x): [y:int] (SUM (x, y) | int y) = if a = 0 then (SUMbase () | 0) else let val (pf1 | s) = sum(a - 1) prval pf = SUMind (pf1) in (pf | s + a) end
  • 13. Verification: Theorem Proving dataprop SUM (int, int) = | SUMbas (0, 0) of () | {x,y1:int} SUMind (x+1, y1+x+1) of SUM (x, y1) fun sum_mul{x: int | x >= 0} (a: int x): [s: int] (MUL (x, x+1, s) | int (s/2)) = let val sum = a * (a + 1) prval pf = mul_make () in (pf | sum / 2) end extern prfun mul2sum {x,s:int | x >= 0} (pf: MUL (x, x+1,s)): SUM (x, s / 2) fun sum {x:int | x >= 0} (a: int x): [y:int] (SUM (x, y) | int y) = let val (pf_mul | sum) = sum_mul(a) prval pf_sum = mul2sum (pf_mul) in (pf_sum | sum) end
  • 14. Linear Type (Intuition)  Program Entities of linear types can be consumed once and exactly once. Creation of Linear Object Passing on Linear Object Destruction of Linear Object
  • 15. Linear Type (viewtype)  Resource Management: lock, memory, interrupt, … absviewt@ype lock extern fun lock_acquire (): lock extern fun lock_release (l: lock >> _): void fun foo (): void = let val l = lock_acquire () // ... process val () = lock_release (l) // must release only once in end
  • 16. Linear Type (View) fun{a:vt0p} ptr_alloc () :<> [l:addr | l > 0] ( a? @ l, mfree_gc_v (l) | ptr l ) fun ptr_free {a:t@ype}{l:addr} ( pfgc: mfree_gc_v (l) , pfat: a @ l | p: ptr l ):<> void a? @ l mfree_gc_v (l) ptr l view (linear proof) Concrete Code Can Deference Can NOT Deference
  • 17. Program Verification Prove that the implementation meets the specification Theorem Proving Model Checking
  • 18. Combining Type Checking and Model Checking  Modeling concurrent software system using ATS  Eliminate bugs in models as much as possible by type checking  Verify models by model checking against temporal properties (e.g. deadlock freeness, atomicity, specification in linear temporal logic, and etc)
  • 19. Q & A  Thank You.  Questions?

Notes de l'éditeur

  1. boehm garbage collector performance