SlideShare uma empresa Scribd logo
1 de 39
Type Theory 
And Practical Application
The Institute for Advanced Study in Princeton, in my opinion, has ruined more good scientists than any institution has 
created, judged by what they did before they came and judged by what they did after. Not that they weren't good 
afterwards, but they were superb before they got there and were only good afterwards. 
-- Richard Hamming
Vladimir Voevodsky 
• Cutting-edge Math so complex probability 
of mistake in any given proof very high 
• Automated proof checking the present 
and future of Math 
• Video: 
Univalent Foundations: New 
Foundations of Mathematics 
http://video.ias.edu/node/6395
Frege  Martin-LÜf  Voevodsky 
• Gottlob Frege, active 1879 – 1923 
works in logic, foundations of arithmetic, and philosophy 
• Per Martin-Löf 
An Intuitionistic Theory of Types, 1975 
• Vladimir Voevodsky 
A very short note on the homotopy Îť-calculus, 2006 
• Institute for Advanced Study 
Homotopy Type Theory: Univalent Foundation of Mathematics, 2013 
a.k.a. The HoTT Book
“The relevance of theory to practical work is it shows us what is possible.”
“A language is type safe if running a program in the language cannot 
result in … the underlying operating system catching the error, not the 
language itself. It is the untrapped errors that hackers take advantage 
of to break into computer systems. [I]t's a good idea to only run code 
that is in a type safe language!” 
-- Jeremy Siek 
http://siek.blogspot.com/2012/08/type-safety-in-five-easy-lemmas.html
Harper’s Computer Science Holy Trinity 
• Category Theory 
• Type Theory 
• Proof Theory
Today’s State of the Art 
• Functional programming 
• Type systems 
largely missing dependent types 
Idris is a notable exception 
• Theorem provers (Coq, Agda, F7, F*) 
still largely in the research stage 
testing is poor man’s substitute for proof 
practical security research (e.g. Heart bleed bug in Open SSL) 
proving assertions about language compiler
Every-thing has a type 
• Objects are types 
• Propositions are types 
• Functions are types 
• Proofs are types
A theory of rules and no axioms 
(For our purposes. There are 2 axioms in higher homotopy type theory) 
• “axioms” appear when we introduce concrete types 
• The game is to manipulate concrete types and elements with the rules 
• i.e. Type Theory provides an algebra over types
a:A ”a is of type A ” 
• Type theory is a deductive system based on 2 forms of judgment 
• ”a is of type A ” is the most basic form of judgment 
• Construction of a proposition is a proof in intuitionistic mathematics
Equality has special cases 
• Judgmental equality a :≡ b is a “witness” 
• p : a =A b is a proposition (and of course a type) 
• p-1 : b =A a is a different type (we will come back to this)
Universes and families 
• Universe : a type whose elements are types 
• U0 : U1 : U2 : … 
• Every type belongs to some universe A : Ui 
• A family of types: type B varying over a type A 
B : A  U 
indicates the universe U is the codomain 
note this is a simple function signature
0 : U the type that is not 
• False, ⊥, bottom 
• You cannot construct it 
• Hence it does not exist. Anything can derive from it. 
ex falso quodlibit
1 : U unit 
• True, ⊤, top, () 
• Always the same 
one-valued logic 
• C family of languages oddly names this type “void”
2 : U boolean 
• 2-valued logic 
highest n-valued fully consistent logic 
• Can be derived as a special case of coproduct / summation type
Infinite types 
• E.g. Natural numbers 
which have a special place in practical application 
• Defined recursively
A  B function type 
• Signature matters to define type 
not the body of function
A + B : U Coproduct type 
• a.k.a. Summation type 
F# discriminated union 
• To construct the function A + B  C 
requires the functions 
A  C 
B  C
Brief tangent on introducing types 
• Formation rule 
e.g. you can form A  B when A is a type and B is a type 
• Introduction rule (a.k.a. constructor) 
e.g. functions have one constructor, Îť-abstraction 
• Elimination rule 
how to use elements of type, e.g. function application 
• Uniqueness principle (optional) 
unique maps into and out of type
A x B : U Product type 
• Tuple, Cartesian product
Lots of other types 
• E.g. Lists 
which of course are defined recursively 
• Not so important from the standpoint of theory 
because we can construct them from what we have…
EXCEPT…
Π(x:A)B(x) Dependent Functions 
• Type of output depends on element of input 
not the type of input 
hence, not just a “parameterized function” 
• Normal function is a special case 
resulting type family a constant type
ÎŁ(x:A)B(x) Dependent pair type 
• Second element depends on a dependently typed function on first 
• Example: 
1, 10 
2, “I am a string”
Logical operations, represented in types 
• True 1 
• False 0 
• A and B A x B 
• A or B A + B 
• If A then B A  B 
• A if and only if B (A  B) x (B  A) 
• Not A A  0
Predicate logic in type theory 
• For all x 
∀x corresponds to Π(x:A)P(x) 
• There exists x 
∃x corresponds to Σ(x:A)P(x)
IdA(a,b) Indentity function 
• Has special importance in type theory 
IdA(a,b) type representing proposition of equality 
p : a =A b 
a = b (shorthand) 
refl : Π(a:A)(a=Aa)reflexivity 
• Homotopy Type Theory – 
there is a path between equals 
reflexivity is an infinitesimally short path from self to self 
paths are types (inverse path is not the same type)
Fundamental “Mathy” Properties of Path 
• Reflexivity 
constant path, e.g. identity 
• Symmetry 
both directions of a “proof” 
• Transitivity 
concatenation of paths
Operations on paths 
• Identity (fundamental compositional element) 
• Associativity 
(p ∙ q) ∙ r = p ∙ (q ∙ r) 
• Transitivity 
p ∙ p-1 = Id(p)
…but equalities are proofs 
• So paths are proofs p : x =A y 
• The equivalence of 2 paths (proofs) is called a homotopy 
• And equality of proofs can have proofs 
p' : p =x=Ay q Paths between paths (i.e. equality of paths) 
• And these are all types 
• It’s turtles all the way down (equivalences of paths)
The Fundamental Theorem of Type Theory 
• Induction principal for identity types 
• Similar to 2 step number theory induction (prove base case, prove a step) 
• Except there is only one step to prove 
• To prove a statement (or construction an object) that depends on path 
identity, 
p: x = A y 
it suffices to prove (or construct) in the special case where x and y are 
the same. p is thus the reflexivity element. 
• “by induction it suffices to assume…”
Connection to computability 
• Constructive logic confines itself to that which can be effectively 
constructed by computation 
• It does not include Law of Excluded Middle or Proof by Contradiction 
• In general the tautologies of classical logic involving NOT cannot be 
constructed
Coming up for air (gasp, gasp) 
• This is where type checking comes in 
• Construction is a proof of a type 
• Type checking proves…
CORRECTNESS! 
“The basic principal of the logic of type theory is that a proposition 
is not merely true or false, but rather can be seen as the collection 
of all possible witnesses of its truth.” 
-- The HoTT Book, p. 53
Theorem Provers 
• Agda 
type checking 
• Coq 
proof strategies
Idris 
“…because Idris has full dependent types, the total subset of the 
language can be used freely in the type system…” 
• Idris: General Purpose Programming with Dependent Types 
https://www.youtube.com/watch?v=vkIlW797JN8 
• https://github.com/idris-lang/Idris-dev/wiki/Manual
Further Study 
• http://siek.blogspot.com/2012/07/crash-course-on-notation-in-programming.html 
• Simply-typed Lambda Calculus 
• Hindley-Milner type inference 
• Software Foundations 
Benjamin C. Pierce, et al. 
http://www.cis.upenn.edu/~bcpierce/sf/ 
• Types and Programming Languages (2002) 
Benjamin C. Pierce 
• Oregon Programming Languages Summer School

Mais conteĂşdo relacionado

Mais procurados

統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)Kota Mori
 
확률 통계 (파이썬)
확률 통계 (파이썬)확률 통계 (파이썬)
확률 통계 (파이썬)Yong Joon Moon
 
統計的学習の基礎6章前半 #カステラ本
統計的学習の基礎6章前半 #カステラ本統計的学習の基礎6章前半 #カステラ本
統計的学習の基礎6章前半 #カステラ本Akifumi Eguchi
 
Rパッケージ recipes の紹介 「うまい飯を作る」
Rパッケージ recipes の紹介 「うまい飯を作る」Rパッケージ recipes の紹介 「うまい飯を作る」
Rパッケージ recipes の紹介 「うまい飯を作る」Yutaka Kuroki
 
量子アニーリング解説 1
量子アニーリング解説 1量子アニーリング解説 1
量子アニーリング解説 1Kohta Ishikawa
 
ラムダ計算入門
ラムダ計算入門ラムダ計算入門
ラムダ計算入門Eita Sugimoto
 
PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現hagino 3000
 
計算論的学習理論入門 -PAC学習とかVC次元とか-
計算論的学習理論入門 -PAC学習とかVC次元とか-計算論的学習理論入門 -PAC学習とかVC次元とか-
計算論的学習理論入門 -PAC学習とかVC次元とか-sleepy_yoshi
 
String Matching with Finite Automata and Knuth Morris Pratt Algorithm
String Matching with Finite Automata and Knuth Morris Pratt AlgorithmString Matching with Finite Automata and Knuth Morris Pratt Algorithm
String Matching with Finite Automata and Knuth Morris Pratt AlgorithmKiran K
 
よくわかるCoqプログラミング
よくわかるCoqプログラミングよくわかるCoqプログラミング
よくわかるCoqプログラミングReal_analysis
 
クラシックな機械学習の入門 3. 線形回帰および識別
クラシックな機械学習の入門 3. 線形回帰および識別クラシックな機械学習の入門 3. 線形回帰および識別
クラシックな機械学習の入門 3. 線形回帰および識別Hiroshi Nakagawa
 
Feature Engineering
Feature EngineeringFeature Engineering
Feature EngineeringSri Ambati
 
Multiple optimization and Non-dominated sorting with rPref package in R
Multiple optimization and Non-dominated sorting with rPref package in RMultiple optimization and Non-dominated sorting with rPref package in R
Multiple optimization and Non-dominated sorting with rPref package in RSatoshi Kato
 
Explanation in Machine Learning and Its Reliability
Explanation in Machine Learning and Its ReliabilityExplanation in Machine Learning and Its Reliability
Explanation in Machine Learning and Its ReliabilitySatoshi Hara
 
MLaPP 9章 「一般化線形モデルと指数型分布族」
MLaPP 9章 「一般化線形モデルと指数型分布族」MLaPP 9章 「一般化線形モデルと指数型分布族」
MLaPP 9章 「一般化線形モデルと指数型分布族」moterech
 
線形計画法入門
線形計画法入門線形計画法入門
線形計画法入門Shunji Umetani
 
公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論Kazuto Fukuchi
 
Rで学ぶロバスト推定
Rで学ぶロバスト推定Rで学ぶロバスト推定
Rで学ぶロバスト推定Shintaro Fukushima
 
情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張nishioka1
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISPNilt1234
 

Mais procurados (20)

統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)統計的学習の基礎 5章前半(~5.6)
統計的学習の基礎 5章前半(~5.6)
 
확률 통계 (파이썬)
확률 통계 (파이썬)확률 통계 (파이썬)
확률 통계 (파이썬)
 
統計的学習の基礎6章前半 #カステラ本
統計的学習の基礎6章前半 #カステラ本統計的学習の基礎6章前半 #カステラ本
統計的学習の基礎6章前半 #カステラ本
 
Rパッケージ recipes の紹介 「うまい飯を作る」
Rパッケージ recipes の紹介 「うまい飯を作る」Rパッケージ recipes の紹介 「うまい飯を作る」
Rパッケージ recipes の紹介 「うまい飯を作る」
 
量子アニーリング解説 1
量子アニーリング解説 1量子アニーリング解説 1
量子アニーリング解説 1
 
ラムダ計算入門
ラムダ計算入門ラムダ計算入門
ラムダ計算入門
 
PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現PRML 6.1章 カーネル法と双対表現
PRML 6.1章 カーネル法と双対表現
 
計算論的学習理論入門 -PAC学習とかVC次元とか-
計算論的学習理論入門 -PAC学習とかVC次元とか-計算論的学習理論入門 -PAC学習とかVC次元とか-
計算論的学習理論入門 -PAC学習とかVC次元とか-
 
String Matching with Finite Automata and Knuth Morris Pratt Algorithm
String Matching with Finite Automata and Knuth Morris Pratt AlgorithmString Matching with Finite Automata and Knuth Morris Pratt Algorithm
String Matching with Finite Automata and Knuth Morris Pratt Algorithm
 
よくわかるCoqプログラミング
よくわかるCoqプログラミングよくわかるCoqプログラミング
よくわかるCoqプログラミング
 
クラシックな機械学習の入門 3. 線形回帰および識別
クラシックな機械学習の入門 3. 線形回帰および識別クラシックな機械学習の入門 3. 線形回帰および識別
クラシックな機械学習の入門 3. 線形回帰および識別
 
Feature Engineering
Feature EngineeringFeature Engineering
Feature Engineering
 
Multiple optimization and Non-dominated sorting with rPref package in R
Multiple optimization and Non-dominated sorting with rPref package in RMultiple optimization and Non-dominated sorting with rPref package in R
Multiple optimization and Non-dominated sorting with rPref package in R
 
Explanation in Machine Learning and Its Reliability
Explanation in Machine Learning and Its ReliabilityExplanation in Machine Learning and Its Reliability
Explanation in Machine Learning and Its Reliability
 
MLaPP 9章 「一般化線形モデルと指数型分布族」
MLaPP 9章 「一般化線形モデルと指数型分布族」MLaPP 9章 「一般化線形モデルと指数型分布族」
MLaPP 9章 「一般化線形モデルと指数型分布族」
 
線形計画法入門
線形計画法入門線形計画法入門
線形計画法入門
 
公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論
 
Rで学ぶロバスト推定
Rで学ぶロバスト推定Rで学ぶロバスト推定
Rで学ぶロバスト推定
 
情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 

Destaque

Agricultural research for crop and livestock value chains development: The IP...
Agricultural research for crop and livestock value chains development: The IP...Agricultural research for crop and livestock value chains development: The IP...
Agricultural research for crop and livestock value chains development: The IP...ILRI
 
Tools for reading papers
Tools for reading papersTools for reading papers
Tools for reading papersJack Fox
 
Functional linear data structures in f#
Functional linear data structures in f#Functional linear data structures in f#
Functional linear data structures in f#Jack Fox
 
Type theories personality theories (4 Temperament theory, 5 Temperament the...
Type theories   personality theories (4 Temperament theory, 5 Temperament the...Type theories   personality theories (4 Temperament theory, 5 Temperament the...
Type theories personality theories (4 Temperament theory, 5 Temperament the...Manu Melwin Joy
 
Analytical psychology Theories of Personality Carl Jung
Analytical psychology Theories of Personality Carl JungAnalytical psychology Theories of Personality Carl Jung
Analytical psychology Theories of Personality Carl JungGrace Bran
 

Destaque (6)

Agricultural research for crop and livestock value chains development: The IP...
Agricultural research for crop and livestock value chains development: The IP...Agricultural research for crop and livestock value chains development: The IP...
Agricultural research for crop and livestock value chains development: The IP...
 
Tools for reading papers
Tools for reading papersTools for reading papers
Tools for reading papers
 
Functional linear data structures in f#
Functional linear data structures in f#Functional linear data structures in f#
Functional linear data structures in f#
 
Modal Type Theory
Modal Type TheoryModal Type Theory
Modal Type Theory
 
Type theories personality theories (4 Temperament theory, 5 Temperament the...
Type theories   personality theories (4 Temperament theory, 5 Temperament the...Type theories   personality theories (4 Temperament theory, 5 Temperament the...
Type theories personality theories (4 Temperament theory, 5 Temperament the...
 
Analytical psychology Theories of Personality Carl Jung
Analytical psychology Theories of Personality Carl JungAnalytical psychology Theories of Personality Carl Jung
Analytical psychology Theories of Personality Carl Jung
 

Semelhante a Type Theory and Practical Application

Intoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryIntoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryJack Fox
 
Propositional logic(part 2)
Propositional logic(part 2)Propositional logic(part 2)
Propositional logic(part 2)SURBHI SAROHA
 
chapter2 Know.representation.pptx
chapter2 Know.representation.pptxchapter2 Know.representation.pptx
chapter2 Know.representation.pptxwendifrawtadesse1
 
Mdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsMdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsRafael Alvarado
 
AI3391 Artificial intelligence Unit IV Notes _ merged.pdf
AI3391 Artificial intelligence Unit IV Notes _ merged.pdfAI3391 Artificial intelligence Unit IV Notes _ merged.pdf
AI3391 Artificial intelligence Unit IV Notes _ merged.pdfAsst.prof M.Gokilavani
 
AI3391 Artificial Intelligence Session 26 First order logic.pptx
AI3391 Artificial Intelligence Session 26 First order logic.pptxAI3391 Artificial Intelligence Session 26 First order logic.pptx
AI3391 Artificial Intelligence Session 26 First order logic.pptxAsst.prof M.Gokilavani
 
Subtyping
Subtyping Subtyping
Subtyping Jeff Chen
 
BT02.pptx
BT02.pptxBT02.pptx
BT02.pptxThAnhonc
 
Fis2010 0823
Fis2010 0823Fis2010 0823
Fis2010 0823Koji Sawa
 
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...Codemotion
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)Nitesh Singh
 
L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classesteach4uin
 
Who studies maths practice
Who studies maths practiceWho studies maths practice
Who studies maths practiceBrendan Larvor
 
Who studies maths practice
Who studies maths practiceWho studies maths practice
Who studies maths practiceBrendan Larvor
 
Lec 3 knowledge acquisition representation and inference
Lec 3  knowledge acquisition representation and inferenceLec 3  knowledge acquisition representation and inference
Lec 3 knowledge acquisition representation and inferenceEyob Sisay
 
Time series anomaly discovery with grammar-based compression
Time series anomaly discovery with grammar-based compressionTime series anomaly discovery with grammar-based compression
Time series anomaly discovery with grammar-based compressionPavel Senin
 
The logic(s) of informal proofs (tyumen, western siberia 2019)
The logic(s) of informal proofs (tyumen, western siberia 2019)The logic(s) of informal proofs (tyumen, western siberia 2019)
The logic(s) of informal proofs (tyumen, western siberia 2019)Brendan Larvor
 
Foundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptxFoundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptxkitsenthilkumarcse
 

Semelhante a Type Theory and Practical Application (20)

Intoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryIntoduction to Homotopy Type Therory
Intoduction to Homotopy Type Therory
 
Propositional logic(part 2)
Propositional logic(part 2)Propositional logic(part 2)
Propositional logic(part 2)
 
chapter2 Know.representation.pptx
chapter2 Know.representation.pptxchapter2 Know.representation.pptx
chapter2 Know.representation.pptx
 
Mdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsMdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signals
 
AI3391 Artificial intelligence Unit IV Notes _ merged.pdf
AI3391 Artificial intelligence Unit IV Notes _ merged.pdfAI3391 Artificial intelligence Unit IV Notes _ merged.pdf
AI3391 Artificial intelligence Unit IV Notes _ merged.pdf
 
Geuvers slides
Geuvers slidesGeuvers slides
Geuvers slides
 
AI3391 Artificial Intelligence Session 26 First order logic.pptx
AI3391 Artificial Intelligence Session 26 First order logic.pptxAI3391 Artificial Intelligence Session 26 First order logic.pptx
AI3391 Artificial Intelligence Session 26 First order logic.pptx
 
Subtyping
Subtyping Subtyping
Subtyping
 
BT02.pptx
BT02.pptxBT02.pptx
BT02.pptx
 
Fis2010 0823
Fis2010 0823Fis2010 0823
Fis2010 0823
 
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
Mike Kotsur - What can philosophy teach us about programming - Codemotion Ams...
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
 
L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classes
 
Lecture 1 - Objects and classes
Lecture 1 - Objects and classesLecture 1 - Objects and classes
Lecture 1 - Objects and classes
 
Who studies maths practice
Who studies maths practiceWho studies maths practice
Who studies maths practice
 
Who studies maths practice
Who studies maths practiceWho studies maths practice
Who studies maths practice
 
Lec 3 knowledge acquisition representation and inference
Lec 3  knowledge acquisition representation and inferenceLec 3  knowledge acquisition representation and inference
Lec 3 knowledge acquisition representation and inference
 
Time series anomaly discovery with grammar-based compression
Time series anomaly discovery with grammar-based compressionTime series anomaly discovery with grammar-based compression
Time series anomaly discovery with grammar-based compression
 
The logic(s) of informal proofs (tyumen, western siberia 2019)
The logic(s) of informal proofs (tyumen, western siberia 2019)The logic(s) of informal proofs (tyumen, western siberia 2019)
The logic(s) of informal proofs (tyumen, western siberia 2019)
 
Foundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptxFoundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptx
 

Mais de Jack Fox

Dependent Types make bad data unrepresentable
Dependent Types make bad data unrepresentableDependent Types make bad data unrepresentable
Dependent Types make bad data unrepresentableJack Fox
 
Dependent Types
Dependent TypesDependent Types
Dependent TypesJack Fox
 
Introduction to the lambda calculus
Introduction to the lambda calculusIntroduction to the lambda calculus
Introduction to the lambda calculusJack Fox
 
Functional programming for production quality code
Functional programming for production quality codeFunctional programming for production quality code
Functional programming for production quality codeJack Fox
 
F# for functional enthusiasts
F# for functional enthusiastsF# for functional enthusiasts
F# for functional enthusiastsJack Fox
 
Semantically coherent functional linear data structures
Semantically coherent functional linear data structuresSemantically coherent functional linear data structures
Semantically coherent functional linear data structuresJack Fox
 
Linear structures lightning talk
Linear structures lightning talkLinear structures lightning talk
Linear structures lightning talkJack Fox
 

Mais de Jack Fox (7)

Dependent Types make bad data unrepresentable
Dependent Types make bad data unrepresentableDependent Types make bad data unrepresentable
Dependent Types make bad data unrepresentable
 
Dependent Types
Dependent TypesDependent Types
Dependent Types
 
Introduction to the lambda calculus
Introduction to the lambda calculusIntroduction to the lambda calculus
Introduction to the lambda calculus
 
Functional programming for production quality code
Functional programming for production quality codeFunctional programming for production quality code
Functional programming for production quality code
 
F# for functional enthusiasts
F# for functional enthusiastsF# for functional enthusiasts
F# for functional enthusiasts
 
Semantically coherent functional linear data structures
Semantically coherent functional linear data structuresSemantically coherent functional linear data structures
Semantically coherent functional linear data structures
 
Linear structures lightning talk
Linear structures lightning talkLinear structures lightning talk
Linear structures lightning talk
 

Último

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
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
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
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
 
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
 
(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
 
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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
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
 
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
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
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
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Último (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
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
 
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...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
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
 
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
 
(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...
 
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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
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
 
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
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
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
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Type Theory and Practical Application

  • 1. Type Theory And Practical Application
  • 2. The Institute for Advanced Study in Princeton, in my opinion, has ruined more good scientists than any institution has created, judged by what they did before they came and judged by what they did after. Not that they weren't good afterwards, but they were superb before they got there and were only good afterwards. -- Richard Hamming
  • 3. Vladimir Voevodsky • Cutting-edge Math so complex probability of mistake in any given proof very high • Automated proof checking the present and future of Math • Video: Univalent Foundations: New Foundations of Mathematics http://video.ias.edu/node/6395
  • 4. Frege  Martin-LĂśf  Voevodsky • Gottlob Frege, active 1879 – 1923 works in logic, foundations of arithmetic, and philosophy • Per Martin-LĂśf An Intuitionistic Theory of Types, 1975 • Vladimir Voevodsky A very short note on the homotopy Îť-calculus, 2006 • Institute for Advanced Study Homotopy Type Theory: Univalent Foundation of Mathematics, 2013 a.k.a. The HoTT Book
  • 5. “The relevance of theory to practical work is it shows us what is possible.”
  • 6. “A language is type safe if running a program in the language cannot result in … the underlying operating system catching the error, not the language itself. It is the untrapped errors that hackers take advantage of to break into computer systems. [I]t's a good idea to only run code that is in a type safe language!” -- Jeremy Siek http://siek.blogspot.com/2012/08/type-safety-in-five-easy-lemmas.html
  • 7.
  • 8. Harper’s Computer Science Holy Trinity • Category Theory • Type Theory • Proof Theory
  • 9. Today’s State of the Art • Functional programming • Type systems largely missing dependent types Idris is a notable exception • Theorem provers (Coq, Agda, F7, F*) still largely in the research stage testing is poor man’s substitute for proof practical security research (e.g. Heart bleed bug in Open SSL) proving assertions about language compiler
  • 10. Every-thing has a type • Objects are types • Propositions are types • Functions are types • Proofs are types
  • 11. A theory of rules and no axioms (For our purposes. There are 2 axioms in higher homotopy type theory) • “axioms” appear when we introduce concrete types • The game is to manipulate concrete types and elements with the rules • i.e. Type Theory provides an algebra over types
  • 12. a:A ”a is of type A ” • Type theory is a deductive system based on 2 forms of judgment • ”a is of type A ” is the most basic form of judgment • Construction of a proposition is a proof in intuitionistic mathematics
  • 13. Equality has special cases • Judgmental equality a :≡ b is a “witness” • p : a =A b is a proposition (and of course a type) • p-1 : b =A a is a different type (we will come back to this)
  • 14. Universes and families • Universe : a type whose elements are types • U0 : U1 : U2 : … • Every type belongs to some universe A : Ui • A family of types: type B varying over a type A B : A  U indicates the universe U is the codomain note this is a simple function signature
  • 15. 0 : U the type that is not • False, ⊥, bottom • You cannot construct it • Hence it does not exist. Anything can derive from it. ex falso quodlibit
  • 16. 1 : U unit • True, ⊤, top, () • Always the same one-valued logic • C family of languages oddly names this type “void”
  • 17. 2 : U boolean • 2-valued logic highest n-valued fully consistent logic • Can be derived as a special case of coproduct / summation type
  • 18. Infinite types • E.g. Natural numbers which have a special place in practical application • Defined recursively
  • 19. A  B function type • Signature matters to define type not the body of function
  • 20. A + B : U Coproduct type • a.k.a. Summation type F# discriminated union • To construct the function A + B  C requires the functions A  C B  C
  • 21. Brief tangent on introducing types • Formation rule e.g. you can form A  B when A is a type and B is a type • Introduction rule (a.k.a. constructor) e.g. functions have one constructor, Îť-abstraction • Elimination rule how to use elements of type, e.g. function application • Uniqueness principle (optional) unique maps into and out of type
  • 22. A x B : U Product type • Tuple, Cartesian product
  • 23. Lots of other types • E.g. Lists which of course are defined recursively • Not so important from the standpoint of theory because we can construct them from what we have…
  • 25. Π(x:A)B(x) Dependent Functions • Type of output depends on element of input not the type of input hence, not just a “parameterized function” • Normal function is a special case resulting type family a constant type
  • 26. ÎŁ(x:A)B(x) Dependent pair type • Second element depends on a dependently typed function on first • Example: 1, 10 2, “I am a string”
  • 27. Logical operations, represented in types • True 1 • False 0 • A and B A x B • A or B A + B • If A then B A  B • A if and only if B (A  B) x (B  A) • Not A A  0
  • 28. Predicate logic in type theory • For all x ∀x corresponds to Π(x:A)P(x) • There exists x ∃x corresponds to ÎŁ(x:A)P(x)
  • 29. IdA(a,b) Indentity function • Has special importance in type theory IdA(a,b) type representing proposition of equality p : a =A b a = b (shorthand) refl : Π(a:A)(a=Aa)reflexivity • Homotopy Type Theory – there is a path between equals reflexivity is an infinitesimally short path from self to self paths are types (inverse path is not the same type)
  • 30. Fundamental “Mathy” Properties of Path • Reflexivity constant path, e.g. identity • Symmetry both directions of a “proof” • Transitivity concatenation of paths
  • 31. Operations on paths • Identity (fundamental compositional element) • Associativity (p ∙ q) ∙ r = p ∙ (q ∙ r) • Transitivity p ∙ p-1 = Id(p)
  • 32. …but equalities are proofs • So paths are proofs p : x =A y • The equivalence of 2 paths (proofs) is called a homotopy • And equality of proofs can have proofs p' : p =x=Ay q Paths between paths (i.e. equality of paths) • And these are all types • It’s turtles all the way down (equivalences of paths)
  • 33. The Fundamental Theorem of Type Theory • Induction principal for identity types • Similar to 2 step number theory induction (prove base case, prove a step) • Except there is only one step to prove • To prove a statement (or construction an object) that depends on path identity, p: x = A y it suffices to prove (or construct) in the special case where x and y are the same. p is thus the reflexivity element. • “by induction it suffices to assume…”
  • 34. Connection to computability • Constructive logic confines itself to that which can be effectively constructed by computation • It does not include Law of Excluded Middle or Proof by Contradiction • In general the tautologies of classical logic involving NOT cannot be constructed
  • 35. Coming up for air (gasp, gasp) • This is where type checking comes in • Construction is a proof of a type • Type checking proves…
  • 36. CORRECTNESS! “The basic principal of the logic of type theory is that a proposition is not merely true or false, but rather can be seen as the collection of all possible witnesses of its truth.” -- The HoTT Book, p. 53
  • 37. Theorem Provers • Agda type checking • Coq proof strategies
  • 38. Idris “…because Idris has full dependent types, the total subset of the language can be used freely in the type system…” • Idris: General Purpose Programming with Dependent Types https://www.youtube.com/watch?v=vkIlW797JN8 • https://github.com/idris-lang/Idris-dev/wiki/Manual
  • 39. Further Study • http://siek.blogspot.com/2012/07/crash-course-on-notation-in-programming.html • Simply-typed Lambda Calculus • Hindley-Milner type inference • Software Foundations Benjamin C. Pierce, et al. http://www.cis.upenn.edu/~bcpierce/sf/ • Types and Programming Languages (2002) Benjamin C. Pierce • Oregon Programming Languages Summer School