SlideShare a Scribd company logo
Seven trees in one
Mark Hopkins
@antiselfdual
Commonwealth Bank
LambdaJam 2015
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Unlabelled binary trees
data Tree = Leaf | Node Tree Tree
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Unlabelled binary trees
data Tree = Leaf | Node Tree Tree
T = 1 + T2
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T = 1 + T2
Suspend disbelief, and solve for T.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T = 1 + T2
Suspend disbelief, and solve for T.
T2
− T + 1 = 0
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T = 1 + T2
Suspend disbelief, and solve for T.
T2
− T + 1 = 0
T =
−b ±
√
b2 − 4ac
2a
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T = 1 + T2
Suspend disbelief, and solve for T.
T2
− T + 1 = 0
T =
−b ±
√
b2 − 4ac
2a
= 1
2 ±
√
3
2 i
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T = 1 + T2
Suspend disbelief, and solve for T.
T2
− T + 1 = 0
T =
−b ±
√
b2 − 4ac
2a
= 1
2 ±
√
3
2 i
= e±πi/3
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Re
Im
1
−1
i
−i
T
−T
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
So T6 = 1.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
So T6 = 1. No, obviously wrong.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
So T6 = 1. No, obviously wrong.
What about
T7
= T?
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
So T6 = 1. No, obviously wrong.
What about
T7
= T?
Not obviously wrong. . .
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
So T6 = 1. No, obviously wrong.
What about
T7
= T?
Not obviously wrong. . .
⇒ true!
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Theorem
There exists an O(1) bijective function from T to T7.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Theorem
There exists an O(1) bijective function from T to T7.
i.e.
we can pattern match on any 7-tuple of trees and put them
together into one tree.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Theorem
There exists an O(1) bijective function from T to T7.
i.e.
we can pattern match on any 7-tuple of trees and put them
together into one tree.
we can decompose any tree into the same seven trees it came
from.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Theorem
There exists an O(1) bijective function from T to T7.
i.e.
we can pattern match on any 7-tuple of trees and put them
together into one tree.
we can decompose any tree into the same seven trees it came
from.
Actually holds for any k = 1 mod 6.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Theorem
There exists an O(1) bijective function from T to T7.
i.e.
we can pattern match on any 7-tuple of trees and put them
together into one tree.
we can decompose any tree into the same seven trees it came
from.
Actually holds for any k = 1 mod 6.
Not true for other values.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T2
→ T
f :: (Tree , Tree) → Tree
t t1 t2 = Node t1 t2
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T2
→ T
f :: (Tree , Tree) → Tree
t t1 t2 = Node t1 t2
Not surjective, since we can never reach Leaf.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T → T2
f :: Tree → (Tree , Tree)
f t = Node t Leaf
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T → T2
f :: Tree → (Tree , Tree)
f t = Node t Leaf
Not surjective either.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T2
→ T, but cleverer
f :: (Tree , Tree) → Tree
f (t1, t2) = go (Node t1 t2)
where
go t = if leftOnly t then left t else t
leftOnly t = t == Leaf
|| right t == Leaf && leftOnly (left t)
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T2
→ T, but cleverer
f :: (Tree , Tree) → Tree
f (t1, t2) = go (Node t1 t2)
where
go t = if leftOnly t then left t else t
leftOnly t = t == Leaf
|| right t == Leaf && leftOnly (left t)
Bijective!
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
T2
→ T, but cleverer
f :: (Tree , Tree) → Tree
f (t1, t2) = go (Node t1 t2)
where
go t = if leftOnly t then left t else t
leftOnly t = t == Leaf
|| right t == Leaf && leftOnly (left t)
Bijective! but not O(1).
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
A solution
f :: T → (T, T, T, T, T, T, T)
f L = (L,L,L,L,L,L,L)
f (N t1 L) = (t1,N L L,L,L,L,L,L)
f (N t1 (N t2 L)) = (N t1 t2,L,L,L,L,L,L)
f (N t1 (N t2 (N t3 L))) = (t1,N (N t2 t3) L,L,L,L,L,L)
f (N t1 (N t2 (N t3 (N t4 L)))) = (t1,N t2 (N t3 t4),L,L,L,L,L)
f (N t1 (N t2 (N t3 (N t4 (N L L))))) = (t1,t2,N t3 t4,L,L,L,L)
f (N t1 (N t2 (N t3 (N t4 (N (N t5 L) L))))) = (t1,t2,t3,N t4 t5,L,L,L)
f (N t1 (N t2 (N t3 (N t4 (N (N t5 (N t6 L)) L))))) = (t1,t2,t3,t4,N t5 t6,L,L)
f (N t1 (N t2 (N t3 (N t4 (N (N t5 (N t6 (N t7 t8))) L))))) = (t1,t2,t3,t4,t5,t6,N t7 t8)
f (N t1 (N t2 (N t3 (N t4 (N t5 (N t6 t7 )))))) = (t1,t2,t3,t4,t5,N t6 t7,L)
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Where did this come from
T = 1 + T2
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Where did this come from
T = 1 + T2
Tk
= Tk−1
+ Tk+1
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Penny game
T0 T1 T2 T3 T4 T5 T6 T7 T8
start with a penny in position 1.
aim is to move it to position 7 by splitting and combining
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Why did this work?
If we have a type isomorphism T ∼= p(T) then
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Why did this work?
If we have a type isomorphism T ∼= p(T) then
q1(T) ∼= q2(T) as types
⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x)
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Why did this work?
If we have a type isomorphism T ∼= p(T) then
q1(T) ∼= q2(T) as types
⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x)
⇒ q1(x) ∼= q2(x) in the ring Z[x]/(p(x) = x)
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Why did this work?
If we have a type isomorphism T ∼= p(T) then
q1(T) ∼= q2(T) as types
⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x)
⇒ q1(x) ∼= q2(x) in the ring Z[x]/(p(x) = x)
⇒ q1(z) ∼= q2(z) for all z ∈ C such that p(z) = z.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Why did this work?
If we have a type isomorphism T ∼= p(T) then
q1(T) ∼= q2(T) as types
⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x)
⇒ q1(x) ∼= q2(x) in the ring Z[x]/(p(x) = x)
⇒ q1(z) ∼= q2(z) for all z ∈ C such that p(z) = z.
And, under some conditions, the reverse implications hold.
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Summary
Simple arithmetic helps us find non-obvious type isomorphisms
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Extensions
Are there extensions to datatypes of decorated trees?
(multivariate polynomials)
What applications are there?
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Extensions
Are there extensions to datatypes of decorated trees?
(multivariate polynomials)
What applications are there?
important when writing a compiler to know when two types
are isomomorphic
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Extensions
Are there extensions to datatypes of decorated trees?
(multivariate polynomials)
What applications are there?
important when writing a compiler to know when two types
are isomomorphic
It could interesting to split up a tree-shaped stream into seven
parts
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Rich theory behind isomorphisms of polynomial types
brings together a number of fields
distributive categories
theory of rigs (semirings)
combinatorial species
type theory
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Further reading
Seven Trees in one, Andreas Blass, Journal of Pure and
Applied Algebra
On the generic solution to P(X) = X in distributive
categories, Robbie Gates
Objects of Categories as Complex Numbers, Marcelo Fiore and
Tom Leinster
An Objective Representation of the Gaussian Integers, Marcelo
Fiore and Tom Leinster
http://rfcwalters.blogspot.com.au/2010/06/robbie-gates-on-
seven-trees-in-one.html
http://blog.sigfpe.com/2007/09/arboreal-isomorphisms-from-
nuclear.html
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Challenge
Consider this datatype (Motzkin trees):
data Tree = Zero | One Tree | Two Tree Tree
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Challenge
Consider this datatype (Motzkin trees):
data Tree = Zero | One Tree | Two Tree Tree
T = 1 + T + T2
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Challenge
Consider this datatype (Motzkin trees):
data Tree = Zero | One Tree | Two Tree Tree
T = 1 + T + T2
Show that T5 ∼= T
by a nonsense argument using complex numbers
by composing bijections (the penny game)
implement the function and its inverse in a language of your
choice
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
Photo credits
The Druid’s Grove, Norbury Park: Ancient Yew Trees by
Thomas Allom 1804-1872
http://www.victorianweb.org/art/illustration/allom/1.html
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
End
Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one

More Related Content

What's hot

Group Theory
Group TheoryGroup Theory
Group Theory
shinojmadhu
 
MarkDrachMeinelThesisFinal
MarkDrachMeinelThesisFinalMarkDrachMeinelThesisFinal
MarkDrachMeinelThesisFinal
Mark Drach-Meinel
 
Set theory
Set theorySet theory
Set theory
AN_Rajin
 
Set theory-complete-1211828121770367-8
Set theory-complete-1211828121770367-8Set theory-complete-1211828121770367-8
Set theory-complete-1211828121770367-8
Yusra Shaikh
 
Discrete Structures lecture 2
 Discrete Structures lecture 2 Discrete Structures lecture 2
Discrete Structures lecture 2
Ali Usman
 
Discrete Structures. Lecture 1
 Discrete Structures. Lecture 1  Discrete Structures. Lecture 1
Discrete Structures. Lecture 1
Ali Usman
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
Masud Parvaze
 
Discreet_Set Theory
Discreet_Set TheoryDiscreet_Set Theory
Discreet_Set Theory
guest68d714
 
BCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and functionBCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and function
Rai University
 
Set Theory
Set TheorySet Theory
Set Theory Presentation
Set Theory PresentationSet Theory Presentation
Set Theory Presentation
Mohammad Saffat-E-Nayeem
 
Class XI CH 1 (sets)
Class XI CH 1 (sets)Class XI CH 1 (sets)
Class XI CH 1 (sets)
Pradeep Sharma
 
CBSE Class X - Mathematics Set Theory Topic
CBSE Class X  - Mathematics Set Theory TopicCBSE Class X  - Mathematics Set Theory Topic
CBSE Class X - Mathematics Set Theory Topic
Edvie
 
A STUDY ON L-FUZZY NORMAL SUBl -GROUP
A STUDY ON L-FUZZY NORMAL SUBl -GROUPA STUDY ON L-FUZZY NORMAL SUBl -GROUP
A STUDY ON L-FUZZY NORMAL SUBl -GROUP
ijejournal
 
Unit I discrete mathematics lecture notes
Unit I  discrete mathematics lecture notesUnit I  discrete mathematics lecture notes
Unit I discrete mathematics lecture notes
GIRIM8
 

What's hot (15)

Group Theory
Group TheoryGroup Theory
Group Theory
 
MarkDrachMeinelThesisFinal
MarkDrachMeinelThesisFinalMarkDrachMeinelThesisFinal
MarkDrachMeinelThesisFinal
 
Set theory
Set theorySet theory
Set theory
 
Set theory-complete-1211828121770367-8
Set theory-complete-1211828121770367-8Set theory-complete-1211828121770367-8
Set theory-complete-1211828121770367-8
 
Discrete Structures lecture 2
 Discrete Structures lecture 2 Discrete Structures lecture 2
Discrete Structures lecture 2
 
Discrete Structures. Lecture 1
 Discrete Structures. Lecture 1  Discrete Structures. Lecture 1
Discrete Structures. Lecture 1
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
 
Discreet_Set Theory
Discreet_Set TheoryDiscreet_Set Theory
Discreet_Set Theory
 
BCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and functionBCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and function
 
Set Theory
Set TheorySet Theory
Set Theory
 
Set Theory Presentation
Set Theory PresentationSet Theory Presentation
Set Theory Presentation
 
Class XI CH 1 (sets)
Class XI CH 1 (sets)Class XI CH 1 (sets)
Class XI CH 1 (sets)
 
CBSE Class X - Mathematics Set Theory Topic
CBSE Class X  - Mathematics Set Theory TopicCBSE Class X  - Mathematics Set Theory Topic
CBSE Class X - Mathematics Set Theory Topic
 
A STUDY ON L-FUZZY NORMAL SUBl -GROUP
A STUDY ON L-FUZZY NORMAL SUBl -GROUPA STUDY ON L-FUZZY NORMAL SUBl -GROUP
A STUDY ON L-FUZZY NORMAL SUBl -GROUP
 
Unit I discrete mathematics lecture notes
Unit I  discrete mathematics lecture notesUnit I  discrete mathematics lecture notes
Unit I discrete mathematics lecture notes
 

Viewers also liked

Pokemon go の技術的注目点
Pokemon go の技術的注目点Pokemon go の技術的注目点
Pokemon go の技術的注目点
Fukuoka Institute of Technology
 
はじめようlocalization
はじめようlocalizationはじめようlocalization
はじめようlocalization
João Orui
 
Shake up the Culture with Automation!
Shake up the Culture with Automation!Shake up the Culture with Automation!
Shake up the Culture with Automation!
Hiroyuki Ito
 
Final san diego venture group keynote 2016
Final san diego venture group keynote   2016Final san diego venture group keynote   2016
Final san diego venture group keynote 2016
Mark Suster
 
Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか?? ~科学・技術を探求することの意味~
Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか??~科学・技術を探求することの意味~Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか??~科学・技術を探求することの意味~
Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか?? ~科学・技術を探求することの意味~
Fukuoka Institute of Technology
 
Power bi for office365 技術ひろばnet
Power bi for office365  技術ひろばnetPower bi for office365  技術ひろばnet
Power bi for office365 技術ひろばnet
mokudai masayuki
 
EL MEDIO AMBIENTE
EL MEDIO AMBIENTEEL MEDIO AMBIENTE
EL MEDIO AMBIENTE
YeSe Villadiego Casarrubia
 
A Powerful Partnership: GIS and Sampling
A Powerful Partnership: GIS and SamplingA Powerful Partnership: GIS and Sampling
A Powerful Partnership: GIS and Sampling
MEASURE Evaluation
 
Tic ii idea_de_negocio_abi
Tic ii idea_de_negocio_abiTic ii idea_de_negocio_abi
Tic ii idea_de_negocio_abi
Abi_Sar_Vi
 
Calzado "Solsol"
Calzado "Solsol"Calzado "Solsol"
Calzado "Solsol"
47860287
 
Terapeutica tb
Terapeutica tbTerapeutica tb
Terapeutica tb
Kuru Mi
 
gestion de la carga de trabajo de la evaluación continua para el profesor
gestion de la carga de trabajo de la evaluación continua para el profesorgestion de la carga de trabajo de la evaluación continua para el profesor
gestion de la carga de trabajo de la evaluación continua para el profesor
Alfredo Prieto Martín
 
Idea de negocio empresarial
Idea de negocio empresarialIdea de negocio empresarial
Idea de negocio empresarial
juan199006
 
Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...
Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...
Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...
María Linares
 
Proyecto de historia clínica electrónica en cundinamarca
Proyecto de historia clínica electrónica en cundinamarcaProyecto de historia clínica electrónica en cundinamarca
Proyecto de historia clínica electrónica en cundinamarca
Alex Rodriguez
 
Digital II Final Project
Digital II Final ProjectDigital II Final Project
Digital II Final Project
stephenjbilharz
 
Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...
Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...
Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...
Gideon Bernto
 
Idea de negocio querubin sac
Idea de negocio   querubin sacIdea de negocio   querubin sac
Idea de negocio querubin sac
HELEN1110
 
乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-
乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-
乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-
Takuya Akiba
 
Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...
Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...
Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...
Rakuten Group, Inc.
 

Viewers also liked (20)

Pokemon go の技術的注目点
Pokemon go の技術的注目点Pokemon go の技術的注目点
Pokemon go の技術的注目点
 
はじめようlocalization
はじめようlocalizationはじめようlocalization
はじめようlocalization
 
Shake up the Culture with Automation!
Shake up the Culture with Automation!Shake up the Culture with Automation!
Shake up the Culture with Automation!
 
Final san diego venture group keynote 2016
Final san diego venture group keynote   2016Final san diego venture group keynote   2016
Final san diego venture group keynote 2016
 
Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか?? ~科学・技術を探求することの意味~
Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか??~科学・技術を探求することの意味~Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか??~科学・技術を探求することの意味~
Tsushima2015 talk event - ロボット・情報技術は生活の役に立つのか?? ~科学・技術を探求することの意味~
 
Power bi for office365 技術ひろばnet
Power bi for office365  技術ひろばnetPower bi for office365  技術ひろばnet
Power bi for office365 技術ひろばnet
 
EL MEDIO AMBIENTE
EL MEDIO AMBIENTEEL MEDIO AMBIENTE
EL MEDIO AMBIENTE
 
A Powerful Partnership: GIS and Sampling
A Powerful Partnership: GIS and SamplingA Powerful Partnership: GIS and Sampling
A Powerful Partnership: GIS and Sampling
 
Tic ii idea_de_negocio_abi
Tic ii idea_de_negocio_abiTic ii idea_de_negocio_abi
Tic ii idea_de_negocio_abi
 
Calzado "Solsol"
Calzado "Solsol"Calzado "Solsol"
Calzado "Solsol"
 
Terapeutica tb
Terapeutica tbTerapeutica tb
Terapeutica tb
 
gestion de la carga de trabajo de la evaluación continua para el profesor
gestion de la carga de trabajo de la evaluación continua para el profesorgestion de la carga de trabajo de la evaluación continua para el profesor
gestion de la carga de trabajo de la evaluación continua para el profesor
 
Idea de negocio empresarial
Idea de negocio empresarialIdea de negocio empresarial
Idea de negocio empresarial
 
Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...
Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...
Nº 33 año 2008, gaceta municipal extraordinaria (ordenanzas contraloría socia...
 
Proyecto de historia clínica electrónica en cundinamarca
Proyecto de historia clínica electrónica en cundinamarcaProyecto de historia clínica electrónica en cundinamarca
Proyecto de historia clínica electrónica en cundinamarca
 
Digital II Final Project
Digital II Final ProjectDigital II Final Project
Digital II Final Project
 
Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...
Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...
Engaging staff in Health and Safety, do rules work? - Golden rules thoughts 2...
 
Idea de negocio querubin sac
Idea de negocio   querubin sacIdea de negocio   querubin sac
Idea de negocio querubin sac
 
乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-
乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-
乱択データ構造の最新事情 -MinHash と HyperLogLog の最近の進歩-
 
Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...
Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...
Conquer CI Server! - Re-establishment of Order and Nurture of the Solid Organ...
 

Similar to Seven trees in one

Understanding variable importances in forests of randomized trees
Understanding variable importances in forests of randomized treesUnderstanding variable importances in forests of randomized trees
Understanding variable importances in forests of randomized trees
Gilles Louppe
 
Pattern_avoidance_in_ternary_trees
Pattern_avoidance_in_ternary_treesPattern_avoidance_in_ternary_trees
Pattern_avoidance_in_ternary_trees
Nathan Gabriel
 
09 binary trees
09 binary trees09 binary trees
09 binary trees
Andres Mendez-Vazquez
 
Fol
FolFol
01_AJMS_277_20_20210128_V1.pdf
01_AJMS_277_20_20210128_V1.pdf01_AJMS_277_20_20210128_V1.pdf
01_AJMS_277_20_20210128_V1.pdf
BRNSS Publication Hub
 
16 rbtrees
16 rbtrees16 rbtrees
16 rbtrees
Dheeraj Singh
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sorting
zukun
 
Dependent Types and Dynamics of Natural Language
Dependent Types and Dynamics of Natural LanguageDependent Types and Dynamics of Natural Language
Dependent Types and Dynamics of Natural Language
Daisuke BEKKI
 
Skiena algorithm 2007 lecture05 dictionary data structure trees
Skiena algorithm 2007 lecture05 dictionary data structure treesSkiena algorithm 2007 lecture05 dictionary data structure trees
Skiena algorithm 2007 lecture05 dictionary data structure trees
zukun
 
8 chapter4 trees_bst
8 chapter4 trees_bst8 chapter4 trees_bst
8 chapter4 trees_bst
SSE_AndyLi
 
Review session2
Review session2Review session2
Review session2
NEEDY12345
 
On Generalized Classical Fréchet Derivatives in the Real Banach Space
On Generalized Classical Fréchet Derivatives in the Real Banach SpaceOn Generalized Classical Fréchet Derivatives in the Real Banach Space
On Generalized Classical Fréchet Derivatives in the Real Banach Space
BRNSS Publication Hub
 
lecture4.ppt
lecture4.pptlecture4.ppt
lecture4.ppt
ssuser1a62e1
 
smtlecture.7
smtlecture.7smtlecture.7
smtlecture.7
Roberto Bruttomesso
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Vikas Sharma
 
Trees ayaz
Trees ayazTrees ayaz
Trees ayaz
Ayaz Shariff
 
FUZZY LOGIC
FUZZY LOGICFUZZY LOGIC
FUZZY LOGIC
Sri vidhya k
 
Trees
TreesTrees
Lecture 4 f17
Lecture 4 f17Lecture 4 f17
Lecture 4 f17
Eric Cochran
 
Jurnal informatika
Jurnal informatika Jurnal informatika
Jurnal informatika
MamaMa28
 

Similar to Seven trees in one (20)

Understanding variable importances in forests of randomized trees
Understanding variable importances in forests of randomized treesUnderstanding variable importances in forests of randomized trees
Understanding variable importances in forests of randomized trees
 
Pattern_avoidance_in_ternary_trees
Pattern_avoidance_in_ternary_treesPattern_avoidance_in_ternary_trees
Pattern_avoidance_in_ternary_trees
 
09 binary trees
09 binary trees09 binary trees
09 binary trees
 
Fol
FolFol
Fol
 
01_AJMS_277_20_20210128_V1.pdf
01_AJMS_277_20_20210128_V1.pdf01_AJMS_277_20_20210128_V1.pdf
01_AJMS_277_20_20210128_V1.pdf
 
16 rbtrees
16 rbtrees16 rbtrees
16 rbtrees
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sorting
 
Dependent Types and Dynamics of Natural Language
Dependent Types and Dynamics of Natural LanguageDependent Types and Dynamics of Natural Language
Dependent Types and Dynamics of Natural Language
 
Skiena algorithm 2007 lecture05 dictionary data structure trees
Skiena algorithm 2007 lecture05 dictionary data structure treesSkiena algorithm 2007 lecture05 dictionary data structure trees
Skiena algorithm 2007 lecture05 dictionary data structure trees
 
8 chapter4 trees_bst
8 chapter4 trees_bst8 chapter4 trees_bst
8 chapter4 trees_bst
 
Review session2
Review session2Review session2
Review session2
 
On Generalized Classical Fréchet Derivatives in the Real Banach Space
On Generalized Classical Fréchet Derivatives in the Real Banach SpaceOn Generalized Classical Fréchet Derivatives in the Real Banach Space
On Generalized Classical Fréchet Derivatives in the Real Banach Space
 
lecture4.ppt
lecture4.pptlecture4.ppt
lecture4.ppt
 
smtlecture.7
smtlecture.7smtlecture.7
smtlecture.7
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Trees ayaz
Trees ayazTrees ayaz
Trees ayaz
 
FUZZY LOGIC
FUZZY LOGICFUZZY LOGIC
FUZZY LOGIC
 
Trees
TreesTrees
Trees
 
Lecture 4 f17
Lecture 4 f17Lecture 4 f17
Lecture 4 f17
 
Jurnal informatika
Jurnal informatika Jurnal informatika
Jurnal informatika
 

Recently uploaded

Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...
Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...
Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...
Sérgio Sacani
 
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptxTOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
shubhijain836
 
Gadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdfGadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdf
PirithiRaju
 
2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf
lucianamillenium
 
Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8
abhinayakamasamudram
 
LEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptxLEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptx
yourprojectpartner05
 
Compositions of iron-meteorite parent bodies constrainthe structure of the pr...
Compositions of iron-meteorite parent bodies constrainthe structure of the pr...Compositions of iron-meteorite parent bodies constrainthe structure of the pr...
Compositions of iron-meteorite parent bodies constrainthe structure of the pr...
Sérgio Sacani
 
Farming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptxFarming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptx
Frédéric Baudron
 
Mites,Slug,Snail_Infesting agricultural crops.pdf
Mites,Slug,Snail_Infesting agricultural crops.pdfMites,Slug,Snail_Infesting agricultural crops.pdf
Mites,Slug,Snail_Infesting agricultural crops.pdf
PirithiRaju
 
Explainable Deepfake Image/Video Detection
Explainable Deepfake Image/Video DetectionExplainable Deepfake Image/Video Detection
Explainable Deepfake Image/Video Detection
VasileiosMezaris
 
Signatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coastsSignatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coasts
Sérgio Sacani
 
JAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDS
JAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDSJAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDS
JAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDS
Sérgio Sacani
 
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Creative-Biolabs
 
GBSN - Microbiology (Unit 2) Antimicrobial agents
GBSN - Microbiology (Unit 2) Antimicrobial agentsGBSN - Microbiology (Unit 2) Antimicrobial agents
GBSN - Microbiology (Unit 2) Antimicrobial agents
Areesha Ahmad
 
seed production, Nursery & Gardening.pdf
seed production, Nursery & Gardening.pdfseed production, Nursery & Gardening.pdf
seed production, Nursery & Gardening.pdf
Nistarini College, Purulia (W.B) India
 
Physiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptxPhysiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptx
fatima132662
 
Quality assurance B.pharm 6th semester BP606T UNIT 5
Quality assurance B.pharm 6th semester BP606T UNIT 5Quality assurance B.pharm 6th semester BP606T UNIT 5
Quality assurance B.pharm 6th semester BP606T UNIT 5
vimalveerammal
 
the fundamental unit of life CBSE class 9.pptx
the fundamental unit of life CBSE class 9.pptxthe fundamental unit of life CBSE class 9.pptx
the fundamental unit of life CBSE class 9.pptx
parminder0808singh
 
Module_1.In autotrophic nutrition ORGANISM
Module_1.In autotrophic nutrition ORGANISMModule_1.In autotrophic nutrition ORGANISM
Module_1.In autotrophic nutrition ORGANISM
rajeshwexl
 
Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7
Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7
Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7
yashika sharman06
 

Recently uploaded (20)

Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...
Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...
Evidence of Jet Activity from the Secondary Black Hole in the OJ 287 Binary S...
 
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptxTOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
 
Gadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdfGadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdf
 
2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf
 
Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8
 
LEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptxLEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptx
 
Compositions of iron-meteorite parent bodies constrainthe structure of the pr...
Compositions of iron-meteorite parent bodies constrainthe structure of the pr...Compositions of iron-meteorite parent bodies constrainthe structure of the pr...
Compositions of iron-meteorite parent bodies constrainthe structure of the pr...
 
Farming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptxFarming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptx
 
Mites,Slug,Snail_Infesting agricultural crops.pdf
Mites,Slug,Snail_Infesting agricultural crops.pdfMites,Slug,Snail_Infesting agricultural crops.pdf
Mites,Slug,Snail_Infesting agricultural crops.pdf
 
Explainable Deepfake Image/Video Detection
Explainable Deepfake Image/Video DetectionExplainable Deepfake Image/Video Detection
Explainable Deepfake Image/Video Detection
 
Signatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coastsSignatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coasts
 
JAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDS
JAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDSJAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDS
JAMES WEBB STUDY THE MASSIVE BLACK HOLE SEEDS
 
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
 
GBSN - Microbiology (Unit 2) Antimicrobial agents
GBSN - Microbiology (Unit 2) Antimicrobial agentsGBSN - Microbiology (Unit 2) Antimicrobial agents
GBSN - Microbiology (Unit 2) Antimicrobial agents
 
seed production, Nursery & Gardening.pdf
seed production, Nursery & Gardening.pdfseed production, Nursery & Gardening.pdf
seed production, Nursery & Gardening.pdf
 
Physiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptxPhysiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptx
 
Quality assurance B.pharm 6th semester BP606T UNIT 5
Quality assurance B.pharm 6th semester BP606T UNIT 5Quality assurance B.pharm 6th semester BP606T UNIT 5
Quality assurance B.pharm 6th semester BP606T UNIT 5
 
the fundamental unit of life CBSE class 9.pptx
the fundamental unit of life CBSE class 9.pptxthe fundamental unit of life CBSE class 9.pptx
the fundamental unit of life CBSE class 9.pptx
 
Module_1.In autotrophic nutrition ORGANISM
Module_1.In autotrophic nutrition ORGANISMModule_1.In autotrophic nutrition ORGANISM
Module_1.In autotrophic nutrition ORGANISM
 
Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7
Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7
Call Girls Noida🔥9873777170🔥Gorgeous Escorts in Noida Available 24/7
 

Seven trees in one

  • 1. Seven trees in one Mark Hopkins @antiselfdual Commonwealth Bank LambdaJam 2015 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 2. Unlabelled binary trees data Tree = Leaf | Node Tree Tree Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 3. Unlabelled binary trees data Tree = Leaf | Node Tree Tree T = 1 + T2 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 4. T = 1 + T2 Suspend disbelief, and solve for T. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 5. T = 1 + T2 Suspend disbelief, and solve for T. T2 − T + 1 = 0 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 6. T = 1 + T2 Suspend disbelief, and solve for T. T2 − T + 1 = 0 T = −b ± √ b2 − 4ac 2a Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 7. T = 1 + T2 Suspend disbelief, and solve for T. T2 − T + 1 = 0 T = −b ± √ b2 − 4ac 2a = 1 2 ± √ 3 2 i Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 8. T = 1 + T2 Suspend disbelief, and solve for T. T2 − T + 1 = 0 T = −b ± √ b2 − 4ac 2a = 1 2 ± √ 3 2 i = e±πi/3 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 9. Re Im 1 −1 i −i T −T Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 10. So T6 = 1. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 11. So T6 = 1. No, obviously wrong. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 12. So T6 = 1. No, obviously wrong. What about T7 = T? Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 13. So T6 = 1. No, obviously wrong. What about T7 = T? Not obviously wrong. . . Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 14. So T6 = 1. No, obviously wrong. What about T7 = T? Not obviously wrong. . . ⇒ true! Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 15. Theorem There exists an O(1) bijective function from T to T7. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 16. Theorem There exists an O(1) bijective function from T to T7. i.e. we can pattern match on any 7-tuple of trees and put them together into one tree. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 17. Theorem There exists an O(1) bijective function from T to T7. i.e. we can pattern match on any 7-tuple of trees and put them together into one tree. we can decompose any tree into the same seven trees it came from. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 18. Theorem There exists an O(1) bijective function from T to T7. i.e. we can pattern match on any 7-tuple of trees and put them together into one tree. we can decompose any tree into the same seven trees it came from. Actually holds for any k = 1 mod 6. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 19. Theorem There exists an O(1) bijective function from T to T7. i.e. we can pattern match on any 7-tuple of trees and put them together into one tree. we can decompose any tree into the same seven trees it came from. Actually holds for any k = 1 mod 6. Not true for other values. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 20. T2 → T f :: (Tree , Tree) → Tree t t1 t2 = Node t1 t2 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 21. T2 → T f :: (Tree , Tree) → Tree t t1 t2 = Node t1 t2 Not surjective, since we can never reach Leaf. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 22. T → T2 f :: Tree → (Tree , Tree) f t = Node t Leaf Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 23. T → T2 f :: Tree → (Tree , Tree) f t = Node t Leaf Not surjective either. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 24. T2 → T, but cleverer f :: (Tree , Tree) → Tree f (t1, t2) = go (Node t1 t2) where go t = if leftOnly t then left t else t leftOnly t = t == Leaf || right t == Leaf && leftOnly (left t) Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 25. T2 → T, but cleverer f :: (Tree , Tree) → Tree f (t1, t2) = go (Node t1 t2) where go t = if leftOnly t then left t else t leftOnly t = t == Leaf || right t == Leaf && leftOnly (left t) Bijective! Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 26. T2 → T, but cleverer f :: (Tree , Tree) → Tree f (t1, t2) = go (Node t1 t2) where go t = if leftOnly t then left t else t leftOnly t = t == Leaf || right t == Leaf && leftOnly (left t) Bijective! but not O(1). Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 27. A solution f :: T → (T, T, T, T, T, T, T) f L = (L,L,L,L,L,L,L) f (N t1 L) = (t1,N L L,L,L,L,L,L) f (N t1 (N t2 L)) = (N t1 t2,L,L,L,L,L,L) f (N t1 (N t2 (N t3 L))) = (t1,N (N t2 t3) L,L,L,L,L,L) f (N t1 (N t2 (N t3 (N t4 L)))) = (t1,N t2 (N t3 t4),L,L,L,L,L) f (N t1 (N t2 (N t3 (N t4 (N L L))))) = (t1,t2,N t3 t4,L,L,L,L) f (N t1 (N t2 (N t3 (N t4 (N (N t5 L) L))))) = (t1,t2,t3,N t4 t5,L,L,L) f (N t1 (N t2 (N t3 (N t4 (N (N t5 (N t6 L)) L))))) = (t1,t2,t3,t4,N t5 t6,L,L) f (N t1 (N t2 (N t3 (N t4 (N (N t5 (N t6 (N t7 t8))) L))))) = (t1,t2,t3,t4,t5,t6,N t7 t8) f (N t1 (N t2 (N t3 (N t4 (N t5 (N t6 t7 )))))) = (t1,t2,t3,t4,t5,N t6 t7,L) Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 28. Where did this come from T = 1 + T2 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 29. Where did this come from T = 1 + T2 Tk = Tk−1 + Tk+1 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 30. Penny game T0 T1 T2 T3 T4 T5 T6 T7 T8 start with a penny in position 1. aim is to move it to position 7 by splitting and combining Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 31. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 32. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 33. Why did this work? If we have a type isomorphism T ∼= p(T) then Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 34. Why did this work? If we have a type isomorphism T ∼= p(T) then q1(T) ∼= q2(T) as types ⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x) Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 35. Why did this work? If we have a type isomorphism T ∼= p(T) then q1(T) ∼= q2(T) as types ⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x) ⇒ q1(x) ∼= q2(x) in the ring Z[x]/(p(x) = x) Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 36. Why did this work? If we have a type isomorphism T ∼= p(T) then q1(T) ∼= q2(T) as types ⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x) ⇒ q1(x) ∼= q2(x) in the ring Z[x]/(p(x) = x) ⇒ q1(z) ∼= q2(z) for all z ∈ C such that p(z) = z. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 37. Why did this work? If we have a type isomorphism T ∼= p(T) then q1(T) ∼= q2(T) as types ⇐⇒ q1(x) ∼= q2(x) in the rig N[x]/(p(x) = x) ⇒ q1(x) ∼= q2(x) in the ring Z[x]/(p(x) = x) ⇒ q1(z) ∼= q2(z) for all z ∈ C such that p(z) = z. And, under some conditions, the reverse implications hold. Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 38. Summary Simple arithmetic helps us find non-obvious type isomorphisms Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 39. Extensions Are there extensions to datatypes of decorated trees? (multivariate polynomials) What applications are there? Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 40. Extensions Are there extensions to datatypes of decorated trees? (multivariate polynomials) What applications are there? important when writing a compiler to know when two types are isomomorphic Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 41. Extensions Are there extensions to datatypes of decorated trees? (multivariate polynomials) What applications are there? important when writing a compiler to know when two types are isomomorphic It could interesting to split up a tree-shaped stream into seven parts Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 42. Rich theory behind isomorphisms of polynomial types brings together a number of fields distributive categories theory of rigs (semirings) combinatorial species type theory Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 43. Further reading Seven Trees in one, Andreas Blass, Journal of Pure and Applied Algebra On the generic solution to P(X) = X in distributive categories, Robbie Gates Objects of Categories as Complex Numbers, Marcelo Fiore and Tom Leinster An Objective Representation of the Gaussian Integers, Marcelo Fiore and Tom Leinster http://rfcwalters.blogspot.com.au/2010/06/robbie-gates-on- seven-trees-in-one.html http://blog.sigfpe.com/2007/09/arboreal-isomorphisms-from- nuclear.html Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 44. Challenge Consider this datatype (Motzkin trees): data Tree = Zero | One Tree | Two Tree Tree Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 45. Challenge Consider this datatype (Motzkin trees): data Tree = Zero | One Tree | Two Tree Tree T = 1 + T + T2 Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 46. Challenge Consider this datatype (Motzkin trees): data Tree = Zero | One Tree | Two Tree Tree T = 1 + T + T2 Show that T5 ∼= T by a nonsense argument using complex numbers by composing bijections (the penny game) implement the function and its inverse in a language of your choice Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 47. Photo credits The Druid’s Grove, Norbury Park: Ancient Yew Trees by Thomas Allom 1804-1872 http://www.victorianweb.org/art/illustration/allom/1.html Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one
  • 48. End Mark Hopkins @antiselfdual Commonwealth Bank Seven trees in one