Logical English (LE) is a natural language syntax for pure Prolog and other logic programming languages, such as ASP and s(CASP). Its main applications until now have been to explore the representation of a wide range of legal texts, helping to identify ambiguities, explore alternative representations of the same text, and compare the logical consequences of the alternatives. The texts include portions of loan agreements, accountancy law, Italian citizenship, EU law on criminal rights, International Swaps and Derivative contracts, and insurance contracts. The current implementation in SWI Prolog can be accessed at https://logicalenglish.logicalcontracts.com.
The basic form of LE is simply syntactic sugar for pure Prolog[2], with predicates written in infix form and declared by means of templates, as in:
*a borrower* defaults on *a date*
where asterisks delimit the argument places of the predicate. Variables are signalled by the use of one of the determiners “a”, “an” or “the”. An indefinite determiner, “a” or “an”, introduces the first occurrence of a variable in a sentence. All later occurrences of the same variable in the same sentence are prefixed by the definite determiner “the”.
LE has only minimal linguistic knowledge of English. Its knowledge of English vocabulary is restricted to the determiners; the logical connectives “if”, “and”, “or” and “it is not the case that”; the logical pattern “for all cases in which…it is the case that…”; and the logical keyword “that”. The keyword “that” identifies the use of a meta-predicate, for representing such “propositional attitudes as prohibition, obligation, belief, desire, fear, notification, etc. Indentation, rather than parentheses, is used to indicate the relative strength of binding of the logical connectives. LE has virtually no knowledge of English grammar. In particular, it does not distinguish between singular and plural nouns and verbs, and it does not know about the relationship between the different tenses of verbs. Despite these restrictions, and because it has the same expressiveness as pure Prolog, it can be used to represent a broad range of knowledge, as shown by its application to the representation of legal texts [3,4,5,6,7]. Here is an example based on the loan agreement in [1]. The SWISH implementation of the example can be found at https://logicalenglish.logicalcontracts.com/p/new_loan_with_cure.pl.
the borrower defaults on a date D2 if the borrower has the obligation that an eventuality and the borrower fails to satisfy the obligation that the eventuality and the lender notifies the borrower on a date D1 that the borrower fails to satisfy the obligation that the eventuality and D2 is 2 days after D1 and it is not the case that the borrower cures on or before D2 the failure to satisfy the obligation that the eventuality.
defaults_on(the_borrower, A) :- has_the_obligation_that(the_borrower, B), fails_to_satisfy_the_obligation_that(the_borrower, B), notifies_on_that(the_lender, the_borrower, C, fails_to_satisfy_the_obligation_that(the_borrower, B)), is_days_after(A, 2, C), not cures_on_or_before_the_failure_to_satisfy_the_obligation_that(the_borrower, A, B).
Figure 1 illustrates a scenario, called “payment”, in which the borrower fails to satisfy the obligations, on lines 22 and 23, to pay the lender 550 on 2015-06-01 and 525 on 2016-06-01. The lender does not notice the first failure, but notices the second failure, and gives notice to the borrower of the second failure on 2016-06-04. The borrower attempts to cure the failure, by paying the correct amount 525 and by notifying the lender of the payment within the two day period of grace. But unfortunately, the borrower notifies the lender incorrectly that the payment was made on the date of notification rather than on the date of payment.
Figure 2 illustrates the result of answering the combination of the stored query, called “defaults” with the scenario. An LE document can contain several stored scenarios and several stored queries, which can be combined in the SWISH query pane.
The SWISH implementation also generates explanations in response to commands of the form answer(defaults, with(payment), le(E), R)
as shown in figure 3. For VSC users there exist extensions for syntax
highlighting and remote execution on a SWISH server. It is also possible
to call the LE parser without the SWISH environment, as a standalone
Prolog application. All the sources and further information are
available at https://github.com/LogicalContracts/LogicalEnglish/.
Figure 3: Explanations in LE
Many thanks to Miguel Calejo, Galileo Sartor, Andrew Noble, John Cummins, Fariba Sadri and Nilokai Merritt for their support and contributions to this work.