One purpose of hiring a lawyer is to find loopholes. One business model for lawyers is selling the exploitation of loopholes. Sounds like formal methods can be very valuable in legal training.
The law isn't perfect, and in that sense, it is like software in that it is constantly changing in anger. With the law, however, you're also in the situation of having many different interpreters. Given that the law is imperfect and requires refinement and adaptation in anger, given the imperfect knowledge of law givers, it is expected that there would be multiple interpretations.
Law does not determine justice by virtue of its codification. Morality does. Law is just the determination of general moral principles. A ruled-based system blindly followed by a machine would be a disaster outside very narrow, niche applications.