SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
Metasepi team meeting #17: 
  
Invariant captured by ATS's API 
Kiwamu Okabe @ Metasepi Project
Who am I? 
☆ http://www.masterq.net/ 
☆ Self employed software engineer 
☆ Trade name := METASEPI DESIGN 
☆ Founder of Metasepi Project 
☆ A Debian Maintainer 
☆ 10 years' experience in developing 
OS using NetBSD
Remember Heartbleed bug? 
Should we use safer language than C? 
== In English == 
"Preventing heartbleed bugs with safe programming languages" 
http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with- 
safe-languages.html 
== In Japanease == 
"安全なプログラミング言語を使って heartbleed を防ぐには" 
https://github.com/jats-ug/translate/blob/master/Web/ 
bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages. 
md 
"A safer systems programming language 
could have prevented the bug."
Want the safer language... 
It's the ATS http://www.ats-lang.org/ ! 
☆ Syntax like ML 
☆ Dependent types 
☆ Linear types 
☆ Without any runtime 
☆ Optional GC
ATS code can run on 8-bit AVR 
hhhttttttpppsss::://////gggiiittthhhuuubbb...cccooommm///fffpppiiiooottt///aaarrrddduuuiiinnnooo---mmmeeegggaaa222555666000---aaatttsss
ATS compile flow
Why ATS language is safe? 
☆ Line is at between caller and callee 
☆ ATS applies type to the line 
☆ Type can enforce invariant in them
{Dependent,Linear} type 
Dependent type 
☆ such like Coq or Agda 
☆ has universal quantification 
☆ has existential quantification 
Linear type 
☆ based on linear logic 
☆ manages resource like memory
Usage of Linear List 
$ vi sample_list.dats 
#include "share/atspre_staload.hats" 
implement main0 () = { 
val l1 = list_vt_make_pair<int> (1, 2) 
val l2 = list_vt_make_pair<int> (3, 4) 
val l3 = list_vt_append (l1, l2) 
val () = println! ("l3[3] := ", l3[3]) 
val l4 = list_vt_reverse l3 
val () = println! ("l4 := [", l4, "]") 
val () = free l4 
} 
$ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats 
$ ./sample_list 
l3[3] := 4 
l4 := [4, 3, 2, 1] 
$ size sample_list 
text data bss dec hex filename 
7908 772 32 8712 2208 sample_list 
$ ldd sample_list | wc -l 
3 
$ nm sample_list| grep "U "| wc -l 
10
Compile error: without free 
$ vi sample_list.dats 
#include "share/atspre_staload.hats" 
implement main0 () = { 
val l1 = list_vt_make_pair<int> (1, 2) 
val l2 = list_vt_make_pair<int> (3, 4) 
val l3 = list_vt_append (l1, l2) 
val () = println! ("l3[3] := ", l3[3]) 
val l4 = list_vt_reverse l3 
val () = println! ("l4 := [", l4, "]") 
// val () = free l4 // <= Changed 
} 
$ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats 
--snip-- 
The 2nd translation (binding) of [sample_list.dats] is 
successfully completed! 
/home/kiwamu/tmp/sample_list.dats: 59(line=2, offs=22) -- 312 
(line=10, offs=2): error(3): the linear dynamic variable [l4$3450 
(-1)] needs to be consumed but it is preserved with the type 
[S2Eapp(S2Ecst(list_vt0ype_int_vtype); S2Einvar(S2EVar(4104)), 
S2EVar(4105))] instead.
Compile error: use freed name 
$ vi sample_list.dats 
#include "share/atspre_staload.hats" 
implement main0 () = { 
val l1 = list_vt_make_pair<int> (1, 2) 
val l2 = list_vt_make_pair<int> (3, 4) 
val l3 = list_vt_append (l1, l2) 
val l4 = list_vt_reverse l3 
val () = println! ("l3[3] := ", l3[3]) // <= Changed 
val () = println! ("l4 := [", l4, "]") 
val () = free l4 
} 
$ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats 
--snip-- 
The 2nd translation (binding) of [sample_list.dats] is 
successfully completed! 
/home/kiwamu/tmp/sample_list.dats: 242(line=7, offs=35) -- 245 
(line=7, offs=38): error(3): the linear dynamic variable [l3$3449 
(-1)] is no longer available.
Compile error: out of range 
$ vi sample_list.dats 
#include "share/atspre_staload.hats" 
implement main0 () = { 
val l1 = list_vt_make_pair<int> (1, 2) 
val l2 = list_vt_make_pair<int> (3, 4) 
val l3 = list_vt_append (l1, l2) 
val () = println! ("l3[4] := ", l3[4]) // <= Changed 
val l4 = list_vt_reverse l3 
val () = println! ("l4 := [", l4, "]") 
val () = free l4 
} 
$ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats 
--snip-- 
The 2nd translation (binding) of [sample_list.dats] is 
successfully completed! 
/home/kiwamu/tmp/sample_list.dats: 215(line=6, offs=38) -- 216 
(line=6, offs=39): error(3): unsolved constraint: C3NSTRprop(main; 
S2Eapp(S2Ecst(<); S2EVar(4101->S2Eintinf(4)), S2Eapp(S2Ecst 
(add_int_int); S2Eintinf(2), S2Eintinf(2)))) 
typechecking has failed: there are some unsolved constraints: 
please inspect the above reported error message(s) for information.
Typechecked: with assert 
$ vi sample_list.dats 
#include "share/atspre_staload.hats" 
implement main0 () = { 
val l1 = list_vt_make_pair<int> (1, 2) 
val l2 = list_vt_make_pair<int> (3, 4) 
val l3 = list_vt_append (l1, l2) 
val () = if length l3 > 4 // <= Changed 
then println! ("l3[4] := ", l3[4]) // <= Changed 
val l4 = list_vt_reverse l3 
val () = println! ("l4 := [", l4, "]") 
val () = free l4 
} 
$ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats 
--snip-- 
The 1st translation (fixity) of [sample_list.dats] is successfully 
completed! 
The 2nd translation (binding) of [sample_list.dats] is 
successfully completed! 
The 3rd translation (type-checking) of [sample_list.dats] is 
successfully completed! 
The 4th translation (type/proof-erasing) of [sample_list.dats] is 
successfully completed!
Type of Linear List 
(* File: prelude/basics_dyn.sats *) 
datavtype 
list_vt0ype_int_vtype (a:vt@ype+, int) = 
| {n:int | n >= 0} 
list_vt_cons (a, n+1) of (a, list_vt0ype_int_vtype (a, n)) 
| list_vt_nil (a, 0) of () 
stadef list_vt = list_vt0ype_int_vtype
make_pair 
(* File: prelude/SATS/list_vt.sats *) 
fun{x:vt0p} 
list_vt_make_pair (x1: x, x2: x):<!wrt> list_vt (x, 2)
append 
(* File: prelude/SATS/list_vt.sats *) 
fun{ 
a:vt0p 
} list_vt_append 
{n1,n2:int} ( 
xs1: list_vt (INV(a), n1), xs2: list_vt (a, n2) 
) :<!wrt> list_vt (a, n1+n2)
[] 
(* File: prelude/SATS/list_vt.sats *) 
fun{x:t0p} 
list_vt_get_at{n:int} 
(xs: !list_vt (INV(x), n), i: natLt n):<> x 
overload [] with list_vt_get_at 
(* File: prelude/basics_sta.sats *) 
typedef g1intBtw 
(tk:tk, lb:int, ub:int) = [i: int | lb <= i; i < ub] g1int (tk, i) 
typedef intBtw (lb:int, ub:int) = g1intBtw (int_kind, lb, ub) 
typedef natLt (n:int) = intBtw (0, n)
reverse 
(* File: prelude/SATS/list_vt.sats *) 
fun{x:vt0p} 
list_vt_reverse{n:int} 
(xs: list_vt (INV(x), n)):<!wrt> list_vt (x, n)
free 
(* File: prelude/basics_dyn.sats *) 
vtypedef 
List_vt (a:vt0p) = [n:int] list_vt (a, n) 
(* File: prelude/SATS/list_vt.sats *) 
fun{x:t0p} 
list_vt_free (xs: List_vt (INV(x))):<!wrt> void 
overload free with list_vt_free
Japan ATS User Group 
http://jats-ug.metasepi.org/ 
☆ In a parody of http://jaws-ug.jp/ 
☆ Push the Facebook like button, now! 
☆ We translate ATS docs into Japanese
"ATSプログラミング入門" 
hhhttttttppp::://////jjjaaatttsss---uuuggg...mmmeeetttaaassseeepppiii...ooorrrggg///dddoooccc///AAATTTSSS222///IIINNNTTT222PPPRRROOOGGGIIINNNAAATTTSSS///iiinnndddeeexxx...hhhtttmmmlll
"ATS公式Wikiの日本語訳" 
hhhttttttpppsss::://////gggiiittthhhuuubbb...cccooommm///jjjaaatttsss---uuuggg///AAATTTSSS---PPPooossstttiiiaaatttsss---wwwiiikkkiii
"MLプログラマ向けATS言語ガイド" 
https://github.com/jats-ug/translate/blob/master/Web/cs.likai.org/ 
ats/ml-programmers-guide-to-ats.md
Paper "Applied Type System" 
https://github.com/jats-ug/translate/raw/master/Paper/ATS-types03/ 
ATS-types03-ja.pdf
Follow me! 
☆ https://twitter.com/jats_ug 
☆ https://www.facebook.com/jatsug
License of photos used 
* Creative Commons BBB | Flickr - Photo Sharing! 
https://www.flickr.com/photos/steren/2732488224 
Copyright: 2008 Steren Giannini / License: CC BY 2.0 
* le coq / o galo de Barcelos | Flickr - Photo Sharing! 
https://www.flickr.com/photos/guymoll/311768037 
Copyright: 2006 Guy MOLL / License: CC BY 2.0 
* news_twitter_facebook | Flickr - Photo Sharing! 
https://www.flickr.com/photos/lioman/4324501845 
Copyright: 2010 lioman123 / License: CC BY-SA 2.0 
* Jordan shooting Jenna with shield | Flickr - Photo Sharing! 
https://www.flickr.com/photos/jasoneppink/80772834 
Copyright: 2005 Jason Eppink / License: CC BY 2.0 
* Marsh Plaza, Boston University | Flickr - Photo Sharing! 
https://www.flickr.com/photos/hankzby/14122296866 
Copyright: 2014 Henry Zbyszynski / License: CC BY 2.0 
* Love That Binds | Flickr - Photo Sharing! 
https://www.flickr.com/photos/enerva/12525888074 
Copyright: 2014 Sonny Abesamis / License: CC BY 2.0

Mais conteúdo relacionado

Mais procurados

Metasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCUMetasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCUKiwamu Okabe
 
Hands-on VeriFast with STM32 microcontroller
Hands-on VeriFast with STM32 microcontrollerHands-on VeriFast with STM32 microcontroller
Hands-on VeriFast with STM32 microcontrollerKiwamu Okabe
 
ATS language overview'
ATS language overview'ATS language overview'
ATS language overview'Kiwamu Okabe
 
Secure Programming Practices in C++ (NDC Security 2018)
Secure Programming Practices in C++ (NDC Security 2018)Secure Programming Practices in C++ (NDC Security 2018)
Secure Programming Practices in C++ (NDC Security 2018)Patricia Aas
 
Reading Other Peoples Code (Web Rebels 2018)
Reading Other Peoples Code (Web Rebels 2018)Reading Other Peoples Code (Web Rebels 2018)
Reading Other Peoples Code (Web Rebels 2018)Patricia Aas
 
A Modest Introduction To Swift
A Modest Introduction To SwiftA Modest Introduction To Swift
A Modest Introduction To SwiftJohn Anderson
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSasha Goldshtein
 
Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Chang W. Doh
 
Shibuyajs Digest
Shibuyajs DigestShibuyajs Digest
Shibuyajs Digesttakesako
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageRené Ribaud
 
Debugging with pry
Debugging with pryDebugging with pry
Debugging with pryCreditas
 
Be pinched by a cRUSTacean to prevent programming errors !
Be pinched by a cRUSTacean to prevent programming errors !Be pinched by a cRUSTacean to prevent programming errors !
Be pinched by a cRUSTacean to prevent programming errors !René Ribaud
 
scaling compiled applications - highload 2013
scaling compiled applications - highload 2013scaling compiled applications - highload 2013
scaling compiled applications - highload 2013ice799
 
Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)Patricia Aas
 
Dear compiler please don't be my nanny v2
Dear compiler  please don't be my nanny v2Dear compiler  please don't be my nanny v2
Dear compiler please don't be my nanny v2Dino Dini
 
C++ The Principles of Most Surprise
C++ The Principles of Most SurpriseC++ The Principles of Most Surprise
C++ The Principles of Most SurprisePatricia Aas
 
Isolating GPU Access in its Own Process
Isolating GPU Access in its Own ProcessIsolating GPU Access in its Own Process
Isolating GPU Access in its Own ProcessPatricia Aas
 

Mais procurados (20)

Metasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCUMetasepi team meeting #16: Safety on ATS language + MCU
Metasepi team meeting #16: Safety on ATS language + MCU
 
Hands-on VeriFast with STM32 microcontroller
Hands-on VeriFast with STM32 microcontrollerHands-on VeriFast with STM32 microcontroller
Hands-on VeriFast with STM32 microcontroller
 
ATS language overview'
ATS language overview'ATS language overview'
ATS language overview'
 
groovy & grails - lecture 1
groovy & grails - lecture 1groovy & grails - lecture 1
groovy & grails - lecture 1
 
Secure Programming Practices in C++ (NDC Security 2018)
Secure Programming Practices in C++ (NDC Security 2018)Secure Programming Practices in C++ (NDC Security 2018)
Secure Programming Practices in C++ (NDC Security 2018)
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Reading Other Peoples Code (Web Rebels 2018)
Reading Other Peoples Code (Web Rebels 2018)Reading Other Peoples Code (Web Rebels 2018)
Reading Other Peoples Code (Web Rebels 2018)
 
A Modest Introduction To Swift
A Modest Introduction To SwiftA Modest Introduction To Swift
A Modest Introduction To Swift
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS X
 
Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!
 
Shibuyajs Digest
Shibuyajs DigestShibuyajs Digest
Shibuyajs Digest
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 
Debugging with pry
Debugging with pryDebugging with pry
Debugging with pry
 
Be pinched by a cRUSTacean to prevent programming errors !
Be pinched by a cRUSTacean to prevent programming errors !Be pinched by a cRUSTacean to prevent programming errors !
Be pinched by a cRUSTacean to prevent programming errors !
 
scaling compiled applications - highload 2013
scaling compiled applications - highload 2013scaling compiled applications - highload 2013
scaling compiled applications - highload 2013
 
Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)
 
Development Principles & Philosophy
Development Principles & PhilosophyDevelopment Principles & Philosophy
Development Principles & Philosophy
 
Dear compiler please don't be my nanny v2
Dear compiler  please don't be my nanny v2Dear compiler  please don't be my nanny v2
Dear compiler please don't be my nanny v2
 
C++ The Principles of Most Surprise
C++ The Principles of Most SurpriseC++ The Principles of Most Surprise
C++ The Principles of Most Surprise
 
Isolating GPU Access in its Own Process
Isolating GPU Access in its Own ProcessIsolating GPU Access in its Own Process
Isolating GPU Access in its Own Process
 

Semelhante a Metasepi team meeting #17: Invariant captured by ATS's API

Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In RRsquared Academy
 
Swift - Krzysztof Skarupa
Swift -  Krzysztof SkarupaSwift -  Krzysztof Skarupa
Swift - Krzysztof SkarupaSunscrapers
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsEleanor McHugh
 
Modern technologies in data science
Modern technologies in data science Modern technologies in data science
Modern technologies in data science Chucheng Hsieh
 
Morel, a data-parallel programming language
Morel, a data-parallel programming languageMorel, a data-parallel programming language
Morel, a data-parallel programming languageJulian Hyde
 
学生向けScalaハンズオンテキスト
学生向けScalaハンズオンテキスト学生向けScalaハンズオンテキスト
学生向けScalaハンズオンテキストOpt Technologies
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 
Introduction to Python , Overview
Introduction to Python , OverviewIntroduction to Python , Overview
Introduction to Python , OverviewNB Veeresh
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programaciónSoftware Guru
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxcarliotwaycave
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertextfrankieroberto
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Basic and logical implementation of r language
Basic and logical implementation of r language Basic and logical implementation of r language
Basic and logical implementation of r language Md. Mahedi Mahfuj
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009David Pollak
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query LanguageJulian Hyde
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Guy Lebanon
 

Semelhante a Metasepi team meeting #17: Invariant captured by ATS's API (20)

Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In R
 
Swift - Krzysztof Skarupa
Swift -  Krzysztof SkarupaSwift -  Krzysztof Skarupa
Swift - Krzysztof Skarupa
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord Migrations
 
Modern technologies in data science
Modern technologies in data science Modern technologies in data science
Modern technologies in data science
 
Morel, a data-parallel programming language
Morel, a data-parallel programming languageMorel, a data-parallel programming language
Morel, a data-parallel programming language
 
学生向けScalaハンズオンテキスト
学生向けScalaハンズオンテキスト学生向けScalaハンズオンテキスト
学生向けScalaハンズオンテキスト
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Introduction to Python , Overview
Introduction to Python , OverviewIntroduction to Python , Overview
Introduction to Python , Overview
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docxINFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
INFORMATIVE ESSAYThe purpose of the Informative Essay assignme.docx
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
My First Rails Plugin - Usertext
My First Rails Plugin - UsertextMy First Rails Plugin - Usertext
My First Rails Plugin - Usertext
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Basic and logical implementation of r language
Basic and logical implementation of r language Basic and logical implementation of r language
Basic and logical implementation of r language
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query Language
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 

Último

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 

Último (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Metasepi team meeting #17: Invariant captured by ATS's API

  • 1. Metasepi team meeting #17:   Invariant captured by ATS's API Kiwamu Okabe @ Metasepi Project
  • 2. Who am I? ☆ http://www.masterq.net/ ☆ Self employed software engineer ☆ Trade name := METASEPI DESIGN ☆ Founder of Metasepi Project ☆ A Debian Maintainer ☆ 10 years' experience in developing OS using NetBSD
  • 3. Remember Heartbleed bug? Should we use safer language than C? == In English == "Preventing heartbleed bugs with safe programming languages" http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with- safe-languages.html == In Japanease == "安全なプログラミング言語を使って heartbleed を防ぐには" https://github.com/jats-ug/translate/blob/master/Web/ bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages. md "A safer systems programming language could have prevented the bug."
  • 4. Want the safer language... It's the ATS http://www.ats-lang.org/ ! ☆ Syntax like ML ☆ Dependent types ☆ Linear types ☆ Without any runtime ☆ Optional GC
  • 5. ATS code can run on 8-bit AVR hhhttttttpppsss::://////gggiiittthhhuuubbb...cccooommm///fffpppiiiooottt///aaarrrddduuuiiinnnooo---mmmeeegggaaa222555666000---aaatttsss
  • 7. Why ATS language is safe? ☆ Line is at between caller and callee ☆ ATS applies type to the line ☆ Type can enforce invariant in them
  • 8. {Dependent,Linear} type Dependent type ☆ such like Coq or Agda ☆ has universal quantification ☆ has existential quantification Linear type ☆ based on linear logic ☆ manages resource like memory
  • 9. Usage of Linear List $ vi sample_list.dats #include "share/atspre_staload.hats" implement main0 () = { val l1 = list_vt_make_pair<int> (1, 2) val l2 = list_vt_make_pair<int> (3, 4) val l3 = list_vt_append (l1, l2) val () = println! ("l3[3] := ", l3[3]) val l4 = list_vt_reverse l3 val () = println! ("l4 := [", l4, "]") val () = free l4 } $ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats $ ./sample_list l3[3] := 4 l4 := [4, 3, 2, 1] $ size sample_list text data bss dec hex filename 7908 772 32 8712 2208 sample_list $ ldd sample_list | wc -l 3 $ nm sample_list| grep "U "| wc -l 10
  • 10. Compile error: without free $ vi sample_list.dats #include "share/atspre_staload.hats" implement main0 () = { val l1 = list_vt_make_pair<int> (1, 2) val l2 = list_vt_make_pair<int> (3, 4) val l3 = list_vt_append (l1, l2) val () = println! ("l3[3] := ", l3[3]) val l4 = list_vt_reverse l3 val () = println! ("l4 := [", l4, "]") // val () = free l4 // <= Changed } $ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats --snip-- The 2nd translation (binding) of [sample_list.dats] is successfully completed! /home/kiwamu/tmp/sample_list.dats: 59(line=2, offs=22) -- 312 (line=10, offs=2): error(3): the linear dynamic variable [l4$3450 (-1)] needs to be consumed but it is preserved with the type [S2Eapp(S2Ecst(list_vt0ype_int_vtype); S2Einvar(S2EVar(4104)), S2EVar(4105))] instead.
  • 11. Compile error: use freed name $ vi sample_list.dats #include "share/atspre_staload.hats" implement main0 () = { val l1 = list_vt_make_pair<int> (1, 2) val l2 = list_vt_make_pair<int> (3, 4) val l3 = list_vt_append (l1, l2) val l4 = list_vt_reverse l3 val () = println! ("l3[3] := ", l3[3]) // <= Changed val () = println! ("l4 := [", l4, "]") val () = free l4 } $ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats --snip-- The 2nd translation (binding) of [sample_list.dats] is successfully completed! /home/kiwamu/tmp/sample_list.dats: 242(line=7, offs=35) -- 245 (line=7, offs=38): error(3): the linear dynamic variable [l3$3449 (-1)] is no longer available.
  • 12. Compile error: out of range $ vi sample_list.dats #include "share/atspre_staload.hats" implement main0 () = { val l1 = list_vt_make_pair<int> (1, 2) val l2 = list_vt_make_pair<int> (3, 4) val l3 = list_vt_append (l1, l2) val () = println! ("l3[4] := ", l3[4]) // <= Changed val l4 = list_vt_reverse l3 val () = println! ("l4 := [", l4, "]") val () = free l4 } $ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats --snip-- The 2nd translation (binding) of [sample_list.dats] is successfully completed! /home/kiwamu/tmp/sample_list.dats: 215(line=6, offs=38) -- 216 (line=6, offs=39): error(3): unsolved constraint: C3NSTRprop(main; S2Eapp(S2Ecst(<); S2EVar(4101->S2Eintinf(4)), S2Eapp(S2Ecst (add_int_int); S2Eintinf(2), S2Eintinf(2)))) typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.
  • 13. Typechecked: with assert $ vi sample_list.dats #include "share/atspre_staload.hats" implement main0 () = { val l1 = list_vt_make_pair<int> (1, 2) val l2 = list_vt_make_pair<int> (3, 4) val l3 = list_vt_append (l1, l2) val () = if length l3 > 4 // <= Changed then println! ("l3[4] := ", l3[4]) // <= Changed val l4 = list_vt_reverse l3 val () = println! ("l4 := [", l4, "]") val () = free l4 } $ patscc -DATS_MEMALLOC_LIBC -o sample_list sample_list.dats --snip-- The 1st translation (fixity) of [sample_list.dats] is successfully completed! The 2nd translation (binding) of [sample_list.dats] is successfully completed! The 3rd translation (type-checking) of [sample_list.dats] is successfully completed! The 4th translation (type/proof-erasing) of [sample_list.dats] is successfully completed!
  • 14. Type of Linear List (* File: prelude/basics_dyn.sats *) datavtype list_vt0ype_int_vtype (a:vt@ype+, int) = | {n:int | n >= 0} list_vt_cons (a, n+1) of (a, list_vt0ype_int_vtype (a, n)) | list_vt_nil (a, 0) of () stadef list_vt = list_vt0ype_int_vtype
  • 15. make_pair (* File: prelude/SATS/list_vt.sats *) fun{x:vt0p} list_vt_make_pair (x1: x, x2: x):<!wrt> list_vt (x, 2)
  • 16. append (* File: prelude/SATS/list_vt.sats *) fun{ a:vt0p } list_vt_append {n1,n2:int} ( xs1: list_vt (INV(a), n1), xs2: list_vt (a, n2) ) :<!wrt> list_vt (a, n1+n2)
  • 17. [] (* File: prelude/SATS/list_vt.sats *) fun{x:t0p} list_vt_get_at{n:int} (xs: !list_vt (INV(x), n), i: natLt n):<> x overload [] with list_vt_get_at (* File: prelude/basics_sta.sats *) typedef g1intBtw (tk:tk, lb:int, ub:int) = [i: int | lb <= i; i < ub] g1int (tk, i) typedef intBtw (lb:int, ub:int) = g1intBtw (int_kind, lb, ub) typedef natLt (n:int) = intBtw (0, n)
  • 18. reverse (* File: prelude/SATS/list_vt.sats *) fun{x:vt0p} list_vt_reverse{n:int} (xs: list_vt (INV(x), n)):<!wrt> list_vt (x, n)
  • 19. free (* File: prelude/basics_dyn.sats *) vtypedef List_vt (a:vt0p) = [n:int] list_vt (a, n) (* File: prelude/SATS/list_vt.sats *) fun{x:t0p} list_vt_free (xs: List_vt (INV(x))):<!wrt> void overload free with list_vt_free
  • 20. Japan ATS User Group http://jats-ug.metasepi.org/ ☆ In a parody of http://jaws-ug.jp/ ☆ Push the Facebook like button, now! ☆ We translate ATS docs into Japanese
  • 24. Paper "Applied Type System" https://github.com/jats-ug/translate/raw/master/Paper/ATS-types03/ ATS-types03-ja.pdf
  • 25. Follow me! ☆ https://twitter.com/jats_ug ☆ https://www.facebook.com/jatsug
  • 26. License of photos used * Creative Commons BBB | Flickr - Photo Sharing! https://www.flickr.com/photos/steren/2732488224 Copyright: 2008 Steren Giannini / License: CC BY 2.0 * le coq / o galo de Barcelos | Flickr - Photo Sharing! https://www.flickr.com/photos/guymoll/311768037 Copyright: 2006 Guy MOLL / License: CC BY 2.0 * news_twitter_facebook | Flickr - Photo Sharing! https://www.flickr.com/photos/lioman/4324501845 Copyright: 2010 lioman123 / License: CC BY-SA 2.0 * Jordan shooting Jenna with shield | Flickr - Photo Sharing! https://www.flickr.com/photos/jasoneppink/80772834 Copyright: 2005 Jason Eppink / License: CC BY 2.0 * Marsh Plaza, Boston University | Flickr - Photo Sharing! https://www.flickr.com/photos/hankzby/14122296866 Copyright: 2014 Henry Zbyszynski / License: CC BY 2.0 * Love That Binds | Flickr - Photo Sharing! https://www.flickr.com/photos/enerva/12525888074 Copyright: 2014 Sonny Abesamis / License: CC BY 2.0