SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Contract Automata
Towards an Algebra of Contracts
Gordon J. Pace
Department of Computer Science
University of Malta
Malta
March 2016
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
What’s so Interesting about Contracts?
Normative notions — ideal vs actual behaviour.
Enabling representation of concepts such as obligations,
prohibitions permissions, and exceptional behaviour.
Ought-to-do or ought-to-be?
Plagued by paradoxes unless one is very careful and restricts
the language.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Paradox of Blame
Paradox of Blame
The law says: You are obliged to hand in Form A on Monday and
Form B on Tuesday, unless officials stop you from doing so.
But it’s sunny outside: On Monday, John spent a day on the
beach, thus not handing in Form A. On Tuesday at 00:00 he was
arrested, and taken to court on Wednesday.
Prosecuting lawyer: To satisfy his obligation the defendant had
to hand in Form A on Monday, which he did not. Hence he should
be found guilty.
Defendant’s lawyer: But to satisfy the obligation the defendant
had to hand in Form B on Tuesday, which he was stopped from
doing by officials. He is hence innocent.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contracts vs. Specifications
What are contracts, and are they different from properties or
specifications?
Obligation to perform x related to the property ‘action taken
must include x’
Prohibition from performing x related to the property ‘action
taken may not include x’
But what are permission to perform x? Actions may include
x? What are violations?
And what about liability?
Or exceptional (non-ideal) behaviour?
Contracts are by definition an agreement between two or more
interacting parties but most formal studies regulate a party at
a time.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contract clause #1
“John is permitted to withdraw cash.”
John may choose to perform an action ‘withdraw cash’,
which the bank is bound to engage with.
John may also choose not to perform the action.
but if he does and the bank does not allow the bank has
violated the contract.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contract clause #2
“John is obliged to pay an annual fee.”
John should perform an action ‘pay annual fee’,
If John chooses not to perform the action, he has violated the
contract.
But the bank is bound to engage with John’s action to allow
him to satisfy the contract.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Interacting Systems
Interaction has a long history in computer science providing
tools such as communication and synchronisation which allow
the modelling of directed modalities in a two-party contract
setting.
We formalise two-party contracts modelling interaction using
synchronous composition with multiset-actions.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Synchronous Composition over Multisets of Actions
The synchronous composition of two automata
Si = Qi , q0i , →i synchronising over alphabet G, is written
S1 G S2, is defined to be Q1 × Q2, (q01, q02), → .
q1
A
−→1 q1
(q1, q2)
A
−→ (q1, q2)
A ∩ G = ∅
q2
A
−→2 q2
(q1, q2)
A
−→ (q1, q2)
A ∩ G = ∅
q1
A
−→1 q1 q2
B
−→2 q2
(q1, q2)
A∪B
−−−→ (q1, q2)
A ∩ G = B ∩ G = ∅
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
But What About the Contract?
Contracts are also encoded as automata with states tagged
with the contract clauses that will be in force at that point.
Contract
“Initially, the user (party u) is forbidden from using the service but
permitted to pay after which the provider (party p) is obliged to
provide the service.”
Pu(pay), Fu(service) Op(service)
∅
{service}
{pay}
{pay, service}
anything
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contract Automata
A contract clause is one of the following:
Clause ::= Op(a) | Op(!a) | Pp(a) | Pp(!a)
A contract automaton is a normal automaton with an
additional function Q → 2Clause.
The transition relation of contract automata is always total to
ensure no deadlock, even after a violation occurs.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contract Automata
A contract clause is one of the following:
Clause ::= Op(a) | Op(!a) | Pp(a) | Pp(!a)
A contract automaton is a normal automaton with an
additional function Q → 2Clause.
The transition relation of contract automata is always total to
ensure no deadlock, even after a violation occurs.
Prohibition
Prohibition Fp(a) is just Op(!a).
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contract Automata
A contract clause is one of the following:
Clause ::= Op(a) | Op(!a) | Pp(a) | Pp(!a)
A contract automaton is a normal automaton with an
additional function Q → 2Clause.
The transition relation of contract automata is always total to
ensure no deadlock, even after a violation occurs.
Negative clauses
!Op(x) = Pp(!x)
!Pp(a) = Op(!a)
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Regulated Two-Party Systems
A regulated two-party system synchronising over the set of
actions G consists of three parts: (i) the interacting systems
S1 and S2 and (ii) the contract A.
By composing the contract automaton A with the parties’
behaviour we can then identify what clauses are in force and
when, hence allowing analysis for contract violation:
(S1 G S2) ΣA.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Contract Violation
Given a regulated two-party system, we can now analyse the
system automata with respect to the contract clauses and tag
violations and the responsible party.
Violations can occur on:
Transitions: e.g. a transition which contains an action which
is prohibited at that point.
States: e.g. a state in which a party does not permit (allow)
the other party to perform an action which should be
permitted.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Obligations
Obligation Op(a) brings in constraints on both parties:
1. party p must include the action in any outgoing transition in
the composed system; and
2. the other party p must provide a viable action set which allows
p to perform all its obligation.
The former marks transitions as violations, whereas the latter
marks states.
viablep(qA, A)
df
= Op(qA) ⊆ A ∧ Fp(qA) ∩ A = ∅
satO
p ((q1, q2)qA
A
−→ (q1, q2)qA
)
df
= viablep(qA, A)
satO
p ((q1, q2)qA )
df
= ∃A ∈ acts(qp), A ⊆ Gc · viablep(qA, A ∪ A )
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Permissions
If party p is permitted to perform shared action a, then the
other party p must provide p with at least one viable outgoing
transition which contains a but does not include any forbidden
actions.
Violations of a permission occur when no appropriate action is
possible, and is thus a property of a state not a transition.
We use a semantics that tags as a violation a state in which
one party is permitted to perform an action, while the other
provides no way of actually doing so.
(q1, q2)qA p Pp(a)
df
= true
(q1, q2)qA p Pp(a)
df
=
a ∈ G =⇒ ∃A ∈ acts(qp), A ⊆ Gc
· a ∈ A ∧ viablep(qA, A ∪ A )
satP
p ((q1, q2)qA
)
df
= ∀Pp(x) ∈ qA · (q1, q2)qA p Pp(x)
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Breach-incapability
A regulated system gives an automaton of all potential
behaviours when composed.
It is breach-incapable if no violating states and/or transitions
are reachable from the initial state.
This is stronger than being compliant for one specific run.
correct(p, R)
df
=
(∀q ∈ reachableS (R) · satp(q)) ∧ (∀t ∈ reachableT (R) · satp(t))
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Ordering of contracts based on leniency
A contract A is more lenient than another contract A for a
particular party p (A p A ) if any system behaviour of p
which may violate A may also violate A .
This definition allows us to characterise the notion of contract
equivalence for a particular party or even for all parties.
A p A
df
= ∀S1, S2 · correct(p, S1, S2 A ) =⇒ correct(p, S1, S2 A)
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Pp(c)
Op(a)
{a} or {b} or ∅
{a, b}
anything
p
Pp(c) Op(a)
Op(a), Pp(b)
{a} or ∅
{a, b}
{b}
{a} or {b} or ∅
{a, b}
anything
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Conflicts in Contracts
Axiom 1: Opposite permissions conflict: Pp(x) !Pp(x).
Axiom 2: Obligation to perform mutually exclusive actions is a
conflict: a b Op(a) Op(b).
Axiom 3: Conflicts are closed under symmetry: C C C C.
Axiom 4: Conflicts are closed under increased strictness:
C C ∧ C C C C .
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
John and his Bank
The contract says that (i) whenever he is logged into his Internet
banking account, he is to be permitted to make money transfers;
and (ii) if a malicious attempt to log in to his account is identified,
logging in and making transfers will be prohibited until the
situation is cleared.
Fj (transfer) Pj (transfer) Pj (login) Fj (login), Fj (transfer)
login
logout
malicious
cleared
Note what happens after {login, malicious} in the composition of
these contracts.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Adding Reparations
Some reparations can be ‘handled’ by contract automata.
e.g. “The passenger is obliged to show a means of
identification when presenting the ticket, and would otherwise
be prohibited from boarding.”
Op(proveIdentity)start
Fp(boardPlane)
{showTicket, proveIdentity}
{showTicket}
But with such an encoding, we have no notion of which
transitions are violating ones.
And even worse, we cannot express a reparation of a
permission in this manner.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Reparations
Pp(boardPlane)
Pp(handLuggage)
Pp(coat)
Pp(report)
Oc (inCargo)
Pp(report)
Oc (inCargo)
Op(switchOffDevices)
Vc (Pp(coat)) {boardPlane} ok {boardPlane}
Vc (Pp(handLuggage)) {boardPlane} Vc (Pp(coat)) ∧ Vc (Pp(handLuggage)) {boardPlane}
By tagging each transition with which clauses would have to
be violated to take that transition, we can model reparations.
In addition, we can talk about hypothetical reparations.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Discussion
By keeping the contract as a separate automaton:
We share the same formalism and theory as for systems;
We are able to reason about contracts independently of the
system — e.g. compose contracts using synchronous
composition
Although we can reduce a regulated system to a single
automaton, by keeping the original systems and contract as
automaton we keep the system behaviours separate and
intact. Permission can only be deduced with this
unadulterated behaviour.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
Conclusions
The main contributions of this work are:
A formalisation of the meaning of directed deontic operators in
a two-party setting;
The use of standard techniques from computer science, namely
communication and synchronisation, to analyse contracts
regulating two parties.
Practically all the work done on directed obligations and
permissions introduces new modalities such as intention,
causality, etc.
We are now looking into how much further such an
automaton based approach supports contract analysis, and
extending it to deal with multi-party (n > 2) systems.
Gordon J. Pace Contract AutomataTowards an Algebra of Contracts

Más contenido relacionado

La actualidad más candente (11)

Free consent
Free consentFree consent
Free consent
 
Contract act----by sumit mukherjee
Contract act----by sumit  mukherjeeContract act----by sumit  mukherjee
Contract act----by sumit mukherjee
 
Law (free consent)
Law (free consent)Law (free consent)
Law (free consent)
 
Free consent
Free consentFree consent
Free consent
 
PRC Contract Law Principles and Risk Management in Contract Drafting
PRC Contract Law Principles and Risk Management in Contract DraftingPRC Contract Law Principles and Risk Management in Contract Drafting
PRC Contract Law Principles and Risk Management in Contract Drafting
 
free Consent
free Consentfree Consent
free Consent
 
free consent
free consentfree consent
free consent
 
Free consent
Free  consentFree  consent
Free consent
 
Free consent By RAZI ANWAR
Free consent By RAZI ANWARFree consent By RAZI ANWAR
Free consent By RAZI ANWAR
 
Consent & mistake in Contracts
Consent & mistake in ContractsConsent & mistake in Contracts
Consent & mistake in Contracts
 
Misrepresentation and fraud
Misrepresentation and fraudMisrepresentation and fraud
Misrepresentation and fraud
 

Destacado (7)

Domain Modeling with Functions - an algebraic approach
Domain Modeling with Functions - an algebraic approachDomain Modeling with Functions - an algebraic approach
Domain Modeling with Functions - an algebraic approach
 
An Algebraic Approach to Functional Domain Modeling
An Algebraic Approach to Functional Domain ModelingAn Algebraic Approach to Functional Domain Modeling
An Algebraic Approach to Functional Domain Modeling
 
Basic Algebra (for beginners)
Basic Algebra (for beginners)Basic Algebra (for beginners)
Basic Algebra (for beginners)
 
BOOLEAN ALGEBRA & LOGIC GATE
BOOLEAN ALGEBRA & LOGIC GATEBOOLEAN ALGEBRA & LOGIC GATE
BOOLEAN ALGEBRA & LOGIC GATE
 
Application of algebra
Application of algebraApplication of algebra
Application of algebra
 
presentation on matrix
 presentation on matrix presentation on matrix
presentation on matrix
 
Applications of linear algebra
Applications of linear algebraApplications of linear algebra
Applications of linear algebra
 

Más de Facultad de Informática UCM

Más de Facultad de Informática UCM (20)

¿Por qué debemos seguir trabajando en álgebra lineal?
¿Por qué debemos seguir trabajando en álgebra lineal?¿Por qué debemos seguir trabajando en álgebra lineal?
¿Por qué debemos seguir trabajando en álgebra lineal?
 
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
 
DRAC: Designing RISC-V-based Accelerators for next generation Computers
DRAC: Designing RISC-V-based Accelerators for next generation ComputersDRAC: Designing RISC-V-based Accelerators for next generation Computers
DRAC: Designing RISC-V-based Accelerators for next generation Computers
 
uElectronics ongoing activities at ESA
uElectronics ongoing activities at ESAuElectronics ongoing activities at ESA
uElectronics ongoing activities at ESA
 
Tendencias en el diseño de procesadores con arquitectura Arm
Tendencias en el diseño de procesadores con arquitectura ArmTendencias en el diseño de procesadores con arquitectura Arm
Tendencias en el diseño de procesadores con arquitectura Arm
 
Formalizing Mathematics in Lean
Formalizing Mathematics in LeanFormalizing Mathematics in Lean
Formalizing Mathematics in Lean
 
Introduction to Quantum Computing and Quantum Service Oriented Computing
Introduction to Quantum Computing and Quantum Service Oriented ComputingIntroduction to Quantum Computing and Quantum Service Oriented Computing
Introduction to Quantum Computing and Quantum Service Oriented Computing
 
Computer Design Concepts for Machine Learning
Computer Design Concepts for Machine LearningComputer Design Concepts for Machine Learning
Computer Design Concepts for Machine Learning
 
Inteligencia Artificial en la atención sanitaria del futuro
Inteligencia Artificial en la atención sanitaria del futuroInteligencia Artificial en la atención sanitaria del futuro
Inteligencia Artificial en la atención sanitaria del futuro
 
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
 Design Automation Approaches for Real-Time Edge Computing for Science Applic... Design Automation Approaches for Real-Time Edge Computing for Science Applic...
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
 
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
 
Fault-tolerance Quantum computation and Quantum Error Correction
Fault-tolerance Quantum computation and Quantum Error CorrectionFault-tolerance Quantum computation and Quantum Error Correction
Fault-tolerance Quantum computation and Quantum Error Correction
 
Cómo construir un chatbot inteligente sin morir en el intento
Cómo construir un chatbot inteligente sin morir en el intentoCómo construir un chatbot inteligente sin morir en el intento
Cómo construir un chatbot inteligente sin morir en el intento
 
Automatic generation of hardware memory architectures for HPC
Automatic generation of hardware memory architectures for HPCAutomatic generation of hardware memory architectures for HPC
Automatic generation of hardware memory architectures for HPC
 
Type and proof structures for concurrency
Type and proof structures for concurrencyType and proof structures for concurrency
Type and proof structures for concurrency
 
Hardware/software security contracts: Principled foundations for building sec...
Hardware/software security contracts: Principled foundations for building sec...Hardware/software security contracts: Principled foundations for building sec...
Hardware/software security contracts: Principled foundations for building sec...
 
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
 
Do you trust your artificial intelligence system?
Do you trust your artificial intelligence system?Do you trust your artificial intelligence system?
Do you trust your artificial intelligence system?
 
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Redes neuronales y reinforcement learning. Aplicación en energía eólica.Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
 
Challenges and Opportunities for AI and Data analytics in Offshore wind
Challenges and Opportunities for AI and Data analytics in Offshore windChallenges and Opportunities for AI and Data analytics in Offshore wind
Challenges and Opportunities for AI and Data analytics in Offshore wind
 

Último

scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Último (20)

Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 

Contract Automata: Towards an Algebra of Contracts - Dr. Gordon J. Pace

  • 1. Contract Automata Towards an Algebra of Contracts Gordon J. Pace Department of Computer Science University of Malta Malta March 2016 Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 2. What’s so Interesting about Contracts? Normative notions — ideal vs actual behaviour. Enabling representation of concepts such as obligations, prohibitions permissions, and exceptional behaviour. Ought-to-do or ought-to-be? Plagued by paradoxes unless one is very careful and restricts the language. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 3. Paradox of Blame Paradox of Blame The law says: You are obliged to hand in Form A on Monday and Form B on Tuesday, unless officials stop you from doing so. But it’s sunny outside: On Monday, John spent a day on the beach, thus not handing in Form A. On Tuesday at 00:00 he was arrested, and taken to court on Wednesday. Prosecuting lawyer: To satisfy his obligation the defendant had to hand in Form A on Monday, which he did not. Hence he should be found guilty. Defendant’s lawyer: But to satisfy the obligation the defendant had to hand in Form B on Tuesday, which he was stopped from doing by officials. He is hence innocent. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 4. Contracts vs. Specifications What are contracts, and are they different from properties or specifications? Obligation to perform x related to the property ‘action taken must include x’ Prohibition from performing x related to the property ‘action taken may not include x’ But what are permission to perform x? Actions may include x? What are violations? And what about liability? Or exceptional (non-ideal) behaviour? Contracts are by definition an agreement between two or more interacting parties but most formal studies regulate a party at a time. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 5. Contract clause #1 “John is permitted to withdraw cash.” John may choose to perform an action ‘withdraw cash’, which the bank is bound to engage with. John may also choose not to perform the action. but if he does and the bank does not allow the bank has violated the contract. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 6. Contract clause #2 “John is obliged to pay an annual fee.” John should perform an action ‘pay annual fee’, If John chooses not to perform the action, he has violated the contract. But the bank is bound to engage with John’s action to allow him to satisfy the contract. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 7. Interacting Systems Interaction has a long history in computer science providing tools such as communication and synchronisation which allow the modelling of directed modalities in a two-party contract setting. We formalise two-party contracts modelling interaction using synchronous composition with multiset-actions. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 8. Synchronous Composition over Multisets of Actions The synchronous composition of two automata Si = Qi , q0i , →i synchronising over alphabet G, is written S1 G S2, is defined to be Q1 × Q2, (q01, q02), → . q1 A −→1 q1 (q1, q2) A −→ (q1, q2) A ∩ G = ∅ q2 A −→2 q2 (q1, q2) A −→ (q1, q2) A ∩ G = ∅ q1 A −→1 q1 q2 B −→2 q2 (q1, q2) A∪B −−−→ (q1, q2) A ∩ G = B ∩ G = ∅ Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 9. But What About the Contract? Contracts are also encoded as automata with states tagged with the contract clauses that will be in force at that point. Contract “Initially, the user (party u) is forbidden from using the service but permitted to pay after which the provider (party p) is obliged to provide the service.” Pu(pay), Fu(service) Op(service) ∅ {service} {pay} {pay, service} anything Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 10. Contract Automata A contract clause is one of the following: Clause ::= Op(a) | Op(!a) | Pp(a) | Pp(!a) A contract automaton is a normal automaton with an additional function Q → 2Clause. The transition relation of contract automata is always total to ensure no deadlock, even after a violation occurs. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 11. Contract Automata A contract clause is one of the following: Clause ::= Op(a) | Op(!a) | Pp(a) | Pp(!a) A contract automaton is a normal automaton with an additional function Q → 2Clause. The transition relation of contract automata is always total to ensure no deadlock, even after a violation occurs. Prohibition Prohibition Fp(a) is just Op(!a). Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 12. Contract Automata A contract clause is one of the following: Clause ::= Op(a) | Op(!a) | Pp(a) | Pp(!a) A contract automaton is a normal automaton with an additional function Q → 2Clause. The transition relation of contract automata is always total to ensure no deadlock, even after a violation occurs. Negative clauses !Op(x) = Pp(!x) !Pp(a) = Op(!a) Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 13. Regulated Two-Party Systems A regulated two-party system synchronising over the set of actions G consists of three parts: (i) the interacting systems S1 and S2 and (ii) the contract A. By composing the contract automaton A with the parties’ behaviour we can then identify what clauses are in force and when, hence allowing analysis for contract violation: (S1 G S2) ΣA. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 14. Contract Violation Given a regulated two-party system, we can now analyse the system automata with respect to the contract clauses and tag violations and the responsible party. Violations can occur on: Transitions: e.g. a transition which contains an action which is prohibited at that point. States: e.g. a state in which a party does not permit (allow) the other party to perform an action which should be permitted. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 15. Obligations Obligation Op(a) brings in constraints on both parties: 1. party p must include the action in any outgoing transition in the composed system; and 2. the other party p must provide a viable action set which allows p to perform all its obligation. The former marks transitions as violations, whereas the latter marks states. viablep(qA, A) df = Op(qA) ⊆ A ∧ Fp(qA) ∩ A = ∅ satO p ((q1, q2)qA A −→ (q1, q2)qA ) df = viablep(qA, A) satO p ((q1, q2)qA ) df = ∃A ∈ acts(qp), A ⊆ Gc · viablep(qA, A ∪ A ) Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 16. Permissions If party p is permitted to perform shared action a, then the other party p must provide p with at least one viable outgoing transition which contains a but does not include any forbidden actions. Violations of a permission occur when no appropriate action is possible, and is thus a property of a state not a transition. We use a semantics that tags as a violation a state in which one party is permitted to perform an action, while the other provides no way of actually doing so. (q1, q2)qA p Pp(a) df = true (q1, q2)qA p Pp(a) df = a ∈ G =⇒ ∃A ∈ acts(qp), A ⊆ Gc · a ∈ A ∧ viablep(qA, A ∪ A ) satP p ((q1, q2)qA ) df = ∀Pp(x) ∈ qA · (q1, q2)qA p Pp(x) Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 17. Breach-incapability A regulated system gives an automaton of all potential behaviours when composed. It is breach-incapable if no violating states and/or transitions are reachable from the initial state. This is stronger than being compliant for one specific run. correct(p, R) df = (∀q ∈ reachableS (R) · satp(q)) ∧ (∀t ∈ reachableT (R) · satp(t)) Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 18. Ordering of contracts based on leniency A contract A is more lenient than another contract A for a particular party p (A p A ) if any system behaviour of p which may violate A may also violate A . This definition allows us to characterise the notion of contract equivalence for a particular party or even for all parties. A p A df = ∀S1, S2 · correct(p, S1, S2 A ) =⇒ correct(p, S1, S2 A) Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 19. Pp(c) Op(a) {a} or {b} or ∅ {a, b} anything p Pp(c) Op(a) Op(a), Pp(b) {a} or ∅ {a, b} {b} {a} or {b} or ∅ {a, b} anything Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 20. Conflicts in Contracts Axiom 1: Opposite permissions conflict: Pp(x) !Pp(x). Axiom 2: Obligation to perform mutually exclusive actions is a conflict: a b Op(a) Op(b). Axiom 3: Conflicts are closed under symmetry: C C C C. Axiom 4: Conflicts are closed under increased strictness: C C ∧ C C C C . Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 21. John and his Bank The contract says that (i) whenever he is logged into his Internet banking account, he is to be permitted to make money transfers; and (ii) if a malicious attempt to log in to his account is identified, logging in and making transfers will be prohibited until the situation is cleared. Fj (transfer) Pj (transfer) Pj (login) Fj (login), Fj (transfer) login logout malicious cleared Note what happens after {login, malicious} in the composition of these contracts. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 22. Adding Reparations Some reparations can be ‘handled’ by contract automata. e.g. “The passenger is obliged to show a means of identification when presenting the ticket, and would otherwise be prohibited from boarding.” Op(proveIdentity)start Fp(boardPlane) {showTicket, proveIdentity} {showTicket} But with such an encoding, we have no notion of which transitions are violating ones. And even worse, we cannot express a reparation of a permission in this manner. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 23. Reparations Pp(boardPlane) Pp(handLuggage) Pp(coat) Pp(report) Oc (inCargo) Pp(report) Oc (inCargo) Op(switchOffDevices) Vc (Pp(coat)) {boardPlane} ok {boardPlane} Vc (Pp(handLuggage)) {boardPlane} Vc (Pp(coat)) ∧ Vc (Pp(handLuggage)) {boardPlane} By tagging each transition with which clauses would have to be violated to take that transition, we can model reparations. In addition, we can talk about hypothetical reparations. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 24. Discussion By keeping the contract as a separate automaton: We share the same formalism and theory as for systems; We are able to reason about contracts independently of the system — e.g. compose contracts using synchronous composition Although we can reduce a regulated system to a single automaton, by keeping the original systems and contract as automaton we keep the system behaviours separate and intact. Permission can only be deduced with this unadulterated behaviour. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts
  • 25. Conclusions The main contributions of this work are: A formalisation of the meaning of directed deontic operators in a two-party setting; The use of standard techniques from computer science, namely communication and synchronisation, to analyse contracts regulating two parties. Practically all the work done on directed obligations and permissions introduces new modalities such as intention, causality, etc. We are now looking into how much further such an automaton based approach supports contract analysis, and extending it to deal with multi-party (n > 2) systems. Gordon J. Pace Contract AutomataTowards an Algebra of Contracts