Semi-automatic proof of Strong connectivity - - PowerPoint PPT Presentation

semi automatic proof of strong connectivity
SMART_READER_LITE
LIVE PREVIEW

Semi-automatic proof of Strong connectivity - - PowerPoint PPT Presentation

Semi-automatic proof of Strong connectivity jean-jacques.levy@inria.fr journes PPS, 12-10-2017 1 Plan motivation algorithm formal proof other systems conclusion .. joint work (in progress) with Ran Chen [VSTTE 2017]) also


slide-1
SLIDE 1

Semi-automatic proof

  • f

Strong connectivity

jean-jacques.levy@inria.fr

journées PPS, 12-10-2017

1

slide-2
SLIDE 2

Plan

2

.. joint work (in progress) with Ran Chen [VSTTE 2017])

also cooperation with Cyril Cohen, Laurent Théry, Stephan Merz

  • formal proof
  • other systems
  • conclusion
  • motivation
  • algorithm
slide-3
SLIDE 3

Motivation

3

  • fully published in articles or journals
  • formal proofs should be exact and readable (by human)
  • algorithms on graphs = a good testbed
  • how to publish formal proofs ?
  • mix automatic and interactive proofs
  • first-order logic is easy to understand, but not expressive
  • nice algorithms simple formal proofs
slide-4
SLIDE 4

One-pass linear-time algorithm

[tarjan 1972]

4

slide-5
SLIDE 5

Depth-first-search

5

2 8 3 4 9 1 7 5 6 2 8 9 7 5 6 3 4 1

graph spanning tree (forest)

slide-6
SLIDE 6

The algorithm (1/3)

6

2 8 9 7 5 6 3 4 1 2 8 3 4 9 1 7 5 6

3 SCCs (strongly connected components) 3 vertices are their bases

slide-7
SLIDE 7

The algorithm (2/3)

7

LOWLINK(x) = min ( {num[x]} ∪ {num[y] | x

= ⇒, → y ∧ x and y are in same connected component} )

2 8 9 7 5 6 3 4 1 2 8 9 7 5 6 3 4 1

1 5 5 5 1 1 2

2 8 9 3 4 1

1 4 4 1 1 2

slide-8
SLIDE 8

The algorithm (3/3)

8

1 1 1 1 1 2 2 2 2 3 3 3 4 4 5 1 2 3 4 5 6 1 1 2 2 3 3 4 4 8 8 1 2 3 4 5 6 9 7

successive values of the working stack 1 2 3 4 5 6 increasing rank

2 8 9 7 5 6 3 4 1

slide-9
SLIDE 9

The program

  • print each component on a line

9

I m p e r a t i v e s t y l e

slide-10
SLIDE 10

Proof in algorithms books (1/2)

10

  • tree structure of strongly connected components
  • consider the spanning trees (forest)
  • 2-3 lemmas about ancestors in spanning trees

LOWLINK(x) = min ( {num[x]} ∪ {num[y] | x

= ⇒, → y ∧ x and y are in same connected component} )

slide-11
SLIDE 11

Proof in algorithms book (2/2)

11

  • give the program
  • proof program
  • that part of the proof is very informal
slide-12
SLIDE 12

Our program (1/3)

returns LOWLINK(x) and new environment

x

e1.stack s3 s2

12

F u n c t i

  • n

a l p r

  • g

r a m m i n g

slide-13
SLIDE 13

Formal proof

13

u s i n g W h y 3

slide-14
SLIDE 14

Plan of proof (1/2)

14

  • prove a few lemmas about positions in stacks (ranks)
  • give pre-post conditions for functions
  • define reachability in graphs and SCCs
  • define invariants on environments
  • add a few intermediate assertions in function bodies
  • avoid paths, prefer edges
slide-15
SLIDE 15

Plan of proof (2/2)

15

  • vertices have colors
  • white = unvisited - gray = being visited - black = visited
  • invariant on environment

vertex in stack reaches all vertices with higher rank

cc1 cc2 ccn sccs stack

increasing rank increasing number

slide-16
SLIDE 16

16

Invariants

slide-17
SLIDE 17

17

Pre/Post-conditions

e’.stack e.stack

x

e.grays = e’.grays e.sccs e’.sccs

e.blacks e’.blacks

slide-18
SLIDE 18

Assertions

18

Coq

x

e1.stack s3 s2

[http://jeanjacqueslevy.net/why3/graph/abs/scct/1-7/scc.html]

slide-19
SLIDE 19

Assertions

19

Coq

  • 9x0y 0,

reachable x x0 ^ edge x0 y 0 ^ reachable y 0 y ^ x0 2 s2 ^ y 0 62 s2

  • 3 cases:
  • proof by contradiction: 9y,

in same scc y x ^ y 62 s2

y 0 is white x0 = x then y 0 ∈ successors x

y 0 is black

x0 6= x then x0 is black ¬ no black to white b1 g1

[1]

y 0 ∈ e1.sccs then

in same scc y 0 x

x is black

[2]

x0 = x then y 0 ∈ successors x

n1 ≤ e1.num[y 0] y 0 ∈ s3

rank y 0 s1 < rank x s1 e1.num[y 0] < e1.num[x] = e.num[x] = n

x0 6= x then xedge to s1 (Cons x s3) y 0

[3]

x

s1=e1.stack s3 s2

slide-20
SLIDE 20

Proof stats

20

[http://jeanjacqueslevy.net/why3/graph/abs/scct/1-7/scc.html]

slide-21
SLIDE 21

Other systems

21

slide-22
SLIDE 22

Coq / ssreflect

  • port in 1 week
  • graphs and finite sets already in mathematical components
  • problems with termination (hacky & higher-order)
  • 920 lines

[http://github.com/CohenCyril/tarjan]

22

[cyril cohen, laurent théry, JJL]

slide-23
SLIDE 23

Isabelle / HOL

  • port in 1 month
  • use many strategies (metis, blast, sledgehammer)
  • still problems with proving termination
  • 31 pages

[http://jeanjacqueslevy.net/why3/graph/abs/scct/isa/Tarjan.pdf]

23

[stephan merz]

slide-24
SLIDE 24

F*

  • start discuss with them
  • Z3 single automatic prover
  • ??

24

[kenji maillard, catalin hritcu]

slide-25
SLIDE 25

Conclusion

25

slide-26
SLIDE 26

Future work

  • library for formal proofs on graphs
  • other graph algorithms
  • beyond graphs …
  • teaching formal methods on test cases
  • imperative programs

26

[http://jeanjacqueslevy.net/why3]