A queue is a device for delaying. A governor is used to control a flow. Control engineering tells you that you shouldn't add a delaying device into a control circuit as that may cause oscillations. That's easy, right? Well, only if you know about your queues – but there might be some invisible lurking to get you.
Short intro to "Grants4Companies"
10. January 2022
Our project "Grants for Companies" won the first price in the competition "eGovernment Wettbewerb 2021". In this blogpost, we show you some details about the implementation.
The Federal Ministry for Digital and Economic Affairs (BMDW) and us started a proof-of-concept for automatic evaluation of grants for companies in 2019, to show that this can be done efficiently.
Other important core aspects were
- traceability of decisions,
- using a standardized programming language (ANSI/X3.226‐1994 Common Lisp),
- and letting a symbolic AI optimize the (automatic) compilation of the logical rules; more about that below.
Basically, a (proposed or existing) grant in lawyer-speak must be translated to a computer representation; the various clauses may be answerable via available data (eg., which state the company is located in), or they may not: when new projects are being funded (eg. for improved energy efficiency), or for R&D projects.
In computer source form this gets translated to a name, some options (here being used to reference other documents), an optional documentation string, and last, but not least, a form to calculate eligibility, which can use existing runtime functions and compiler macros.
Comments are available too, of course; copy-pasting a grant document and then replacing parts with S-expressions gets us a working example quickly, even for more complicated proposals (here shortened a bit; this is an outdated grant, so the links don't work any more):
These grant definitions are then loaded into a Lisp-Image and get compiled into two functions: one that derives the result as quickly as possible, and another one that provides tracing/debugging by returning all individual subform results as well (In case you're curious, during a code walk each form gets assigned an index, and the results are accumulated into an array that's addressed by the individual subform index number).
After answering one of the questions (setting "Fahrzeugklasse" to "M1") for a company located in Vienna (so the required location clause (STANDORT :NOE) for Lower Austria doesn't apply), the debugging HTML output (with the calculated values in the right-most column being shown as if serialized in nested JSON arrays) looks like this:
But not only boolean values are available; date or numerical comparisons are often used in grants as well, and for more complex translations even numerical calculations can be done to have a better correspondence from grant text to computer form – here's an example for the Höchstbeitragsgrundlage ("maximum contribution" for social security), with the income being answered as 8000:
By using Common Lisp and its embedded compiler, we get all its compile-time optimizations for free - like constant folding.
But this is not the end - as the grant evaluation is purely functional and has no side-effects, our AND and OR operators can (unlike the Common-Lisp standard macros) reorder their clauses:
- The tracing functions will evaluate the result frequency of sub-forms over all companies;
- with that information our code-walker can try to abort the compilation sooner, by
- moving the most-often-false clause to the top of its surrounding AND, and the most-often-true one to the top of its OR.
Also, the typical transformations from (NOT (OR a b)) to (AND (NOT a) (NOT b) are allowed as well, possibly shifting a seldom-true expression to the outermost AND and so speeding up the quick evaluation even more.
But why is performance so important? Well, one of the use-cases is quick and easy tailoring of new grants. For this, evaluation of a new grant proposal over the whole company landscape (say, half a million companies in Austria registered in the USP) needs to be possible; with the faster one of the compiled functions we see an average response time below 0.5µsec per grant per company, so with a single core the number of applicable companies can be determinded within a quarter of a second – which can be called "interactive" usage ;)
Other questions that can be answered with this symbolic representation of grants are:
- Are there grants with the same clauses? ("Doppelförderungen")
- Are there grants with nearly the same clauses, with only very small differences like the state the grants apply to?
- Can a grant be simplified by determining that one clause logically includes or precludes another one?
So a broad series of (automated, repeated) investigations in the grant sector can then be carried out easily as well.