SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

圏論のモナドとHaskellのモナド
圏論のモナドとHaskellのモナド圏論のモナドとHaskellのモナド
圏論のモナドとHaskellのモナドYoshihiro Mizoguchi
 
自動定理証明の紹介
自動定理証明の紹介自動定理証明の紹介
自動定理証明の紹介Masahiro Sakai
 
数学で解き明かす深層学習の原理
数学で解き明かす深層学習の原理数学で解き明かす深層学習の原理
数学で解き明かす深層学習の原理Taiji Suzuki
 
Cody Roux - Pure Type Systems - Boston Haskell Meetup
Cody Roux - Pure Type Systems - Boston Haskell MeetupCody Roux - Pure Type Systems - Boston Haskell Meetup
Cody Roux - Pure Type Systems - Boston Haskell MeetupGreg Hale
 
pixivのおすすめを改善する話
pixivのおすすめを改善する話pixivのおすすめを改善する話
pixivのおすすめを改善する話Masataka Miyoshi
 
ベイズ統計によるデータ解析
ベイズ統計によるデータ解析ベイズ統計によるデータ解析
ベイズ統計によるデータ解析Kunihiro Hisatsune
 
LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編
LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編
LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編Maho Nakata
 
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)Yoshitake Takebayashi
 
【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~
【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~ 【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~
【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~ TOKITA Shinichi
 
社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森Masashi Komori
 
Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp
Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp
Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp @yuzutas0 Yokoyama
 
ユーザーサイド情報検索システム
ユーザーサイド情報検索システムユーザーサイド情報検索システム
ユーザーサイド情報検索システムjoisino
 
Apache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームApache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームKouhei Sutou
 
Scala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみたScala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみたKazuyuki TAKASE
 
感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...
感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...
感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...Masatoshi Yoshida
 
よくわかるCoqプログラミング
よくわかるCoqプログラミングよくわかるCoqプログラミング
よくわかるCoqプログラミングReal_analysis
 
よくわかるフリストンの自由エネルギー原理
よくわかるフリストンの自由エネルギー原理よくわかるフリストンの自由エネルギー原理
よくわかるフリストンの自由エネルギー原理Masatoshi Yoshida
 

La actualidad más candente (20)

圏論のモナドとHaskellのモナド
圏論のモナドとHaskellのモナド圏論のモナドとHaskellのモナド
圏論のモナドとHaskellのモナド
 
自動定理証明の紹介
自動定理証明の紹介自動定理証明の紹介
自動定理証明の紹介
 
数学で解き明かす深層学習の原理
数学で解き明かす深層学習の原理数学で解き明かす深層学習の原理
数学で解き明かす深層学習の原理
 
Coqチュートリアル
CoqチュートリアルCoqチュートリアル
Coqチュートリアル
 
Cody Roux - Pure Type Systems - Boston Haskell Meetup
Cody Roux - Pure Type Systems - Boston Haskell MeetupCody Roux - Pure Type Systems - Boston Haskell Meetup
Cody Roux - Pure Type Systems - Boston Haskell Meetup
 
pixivのおすすめを改善する話
pixivのおすすめを改善する話pixivのおすすめを改善する話
pixivのおすすめを改善する話
 
ベイズ統計によるデータ解析
ベイズ統計によるデータ解析ベイズ統計によるデータ解析
ベイズ統計によるデータ解析
 
LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編
LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編
LiHのポテンシャルエネルギー曲面 を量子コンピュータで行う Q#+位相推定編
 
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
 
【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~
【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~ 【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~
【数学パズル】 無限の囚人と帽子パズル ~選択公理を使ったトリック~
 
社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森
 
Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp
Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp
Jupyter(Python)とBigQueryによるデータ分析基盤のDevOps #pyconjp
 
ユーザーサイド情報検索システム
ユーザーサイド情報検索システムユーザーサイド情報検索システム
ユーザーサイド情報検索システム
 
Apache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォームApache Arrow - データ処理ツールの次世代プラットフォーム
Apache Arrow - データ処理ツールの次世代プラットフォーム
 
Scala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみたScala 初心者が米田の補題を Scala で考えてみた
Scala 初心者が米田の補題を Scala で考えてみた
 
感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...
感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...
感覚運動随伴性、予測符号化、そして自由エネルギー原理 (Sensory-Motor Contingency, Predictive Coding and ...
 
概念モデリング再考
概念モデリング再考概念モデリング再考
概念モデリング再考
 
深層学習による自然言語処理の研究動向
深層学習による自然言語処理の研究動向深層学習による自然言語処理の研究動向
深層学習による自然言語処理の研究動向
 
よくわかるCoqプログラミング
よくわかるCoqプログラミングよくわかるCoqプログラミング
よくわかるCoqプログラミング
 
よくわかるフリストンの自由エネルギー原理
よくわかるフリストンの自由エネルギー原理よくわかるフリストンの自由エネルギー原理
よくわかるフリストンの自由エネルギー原理
 

Destacado

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
 

Destacado (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
 

Similar 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
 
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
 

Similar 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
 

Más 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
 

Más 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

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 

Último (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 

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