Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo...

65
university-log Model Checking Contracts A case study Gordon Pace Cristian Prisacariu Gerardo Schneider [email protected] cristi@ifi.uio.no gerardo@ifi.uio.no Department of Informatics, University of Oslo ATVA’07 Tokyo, Japan October 22-25, 2007 Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 1 / 24

Transcript of Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo...

Page 1: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking ContractsA case study

Gordon Pace Cristian Prisacariu Gerardo [email protected] [email protected] [email protected]

Department of Informatics,University of Oslo

ATVA’07Tokyo, Japan

October 22-25, 2007

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 1 / 24

Page 2: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Contracts

“A contract is a binding agreement between two or more persons thatis enforceable by law.” [Webster on-line]

This deed of Agreement is made between:1. [name], from now on referred to as Provider and2. the Client.INTRODUCTION3. The Provider is obliged to provide the Internet Services as stipulated in this Agreement.4. DEFINITIONSa) Internet traffic may be measured by both Client and Provider by means of Equipment

and may take the two values high and normal.OPERATIVE PART1. The Client shall not supply false information to the Client Relations Department of theProvider.2. Whenever the Internet Traffic is high then the Client must pay [price] immediately, or theClient must notify the Provider by sending an e-mail specifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he must immediatelylower the Internet traffic to the normal level, and pay later twice (2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Client will have to pay3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submit within seven (7)days the Personal Data Form from his account on the Provider’s web page to the ClientRelations Department of the Provider.

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 2 / 24

Page 3: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Contracts

“A contract is a binding agreement between two or more persons thatis enforceable by law.” [Webster on-line]

This deed of Agreement is made between:1. [name], from now on referred to as Provider and2. the Client.INTRODUCTION3. The Provider is obliged to provide the Internet Services as stipulated in this Agreement.4. DEFINITIONSa) Internet traffic may be measured by both Client and Provider by means of Equipment

and may take the two values high and normal.OPERATIVE PART1. The Client shall not supply false information to the Client Relations Department of theProvider.2. Whenever the Internet Traffic is high then the Client must pay [price] immediately, or theClient must notify the Provider by sending an e-mail specifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he must immediatelylower the Internet traffic to the normal level, and pay later twice (2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Client will have to pay3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submit within seven (7)days the Personal Data Form from his account on the Provider’s web page to the ClientRelations Department of the Provider.

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 2 / 24

Page 4: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Contracts

We call the above a conventional contractAn e-contract is a machine-readable contract

Two scenarios:1 Obtain an e-contract from a conventional contract

Context: legal (e.g. financial) contracts2 Write the e-contract directly in a formal language

Context: web services, components, OO, etc

DefinitionA contract is a document which engages several parties in a transactionand stipulates their (conditional) obligations, rights, and prohibitions, aswell as penalties in case of contract violations.

A better name: ‘deontic’ e-contracts

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 3 / 24

Page 5: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Contracts

We call the above a conventional contractAn e-contract is a machine-readable contract

Two scenarios:1 Obtain an e-contract from a conventional contract

Context: legal (e.g. financial) contracts2 Write the e-contract directly in a formal language

Context: web services, components, OO, etc

DefinitionA contract is a document which engages several parties in a transactionand stipulates their (conditional) obligations, rights, and prohibitions, aswell as penalties in case of contract violations.

A better name: ‘deontic’ e-contracts

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 3 / 24

Page 6: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Aim and Motivation

Use deontic e-contracts to ‘rule’ services exchange

1 Give a formal language for specifying/writing contracts2 Analyze contracts “internally”

Detect contradictions/inconsistencies staticallyDetermine the obligations (permissions, prohibitions) of a signatoryDetect superfluous contract clauses

3 Develop a theory of contractsContract compositionSubcontractingConformance between a contract and the governing policiesMeta-contracts (policies)

4 Monitor contractsRun-time system to ensure the contract is respectedIn case of contract violations, act accordingly

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 4 / 24

Page 7: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Aim and Motivation

Use deontic e-contracts to ‘rule’ services exchange

1 Give a formal language for specifying/writing contracts2 Analyze contracts “internally”

Detect contradictions/inconsistencies staticallyDetermine the obligations (permissions, prohibitions) of a signatoryDetect superfluous contract clauses

3 Develop a theory of contractsContract compositionSubcontractingConformance between a contract and the governing policiesMeta-contracts (policies)

4 Monitor contractsRun-time system to ensure the contract is respectedIn case of contract violations, act accordingly

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 4 / 24

Page 8: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Aim and Motivation

Use deontic e-contracts to ‘rule’ services exchange

1 Give a formal language for specifying/writing contracts2 Analyze contracts “internally”

Detect contradictions/inconsistencies staticallyDetermine the obligations (permissions, prohibitions) of a signatoryDetect superfluous contract clauses

3 Develop a theory of contractsContract compositionSubcontractingConformance between a contract and the governing policiesMeta-contracts (policies)

4 Monitor contractsRun-time system to ensure the contract is respectedIn case of contract violations, act accordingly

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 4 / 24

Page 9: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Aim and Motivation

Use deontic e-contracts to ‘rule’ services exchange

1 Give a formal language for specifying/writing contracts2 Analyze contracts “internally”

Detect contradictions/inconsistencies staticallyDetermine the obligations (permissions, prohibitions) of a signatoryDetect superfluous contract clauses

3 Develop a theory of contractsContract compositionSubcontractingConformance between a contract and the governing policiesMeta-contracts (policies)

4 Monitor contractsRun-time system to ensure the contract is respectedIn case of contract violations, act accordingly

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 4 / 24

Page 10: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Aim and Motivation

Use deontic e-contracts to ‘rule’ services exchange

1 Give a formal language for specifying/writing contracts2 Analyze contracts “internally”

Detect contradictions/inconsistencies staticallyDetermine the obligations (permissions, prohibitions) of a signatoryDetect superfluous contract clauses

3 Develop a theory of contractsContract compositionSubcontractingConformance between a contract and the governing policiesMeta-contracts (policies)

4 Monitor contractsRun-time system to ensure the contract is respectedIn case of contract violations, act accordingly

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 4 / 24

Page 11: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Outline

1 The Contract Language CL

2 Model Checking Contracts

3 Final Remarks

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 5 / 24

Page 12: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Outline

1 The Contract Language CL

2 Model Checking Contracts

3 Final Remarks

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 6 / 24

Page 13: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

The Contract Specification Language CL

Contract := D ; CC := CO | CP | CF | C ∧ C | [α]C | 〈α〉C | C U C | © C | �CCO := O(α) | CO ⊕ COCP := P(α) | CP ⊕ CPCF := F (α) | CF ∨ [α]CF

O(α), P(α), F (α) specify obligation, permission (rights), andprohibition (forbidden) over actionsα are actions given in the definition part D

+ choice· concatenation (sequencing)

& concurrencyφ? test

∧, ∨, and ⊕ are conjunction, disjunction, and exclusive disjunction[α] and 〈α〉 are the action parameterized modalities of dynamic logicU , ©, and � correspond to temporal logic operators

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 7 / 24

Page 14: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

The Contract Specification Language CL

Contract := D ; CC := CO | CP | CF | C ∧ C | [α]C | 〈α〉C | C U C | © C | �CCO := O(α) | CO ⊕ COCP := P(α) | CP ⊕ CPCF := F (α) | CF ∨ [α]CF

O(α), P(α), F (α) specify obligation, permission (rights), andprohibition (forbidden) over actionsα are actions given in the definition part D

+ choice· concatenation (sequencing)

& concurrencyφ? test

∧, ∨, and ⊕ are conjunction, disjunction, and exclusive disjunction[α] and 〈α〉 are the action parameterized modalities of dynamic logicU , ©, and � correspond to temporal logic operators

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 7 / 24

Page 15: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

The Contract Specification Language CL

Contract := D ; CC := CO | CP | CF | C ∧ C | [α]C | 〈α〉C | C U C | © C | �CCO := O(α) | CO ⊕ COCP := P(α) | CP ⊕ CPCF := F (α) | CF ∨ [α]CF

O(α), P(α), F (α) specify obligation, permission (rights), andprohibition (forbidden) over actionsα are actions given in the definition part D

+ choice· concatenation (sequencing)

& concurrencyφ? test

∧, ∨, and ⊕ are conjunction, disjunction, and exclusive disjunction[α] and 〈α〉 are the action parameterized modalities of dynamic logicU , ©, and � correspond to temporal logic operators

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 7 / 24

Page 16: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

The Contract Specification Language CL

Contract := D ; CC := CO | CP | CF | C ∧ C | [α]C | 〈α〉C | C U C | © C | �CCO := O(α) | CO ⊕ COCP := P(α) | CP ⊕ CPCF := F (α) | CF ∨ [α]CF

O(α), P(α), F (α) specify obligation, permission (rights), andprohibition (forbidden) over actionsα are actions given in the definition part D

+ choice· concatenation (sequencing)

& concurrencyφ? test

∧, ∨, and ⊕ are conjunction, disjunction, and exclusive disjunction[α] and 〈α〉 are the action parameterized modalities of dynamic logicU , ©, and � correspond to temporal logic operators

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 7 / 24

Page 17: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

The Contract Specification Language CL

Contract := D ; CC := CO | CP | CF | C ∧ C | [α]C | 〈α〉C | C U C | © C | �CCO := O(α) | CO ⊕ COCP := P(α) | CP ⊕ CPCF := F (α) | CF ∨ [α]CF

O(α), P(α), F (α) specify obligation, permission (rights), andprohibition (forbidden) over actionsα are actions given in the definition part D

+ choice· concatenation (sequencing)

& concurrencyφ? test

∧, ∨, and ⊕ are conjunction, disjunction, and exclusive disjunction[α] and 〈α〉 are the action parameterized modalities of dynamic logicU , ©, and � correspond to temporal logic operators

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 7 / 24

Page 18: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

More on the Contract LanguageCTD and CTP

Expressing contrary-to-duty (CTD)

OC(α) = O(α) ∧ [α]C

Expressing contrary-to-prohibition (CTP)

FC(α) = F (α) ∧ [α]C

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 8 / 24

Page 19: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

More on the Contract LanguageCTD and CTP

Expressing contrary-to-duty (CTD)

OC(α) = O(α) ∧ [α]C

Expressing contrary-to-prohibition (CTP)

FC(α) = F (α) ∧ [α]C

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 8 / 24

Page 20: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

CL SemanticsCµ – A variant of the modal µ-calculus

Translation into a variant of µ-calculus (Cµ)The syntax of the Cµ logicϕ := P | Z | Pc | > | ¬ϕ | ϕ ∧ ϕ | [γ]ϕ | µZ .ϕ(Z )

Main differences with respect to the classical µ-calculus:

1 Pc is set of propositional constants Oa and Fa, one for each basicaction a

2 Multisets of basic actions: i.e. γ = {a, a, b} is a label

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 9 / 24

Page 21: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

CL SemanticsCµ – A variant of the modal µ-calculus

Translation into a variant of µ-calculus (Cµ)The syntax of the Cµ logicϕ := P | Z | Pc | > | ¬ϕ | ϕ ∧ ϕ | [γ]ϕ | µZ .ϕ(Z )

Main differences with respect to the classical µ-calculus:

1 Pc is set of propositional constants Oa and Fa, one for each basicaction a

2 Multisets of basic actions: i.e. γ = {a, a, b} is a label

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 9 / 24

Page 22: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

CL SemanticsObligation

Obligation

f T (O(a&b)) = 〈{a, b}〉(Oa ∧ Ob)

{a, b}

O(a&b)

Ob

Oa

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 10 / 24

Page 23: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

CL SemanticsObligation

Obligation

f T (O(a&b)) = 〈{a, b}〉(Oa ∧ Ob)

{a, b}

O(a&b)

Ob

Oa

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 10 / 24

Page 24: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Outline

1 The Contract Language CL

2 Model Checking Contracts

3 Final Remarks

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 11 / 24

Page 25: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 26: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 27: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 28: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 29: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 30: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 31: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

1 Model the conventional contract (in English) as a CL expression2 Translate the CL specification into Cµ3 Obtain a Kripke-like model (LTS) from the Cµ formulas4 Translate the LTS into the input language of NuSMV5 Perform model checking using NuSMV

Check the model is ‘good’Check some properties about the client and the provider

6 In case of a counter-example given by NuSMV, interpret it as a CLclause and repeat the model checking process until the property issatisfied

7 In some cases rephrase the original contract

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 12 / 24

Page 32: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyA Contract Example

1. The Client shall not:a) supply false information to the Client Relations Department of the Provider.2. Whenever the Internet Traffic is high then the Client must pay [price]immediately, or the Client must notify the Provider by sending an e-mailspecifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he mustimmediately lower the Internet traffic to the normal level, and pay later twice(2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 13 / 24

Page 33: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyA Contract Example

1. The Client shall not:a) supply false information to the Client Relations Department of the Provider.2. Whenever the Internet Traffic is high then the Client must pay [price]immediately, or the Client must notify the Provider by sending an e-mailspecifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he mustimmediately lower the Internet traffic to the normal level, and pay later twice(2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 13 / 24

Page 34: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �F (fi)

2. Whenever the Internet Traffic is high then the Client must pay [price]immediately, or the Client must notify the Provider by sending an e-mailspecifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he mustimmediately lower the Internet traffic to the normal level, and pay later twice(2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

7. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 35: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �F (fi)

2. Whenever the Internet Traffic is high then the Client must pay [price]immediately, or the Client must notify the Provider by sending an e-mailspecifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he mustimmediately lower the Internet traffic to the normal level, and pay later twice(2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 36: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �FP(s)(fi)

2. Whenever the Internet Traffic is high then the Client must pay [price]immediately, or the Client must notify the Provider by sending an e-mailspecifying that he will pay later.3. If the Client delays the payment as stipulated in 2, after notification he mustimmediately lower the Internet traffic to the normal level, and pay later twice(2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.

6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 37: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �FP(s)(fi)

2. �[h](φ ⇒ O(p + (d&n)))

3. If the Client delays the payment as stipulated in 2, after notification he mustimmediately lower the Internet traffic to the normal level, and pay later twice(2 ∗ [price]).4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.

6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 38: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �FP(s)(fi)

2. �[h](φ ⇒ O(p + (d&n)))

3. �([d&n](O(l) ∧ [l ]♦O(p&p)))

4. If the Client does not lower the Internet traffic immediately, then the Clientwill have to pay 3 ∗ [price].5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.

6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 39: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �FP(s)(fi)

2. �[h](φ ⇒ O(p + (d&n)))

3. �([d&n](O(l) ∧ [l ]♦O(p&p)))

4. �([d&n · l ]♦O(p&p&p))

5. The Client shall, as soon as the Internet Service becomes operative, submitwithin seven (7) days the Personal Data Form from his account on the Provider’sweb page to the Client Relations Department of the Provider.

6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 40: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyTranslating into CL syntax

1. �FP(s)(fi)

2. �[h](φ ⇒ O(p + (d&n)))

3. �([d&n](O(l) ∧ [l ]♦O(p&p)))

4. �([d&n · l ]♦O(p&p&p))

5. �([o]O(sfD))

6. Provider may, at its sole discretion, without notice or giving any reason orincurring any liability for doing so:a) Suspend Internet Services immediately if Client is in breach of Clause 1;

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 14 / 24

Page 41: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyHandcrafting the model

φ = the Internet traffic is highfi = client supplies false information

to Client Relations Departmenth = client increases Internet traffic

to high levelp = client pays [price]d = client delays paymentn = client notifies by e-maill = client lowers the Int. traffic

sfD = client sends the PersonalData Form to Client RelationsDepartment

o = provider activates the InternetService (it becomes operative)

s = provider suspends service

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 15 / 24

Page 42: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyHandcrafting the model

φ = the Internet traffic is highfi = client supplies false information

to Client Relations Departmenth = client increases Internet traffic

to high levelp = client pays [price]d = client delays paymentn = client notifies by e-maill = client lowers the Int. traffic

sfD = client sends the PersonalData Form to Client RelationsDepartment

o = provider activates the InternetService (it becomes operative)

s = provider suspends service

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 15 / 24

Page 43: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model

1. �FP(s)(fi)2. �[h](φ ⇒ O(p + (d&n)))3. �([d&n](O(l) ∧ [l ]♦O(p&p)))

4. �([d&n · l ]♦O(p&p&p))5. �([o]O(sfD))

1, 2, and 4: OK3 and 5: FAIL!

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 16 / 24

Page 44: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model

1. �FP(s)(fi)2. �[h](φ ⇒ O(p + (d&n)))3. �([d&n](O(l) ∧ [l ]♦O(p&p)))

4. �([d&n · l ]♦O(p&p&p))5. �([o]O(sfD))

1, 2, and 4: OK

3 and 5: FAIL!

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 16 / 24

Page 45: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model

1. �FP(s)(fi)2. �[h](φ ⇒ O(p + (d&n)))3. �([d&n](O(l) ∧ [l ]♦O(p&p)))

4. �([d&n · l ]♦O(p&p&p))5. �([o]O(sfD))

1, 2, and 4: OK3 and 5: FAIL!

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 16 / 24

Page 46: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model (cont.)

Failure of 3. It fails since there is a dependency with clause 2We need to combine clauses 2 and 3: it model checks!

Failure on our formalization in CL!Failure of 5. (�([o]O(sfD)))

The system should become operative only once

1 We rewrite the original contract2 This is formulated in CL, written in NuSMV, and it

model checks!

’Failure’ on the original contract!

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 17 / 24

Page 47: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model (cont.)

Failure of 3. It fails since there is a dependency with clause 2We need to combine clauses 2 and 3: it model checks!

Failure on our formalization in CL!

Failure of 5. (�([o]O(sfD)))

The system should become operative only once

1 We rewrite the original contract2 This is formulated in CL, written in NuSMV, and it

model checks!

’Failure’ on the original contract!

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 17 / 24

Page 48: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model (cont.)

Failure of 3. It fails since there is a dependency with clause 2We need to combine clauses 2 and 3: it model checks!

Failure on our formalization in CL!Failure of 5. (�([o]O(sfD)))

The system should become operative only once

1 We rewrite the original contract2 This is formulated in CL, written in NuSMV, and it

model checks!

’Failure’ on the original contract!

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 17 / 24

Page 49: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model (cont.)

Failure of 3. It fails since there is a dependency with clause 2We need to combine clauses 2 and 3: it model checks!

Failure on our formalization in CL!Failure of 5. (�([o]O(sfD)))

The system should become operative only once

1 We rewrite the original contract2 This is formulated in CL, written in NuSMV, and it

model checks!

’Failure’ on the original contract!

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 17 / 24

Page 50: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyChecking the contract on the model (cont.)

Failure of 3. It fails since there is a dependency with clause 2We need to combine clauses 2 and 3: it model checks!

Failure on our formalization in CL!Failure of 5. (�([o]O(sfD)))

The system should become operative only once

1 We rewrite the original contract2 This is formulated in CL, written in NuSMV, and it

model checks!

’Failure’ on the original contract!

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 17 / 24

Page 51: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about client obligations

“It is always the case thatwhenever the Internet traffic ishigh, if the clients paysimmediately, then the client isnot obliged to pay againimmediately afterward”

It fails!We get a counter-example–Problem: state s4We modify the original contractto capture the above moreprecisely

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 18 / 24

Page 52: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about client obligations

“It is always the case thatwhenever the Internet traffic ishigh, if the clients paysimmediately, then the client isnot obliged to pay againimmediately afterward”It fails!

We get a counter-example–Problem: state s4We modify the original contractto capture the above moreprecisely

Fs¬

Ffi

OlOpOsfD ,

Od On, Opφ,

l−

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 18 / 24

Page 53: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about client obligations

“It is always the case thatwhenever the Internet traffic ishigh, if the clients paysimmediately, then the client isnot obliged to pay againimmediately afterward”It fails!We get a counter-example–Problem: state s4

We modify the original contractto capture the above moreprecisely

Fs¬

Ffi

OlOpOsfD ,

l−

Od On, Opφ,

sfD

o

l

s

fi

{d,n}

fi hp

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 18 / 24

Page 54: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about client obligations

“It is always the case thatwhenever the Internet traffic ishigh, if the clients paysimmediately, then the client isnot obliged to pay againimmediately afterward”It fails!We get a counter-example–Problem: state s4We modify the original contractto capture the above moreprecisely

Fs¬

Ffi

OlOpOsfD ,

l−

Od On,

sfD

o

l

s

fi

{d,n}

fi h

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

φ

p

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 18 / 24

Page 55: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about payment in case of increasing Internet traffic

“It is always the case thatwhenever Internet traffic is high, ifthe client delays payment andnotifies, and afterward lowers theInternet traffic, then the client isforbidden to increase Internettraffic until he pays twice”

It fails!Counter-example: From s4 (φholds), after d&n · l , it ispossible to increase Internettraffic in state s7, so neitherF (h) nor donep&p holdAdd to the original contract theclause above!

Fs¬

Ffi

OlOpOsfD ,

l−

Od On,

sfD

o

l

s

fi

{d,n}

fi h

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

p

φ

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 19 / 24

Page 56: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about payment in case of increasing Internet traffic

“It is always the case thatwhenever Internet traffic is high, ifthe client delays payment andnotifies, and afterward lowers theInternet traffic, then the client isforbidden to increase Internettraffic until he pays twice”

It fails!

Counter-example: From s4 (φholds), after d&n · l , it ispossible to increase Internettraffic in state s7, so neitherF (h) nor donep&p holdAdd to the original contract theclause above!

Fs¬

Ffi

OlOpOsfD ,

l−

Od On,

sfD

o

l

s

fi

{d,n}

fi h

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

p

φ

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 19 / 24

Page 57: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about payment in case of increasing Internet traffic

“It is always the case thatwhenever Internet traffic is high, ifthe client delays payment andnotifies, and afterward lowers theInternet traffic, then the client isforbidden to increase Internettraffic until he pays twice”

It fails!Counter-example: From s4 (φholds), after d&n · l , it ispossible to increase Internettraffic in state s7, so neitherF (h) nor donep&p hold

Add to the original contract theclause above!

Fs¬

Ffi

l−

Od On,

OpOsfD ,Ol

sfD

o

l

s

fi

{d,n}

fi h

fi

fifi

fi

fi

else

else

s3

s4s5

s7s6

s8

s1

s2

p

φ

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 19 / 24

Page 58: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Case StudyVerifying a property about payment in case of increasing Internet traffic

“It is always the case thatwhenever Internet traffic is high, ifthe client delays payment andnotifies, and afterward lowers theInternet traffic, then the client isforbidden to increase Internettraffic until he pays twice”

It fails!Counter-example: From s4 (φholds), after d&n · l , it ispossible to increase Internettraffic in state s7, so neitherF (h) nor donep&p holdAdd to the original contract theclause above!

Fs¬

Ffi

OlOpOsfD ,

l−

Od On,

sfD

o

l

s

fi

{d,n}

fi h

fi

fifi

fi

fi

s3

s4s5

s7s6

s8

s1

s2

p

φ

{p,p,p}

{p,p}

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 19 / 24

Page 59: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Outline

1 The Contract Language CL

2 Model Checking Contracts

3 Final Remarks

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 20 / 24

Page 60: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

Initial ideas on how to model check contracts

Based on:

A formal specification language for contracts with semantics based ona variant of µ-calculus

Use of model checking for reasoning about contracts:

1 We use model checking to increase our confidence in the correctnessof the model with respect to the original natural language contract

2 By finding errors in the model, we identify problems in the originalnatural language contract or its interpretation in CL

3 We enable the signatories to safeguard their interests by ensuringcertain desirable properties hold (and certain undesirable ones do not)

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 21 / 24

Page 61: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Model Checking Contracts

Initial ideas on how to model check contracts

Based on:

A formal specification language for contracts with semantics based ona variant of µ-calculus

Use of model checking for reasoning about contracts:

1 We use model checking to increase our confidence in the correctnessof the model with respect to the original natural language contract

2 By finding errors in the model, we identify problems in the originalnatural language contract or its interpretation in CL

3 We enable the signatories to safeguard their interests by ensuringcertain desirable properties hold (and certain undesirable ones do not)

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 21 / 24

Page 62: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Current and Further Work

Currently:Direct semantics: “Normative” automataRedesign CLAutomate the model checking process

Further work:Develop a proof systemInternal vs external operationsAdd timeCase studiesExplore how to extract a contract monitor (?!)

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 22 / 24

Page 63: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Current and Further Work

Currently:Direct semantics: “Normative” automataRedesign CLAutomate the model checking process

Further work:Develop a proof systemInternal vs external operationsAdd timeCase studiesExplore how to extract a contract monitor (?!)

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 22 / 24

Page 64: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Thank you!

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 23 / 24

Page 65: Model Checking Contracts A case studygersch/slides-talks/slides-ATVA-07.pdf · university-logo ModelCheckingContracts Acasestudy GordonPace CristianPrisacariu GerardoSchneider gordon.pace@um.edu.mt

university-logo

Links and Papers

C. Prisacariu and G. Schneider. A formal language for electroniccontracts. In FMOODS’07, vol. 4468 of LNCS, pages 174-189, June2007

COSoDIS: “Contract-Oriented Software Development for InternetServices” –A Nordunet3 project(http://folk.uio.no/gerardo/nordunet3/index.shtml)

FLACOS’07 – 1st Workshop on Formal Languages and Analysis ofContract-Oriented Software (http://www.ifi.uio.no/flacos07/)

Oslo, 9-10 October 2007

Gerardo Schneider (UiO) Model Checking Contracts ATVA’07 Tokyo, Japan 24 / 24