From OCL to Propositional and First-order Logic: Part...

87
22c181: Formal Methods in Software Engineering The University of Iowa Spring 2008 From OCL to Propositional and First-order Logic: Part I Copyright 2007-8 Reiner Hähnle and Cesare Tinelli. Notes originally developed by Reiner Hähnle at Chalmers University and modified by Cesare Tinelli at the University of Iowa. These notes are copyrighted materials and may not be used in other course settings outside of the University of Iowa in their current form or modified form without the express written permission of one of the copyright holders. 22c181: Formal Methods in Software Engineering – p.1/32

Transcript of From OCL to Propositional and First-order Logic: Part...

Page 1: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

22c181:Formal Methods in Software Engineering

The University of Iowa

Spring 2008

From OCL to Propositional andFirst-order Logic: Part I

Copyright 2007-8 Reiner Hähnle and Cesare Tinelli.

Notes originally developed by Reiner Hähnle at Chalmers Uni versity and modified by Cesare Tinelli at the University of Io wa. These notes

are copyrighted materials and may not be used in other course settings outside of the University of Iowa in their current f orm or modified

form without the express written permission of one of the cop yright holders.22c181: Formal Methods in Software Engineering – p.1/32

Page 2: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Contents

Overview of KeY

UML and its semantics

Introduction to OCL

Specifying requirements with OCL

Modelling of Systems with Formal Semantics

Propositional & First-order logic, sequent calculus

OCL to Logic, horizontal proof obligations, using KeY

Dynamic logic, proving program correctness

Java Card DL

Vertical proof obligations, using KeY

Wrap-up, trends

22c181: Formal Methods in Software Engineering – p.2/32

Page 3: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �

22c181: Formal Methods in Software Engineering – p.3/32

Page 4: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �I(Vehicle) = {harley17,bmw3}

22c181: Formal Methods in Software Engineering – p.3/32

Page 5: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �I(Vehicle) = {harley17,bmw3}

⇒ harley17.I(owner).I(age) ≥ 18 and bmw3.I(owner).I(age) ≥ 18

22c181: Formal Methods in Software Engineering – p.3/32

Page 6: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �I(Vehicle) = {harley17,bmw3}

⇒ harley17.I(owner).I(age) ≥ 18 and bmw3.I(owner).I(age) ≥ 18

I(owner) : Vehicle → Person

22c181: Formal Methods in Software Engineering – p.3/32

Page 7: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �I(Vehicle) = {harley17,bmw3}

⇒ harley17.I(owner).I(age) ≥ 18 and bmw3.I(owner).I(age) ≥ 18

I(owner)(harley17) = I(owner)(bmw3) = id0825

22c181: Formal Methods in Software Engineering – p.3/32

Page 8: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �I(Vehicle) = {harley17,bmw3}

⇒ harley17.I(owner).I(age) ≥ 18 and bmw3.I(owner).I(age) ≥ 18

I(owner)(harley17) = I(owner)(bmw3) = id0825

⇒ id0825 .I(age) ≥ 18

22c181: Formal Methods in Software Engineering – p.3/32

Page 9: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reminder: Object Diagrams and OCL

id0815:Person

name = ‘‘Jane’’

age = 5

harley17:Bike

colour = idBlack

idBlack:Colour

black() = idBlack

white() = idWhite

red() = idRed

id0825:Person

name = ‘‘Paul’’

age = 25

bmw3:Car

colour = idWhite

idWhite:Colour

black() = idBlack

white() = idWhite

red() = idRed

idRed:Colour

black() = idBlack

white() = idWhite

red() = idRed

ownership

ownership

context Vehicleinv: self.owner.age >= 18 �I(Vehicle) = {harley17,bmw3}

⇒ harley17.I(owner).I(age) ≥ 18 and bmw3.I(owner).I(age) ≥ 18

I(owner)(harley17) = I(owner)(bmw3) = id0825

⇒ id0825 .I(age) ≥ 18

I(age)(id0825 ) = 25 ⇒ 25 ≥ 18 �22c181: Formal Methods in Software Engineering – p.3/32

Page 10: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

OCL and Formal Proofs

Snapshots provide formal semantics for UML and OCL

⇒ can formally prove properties of model and implementation

22c181: Formal Methods in Software Engineering – p.4/32

Page 11: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

OCL and Formal Proofs

Snapshots provide formal semantics for UML and OCL

⇒ can formally prove properties of model and implementation

Examples:

Invariant of class A implies invariant of class B

For each snapshot I : if A’s invariant holds in I , then so does B’s

Horizontal verification problem (within specification)

Implementation of operation m fulfills its contract

For each snapshot I : if precondition of m holds in I , then itspostcondition holds in snapshot I ′ produced by execution of m

Vertical verification problem (implementation against specification)

22c181: Formal Methods in Software Engineering – p.4/32

Page 12: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Snapshots and States: Static View

Snaphots have static and dynamic part

22c181: Formal Methods in Software Engineering – p.5/32

Page 13: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Snapshots and States: Static View

Snaphots have static and dynamic part

Static (object diagram): objects, attribute values, association s

Static part of snapshot similar to execution state of program

Denote such states with s, set of all states S (infinite!)Think of one single state as object diagram

Proving horizontal verification problem: state inclusion

22c181: Formal Methods in Software Engineering – p.5/32

Page 14: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Snapshots and States: Static View

Snaphots have static and dynamic part

Static (object diagram): objects, attribute values, association s

Static part of snapshot similar to execution state of program

Denote such states with s, set of all states S (infinite!)Think of one single state as object diagram

Proving horizontal verification problem: state inclusion

Example: Let invA be invariant of class A, invB invariant of class B

{s ∈ S | invA holds in s} ⊆ {s ∈ S | invB holds in s}

22c181: Formal Methods in Software Engineering – p.5/32

Page 15: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Snapshots and States: Dynamic View

Program state s = static part of snapshotSet of all states S

Dynamic part of snapshot:

Semantics of operations m: ρ(m) : S → S

Operation can be seen as state transformer

For each m and s ∈ S result state ρ(m)(s)ρ is partial function : programs deterministic , may not terminate

Proving vertical verification problem: state reachability

22c181: Formal Methods in Software Engineering – p.6/32

Page 16: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Snapshots and States: Dynamic View

Program state s = static part of snapshotSet of all states S

Dynamic part of snapshot:

Semantics of operations m: ρ(m) : S → S

Operation can be seen as state transformer

For each m and s ∈ S result state ρ(m)(s)ρ is partial function : programs deterministic , may not terminate

Proving vertical verification problem: state reachability

Example: Let pre be precondition, post postcondition of m

Does post hold in all states s′ ∈ {ρ(m)(s) | s satisfies pre}?

Does post hold in all states s′ that can be reached via m

from any state s satisfying pre?22c181: Formal Methods in Software Engineering – p.6/32

Page 17: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Dynamic Part of Snapshots as LTS

(Deterministic) Labelled Transition System (LTS) K = (S,ρ):

S set of states, ρ : Method → (S → S) (takes a program and returns a

map from S to S), α = ρ(m), β = ρ(m′)a

a

s1 s2

s4

s5 s6 s3

β

α β

β

αβ

α

a

Infinite number of states ⇒ need theorem proving (or approximation)22c181: Formal Methods in Software Engineering – p.7/32

Page 18: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Dynamic Part of Snapshots as LTS

Each state is a static snapshot (ie, object diagram) with the current

objects and values.

If ρ(m) takes, say, state s1 into s4, then a directed edge from s1 to s4

labelled with ρ(m) is present in K.

ρ(m) is then a (possibly infinite) number of pre-/post execution

state pairs.

There is no explicit notion of initial state.

One may consider as initial states those that satisfy the

precondition of a distinguished main method (and possibly the

invariant of its class).

22c181: Formal Methods in Software Engineering – p.8/32

Page 19: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Encoding Verification Problem in Logic

UML Model

CASE Tool

Java (Card)(partial implementation)

Java (Card) OCL

OCL ParserUniv Dresden

AST

XMLAPI

Patterns/Idioms

OCL(partial specification)

Translation

RecodeR

Univ Karlsruhe

AST

FOL/Java Card DLformula synthesis (vert. verif.)

Formal proof

Interactive/Automated Theorem Prover

22c181: Formal Methods in Software Engineering – p.9/32

Page 20: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Why translate OCL into Logic?

22c181: Formal Methods in Software Engineering – p.10/32

Page 21: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Why translate OCL into Logic?

Difficult and expensive to develop theorem prover for a forma lism

OCL only one of many specification languages (JML, RSL, etc.)

OCL prone to change (1.3, 1.4, 1.5, . . . , 2.0, . . . ?)

First order logic (FOL) well understood, mature tools“FOL in verification like the Reals in Calculus”

22c181: Formal Methods in Software Engineering – p.10/32

Page 22: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Why translate OCL into Logic?

Difficult and expensive to develop theorem prover for a forma lism

OCL only one of many specification languages (JML, RSL, etc.)

OCL prone to change (1.3, 1.4, 1.5, . . . , 2.0, . . . ?)

First order logic (FOL) well understood, mature tools“FOL in verification like the Reals in Calculus”

OCL not designed for verification, programming language ind ependent

OCL (UML) doesn’t know about implementation of operationsNeed to incorporate Java data types and programs

OCL not designed to express verification problems

OCL doesn’t know about (class) initialization (<2.0)22c181: Formal Methods in Software Engineering – p.10/32

Page 23: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Contents

Overview of KeY

UML and its semantics

Introduction to OCL

Specifying requirements with OCL

Modelling of Systems with Formal Semantics

Propositional & First-order logic, sequent calculus

OCL to Logic, horizontal proof obligations, using KeY

Dynamic logic, proving program correctness

Java Card DL

Vertical proof obligations, using KeY

Wrap-up, trends

22c181: Formal Methods in Software Engineering – p.11/32

Page 24: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formalisation

Real

World

Formal

Model

Formalisation

22c181: Formal Methods in Software Engineering – p.12/32

Page 25: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formalisation

Real

World

Formal

Language

Formal

Semantics

22c181: Formal Methods in Software Engineering – p.12/32

Page 26: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formalisation

Real

WorldI , ρ

UMLOCLJava

Snapshots/LTS

22c181: Formal Methods in Software Engineering – p.12/32

Page 27: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formalisation

Real

World

I , ρ

UMLOCLJava

Snapshots/LTS

“infinite”

22c181: Formal Methods in Software Engineering – p.12/32

Page 28: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formalisation

Real

World

I , ρ

UMLOCLJava

Snapshots/LTS

“infinite”

Calculus

“finite”

22c181: Formal Methods in Software Engineering – p.12/32

Page 29: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formal Verification

Real

World

I , ρ

UMLOCLJava

Snapshot/LTS

“infinite”

Calculus

“finite”

22c181: Formal Methods in Software Engineering – p.13/32

Page 30: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formal Verification

Real

World

I , ρ

UMLOCLJava

Obj. Diagr.

Snapshot/LTS

Calculus

22c181: Formal Methods in Software Engineering – p.13/32

Page 31: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formal Verification

Real

World

I , ρ

UMLOCLJava

Obj. Diagr.

Snapshot/LTS

Calculus

I , ρ

FO LogicDyn. Logic

FO Interp.

Kripke Str.

Translation

22c181: Formal Methods in Software Engineering – p.13/32

Page 32: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Formal Verification

Real

World

I , ρ

UMLOCLJava

Obj. Diagr.

Snapshot/LTS

Calculus

I , ρ

FO LogicDyn. Logic

FO Interp.

Kripke Str.

Translation

I , ρ, |=

FO LogicDyn. Logic

FO Interp.

Kripke Str.

SequentCalculus

22c181: Formal Methods in Software Engineering – p.13/32

Page 33: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax, Semantics, Calculus

I , ρ, |=

Syntax“Formula”

Semantics

“Valid”

Calculus“Derivable”

22c181: Formal Methods in Software Engineering – p.14/32

Page 34: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax, Semantics, Calculus

I , ρ, |=

Syntax“Formula”

Semantics

“Valid”

Calculus“Derivable”

⊢Completeness

22c181: Formal Methods in Software Engineering – p.14/32

Page 35: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax, Semantics, Calculus

I , ρ, |=

Syntax“Formula”

Semantics

“Valid”

Calculus“Derivable”

⊢Completeness

Soundness

22c181: Formal Methods in Software Engineering – p.14/32

Page 36: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic

I , |=

PropositionalFormulas

MappingVariables into{true, false}

SequentCalculus

SAT solver

22c181: Formal Methods in Software Engineering – p.15/32

Page 37: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic

I , |=

PropositionalFormulas

MappingVariables into{true, false}

SequentCalculus

22c181: Formal Methods in Software Engineering – p.15/32

Page 38: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Contents

Overview of KeY

UML and its semantics

Introduction to OCL

Specifying requirements with OCL

Modelling of Systems with Formal Semantics

Propositional & First-order logic, sequent calculus

OCL to Logic, horizontal proof obligations, using KeY

Dynamic logic, proving program correctness

Java Card DL

Vertical proof obligations, using KeY

Wrap-up, trends

22c181: Formal Methods in Software Engineering – p.16/32

Page 39: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic: Syntax

I , |=

PropositionalFormulas

MappingVariables into{true, false}

SequentCalculus

22c181: Formal Methods in Software Engineering – p.17/32

Page 40: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax of Propositional Logic

The Signature :

Propositional Variables P = {pi|i ∈ IN} with type Boolean

22c181: Formal Methods in Software Engineering – p.18/32

Page 41: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax of Propositional Logic

The Signature :

Propositional Variables P = {pi|i ∈ IN} with type Boolean

Connectives {true , false , &, | , !, -> , <-> }

22c181: Formal Methods in Software Engineering – p.18/32

Page 42: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax of Propositional Logic

The Signature :

Propositional Variables P = {pi|i ∈ IN} with type Boolean

Connectives {true , false , &, | , !, -> , <-> }

Propositional Formulas For0 (all have type Boolean)

Truth constants ‘true’, ‘false’ and variables P are formulas

22c181: Formal Methods in Software Engineering – p.18/32

Page 43: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Syntax of Propositional Logic

The Signature :

Propositional Variables P = {pi|i ∈ IN} with type Boolean

Connectives {true , false , &, | , !, -> , <-> }

Propositional Formulas For0 (all have type Boolean)

Truth constants ‘true’, ‘false’ and variables P are formulas

If G and H are formulas then

!G, (G&H), (G | H), (G -> H), (G <-> H)

are also formulas

There are no other formulas (inductive definition)

22c181: Formal Methods in Software Engineering – p.18/32

Page 44: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic: Semantics

I , |=

PropositionalFormulas

MappingVariables into{true, false}

SequentCalculus

22c181: Formal Methods in Software Engineering – p.19/32

Page 45: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Semantics of Propositional Logic

Interpretation I

Assigns a truth value to each propositional variable

I : P → {true, false}

22c181: Formal Methods in Software Engineering – p.20/32

Page 46: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Semantics of Propositional Logic

Interpretation I

Assigns a truth value to each propositional variable

I : P → {true, false}

Valuation function valI : extension of I to For0

valI : For 0 → {true, false}

22c181: Formal Methods in Software Engineering – p.20/32

Page 47: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Semantics of Propositional Logic

Interpretation I

Assigns a truth value to each propositional variable

I : P → {true, false}

Valuation function valI : extension of I to For0

valI : For 0 → {true, false}

valI(pi) = I(pi)

valI(true ) = true

valI(false ) = false

valI(G -> H) =

true if valI(G) = false or

valI(H) = true

false otherwise

etc.

I satisfies G if valI(G) = true; otherwise, it falsifies G.22c181: Formal Methods in Software Engineering – p.20/32

Page 48: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Example

Formula

p -> (q -> p)

22c181: Formal Methods in Software Engineering – p.21/32

Page 49: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Example

Formula

p -> (q -> p)

Interpretation (one of four that are possible)

I(p) = true

I(q) = false

22c181: Formal Methods in Software Engineering – p.21/32

Page 50: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Example

Formula

p -> (q -> p)

Interpretation (one of four that are possible)

I(p) = true

I(q) = false

Valuation

valI( q -> p ) = true

22c181: Formal Methods in Software Engineering – p.21/32

Page 51: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Example

Formula

p -> (q -> p)

Interpretation (one of four that are possible)

I(p) = true

I(q) = false

Valuation

valI( q -> p ) = true

valI( p -> (q -> p) ) = true

22c181: Formal Methods in Software Engineering – p.21/32

Page 52: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Semantic Notions

Let G ∈ For 0, Γ ⊂ For0

Validity Relation |=

G is valid in I iff valI(G) = true (write: I |= G)

A formula that is valid in some interpretation is satisfiable

Γ entails G (Γ |= G) iff for all interpretations I:

If I |=H for all H ∈ Γ then also I |= G

If G is valid in any interpretation, i.e

∅ |= G (short : |= G)

then G is called logically valid

22c181: Formal Methods in Software Engineering – p.22/32

Page 53: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic Examples

p & ((!p) | q)

Satisfiable?

22c181: Formal Methods in Software Engineering – p.23/32

Page 54: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic Examples

p & ((!p) | q)

Satisfiable? Yes

22c181: Formal Methods in Software Engineering – p.23/32

Page 55: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic Examples

p & ((!p) | q)

Satisfiable? Yes

Satisfying Interpretation?

22c181: Formal Methods in Software Engineering – p.23/32

Page 56: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic Examples

p & ((!p) | q)

Satisfiable? Yes

Satisfying Interpretation? I(p) = true, I(q) = true

22c181: Formal Methods in Software Engineering – p.23/32

Page 57: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic Examples

p & ((!p) | q)

Satisfiable? Yes

Satisfying Interpretation? I(p) = true, I(q) = true

p & ((!p) | q) |= q | r

Does this hold?

22c181: Formal Methods in Software Engineering – p.23/32

Page 58: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic Examples

p & ((!p) | q)

Satisfiable? Yes

Satisfying Interpretation? I(p) = true, I(q) = true

p & ((!p) | q) |= q | r

Does this hold? Yes. Why?

22c181: Formal Methods in Software Engineering – p.23/32

Page 59: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic

I, |=

PropositionalFormulas

MappingVariables into{true, false}

SequentCalculus

22c181: Formal Methods in Software Engineering – p.24/32

Page 60: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reasoning by Syntactic Transformation

Establish |= G by finite syntactic transformations of G

22c181: Formal Methods in Software Engineering – p.25/32

Page 61: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reasoning by Syntactic Transformation

Establish |= G by finite syntactic transformations of G

(Logic) Calculus: a set of syntactic transformation rules R defining

a property ⊢ over For0 such that |= G iff ⊢ G (G is derivable )

|= G implies ⊢ G (Completeness ) ⊢ G implies |= G (Soundness )

22c181: Formal Methods in Software Engineering – p.25/32

Page 62: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Reasoning by Syntactic Transformation

Establish |= G by finite syntactic transformations of G

(Logic) Calculus: a set of syntactic transformation rules R defining

a property ⊢ over For0 such that |= G iff ⊢ G (G is derivable )

|= G implies ⊢ G (Completeness ) ⊢ G implies |= G (Soundness )

Sequent Calculus based on notion of sequent

ψ1, . . . ,ψm︸ ︷︷ ︸

Antecedent

==> φ1, . . . , φn︸ ︷︷ ︸

Succedent

has same semantics as

(ψ1& · · ·&ψm) -> (φ1 | · · · | φn)

{ψ1, . . . ,ψm} |= φ1 | · · · | φn

22c181: Formal Methods in Software Engineering – p.25/32

Page 63: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Notation for Sequents

ψ1, . . . ,ψm ==> φ1, . . . , φn

Consider antecedent/succedent as sets of formulas, may be e mpty

Use schema variables Γ, φ, . . . that match (sets of) formulasCharacterize infinitely many formulas with a single sequent

Γ ==> ∆, φ& ψ

Matches any sequent with occurrence of conjunction in succe dent

Call φ&ψ main formula and Γ,∆ side formulas of sequent

Any sequent of the form Γ, φ ==> ∆, φ is logically valid, and is called an

axiom22c181: Formal Methods in Software Engineering – p.26/32

Page 64: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Sequent Calculus Rules

Basic idea: write syntactic transformation schema for sequents thatreflects semantics of connectives as closely as possible

rule name

Premisses︷ ︸︸ ︷

Γ1 ==> ∆1 · · · Γr ==> ∆r

Γ ==> ∆︸ ︷︷ ︸

Conclusion

22c181: Formal Methods in Software Engineering – p.27/32

Page 65: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Sequent Calculus Rules

Basic idea: write syntactic transformation schema for sequents thatreflects semantics of connectives as closely as possible

rule name

Premisses︷ ︸︸ ︷

Γ1 ==> ∆1 · · · Γr ==> ∆r

Γ ==> ∆︸ ︷︷ ︸

Conclusion

Example AND_RIGHTΓ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

22c181: Formal Methods in Software Engineering – p.27/32

Page 66: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Sequent Calculus Rules

Basic idea: write syntactic transformation schema for sequents thatreflects semantics of connectives as closely as possible

rule name

Premisses︷ ︸︸ ︷

Γ1 ==> ∆1 · · · Γr ==> ∆r

Γ ==> ∆︸ ︷︷ ︸

Conclusion

Example AND_RIGHTΓ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

Rules can have zero premisses (iff conclusion is valid, eg. a n axiom)

22c181: Formal Methods in Software Engineering – p.27/32

Page 67: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Sequent Calculus Rules

Basic idea: write syntactic transformation schema for sequents thatreflects semantics of connectives as closely as possible

rule name

Premisses︷ ︸︸ ︷

Γ1 ==> ∆1 · · · Γr ==> ∆r

Γ ==> ∆︸ ︷︷ ︸

Conclusion

Example AND_RIGHTΓ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

A rule is sound if every interpretation that satisfies each premiss of

the rule also satisfies its conclusion (essential property)

22c181: Formal Methods in Software Engineering – p.27/32

Page 68: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Sequent Calculus Rules

Basic idea: write syntactic transformation schema for sequents thatreflects semantics of connectives as closely as possible

rule name

Premisses︷ ︸︸ ︷

Γ1 ==> ∆1 · · · Γr ==> ∆r

Γ ==> ∆︸ ︷︷ ︸

Conclusion

Example AND_RIGHTΓ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

A rule is sound if every interpretation that satisfies each premiss of

the rule also satisfies its conclusion (essential property)

A rule is complete if every interpretation that satisfies its

conclusion also satisfies each of its premisses (desirable p roperty)22c181: Formal Methods in Software Engineering – p.27/32

Page 69: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Rules of Propositional Sequent Calculus

main left side (work on antecedent) right side (work on succedent)

notΓ ==> φ,∆

Γ, !φ ==> ∆

Γ, φ ==> ∆

Γ ==> !φ,∆

22c181: Formal Methods in Software Engineering – p.28/32

Page 70: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Rules of Propositional Sequent Calculus

main left side (work on antecedent) right side (work on succedent)

notΓ ==> φ,∆

Γ, !φ ==> ∆

Γ, φ ==> ∆

Γ ==> !φ,∆

andΓ, φ,ψ ==> ∆

Γ, φ&ψ ==> ∆

Γ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

22c181: Formal Methods in Software Engineering – p.28/32

Page 71: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Rules of Propositional Sequent Calculus

main left side (work on antecedent) right side (work on succedent)

notΓ ==> φ,∆

Γ, !φ ==> ∆

Γ, φ ==> ∆

Γ ==> !φ,∆

andΓ, φ,ψ ==> ∆

Γ, φ&ψ ==> ∆

Γ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

orΓ, φ ==> ∆ Γ,ψ ==> ∆

Γ, φ | ψ ==> ∆

Γ ==> φ,ψ,∆

Γ ==> φ | ψ,∆

22c181: Formal Methods in Software Engineering – p.28/32

Page 72: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Rules of Propositional Sequent Calculus

main left side (work on antecedent) right side (work on succedent)

notΓ ==> φ,∆

Γ, !φ ==> ∆

Γ, φ ==> ∆

Γ ==> !φ,∆

andΓ, φ,ψ ==> ∆

Γ, φ&ψ ==> ∆

Γ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

orΓ, φ ==> ∆ Γ,ψ ==> ∆

Γ, φ | ψ ==> ∆

Γ ==> φ,ψ,∆

Γ ==> φ | ψ,∆

impΓ ==> φ,∆ Γ,ψ ==> ∆

Γ, φ -> ψ ==> ∆

Γ, φ ==> ψ,∆

Γ ==> φ -> ψ,∆

22c181: Formal Methods in Software Engineering – p.28/32

Page 73: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Rules of Propositional Sequent Calculus

main left side (work on antecedent) right side (work on succedent)

notΓ ==> φ,∆

Γ, !φ ==> ∆

Γ, φ ==> ∆

Γ ==> !φ,∆

andΓ, φ,ψ ==> ∆

Γ, φ&ψ ==> ∆

Γ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

orΓ, φ ==> ∆ Γ,ψ ==> ∆

Γ, φ | ψ ==> ∆

Γ ==> φ,ψ,∆

Γ ==> φ | ψ,∆

impΓ ==> φ,∆ Γ,ψ ==> ∆

Γ, φ -> ψ ==> ∆

Γ, φ ==> ψ,∆

Γ ==> φ -> ψ,∆

CLOSEΓ, φ ==> φ,∆

TRUEΓ ==> true ,∆

FALSEΓ, false ==> ∆

22c181: Formal Methods in Software Engineering – p.28/32

Page 74: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Justification of Rules

Compute rules by applying semantics definition of connectiv es

22c181: Formal Methods in Software Engineering – p.29/32

Page 75: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Justification of Rules

Compute rules by applying semantics definition of connectiv es

OR_RIGHTΓ ==> φ,ψ,∆

Γ ==> φ | ψ,∆

Follows directly from semantics of sequents

22c181: Formal Methods in Software Engineering – p.29/32

Page 76: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Justification of Rules

Compute rules by applying semantics definition of connectiv es

OR_RIGHTΓ ==> φ,ψ,∆

Γ ==> φ | ψ,∆

Follows directly from semantics of sequents

AND_RIGHTΓ ==> φ,∆ Γ ==> ψ,∆

Γ ==> φ&ψ,∆

Γ -> (φ&ψ) | ∆ iff Γ -> φ | ∆ and Γ -> ψ | ∆

Distributivity of & over | and ->

22c181: Formal Methods in Software Engineering – p.29/32

Page 77: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Sequent Calculus Proofs

Goal to prove: G = ψ1, . . . ,ψm ==> φ1, . . . , φn

find rule R whose conclusion matches G

instantiate R such that conclusion identical to G

recursively find proofs for resulting premisses G1, . . . , Gr

tree structure with goal as root

close proof branch when rule without premise encountered

Goal-directed proof search

In KeY tool proof displayed as J AVA Swing tree

22c181: Formal Methods in Software Engineering – p.30/32

Page 78: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

A Simple Proof

==> (A& (A -> B)) -> B

22c181: Formal Methods in Software Engineering – p.31/32

Page 79: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

A Simple Proof

A& (A -> B) ==> B

==> (A& (A -> B)) -> B

By imp rightΓ, φ ==> ψ,∆

Γ ==> φ -> ψ,∆

22c181: Formal Methods in Software Engineering – p.31/32

Page 80: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

A Simple Proof

A, (A -> B) ==> B

A& (A -> B) ==> B

==> (A& (A -> B)) -> B

By and leftΓ, φ,ψ ==> ∆

Γ, φ&ψ ==> ∆

22c181: Formal Methods in Software Engineering – p.31/32

Page 81: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

A Simple Proof

A ==> B,A A,B ==> B

A, (A -> B) ==> B

A& (A -> B) ==> B

==> (A& (A -> B)) -> B

By imp leftΓ ==> φ,∆ Γ,ψ ==> ∆

Γ, φ -> ψ ==> ∆

22c181: Formal Methods in Software Engineering – p.31/32

Page 82: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

A Simple Proof

CLOSE∗

A ==> B,A

A,B ==> B

CLOSE

A, (A -> B) ==> B

A& (A -> B) ==> B

==> (A& (A -> B)) -> B

By closeΓ, φ ==> φ,∆

22c181: Formal Methods in Software Engineering – p.31/32

Page 83: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

A Simple Proof

CLOSE∗

A ==> B,A

A,B ==> B

CLOSE

A, (A -> B) ==> B

A& (A -> B) ==> B

==> (A& (A -> B)) -> B

A proof is closed , if all its branches are closed.

22c181: Formal Methods in Software Engineering – p.31/32

Page 84: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic is insufficient

A ALL PERSONS ARE HAPPY

22c181: Formal Methods in Software Engineering – p.32/32

Page 85: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic is insufficient

A

B

ALL PERSONS ARE HAPPY

PAT IS A PERSON

22c181: Formal Methods in Software Engineering – p.32/32

Page 86: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic is insufficient

A

B

?

ALL PERSONS ARE HAPPY

PAT IS A PERSON

PAT IS HAPPY

Propositional logic lacks possibility to talk about indivi duals

In particular, need to model objects, attributes, associat ions, etc.

22c181: Formal Methods in Software Engineering – p.32/32

Page 87: From OCL to Propositional and First-order Logic: Part Ihomepage.cs.uiowa.edu/~tinelli/classes/181/Spring08/Notes/06-OCL-PL.pdfPropositional & First-order logic, sequent calculus OCL

Propositional Logic is insufficient

A

B

?

ALL PERSONS ARE HAPPY

PAT IS A PERSON

PAT IS HAPPY

Propositional logic lacks possibility to talk about indivi duals

In particular, need to model objects, attributes, associat ions, etc.

⇒ First-Order Logic (FOL)

22c181: Formal Methods in Software Engineering – p.32/32