SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
Hello, Type Systems!
Introduction to Featherweight Java
Cheshire Cat (@y_taka_23)
Shibuya Java #12 (Aug. 1, 2015)
Who Am I?
● HN: Cheshire Cat
● Twitter: @y_taka_23
● GitHub: y-taka-23
● Favorites
○ Formal methods
○ Functional programming
In the Era of Java 1.4
The following is compilable, but ...
public static void main(String[] args) {
List list = new ArrayList();
list.add(23);
String str = (String) list.get(0);
}
In the Era of Java 1.4
Implicite upcast from int to Object
public static void main(String[] args) {
List list = new ArrayList();
list.add(23);
String str = (String) list.get(0);
}
In the Era of Java 1.4
Downcast from Object to String
public static void main(String[] args) {
List list = new ArrayList();
list.add(23);
String str = (String) list.get(0);
}
In the Era of Java 1.4
Run-time exception!!
public static void main(String[] args) {
List list = new ArrayList();
list.add(23);
String str = (String) list.get(0);
}
What is the “Type Safety”?
Featherweight Java (FJ)
● Introduced by IGARASHI et al. (2002)
● Formalized & minimalized model
● Many features are omitted, e.g.
○ Assignment
○ Interfaces
○ Exceptions
● “Functional” fragment of Java
Three Points to Understand FJ
1. Expressions: What is the “programs”?
2. Typing: What is the “type check”?
3. Reduction: What is the “execution”?
Expressions
● Variables
● Constructors
● Field accesses
● Method invocations
● Casts
x1, x2, ...
new C(e1, ..., en)
e.f
e.m(x1, ..., xn)
(C)e
Typing Rules
Example: Rule for field accesses
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
Premise
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
Conclusion
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
Type env: Map from variable names to types
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
If e0 has type C0 under Gamma,
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
and fields of class C0 are
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
f1, ..., fn of classes C1, ..., Cn,
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Typing Rules
then e0.fi has type Ci under Gamma
Gamma |- e0 : C0
fields(C0) = C1 f1, ..., Cn fn
--------------------------------
Gamma |- e0.fi : Ci
Reduction Rules
Example: Rule for field accesses
fields(C) = C1 f1, ..., Cn fn
--------------------------------
(new C(e1, ..., en)).fi -> ei
Reduction Rules
Premise
fields(C) = C1 f1, ..., Cn fn
--------------------------------
(new C(e1, ..., en)).fi -> ei
Reduction Rules
Conclusion
fields(C) = C1 f1, ..., Cn fn
--------------------------------
(new C(e1, ..., en)).fi -> ei
Reduction Rules
If fields of class C are ...
fields(C) = C1 f1, ..., Cn fn
--------------------------------
(new C(e1, ..., en)).fi -> ei
Reduction Rules
f1, ..., fn of classes C1, ..., Cn,
fields(C) = C1 f1, ..., Cn fn
--------------------------------
(new C(e1, ..., en)).fi -> ei
Reduction Rules
then(new ...).fi reduces to ei
fields(C) = C1 f1, ..., Cn fn
--------------------------------
(new C(e1, ..., en)).fi -> ei
“Type Safety” in FJ
If an expression e satisfies:
● e has a type without the two “impolite” rules
● e -> ... -> e’
● No expression e’’ such that e’ -> e’’
Then e’ must be “completely reduced”, i.e.
● e consists of only constructors
Summary
● FJ is the “minimum” model of Java
● “Type safety” is the consistency of
○ Typing rules
○ Reduction rules
● We can discuss properties of
programming languages by formalization
Have a Nice Typing!
Presented by
Cheshire Cat (@y_taka_23)

Más contenido relacionado

La actualidad más candente

computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
ecomputernotes
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
Syed Umair
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
Kota Abe
 
Derivatives Lesson Oct 14
Derivatives Lesson  Oct 14Derivatives Lesson  Oct 14
Derivatives Lesson Oct 14
ingroy
 

La actualidad más candente (20)

Stack
StackStack
Stack
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
 
[C++ Korea] Effective Modern C++ Study item 34 36
[C++ Korea] Effective Modern C++ Study item 34 36[C++ Korea] Effective Modern C++ Study item 34 36
[C++ Korea] Effective Modern C++ Study item 34 36
 
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
 
Breadth-First-Search algorithm with Code
Breadth-First-Search algorithm with CodeBreadth-First-Search algorithm with Code
Breadth-First-Search algorithm with Code
 
Introduction to Python and Matplotlib
Introduction to Python and MatplotlibIntroduction to Python and Matplotlib
Introduction to Python and Matplotlib
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
 
Derivatives Lesson Oct 14
Derivatives Lesson  Oct 14Derivatives Lesson  Oct 14
Derivatives Lesson Oct 14
 
Nesting of for loops using C++
Nesting of for loops using C++Nesting of for loops using C++
Nesting of for loops using C++
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
 
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
 
stack
stackstack
stack
 

Destacado

Destacado (10)

Frege, What a Non-strict Language
Frege, What a Non-strict LanguageFrege, What a Non-strict Language
Frege, What a Non-strict Language
 
AWS は形式手法の夢を見るか? - モデル検査器 Alloy によるインフラ設計
AWS は形式手法の夢を見るか? - モデル検査器 Alloy によるインフラ設計AWS は形式手法の夢を見るか? - モデル検査器 Alloy によるインフラ設計
AWS は形式手法の夢を見るか? - モデル検査器 Alloy によるインフラ設計
 
Fission で 始める Containerless Kubernetes #serverlesstokyo
Fission で 始める Containerless Kubernetes #serverlesstokyoFission で 始める Containerless Kubernetes #serverlesstokyo
Fission で 始める Containerless Kubernetes #serverlesstokyo
 
Learn You a Frege for Great Good!
Learn You a Frege for Great Good!Learn You a Frege for Great Good!
Learn You a Frege for Great Good!
 
すごい Frege たのしく学ぼう!
すごい Frege たのしく学ぼう!すごい Frege たのしく学ぼう!
すごい Frege たのしく学ぼう!
 
猫でもわかる! モデル検査器 SPIN 入門
猫でもわかる! モデル検査器 SPIN 入門猫でもわかる! モデル検査器 SPIN 入門
猫でもわかる! モデル検査器 SPIN 入門
 
机上の Kubernetes - 形式手法で見るコンテナオーケストレーション #NGK2016B
机上の Kubernetes -  形式手法で見るコンテナオーケストレーション #NGK2016B机上の Kubernetes -  形式手法で見るコンテナオーケストレーション #NGK2016B
机上の Kubernetes - 形式手法で見るコンテナオーケストレーション #NGK2016B
 
形式手法と AWS のおいしい関係。- モデル検査器 Alloy によるインフラ設計技法 #jawsfesta
形式手法と AWS のおいしい関係。- モデル検査器 Alloy によるインフラ設計技法 #jawsfesta形式手法と AWS のおいしい関係。- モデル検査器 Alloy によるインフラ設計技法 #jawsfesta
形式手法と AWS のおいしい関係。- モデル検査器 Alloy によるインフラ設計技法 #jawsfesta
 
形式手法で捗る!インフラ構成の設計と検証
形式手法で捗る!インフラ構成の設計と検証形式手法で捗る!インフラ構成の設計と検証
形式手法で捗る!インフラ構成の設計と検証
 
思ったほど怖くない! Haskell on JVM 超入門 #jjug_ccc #ccc_l8
思ったほど怖くない! Haskell on JVM 超入門 #jjug_ccc #ccc_l8思ったほど怖くない! Haskell on JVM 超入門 #jjug_ccc #ccc_l8
思ったほど怖くない! Haskell on JVM 超入門 #jjug_ccc #ccc_l8
 

Similar a Hello, Type Systems! - Introduction to Featherweight Java

Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
anujsharmaanuj14
 
Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]
Palak Sanghani
 
Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
Mohamed Krar
 
Csc1100 lecture09 ch07_pt2
Csc1100 lecture09 ch07_pt2Csc1100 lecture09 ch07_pt2
Csc1100 lecture09 ch07_pt2
IIUM
 
Lecture 2 coding_principles
Lecture 2 coding_principlesLecture 2 coding_principles
Lecture 2 coding_principles
moduledesign
 

Similar a Hello, Type Systems! - Introduction to Featherweight Java (20)

Chapter 7 String
Chapter 7 StringChapter 7 String
Chapter 7 String
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.3 book - Part 26 of 88The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.3 book - Part 26 of 88
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and Java
 
Oop objects_classes
Oop objects_classesOop objects_classes
Oop objects_classes
 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
 
Lecture 2 coding_principles
Lecture 2 coding_principlesLecture 2 coding_principles
Lecture 2 coding_principles
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]
 
Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
 
The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.5.3 book - Part 35 of 184The Ring programming language version 1.5.3 book - Part 35 of 184
The Ring programming language version 1.5.3 book - Part 35 of 184
 
Comp102 lec 7
Comp102   lec 7Comp102   lec 7
Comp102 lec 7
 
Chap2 class,objects contd
Chap2 class,objects contdChap2 class,objects contd
Chap2 class,objects contd
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
Csc1100 lecture09 ch07_pt2
Csc1100 lecture09 ch07_pt2Csc1100 lecture09 ch07_pt2
Csc1100 lecture09 ch07_pt2
 
Lecture 2 coding_principles
Lecture 2 coding_principlesLecture 2 coding_principles
Lecture 2 coding_principles
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Hello, Type Systems! - Introduction to Featherweight Java

  • 1. Hello, Type Systems! Introduction to Featherweight Java Cheshire Cat (@y_taka_23) Shibuya Java #12 (Aug. 1, 2015)
  • 2. Who Am I? ● HN: Cheshire Cat ● Twitter: @y_taka_23 ● GitHub: y-taka-23 ● Favorites ○ Formal methods ○ Functional programming
  • 3. In the Era of Java 1.4 The following is compilable, but ... public static void main(String[] args) { List list = new ArrayList(); list.add(23); String str = (String) list.get(0); }
  • 4. In the Era of Java 1.4 Implicite upcast from int to Object public static void main(String[] args) { List list = new ArrayList(); list.add(23); String str = (String) list.get(0); }
  • 5. In the Era of Java 1.4 Downcast from Object to String public static void main(String[] args) { List list = new ArrayList(); list.add(23); String str = (String) list.get(0); }
  • 6. In the Era of Java 1.4 Run-time exception!! public static void main(String[] args) { List list = new ArrayList(); list.add(23); String str = (String) list.get(0); }
  • 7. What is the “Type Safety”?
  • 8. Featherweight Java (FJ) ● Introduced by IGARASHI et al. (2002) ● Formalized & minimalized model ● Many features are omitted, e.g. ○ Assignment ○ Interfaces ○ Exceptions ● “Functional” fragment of Java
  • 9. Three Points to Understand FJ 1. Expressions: What is the “programs”? 2. Typing: What is the “type check”? 3. Reduction: What is the “execution”?
  • 10. Expressions ● Variables ● Constructors ● Field accesses ● Method invocations ● Casts x1, x2, ... new C(e1, ..., en) e.f e.m(x1, ..., xn) (C)e
  • 11. Typing Rules Example: Rule for field accesses Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 12. Typing Rules Premise Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 13. Typing Rules Conclusion Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 14. Typing Rules Type env: Map from variable names to types Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 15. Typing Rules If e0 has type C0 under Gamma, Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 16. Typing Rules and fields of class C0 are Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 17. Typing Rules f1, ..., fn of classes C1, ..., Cn, Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 18. Typing Rules then e0.fi has type Ci under Gamma Gamma |- e0 : C0 fields(C0) = C1 f1, ..., Cn fn -------------------------------- Gamma |- e0.fi : Ci
  • 19. Reduction Rules Example: Rule for field accesses fields(C) = C1 f1, ..., Cn fn -------------------------------- (new C(e1, ..., en)).fi -> ei
  • 20. Reduction Rules Premise fields(C) = C1 f1, ..., Cn fn -------------------------------- (new C(e1, ..., en)).fi -> ei
  • 21. Reduction Rules Conclusion fields(C) = C1 f1, ..., Cn fn -------------------------------- (new C(e1, ..., en)).fi -> ei
  • 22. Reduction Rules If fields of class C are ... fields(C) = C1 f1, ..., Cn fn -------------------------------- (new C(e1, ..., en)).fi -> ei
  • 23. Reduction Rules f1, ..., fn of classes C1, ..., Cn, fields(C) = C1 f1, ..., Cn fn -------------------------------- (new C(e1, ..., en)).fi -> ei
  • 24. Reduction Rules then(new ...).fi reduces to ei fields(C) = C1 f1, ..., Cn fn -------------------------------- (new C(e1, ..., en)).fi -> ei
  • 25. “Type Safety” in FJ If an expression e satisfies: ● e has a type without the two “impolite” rules ● e -> ... -> e’ ● No expression e’’ such that e’ -> e’’ Then e’ must be “completely reduced”, i.e. ● e consists of only constructors
  • 26. Summary ● FJ is the “minimum” model of Java ● “Type safety” is the consistency of ○ Typing rules ○ Reduction rules ● We can discuss properties of programming languages by formalization
  • 27. Have a Nice Typing! Presented by Cheshire Cat (@y_taka_23)