regression proving with dependent types: theory and practicele/module selection asynchronous proof...

71
Regression Proving with Dependent Types: Theory and Practice Karl Palmskog https://setoid.com The University of Texas at Austin Joint work with Ahmet Celik, Chenguang Zhu, and Milos Gligoric 1 / 40

Upload: others

Post on 21-Aug-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Regression Proving with Dependent Types:Theory and Practice

Karl Palmskog

https://setoid.com

The University of Texas at Austin

Joint work with Ahmet Celik, Chenguang Zhu,and Milos Gligoric

1 / 40

Page 2: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Regression Proving with Dependent Types:Practice and Some Theory

Karl Palmskog

https://setoid.com

The University of Texas at Austin

Joint work with Ahmet Celik, Chenguang Zhu,and Milos Gligoric

2 / 40

Page 3: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

“Scale Changes Everything”

Project Year Assistant Check Time LOC

4-Color Theorem 2005 Coq tens of mins 60kOdd Order Theorem 2012 Coq tens of mins 150kKepler Conjecture 2015 HOL Light days 500k

CompCert 2009 Coq tens of mins 40kseL4 2009 Isabelle/HOL hours 200kCogent BilbyFS 2016 Isabelle/HOL days 14kVerdi Raft 2016 Coq tens of mins 50k

3 / 40

Page 4: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Proof Engineering Can Help

“[T]he activity of construction, maintenance,documentation and presentation of large formal proofdevelopments.”

—David Aspinall

This talk

1 techniques for faster checking of evolving projects (for Coq)

2 formalization and verification of these techniques (in Coq)

4 / 40

Page 5: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Proof Engineering Can Help

“[T]he activity of construction, maintenance,documentation and presentation of large formal proofdevelopments.”

—David Aspinall

This talk

1 techniques for faster checking of evolving projects (for Coq)

2 formalization and verification of these techniques (in Coq)

4 / 40

Page 6: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Our Working Analogy: Proofs ∼ Tests

tests are “partial functional specifications” of programs

proofs represent many, usually an infinite number of, tests

does not fit all projects in mathematics well

Fixpoint app {A} (l m:list A)

:= match l with

| [] ⇒ m

| a :: l’ ⇒ a :: app l’ m

end.

1. Coq function

5 / 40

Page 7: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Our Working Analogy: Proofs ∼ Tests

tests are “partial functional specifications” of programs

proofs represent many, usually an infinite number of, tests

does not fit all projects in mathematics well

Fixpoint app {A} (l m:list A)

:= match l with

| [] ⇒ m

| a :: l’ ⇒ a :: app l’ m

end.

1. Coq function

Lemma asoc: ∀ A (l m n:list A),

app l(app m n) = app(app l m) n.

Proof.

induction l; intros; auto.

simpl; rewrite IHl; auto.

Qed.

2. Coq lemma

5 / 40

Page 8: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Our Working Analogy: Proofs ∼ Tests

tests are “partial functional specifications” of programs

proofs represent many, usually an infinite number of, tests

does not fit all projects in mathematics well

Fixpoint app {A} (l m:list A)

:= match l with

| [] ⇒ m

| a :: l’ ⇒ a :: app l’ m

end.

1. Coq function

Lemma asoc: ∀ A (l m n:list A),

app l(app m n) = app(app l m) n.

Proof.

induction l; intros; auto.

simpl; rewrite IHl; auto.

Qed.

2. Coq lemma

let test_app_assoc ctxt =

assert_equal

(app [1] (app [2] [3]))

(app (app [1] [2]) [3])

3. OCaml test

5 / 40

Page 9: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Regression Proving in Evolving Projects

Typical proving scenario:

1 change definition or lemma statement

2 begin process of re-checking all proofs

3 checking fails much later (for seemingly unrelated proof)

Typical testing scenario:

1 change method statements or method signature

2 begin process of re-running all tests

3 testing fails much later (for seemingly unrelated test)

6 / 40

Page 10: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Regression Proving in Evolving Projects

Typical proving scenario:

1 change definition or lemma statement

2 begin process of re-checking all proofs

3 checking fails much later (for seemingly unrelated proof)

Typical testing scenario:

1 change method statements or method signature

2 begin process of re-running all tests

3 testing fails much later (for seemingly unrelated test)

6 / 40

Page 11: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Basic Techniques For More Efficient Regression Proving

Proof selection: check only proofs affected by changes

file/module selection

asynchronous proof checking

Examples: Make, Isabelle [ITP ’14]

Proof parallelization: leverage multi-core hardware

parallel checking of proofs

parallel checking of files

Examples: Make, Isabelle [ITP ’13], Coq [ITP ’15], Lean [CADE ’15]

7 / 40

Page 12: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Basic Techniques For More Efficient Regression Proving

Proof selection: check only proofs affected by changes

file/module selection

asynchronous proof checking

Examples: Make, Isabelle [ITP ’14]

Proof parallelization: leverage multi-core hardware

parallel checking of proofs

parallel checking of files

Examples: Make, Isabelle [ITP ’13], Coq [ITP ’15], Lean [CADE ’15]

7 / 40

Page 13: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Our Recent Work on Regression Proving in Practice

taxonomy of regression proving techniques that leverage bothselection and parallelism

implementation of techniques in tool, iCoq, that supports Coqprojects (useful for CI, e.g., Travis on GitHub)

evaluation using iCoq on six open source projects(23 kLOC over 22 revisions per project, on average)

8 / 40

Page 14: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Regression Proving Modes for Coq (Our Taxonomy)

Parallelization Selection

Granularity None Files Proofs

File level f·none f·file N/AProof level p·none p·file p·icoq

used in most GitHub Coq projects

no overhead from proof task management or dep. tracking

parallelism restricted by file dependency graph

9 / 40

Page 15: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Proof-Checking Toolchain

Legacy Top-Down Proof Checking (1990s)

coqc: compilation of source .v files to binary .vo files

.vo files contain specifications and all proofs

file-level parallelism via Make

Quick Compilation and Asynchronous Checking (2015)

coqc -quick: compilation of .v files to binary .vio files

.vio files contain specifications and proof tasks

proof tasks checkable asynchronously in parallel

10 / 40

Page 16: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Proof-Checking Toolchain

Legacy Top-Down Proof Checking (1990s)

coqc: compilation of source .v files to binary .vo files

.vo files contain specifications and all proofs

file-level parallelism via Make

Quick Compilation and Asynchronous Checking (2015)

coqc -quick: compilation of .v files to binary .vio files

.vio files contain specifications and proof tasks

proof tasks checkable asynchronously in parallel

10 / 40

Page 17: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Source File Example

Require Import List.

Require Import ListUtil.

Import ListNotations.

Fixpoint dedup A A_eq_dec (xs : list A) : list A :=

match xs with

| [] ⇒ []

| x :: xs ⇒if in_dec A_eq_dec x xs then dedup A A_eq_dec xs

else x :: dedup A A_eq_dec xs

end.

Lemma remove_dedup :

∀ A A_eq_dec (x : A) xs,

remove A_eq_dec x (dedup A A_eq_dec xs) =

dedup A A_eq_dec (remove A_eq_dec x xs).

Proof.

induction xs; intros; auto; simpl.

repeat (try case in_dec; try case A_eq_dec;

simpl; intuition); auto using f_equal.

- exfalso. apply n0. apply remove_preserve; auto.

- exfalso. apply n. apply in_remove in i; intuition.

Qed.

Dedup.v

11 / 40

Page 18: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Source File Example

Require Import List.

Require Import ListUtil.

Import ListNotations.

Fixpoint dedup A A_eq_dec (xs : list A) : list A :=

match xs with

| [] ⇒ []

| x :: xs ⇒if in_dec A_eq_dec x xs then dedup A A_eq_dec xs

else x :: dedup A A_eq_dec xs

end.

Lemma remove_dedup :

∀ A A_eq_dec (x : A) xs,

remove A_eq_dec x (dedup A A_eq_dec xs) =

dedup A A_eq_dec (remove A_eq_dec x xs).

Proof.

induction xs; intros; auto; simpl.

repeat (try case in_dec; try case A_eq_dec;

simpl; intuition); auto using f_equal.

- exfalso. apply n0. apply remove_preserve; auto.

- exfalso. apply n. apply in_remove in i; intuition.

Qed.

Dedup.v

Require statements expressingfile dependencies.

11 / 40

Page 19: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Source File Example

Require Import List.

Require Import ListUtil.

Import ListNotations.

Fixpoint dedup A A_eq_dec (xs : list A) : list A :=

match xs with

| [] ⇒ []

| x :: xs ⇒if in_dec A_eq_dec x xs then dedup A A_eq_dec xs

else x :: dedup A A_eq_dec xs

end.

Lemma remove_dedup :

∀ A A_eq_dec (x : A) xs,

remove A_eq_dec x (dedup A A_eq_dec xs) =

dedup A A_eq_dec (remove A_eq_dec x xs).

Proof.

induction xs; intros; auto; simpl.

repeat (try case in_dec; try case A_eq_dec;

simpl; intuition); auto using f_equal.

- exfalso. apply n0. apply remove_preserve; auto.

- exfalso. apply n. apply in_remove in i; intuition.

Qed.

Dedup.v

Definition of a recursive functionto remove duplicate list elementsin Gallina.Processed by quick-compilation.

11 / 40

Page 20: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Source File Example

Require Import List.

Require Import ListUtil.

Import ListNotations.

Fixpoint dedup A A_eq_dec (xs : list A) : list A :=

match xs with

| [] ⇒ []

| x :: xs ⇒if in_dec A_eq_dec x xs then dedup A A_eq_dec xs

else x :: dedup A A_eq_dec xs

end.

Lemma remove_dedup :

∀ A A_eq_dec (x : A) xs,

remove A_eq_dec x (dedup A A_eq_dec xs) =

dedup A A_eq_dec (remove A_eq_dec x xs).

Proof.

induction xs; intros; auto; simpl.

repeat (try case in_dec; try case A_eq_dec;

simpl; intuition); auto using f_equal.

- exfalso. apply n0. apply remove_preserve; auto.

- exfalso. apply n. apply in_remove in i; intuition.

Qed.

Dedup.v

Statement (type) of a lemma inGallina.

11 / 40

Page 21: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Coq Source File Example

Require Import List.

Require Import ListUtil.

Import ListNotations.

Fixpoint dedup A A_eq_dec (xs : list A) : list A :=

match xs with

| [] ⇒ []

| x :: xs ⇒if in_dec A_eq_dec x xs then dedup A A_eq_dec xs

else x :: dedup A A_eq_dec xs

end.

Lemma remove_dedup :

∀ A A_eq_dec (x : A) xs,

remove A_eq_dec x (dedup A A_eq_dec xs) =

dedup A A_eq_dec (remove A_eq_dec x xs).

Proof.

induction xs; intros; auto; simpl.

repeat (try case in_dec; try case A_eq_dec;

simpl; intuition); auto using f_equal.

- exfalso. apply n0. apply remove_preserve; auto.

- exfalso. apply n. apply in_remove in i; intuition.

Qed.

Dedup.v

Proof script in Ltac – potentiallytime-consuming to process.Becomes proof task.

11 / 40

Page 22: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·none Mode: File-Level Parallelization, No Selection

Parallelization Selection

Granularity None Files Proofs

File level f·none f·file N/AProof level p·none p·file p·icoq

classic mode used in most GitHub projects (“ReproveAll”)

no overhead from proof task management or dep. tracking

parallelism restricted by file dependency graph

12 / 40

Page 23: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

2 RemoveAll.vo remove all, remove all in, remove all preserve

13 / 40

Page 24: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

2 RemoveAll.vo remove all, remove all in, remove all preserve

13 / 40

Page 25: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

2 RemoveAll.vo remove all, remove all in, remove all preserve

13 / 40

Page 26: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

2 RemoveAll.vo remove all, remove all in, remove all preserve

13 / 40

Page 27: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·none Mode: Proof-Level Parallelization, No Selection

Parallelization Selection

Granularity None Files Proofs

File level f·none f·file N/AProof level p·none p·file p·icoq

used in some GitHub Coq projects

overhead from proof task management

parallelism (largely) unrestricted by file dependency graph

14 / 40

Page 28: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

3 checking remove all preserve

15 / 40

Page 29: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

3 checking remove all preserve

15 / 40

Page 30: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

3 checking remove all preserve

15 / 40

Page 31: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·none Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

3 checking remove all preserve

15 / 40

Page 32: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·file Mode: File-Level Parallelization, File Selection

Parallelization Selection

Granularity None Files Proofs

File level f·none f·file N/AProof level p·none p·file p·icoq

persists file checksums

overhead from file dependency tracking

parallelism restricted by file dependency graph

16 / 40

Page 33: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

17 / 40

Page 34: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

17 / 40

Page 35: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

17 / 40

Page 36: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

f·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vo remove preserve, in remove

2 Dedup.vo dedup, remove dedup

17 / 40

Page 37: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·file Mode: Proof-Level Parallelism, File Selection

Parallelization Selection

Granularity None Files Proofs

File level f·none f·file N/AProof level p·none p·file p·icoq

persists file checksums

overhead from file dependency tracking

parallelism (mostly) unrestricted by file dependency graph

18 / 40

Page 38: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove all in

3 checking remove all preserve

19 / 40

Page 39: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove all in

3 checking remove all preserve

19 / 40

Page 40: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove all in

3 checking remove all preserve

19 / 40

Page 41: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove all in

3 checking remove all preserve

19 / 40

Page 42: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·file Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking remove all in

3 checking remove all preserve

19 / 40

Page 43: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode: Proof-Level Parallelism, Proof Selection

Parallelization Selection

Granularity None Files Proofs

File level f·none f·file N/AProof level p·none p·file p·icoq

persists file & proof checksums

overhead from file & proof dependency tracking

parallelism (mostly) unrestricted by file dependency graph

20 / 40

Page 44: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

21 / 40

Page 45: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

21 / 40

Page 46: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

21 / 40

Page 47: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

21 / 40

Page 48: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

21 / 40

Page 49: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Mode in Practice

ListUtil.v

remove preserve in remove

Dedup.v

dedup remove dedup

RemoveAll.v

remove all preserve

remove all inremove all

Phase Task Definitions and Lemmas

1 ListUtil.vio remove preserve, in remove

2 Dedup.vio dedup, remove dedup

2 RemoveAll.vio remove all, remove all in, remove all preserve

3 checking in remove

3 checking remove dedup

3 checking remove all in

21 / 40

Page 50: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Workflow with 4-way Parallelization

file dep.graph

.v files

proof dep.graph

Analysis

compilationcommands

.vio files

affectedproofs

Checking

proofdependencies

proof-checking

commands

Collection

new dep.graphs

storage

22 / 40

Page 51: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Workflow with 4-way Parallelization

file dep.graph

.v files

proof dep.graph

Analysis

compilationcommands

.vio files

affectedproofs

Checking

proofdependencies

proof-checking

commands

Collection

new dep.graphs

storage

22 / 40

Page 52: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Workflow with 4-way Parallelization

file dep.graph

.v files

proof dep.graph

Analysis

compilationcommands

.vio files

affectedproofs

Checking

proofdependencies

proof-checking

commands

Collection

new dep.graphs

storage

22 / 40

Page 53: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

p·icoq Workflow with 4-way Parallelization

file dep.graph

.v files

proof dep.graph

Analysis

compilationcommands

.vio files

affectedproofs

Checking

proofdependencies

proof-checking

commands

Collection

new dep.graphs

storage

22 / 40

Page 54: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Evaluation: Open Source Git-Based Projects

Project LOC Domain

Coquelicot 38260 real number analysisFinmap 5661 finite sets and mapsFlocq 24786 floating-point arithmeticFomegac 2637 formal system metatheorySurface Effects 9621 functional programming languagesVerdi 56147 distributed systems∑

137112Avg. 22852.00

23 / 40

Page 55: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Evaluation: Open Source Git-Based Projects

Project LOC #Revs. #Files #Proof Tasks

Coquelicot 38260 24 29 1660Finmap 5661 23 4 959Flocq 24786 23 40 943Fomegac 2637 14 13 156Surface Effects 9621 24 15 289Verdi 56147 24 222 2756∑

137112 132 323 6763Avg. 22852.00 22.00 53.83 1127.16

24 / 40

Page 56: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Results with 4-way Parallelization: Coquelicot

0

20

40

befc2aa5

65187c83

af196a6f

96153bf0

30893b49

7c74911f

cc869c0d

a94e2add

ac474859

8f7b7c3f

51ccec65

a21157ac

67c0544f

99d324c8

02aa4835

ef18b8b5

18363068

a43e920b

f25236ff

e49f02aa

fc2b7663

a22616bb

a035d3bd

680ca587

Revision

Tim

e [s

]

f·none p·none f·file p·file p·icoq

25 / 40

Page 57: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Results with 4-way Parallelization: Fomegac

0

10

20

30

0af6b37e

ac790c93

a9bcb72a

78a261b5

79442b65

ca71b96c

4c1f4b3b

99f338f0

62d1a9d5

5f156d72

4b9edb51

b5020661

81d7d688

7a654d7c

Revision

Tim

e [s

]

f·none p·none f·file p·file p·icoq

26 / 40

Page 58: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Speedups over f·none for 4-way Parallel Checking

Coquelicot Finmap Flocq Fomegac Surface Effects Verdi

0

1

2

3

4

5

6

7

8

9

Sp

eed

up

fact

oro

verf·none

f·nonep·nonef·filep·filep·icoq

“How much faster modes are than the default mode, for each project”

27 / 40

Page 59: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Speedups from Sequential to 4-way Parallel Checking

Coquelicot Finmap Flocq Fomegac Surface Effects Verdi

0

0.5

1

1.5

2

2.5

3

3.5

Sp

eed

up

fact

oro

ver

seq

uen

tia

l

f·nonep·nonef·filep·filep·icoq

“Effect of parallelism on each mode and project”

28 / 40

Page 60: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Our Recent Work on the Theory of Regression Proving

We want to prove our regression proving techniques correct!

First steps:

model of change impact analysis in Coq using MathComp

practical tool, Chip, extracted from Coq code

evaluation of Chip for regression testing and build tools

29 / 40

Page 61: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Impact Analysis, Abstractly

1 2

3 4

5 6

(a)

1 2

3 4

5 6

(b)

30 / 40

Page 62: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Formal Model, Informally

finite sets of vertices V ,V ′ where V ⊆ V ′

set A of artifacts with decidable equality

functions f : V → A and f ′ : V ′ → A

dependency graphs g and g ′ for vertices in V and V ′

set N ⊆ V ′ of checkable vertices

operation check on vertices, with distinguishable results R

31 / 40

Page 63: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Formal Model, Informally

Modified Vertices

A vertex v ∈ V is modified whenever f (v) 6= f ′(v).

Impacted Vertices

A vertex v ∈ V is impacted (v ∈ I ) if it is reachable from somemodified vertex in g−1.

Fresh Vertices

A vertex v ∈ V ′ is fresh (v ∈ F ) whenever v /∈ V .

We check all vertices in the set (I ∪ F ) ∩ N.

32 / 40

Page 64: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Encoding in Coq using MathComp (Sketch)

Variable (A : eqType).Variables (V’ : finType) (P : pred V’).Definition V := sig_finType P.Variables (f’ : V’ → A) (f : V → A).

Definition impacted (g : rel V) (m : {set V}) : {set V} :=\bigcup_( x | x \in m) [set y | connect g x y].

Definition impacted_V’ g m := [set (val v) | v in impacted g−1 m].Definition fresh_V’ := [set v | ∼ P v].

Definition mod_V := [set v | f v != f’ (val v)].Definition impacted_fresh_V’ g := impacted_V’ g mod_V :|: fresh_V’.

33 / 40

Page 65: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Correctness Approach

assume we have all tuples of vertices in V and results ofapplying check

then, we check on all impacted and fresh vertices, and addresults and unimpacted-vertex tuples to form set Ris R complete: does it contain all checkable vertices in V ′?

is R sound: are all outcomes as if checked from scratch?

34 / 40

Page 66: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Correctness in Coq (Sketch)

Variable (R : eqType).Variables (g : rel V) (g’ : rel V’).Variables (checkable : pred V) (checkable’ : pred V’).Variables (check : V → R) (check’ : V’ → R).

Variable res_V : seq (V ∗ R).Hypothesis res_VP : ∀ v r,reflect (checkable v ∧ check v = r) ((v,r) \in res_V).

Definition res_unimpacted_V’ := [seq (val vr.1, vr.2) |vr ← res_V & val vr.1 \notin impacted_V’ g mod_V].

Definition res_V’ := res_impacted_fresh_V’ ++ res_unimpacted_V’.Definition chk_V’ := [seq vr.1 | vr ← res_V’].

Theorem chk_V’_compl : ∀ v, checkable’ v → v \in chk_V’.Theorem chk_V’_sound : ∀ v r, (v, r) \in res_V’ →checkable’ v ∧ check’ v = r.

35 / 40

Page 67: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Hierarchical Impact Analysis

U is set of coarse-grained components (“files”)

V is set of fine-grained components (“proofs”)

p : U → 2V is partition of V

g> is dep. graph for U, g⊥ is dep. graph for V

we can use impact analysis of U and g> to analyze V and g⊥

36 / 40

Page 68: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Hierarchical Impact Analysis, Illustrated

U

V

37 / 40

Page 69: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Hierarchical Strategies

Overapproximation Strategy (similar to f·file)

U ′i is set of impacted and fresh vertices in U ′

let V ′p =⋃

u∈U′ip′(u)

check all checkable vertices in V ′p

Compositional Strategy (similar to p·icoq)

Ui is set of impacted vertices in U

let Vp =⋃

u∈Uip(u)

let gp be subgraph of g⊥ induced by Vp

perform impact analysis in gp, check resulting vertices

38 / 40

Page 70: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Tool Implementation and Evaluation

extracted tool to OCaml from refined Coq code

integrated with two test selection tools and one build tool

compared outcomes/times with those for unmodified tools

outcomes are the same and things run a little slower

39 / 40

Page 71: Regression Proving with Dependent Types: Theory and Practicele/module selection asynchronous proof checking Examples: Make, Isabelle [ITP ’14] Proof parallelization: leverage multi-core

Conclusion

See our iCoq and piCoq papers and recommendations to Coqdevelopers: https://setoid.com

Contact us:

Karl Palmskog, [email protected]

Ahmet Celik, [email protected]

Chenguang Zhu, [email protected]

Milos Gligoric, [email protected]

40 / 40