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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
- 2.
- 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.
The function permutations( L ), which is defined in the util module, returns a list of permutations of L.
- 5.
- 6.
- 7.
Picat does not issue singleton variable warnings for variable names that begin with the underscore _.
- 8.
References
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)
Armstrong, J.: Programming Erlang, 2nd edn. Pragmatic Press, Dallas (2013)
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)
Colmerauer, A.: Equations and inequations on finite and infinite trees. In: Proceedings of FGCS, pp. 85–99. ICOT (1984)
Debray, S.K.: Static inference of modes and data dependencies in logic programs. ACM Trans. Program. Lang. Syst. 11(3), 418–450 (1989)
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)
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)
Van Hentenryck, P.: Constraint and integer programming in OPL. INFORMS J. Comput. 14, 345–372 (2002)
Kowalski, R., Kuehner, D.: Linear resolution with selection function. Artif. Intell. 2(3–4), 227–260 (1971)
Malik, S., Zhang, L.: Boolean satisfiability: from theoretical hardness to practical success. Commun. ACM 52(8), 76–82 (2009)
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)
Rossi, F., van Beek, P., Walsh, T.: Handbook of Constraint Programming. Elsevier, Amsterdam (2006)
Van Roy, P., Haridi, S.: Concepts, Techniques, and Models of Computer Programming. MIT Press, Cambridge (2004)
Schimpf, J.: Logical loops. In: Stuckey, P.J. (ed.) ICLP 2002. LNCS, vol. 2401, pp. 224–238. Springer, Heidelberg (2002)
Warren, D.S.: Memoing for logic programs. Commun. ACM, Special Sect. Logic Program. 35, 93–111 (1992)
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)
Zhou, N.-F., Bartak, R., Dovier, A.: Planning as tabled logic programming. Theory Pract. Logic Program. 15, 543–558 (2015)
Zhou, N.-F., Fruhman, J.: A User’s Guide to Picat. http://picat-lang.org
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)
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
Zhou, N.-F., Kjellerstrand, H., Fruhman, J.: Constraint Solving and Planning with Picat. SpringerBriefs in Intelligent Systems. Springer, Heidelberg (2015)
Zhou, N.-F., Sato, T., Shen, Y.-D.: Linear tabling strategies and optimizations. Theory Pract. Logic Program. 8(1), 81–109 (2008)
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
Corresponding author
Editor information
Editors and Affiliations
Rights 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)