Streams with a Bottom in Functional Languages

  • Hideki Tsuiki
  • Keiji Sugihara
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3444)

Abstract

When an infinite sequence contains a bottom cell, we cannot access the rest of the sequence with the ordinary stream access. On the other hand, when we consider an extended stream access with two heads, we can read or write 1\(\bot\)-sequences, which are infinite sequences with at most one bottom cell. In this paper, we present a way of extending a lazy functional language with such an extended stream access in the realm of sequential computation. It has an application in real number computation in that the set of real numbers is topologically embedded in the set of 1 \(\bot\)-sequences [16], and therefore we can consider a program with such an extended stream access as directly manipulating real numbers. We implemented this mechanism by modifying the runtime of the Hugs system, which is a graph-reduction based implementation of the Haskell language. We present programming examples like addition and multiplication on real numbers in this extended Haskell.

For this implementation, we extended Haskell with the gamb operator, which works just as McCarthy’s bottom-avoiding nondeterministic choice operator “amb”. The difference is that it is realized in the realm of sequential computation, and that it is applicable only when the graph representations of the arguments share the same redex. In order to show that programs corresponding to two-head stream accesses satisfy this condition, we introduce a PCF-based calculus of term-graphs and define a data-type of 1 \(\bot\)-streams as a subtype of [Bool].

References

  1. 1.
    Ariola, Z., Felleisen, M., Maraist, J., Odersky, M., Wadler, P.: A Call-by-Need Lambda Calculus. In: Proc. POPL 1995, 22’nd Annual Symposium on Principles of Programming Languages, San Francisco, California, pp. 233–246 (1995)Google Scholar
  2. 2.
    Du Bois, A., Pointon, R., Loidl, H.-W., Trinder, P.: Implementing Declarative Parallel Bottom-Avoiding Choice. In: Proc. 14th Symposium on Computer Architecture and High Performance Computing (2002)Google Scholar
  3. 3.
    Escardó, M.H., Hofmann, M., Streicher, T.: On the non-sequential nature of the interval-domain model of exact real-number computation. Mathematical Structures in Computer Science (to appear)Google Scholar
  4. 4.
    Di Gianantonio, P.: An Abstract Data Type for Real Numbers. Theoretical Computer Science 221, 295–326 (1999)MATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Gray, F.: Pulse code communications. U. S. Patent 2632058 (March 1953)Google Scholar
  6. 6.
    Jones, M.P.: The implementation of the Gofer functional programming system. Research Report YALEU/DCS/RR-1030, Yale University, USA (1994)Google Scholar
  7. 7.
    Peyton Jones, S.L.: The Implementation of Functional Programming Languages. Prentice-Hall, Englewood Cliffs (1987)MATHGoogle Scholar
  8. 8.
    Jones, S.P. (ed.): Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, Cambridge (2003)Google Scholar
  9. 9.
    Kennaway, J.R., Klop, J.W., Sleep, M.R., de Vries, F.J.: An Introduction to Term Graph Rewriting. In: [14]Google Scholar
  10. 10.
    Raymundo Marcial-Romero, J., Escardó, M.H.: Semantics of a Sequential Language for Exact Real-Number Computation. In: Proceedings of the Annual IEEE Symbposium on Logic in Computer Science, pp. 426–435 (2004)Google Scholar
  11. 11.
    McCarthy, J.: A Basis for a Mathematical Theory of Computation. In: Braffort, P., Hirshberg, D. (eds.) Computer Programming and Formal Systems, pp. 33–70. North-Holland, Amsterdam (1963)CrossRefGoogle Scholar
  12. 12.
    Hughes, J., Moran, A.: Making Choices Lazily. In: Conference Record of FPCA 1995, pp. 108–119. ACM Press, New York (1995)Google Scholar
  13. 13.
    Rose, K.H.: Graph-based Operational Semantics of a Lazy Functional Language. In: [14]Google Scholar
  14. 14.
    Sleep, R., Plasmeijer, R., van Eekelen, M. (eds.): Term Graph Rewriting: Theory and Practice. John Wiley & Sons Ltd, Chichester (1993)MATHGoogle Scholar
  15. 15.
    Tsuiki, H.: Computational dimension of topological spaces. In: Blank, J., Brattka, V., Hertling, P. (eds.) CCA 2000. LNCS, vol. 2064, pp. 323–335. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  16. 16.
    Tsuiki, H.: Real number computation through gray code embedding. Theoretical Computer Science 284(2), 467–485 (2002)MATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Tsuiki, H.: Real Number Computation with Committed Choice Logic Programming. Journal of Logic and Algebraic Programming (2004) (to appear)Google Scholar
  18. 18.
  19. 19.
    Weihrauch, K.: Computable analysis, an Introduction. Springer, Heidelberg (2000)MATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Hideki Tsuiki
    • 1
  • Keiji Sugihara
    • 1
  1. 1.Graduate School of Human and Environmental StudiesKyoto UniversityKyotoJapan

Personalised recommendations