From Farkas' Lemma to Linear Programming: an Exercise in Diagrammatic Algebra ((Co)algebraic pearls)

Authors Filippo Bonchi , Alessandro Di Giorgio , Fabio Zanasi

Thumbnail PDF


  • Filesize: 0.88 MB
  • 19 pages

Document Identifiers

Author Details

Filippo Bonchi
  • University of Pisa, Italy
Alessandro Di Giorgio
  • University of Pisa, Italy
Fabio Zanasi
  • University College London, UK

Cite AsGet BibTex

Filippo Bonchi, Alessandro Di Giorgio, and Fabio Zanasi. From Farkas' Lemma to Linear Programming: an Exercise in Diagrammatic Algebra ((Co)algebraic pearls). In 9th Conference on Algebra and Coalgebra in Computer Science (CALCO 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 211, pp. 9:1-9:19, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2021)


Farkas' lemma is a celebrated result on the solutions of systems of linear inequalities, which finds application pervasively in mathematics and computer science. In this work we show how to formulate and prove Farkas' lemma in diagrammatic polyhedral algebra, a sound and complete graphical calculus for polyhedra. Furthermore, we show how linear programs can be modeled within the calculus and how some famous duality results can be proved.

Subject Classification

ACM Subject Classification
  • Theory of computation → Categorical semantics
  • String diagrams
  • Farkas Lemma
  • Duality
  • Linear Programming


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. David Avis and Bohdan Kaluzny. Solving inequalities and proving Farkas’s lemma made easy. The American Mathematical Monthly, 111(2):152-157, 2004. Google Scholar
  2. John C Baez and Jason Erbele. Categories in control. Theory and Applications of Categories, 30(24):836-881, 2015. Google Scholar
  3. David Bartl. A short algebraic proof of the Farkas lemma. SIAM Journal on Optimization, 19(1):234-239, 2008. Google Scholar
  4. Dimitri P Bertsekas. Nonlinear programming. Journal of the Operational Research Society, 48(3):334-334, 1997. Google Scholar
  5. Guillaume Boisseau, Filippo Bonchi, Alessandro Di Giorgio, and Pawel Sobocinski. Diagrammatic polyhedral algebra, 2021. URL:
  6. Filippo Bonchi, Joshua Holland, Robin Piedeleu, Paweł Sobociński, and Fabio Zanasi. Diagrammatic algebra: from linear to concurrent systems. Proceedings of the 46th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 3:1-28, 2019. Google Scholar
  7. Filippo Bonchi, Robin Piedeleu, Paweł Sobociński, and Fabio Zanasi. Graphical affine algebra. In Proceedings of the 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), pages 1-12, 2019. Google Scholar
  8. Filippo Bonchi, Paweł Sobociński, and Fabio Zanasi. A categorical semantics of signal flow graphs. In Proceedings of the 25th International Conference on Concurrency Theory (CONCUR), pages 435-450. Springer, 2014. Google Scholar
  9. Filippo Bonchi, Pawel Sobocinski, and Fabio Zanasi. The calculus of signal flow diagrams I: linear relations on streams. Information and Computation, 252:2-29, 2017. Google Scholar
  10. CG Broyden. A simple algebraic proof of Farkas’s lemma and related theorems. Optimization methods and software, 8(3-4):185-199, 1998. Google Scholar
  11. Roberto Bruni, Ivan Lanese, and Ugo Montanari. A basic algebra of stateless connectors. Theoretical Computer Science, 366(1-2):98-120, 2006. Google Scholar
  12. Bob Coecke and Ross Duncan. Interacting quantum observables: categorical algebra and diagrammatics. New Journal of Physics, 13(4):043016, 2011. Google Scholar
  13. Bob Coecke and Aleks Kissinger. Picturing Quantum Processes - A first course in Quantum Theory and Diagrammatic Reasoning. Cambridge University Press, 2017. Google Scholar
  14. René David and Hassane Alla. Discrete, Continuous, and Hybrid Petri Nets. Springer, Berlin, 2 edition, 2010. URL:
  15. Achiya Dax. An elementary proof of Farkas' lemma. SIAM Review, 39(3):503-507, 1997. URL:
  16. Gyula Farkas. A Fourier-féle mechanikai elv alkalmazásának algebrai alapja [hungarian; on the algebraic foundation of the applications of the mechanical principle of Fourier]. Mathematikai és Physikai Lapok, 5:49-54, 1896. Google Scholar
  17. J. Farkas. Theorie der einfachen ungleichungen. Journal für die reine und angewandte Mathematik (Crelles Journal), 1902:1-27, 1902. Google Scholar
  18. Brendan Fong, Paolo Rapisarda, and Paweł Sobociński. A categorical approach to open and interconnected dynamical systems. In LICS 2016, 2016. Google Scholar
  19. Brendan Fong and David I. Spivak. String diagrams for regular logic (extended abstract). In John Baez and Bob Coecke, editors, Proceedings Applied Category Theory 2019, ACT 2019, University of Oxford, UK, 15-19 July 2019, volume 323 of EPTCS, pages 196-229, 2019. URL:
  20. David Gale, Harold W Kuhn, and Albert W Tucker. Linear programming and the theory of games. Activity analysis of production and allocation, 13:317-335, 1951. Google Scholar
  21. Dan R Ghica and Achim Jung. Categorical semantics of digital circuits. In Proceedings of the 16th Conference on Formal Methods in Computer-Aided Design (FMCAD), pages 41-48, 2016. Google Scholar
  22. RA Good. Systems of linear relations. SIAM Review, 1(1):1-31, 1959. Google Scholar
  23. Alexandre Goy and Daniela Petrisan. Combining probabilistic and non-deterministic choice via weak distributive laws. In Holger Hermanns, Lijun Zhang, Naoki Kobayashi, and Dale Miller, editors, LICS '20: 35th Annual ACM/IEEE Symposium on Logic in Computer Science, Saarbrücken, Germany, July 8-11, 2020, pages 454-464. ACM, 2020. URL:
  24. Murray C Kemp and Yoshio Kimura. Introduction to mathematical economics. Technical report, Springer, 1978. Google Scholar
  25. Vilmos Komornik. A simple proof of Farkas' lemma. The American Mathematical Monthly, 105(10):949-950, 1998. URL:
  26. Stephen Lack. Composing PROPs. Theory and Application of Categories, 13(9):147-163, 2004. Google Scholar
  27. Saunders Mac Lane. Categorical algebra. Bulletin of the American Mathematical Society, 71:40-106, 1965. Google Scholar
  28. Olvi L Mangasarian. Nonlinear programming. SIAM, 1994. Google Scholar
  29. Koko Muroya, Steven W. T. Cheung, and Dan R. Ghica. The geometry of computation-graph abstraction. In Anuj Dawar and Erich Grädel, editors, Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2018, Oxford, UK, July 09-12, 2018, pages 749-758. ACM, 2018. URL:
  30. Hukukane Nikaido. Convex structures and economic theory. Elsevier, 2016. Google Scholar
  31. Martin H. Pearl. A matrix proof of Farkas’s Theorem. The Quarterly Journal of Mathematics, 18(1):193-197, January 1967. URL:
  32. Robin Piedeleu and Fabio Zanasi. A string diagrammatic axiomatisation of finite-state automata. In FoSSaCS 2021, 2021. Google Scholar
  33. Peter Selinger. A survey of graphical languages for monoidal categories. Springer Lecture Notes in Physics, 13(813):289-355, 2011. Google Scholar
  34. Claude E. Shannon. The theory and design of linear differential equation machines. Technical report, National Defence Research Council, 1942. Google Scholar
  35. Robert J Vanderbei et al. Linear programming, volume 3. Springer, 2015. Google Scholar
  36. Fabio Zanasi. Interacting Hopf Algebras: the theory of linear systems. PhD thesis, Ecole Normale Supérieure de Lyon, 2015. Google Scholar
  37. Fabio Zanasi. The algebra of partial equivalence relations. Electronic Notes in Theoretical Computer Science, 325:313-333, 2016. Google Scholar