23
A Lightweight Formal Encoding for a Constraint Language DSML Component Arnaud Dieumegard 1,2 Marc Pantel 1 G. Babin 1 M. Carton 1 1 IRIT/ENSEEIHT - 2 rue Charles Camichel, 31000 Toulouse, France [email protected] 2 IRT Saint Exupéry - 118 route de Narbonne, 31432 Toulouse, France [email protected] September 28th 2015 A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 1 / 21

A Lightweight Formal Encoding for a Constraint Language DSML Component

Embed Size (px)

Citation preview

Page 1: A Lightweight Formal Encoding for a Constraint Language DSML Component

A Lightweight Formal Encoding for a Constraint LanguageDSML Component

Arnaud Dieumegard1,2 Marc Pantel1 G. Babin1 M. Carton1

1IRIT/ENSEEIHT - 2 rue Charles Camichel, 31000 Toulouse, [email protected]

2IRT Saint Exupéry - 118 route de Narbonne, 31432 Toulouse, [email protected]

September 28th 2015

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 1 / 21

Page 2: A Lightweight Formal Encoding for a Constraint Language DSML Component

Introduction

1 Introduction

2 Verification of DSMLs using a Constraint Language Component

3 DSML Verification

4 Case study : the BlockLibrary specification language

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 2 / 21

Page 3: A Lightweight Formal Encoding for a Constraint Language DSML Component

Introduction

Introduction

Embedded systems development and verification is complex

Need for safe and sound development and verification techniques

State Of the Art : Domain Specific Modeling Languages (DSMLs)Adapted to the needsAdapted to the developer/designer knowledgeEase of manipulation/transformationEase the verification

Evolution of DSMLs : Language Component-based DSMLsCapitalisation on the developer/designer knowledgeIntegration of already existing and known concrete syntaxes/languagesRequire means for semantics specification

Problem : How to verify DSMLs instances

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 3 / 21

Page 4: A Lightweight Formal Encoding for a Constraint Language DSML Component

Verification of DSMLs using a Constraint Language Component

1 Introduction

2 Verification of DSMLs using a Constraint Language Component

3 DSML Verification

4 Case study : the BlockLibrary specification language

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 4 / 21

Page 5: A Lightweight Formal Encoding for a Constraint Language DSML Component

Verification of DSMLs using a Constraint Language Component

DSMLs

DesignWell known techniques

Metamodel for the definition of the DSML structure (concepts and relations)OCL constraints for the static semantics of the DSML

ImplementationModel driven engineering based approach

VerificationTransformations to formal methods/tools

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 5 / 21

Page 6: A Lightweight Formal Encoding for a Constraint Language DSML Component

Verification of DSMLs using a Constraint Language Component

OCL-like Component Constraint Language

DSML are more and more complexNeed for the specification/development of more complex systemsImprovement of the specification for simpler/safer development

Relying on an OCL-like language as a componentRelates to the DSML data language component

Integrated in the DSMLAllows to dynamically constrain the DSML constructsA rich/known/accessible language

Problem :Verification of the DSML instances including the constraints

Translation of the DSML constructs to the formal worldTranslation of the OCL-like constraints to the formal world

Automatic verification of the DSML propertiesAllows the DSML user to interact with formal methodsNo preliminary knowledge required

⇒ Improvement of the DSML efficiency/confidence and thus its use/adoption

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 6 / 21

Page 7: A Lightweight Formal Encoding for a Constraint Language DSML Component

DSML Verification

1 Introduction

2 Verification of DSMLs using a Constraint Language Component

3 DSML Verification

4 Case study : the BlockLibrary specification language

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 7 / 21

Page 8: A Lightweight Formal Encoding for a Constraint Language DSML Component

DSML Verification

Verification Proposal

A common formalisation of the DSML structure and constraintsRelying on the Why3 platform and the WhyML languageVerification of DSML properties with SMT solvers for automatic verification

⇒ An integrated verification framework

Translation of the DSML for verificationAppropriate DSML elements from data component translated to WhyMLtypesIntegrated constraints translated using a pre-defined formalisation of theconstraint languageAutomatic generation of verification properties

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 8 / 21

Page 9: A Lightweight Formal Encoding for a Constraint Language DSML Component

DSML Verification

Constraint Language Scope

Constraint language based on a subset of the OCL

Relying on the OCL syntax to reduce the learning curveLimited support of the original OCL operations/constructs

No tuples (easy extension)No messages (UML related)No Null or Invalid valuesOnly Bag collections (easy extension)No support for collection conversion operations (easy extension)No support for failure prone operations (e.g. div, can be introduced withpre-condition : not(b=0) for div(a,b)).No Closure operationNo support for Type manipulation operations (OclAsType, OclIsTypeOf, ...)(depends on the DSML data component)

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 9 / 21

Page 10: A Lightweight Formal Encoding for a Constraint Language DSML Component

DSML Verification

Constraint Language Formalisation using WhyML

OCL standard data types → WhyML standard data types

Collections → lists

Standard operations

Collection operations

Iteration operation

pre/post

function implementation

lemmas

Lemmas verification through SMT solvers or proof assistants

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 10 / 21

Page 11: A Lightweight Formal Encoding for a Constraint Language DSML Component

DSML Verification

Extract of the Select Iteration Operation Formalisation

function select (l: list oclType) (p: HO.pred oclType): list oclType =match l with| Nil -> Nil| Cons hd tl -> if p hd then Cons hd (select tl p)

else select tl pend

lemma select_nil: forall p: HO.pred oclType.select Nil p = Nil

lemma select_cons_verified: forall e: oclType, l: list oclType,p: HO.pred oclType.

p e -> select (Cons e l) p = Cons e (select l p)lemma select_cons_not_verified: forall e: oclType, l: list oclType,

p: HO.pred oclType.not (p e) -> select (Cons e l) p = select l p

lemma select_mem: forall l: list oclType, b: oclType,p: HO.pred oclType.

(mem b l /\ p b) -> mem b (select l p)

Proof obligations Alt-Ergo-Pro (1.0.0) Coq (8.4pl3)

lemma select_nil 0.03

lemma select_cons_verified 0.03

lemma select_cons_not_verified 0.04

lemma select_mem 2.31

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 11 / 21

Page 12: A Lightweight Formal Encoding for a Constraint Language DSML Component

DSML Verification

DSML Translation to WhyML

Direct translation of the constraint relying onDSML data component elements formalisationConstraint component language formalisation

Translation of the verification properties

"Out of formalisation" constraints are necessarily falsePre/post conditions and lemmas constrains the use of the operationsConstraints out of the formalisation scope lead to a verification failure

AdvantagesRelying on an already verified formalisationSimpler translationSimpler verification of the properties

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 12 / 21

Page 13: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

1 Introduction

2 Verification of DSMLs using a Constraint Language Component

3 DSML Verification

4 Case study : the BlockLibrary specification language

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 13 / 21

Page 14: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Specification DSL (OCL2012,SPLC2014)

Specificition of dataflow languages (e.g. Simulink, SCADE, . . .) blocklibraries

Complex blocks (e.g. Sum operation documentation in Simulink around20 pages)

Requires verification of Consistency and Completeness

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 14 / 21

Page 15: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Specification DSL – Metamodel

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 15 / 21

Page 16: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Specification DSL – Metamodel

VariantSet : composition of block interfaces (BlockVariants) and attachementof block semantics (BlockMode)

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 15 / 21

Page 17: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Specification DSL – Block Interface

Block interfaces building inspired from product line technologies

n-ary AND, n-ary ALT (XOR) composition operators

Interface and features constraining

variant InternalDelay {parameter Delay : TInt32

}variant ExternalDelay {in data Delay : TInt32

}variant DelayVar extends ALT (InternalDelay,

ExternalDelay) {invariant ocl { Delay.value > 0 }

}variant ListDelay_ScalarInput extends AND (ResetParam, DelayVar, InputScalar

) {invariant ocl { Delay.value > 1 }invariant ocl { Init.value.size() = Delay.value }memory Mem {datatype auto ocl {In.value}length auto ocl {0}

}}

Out

DelayBlock

Init

Mem

DelayIn

Out

DelayBlock

Init

Mem

In

Delay

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 16 / 21

Page 18: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Specification DSL – Block Interface

Block interfaces building inspired from product line technologies

n-ary AND, n-ary ALT (XOR) composition operators

Interface and features constraining

variant InternalDelay {parameter Delay : TInt32

}variant ExternalDelay {in data Delay : TInt32

}variant DelayVar extends ALT (InternalDelay,

ExternalDelay) {invariant ocl { Delay.value > 0 }

}variant ListDelay_ScalarInput extends AND (ResetParam, DelayVar, InputScalar

) {invariant ocl { Delay.value > 1 }invariant ocl { Init.value.size() = Delay.value }memory Mem {datatype auto ocl {In.value}length auto ocl {0}

}}

BlockLibrary BlockType

BlockVariant

...

BV

Constraints

Parameter

Port

MemoryConstraints

Constraints

Constraints

ref

ref

ref

DataType

...

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 16 / 21

Page 19: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Specification DSL – Block Configuration

Block semantics definition

Gives semantics to block interface

Attached to block interface using same composition operators

mode SimpleDelay implements ALT (SimpleDelay_ScalarInput,SimpleDelay_VectorInput,SimpleDelay_MatrixInput)

{definition bal = init {precondition ocl { ... }postcondition ocl { Mem == Init }Mem = Init;

}definition bal = compute {precondition ocl { ... }postcondition ocl { Output == Mem }Output = Mem;

}definition bal = update {precondition ocl { ... }postcondition ocl { Mem == In }Mem = In;

}}

BlockLibrary BlockType

BlockVariant

...

BV

Constraints

BlockMode

Pre PostAction

...BM

Constraints

Parameter

Port

MemoryConstraints

Constraints

Constraints

ref

ref

ref

DataType

...

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 17 / 21

Page 20: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

BlockLibrary Verification

Structural correctness (syntax, structure)

⇒ Metamodel conformance and OCL constraints on models

Semantics behavior correctness criteria (verification)

Disjointness : Configurations are unique

Completeness : All possible configurations are specified

Hoare-based semantics consistency

⇒ Translation to a formal verification platform

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 18 / 21

Page 21: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

Verification Strategy : Translation to Why3

Why3Utheory

Why3Umodule

DataTypes

Predicates

DisjointnessCompleteness

Goals

ConfigurationTransformation

ConfigurationPredicate

GoalsUExtraction

BlockUDomainTransformation

Why3Utheory

Use

SemanticsUstepFunctionsSemanticsU

VerificationTransformation

Use

initcomputeupdate

BlockLibrary BV

BM

BlockType

BlockMode BM

BlockVariant

Constraints

Pre PostAction

...

...

BV

Constraints

Parameter

Port

MemoryConstraints

Constraints

Constraints

DataType

ref

ref

ref

...

⇒ SMT solver/Proof assistant to verify goals and functionsA. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 19 / 21

Page 22: A Lightweight Formal Encoding for a Constraint Language DSML Component

Case study : the BlockLibrary specification language

Disjointness/Completeness Properties Verification

1 – Block specification(extract)

variant InternalDelay {parameter Delay : TInt32

}variant ExternalDelay {in data Delay : TInt32

}variant DelayVar extends ALT(InternalDelay, ExternalDelay) {invariant ocl { Delay.value > 0 }

}variant ListDelay_ScalarInput extends AND(ResetParam, DelayVar, InputScalar

) {invariant ocl { Delay.value > 1 }invariant ocl {Init.value.size() = Delay.value }

memory Mem {datatype auto ocl {In.value}length auto ocl {0}

}}

2 – Generated Why predicates (extract)type tDelay_InternalDelay_TInt32 = tParameter (tRealInt32)type tDelay_ExternalDelay_TInt32 = tInPortGroup (tRealInt32)type tMem_ListDelay_ScalarInput_TArray1Dim_TDouble =

tMemoryVariable (list (tRealDouble))(* Theory 1 *)predicate delayvar_inv_1 (...) =delay.value_pt > 0

predicate listdelay_scalarinput_modeInv_1 (...) =delay.value_pt > 1

predicate listdelay_scalarinput_modeInv_2 (...) =let init_0 = init.value_pt in length init_0 = delay.value_pt

(* Theory 2*)predicate listdelay_scalarinput_modeInv_2 (...) =let init_0 = init.value_pt in length init_0 = delay.value_inpg

3 – Generated verification goal (extract)goal Delay_completeness :forall reset_Algo : tReset_Algo_ResetParam_TResetAlgo ,

delay : tDelay_InternalDelay_TInt32 ,init : tInit_InternalICMatrix_TMatrixDouble, ...

delay_Simple_sig0 reset_Algo delay iC mem output input block \/delay_Simple_sig1 reset_Algo delay mem iC output input block ...

4 – Verification outputDelayComplet_Delay.why Delay_Verif Delay_completeness : Valid (2.01s)DelayComplet_Delay.why Delay_Verif Delay_disjointness : Valid (7.85s)

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 20 / 21

Page 23: A Lightweight Formal Encoding for a Constraint Language DSML Component

Conclusion

Conclusion

Current status

A lightweight formalisation of a constraint language component inspiredby OCL

Automatic verification of DSML properties achievable with SMT solvers

Future works

Automatic translation of the DSML constructs to WhyMLWidening of the constraint language scope

Extensions based on DSML needsDo not target full OCL (HOL-OCL fills the need)

Verification feedback to the DSML user

A. Dieumegard et al. (IRIT/Univ. De Toulouse) Tool paper September 28th 2015 21 / 21