Skip to main content
Log in

Contract as automaton: representing a simple financial agreement in computational form

  • Original Research
  • Published:
Artificial Intelligence and Law Aims and scope Submit manuscript

Abstract

We show that the fundamental legal structure of a well-written financial contract follows a state-transition logic that can be formalized mathematically as a finite-state machine (specifically, a deterministic finite automaton or DFA). The automaton defines the states that a financial relationship can be in, such as “default,” “delinquency,” “performing,” etc., and it defines an “alphabet” of events that can trigger state transitions, such as “payment arrives,” “due date passes,” etc. The core of a contract describes the rules by which different sequences of events trigger particular sequences of state transitions in the relationship between the counterparties. By conceptualizing and representing the legal structure of a contract in this way, we expose it to a range of powerful tools and results from the theory of computation. These allow, for example, automated reasoning to determine whether a contract is internally coherent and whether it is complete relative to a particular event alphabet. We illustrate the process by representing a simple loan agreement as an automaton.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2

Similar content being viewed by others

Notes

  1. There are many excellent textbook treatments of the theory of computation and finite state machines, including Sipser (2006), Kozen (1997), and Rosenberg (2010). For an overview, see the lectures by Simonson (2013).

  2. Kuhn (2014) surveys numerous “controlled natural languages.” Among these is one form of legalese, namely the “Massachusetts Legislative Drafting Language”.

  3. The notion of the “happy path” comes from the world of software testing, where it refers to the primary software execution path that provides the core required functionality and does not provide for error handling or other exceptional events. In other words, the happy path is the sequence executed when everything goes as expected (Software Engineering Institute 2009).

  4. There are several alternative representations with expressiveness equivalent to the deterministic finite automaton (DFA). We discuss tabular, graphical, and regular expression presentations below. In addition, any DFA can be converted to an equivalent nondeterministic finite automaton (NFA), and vice versa, as a programmatic exercise. The NFA representation adds a layer of abstraction, but is typically more compact than the corresponding DFA; see Sipser (2006), section 1.2. More expressive computational models include pushdown automata (Sipser 2006, 109ff) and Turing machines (Sipser 2006, 137ff).

  5. This is a cosmetic simplification. One could add states to the deterministic finite automaton (DFA) to handle “product events” representing the simultaneous occurrence of two or more default triggers. This would proliferate states in the model, but without adding sophistication beyond that expressible by a DFA.

  6. To emphasize that this is a DFA, Fig. 2 presents the state-transition diagram again with traditional DFA notation, where, the node labels match the “State” column in Table 2, and the edge labels match the “ID” column in Table 3.

  7. The Myhill-Nerode property is essentially a non-stochastic equivalent of the first-order Markov property; in other words, a first-order Markov chain is the probabilistic counterpart of a deterministic finite automaton (DFA). In particular, the characteristic memorylessness of a Markov chain also applies here, even though the DFA is a non-random process. For a detailed discussion of the Myhill-Nerode property and its implications, see Rosenberg (2010), especially chapters 4–5.

  8. Separately, there is a practical challenge of synchronizing distributed state in a contractual relationship. Financial contracts typically specify events to facilitate unilateral verification by any of the parties. For example, “Deliver amount X to bank B on or before date T.” However, contracts will define a messaging protocol, such as a notification-and-cure process, for ambiguous situations where unilateral verification fails for some reason.

  9. Von der Lieth Gardner (1987, chapter 6) refers to self-transitions as “ineffective events.” Knowing when to ignore events, rather than reject (for example, by triggering a back-office investigation), is an important judgment call for contract drafters and implementers. For example, expiration of the statute of limitations with respect to the obligations of the borrower (event E in Table 3) before delivery of the principal (event F) is a physical impossibility, so there is little point in developing error-handling procedures for this case. On the other hand, multiple occurrences of event F in quick succession would be a plausible clerical error, and a rejection procedure might be appropriate to handle this case.

  10. For an introduction to regular expressions, see Friedl (2006). For a more technical introduction, see Aho and Ullman (1995, chapter 10). Hopcroft et al. (2001), section 3.3, offer an overview of the Unix syntax for regular expressions. Implementations of regular expression parsers frequently augment the functionality with features such as grouping and backtracking to make them more powerful than “pure” regular languages. We ignore these possible extensions here.

  11. For an introduction to the translation between deterministic finite automatons (DFAs) and regular expressions, see Sipser (2006), section 1.3. For a deeper discussion, see Rosenberg (2010), especially section 5.2.

  12. For a more detailed introduction to the state-elimination method, see Hopcroft et al. (2001), section 3.2; or Sipser (2006), pp. 66–76. Hopcroft et al. (2001) describe two general methods for the DFA-to-regular expressions conversion, namely path induction and state elimination. The two methods are equivalent in the sense of producing equivalent regular expressions.

  13. One might object that, because a deterministic finite automaton’s (DFA) state transition network and its regular expression are generally not unique, the complexity score is arbitrary. This objection is ill-founded, however, because there are programmatic techniques to reduce any DFA to a theoretical minimum state-transition network and standard techniques for representing any given DFA as a regular expression.

  14. The Basel Committee on Banking Supervision (BCBS) (2013) identifies risk data aggregation as a key challenge for financial institutions. A more recent update notes that “none of the banks are fully compliant with the BCBS 239 principles, as attaining the necessary data architecture and IT infrastructure remains a challenge for many” (BCBS 2020, p. 1).

  15. Multiple responses to the same event appear to be a contradiction in terms. However, the multiple transitions are not to be taken literally. Instead, the NFA is a modeling abstraction with identical expressiveness to the DFA, but which is typically more concise. See Sipser (2006, chapter 1) for further discussion.

  16. Turing-completeness is a statement about the expressiveness of a programming language. Roughly, a language is Turing-complete if any computable function can be written in that language. In other words, the language can describe any computation that might performed by the broadest class of computers, known as Turing machines, Most familiar programming languages, such as C++, Java, or Python are Turing-complete.

  17. The need for adequate specification of the external events and internal logic of a contract is reflected in the broadly recognized principle of Anglo-American law that courts will not grant enforcement to contracts that constitute “agreements to agree.” In Delaware state courts, for instance, “a valid contract exists when (1) the parties intended that the contract would bind them, (2) the terms of the contract are sufficiently definite, and (3) the parties exchange legal consideration.” Osborn ex rel. Osborn v. Kemp, 991 A.2d 1153, 1158 (Del. 2010).

  18. For an introduction to computational logics and formal semantics, see Huth and Ryan (2004).

  19. At the implementation level, many contracts will also involve some calculation chores, such as determining precise payment amounts, sorting through holiday calendars and day-count conventions, etc. The streamlined agreement elides these considerations by explicitly stating precise dates and dollar amounts. In general, these sorts of calculations would and should typically be the implementation details of some delegated subsystem.

  20. Transducers are widely used in control systems, including computer hardware design, and in computational linguistics. The control applications are closer to our case of computable contracts; see Mueller and Paul (2000). There are two general classes of finite-state transducers—Moore machines and Mealy machines—that differ essentially in whether outputs can (Mealy) or cannot (Moore) depend on the input event that triggered the transition. See Moore (1956), and Mealy (1955).

  21. Computer systems designers worry actively about the problem of state space explosion (i.e., proliferation). See for example Baier and Katoen (2008), especially chapter 2.

References

  • Aho AV, Ullman JD (1995) Foundations of computer science. Computer Science Press

    MATH  Google Scholar 

  • Allen L (1957) Symbolic logic: a razor-edged tool for drafting and interpreting legal documents. Yale Law J 66:833–879

    Article  Google Scholar 

  • Azzopardi S, Pace G, Schapachnik F, Schneider G (2016) Contract automata: an operational view of contracts between interactive parties. Artif Intell Law 24:203–243

    Article  Google Scholar 

  • Baier C, Katoen J (2008) Principles of model checking. MIT Press

    MATH  Google Scholar 

  • Basel Committee on Banking Supervision (2013) Principles for effective risk data aggregation and risk reporting, January. http://www.bis.org/publ/bcbs239.htm

  • Basel Committee on Banking Supervision (2020) Progress in adopting the Principles for effective risk data aggregation and risk reporting, April. https://www.bis.org/bcbs/publ/d501.htm

  • Bolton P, Dewatripont M (2005) Contract theory. MIT Press

    Google Scholar 

  • Borselli A (2020) Smart contracts in insurance: a law and futurology perspective. In: Marano P, Noussia K (eds) InsurTech: a legal and regulatory view. AIDA Europe research series on insurance law and regulation, vol 1. Springer

    Google Scholar 

  • Brammertz W, Akkizidis I, Breymann W, Entin R, Rustmann M (2009) Unified financial analysis: the missing links of finance. Wiley

    Google Scholar 

  • Brose MS, Flood MD, Krishna D, Nichols B (2014a) Handbook of financial data and risk information vol I: principles and context. Cambridge University Press

    Book  Google Scholar 

  • Brose MS, Flood MD, Krishna D, Nichols B (2014b) Handbook of Financial data and risk information, vol II software and data. Cambridge University Press, II

    Google Scholar 

  • Clack C (2018) Smart contract templates: legal semantics and code validation. J Digit Bank 2(4):338–352

    Google Scholar 

  • Clack C (2021) Languages for smart and computable contracts. Working paper, University College London, https://arxiv.org/abs/2104.03764

  • Clark C (2011) Whither equity volumes? January 31, 2011. NYSE Exchanges. http://exchanges.nyx.com/cclark/whither-equity-volumes

  • Cummins J, Clack C (2020) Transforming commercial contracts through computable contracting. Working Paper, University College London, https://arxiv.org/abs/2003.10400

  • Dimishkovska A (2017) Deontic logic and legal rules. In: Sellers M, Kirste S (eds) Encyclopedia of the philosophy of law and social philosophy. Springer

    Google Scholar 

  • Flood M, Mendelowitz A, Nichols W (2013) Monitoring financial stability in a complex world. In: Lemieux V (ed) Financial analysis and risk management: data governance, analytics and life cycle management. Springer, pp 15–46

    Chapter  Google Scholar 

  • Foreign Exchange Committee (1997) The 1997 International Foreign Exchange Master Agreement (IFEMA). Technical Report, Federal Reserve Bank of New York. Accessed 12 December 2014.

  • Friedl JEF (2006) Mastering regular expressions, 3rd edn. O’Reilly

    Google Scholar 

  • Gasarch W (2014) Classifying problems into complexity classes. Adv Comput 95:239–292

    Article  Google Scholar 

  • Genesereth M, Chaudhri VK (2020) Introduction to logic programming. Morgan & Claypool

    Book  Google Scholar 

  • Genesereth MR, Greiner R, Smith DE (1981) MRS manual. Stanford University. http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA123256

  • Goodenough OR (2020) Integrating smart contracts with the legacy legal system: a US perspective”. In: Cappiello B, Carullo G (eds) Blockchain, law and governance. Springer, pp 191–203

    Google Scholar 

  • Governatori G (2018) Practical normative reasoning with defeasible deontic logic. Reason Web Int Summer Sch. https://doi.org/10.1007/978-3-030-00338-8_1

    Article  Google Scholar 

  • Governatori G, Idelberger F, Milosevic Z, Riveret R, Sartor G, Xu X (2018) On legal contracts, imperative and declarative smart contracts, and blockchain systems. Artif Intell Law 26:377–409

    Article  Google Scholar 

  • Greenwood R, Scharfstein D (2013) The growth of finance. J Econ Persp 27(2):3–28

    Article  Google Scholar 

  • Grosof BN, Poon TC (2004) SweetDeal: representing agent contracts with exceptions using semantic web rules, ontologies, and process descriptions. Int J Electron Commer 8(4):61–97

    Article  Google Scholar 

  • Hendershott T, Zhang X, Zhao JL, Zheng Z (2021) FinTech as a game changer. Inf Syst Res 32(1):1–17

    Article  Google Scholar 

  • Hopcroft J, Motwani R, Ullman J (2001) Introduction to automata theory, languages, and computation, 2nd edn. Pearson

    MATH  Google Scholar 

  • Huth M, Ryan M (2004) Logic in computer science: modelling and reasoning about systems, 2nd edn. Cambridge University Press

    Book  Google Scholar 

  • ISDA (2002) ISDA Master Agreement, ISDA Bookstore. http://www.isda.org/publications/isdamasteragrmnt.aspx. Accessed 12 Dec 2014

  • ISDA (2020) Standardize to digitise. IQ ISDA Q 6(1):1–47

    Google Scholar 

  • Kozen DC (1997) Automata and computability. Springer

    Book  Google Scholar 

  • Kuhn T (2014) A survey and classification of controlled natural languages. Comput Linguist 40(1):121–170

    Article  Google Scholar 

  • Liu Q, Islam B, Governatori G (2021) Towards an efficient rule-based framework for legal reasoning. Knowl-Based Syst 224:1070

    Article  Google Scholar 

  • LSP Working Group, Goodenough O, Salkind S (2019) Developing a legal specification protocol: technological considerations and requirements. CodeX – The Stanford Center for Legal Informatics. https://law.stanford.edu/publications/developing-a-legal-specification-protocol-technological-considerations-and-requirements/

  • MacLeod WB (2007) Reputations, relationships, and contract enforcement. J Econ Lit 45(3):595–628

    Article  Google Scholar 

  • Mealy GH (1955) A method for synthesizing sequential circuits. Bell Syst Tech J 34:1045–1079

    Article  MathSciNet  Google Scholar 

  • Moore EF (1956) Gedanken-experiments on sequential machines. Automata Stud 34:129–153

    MathSciNet  Google Scholar 

  • Mueller SM, Paul WJ (2000) Computer architecture complexity and correctness. Springer

    Book  Google Scholar 

  • Navarro PE, Rodriguez JL (2014) Deontic logic and legal systems. Cambridge University Press

    Book  Google Scholar 

  • Object Management Group (OMG) (2014) Enterprise Data Management Council (EDMC) Financial Industry Business Ontology (FIBO) Standard, Version 1.0 - Beta 1. Technical report, OMG. http://www.omg.org/spec/EDMC-FIBO/FND/. Accessed 13 Dec 2014

  • Prisacariu C, Schneider G (2007) A formal language for electronic contracts. In: Formal methods for open object-based distributed systems. Lecture notes in computer science, vol 4468, pp 174–189

  • Prisacariu C, Schneider G (2009) CL: an action-based logic for reasoning about contracts. In: Workshop on Logic, Language, Information and Computation (WoLLIC’09). Lecture notes in computer science, vol 5514, pp 335–349

  • Project ACTUS (2015) ACTUS: Algorithmic Contract Types Unified Standards. Internet site. http://www.projectactus.org/. Accessed 28 Aug 2015

  • Rosenberg AL (2010) The pillars of computation theory state, encoding, nondeterminism. Springer

    Book  Google Scholar 

  • Sergot MJ, Sadri F, Kowalski RA, Kriwaczek F, Hammond P, Cory HT (1986) The British nationality act as a logic program. Commun ACM 29(5):370–386

    Article  Google Scholar 

  • Simonson S (2013) Theory of computation. ADUni.org. http://www.aduni.org/courses/theory/

  • Sipser M (2006) Introduction to the theory of computation, 2nd edn. Thompson Learning

    MATH  Google Scholar 

  • Software Engineering Institute (2009) 'Happy Path' testing. Acquisition Archetypes, Carnegie Mellon University. http://www.sei.cmu.edu/library/assets/happy.pdf

  • Stout LA (2012) The shareholder value myth how putting shareholders first harms investors, corporations, and the public. Berrett-Koehler

    Google Scholar 

  • Surden H (2012) Computable contracts. UCDL Rev 46:629–639

    Google Scholar 

  • Szabo N (1997) Formalizing and securing relationships on public networks. Reprinted at https://nakamotoinstitute.org/formalizing-securing-relationships/

  • Tolmach P, Li Y, Lin S-W, Liu Y, Li Z (2021) A survey of smart contract formal specification and verification. Working paper, Nanyang Technological University, April, https://arxiv.org/abs/2008.02712

  • von der Lieth Gardner A (1987) An artificial intelligence approach to legal reasoning. MIT Press

    Google Scholar 

Download references

Acknowledgements

The authors thank Dan Katz, Jeanne Eicks, Matt Reed, Greg Feldberg, Primavera de Filippi, David Blaszkowsky, Sean Byrne, Harold Boley, Sanjoy Mitter, Andrew Lo, and Lynn Stout. Other helpful comments and background discussions on computation law came from research seminar participants at Cambridge University, Dartmouth College, George Mason University, Harvard University’s Berkman Center for Internet and Society, Massachusetts Institute of Technology, Office of Financial Research, Ewing Marion Kauffman Foundation, Gruter Institute, Stanford CodeX Center for Legal Informatics, IBM Research at Almaden, Institute for Pure and Applied Mathematics at the University of California at Los Angeles, Vermont Law School, and American Association of Law Schools’ annual meeting. We also thank John Donnelly, Jaryn Fields, Catherine Bourque, and Jacinta Ritchie for able support on this and related research. All remaining errors are the responsibility of the authors alone.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Mark D. Flood.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Flood, M.D., Goodenough, O.R. Contract as automaton: representing a simple financial agreement in computational form. Artif Intell Law 30, 391–416 (2022). https://doi.org/10.1007/s10506-021-09300-9

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10506-021-09300-9

Keywords

JEL Classification

Navigation