Depth-first search and strong connectivity in Coq

Similar documents
arxiv:cs/ v1 [cs.ds] 8 Dec 1998

Noncrossing Trees and Noncrossing Graphs

Multi-Robot Forest Coverage

Red-Black Trees Goodrich, Tamassia Red-Black Trees 1

tr0 TREES Hanan Samet

tr0 TREES Hanan Samet

Multi-Robot Flooding Algorithm for the Exploration of Unknown Indoor Environments

Rearranging trees for robust consensus

10 Torque. Lab. What You Need To Know: Physics 211 Lab

Efficient Algorithms for finding a Trunk on a Tree Network and its Applications

ABriefIntroductiontotheBasicsof Game Theory

CS3350B Computer Architecture. Lecture 6.2: Instructional Level Parallelism: Hazards and Resolutions

The Properties of. Model Rocket Body Tube Transitions

Fundamental Algorithms for System Modeling, Analysis, and Optimization

The Solution to the Bühlmann - Straub Model in the case of a Homogeneous Credibility Estimators

Faster Nearest Neighbors: Voronoi Diagrams and k-d Trees

Complexity of Data Tree Patterns over XML Documents

Wind and extremely long bridges a challenge for computer aided design

Overlap-Based Genome Assembly from Variable-Length Reads

CORESTA RECOMMENDED METHOD N 68

Tree. Tree. Siblings Grand Parent Grand Child H I J I J K. Tree Definitions

British Prime Minister Benjamin Disraeli once remarked that

An Auction Based Mechanism for On-Demand Transport Services

Cyclostrophic Balance in Surface Gravity Waves: Essay on Coriolis Effects

Angle-restricted Steiner arborescences for flow map layout Buchin, K.A.; Speckmann, B.; Verbeek, K.A.B.

Carnegie Mellon University Forbes Ave., Pittsburgh, PA command as a point on the road and pans the camera in

EC-FRM: An Erasure Coding Framework to Speed up Reads for Erasure Coded Cloud Storage Systems

OPTIMAL SCHEDULING MODELS FOR FERRY COMPANIES UNDER ALLIANCES

Lesson 33: Horizontal & Vertical Circular Problems

Numerical study of super-critical carbon dioxide flow in steppedstaggered

SHRiMP: Accurate Mapping of Short Color-space Reads

Design Engineering Challenge: The Big Dig Contest Platter Strategies: Ball Liberation

Rotor Design and Analysis of Stall-regulated Horizontal Axis Wind Turbine

MODELLING THE INTERACTION EFFECTS OF THE HIGH-SPEED TRAIN TRACK BRIDGE SYSTEM USING ADINA

Cheat-Proof Playout for Centralized and Distributed Online Games

Fault tolerant oxygen control of a diesel engine air system

Bicycle and Pedestrian Master Plan

Lecture Topics. Overview ECE 486/586. Computer Architecture. Lecture # 9. Processor Organization. Basic Processor Hardware Pipelining

RESOLUTION No A RESOLUTION OF THE CITY OF SALISBURY, MARYLAND AUTHORIZING THE MAYOR TO ENTER INTO AN AGREEMENT BETWEEN THE CITY OF

Design and Simulation Model for Compensated and Optimized T-junctions in Microstrip Line

Matlab Simulink Implementation of Switched Reluctance Motor with Direct Torque Control Technique

Performance Characteristics of Parabolic Trough Solar Collector System for Hot Water Generation

Range Extension Control System for Electric Vehicles Based on Front and Rear Driving Force Distribution Considering Load Transfer

Motivation. Prize-Collecting Steiner Tree Problem (PCSTP) Kosten und Profite. Das Fraktionale Prize-Collecting Steiner Tree Problem auf Baumgraphen

Experiment #10 Bio-Physics Pre-lab Questions

Electrical Equipment of Machine Tools

DETC A NEW MODEL FOR WIND FARM LAYOUT OPTIMIZATION WITH LANDOWNER DECISIONS

Experiment #10 Bio-Physics Pre-lab Comments, Thoughts and Suggestions

THE IMPACTS OF CONGESTION ON COMMERCIAL VEHICLE TOUR CHARACTERISTICS AND COSTS

UNIVERSITÀ DEGLI STUDI DI PADOVA. Dipartimento di Scienze Economiche Marco Fanno

Finite Element Analysis of Active Isolation of Deep Foundation in Clayey Soil by Rectangular Trenches

A Three-Axis Magnetic Sensor Array System for Permanent Magnet Tracking*

Multiple Vehicle Driving Control for Traffic Flow Efficiency

I. FORMULATION. Here, p i is the pressure in the bubble, assumed spatially uniform,

"A Home for Gracious Living" (real estate brochure for Batten House)

Incorporating Location, Routing and Inventory Decisions in Dual Sales Channel - A Hybrid Genetic Approach

f i r e - p a r t s. c o m

Cluster trees and message propagation

An integrated supply chain design model with random disruptions consideration

Deception in Honeynets: A Game-Theoretic Analysis

Trees & Routing (1) BFS

Torque. Physics 2. Prepared by Vince Zaccone For Campus Learning Assistance Services at UCSB

Installation and Operation Instructions

Toward a Virtual Neuromuscular Control for Robust Walking in Bipedal Robots

SIMULATION OF SEISMIC BEHAVIOUR OF GRAVITY QUAY WALL USING A GENERALIZED PLASTICITY MODEL

AGENDA REPORT. side of Walden Woods Dr., south of E. Park Rd. and north of E. Alexander St., in

Phase Behavior Introduction to Phase Behavior F.E. Londono M.S. Thesis (2001)

Abebe Eshetu Degati 1, Assistance Professor Harish Kumar 2 1(PhD student, sport science department, Punjabi university, Patiala, Punjab (India)

FALL PROTECTION PROGRAM

MOT-Jefferson Street Reconstruction PID

Bubble clustering and trapping in large vortices. Part 1: Triggered bubbly jets investigated by phase-averaging

Genetic Mapping Exercise - Extra Credit. Do not work together - each person to do their own work.

High Axial Load Capacity, High speed, Long life. Spherical Roller Bearings

READING AREA TRANSPORTATION STUDY BICYCLE AND PEDESTRIAN TRANSPORTATION PLAN ADOPTED NOVEMBER 18, 2010

A Method of Hand Contour Tracking based on GVF, Corner and Optical flow Ke Du1, a, Ying Shi1,b, Jie Chen2,c, MingJun Sun1, Jie Chen1, ShuHai Quan1

Data Sheet. Linear bearings

Cavitation Bubble Dynamics in Non-Newtonian Fluids

CARDBOARD BOAT BUILDING 101

Color Encodings: srgb and Beyond

A CONCEPTUAL WHEELED ROBOT FOR IN-PIPE INSPECTION Ioan Doroftei, Mihaita Horodinca, Emmanuel Mignon

The Study About Stopping Distance of Vehicles

Alternate stable states in coupled fishery-aquaculture systems. Melissa Orobko

2650 King Rd, Suite #500. Little Elm/Frisco

ROCK HILL AQUATICS CENTER POOL SCHEDULES

Watford Half Marathon. Watford Half Marathon. Sunday February 4th Starting at 10.30am. Enjoy Your Run!!! Notice to all Entrants.

College Hill Carthage. Winton Hills. Mill Creek. Spring Grove Village Paddock Hills. North Avondale. Avondale. Evanston. CUF Walnut Hills.

Community Development Department

PREDICTION OF ELECTRICAL PRODUCTION FROM WIND ENERGY IN THE MOROCCAN SOUTH

THE GREAT CARDBOARD BOAT RACE INTRODUCTION, BOAT BUILDING & RULES by United Way of Elkhart County

Morrison Drive tel. Ottawa, ON, Canada K2H 8S fax. com

Assessment of Direct Torque Control of a Double Feed Induction Machine

Interior Rule of the Quebec Open 2017

Lecture 24. Wind Lidar (6) Direct Motion Detection Lidar

PlacesForBikes City Ratings Methodology. Overall City Rating

OUTDOOR FOOTBALL FIELD

Watford Half Marathon. Watford Half Marathon. Sunday February 5th Starting at 10.30am. Enjoy Your Run!!! Notice to all Entrants.

55CM ROUND CHARCOAL KETTLE BBQ

A Deceleration Control Method of Automobile for Collision Avoidance based on Driver's Perceptual Risk

EcoMobility World Festival 2013 Suwon: an analysis of changes in citizens awareness and satisfaction

THE performance disparity between processor speed and the

Transcription:

1 Depth-fist seach and stong connectivity in Coq Januay 9, 2015

2 The poblem Finding the stongly connected components of a diected gaph. Pedagogical value: The fist nontivial gaph algoithm. Pactical value: Applications in pogam analysis, constaint solving, model-checking, etc.

3 Known algoithms Seveal known algoithms un in linea time: Tajan (1972). One pass. Maintains auxiliay data ( lowpoint values, etc.). Kosaaju (unpublished, 1978) and Shai (1981). Two passes. Maintains no auxiliay data. Descibed in Comen/Leiseson/Rivest s textbook. Explained by Wegene (2002). Gabow (2000), impoving on Pudom (1968) and Muno (1971). One pass. Maintains a union-find data stuctue.

4 Kosaaju s algoithm The algoithm is as follows: 1. Pefom a DFS tavesal of the gaph E, poducing a foest f 1. 2. Pefom a DFS tavesal of the evese gaph Ē, visiting the oots in the evese post-ode of f 1, poducing a foest f 2. Then, f 2 is a list of the stongly connected components. Magic! Note: the second tavesal does not have to be depth-fist. Really Easy to implement if you have done DFS aleady.

5 Why does this wok?

6 Complete discovey The left side of evey dashed bounday is closed w..t. E. The ight side of evey dashed bounday is closed w..t. Ē. Evey component is contained within some tee.

7 f 1 scc() w 1 Let be the oot of the last tee in f 1. The component of must be Ē (). v 1 f 2 w1 scc() w2 v 2

8 f 1 scc() w 1 Let be the oot of the last tee in f 1. The component of must be Ē (). So it is exactly the fist tee in f 2. v 1 f 2 w1 scc() w2 v 2

9 f 1 scc() Let be the oot of the last tee in f 1. w 1 The component of must be Ē (). So it is exactly the fist tee in f 2. v 1 f 2 w1 Futhemoe, it is a pefix of the last tee in f 1. scc() w2 v 2

10 f 1 scc() Let be the oot of the last tee in f 1. w 1 The component of must be Ē (). So it is exactly the fist tee in f 2. v 1 f 2 w1 Futhemoe, it is a pefix of the last tee in f 1. So, if we emove it by thought... scc() we end up whee we stated,... only with a smalle gaph. (Induction!) w2 v 2

11 Now, in Coq (biefly)

12 Foests A non-empty foest: w w v Foests fom an inductive type: f, v, w ::= ɛ w w :: v

13 DFS foests We define an inductive pedicate dfs (i) v (o). It has a cetain declaative flavo: v is a DFS foest. It still has a cetain impeative flavo: if the vetices in i ae maked at the beginning, then a DFS algoithm may constuct v, and the vetices in o ae maked at the end.

14 DFS foests DFS-Empty dfs (i) ɛ (i)

15 DFS foests DFS-NonEmpty w i dfs ({w} i) w (m) oots( w) E({w}) E({w}) m dfs (m) v (o) dfs (i) w :: v (o) w w was not initially maked afte making w, the DFS foest w was built evey oot of w is a successo of w evey successo of w was maked at this point then, the DFS foest v was built the DFS foest w :: v was built w

16 Complete discovey

17 Complete discovey Lemma (Complete discovey) dfs (i) v (o) and E(i) i imply E(o) o. Easy. (The pape summay of the poof is a few lines long.)

18 f 1 scc() w 1 v 1 f 2 w1 scc() w2 v 2

19 Kosaaju s algoithm Theoem (Kosaaju s algoithm is coect) Let (V, E) be a diected gaph. If the following hypotheses hold, dfs E ( ) f 1 (V) dfs Ē ( ) f 2 (V) ev(post(f 1 )) odes f 2 then the toplevel tees of f 2 ae the components of the gaph E. Slightly involved. (The pape summay of the poof is two pages.)

20 Towads an executable DFS in Coq ( executable = extactible)

21 Paametes A set V of vetices. V must be finite. Slightly too stong an assumption, but OK fo now.

22 Paametes A mathematical gaph E. A untime function successo v poducing an iteato on the successos of v.

23 Paametes A untime epesentation of sets of vetices. Recod SET (V : Type) := MkSET { ep : Type; meaning : ep -> (V -> Pop); void : ep; mak : V -> ep -> ep; maked : V -> ep -> bool;... // 3 moe hypotheses about void, mak, maked }.

24 A ecusive fomulation Notation state := (ep * foest V)%type. A state ecods the maked vetices and the foest built so fa.

25 A ecusive fomulation One would like to wite something like this: Definition visitf : state -> V -> state :=... This cannot wok, though. Because the ecusive call sits in a loop, the poof of temination must use the fact that a vetex, once maked, emains maked. So, we must build this infomation into the postcondition...

26 A ecusive fomulation This states that s1 has at least as many maked vetices as s0: Definition visitf_dep: foall s0 : state, V -> { s1 lift le s0 s1 }. Poof. eapply (Fix (...) (...)).... Defined. Woks. Unpleasant.

27 A tail-ecusive fomulation Wok in pogess. Temination is elatively easy to pove. (Geneic libay: Loop.) Paameteized by use hooks (on enty, on exit, on ediscovey). Nice (?) most geneal (?) specification: Theoem dfs_main_spec: exists vs, ev oots = ootsl vs /\ dfs E (maked base) (maked dfs_main) vs /\ dfs_main = fold dfs_init_spec vs. Running the iteative DFS algoithm is equivalent to guessing a DFS foest and ecusively folding ove this foest.

28 Conclusion

29 Conclusion Contibutions: Poofs of basic popeties of DFS. A poof of (the pinciple of) Kosaaju s algoithm. Embyo of a cetified DFS libay. (Moe to come.) Lessons: Sepaation between mathematics and code is desiable, and quite easy to achieve in Coq. Witing, specifying, poving geneic executable code is a lot of wok! We need a cetified libay of basic gaph algoithms!