SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Techtalk:多様体
Techtalk:多様体Techtalk:多様体
Techtalk:多様体Kenta Oono
 
車両運行管理システムのためのデータ整備と機械学習の活用
車両運行管理システムのためのデータ整備と機械学習の活用車両運行管理システムのためのデータ整備と機械学習の活用
車両運行管理システムのためのデータ整備と機械学習の活用Eiji Sekiya
 
Intoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryIntoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryJack Fox
 
Direct feedback alignment provides learning in Deep Neural Networks
Direct feedback alignment provides learning in Deep Neural NetworksDirect feedback alignment provides learning in Deep Neural Networks
Direct feedback alignment provides learning in Deep Neural NetworksDeep Learning JP
 
C++による数値解析の並列化手法
C++による数値解析の並列化手法C++による数値解析の並列化手法
C++による数値解析の並列化手法dc1394
 
[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions
[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions
[DL輪読会]Deep Learning for Sampling from Arbitrary Probability DistributionsDeep Learning JP
 
SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜
SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜
SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜SSII
 
情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張nishioka1
 
確率ロボティクス第六回
確率ロボティクス第六回確率ロボティクス第六回
確率ロボティクス第六回Ryuichi Ueda
 
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)STAIR Lab, Chiba Institute of Technology
 
ユーザーサイド情報検索システム
ユーザーサイド情報検索システムユーザーサイド情報検索システム
ユーザーサイド情報検索システムjoisino
 
Wasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 IWasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 ISungbin Lim
 
数学はアートを創るか?―Processingによる実践
数学はアートを創るか?―Processingによる実践数学はアートを創るか?―Processingによる実践
数学はアートを創るか?―Processingによる実践TatsukiHayama
 
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料Ken'ichi Matsui
 
Optuna: A Define-by-Run Hyperparameter Optimization Framework
Optuna: A Define-by-Run Hyperparameter Optimization FrameworkOptuna: A Define-by-Run Hyperparameter Optimization Framework
Optuna: A Define-by-Run Hyperparameter Optimization FrameworkPreferred Networks
 
画像処理AIを用いた異常検知
画像処理AIを用いた異常検知画像処理AIを用いた異常検知
画像処理AIを用いた異常検知Hideo Terada
 
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法MITSUNARI Shigeo
 
論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”
論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”
論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”Adachi (OEI)
 

Was ist angesagt? (20)

Techtalk:多様体
Techtalk:多様体Techtalk:多様体
Techtalk:多様体
 
車両運行管理システムのためのデータ整備と機械学習の活用
車両運行管理システムのためのデータ整備と機械学習の活用車両運行管理システムのためのデータ整備と機械学習の活用
車両運行管理システムのためのデータ整備と機械学習の活用
 
一般化線形モデル (GLM) & 一般化加法モデル(GAM)
一般化線形モデル (GLM) & 一般化加法モデル(GAM) 一般化線形モデル (GLM) & 一般化加法モデル(GAM)
一般化線形モデル (GLM) & 一般化加法モデル(GAM)
 
Intoduction to Homotopy Type Therory
Intoduction to Homotopy Type TheroryIntoduction to Homotopy Type Therory
Intoduction to Homotopy Type Therory
 
Direct feedback alignment provides learning in Deep Neural Networks
Direct feedback alignment provides learning in Deep Neural NetworksDirect feedback alignment provides learning in Deep Neural Networks
Direct feedback alignment provides learning in Deep Neural Networks
 
C++による数値解析の並列化手法
C++による数値解析の並列化手法C++による数値解析の並列化手法
C++による数値解析の並列化手法
 
[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions
[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions
[DL輪読会]Deep Learning for Sampling from Arbitrary Probability Distributions
 
SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜
SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜
SSII2020SS: グラフデータでも深層学習 〜 Graph Neural Networks 入門 〜
 
情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張情報検索の基礎 #9適合フィードバックとクエリ拡張
情報検索の基礎 #9適合フィードバックとクエリ拡張
 
確率ロボティクス第六回
確率ロボティクス第六回確率ロボティクス第六回
確率ロボティクス第六回
 
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
 
ユーザーサイド情報検索システム
ユーザーサイド情報検索システムユーザーサイド情報検索システム
ユーザーサイド情報検索システム
 
Wasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 IWasserstein GAN 수학 이해하기 I
Wasserstein GAN 수학 이해하기 I
 
数学はアートを創るか?―Processingによる実践
数学はアートを創るか?―Processingによる実践数学はアートを創るか?―Processingによる実践
数学はアートを創るか?―Processingによる実践
 
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
 
Optuna: A Define-by-Run Hyperparameter Optimization Framework
Optuna: A Define-by-Run Hyperparameter Optimization FrameworkOptuna: A Define-by-Run Hyperparameter Optimization Framework
Optuna: A Define-by-Run Hyperparameter Optimization Framework
 
画像処理AIを用いた異常検知
画像処理AIを用いた異常検知画像処理AIを用いた異常検知
画像処理AIを用いた異常検知
 
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
深層学習フレームワークにおけるIntel CPU/富岳向け最適化法
 
PRML Chapter 14
PRML Chapter 14PRML Chapter 14
PRML Chapter 14
 
論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”
論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”
論文読んだよ “State Lattice-based Motion Planning for Autonomous On-Road Driving”
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie Type Theory and Practical Application

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
 

Ähnlich wie Type Theory and Practical Application (20)

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
 
Semantic Networks
Semantic NetworksSemantic Networks
Semantic Networks
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
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
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 

Kürzlich hochgeladen (20)

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
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...
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 

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