That seems to imply we need two pieces of code for "perfect laws as code": 1) that which writes/defines the laws and 2) that which interprets the prevailing milieu and determines the application of law.
Since we're speculating anyways, why not implement the whole system we currently have? Assuming humanlike-AI (heh!), the following services are imaginable:
1 AI Legislature
2 AI Judge
3 AI Lawyers
Govt programmers handle (1) and (2), applicants and respondents (or prosecution and defence) handle (3). AI Legislature determines laws according to citizen referendum and policy upon consultation with the the AI Judges. Each AI Lawyer makes arguments to the AI Judge who evaluates each against the law and jurisprudence to arrive at a judgement. Wiggle away!
As a final layer which arose out of the Luddite massacres of 2137-40, a group of rubber-stamping human judges at the top serving as final adjudicators and appellate court.