# Logical English, [LE](https://github.com/LogicalContracts/LogicalEnglish/blob/main/le_handbook.pdf)
## the British Nationality Act Example
:- module('citizenship+https://www.legislation.gov.uk/ukpga/1981/61/section/1',[]).
en("the target language is: prolog.
the templates are:
*a person* acquires British citizenship on *a date*.
*a person* is born in *a place* on *a date*,
*a date* is after commencement,
*a person* is the mother of *a person*,
*a person* is the father of *a person*,
*a person* is a British citizen on *a date*,
*a person* is settled in the UK on *a date*,
*a person* says that *a sentence*,
*a person* is authorised to determine fatherhood.
the knowledge base citizenship includes:
a person acquires British citizenship on a date
if the person is born in the UK on the date
and the date is after commencement
and an other person is the mother of the person
or the other person is the father of the person
and the other person is a British citizen on the date
or the other person is settled in the UK on the date.
scenario alice is:
John is born in the UK on 2021-10-09.
2021-10-09 is after commencement.
Alice is the mother of John.
Alice is a British citizen on 2021-10-09.
query one is:
which person acquires British citizenship on which date.
").
SWISH -- LogicalEnglish.swinb (logicalcontracts.com
answer one with alice.
But it can also be queried directly, like this:
answer('which person acquires British citizenship on which date', with(alice)).
Or it can be queried in Prolog with extra arguments for features like explanations:
answer(one, with(alice), le(E), R).
# Introduction to the Syntax of LE
The parser of LE assumes a document with the following structure. One declaration title like:
the templates are:
followed by the declarations of all the corresponding predicates mentioned in the knowledge base.
Each declarations define a template with the variables and other words required to describe a relevant relation.
It is a comma separated list of templates which ends
with a period.
After that period, one of the following statement introduces the knowledge base:
the knowledge base includes:
or
the knowledge base [name of the kb] includes:
And it is followed by the rules and facts written in Logical English syntax.
Each rule must end with a period.
Indentation is used to organize the and/or list of conditions by strict observance
of one condition per line with a level of indentation that corresponds to each operator and corresponding conditions.
Similarly, there may be sections for scenarios and queries, like:
scenario test is:
borrower pays an amount to lender on 2015-06-01.
and
query one is:
for which event:
the small business restructure rollover applies to the event.
query two is:
which tax payer is a party of which event.
query three is:
A first time is after a second time
and the second time is immediately before the first time.
which can then be used on the new command interface of LE on SWISH (e.g. answer/1 and others querying predicates)
? answer 'query one with scenario test'.
A first example is the one shown above, as part of this notebook. More examples linked below. They could all be used as separated programs as well
## Other recommended examples
1. [Citizenship with trust](https://le.logicalcontracts.com/p/citizenship.pl)
2. [Grandparent and ancestor](https://le.logicalcontracts.com/p/impossible%20ancestor.pl)
3. [Subset](https://le.logicalcontracts.com/p/subset%20with%20lists.pl)
4. [OECD Convention on double taxation](https://le.logicalcontracts.com/p/oecd_test.pl)
5. On LPS: the [rock paper scissors](https://demo.logicalcontracts.com/example/RockPaperScissorsBaseEN.pl) example.
## More information
For more information on Logical English, see [the Handbook](https://github.com/LogicalContracts/LogicalEnglish/blob/main/le_handbook.pdf).
The open source code is at [https://github.com/LogicalContracts/LogicalEnglish](https://github.com/LogicalContracts/LogicalEnglish)