Cutland: Computability, an introduction to recursive function theory - - PowerPoint PPT Presentation

cutland computability an introduction to recursive
SMART_READER_LITE
LIVE PREVIEW

Cutland: Computability, an introduction to recursive function theory - - PowerPoint PPT Presentation

W EAK C ALL - BY -V ALUE L AMBDA C ALCULUS AS A M ODEL OF C OMPUTATION IN C OQ ITP 2017 Yannick Forster Gert Smolka S AARLAND U NIVERSITY , P ROGRAMMING S YSTEMS L AB saarland university computer science Introduction Definitions


slide-1
SLIDE 1

WEAK CALL-BY-VALUE LAMBDA CALCULUS

AS A MODEL OF COMPUTATION IN COQ

ITP 2017

Yannick Forster Gert Smolka

SAARLAND UNIVERSITY, PROGRAMMING SYSTEMS LAB

computer science

saarland

university

slide-2
SLIDE 2

Introduction Definitions Verification Rice Modesty Post

RELATED WORK

Michael Norrish Mechanised computability theory ITP 2011

  • J. Xu, X. Zhang and C. Urban

Mechanising Turing Machines and computability theory in Isabelle/HOL ITP 2013 Andrea Asperti and Wilmer Ricciotti A formalization of multi-tape Turing machines TCS 2015 Andrej Bauer First steps in synthetic computability theory ENTCS 2006

2

slide-3
SLIDE 3

Introduction Definitions Verification Rice Modesty Post

Cutland: Computability, an introduction to recursive function theory Kozen: Automata and Computability: Wikipedia: 3

slide-4
SLIDE 4

Introduction Definitions Verification Rice Modesty Post

INGREDIENTS

◮ Take terms s, t, u, call closed normal forms procedures, ◮ take evaluation s ⊲ t (functional, t procedure), ◮ define Es := ∃t. s ⊲ t, ◮ take procedures T = F such that Tst ⊲ s and Fst ⊲ t, ◮ take retraction s into procedures to encode terms, ◮ do computability theory. 4

slide-5
SLIDE 5

Introduction Definitions Verification Rice Modesty Post

DEFINITIONS u decides p if ∀s. ps ∧ us ⊲ T ∨ ¬ps ∧ us ⊲ F u recognises p if ∀s. ps ↔ E(us)

5

slide-6
SLIDE 6

Introduction Definitions Verification Rice Modesty Post

u decides p if ∀s. ps ∧ us ⊲ T ∨ ¬ps ∧ us ⊲ F

Fact

λs.¬(ss ⊲ T) is not decidable.

Proof.

u decides λs.¬(ss ⊲ T): ∀s. ¬(ss ⊲ T) ∧ us ⊲ T ∨ ¬¬(ss ⊲ T) ∧ us ⊲ F ¬(uu ⊲ T) ∧ uu ⊲ T ∨ ¬¬(uu ⊲ T) ∧ uu ⊲ F Contradiction!

6

slide-7
SLIDE 7

Introduction Definitions Verification Rice Modesty Post

SELECTED RESULTS

◮ Self-interpreter. There is a procedure U such that for all

terms s, t:

  • 1. If s ⊲ t, then U s ⊲ t.
  • 2. If U s evaluates, then s evaluates.

◮ Rice’s theorem. Every nontrivial extensional class of

procedures is undecidable.

◮ Modesty. L-decidable classes are functionally decidable. ◮ Post’s Theorem. A class is decidable if it is recognisable,

corecognisable, and logically decidable.

7

slide-8
SLIDE 8

Introduction Definitions Verification Rice Modesty Post

SYNTAX OF L

De Bruijn Terms: s, t ::= n | s t | λs (n ∈ N) I = λx.x T = λxy.x F = λxy.y ω = λx.xx D = λx.ωω := λ0 := λ(λ1) := λ(λ0) := λ(00) := λ(ωω)

“Procedure” := closed abstraction

8

slide-9
SLIDE 9

Introduction Definitions Verification Rice Modesty Post

SEMANTICS OF L

Reduction: (λs)(λt) ≻ s0

λt

s ≻ s′ st ≻ s′t t ≻ t′ st ≻ st′

implemented using capturing single-point substitution

≡ equivalence closure of ≻ ⊲ big-step evaluation to abstraction

  • 1. Equational reasoning: s ≡ s′ → t ≡ t′ → st ≡ s′t′
  • 2. Church Rosser: If s ≡ t, then s ≻∗ u and t ≻∗ u for some u.
  • 3. Unique nfs: If s ⊲m t, s ⊲n u, then t = u, m = n.

9 [Plotkin, 1975], [Niehren, 1996], [Dal Lago & Martini, 2008]

slide-10
SLIDE 10

Introduction Definitions Verification Rice Modesty Post

SCOTT ENCODINGS AND RECURSION

ENCODINGS T, F for booleans

  • n for natural numbers

s for terms SCOTT CONSTRUCTORS

◮ Succ

n ≡ Sn

◮ A s t ≡ st

RECURSION COMBINATOR

◮ (ρu)v ≡ u(ρu)v 10 [Mogensen, 1990], [Jansen, 2013]

slide-11
SLIDE 11

Introduction Definitions Verification Rice Modesty Post

VERIFICATION

Functional specification: ∀mn. Add m n ≡ m + n By induction from: Add n ≡ n Add Sm n ≡ Succ (Add m n) Add := ρ(λamn.mn(λm0.Succ(am0n))) Add m n ≡ Add n m

11

slide-12
SLIDE 12

Introduction Definitions Verification Rice Modesty Post

If u decides p and v decides q then λs.ps ∧ qs is decidable. λx.ux(vx)F does the job

12

slide-13
SLIDE 13

Introduction Definitions Verification Rice Modesty Post

(STEP-INDEXED) INTERPRETER

eval : N → T → T⊥ eval n k = ⊥ eval n (λs) = ⌊λs⌋ eval 0 (st) = ⊥ eval (Sn) (st) = match eval n s, eval n t with | ⌊λs⌋, ⌊t⌋ ⇒ eval n s0

t

| _ _ ⇒ ⊥

s ⊲ t ↔ ∃n. eval n s = ⌊t⌋ E n s ≡ eval n s If s ⊲ t, then U s ⊲ t. If U s evaluates, then s evaluates.

13

slide-14
SLIDE 14

Introduction Definitions Verification Rice Modesty Post

MINIMISATION AND INTERPRETER

If s ⊲ t, then U s ⊲ t. If U s evaluates, then s evaluates.

Theorem

There is a procedure C such that for every unary u:

  • 1. If u is satisfiable, then Cu ⊲

n for some n satisfying u.

  • 2. If Cu evaluates, then u is satisfiable.

U := λx.E (C(λy.E y x (λz.T) F)) x

14

slide-15
SLIDE 15

Introduction Definitions Verification Rice Modesty Post

RICE IN REALITY

Kozen: Wikipedia: 15

slide-16
SLIDE 16

Introduction Definitions Verification Rice Modesty Post

RICE & SCOTT

Scott: Every class p satisfying the following conditions is undecidable.

  • 1. There are closed terms s1 and s2 such that ps1 and ¬ps2.
  • 2. If s and t are closed terms such that s ≡ t and ps, then pt.

Rice: Every class p satisfying the following conditions is undecidable.

  • 1. There are procedures s1 and s2 such that ps1 and ¬ps2.
  • 2. If s and t are procedures such that ∀uv. su ⊲ v ↔ tu ⊲ v and

ps, then pt. (“p is extensional”)

16 [Barendregt, 1984]

slide-17
SLIDE 17

Introduction Definitions Verification Rice Modesty Post

RICE’S THEOREM

Fact

The class of closed terms s such that ¬E(ss) is not recognisable.

Lemma (Reduction)

A class p is unrecognisable if there exists a function f such that:

  • 1. p(fs) ↔ ¬E(ss) for every closed terms s.
  • 2. There is a procedure v such that vs ≡ fs for all s.

17

slide-18
SLIDE 18

Introduction Definitions Verification Rice Modesty Post

RICE’S THEOREM

Lemma

Let p be an extensional class such that D is in p and some procedure N is not in p. Then p is unrecognisable.

Proof.

◮ Define function fs such that

◮ fs ≈ D if ¬E(ss) ◮ fs ≈ N if E(ss)

◮ f := s → λy.F(ss)Ny

v := λx.L(A(A(A F(Ax(Qx)))N)0)

◮ vs ≡ fs and p(fs) ↔ ¬E(ss) ◮ Reduction lemma 18

slide-19
SLIDE 19

Introduction Definitions Verification Rice Modesty Post

RICE’S THEOREM

Lemma

Let p be an extensional class such that D is in p and some procedure N is not in p. Then p is unrecognisable.

Theorem

Every nontrivial extensional class of procedures is undecidable.

Proof.

If u decides p then pD or ¬pD and . . .

19

slide-20
SLIDE 20

Introduction Definitions Verification Rice Modesty Post

COMPUTABLE NORMAL FORMS

Lemma

There is a function of type ∀s. (∃t. s ⊲ t) → Σt. s ⊲ t.

Proof.

◮ (∃t.s ⊲ t) ↔ ∃n. eval n s = ⊥ ◮ λn.eval n s = ⊥ is Coq-decidable ◮ Use constructive choice (constructive indefinite ground

description) to obtain n with eval n s = ⌊t⌋

◮ s ⊲ t 20

slide-21
SLIDE 21

Introduction Definitions Verification Rice Modesty Post

TYPING TOTAL λ-DEFINABLE FUNCTIONS IN COQ

If u decides p then there is f with fs = true ↔ ps ⇒ L-decidability implies Coq-decidability

∀u.(∀n∃m. u n ⊲ m) → {f : N → N | ∀s. u s ⊲ fs}

21 [Larchey-Wendling (2017)]

slide-22
SLIDE 22

Introduction Definitions Verification Rice Modesty Post

POST’S THEOREM

Theorem

If u recognises p and v recognises λs.¬ps, then p is decidable if ∀s. ps ∨ ¬ps. Without restriction: equivalent to ¬¬Es → Es

22 [Bauer (2006)]

slide-23
SLIDE 23

Introduction Definitions Verification Rice Modesty Post

FURTHER RESULTS

◮ Totality. The class of total procedures is unrecognisable. ◮ Parallel or. There is procedure O such that:

  • 1. If s or t evaluates, then O s t evaluates.
  • 2. If O s t evaluates, then either O s t ⊲ T and E s, or O s t ⊲ F

and E t.

◮ Closure under union. The union of recognisable languages is

recognisable.

◮ Scott’s theorem. Every nontrivial class of closed terms

closed under ≡ is undecidable.

◮ Enumerability. A class is recognisable if and only if it is

enumerable.

23

slide-24
SLIDE 24

Introduction Definitions Verification Rice Modesty Post

CONTRIBUTION

◮ Elegant model of computation, easy to reason about ◮ Constructive formalisation of basic computability theory,

less than 2000 loc

◮ Self-Interpreter, Rice, Scott, Post, Totality 24

slide-25
SLIDE 25

Introduction Definitions Verification Rice Modesty Post

FUTURE WORK

◮ “L and Turing Machines can simulate each other with a

polynomially bounded overhead in time and a constant-factor overhead in space.”

[Dal Lago, Martini (2008)], [Forster, Kunze, Roth (LOLA 2017)]

◮ Connect L to other models such as recursive functions. ◮ Use L to show “real-word” problems undecidable (e.g.

from logic)

◮ Do further computability theory in L (Turing degrees,

Myhill isomorphism theorem)

◮ Automate correctness proofs including time complexity

[Forster, Kunze (CoqWS 2016)]

https://www.ps.uni-saarland.de/ extras/L-computability/

25

slide-26
SLIDE 26

LINES OF CODE UP TO . . .

What? Lines cumulated Definition of L 400 400 loc Rice’s theorem 500 900 loc Step-indexed interpreter 500 900 loc Full parallel interpreter 300 1200 loc Enumerable ↔ recognisable 600 1500 loc

26