# Resource-Passing Concurrent Programming

## Abstract

The use of types to deal with access capabilities of program entities is becoming increasingly popular.

In concurrent logic programming, the first attempt was made in Moded Flat GHC in 1990, which gave polarity structures (modes) to every variable occurrence and every predicate argument. Strong moding turned out to play fundamental rôles in programming, implementation and the in-depthunderstanding of constraint-based concurrent computation.

The moding principle guarantees that each variable is written only once and encourages capability-conscious programming. Furthermore, it gives less generic modes to programs that discard or duplicate data, thus providing the view of “data as resources.” A simple linearity system built upon the mode system distinguishes variables read only once from those read possibly many times, enabling compile-time garbage collection. Compared to linear types studied in other programming paradigms, the primary issue in constraint-based concurrency has been to deal with logical variables and highly non-strict data structures they induce.

In this paper, we put our resource-consciousness one step forward and consider a class of ‘ecological’ programs which recycle or return all the resources given to them while allowing concurrent reading of data structures via controlled aliasing. This completely recyclic subset enforces us to think more about resources, but the resulting programs enjoy high symmetry which we believe has more than aesthetic implications to our programming practice in general.

The type system supporting recyclic concurrent programming gives a [−1, +1] capability to each occurrence of variable and function symbols (constructors), where positive/negative values mean read/write capabilities, respectively, and fractions mean non-exclusive read/write paths. The capabilities are intended to be statically checked or reconstructed so that one can tell the polarity and exclusiveness of each piece of information handled by concurrent processes. The capability type system refines and integrates the mode system and the linearity system for Moded Flat GHC. Its arithmetic formulation contributes to the simplicity.

The execution of a recyclic program proceeds so that every variable has zero-sum capability and the resources (i.e., constructors weighted by their capabilities) a process absorbs match the resources it emits. Constructors accessed by a process withan exclusive read capability can be reused for other purposes.

The first half of this paper is devoted to a tutorial introduction to constraint-based concurrency in the hope that it will encourage crossfertilization of different concurrency formalisms.

## Keywords

Logic Program Mode Graph Logical Variable Mode Constraint Program Clause## Preview

Unable to display preview. Download preview PDF.

## References

- 1.Aït-Kaci, H. and Nasr, R., LOGIN: A Logic Programming Language withBuilt-In Inheritance.
*J. Logic Programming*, Vol. 3, No. 3 (1986), pp. 185–215.CrossRefGoogle Scholar - 2.Ajiro, Y., Ueda, K. and Cho, K., Error-Correcting Source Code. In
*Proc. Fourth Int. Conf. on Principles and Practice of Constraint Programming (CP’98)*, LNCS 1520, Springer-Verlag, 1998, pp. 40–54.Google Scholar - 3.Ajiro, Y. and Ueda, K., Kima: an Automated Error Correction System for Concurrent Logic Programs. To appear in
*Automated Software Engineering*, 2001.Google Scholar - 4.Baker, H. G., Lively Linear Lisp—‘Look Ma, No Garbage!’
*Sigplan Notices*, Vol. 27, No. 8 (1992), pp. 89–98.CrossRefGoogle Scholar - 5.Chikayama, T. and Kimura, Y., Multiple Reference Management in Flat GHC. In
*Logic Programming: Proc. of the Fourth Int. Conf. (ICLP’87)*, The MIT Press, 1987, pp. 276–293.Google Scholar - 6.Chikayama, T., Operating System PIMOS and Kernel Language KL1. In
*Proc. Int. Conf. on Fifth Generation Computer Systems 1992 (FGCS’92)*, Ohmsha and IOS Press, Tokyo, 1992, pp. 73–88.Google Scholar - 7.Chikayama, T., Fujise, T. and Sekita, D., A Portable and Efficient Implementation of KL1. In
*Proc. 6th Int. Symp. on Programming Language Implementation and Logic Programming (PLILP’94)*, LNCS 844, Springer-Verlag, 1994, pp. 25–39.Google Scholar - 8.Clark, K. L. and Gregory, S., PARLOG: Parallel Programming in Logic.
*ACM. Trans. Prog. Lang. Syst.*, Vol. 8, No. 1 (1986), pp. 1–49.zbMATHCrossRefGoogle Scholar - 9.Crary, K. and Weirich, S., Resource Bound Certification. In
*Proc. 27th ACM Symp. on Principles of Programming Languages (POPL’00)*, 2000, pp. 184–198.Google Scholar - 10.Fujita, H. and Hasegawa, R., A Model Generation Theorem Prover in KL1 Using a Ramified-Stack Algorithm. In
*Proc. Eighth Int. Conf. on Logic Programming (ICLP’91)*, The MIT Press, Cambridge, MA, 1991, pp. 535–548.Google Scholar - 11.Fournet, C., Gonthier, G. Lévy, J.-J., Maranget, L. and Rémy, D., A Calculus of Mobile Agents. In
*Proc. 7th Int. Conf. on Concurrency Theory (CONCUR’96)*, LNCS 1119, Springer-Verlag, 1996, pp. 406–421.Google Scholar - 12.Fruhwirth, T., Theory and Practice of Constraint Handling Rules.
*J. Logic Programming*, Vol. 37, No. 1-3 (1998), pp. 95–138.CrossRefMathSciNetGoogle Scholar - 13.Gay, S. and Hole, M., Types and Subtypes for Client-Server Interactions. In
*Proc. European Symp. on Programming (ESOP’99)*, LNCS 1576, Springer-Verlag, 1999, pp. 74–90.Google Scholar - 14.Gudjonsson, G. and Winsborough, W. H., Compile-time Memory Reuse in Logic Programming Languages Through Update in Place.
*ACM Trans. Prog. Lang. Syst,*Vol. 21, No. 3 (1999), pp. 430–501.CrossRefGoogle Scholar - 15.Honda, K. and Tokoro, M., An Object Calculus for Asynchronous Communication. In
*Proc. Fifth Conf. on Object-Oriented Programming (ECOOP’91)*, LNCS 512, Springer-Verlag, 1991, pp. 133–147.CrossRefGoogle Scholar - 16.Hughes, J. and Pareto, L., Recursion and Dynamic Data-structures in Bounded Space: Towards Embedded ML Programming. In
*Proc. Fourth ACM SIGPLAN Int. Conf. on Functional Programming (ICFP’99)*, 1999, pp. 70–81.Google Scholar - 17.Jaffar, J. and Maher, M. J., Constraint Logic Programming: A Survey.
*J. Logic Programming*, Vol. 19-20 (1994), pp. 503–582.CrossRefMathSciNetGoogle Scholar - 18.Kobayashi, N., Quasi-Linear Types In
*Proc. 26th ACM Symp. on Principles of Programming Languages (POPL’99)*, ACM, 1999, pp. 29–42.Google Scholar - 19.Kobayashi, N., Pierce, B. and Turner, D., Linearity and the Pi-Calculus.
*ACM Trans. Prog. Lang. Syst.*, Vol. 21, No. 5 (1999), pp. 914–947.CrossRefGoogle Scholar - 20.Mackie, I., Lilac: A Functional Programming Language Based on Linear Logic.
*J. Functional Programming*, Vol. 4, No. 4 (1994), pp. 1–39.Google Scholar - 21.Mazur, N., Janssens, G. and Bruynooghe, M., A Module Based Analysis for Memory Reuse in Mercury. In
*Proc. Int. Conf. on Computational Logic (CL2000)*, LNCS 1861, Springer-Verlag, 2000, pp. 1255–1269.Google Scholar - 22.Merro, M., Locality in the
*π*-calculus and Applications to Distributed Objects. PhD Thesis, Ecol des Mines de Paris, 2000.Google Scholar - 23.Miller, D., A Survey on Linear Logic Programming.
*The Newsletter of the European Network in Computational Logic*, Vol. 2, No. 2 (1995), pp.63–67.Google Scholar - 24.Niehren, J. and Müller, M., Constraints for Free in Concurrent Computation. In
*Proc. Asian Computing Science Conf. (ACSC’95)*, LNCS 1023, Springer-Verlag, 1995, pp. 171–186.Google Scholar - 25.Sakamoto, K., Matsumiya, S. and Ueda, K., Optimizing Array Processing of Parallel KLIC. In
*IPSJ Trans. on Programming*, Vol. 42, No. SIG 3(PRO 10) (2001), pp. 1–13 (in Japanese).Google Scholar - 26.Sangiorgi, D.,
*π*-Calculus, Internal Mobility and Agent-Passing Calculi.*Theoretical Computer Science*, Vol. 167, No. 1-2 (1996), pp. 235–274.zbMATHCrossRefMathSciNetGoogle Scholar - 27.Saraswat, V. A., Kahn, K. and Levy, J., Janus: A Step Towards Distributed Constraint Programming. In
*Proc. 1990 North American Conf. on Logic Programming (NACLP’90)*, The MIT Press, Cambridge, MA, 1990, pp. 431–446.Google Scholar - 28.Saraswat, V. A. and Rinard, M., Concurrent Constraint Programming (Extended Abstract). In
*Proc. 17th Annual ACM Symp. on Principles of Programming Languages (POPL’90)*, ACM, 1990, pp. 232–245.Google Scholar - 29.Sastry, A. V. S. and Clinger, W., Parallel Destructive Updating in Strict Functional Languages. In
*Proc. 1994 ACM Conf. on LISP and Functional Programming*, 1994, pp. 263–272.Google Scholar - 30.Shapiro, E. Y., Concurrent Prolog: A Progress Report.
*IEEE Computer*, Vol. 19, No. 8 (1986), pp. 44–58.Google Scholar - 31.Shapiro, E., The Family of Concurrent Logic Programming Languages.
*ACM Computing Surveys*, Vol. 21, No. 3 (1989), pp. 413–510.CrossRefGoogle Scholar - 32.Shapiro, E. Y., Warren, D. H. D., Fuchi, K., Kowalski, R. A., Furukawa, K., Ueda, K., Kahn, K. M., Chikayama, T. and Tick, E., The Fifth Generation Project: Personal Perspectives.
*Comm. ACM*, Vol. 36, No. 3 (1993), pp. 46–103.CrossRefGoogle Scholar - 33.Smolka, G., A Foundation for Higher-order Concurrent Constraint Programming. In
*Proc. First Int. Conf. on Constraints in Computational Logics*, LNCS 845, Springer-Verlag, 1994, pp. 50–72.CrossRefGoogle Scholar - 34.Somogyi, Z., Henderson, F. and Conway, T., The Execution Algorithm of Mercury, An Efficient Purely Declarative Logic Programming Language.
*J. Logic Programming*, Vol. 29, No. 1-3 (1996), pp. 17–64.zbMATHCrossRefGoogle Scholar - 35.Turner, D. N., Wadler, P. and Mossin, C., Once Upon a Type. In
*Proc. Seventh Int. Conf. on Functional Programming Languages and Computer Architecture (FPCA’95)*, ACM, 1995, pp. 1–11.Google Scholar - 36.Ueda, K., Guarded Horn Clauses. ICOT Tech. Report TR-103, ICOT, Tokyo, 1985. Also in
*Logic Programming’ 85*, Wada, E. (ed.), LNCS 221, Springer-Verlag, 1986, pp. 168–179.Google Scholar - 37.Ueda, K., Guarded Horn Clauses. D. Eng. Thesis, Univ. of Tokyo, 1986.Google Scholar
- 38.Ueda, K. and Furukawa, K., Transformation Rules for GHC Programs. In
*Proc. Int. Conf. on Fifth Generation Computer Systems 1988 (FGCS’88)*, ICOT, Tokyo, 1988, pp. 582–591.Google Scholar - 39.Ueda, K. and Chikayama, T. Design of the Kernel Language for the Parallel Inference Machine.
*The Computer Journal*, Vol. 33, No. 6 (1990), pp. 494–500.CrossRefMathSciNetGoogle Scholar - 40.Ueda, K. and Morita, M., Message-Oriented Parallel Implementation of Moded Flat GHC.
*New Generation Computing*, Vol. 11, No. 3-4 (1993), pp. 323–341.Google Scholar - 41.Ueda, K. and Morita, M., Moded Flat GHC and Its Message-Oriented Implementation Technique.
*New Generation Computing*, Vol. 13, No. 1 (1994), pp. 3–43.CrossRefGoogle Scholar - 42.Ueda, K., Moded Flat GHC for Data-Parallel Programming. In
*Proc. FGCS’94 Workshopon Parallel Logic Programming*, ICOT, Tokyo, 1994, pp. 27–35.Google Scholar - 43.Ueda, K., Experiences withStrong Moding in Concurrent Logic/Constraint Programming. In
*Proc. Int. Workshopon Parallel Symbolic Languages and Systems (PSLS’95)*, LNCS 1068, Springer-Verlag, 1996, pp. 134–153.CrossRefGoogle Scholar - 44.Ueda, K.,
*klint*-Static Analyzer for KL1 Programs. Available from http://www.icot.or.jp/ARCHIVE/Museum/FUNDING/funding-98-E.html, 1998. - 45.Ueda, K., Concurrent Logic/Constraint Programming: The Next 10 Years. In
*The Logic Programming Paradigm: A 25-Year Perspective*, Apt, K. R., Marek, V. W., Truszczynski M., and Warren D. S. (eds.), Springer-Verlag, 1999, pp. 53–71.Google Scholar - 46.Ueda, K., Linearity Analysis of Concurrent Logic Programs. In
*Proc. Int. Workshop on Parallel and Distributed Computing for Symbolic and Irregular Applications*, Ito, T. and Yuasa, T. (eds.), World Scientific, 2000, pp. 253–270.Google Scholar - 47.van Emden, M. H. and de Lucena Filho, G. J., Predicate Logic as a Language for Parallel Programming. In
*Logic Programming*, Clark, K. L. and Tarnlund, S.-Å. (eds.), Academic Press, London, 1982, pp. 189–198.Google Scholar - 48.Victor, B., The Fusion Calculus: Expressiveness and Symmetry in Mobile Processes, PhD Thesis, Uppsala Univ., 1998.Google Scholar
- 49.Wadler, P., Linear Types Can Change theWorld! In
*Prof. IFIP TC2 Working Conf. on Programming Concepts and Methods*, Broy, M. and Jones, C. (eds.), North-Holland, 1990, pp. 347–359.Google Scholar - 50.Walker, D. P., Typed Memory Management. PhD thesis, Cornell Univ., 2001.Google Scholar