Verified Graph Algorithms in ACL2 Nathan Guermond Kestrel Institute - - PowerPoint PPT Presentation

verified graph algorithms in acl2
SMART_READER_LITE
LIVE PREVIEW

Verified Graph Algorithms in ACL2 Nathan Guermond Kestrel Institute - - PowerPoint PPT Presentation

Verified Graph Algorithms in ACL2 Nathan Guermond Kestrel Institute November 5, 2018 Another graph library? Goal: A unified graph library with common algorithms Another graph library? Goal: A unified graph library with common algorithms


slide-1
SLIDE 1

Verified Graph Algorithms in ACL2

Nathan Guermond Kestrel Institute November 5, 2018

slide-2
SLIDE 2

Another graph library?

Goal: A unified graph library with common algorithms

slide-3
SLIDE 3

Another graph library?

Goal: A unified graph library with common algorithms ◮ Full specifications

slide-4
SLIDE 4

Another graph library?

Goal: A unified graph library with common algorithms ◮ Full specifications ◮ Modularity

slide-5
SLIDE 5

Another graph library?

Goal: A unified graph library with common algorithms ◮ Full specifications ◮ Modularity ◮ Optimization

slide-6
SLIDE 6

Core data structure

A graph is a dependent datastructure with ◮ (setp vertices) ◮ (true-listp edges) ◮ (booleanp directed)

slide-7
SLIDE 7

Core data structure

A graph is a dependent datastructure with ◮ (setp vertices) → (get-vertices gph) ◮ (true-listp edges) → (get-edges gph) ◮ (booleanp directed) → (directed-p gph)

slide-8
SLIDE 8

Core data structure

A graph is a dependent datastructure with ◮ (setp vertices) → (get-vertices gph) ◮ (true-listp edges) → (get-edges gph) ◮ (booleanp directed) → (directed-p gph) The dependency is given by the well-formedness constraint ◮ (graph-constraint vertices edges)

slide-9
SLIDE 9

Common data structures

◮ (path-p pth gph) satisfies

  • 1. (true-listp pth) with
  • 2. (in (car pth) (neighbours (cadr pth) gph))
  • 3. (path-p (cdr pth))

◮ (rev-path-p rev-pth gph) satisfies

  • 1. (true-listp pth) with
  • 2. (in (cadr pth) (inv-neighbours (car pth) gph))
  • 3. (rev-path-p (cdr pth))

◮ (cycle-p cyc gph) is a path-p with equal ends

slide-10
SLIDE 10

Algorithms and specs

◮ (find-path src tgt gph)

(defthm path−exists−implies−exists−path−spec ( implies (and (path−p pth gph ) ( graph−p gph )) ( find−path ( get−src pth ) ( get−tgt pth ) gph ) ) ) (defthm exists−path−implies−path−constructible−spec ( implies (and ( graph−p gph ) ( find−path src tgt gph )) ( let (( pth ( find−path src tgt gph ) ) ) (and (path−p pth gph ) ( equal ( get−src pth ) src ) ( equal ( get−tgt pth ) tgt ) ) ) ) )

slide-11
SLIDE 11

Algorithms and specs

◮ (find-path src tgt gph)

slide-12
SLIDE 12

Algorithms and specs

◮ (find-path src tgt gph) ◮ (reachable-set S gph)

(defthm exists−path−implies−reachable−spec ( implies (and ( graph−p gph ) (path−p pth gph )) ( in ( get−tgt pth ) ( reachable−set ( s i n g l e t o n ( get−src pth )) gph ) ) ) ) (defthm exists−path−from−src−to−reachable−set−spec ( implies (and ( graph−p gph ) ( in src ( get−vertices gph )) ( in tgt ( reachable−set ( s i n g l e t o n src ) gph ) ) ) ( find−path src tgt gph ) ) )

slide-13
SLIDE 13

Algorithms and specs

◮ (find-path src tgt gph) ◮ (reachable-set S gph) and (inv-reachable-set S gph)

slide-14
SLIDE 14

Algorithms and specs

◮ (find-path src tgt gph) ◮ (reachable-set S gph) and (inv-reachable-set S gph) ◮ (find-simple-cycle gph) and (find-non-trivial-cycle gph)

slide-15
SLIDE 15

Algorithms and specs

◮ (find-path src tgt gph) ◮ (reachable-set S gph) and (inv-reachable-set S gph) ◮ (find-simple-cycle gph) and (find-non-trivial-cycle gph) ◮ (topological-sort gph)

slide-16
SLIDE 16

Algorithms and specs

◮ (find-path src tgt gph) ◮ (reachable-set S gph) and (inv-reachable-set S gph) ◮ (find-simple-cycle gph) and (find-non-trivial-cycle gph) ◮ (topological-sort gph) ◮ (get-strongly-connected-component S gph) ◮ (collapse-strongly-connected-components gph)

slide-17
SLIDE 17

Algorithms and specs

◮ (find-path src tgt gph) ◮ (reachable-set S gph) and (inv-reachable-set S gph) ◮ (find-simple-cycle gph) and (find-non-trivial-cycle gph) ◮ (topological-sort gph) ◮ (get-strongly-connected-component S gph) ◮ (collapse-strongly-connected-components gph)

◮ constructed from find-non-trivial-cycle, reachable-set, and inv-reachable-set ◮ A strongly connected compoment is given by (Reach cyc) ∩ (InvReach cyc)

slide-18
SLIDE 18

Reachable and finite differencing

◮ Specification is proven by a two step refinement

◮ Compute set reachable in k steps

◮ S ∪ (Neighs S) ∪ . . . ∪ (Neighs (. . . (Neighs S)) . . .)

1 2 3 4 5 6 7 8 9

slide-19
SLIDE 19

Reachable and finite differencing

◮ Specification is proven by a two step refinement

◮ Compute set reachable in k steps

◮ S ∪ (Neighs S) ∪ . . . ∪ (Neighs (. . . (Neighs S)) . . .)

◮ Compute reachable set by iterative unioning

◮ S ∪ (Neighs S) ∪ (Neighs (Neighs S)) . . .

1 2 3 4 5 6 7 8 9

slide-20
SLIDE 20

Reachable and finite differencing

◮ Specification is proven by a two step refinement

◮ Compute set reachable in k steps

◮ S ∪ (Neighs S) ∪ . . . ∪ (Neighs (. . . (Neighs S)) . . .)

◮ Compute reachable set by iterative unioning

◮ S ∪ (Neighs S) ∪ (Neighs (Neighs S)) . . .

◮ Compute reachable set by finite difference

◮ S0 = S, S1 = (Neighs S0) ◮ Di+1 = Si+1 − Si, Si+1 = Si ∪ (Neighs Di)

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

slide-21
SLIDE 21

Applications

◮ Call-graphs factorial + * zp < not integerp if

slide-22
SLIDE 22

Applications

◮ Call-graphs ◮ Guard verification factorial + * zp < not integerp if

slide-23
SLIDE 23

Applications

◮ Call-graphs ◮ Guard verification ◮ Getting ordered guard

  • bligations

factorial + * zp < not integerp if

slide-24
SLIDE 24

Applications

◮ Call-graphs ◮ Guard verification ◮ Getting ordered guard

  • bligations

◮ Your next project! factorial + * zp < not integerp if

slide-25
SLIDE 25

Future work

◮ Prove specs for topological-sort

slide-26
SLIDE 26

Future work

◮ Prove specs for topological-sort ◮ Prove specs for collapse-strongly-connected-components

slide-27
SLIDE 27

Future work

◮ Prove specs for topological-sort ◮ Prove specs for collapse-strongly-connected-components ◮ Optimize find-path using finite differencing

slide-28
SLIDE 28

Future work

◮ Prove specs for topological-sort ◮ Prove specs for collapse-strongly-connected-components ◮ Optimize find-path using finite differencing ◮ Optimize already specified algorithms, possibly using transformations