Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Equality of Streams is a Problem Grigore Rosu University of Illinois at Urbana-Champaign.

Similar presentations


Presentation on theme: "1 Equality of Streams is a Problem Grigore Rosu University of Illinois at Urbana-Champaign."— Presentation transcript:

1 1 Equality of Streams is a Problem Grigore Rosu University of Illinois at Urbana-Champaign

2 2 Streams Infinite sequences (of 0,1 bits) 0, 1, 1, 0, 0, 1, … Many applications –Protocols (inputs/outputs) –Lazy functional programming (elegant) Canonical infinite structures –Basic case study for theoretical or algorithmic approaches to infinite state systems Many streams of interest can be defined equationally, with a finite number of equations

3 3 Outline Equational definitions of streams –Stream equality problem Computation as equational deduction Stream equality is  2 0 -hard –Reduction from TOTALITY Stream equality is in  2 0 –Completeness of FOL =

4 4 Equational Definitions of Streams Many practical streams and operations on streams can be defined equationally; e.g. Many languages support such definitions: functional (Haskell), algebraic (Maude), coalgebraic (BOBJ), etc. E 00 11 (01) 

5 5 Given an equational definition of streams E and stream terms str and str’, is it true that E str = str’ E.g: Stream Equality Problem E ? E ?

6 6 On Proving Stream Equality Equational deduction sound, but weak –Cannot show zip(zeros,ones) = blink Ordinary structural induction –Not always sound (constructors for streams?) –Weak, initial model not appropriate zip(zeros,ones) ≠ blink in the initial model Behavioral/observational techniques –Indistinguishability under experiments –Coinduction (Rutten), context induction (Hennicker), circular coinduction (Rosu)

7 7 Circular Coinduction zip(zeros, ones) = blink zip(zeros, ones) = blink 0 = 0zip(ones,zeros) = t(blink) 1 = 1zip(zeros,ones) = blink ht h t Cobasis {h,t} (i.e., experiments with h and t)

8 8 The Temptation … We show that neither of these is possible ! Moreover, we give a precise characterization of the difficulty of this problem Search for “complete” proof systems or algorithms for equality or for inequality of streams …

9 9 What is … P is iff P(k) = (  i)(  j) r(i,j,k) r

10 10 A Complete Problem TOTALITY Input: the k th –Turing machine, or –Partial recursive function Output –Does it halt, or is it total, on any input? (  input i)(  computation j) r(i,j,k) TOTALITY

11 11 TOTALITY: Simpler Version Fix a universal machine U, such that U(1 i 01 k ) runs machine number k on input number i Input –integer k Output –Does U(1 i 01 k ) halt for any integer i ? TOTALITY - simpler -

12 12 Encoding Computation as Equational Deduction - 1 Well known, but involved –Bergstra & Tucker, Nipkow, etc. We give simpler encoding (thanks to streams) –Turing machine M with tape infinite at both ends –Configuations q(L,R) –Add equation q(b’:L, b:R) = q’(L, b’:b:R) when M moves head to left, changing state from q to q’ –q start initial state, q halt halt state; add q halt (L,R) = 1 RL bb’ zeros b:R, b’:L streams

13 13 Encoding Computation as Equational Deduction - 2 Let E M be the equational specification associated to Turing machine M as above Theorem M halts on b 1 b 2 …b n iff E M satisfies q start (zeros, b 1 : b 2 : … : b n : zeros) = 1 We apply it when M is U (the universal TM)

14 14 Stream Equality is Hard - 1 Reduction from TOTALITY Let E U be the equational specification associated to universal Turing machine U Input –integer k Output –Does E U satisfy q start (0 , 1 i 01 k 0  ) = 1 for any i ? TOTALITY - deductive -

15 15 Stream Equality is Hard - 1 Reduction from TOTALITY Let E U be the equational specification associated to universal Turing machine U Input –integer k Output –Does E U satisfy q start (0 , 1 i 01 k 0  ) = 1 for any i ? TOTALITY - deductive -

16 16 Stream Equality is Hard - 2 Define an additional stream operation total?(R) = q start (0 , R) : total?(1:R) Input –integer k Output –Does E U satisfy total?(01 k 0  ) = 1  ? TOTALITY - equational -

17 17 Membership in - 1 Input – specification E and – streams str, str’ Output – Does E satisfy str = str’ ? Stream equality P is iff P(k) = (  i)(  j) r(i,j,k)

18 18 Membership in - 2 Step 1: build FOL = spec E Bit as follows –For each stream = stream’ in E, add r.e. set { hd(tl i (stream)) = hd(tl i (stream’)) | i  N } –Add  (0 = 1) –Add (  b:Bit) b = 0  b = 1 Step 2: prove theorem – E stream-satisfies str = str’ iff – for all i, E Bit satisfies hd(tl i (str)) = hd(tl i (str’)) in FOL= Step 3: conclude – is, by the complete deduction of FOL =

19 19 Conclusion hardness – Reduction from TOTALITY Membership in – Completeness of FOL = Stream Equality is - complete

20 20 What this result tells us No way to automatically –Prove equalities of streams –Prove inequalities of streams …

21 21 Then, what should we do? Should we then stop trying? –NO Instead, develop –Algorithms that work in “practice” –Criteria that filter out “bad” stream definitions For example, what makes the following coinductive proof work?

22 22 Circular Coinduction zip(odd(S), even(S)) = S zip(odd(S), even(S)) = S h(S) = h(S)zip(even(S),even(t(S))) = t(S) h(t(S)) = h(t(S))zip(even(t(S)), even(t(t(S)))) = t(t(S)) ht h t Cobasis {h,t}


Download ppt "1 Equality of Streams is a Problem Grigore Rosu University of Illinois at Urbana-Champaign."

Similar presentations


Ads by Google