A Kripke Logical Relation for Linear Functions

Post on 04-Nov-2021

7 views 0 download

Transcript of A Kripke Logical Relation for Linear Functions

A Kripke Logical Relation for Linear Functions:

The Story of a Free Theorem in the Presence of Non-termination

Phillip Mates & Amal AhmedNortheastern University

2

Programmers shouldn't have to think about compilers

3

Fully abstract compiler

Source Target

4

Fully abstract compiler

Source Target

preserves equivalence

5

Fully abstract compiler

Source Target

reflects equivalence

preserves equivalence

&

6

Verifying a CPS translation fully abstract

Source

Target

7

Outline

Finding a fully abstract CPS translation w/ • Standard CPS

• Polymorphic CPS ( only in a pure setting)

• Linear + polymorphic CPS

Proving full-abstraction

Towards a semantic model for linearly-treated functions

8

Standard CPS isn't fully abstract

9

Standard CPS isn't fully abstract

10

Standard CPS isn't fully abstract

11

Standard CPS isn't fully abstract

12

Standard CPS isn't fully abstract

13

Standard CPS isn't fully abstract

14

Standard CPS isn't fully abstract

15

Standard CPS isn't fully abstract

16

How can we modify the standardCPS translation to be fully abstract?

17

Standard CPS

Ahmed & Blume's polymorphic CPS

18

What happens when we add non-termination?

Standard CPS

Ahmed & Blume's polymorphic CPS

19

Linear + polymorphic CPS

Standard CPS

Ahmed & Blume's polymorphic CPS

20

Outline

Finding a fully abstract CPS translation w/

Proving full-abstraction• Polymorphic CPS proof

• Scaling to a non-terminating setting using linearity

Towards a semantic model for linearly-treated functions

21

Proving polymorphic CPS fully abstract

Ahmed + Blume's approach relies ona type isomorphism:

22

Proving polymorphic CPS fully abstract

The type isomorphism relies ona parametric condition:

23

Parametric condition fails in the presence of non-termination

24

Parametric condition fails in the presence of non-termination

25

Parametric condition fails in the presence of non-termination

26

Parametric condition fails in the presence of non-termination

27

A step back

Ahmed & Blume's polymorphic CPS

28

A step back

Ahmed & Blume's polymorphic CPS

requires

29

A step back

Ahmed & Blume's polymorphic CPS

requires

30

A step back

Ahmed & Blume's polymorphic CPS

requires

Linear + polymorphic CPS

31

A step back

Ahmed & Blume's polymorphic CPS

requires

Linear + polymorphic CPS

requires

32

A step back

Ahmed & Blume's polymorphic CPS

requires

Linear + polymorphic CPS

requires linear

33

A “linear” parametric conditionin presence of non-termination

linear

34

How do you prove thisnew parametric condition,

which uses continuations linearly?

35

Free theorem: use a logical relation

36

Free theorem: use a logical relation

37

Free theorem: use a logical relation

38

Free theorem: use a logical relation

39

Free theorem: use a logical relation

?

40

Proving

41

Proving

know

42

Proving

know

43

Proving

showknow

44

Proving

know show

45

Proving

know:

showknow

46

Proving

know:

show:

showknow

47

Proving

know:

show:

showknow

48

Proving

49

Proving

know

50

Proving

know

know

51

Proving

show

know

know

52

show

know

Proving

know

behaviour?

53

show

know

know

Proving

54

show

know

Proving

know

55

show

know

Proving

=know

56

Outline

Finding a fully abstract CPS translation w/

Proving full-abstraction

Towards a semantic model for linearly-treated functions

57

?

Function semantics: case 1

58

for all possible inputs

Function semantics: case 1

unrestrictedusage

59

Function semantics: case 2

for all possible inputs &treat inputs linearly

unrestrictedusage

60

for particular inputs

Function semantics: case 3

linearly used

61

Function semantics: case 4

for particular inputs &treat input linearly

linearly used

62

Relating linearly-treated functions

63

Relating linearly-treated functions

64

Relating linearly-treated functions

65

Relating linearly-treated functions

66

Relating linearly-treated functions

where

67

Linearity by default

68

Kripke logical relation for linearity

69

Kripke logical relation for linearity

70

Kripke logical relation for linearity

71

Kripke logical relation for linearity

72

Kripke logical relation for linearity

73

Kripke logical relation for linearity

74

Kripke logical relation for linearity

75

Kripke logical relation for linearity

76

Related Work

Fully abstract CPS for PCF [Laird]

• Uses game semantics proof

Logical relation for linear free theorems [Zhao et. al.]

• Open logical relation to ensure preservation of linear resources

TT logical relation for Lily [Bierman et. al.]

77

Conclusion

Fully abstract CPS in a language with rec. types using operational proof techniques

requires

which requires

78

Conclusion

Fully abstract CPS in a language with rec. types using operational proof techniques

requires

which requires

Kripke logical relation that can distinguishlinearly-treated: unrestricted:

79

80

Why polymorphism:ST boundary semantics