Skip to main content

Programming in Picat

  • Conference paper
  • First Online:
  • 2303 Accesses

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 9718))

Abstract

Picat (picat-lang.org) is a logic-based multi-paradigm programming language that integrates logic programming, functional programming, constraint programming, and scripting. Picat takes many features from other languages, including logic variables, unification, backtracking, pattern-matching rules, functions, list/array comprehensions, loops, assignments, tabling for dynamic programming and planning, and constraint solving with CP (constraint programming), SAT (satisfiability), and MIP (mixed integer programming). These features make Picat more convenient than Prolog for scripting and modeling, and more suitable than functional languages (such as Haskell and F#) and scripting languages (such as Python and Ruby) for symbolic computations. This article provides a quick introduction to Picat using examples from Google Code Jam (GCJ).

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    https://code.google.com/codejam/contest/351101/dashboard#s=p0.

  2. 2.

    https://code.google.com/codejam/contest/32016/dashboard#s=p0.

  3. 3.

    The minof predicate, which takes another predicate call as the first argument, is called a higher-order predicate. Picat provides several higher-order built-ins. For example, maxof( Goal,Exp ), find_all( Template,Goal ), and count_all( Goal ).

  4. 4.

    The function permutations( L ), which is defined in the util module, returns a list of permutations of L.

  5. 5.

    https://code.google.com/codejam/contest/32003/dashboard#s=p0.

  6. 6.

    https://code.google.com/codejam/contest/90101/dashboard#s=p0&a=1.

  7. 7.

    Picat does not issue singleton variable warnings for variable names that begin with the underscore _.

  8. 8.

    https://code.google.com/codejam/contest/32003/dashboard#s=p2.

References

  1. Appa, G.M., Pitsoulis, L., Springer, H., Williams, P.: Handbook on Modelling for Discrete Optimization. International Series in Operations Research & Management Science. Springer, New York (2010)

    Google Scholar 

  2. Armstrong, J.: Programming Erlang, 2nd edn. Pragmatic Press, Dallas (2013)

    Google Scholar 

  3. Barták, R., Dovier, A., Zhou, N.-F.: On modeling planning problems in tabled logic programming. In: Proceedings of the 17th ACM International Symposium on Principles and Practice of Declarative Programming, PPDP 2015, pp. 31–42 (2015)

    Google Scholar 

  4. Colmerauer, A.: Equations and inequations on finite and infinite trees. In: Proceedings of FGCS, pp. 85–99. ICOT (1984)

    Google Scholar 

  5. Debray, S.K.: Static inference of modes and data dependencies in logic programs. ACM Trans. Program. Lang. Syst. 11(3), 418–450 (1989)

    Article  Google Scholar 

  6. Dymchenko, S., Mykhailova, M.: Declaratively solving Google Code Jam problems with Picat. In: Pontelli, E., Son, T.C. (eds.) PADL 2015. LNCS, vol. 9131, pp. 50–57. Springer, Heidelberg (2015)

    Chapter  Google Scholar 

  7. Hanus, M.: Functional logic programming: from theory to Curry. In: Voronkov, A., Weidenbach, C. (eds.) Programming Logics. LNCS, vol. 7797, pp. 123–168. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  8. Van Hentenryck, P.: Constraint and integer programming in OPL. INFORMS J. Comput. 14, 345–372 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  9. Kowalski, R., Kuehner, D.: Linear resolution with selection function. Artif. Intell. 2(3–4), 227–260 (1971)

    Article  MathSciNet  MATH  Google Scholar 

  10. Malik, S., Zhang, L.: Boolean satisfiability: from theoretical hardness to practical success. Commun. ACM 52(8), 76–82 (2009)

    Article  Google Scholar 

  11. Nethercote, N., Stuckey, P.J., Becket, R., Brand, S., Duck, G.J., Tack, G.: MiniZinc: towards a standard CP modelling language. In: CP, pp. 529–543 (2007)

    Google Scholar 

  12. Rossi, F., van Beek, P., Walsh, T.: Handbook of Constraint Programming. Elsevier, Amsterdam (2006)

    MATH  Google Scholar 

  13. Van Roy, P., Haridi, S.: Concepts, Techniques, and Models of Computer Programming. MIT Press, Cambridge (2004)

    Google Scholar 

  14. Schimpf, J.: Logical loops. In: Stuckey, P.J. (ed.) ICLP 2002. LNCS, vol. 2401, pp. 224–238. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  15. Warren, D.S.: Memoing for logic programs. Commun. ACM, Special Sect. Logic Program. 35, 93–111 (1992)

    MathSciNet  Google Scholar 

  16. Zhou, N.-F.: The language features and architecture of B-Prolog. Theory Pract. Logic Program., Special Issue Prolog Syst. 12(1–2), 189–218 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  17. Zhou, N.-F., Bartak, R., Dovier, A.: Planning as tabled logic programming. Theory Pract. Logic Program. 15, 543–558 (2015)

    Article  MathSciNet  Google Scholar 

  18. Zhou, N.-F., Fruhman, J.: A User’s Guide to Picat. http://picat-lang.org

  19. Zhou, N.-F., Have, C.T.: Efficient tabling of structured data with enhanced hash-consing. Theory Pract. Logic Program. 12(4–5), 547–563 (2012)

    Article  MATH  Google Scholar 

  20. Zhou, N.-F., Kjellerstrand, H.: The Picat-SAT compiler. In: Gavanelli, M., Reppy, J. (eds.) PADL 2016. LNCS, vol. 9585, pp. 48–62. Springer, Heidelberg (2016). doi:10.1007/978-3-319-28228-2_4

    Chapter  Google Scholar 

  21. Zhou, N.-F., Kjellerstrand, H., Fruhman, J.: Constraint Solving and Planning with Picat. SpringerBriefs in Intelligent Systems. Springer, Heidelberg (2015)

    Book  Google Scholar 

  22. Zhou, N.-F., Sato, T., Shen, Y.-D.: Linear tabling strategies and optimizations. Theory Pract. Logic Program. 8(1), 81–109 (2008)

    MathSciNet  MATH  Google Scholar 

Download references

Acknowledgement

The author would like to thank Sergii Dymchenko for bring GCJ to his attention, and the following people for giving very helpful comments on early drafts of this article: Roman Barták, Peter Bernschneider, Mike Bionchik, Jonathan Fruhman, Håkan Kjellerstrand, Annie Liu, Claudio Cesar de Sá, and Bo Yuan (Bobby) Zhou.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Neng-Fa Zhou .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Zhou, NF. (2016). Programming in Picat. In: Alferes, J., Bertossi, L., Governatori, G., Fodor, P., Roman, D. (eds) Rule Technologies. Research, Tools, and Applications. RuleML 2016. Lecture Notes in Computer Science(), vol 9718. Springer, Cham. https://doi.org/10.1007/978-3-319-42019-6_1

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-42019-6_1

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-42018-9

  • Online ISBN: 978-3-319-42019-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics