a tale of two provers - github pages · a tale of two provers conclusion hackage sharing proofs...

33
A TALE of TWO by Niki Vazou, Leonidas Lampropoulos and Jeff Polakow P R O V E R S

Upload: others

Post on 15-Jul-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

A TALE of TWO

by Niki Vazou, Leonidas Lampropoulos and Jeff Polakow

PROVERS

Page 2: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

take ::

Haskell

Int ! [a] ! [a]

Page 3: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

take ::

i:{Int|0≤i} ! xs:{[a]|i≤len xs} ! [a]

Liquid

Int ! [a] ![a]

Haskell

Page 4: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

take 2 [1,2,3]

OK

take 9 [1,2,3]

take ::

i:{Int|0≤i} ! xs:{[a]|i≤len xs} ! [a] Int ! [a] !

Error

Liquid Haskell

Page 5: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

take 2 [1,2,3]

OK

take 9 [1,2,3]

Error

0 ≤ 2 ≤ 3

0 ≤ 9 ≤ 3

SMT

take ::

i:{Int|0≤i} ! xs:{[a]|i≤len xs} ! [a] Int ! [a]

Liquid Haskell

Page 6: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Is Liquid Haskell a Theorem Prover?

Page 7: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

*f is a morphism when f []=[] ∧ f (x<>y) = f x <> f y

Theorem: Parallelism Equivalence If f is a morphism*between two lists, then f can be applied in parallel.

*

Is Liquid Haskell a Theorem Prover?

Page 8: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Theorem: Parallelism Equivalence If f is a morphism*between two lists, then .

*f is a morphism when f []=[] ∧ f (x<>y) = f x <> f y

f x = concat (pmap f (chunk i x))*

Is Liquid Haskell a Theorem Prover?

Page 9: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

pEquiv :: f:([a] -> [b])

-> Morphism [a] [b] f -> x:[a] -> i:Pos -> {f x = concat (pmap f (chunk i x))}

f x = concat (pmap f (chunk i x))

*f is a morphism when f []=[] ∧ f (x<>y) = f x <> f y

Is Liquid Haskell a Theorem Prover?

Page 10: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

pEquiv :: f:([a] -> [b])

-> Morphism [a] [b] f -> x:[a] -> i:Pos -> {f x = concat (pmap f (chunk i x))}

f x = concat (pmap f (chunk i x))

*type Morphism a b f = x:a -> y:b -> f []=[] ∧ f (x<>y) = f x <> f y { }

Is Liquid Haskell a Theorem Prover?

Page 11: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

pEquiv :: f:([a] -> [b])

-> Morphism [a] [b] f -> x:[a] -> i:Pos -> {f x = concat (pmap f (chunk i x))}

f x = concat (pmap f (chunk i x))

Yes!

Theorems: Proofs:

Refinement Types(Terminating) Haskell Terms

Correctness: Liquid Type Checking

Is Liquid Haskell a Theorem Prover?

Page 12: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

pEquiv :: f:([a] -> [b])

-> Morphism [a] [b] f -> x:[a] -> i:Pos -> {f x = concat (pmap f (chunk i x))}

f x = concat (pmap f (chunk i x))

Demo

Is Liquid Haskell a Theorem Prover?Yes!

Page 13: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Morphism Parallelism Equivalence

Application: String Matching

pEquiv :: RightId [b] -> f:([a] -> [b])

-> Morphism [a] [b] f -> x:[a] -> i:Pos -> {f x = concat (pmap f (chunk i x))}

=> f:([a] -> m)

-> Morphism [a] m f

-> {f x = mconcat (pmap f (chunk i x))}

=> f:(n -> m)

(Monoid m)(Chunkable n, Monoid m)

-> Morphism n m f -> x:n -> i:Pos

Page 14: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Find all the occurrences of a target string in an input string.

Application: String Matching

Page 15: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

“the best of times”

Find all the occurrences of a target string in an input string.

Application: String Matching

Page 16: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Find all the occurrences of a target string in an input string.

Application: String Matching

“the best of times”1 2 3 54 6 87 9 10 11 1312 161514 17

Target “es” matches at [6, 16].

Page 17: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Verification Time:

0

200

400

600

800

Exec Spec Proof

669LoC

285LoC180LoC

Application: String Matching

Human Effort:

5x

20 min

2 months

LoC (Proofs/Exec):

Page 18: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

0

200

400

600

800

Exec Spec Proof

766LoC

248LoC122LoC

669LoC

285LoC180LoC

Verification Time:

Human Effort:

5x

20 min

2 months

8x

38 sec

2 weeks

VS.

LoC (Proofs/Exec):

Page 19: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

Haskell VS. Non-Haskell Proofs

Page 20: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

SMT- VS. Tactic- Based Automations

Haskell VS. Non-Haskell Proofs

Page 21: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

Intrinsic VS. Extrinsic Verification

SMT- VS. Tactic- Based Automations

Haskell VS. Non-Haskell Proofs

Page 22: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Intrinsic VS. Extrinsic Verification

take :: i:Nat ! xs:{i≤len xs} ! {v|len v=i}

take 0 _ = [] take i xs = x:take (i-1) xs

Page 23: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Definition take := seq.take.

Theorem take_spec: ∀i x, i ≤ length x ! length (take i x) = i.

take :: i:Nat ! xs:{i≤len xs} ! {v|len v=i}

take 0 _ = [] take i xs = x:take (i-1) xs

Intrinsic VS. Extrinsic Verification

Page 24: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

SMT- VS. Tactic- Based Automations

Intrinsic VS. Extrinsic Verification

Haskell VS. Non-Haskell Proofs

Page 25: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

SMT- VS. Tactic- Based Automations

Intrinsic VS. Extrinsic Verification

Semantic VS. Syntactic Termination

Haskell VS. Non-Haskell Proofs

Page 26: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

chunk :: i:Pos ! xs:[a] ! [[a]] / [len xs]

Semantic VS. Syntactic Termination

Page 27: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

Fixpoint chunk {M: Type} (fuel: nat) (i: nat) (x: M) : option (list M)

chunk :: i:Pos ! xs:[a] ! [[a]] / [len xs]

Semantic VS. Syntactic Termination

Page 28: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

chunk :: i:Pos ! xs:[a] ! [[a]] / [len xs]

SMT OK /Errorghc

Big VS. Tiny Trusted Code Base

Page 29: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

SMT OK /Errorghc.hs

Big VS. Tiny Trusted Code Base

Page 30: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

Big VS. Tiny Trusted Code Base

Semantic VS. Syntactic Termination

SMT- VS. Tactic- Based Automations

Intrinsic VS. Extrinsic Verification

Haskell VS. Non-Haskell Proofs

Page 31: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

VS.

Big VS. Tiny Trusted Code Base

Semantic VS. Syntactic Termination

SMT- VS. Tactic- Based Automations

Proof Verifier VS. Assistant

Intrinsic VS. Extrinsic Verification

Haskell VS. Non-Haskell Proofs

Page 32: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

A Tale of Two Provers

Conclusion

Liquid Haskell is a promising prover, but needs a lot of Coq-inspired future work.

Page 33: A TALE of TWO PROVERS - GitHub Pages · A Tale of Two Provers Conclusion Hackage Sharing Proofs Liquid GUI Proof Assistant Fast “tactics” Thanks! Liquid Haskell is a promising

A Tale of Two Provers

Conclusion

Hackage Sharing ProofsLiquid GUI Proof Assistant

Fast “tactics”

Thanks!

Liquid Haskell is a promising prover, but needs a lot of Coq-inspired future work.