sydney university law society
Screen Shot 2017-10-23 at 7.52.41 am.png

The Legal Algorithm: What the Law Can Learn From Computer Science

The Legal Algorithm: What the Law Can Learn From Computer Science

By Peter Wooden


Peter Wooden

Bachelor of Science/Bachelor of Laws



From the advent of the stone age, our ancestors have adapted to the demands of life through technological innovation, investing resources in the creation of a system that lowers the cost of a future activity. We have displaced the physical abilities of our hands with tools, our fists with gunpowder, and our muscles with combustion engines. Since the digital revolution, computers have slowly edged the human mind out from its podium. Computers consist of modules of circuits which send and receive data, read instructions, perform operations on data, and store information. This is sufficient to complete any information processing method (an algorithm),[1] no matter how non-linear or recursive the instructions are.

Legal systems are another major innovation. First, they took conflicts of interests between two parties out of their own hands and arbitrated them with the judgement of the population. Second, they minimised the cost of arbitration by not requiring the whole population to decide each case, but by encoding a decision-making process into written documents—that is, the law—to emulate the will of society. The legal system mitigated risks to society, fostered convenient conditions for transactions and relationships, and protected particularly sensitive interests—for example, the rights of the individual.

A legal system is essentially an information processing system. The system has inputs: details of a dispute and the will of the society; a process: sorting through and updating a long evolved ‘algorithm’ which has been encoded into cases and statutes; and an output: orders of the court prescribing how the interests should be interfered with.

This article will conceptualise the current legal system as an information processing system, identify its problems, and outline the relevant characteristics of an ideal legal system. Following this, two models of a computerised legal system will be explored and evaluated: an artificial intelligence-based system and a computer code-based system. The latter will be found to be the system most efficient and consistent with the rule of law.

The law as an information processing system

A Understanding the Current Legal System as an Information Processing System

Before the legal system can be reimagined, it must first be characterised as a system: inputs, process, and outputs. To avoid getting lost in the weeds of the legal system as it currently exists, computer science terminology will be used to aid in understanding the system.


Figure 1: The adversarial system.


Legal system inputs: The will of society, through votes (referendums, electoral votes, plebiscites) and public consultations. The details of a dispute, through the claims of each party.

Legal system processes: For each case, a processing unit (a judge and jury) reads the legal claims of the parties and determines what the facts and law are by following a specific method (or, ‘algorithm’). This involves accessing long-term storage mediums (constitution, legislation, case law, law reform commission reports, Hansard, etc) to ascertain the will of society. The processing unit then interprets the law as a set of if-then conditions, which are then applied to the facts. The details of this execution of the process (the judgement) are fed back into a storage medium, and can be accessed by subsequent iterations and used as shortcuts or consistency checks. Relevant parts of the judgement are sent as an output.

Storage mediums make the process less costly by saving the entire public from having to adjudicate every case. The elected representatives serve as short-term memory devices for the will of their electorate, which then alter the long term storage mediums. The long term storage mediums provide each case with an imperfect record of the will of society. This sub-system is self-correcting.

Legal system outputs: The orders of the court, regarding how the interests of each party should be reconciled. Another output is information that can be used to predict the outcome of later applications of the legal system.

B The Problems with the Legal System

The current legal system swallows up lots of time, money, and valuable labour.[2] The body of law grows with each case and statute, producing vast amounts of information. Computationally, it is inefficient. Determining the meaning and value of a segment of law is a complex task due to the interrelationships between different parts of the law, and the law’s poor organisation. The lack of strict rules of formulation and universal standards enables indeterminacies in the law, and the personal bias of a judge might thereby become an unwelcome input to the process. While there is a place for judicial activism in the courts, if this input is meant to be a reflection of the politics of broader society, any single judge is unlikely to have a sufficiently representative opinion.

C Characteristics of an Ideal Legal System

The innovative and defiant culture of the technology industry contrasts immensely with the legal industry. In tech, people have an incentive to maximise the efficiency and effectiveness of their products by creating new processes and redesigning old ones; but in law, people have an incentive to conform as much as possible to the existing system. From a computer science perspective, we should maximise efficiency and effectiveness in the new legal system. Efficiency means minimising computational complexity and use of computational resources, such as memory space. In law, this also means minimising the amount of economic resources consumed. Effectiveness relates to how well the interests of the user are met—thus, from a legal perspective, we may borrow some values from Lord Bingham’s formulation of the Rule of Law: predictability, consistency, accessibility, and intelligibility.[3] A seemingly substantial value can be considered, like Dicey’s rejection of discretionary power:[4] essentially, this is acknowledging that an individual’s will is unlikely to be representative of the will of the population. Therefore, the process should take a set of values representative of the population’s as an input, in a way that can be easily updated to reflect changing societal beliefs.

The Offer of Computer Science

The languages that computer scientists have developed are constrained by the architecture of the computer chips running the programs. They contain circuits to perform logical operations, such as and, or, exclusive or, not, and perform decisions such as if-then, and go-to-other-step.[5] They have memory to store instructions and variables for short or long term uses. The two limitations on a computer being able to perform a task are the computational resources of the computer and the ability of humans to write clear instructions for it. There are two main ways computers can replace the legal system: an artificial intelligence-based system and a code-based system.

A Artificial Intelligence-based Legal System

Figure 2: Artificial intelligence-based legal system.

For difficult computational problems, such as visual recognition, programmers solve the problem indirectly by writing a program to mimic a brain structure, called a ‘neural network.’ The neural network is trained by exposing the program to example inputs and outputs, and the process element evolves until the output of the neural network matches the example output.[6]

Returning to the fundamental benefits of legal systems: third party (population) arbitration, and the cost of arbitration is minimised because the population doesn’t have to directly arbitrate each case as their will is stored. It may be difficult and costly to mimic the judgement of the population through the current legal system, but a neural network can be trained to mimic this judgement. The details of a dispute are sent to this neural network, and it will promptly return how the population would say it should be resolved. This system however, does not meet the standards of the ideal legal system that have been set out. Its only benefits are efficiency and accessibility, as the costs are very small. Its downsides are that it may not mimic the will of the population reliably, or accurately mimic undesirable elements like implicit biases, it would be very difficult to train, and it may not be consistent as it may be sensitive to irrelevant facts (overfitting the data).[7] Another major problem is opacity: the only way to ascertain the current state of the law is by running test inputs through the neural network.

B Computer Code-based Law

Figure 3: Flowchart of possible code-based legal system.

This approach retains the short-term storage medium (parliamentary representatives), replaces the long-term storage medium (constitution, legislation, cases, Hansard, law reform commission reports, etc) with a different format (computer code), and replaces the units that process each case with computers.  As the current legal system uses normal language to formulate the law, this invariably leads to the following: non-obvious inconsistencies which are detected only when the law is applied, ambiguities which are thought precise in the frame of mind of the drafter, and the embedding of unnecessary inferential leaps.

Instead, developing a programming language to formulate the law with would impose sufficient discipline on the drafting process and would ensure many benefits. Similarly, replacing the processing unit with computers that execute the code contained on the long-term storage medium is advantageous. One such example is demonstrated below:

Figure 4: Example of code-based law fitted to a fragment of the current law of battery.


Algorithms written in programming languages have the following characteristics and benefits:

1. Universal and strict syntax and semantics. The syntax of a programming language are its grammatical rules. Semantics relates elements of a programming language to the processes a computer completes when executing it and helps to prove exactly what a piece of a program means,[8] which implies there is never any ambiguity. Every piece of a program needs to reflect a logical, memory, instruction-calling, or input/output operation—the only fundamental operations of an information processing system.[9] A program’s semantics need to be extremely strict so that the program can be reduced, or compiled, into these basic instructions.[10] Programming languages are useful because they allow higher-order instructions to be written,[11] such as if-then-else statements, where more statements and instructions can be nested as many times as necessary.

2. Inconsistencies and consequences can be identified in real-time. Strict and universal syntax and semantics lends itself easily to software analysis. If conflicting duties or a breach of rights could arise under a certain clause, the software would be able to immediately alert the drafter. Economic consequences can also be detected: for example, regulations which require businesses to expend resources in many ways which would be unforeseeably expensive could be analysed and announced to the drafter. A program-based law would allow software to analyse the effect on all stakeholders of any part of the code.

 3. Determinate output (consistency and predictability). Differences in judicial opinion are a problem for predictability and consistency in the law. A computer code-based algorithm outputs the same result every time, given the same inputs. This characteristic follows from the universal and strict syntax and semantics. There will be no need for test cases since the law can be ascertained on any computer.

4. Efficient structure. Object-oriented programming allows coders to formulate programs in very efficient ways. It organises the code around templates for objects called ‘classes’ (such as parties to a case, a contract, a civil lawsuit, a regulation, an individual, a right, etc.), which define data that describe it (called ‘variables’) and logical sequences that can manipulate it (called ‘methods’).[12] Similar classes, such as battery and assault, can be abbreviated by inheriting variables and methods from another class, such as intentional tort.

If one political value determines many areas of the law, object-oriented programming will allow a drafter to update each of those rules by changing just one variable, rather than rewriting each part. This structure makes it easy to understand how each part of the law relates to another, makes the law consistent, and minimises the size of the body of law. Further, each class isn’t stored in a separate database, or printed in a certain volume of a law report. They are all centralised in one folder/directory which makes it easy to access and navigate for anyone.

5. Significance of a piece of code is more clear. In the common law system, statutes can contain clauses repealing or qualifying the application of other areas of statute law. This can lead to complex interactions between different parts of the law, and it is not immediately clear after reading a clause if and when it should be applied. With computer code, usage of code is determined by whether and when it is ‘called’ by other code, not by its place in a chronological hierarchy. Software tools can be written to detect redundancies automatically, or to list every instance and context of a piece of code being called upon.

6. Efficient execution (accessibility). A human might take days to work through a set of instructions on how to solve an informational problem, but it takes a computer seconds. If the primary role of legal professionals changes to only find facts (which is a process already undertaken by e-discovery professionals) and operate the algorithm, access to justice will be much less costly, and court time will be freed up. This also has many economic benefits, as legal professionals will be able to supply other industries with their intellectual capacity.

However, the following concerns may arise:

1. Inflexibility at point of application. This implies that there is no place for case law. When drafters leave a difficult issue to the courts the decide, there is no reason why the law generated in the courts cannot be generated in the drafting process. The availability of software analysis means that every conceivable factual matrix can be tested in the algorithm instantly, which aids the drafter, who cannot see every possible consequence of their phrasing themself. If there are intended consequences of the law that are unfavourable, the way to deal with this is through the ‘constitutional’ part of the code (i.e. can only be changed by a national vote), which can institute a process of appeal. A possible way to do this is to have representative samples of the population (large size, randomly selected)[13] spend a day speed-reviewing the outcomes of sets of cases to ensure that the output of the legal code reflects their judgement. If it does not, another process can be instituted to alter the code in a way consistent with the population.

2. Computer code cannot appreciate non-binary values. A computer can ultimately only handle values of true (1) and false (0). This is not much of a limitation, since any well-defined quantity can be encoded in a sequence of these terms (eg. 01001100).[14]

3. Computers cannot appreciate the complexity of human judgement. It is difficult to systematise or model things like our judgement of ‘causation’ in negligence cases, where the test involves an appeal to ‘common sense.’[15] If no better test is possible, the computer code can also outsource this to real human judgement (or, if the technology is reliable enough, artificial intelligence).

4. Most legal professionals will be made redundant. Continuing legal professionals will have to be flexible in the roles undertaken in their work, which may expand to other operations in the legal business. Continuing legal professionals will also have to be re-trained to understand the new system.

5. A computer system is vulnerable to hacking. Alterations to the legal algorithm or records of court orders can be addressed through a number of cybersecurity mechanisms, such as decentralised data storage, encryption, and consistency checks.

6. ‘Faith in the system’ may be difficult to build. This will be remedied with testing, continued use, and a good track record.

7. Code may not be easily intelligible to laymen. Readers of computer code-based law would have to learn the basics of the programming language in order to understand it, but it is much easier to learn how to read code than write it. It is possible a software tool could be developed to ‘translate’ the code into ordinary language.


The current legal system can be understood to be a very outdated technology that needs a major update. Adopting a computer-code based legal system would require the parliamentary system to be kept, but reformatting the long-term storage mechanism of the will of society (constitution, legislation, case law, etc) into a set of coded files, which can be separated into entrenched ‘constitutional’ elements, and a flexible set of laws that is updated by parliament.

Such a model will also require change in the way the law is processed and applied to each case, such that the details of a dispute are entered into the computer which then ‘calculates’ the orders of the court. This proposed model will increase access to justice and allow society to pursue other important economic goals, and it will encompass the beneficial implications for transparency, predictability, and consistency. While there are still barriers to adoption, a computer-code based legal system is far better economically, and is more consistent with the rule of law and with other aspects of an ideal legal system.



[1] See Bryan Pfaffenberger and Bill Daley, Computers in Your Future (2003) NYU Computer Science <>.

[2] See IbisWorld, Legal Services in Australia: Market Research Report (September 2017) Market Research Reports & Analysis <>.

[3] Lord Bingham, ‘The Rule of Law’ (2007) 66 Cambridge Law Journal 67.

[4] A V Dicey, Introduction to the study of the law of the Constitution (Macmillan, 8th ed, 1915) 120.

[5] See generally David Evans, x86 Assembly Guide (1 January 2017) University of Virginia Computer Science <>.

[6] See generally Michael Nielsen, Using Neural Nets to Recognize Handwritten Digits (August 2017) Neural Networks and Deep Learning <>.

[7] See generally Jim Frost, The Danger of Overfitting Regression Models (3 September 2015) Minitab <>.

[8] Daniel P Friedman and Mitchell Wand, Essentials of Programming Languages (The MIT Press, 3rd ed, 2008) 51.

[9] See generally Vladimir Slamecka, Information Processing (9 June 2015) Encyclopædia Britannica <>.

[10] See generally What is a Compiler? <>.

[11] The Purpose of Programming Languages, Freetext Library <>.

[12] Margaret Rouse, Object-oriented Programming (OOP) (August 2008) SearchMicroservices <>.

[13] Australian Bureau of Statistics, Statistical Language - Census and Sample (3 July 2013) <>.

[14] Andreas Moshovos, Using Bits to Represent Things (Spring 2006) Computer Engineering Research Group <>.

[15] March v Stramare (E & MH) Pty Ltd (1991) 171 CLR 506, 515.