testing log log program favonia 1 Testing map map : . .( ) - - PowerPoint PPT Presentation

testing log log program favonia 1 testing map
SMART_READER_LITE
LIVE PREVIEW

testing log log program favonia 1 Testing map map : . .( ) - - PowerPoint PPT Presentation

testing log log program favonia 1 Testing map map : . .( ) list( ) list( ) 2 Testing map map : . .( ) list( ) list( ) * = * = identity function and [0, 1, ,


slide-1
SLIDE 1

testing program log favonia log 1

slide-2
SLIDE 2

map : ∀α.∀β.(α→β)→list(α)→list(β)

Testing map 2

slide-3
SLIDE 3

map : ∀α.∀β.(α→β)→list(α)→list(β)

α* = β* = ℕ identity function and [0, 1, …, n-1] Testing map 2

slide-4
SLIDE 4

exists : ∀α.(α→2)→list(α)→2

α* = 2 identity function and all lists Testing exists 3

slide-5
SLIDE 5

pick : ∀α. α×α→α

α* = 2 (true, false) Testing pick 4

slide-6
SLIDE 6

Theorem [Bernardy et al.]

p : ∀α. (F(α)→α)×(G(α)→K)→H(α)

pos pos pos α* = μF if it exists ρ* : F(α*)→α* catamorphism “roll” 5

slide-7
SLIDE 7

p : ∀α. (F(α)→α)×(G(α)→K)→H(α)

pos pos pos Theorem [Bernardy et al.]

p : ∀α. P(α)→H(α)

pos project embed 6

slide-8
SLIDE 8

My Problems with Embedding/Projection

Type μF buried under layers

  • f existence theorems.

Error-prone: e.g., wrongly assuming list(α) ⊆ ℕ×(ℕ→α).

7

slide-9
SLIDE 9

p : ∀α. P(α)→H(α)

8

slide-10
SLIDE 10

Logarithmic Conjecture

p : ∀α. P(α)→H(α)

α* = μα.logαP(α) if it exists 8

slide-11
SLIDE 11

Logarithmic Conjecture

p : ∀α. P(α)→H(α)

α* = μα.logαP(α) if it exists

Goal: simple and direct calculation

8

slide-12
SLIDE 12

pick : ∀α. α×α→α

α* = logα(α×α) = logα(α2) = 2 Testing pick

“all locations of α” “all ways to generate an α-element”

9

slide-13
SLIDE 13

logαα = 1 logαK = 0

10

slide-14
SLIDE 14

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

slide-15
SLIDE 15

logαα = 1 logαK = 0 logα(A+B) = logαA ∪ logαB 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

  • ptional

10

slide-16
SLIDE 16

logαα = 1 logαK = 0 logα(A+B) = logαA ∪ logαB 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) = A × logαB

  • ptional

“BA”

10

slide-17
SLIDE 17

map : ∀α.∀β.(α→β)→list(α)→list(β)

Testing map 11

slide-18
SLIDE 18

map : ∀α.∀β.(α→β)→list(α)→list(β)

Testing map

P(α) = (α→β) × list(α)

11

slide-19
SLIDE 19

map : ∀α.∀β.(α→β)→list(α)→list(β)

Testing map

P(α) = (α→β) × list(α) logαP(α) = logα(α→β) + logαlist(α)

11

slide-20
SLIDE 20

map : ∀α.∀β.(α→β)→list(α)→list(β)

Testing map

P(α) = (α→β) × list(α) logαP(α) = logα(α→β) + logαlist(α)

= α × logαβ = α × 0 ≅ 0

11

slide-21
SLIDE 21

Rules of Recursive Logarithm

X ≅ P(X) logαX ≅ logαP(X)

X X

α

X X

12

slide-22
SLIDE 22

Rules of Recursive Logarithm

X ≅ P(X) logαX ≅ logαP(X) logα(μX.P) = μX′.(logαP)[μX.P/X] logαX = X′

X X

α

X X

12

slide-23
SLIDE 23

Rules of Recursive Logarithm

logα(μX.P) = μX′.(logαP)[μX.P/X] logαX = X′ list(α) = μX. 1 + α × X logα(list(α)) = μX′. 0 ∪ (1 + X′) ≈ μX′. 1 + X′ = ℕ

I will assume 0 ∪ A = A from now on

13

slide-24
SLIDE 24

map : ∀α.∀β.(α→β)→list(α)→list(β)

Testing map

P(α) = (α→β) × list(α) logαP(α) = logα(α→β) + logαlist(α)

≅ 0 ≈ ℕ

14

slide-25
SLIDE 25

Logarithmic Conjecture

p : ∀α. P(α)→H(α)

α* = μα.logαP(α) if it exists

Goal: simple and direct calculation

15

slide-26
SLIDE 26

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

slide-27
SLIDE 27

Non-regular Recursion and Change of Bases / Chain Rules

N(α) ≅ 1 + α × N(α×α) logαN(α) ≅ 1 + “logα×αN(α×α)” × logα(α×α) N′(α) ≅ 1 + N′(α×α) × 2 α α2 α4 α8 1

example stolen from Categories of Containers [Abbott et al.]

16

slide-28
SLIDE 28

Non-regular Recursion and Change of Bases / Chain Rules

logαP(Q(α)) = P′(Q(α)) × Q′(α)

P Q

α

P Q

17

slide-29
SLIDE 29

Non-regular Recursion and Change of Bases / Chain Rules

logαP(Q(α)) = P′(Q(α)) × Q′(α) logα((α2)3) = 3 × 2 logα(α2 × α2 × α2) = 2 + 2 + 2 Should work for arbitrary P with more equations

P Q

α

P Q

17

slide-30
SLIDE 30

Non-regular Recursion and Change of Bases / Chain Rules

F(α) ≅ 1 + α + list(α) × F(α2+α3) × list(α)

list(α) may be optimized to α + α2 + α3 + α4

(finger trees)

18

slide-31
SLIDE 31

Non-regular Recursion and Change of Bases / Chain Rules

F(α) ≅ 1 + α + list(α) × F(α2+α3) × list(α) F′(α) ≅ 1 ∪ (ℕ + F′(α2+α3) × (2 ∪ 3) + ℕ)

list(α) may be optimized to α + α2 + α3 + α4

(finger trees)

18

slide-32
SLIDE 32

Corollary of Conjecture p : ∀α. (F(α)→α)×(G(α)→K)→H(α)

19

slide-33
SLIDE 33

Corollary of Conjecture p : ∀α. (F(α)→α)×(G(α)→K)→H(α)

logα((F(α)→α)×(G(α)→K)) = logα(F(α)→α) + logα(G(α)→K)

α* ≅ μα.(F(α) + 0) ≅ μF

≅ F ( α ) ≈

19

slide-34
SLIDE 34

Corollary of Conjecture p : ∀α. (F(α)→α)×(G(α)→K)→H(α)

logα((F(α)→α)×(G(α)→K)) = logα(F(α)→α) + logα(G(α)→K)

α* ≅ μα.(F(α) + 0) ≅ μF

How to plug in ρ*, the catamorphism (“roll”)?

≅ F ( α ) ≈

19

slide-35
SLIDE 35

Upgraded Logarithmic Conjecture

p : ∀α. P(α)→H(α)

α* = μα.P′(α) if it exists 20

slide-36
SLIDE 36

Upgraded Logarithmic Conjecture

p : ∀α. P(α)→H(α)

α* = μα.P′(α) if it exists ρ* : P′(α*) → α* catamorphism “roll” 20

slide-37
SLIDE 37

Upgraded Logarithmic Conjecture

p : ∀α. P(α)→H(α)

α* = μα.P′(α) if it exists

wants: ρ+ : something → P(α*)

ρ* : P′(α*) → α* catamorphism “roll” 20

slide-38
SLIDE 38

wants: ρ+ : something → P(α*)

has: ρ* : P′(α*) → α* 21

slide-39
SLIDE 39

ρ* can fill in strictly positive positions

wants: ρ+ : something → P(α*)

has: ρ* : P′(α*) → α* 21

slide-40
SLIDE 40

ρ* can fill in strictly positive positions

wants: ρ+ : something → P(α*)

has: ρ* : P′(α*) → α*

exists : ∀α.(α→2)→list(α)→2

21

slide-41
SLIDE 41

ρ* can fill in strictly positive positions

wants: ρ+ : something → P(α*)

has: ρ* : P′(α*) → α*

exists : ∀α.(α→2)→list(α)→2

something: everything else 21

slide-42
SLIDE 42

Killing the Strictly Positive

α− = 1 K− = K

(A+B)− = A− + B− (A×B)− = A− × B−

(A→B)− = A → B−

ρ+ : P−(α*) → P(α*)

(A∪B)− = A− ∪ B− (μβ.A)− = μβ.A− residual full

22

slide-43
SLIDE 43

Corollary of Upgraded Conjecture p : ∀α. (F(α)→α)×(G(α)→K)→H(α)

= ((F(α)→α) × (G(α)→K))− = (F(α)→1) × (G(α)→K)

ρ+(_, g) ≈ (ρ*, g)

with appropriate rules (omitted)

≅ 1

ρ+ puts ρ* at the right places 23

slide-44
SLIDE 44

α* = ℕ, but α = 2 with id seems better

Problems: Suboptimal Types

similarly “all”, “toString”, “filter”, etc.

exists : ∀α.(α→2)→list(α)→2

24

slide-45
SLIDE 45

α* = ℕ, but α = 2 with id seems better

Problems: Suboptimal Types

length : ∀α.list(α)→ℕ

α* = ℕ, but α = 1 suffices

similarly “all”, “toString”, “filter”, etc.

exists : ∀α.(α→2)→list(α)→2

24

slide-46
SLIDE 46

α* = ℕ, but α = 2 with id seems better

Problems: Suboptimal Types

length : ∀α.list(α)→ℕ

α* = ℕ, but α = 1 suffices Current: full distinctiveness Next: inspectability

similarly “all”, “toString”, “filter”, etc.

exists : ∀α.(α→2)→list(α)→2

24

slide-47
SLIDE 47

Future Work 25

slide-48
SLIDE 48

Conjectures → Theorems

Future Work 25

slide-49
SLIDE 49

Conjectures → Theorems

Future Work

Greatest fixed points, etc.

25

slide-50
SLIDE 50

Conjectures → Theorems

Future Work

Unknown datatypes, not just functions

Checker for parts of CMU 15-210 in 2015 General theory under development

Greatest fixed points, etc.

25

slide-51
SLIDE 51

Some Related Work

Categories of Containers

Michael Abbott, Thorsten Altenkirch, and Neil Ghani

Testing Polymorphic Properties

Jean-Philippe Bernardy, Patrik Jansson, and Koen Claessen

Species and Functors and Types, Oh My!

Brent A. Yorgey

A semantics for shape

  • C. Barry Jay

26

slide-52
SLIDE 52

Unlike derivatives, logarithms differentiate.

credit to Danny Gratzer

27