logical english - department of computing

45
Robert Kowalski Imperial College London 1 Logical English as an Executable Computer Language

Upload: others

Post on 13-May-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Logical English - Department of Computing

Robert KowalskiImperial College London

1

Logical English as an Executable Computer Language

Page 2: Logical English - Department of Computing

2

Together with

Fariba Sadri Miguel CalejoJacinto Davila Vesko Karadotchev

Page 3: Logical English - Department of Computing

3

Conclusion

Page 4: Logical English - Department of Computing

4

• modelled on the language of law.

• understandable by English speakers without special training.

• suitable for general computation, i.e.programming, databases and knowledge representation.

• prototypes in Prolog

Logical English (LE)

Page 5: Logical English - Department of Computing

5

The Language of Law

declarative

describes the legal consequencesof actions and events

logical conditionals andlogical all/every/exists

avoids ambiguity, butembraces vagueness(open texture)

passively judges the behaviour of external agents

The majority of computer languages

imperative

assignment statements

if-then-else,iteration and loops

unambiguous by design

actively support the goals of external agents

Smart contractsactively support the goals of legal agreements.

Page 6: Logical English - Department of Computing

6

Examples from

• The British Nationality Act logic programs.

• A simplified loan agreementdeterministic finite automata.

• Rock, Paper, Scissors (Lessons and insights from a cryptocurrency lab)imperatives.

• ISDA Master Agreement (International Swaps and Derivatives Association)obligations.

Page 7: Logical English - Department of Computing

7

Page 8: Logical English - Department of Computing

British Nationality ActAcquisition at Birth

English

1.-(1) A person born in the United Kingdom after commencement shall be a British citizen if at the time of the birth his father or mother is (a) a British citizen; or(b) settled in the United Kingdom.

Logical English (basic level)

Page 9: Logical English - Department of Computing

British Nationality ActAcquisition at Birth

English

1.-(1) A person born in the United Kingdom after commencement shall be a British citizen if at the time of the birth his father or mother is (a) a British citizen; or(b) settled in the United Kingdom.

A person acquires british citizenship by subsection 1.1 at a timeif the person is born in the uk at the timeand the time is after commencementand another person is the father of the person

or another person is the mother of the person and the other person is a british citizen at the time

or the other person is settled in the uk at the time.

Logical English (basic level)

“a”, “an” or “another” indicates the first occurrence of a logical variable“the” indicates a later occurrence of the same logical variable in the same sentence.No “all”, “every” or “some”.

Page 10: Logical English - Department of Computing

10

All payments that are specified in some transaction are obligatory.

needs to be rewritten.

For example:

A payment is obligatory if the payment is specified in a transaction.

Or:

It is an obligation that a payment is madeif the payment is specified in a transaction.

No “all”, “every” or “some” in Basic Logical English

Page 11: Logical English - Department of Computing

11

Examples from

• The British Nationality Act logic programs.

• A simplified loan agreementdeterministic finite automata.

• Rock, Paper, Scissors (Lessons and insights from a cryptocurrency lab)imperatives.

• ISDA Master Agreement (International Swaps and Derivatives Association)obligations.

Page 12: Logical English - Department of Computing

12

Page 13: Logical English - Department of Computing

13

Page 14: Logical English - Department of Computing

14

Page 15: Logical English - Department of Computing

15

Page 16: Logical English - Department of Computing

16

It is an obligation that the lender advances $1000 to the borrower at a timeand the time is before the end of 2014/6/2

if the borrower has requested $1000 on 2014/6/1.

Or The lender becomes liable to litigation at a timeif it is the end of 2014/6/2 at the timeand the borrower has requested $1000 on 2014/6/1and it is not the case that

the lender has advanced $1000 at another time and the other time is before the end of 2014/6/2.

Page 17: Logical English - Department of Computing

17

The contract becomes terminated at a timeif it is the end of 2014/6/1 at the timeand it is not the case that

the borrower has requested the loan at the time.

The contract becomes terminated when it is the end of 2014/6/1and it is not the case that

the borrower has requested the loan.“conclusion when conditions”means“conclusion at a timeif conditions at the time”

translated into Prolog/LPS(Logical Production System)

Page 18: Logical English - Department of Computing

18

LPS implemented in SWI Prolog running online in SWISH

Page 19: Logical English - Department of Computing

19

The history of states and events can be visualised as a state transition diagram(or derministic finite automaton)

Page 20: Logical English - Department of Computing

20

Examples from

• The British Nationality Act logic programs.

• A simplified loan agreementdeterministic finite automata.

• Rock, Paper, Scissors (Lessons and insights from a cryptocurrency lab)imperatives.

• ISDA Master Agreement (International Swaps and Derivatives Association)obligations.

Page 21: Logical English - Department of Computing

21

Each player simultaneously

forms one of three shapes

with an outstretched hand:

Page 22: Logical English - Department of Computing

22

Rock-paper-scissors in an “early” variant of Logical English

Page 23: Logical English - Department of Computing

Rock-paper-scissors in LPS on the Ethereum blockchain

23June 26, 2018 http://logicalcontracts.com

Page 24: Logical English - Department of Computing

24

Reactive rules in LPS behave like imperative programs

If a player has played a choice and another player has played another choice, and the choice beats the other choice ,and the game is not over, and the reward is a prizethen end the game and pay the player the prize.

Declarative English

If a player has played a choice and another player has played another choice, and the choice beats the other choice ,and the game is not over, and the reward is a prizethen the game becomes over and the player is paid the prize.

Imperative English

Page 25: Logical English - Department of Computing

25

Page 26: Logical English - Department of Computing

26

Examples from

• The British Nationality Act logic programs.

• A simplified loan agreementdeterministic finite automata.

• Rock, Paper, Scissors (Lessons and insights from a cryptocurrency lab)imperatives.

• ISDA Master Agreement (International Swaps and Derivatives Association)obligations.

Page 27: Logical English - Department of Computing

27

Page 28: Logical English - Department of Computing

28

Page 29: Logical English - Department of Computing

29

It is an obligation that a party performs an actionif the action is specified in a confirmationand the action is a payment

or the action is a delivery and it cannot be shown that

it is not the case that it is an obligation that the party performs the action.

An obligation is satisfied if the obligation is that the party performs an actionand the party performs the action.

An obligation is violatedif it is not the case that the obligation is satisfied.

Page 30: Logical English - Department of Computing

30

It is not the case that it is an obligation that a party pays to a counterparty an amount in a currency for a transaction on a date

if it is an obligation that the party pays to the counterparty a net amount in the currency for the transaction on the date.

It is an obligation that a party pays to a counterparty a net amount in a currency for a transaction on a date

if the net amount is a larger aggregate amount minus a smaller aggregate amountand the larger aggregate amount is the sum of each amount of each payment by the

party to the counterparty in the currency for the transaction on the dateand the smaller aggregate amount is the sum of each amount of each payment by the

counterparty to the party in the currency for the transaction on the date.

Page 31: Logical English - Department of Computing

31

Page 32: Logical English - Department of Computing

32

Conclusion

Page 33: Logical English - Department of Computing

33

For more informationand opinion

Page 34: Logical English - Department of Computing

34

Acknowledgements

for BNA + LPSfor LPS on SWISH + Logical Contractsfor preliminary version of Logical Englishfor most recent development of Logical English

Thank you

Fariba Sadri Miguel CalejoJacinto Davila Vesko Karadotchev

Page 35: Logical English - Department of Computing

35

Additional background slides

Page 36: Logical English - Department of Computing

36

Page 37: Logical English - Department of Computing
Page 38: Logical English - Department of Computing

38

Page 39: Logical English - Department of Computing

39

Page 40: Logical English - Department of Computing

40

Page 41: Logical English - Department of Computing

41

Page 42: Logical English - Department of Computing

42

The history of states and events can be visualised as a timeline (or Gantt chart)

Page 43: Logical English - Department of Computing

43

A smart contract in an imperative programming language

Page 44: Logical English - Department of Computing
Page 45: Logical English - Department of Computing