testing log log program favonia 1
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) 2
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) α * = β * = ℕ identity function and [0, 1, …, n-1] 2
Testing exists exists : ∀α .( α→ 2) → list( α ) → 2 α * = 2 identity function and all lists 3
Testing pick pick : ∀α . α × α→α α * = 2 (true, false) 4
Theorem [Bernardy et al. ] p : ∀α . (F( α ) →α )×(G( α ) → K) → H( α ) pos pos pos α * = μ F if it exists ρ * : F( α *) →α * catamorphism “roll” 5
Theorem [Bernardy et al. ] p : ∀α . (F( α ) →α )×(G( α ) → K) → H( α ) pos pos pos project embed p : ∀α . P( α ) → H( α ) pos 6
My Problems with Embedding/Projection Type μ F buried under layers of existence theorems. Error-prone: e.g. , wrongly assuming list( α ) ⊆ ℕ ×( ℕ →α ). 7
p : ∀α . P( α ) → H( α ) 8
Logarithmic Conjecture p : ∀α . P( α ) → H( α ) α * = μα .log α P( α ) if it exists 8
Logarithmic Conjecture p : ∀α . P( α ) → H( α ) α * = μα .log α P( α ) if it exists Goal: simple and direct calculation 8
Testing pick pick : ∀α . α × α→α α * = log α ( α × α ) = log α ( α 2 ) = 2 “all locations of α ” “all ways to generate an α -element” 9
log α α = 1 log α K = 0 10
log α α = 1 log α K = 0 log α (A×B) = log α A + log α B log α (A+B) = log α A ∪ log α B A ∪ B ≈ “max(A,B)” can be A+B, ideally more optimized 10
log α α = 1 log α K = 0 log α (A×B) = log α A + log α B log α (A+B) = log α A ∪ log α B A ∪ B ≈ “max(A,B)” can be A+B, ideally more optimized log α (A ∪ B) = log α A ∪ log α B optional 10
log α α = 1 log α K = 0 log α (A×B) = log α A + log α B log α (A+B) = log α A ∪ log α B A ∪ B ≈ “max(A,B)” can be A+B, ideally more optimized log α (A ∪ B) = log α A ∪ log α B optional log α (A → B) = A × log α B “B A ” 10
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) 11
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) P( α ) = ( α→β ) × list( α ) 11
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) P( α ) = ( α→β ) × list( α ) log α P( α ) = log α ( α→β ) + log α list( α ) 11
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) P( α ) = ( α→β ) × list( α ) log α P( α ) = log α ( α→β ) + log α list( α ) = α × log α β = α × 0 ≅ 0 11
α Rules of Recursive Logarithm X ≅ P(X) X X log α X ≅ log α P(X) X X 12
α Rules of Recursive Logarithm X ≅ P(X) X X log α X ≅ log α P(X) X X log α ( μ X.P) = μ X ′ .(log α P)[ μ X.P/X] log α X = X ′ 12
Rules of Recursive Logarithm list( α ) = μ X. 1 + α × X log α (list( α )) = μ X ′ . 0 ∪ (1 + X ′ ) ≈ μ X ′ . 1 + X ′ = ℕ log α ( μ X.P) = μ X ′ .(log α P)[ μ X.P/X] log α X = X ′ I will assume 0 ∪ A = A from now on 13
Testing map map : ∀α . ∀β .( α→β ) → list( α ) → list( β ) P( α ) = ( α→β ) × list( α ) log α P( α ) = log α ( α→β ) + log α list( α ) ≈ ℕ ≅ 0 14
Logarithmic Conjecture p : ∀α . P( α ) → H( α ) α * = μα .log α P( α ) if it exists Goal: simple and direct calculation 15
Non-regular Recursion and Change of Bases / Chain Rules N( α ) ≅ 1 + α × N( α × α ) α α 2 α 4 α 8 1 example stolen from Categories of Containers [Abbott et al. ] 16
Non-regular Recursion and Change of Bases / Chain Rules N( α ) ≅ 1 + α × N( α × α ) α α 2 α 4 α 8 1 log α N( α ) ≅ 1 + “log α × α N( α × α )” × log α ( α × α ) N ′ ( α ) ≅ 1 + N ′ ( α × α ) × 2 example stolen from Categories of Containers [Abbott et al. ] 16
α Non-regular Recursion and Change of Bases / Chain Rules P P log α P(Q( α )) = P ′ (Q( α )) × Q ′ ( α ) Q Q 17
α Non-regular Recursion and Change of Bases / Chain Rules P P log α P(Q( α )) = P ′ (Q( α )) × Q ′ ( α ) Q Q Should work for arbitrary P with more equations log α (( α 2 ) 3 ) = 3 × 2 log α ( α 2 × α 2 × α 2 ) = 2 + 2 + 2 17
Non-regular Recursion and Change of Bases / Chain Rules F( α ) ≅ 1 + α + list( α ) × F( α 2 + α 3 ) × list( α ) ( fi nger trees) list( α ) may be optimized to α + α 2 + α 3 + α 4 18
Non-regular Recursion and Change of Bases / Chain Rules F( α ) ≅ 1 + α + list( α ) × F( α 2 + α 3 ) × list( α ) ( fi nger trees) F ′ ( α ) ≅ 1 ∪ ( ℕ + F ′ ( α 2 + α 3 ) × (2 ∪ 3) + ℕ ) list( α ) may be optimized to α + α 2 + α 3 + α 4 18
Corollary of Conjecture p : ∀α . (F( α ) →α )×(G( α ) → K) → H( α ) 19
Corollary of Conjecture p : ∀α . (F( α ) →α )×(G( α ) → K) → H( α ) log α ((F( α ) →α )×(G( α ) → K)) = log α (F( α ) →α ) + log α (G( α ) → K) ) ( 0 F α ≈ ≅ α * ≅ μα .(F( α ) + 0) ≅ μ F 19
Corollary of Conjecture p : ∀α . (F( α ) →α )×(G( α ) → K) → H( α ) log α ((F( α ) →α )×(G( α ) → K)) = log α (F( α ) →α ) + log α (G( α ) → K) ) ( 0 F α ≈ ≅ α * ≅ μα .(F( α ) + 0) ≅ μ F How to plug in ρ *, the catamorphism (“roll”)? 19
Upgraded Logarithmic Conjecture p : ∀α . P( α ) → H( α ) α * = μα .P ′ ( α ) if it exists 20
Upgraded Logarithmic Conjecture p : ∀α . P( α ) → H( α ) α * = μα .P ′ ( α ) if it exists ρ * : P ′ ( α *) → α * catamorphism “roll” 20
Upgraded Logarithmic Conjecture p : ∀α . P( α ) → H( α ) α * = μα .P ′ ( α ) if it exists ρ * : P ′ ( α *) → α * catamorphism “roll” wants: ρ + : something → P( α *) 20
has: ρ * : P ′ ( α *) → α * wants: ρ + : something → P( α *) 21
has: ρ * : P ′ ( α *) → α * wants: ρ + : something → P( α *) ρ * can fi ll in strictly positive positions 21
has: ρ * : P ′ ( α *) → α * wants: ρ + : something → P( α *) ρ * can fi ll in strictly positive positions exists : ∀α .( α→ 2) → list( α ) → 2 21
has: ρ * : P ′ ( α *) → α * wants: ρ + : something → P( α *) ρ * can fi ll in strictly positive positions exists : ∀α .( α→ 2) → list( α ) → 2 something: everything else 21
Killing the Strictly Positive α − = 1 K − = K (A → B) − = A → B − (A×B) − = A − × B − (A ∪ B) − = A − ∪ B − (A+B) − = A − + B − ( μβ .A) − = μβ .A − ρ + : P − ( α *) → P( α *) residual full 22
Corollary of Upgraded Conjecture p : ∀α . (F( α ) →α )×(G( α ) → K) → H( α ) = ((F( α ) →α ) × (G( α ) → K)) − = (F( α ) → 1) × (G( α ) → K) ≅ 1 ρ + (_, g) ≈ ( ρ *, g) with appropriate rules (omitted) ρ + puts ρ * at the right places 23
Problems: Suboptimal Types exists : ∀α .( α→ 2) → list( α ) → 2 α * = ℕ , but α = 2 with id seems better similarly “all”, “toString”, “ fi lter”, etc. 24
Problems: Suboptimal Types exists : ∀α .( α→ 2) → list( α ) → 2 α * = ℕ , but α = 2 with id seems better similarly “all”, “toString”, “ fi lter”, etc. length : ∀α .list( α ) → ℕ α * = ℕ , but α = 1 su ffi ces 24
Problems: Suboptimal Types exists : ∀α .( α→ 2) → list( α ) → 2 α * = ℕ , but α = 2 with id seems better similarly “all”, “toString”, “ fi lter”, etc. length : ∀α .list( α ) → ℕ α * = ℕ , but α = 1 su ffi ces Current: full distinctiveness Next: inspectability 24
Future Work 25
Future Work Conjectures → Theorems 25
Future Work Conjectures → Theorems Greatest fi xed points, etc. 25
Future Work Conjectures → Theorems Greatest fi xed points, etc. Unknown datatypes, not just functions Checker for parts of CMU 15-210 in 2015 General theory under development 25
Some Related Work Testing Polymorphic Properties Jean-Philippe Bernardy, Patrik Jansson, and Koen Claessen Categories of Containers Michael Abbott, Thorsten Altenkirch, and Neil Ghani A semantics for shape C. Barry Jay Species and Functors and Types, Oh My! Brent A. Yorgey 26
Unlike derivatives, logarithms di ff erentiate. credit to Danny Gratzer 27
Recommend
More recommend