Skip to content

Commit

Permalink
Updating main with latest extension on logical-languages, document in…
Browse files Browse the repository at this point in the history
…clusion and sCASP handling
  • Loading branch information
jacintodavila committed May 6, 2022
2 parents d405af4 + b268cc5 commit 97abce7
Show file tree
Hide file tree
Showing 17 changed files with 1,300 additions and 193 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
data
backupdata
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,44 @@ Introduction and list of resources at [Advent of Logical English​​](https://

## Development RoadMap

1. **Improve the error detection system** for better pinpointing of error location and cause.
2. a. **Store LE translation as a prolog or a s(CASP) file** to be injected into SWISH storage (to appear in the SWISH file list).
1. *TESTING NOW* **Improve the error detection system** for better pinpointing of error location and cause.
2. *TESTING NOW* a. **Store LE translation as a prolog or a s(CASP) file** to be injected into SWISH storage (to appear in the SWISH file list).
3. **Add a facility to name rules**, initially to refer to them in the explainer, but eventually to incorporate naming of rules with rule priorities, to deal with hierarchies of rules and exceptions. Note that the resulting implementation of defeasibility can be accomplished either by means of a meta-interpreter, or by compiling rule priorities into lower-level Prolog rules with explicit negative conditions.
4. **Add a facility for naming and combining knowledge bases**, with a view to obtaining some of the functionality of object-oriented systems, including inheritance and overriding.
4. *TESTING NOW* **Add a facility for naming and combining knowledge bases**, with a view to obtaining some of the functionality of object-oriented systems, including inheritance and overriding.
5. b. **Develop an editor for LE** with syntax and semantic highlighting, and error detection, as a separate editor project, preferably on JS Codemirror, using simple pengine calls to a SWISH server to assist the editing, and convert to different formats.
6. c. AFTER (b) is done, add .le as a valid SWISH file type.
7. **Add a treatment of common nouns as types**.
8. Update older examples into the new syntax extensions.

## Support RoadMap

1. **Opening the discussion forum**
2. **Update** the LE handbook.
2. **Update** the LE handbook with the latest syntax extensions.
3. Add more examples (both to the report and the handbook).

## Older Examples under review

1. [1_net_asset_value_test](./kb/1_net_asset_value_test.pl) Determine if a given entity satisfies the maximum net value test for Capital Gain Test, CGT, assets.
2. [2_r_and_d_tax_reliefs](./kb/2_r_and_d_tax_reliefs.pl) Determine if a project qualifies for the EIS.
3. [3_rollover_2](./kb/3_rollover_2.pl) Decide whether the small business restructure rollover applies to an event.
4. [4_affiliates](./kb/4_affiliates.pl) Determine if a given entity is affiliate of another (also given).
5. [5_tax_reliefs](./kb/5_tax_reliefs.pl) Determine if an electronic transaction is exempt from SDRT.
6. [6_statutory_residence](./kb/6_statutory_residence.pl) Determine if a person is a UK resident for tax purposes.
7. [7_loan_agreement](./kb/7_loan_agreement.pl) The Loan Agreement (and many variations with and without the Event Calculus)
8. [014_escrow](./kb/014_escrow.pl) A blockchain-like escrow agreement.
9. [cittadinanza_ita](./kb/cittadinanza_ita.pl) Cittadinanza Italiana (Italian Citizenship, many versions and translation into sCASP).
10. [010_isda_agreement](./kb/010_isda_agreement.pl) The ISDA Agreement (Many versions including [isda-permission-corrected](./kb/isda-permission-corrected.pl))
11. [oecd_test_for_inclusion](./kb/oecd_test_for_inclusion.pl) OECD example with an included document.
12. [criminal_justice](./kb/criminal_justice.pl) Criminal justice example.
13. [subsets](./kb/subsets.pl) Subsets example in many languages and into Prolog and sCASP.
14. [permitted that](./kb/permitted%20that.pl) Example with metavariables.
15. [minicontractv2](./kb/minicontractv2.pl) A proposed format for an electronic contract.


## <a name='Releases'></a>Release Notes

- [2022-05-05] Beta testing. Previous version: [d405af4da4fbeb170cd1cb1be333ff66c65a8d98](https://github.com/LogicalContracts/LogicalEnglish/commit/d405af4da4fbeb170cd1cb1be333ff66c65a8d98)
- Merging branch logical_languages with the latest extensions of LE syntax for sources in Italian, French and Spanish and targeting sCASP beside Prolog. Also, inclusion of other documents.
- [2021-11-23] Updating the roadmap. Previous version: [c4d67e9e0dbc54356473b284c9b72725c6504673](https://github.com/mcalejo/TaxKB/commit/c4d67e9e0dbc54356473b284c9b72725c6504673)
- [2021-11-08] Beta testing.
- Adding extract_variable_template/7 as specific predicates for templates. Fixing bug in output of answers with dates.
Expand Down
76 changes: 76 additions & 0 deletions kb/a_family_example.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
:- module('family_example',[]).

en("the target language is: prolog.

the templates are:
*a person* is a parent of *an other person*,
*a person* is a child of *an other person*,
*a person* is male,
*a person* is of opposite sex from *an other person*,
*a person* is female,
*a person* is a grandfather of *an other person*,
*a person* is a father of *an other person*.

the knowledge base family example includes:

a person Y is a parent of a person X
if X is a child of Y.

a person Y is a father of a person X
if X is a child of Y
and Y is male.

a person X is of opposite sex from a person Y
if X is male
and Y is female.

a person Y is of opposite sex from a person X
if X is male
and Y is female.

a person X is a grandfather of a person Z
if X is a father of a person Y
and Y is a parent of Z.

scenario one is:
john is a child of sue.
john is a child of sam.
jane is a child of sue.
jane is a child of sam.
sue is a child of george.
sue is a child of gina.
john is male.
jane is female.
june is female.
sam is male.
sue is female.
george is male.

query one is:
jane is a child of sue.

query two is:
gina is female.

query three is:
george is a father of sue.

query four is:
jane is of opposite sex from george.

query five is:
george is a grandfather of john.

query six is:
which person is a grandfather of john.
").

/** <examples>
?- answer one with one.
?- answer two with one.
?- answer three with one.
?- answer four with one.
?- answer five with one.
?- answer six with one.
?- show prolog.
*/
30 changes: 30 additions & 0 deletions kb/bigger.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:- module('bigger',[]).

en("the target language is: prolog.

the templates are:
*an animal* is bigger than *an other animal*,
*an animal* is just bigger than *an other animal*,

the knowledge base bigger includes:

an animal X is bigger than an animal Y
if X is just bigger than Y.

an animal X is bigger than an animal Y
if X is just bigger than an animal Z
and Z is bigger than Y.

scenario one is:
elephant is just bigger than horse.
horse is just bigger than donkey.

query one is:
which animal X is bigger than which animal Y.

").

/** <examples>
?- answer one with one.
?- show prolog.
*/
34 changes: 34 additions & 0 deletions kb/cittadinanza_ita.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
:- module('cittadinanza_ita+http://tests.com',[]).

it("il linguaggio destinazione è: scasp.

i modelli sono:
*una persona* ha la cittadinanza italiana,
*una persona* è padre di *una persona*,
*una persona* è madre di *una persona*,
*una persona* è nato in italia,
*una persona* è apolide,
il padre di *una persona* è sconosciuto,
la madre di *una persona* è sconosciuta,
*una persona* segue la cittadinanza di *una persona*.

la base di conoscenza cittadinanza_ita include:
una persona A ha la cittadinanza italiana
se una persona B è padre di la persona A
e la persona B ha la cittadinanza italiana.

scenario giuseppe è:
felice è padre di giuseppe.
tatiana è madre di giuseppe.
felice ha la cittadinanza italiana.
tatiana ha la cittadinanza italiana.

domanda uno è:
quale persona ha la cittadinanza italiana.

").

/** <examples>
?- answer(uno, with(giuseppe), le(E), R).
?- risposta uno con giuseppe.
*/
46 changes: 46 additions & 0 deletions kb/conjunto.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
:- module('conjunto',[]).

es("el lenguaje objetivo es: prolog.

los predicados son:
*un conjunto* es un subconjunto de *un conjunto*,
*una cosa* es un conjunto,
*una cosa* pertenece a *un conjunto*.

la base de conocimiento conjunto incluye:

un conjunto A es un subconjunto de un conjunto B
si el conjunto A es un conjunto
y el conjunto B es un conjunto
y en todos los casos en los que
una cosa pertenece a el conjunto A
es el caso que
la cosa pertenece a el conjunto B.

escenario uno es:
familia uno es un conjunto.
familia dos es un conjunto.
Roberto pertenece a la familia uno.
Alicia pertenece a la familia uno.

Alicia pertenece a la familia dos.

la pregunta uno es:
cuál primera familia es un subconjunto de cuál segunda familia.

escenario dos es:
[Alicia, Roberto] es un conjunto.
[Alicia] es un conjunto.

una cosa pertenece a un conjunto
if la cosa is in el conjunto.

la pregunta dos es:
cuál conjunto es un subconjunto de cuál segundo conjunto.

").

/** <examples>
?- show prolog.
?- responde dos con dos.
*/
66 changes: 66 additions & 0 deletions kb/italian_citizenship_to_include.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
:- module('italian_citizenship_to_include',[]).

en("the target language is: prolog. % other languages available soon

the templates are:
*a person* is an italian citizen,
*a person* is the father of *a person*,
*a person* is the mother of *a person*,
*a person* is born in italy,
*a person* is stateless,
*a person* follows the citizenship of *a person*.

the knowledge base italian_citizenship_to_include includes:

% Article 1.1(a)
a person A is an italian citizen
if a person B is the father of the person A
and the person B is an italian citizen.

a person A is an italian citizen
if a person B is the mother of the person A
and the person B is an italian citizen.

% Article 1.1(b)
a person A is an italian citizen
if the person A is born in italy
and unknown is the father of the person A
and unknown is the mother of the person A.

a person A is an italian citizen
if the person A is born in italy
and a person F is the father of the person A
and the person F is stateless
and the person M is the mother of the person A
and the person M is stateless.

a person A is an italian citizen
if the person A is born in italy
and a person F is the father of the person A
and a person M is the mother of the person A
and it is not the case that
the person A follows the citizenship of the person F
and the person A follows the citizenship of the person M.

% add as many as you need
scenario giuseppe is:
felice is the father of giuseppe.
tatiana is the mother of giuseppe.
felice is an italian citizen.
tatiana is an italian citizen.

scenario luca is:
luca is born in italy.
unknown is the father of luca.
unknown is the mother of luca.

% add as many as you need
query one is:
which person is an italian citizen.

").

/** <examples>
?- answer("query one with scenario giuseppe").
?- answer(one, with(giuseppe), le(E), R).
*/
44 changes: 44 additions & 0 deletions kb/minicontractv1.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
:- module('minicontractv1+http://tests.com',[]).

en("the target language is: prolog.
% Logical English document

the templates are:
The terms of the contract are met,
*a contract* is a valid contract,
*a contract* is signed by the service provider,
*a contract* is also signed by the service recipient,
the service is delivered before *a date*,
the service recipient maintains all communication within the confines of *a domain*,
the service recipient delivers requested information before *a date*.

the knowledge base minicontractv1 includes:
A contract is a valid contract if
the contract is signed by the service provider
and the contract is also signed by the service recipient.

The terms of the contract are met if
the service is delivered before 2022-06-05T10:00:00
and the service recipient maintains all communication within the confines of domain
and the service recipient delivers requested information before 2022-06-01T10:00:00.

scenario one is:
the service is delivered before 2022-06-05T10:00:00.
the service recipient maintains all communication within the confines of domain.
the service recipient delivers requested information before 2022-06-01T10:00:00.
the contract is signed by the service provider.
the contract is also signed by the service recipient.

query one is:
which contract is a valid contract.

query two is:
The terms of the contract are met.

").

/** <examples>
?- answer("query one with scenario one").
?- answer("query two with scenario one").
?- show prolog.
*/

0 comments on commit 97abce7

Please sign in to comment.