34
Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student ITMO University Ilya Ivanov Undergrad student ITMO University Anatoly Shalyto Dr. Sci., professor ITMO University

Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Embed Size (px)

Citation preview

Page 1: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Inferring Temporal Properties of Finite-State Machines with Genetic Programming

GECCO’15 Student Workshop

July 11, 2015

Daniil ChivilikhinPhD student

ITMO University

Ilya IvanovUndergrad studentITMO University

Anatoly ShalytoDr. Sci., professorITMO University

Page 2: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Introduction

Software modelsNot always createdIf created, not always kept up to date

2

Page 3: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Model inference

Executable program

Test cases

Program model

Model inference algorithm

Finite-state machine

Quite a few good algorithms3

Page 4: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Temporal logics

Used to express time-related propositionsIn software verification: state requirements for software systemsExample statement

“If a request is received, an answer is eventually generated”

4

Page 5: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Linear temporal logics

Propositional variables: elementary statementsBoolean logic operators: , , ¬, →∨ ∧Temporal operators• X(f) – f has to hold in the next state• F(f) – f has to hold in some state in the future• G(f) – f has to hold for all states• U(f, g) – f has to hold until g holds• …

5

Page 6: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Specification inference

Executable program

Test cases

Temporal properties

Specification inference algorithm

Only very simple properties

6

Page 7: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Finite-State Machines

7

e1 / z0, z1eventoutput actions

Page 8: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

LTL for FSMs

Propositional variableswasEvent(e) for all events e wasAction(z) for all output actions z

G (wasEvent(e2) → wasAction(z2)) 8

Page 9: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Problem statement

Find some non-trivial “interesting” LTL properties (formulas) of a given FSM

• All formulas must hold for input FSM• Short formulas are better than long ones• Should not hold for FSMs similar to the

input FSM

9

Page 10: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Proposed approach

Use Genetic Programming (GP) Evolve a population of LTL formulasExpress constraints using several fitness functionsMultiobjective optimization

10

Page 11: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Main challenge

Design a set of fitness functions that result in proper LTL properties

11

Page 12: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #1: Formula must hold for input FSM

Main search objectiveUse model checker to check formula f against FSM a

1,0stransitionofnumber

stransitionverifiedofnumber),()(1 farfF

12

Page 13: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #2: Minimal formula weight

Measure structural complexity of a formulaOperators O = { , , ¬, →, ∨ ∧ X, F, U, R}Propositional variables

S = {wasEvent(e) for all e ∈ E} U {wasAction(z) for all z ∈Z}

13

Page 14: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #2: Minimal formula weight (continued)

Each operator and variable are assigned weight WW(s)= ws for s S∈

W(o(arg1, [arg2])) = wo + W(arg1) [+W(arg2)]

1,01)(2 W(f)

fF

14

Page 15: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #3: Random FSMs

Idea: if a large number of randomly generated FSMs satisfy an LTL formula, it is meaninglessGenerate a number of random FSMs with the same interface as the input FSM a1, . . . , aNsample

sample

1

23

1

1)( N

i f),r(a

fF

15

Page 16: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #4: Mutants of input FSM

Idea: if a formula is not violated by a small change in the FSM, it is not so “interesting”Generate random mutants of the input FSM m1, . . . , mNsample

Mutation operators• Change transition end state• Add/delete transitions

sample

1

24

1

1)( N

i f),r(m

fF

16

Page 17: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #5: FSM constructed from scenarios

A scenario is a finite path in an FSM

Example:

17

1010222 ,e;,,e;,e zzzz

Page 18: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #5: FSM constructed from scenarios (continued)

Derive random scenarios of fixed length from input FSM aUse fast exact algorithm to construct an FSM a* from scenariosNote: a* probably differs from aNote: not all formulas that are true for a are true for a*

18

)*,(1)(5 farfF

Page 19: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

FF #6: Mutants of FSM constructed from scenarios

Same as FF #4, but mutants are generated from the FSM constructed from scenarios

19

Page 20: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Implementation

ECJ library used for EA implementationMultiobjective EAs: NSGA-II and SPEA2Standard GP operators

https://cs.gmu.edu/~eclab/projects/ecj/

20

Page 21: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Experiments

Case study: Elevator doors control FSMInput events: A, B, C ,D, EOutput actions: z1, z2, z3

17 manually created LTL formulas

21

Page 22: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Original LTL properties

22

Page 23: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Experiments goal

Goal: infer formulas similar to manually created onesBut how do we measure the quality of inferred formulas?Introduced two empirical metrics• Coverage metric• Mutants metric

23

Page 24: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Coverage metric{fold} – original manually created formulas{fnew} – inferred formulas

1. Derive scenarios from original FSM a2. Model inference: build FSM a’ from scenarios and

{fnew}

3. Metric: how many formulas from {fold} does a’ satisfy?

}{ old

}{cover

old

f

f)r(a',c ff

24

Page 25: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Mutants metric{fold} – original manually created formulas{fnew} – inferred formulas

1. Generate M’ ≤ 1000 different mutants of original FSM a

2. Ratio of mutants that violate at least one formula from {fold}

3. Metric:

'

1}{

oldunsat ,min1

'

1old

M

iff

fmrM

n

oldunsat

newunsat

mut n

nc

25

Page 26: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Experimental setup

Tried both NSGA-II and SPEA2EAs run for 50 generationsPopulation size = 500Result of experiment: all formulas in Pareto frontEach experiment repeated 20 timesFF1 and FF2 in all experiments, all combinations of the rest

26

Page 27: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Experimental data

27

Page 28: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Experimental results

NSGA-II and SPEA2 yield similar formula qualitySPEA2 is much faster than NSGA-IIConfig #8 = {all but FF3} is best for NSGA-II

Config #15 = {all but FF6} is best for SPEA2

Significance validated using Wilcoxon signed-rank test

28

Page 29: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Varying other parameters

Use SPEA2 with config #15Varied population size from 100 to 1000

Change number of generations from 25 to 200• No significant changes

Pop size 100 250 500 1000100 c∙ learn, % 23 86 86 86100 c∙ mut, % 13 79 96 96

29

Page 30: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Larger example

ATM control FSM12 states14 events13 output actions30 LTL formulasMutants metric: 100 ∙ cmut = 65 %

Coverage metric: infeasible

30

Page 31: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Results

Proposed GP-based approach for inferring LTL properties of FSMsFeasibility demonstrated on two examples using two empirical quality metricsApproach is able to infer up to 100 % of human-written LTL formulas

31

Page 32: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Future work

Couple with existing model inference algorithms

Page 33: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Acknowledgements

This work was financially supported by the Government of Russian Federation, Grant 074-U01.

33

Page 34: Inferring Temporal Properties of Finite-State Machines with Genetic Programming GECCO’15 Student Workshop July 11, 2015 Daniil Chivilikhin PhD student

Thank you for your attention!

Daniil ChivilikhinIlya Ivanov

Anatoly Shalyto

[email protected]

34