Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Logical Equivalence of Algebraic Effects in Programming: A Sound and Complete Logic, Study notes of Logic

The logical equivalence of algebraic effects in programming, focusing on contextual equivalence and behavioral logic. The authors, Cristina Matache and Sam Staton, present their work from the University of Oxford. program equivalence, contextual equivalence, logical equivalence, and continuation-passing style (CPS). It also includes examples of effect signatures and observations.

What you will learn

  • What is the role of logical equivalence in program equivalence?
  • What is the main contribution of this paper?
  • What are the examples of effect signatures given in the document?
  • How is the behavior of programs described using logic?
  • How is contextual equivalence defined?

Typology: Study notes

2021/2022

Uploaded on 09/27/2022

myas
myas 🇬🇧

5

(9)

216 documents

1 / 47

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A Sound and Complete Logic for
Algebraic Effects
Cristina Matache (joint work with Sam Staton)
University of Oxford
1/24
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f

Partial preview of the text

Download Logical Equivalence of Algebraic Effects in Programming: A Sound and Complete Logic and more Study notes Logic in PDF only on Docsity!

A Sound and Complete Logic for

Algebraic Effects

Cristina Matache (joint work with Sam Staton)

University of Oxford

Question

Programming Language

▶ Higher-order functions ▶ Algebraic effects [Plotkin & Power] ▶ Recursive functions ▶ Continuation passing (CPS)

Logic M ⊧ ϕ

program

formula

program property

Contextual

Equivalence

Main

Theorem

[Matache & Staton, FoSSaCS’19]

Logical Equivalence

¾ϕ: M ⊧ ϕ ⟺ N ⊧ ϕ:

Motivation: [Simpson & Voorneveld, ESOP’18].

Outline

1 Introduction: Program Equivalence and CPS

2 Programming Calculus

3 Logic

4 Main Theorem

Program equivalence

Establishes when two programs have

the same behaviour.

Higher-order functions make it hard.

Effects make it hard.

Example or x ; y  nondeterministically choose x or y Want: or or 1 2

or 1 or 2 3

or

or

6 or

Behavioural Logic

Logic M ⊧ ϕ

program

formula

program property

⊧ describes the behaviour of programs

Example

or ( or 1 ; 2 ; 3 ) ⊧ ◇r 3 x may return 3

⊧ □r 1 ; 2 ; 3 x

always returns one of r 1 ; 2 ; 3 x

Behavioural Logic

Logic M ⊧ ϕ

program

formula

program property

⊧ describes the behaviour of programs

Logical Equivalence

M ≡log N iff ¾ϕ: M ⊧ ϕ ⟺ N ⊧ ϕ:

Want: ≡ log  ≡ctx

Outline

1 Introduction: Program Equivalence and CPS

2 Programming Calculus

3 Logic

4 Main Theorem

ECPS Calculus

▶ Types: A ; AiA 1 ; : : : ; An R ∣ nat n ' 0  ▶ Values vs. computations

Γ;  x  ∶ A ⊢c^ t ∶ R Γ ⊢v^ 

xA : t

A R

Γ ⊢v^ v ∶  A R Γ ⊢v^ wiAi  i Γ ⊢c^ v  w  ∶ R

ECPS Calculus

▶ Types: A ; AiA 1 ; : : : ; An R ∣ nat n ' 0  ▶ Values vs. computations Γ;  x  ∶ A ⊢c^ t ∶ R Γ ⊢v^  xA : t ∶  A R

Γ ⊢v^ v ∶  A R Γ ⊢v^ wiAi  i Γ ⊢c^ v  w  ∶ R ▶ Effect operations.

 " Σ Γ ⊢v Σ vi ∶ nat i Γ ⊢v Σ kj ∶ nat; : : : ; natR j

Γ ⊢c Σ  vi ;

kj  ∶ R

▶ Recursion

Examples of Effect Signatures

Probability: p - or ∶ (R; R)R (^) like h ∶ R  R R

geom k (^) k 1

k 2

k 3

▶ geom computes the geometric distribution: it passes n to the continuation k with probability (^21) n.

geom  k ∶natR: (rec f :  n ∶nat; k ¬∶natR: p - or : k ¬^ n ; : f succ n ; k ¬ ) 1 ; k :

Examples of Effect Signatures

Probability: Σ r p - or ∶ (R; R)R;  ∶ Rx

Computation tree

geom k (^) k 1

k 2 k 3

Jgeom  x ∶nat:  K p - or  p - or  geometric distribution^ Jgeom^  x ∶nat:^ ^ K

Examples of Effect Signatures

Nondeterminism: Σ r or ∶ (R; R)R;  ∶ Rx

Abstract syntax tree Computation tree

three_or_four k

k 4

k 3 k 4

Jthree_or_four  x ∶nat: if x 4 then  else loop K or  or ⊥ 

▶ three_or_four returns either 3 or 4 to continuation.

Observations

Observation P Set of trees

▶ Σ Success: rx ▶ Σ Probability: for q " Q; 0 & q $ 1 P% q rtrees that succeed with probability % q x ▶ Σ Nondeterminism: ◇ rtrees with at least one  leafx □ rtrees of finite height with only  leavesx ▶ Σ Global store: S " L ⟶ N  S  rtrees that succeed when started in state S x

Observations

Observation P Set of trees

▶ Σ Success: rx

Jtest_zero 0 K  "