1 / 22

Equality of Streams is a Problem

Equality of Streams is a Problem. Grigore Rosu University of Illinois at Urbana-Champaign. 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

mspeer
Download Presentation

Equality of Streams is a Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. Outline • Equational definitions of streams • Stream equality problem • Computation as equational deduction • Stream equality is 20-hard • Reduction from TOTALITY • Stream equality is in20 • Completeness of FOL=

  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. 0 E 1 (01)

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

  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. h t t h Circular Coinductionzip(zeros, ones) = blink Cobasis {h,t} (i.e., experiments with h and t) zip(zeros, ones) = blink 0 = 0 zip(ones,zeros) = t(blink) 1 = 1 zip(zeros,ones) = blink

  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. What is … r P is iff P(k) = (i)(j) r(i,j,k)

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

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

  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) whenMmoves head to left, changing state fromqtoq’ • qstart initial state, qhalt halt state; add qhalt(L,R) = 1 zeros zeros b’ b L R b:R, b’:L streams

  13. Encoding Computation as Equational Deduction - 2 • Let EM be the equational specification associated to Turing machine M as above Theorem M halts on b1b2…bn iff EMsatisfies qstart(zeros, b1 : b2 : … : bn : zeros) = 1 • We apply it whenMisU(the universal TM)

  14. Stream Equality is Hard - 1 • Reduction from TOTALITY • Let EU be the equational specification associated to universal Turing machine U Input • integerk Output • Does EUsatisfy qstart(0, 1i01k0) = 1 for any i ? TOTALITY - deductive -

  15. Stream Equality is Hard - 1 • Reduction from TOTALITY • Let EU be the equational specification associated to universal Turing machine U Input • integerk Output • Does EUsatisfy qstart(0, 1i01k0) = 1 for any i ? TOTALITY - deductive -

  16. Stream Equality is Hard - 2 • Define an additional stream operation total?(R) = qstart(0, R) : total?(1:R) Input • integerk Output • Does EUsatisfy total?(01k0) = 1 ? TOTALITY - equational -

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

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

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

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

  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. h t t h Circular Coinductionzip(odd(S), even(S)) = S Cobasis {h,t} 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))

More Related