mechanizing the metatheory of sledgehammerandreipopescu.uk/slides/frocos2013-slides.pdf ·...

28
Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult¨ at f¨ ur Informatik Technische Universit¨ at M¨ unchen

Upload: others

Post on 10-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Mechanizing the Metatheoryof Sledgehammer

Jasmin Blanchette and Andrei Popescu

Fakultat fur InformatikTechnische Universitat Munchen

Page 2: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Overview

• Sledgehammer

• Sledgehammer’s Metatheory

• Mechanization

Page 3: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Overview

• Sledgehammer

• Sledgehammer’s Metatheory

• Formal Verification

Page 4: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Overview

• Sledgehammer

• Sledgehammer’s Metatheory

• Formal Verification

Page 5: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Sledgehammer

• Isabelle: interactive theorem prover

• Sledgehammer: connects Isabelle withautomatic theorem provers (ATPs)

Lemma: ∀x. ∃y. P (x, y)Proof (with Isabelle’s structured proof language):

Fix xObtain z where Q(x, z) using 〈facts〉 by 〈method〉From this obtain y where P (x, y) call sledgehammer

qed

Page 6: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Sledgehammer’s Pipeline

(∧

F )?

=⇒ϕ

• Start with (typed) HOL goal ϕ

• Gather set of relevant facts F

• Encode in (untyped) FOLλ’s go away, types go away

• Feed to ATPs

• If one succeeds, with E ⊆ F

• Reprove with Isabelle’s internal ATP, Metis

• Why reprove? Isabelle trusts no one but herself

Page 7: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Overview

• Sledgehammer

• Sledgehammer’s Metatheory

• Formal Verification

Page 8: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Sledgehammer’s Metatheory

Higher Order Logic

HOL PFOLλ

MFOLpoly

UFOL

typespoly types

Are the encodings sound? complete? efficient?All these are important practical questions!

Page 9: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Sledgehammer’s Metatheory

• Completeness: The orginal Isabelle goalprovable implies FOL encoding also provable7→ The ATPs have a chance to prove it

• Soundness: FOL encoding provable impliesoriginal Isabelle goal also provable7→ Isabelle can reconstruct the proof

• Efficiency• When erasing types, extra structure is added in

compensation: tag or guard decoration• Decoration should be lightweight, yet preserve

soundness and completeness7→ Smaller clutter means better chance for ATPs

It’s all for the user ,

Page 10: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Overview

• Sledgehammer

• Sledgehammer’s Metatheory

• Formal Verification

Page 11: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Formal Verification

HOL PFOLλ

MFOLpoly

UFOL

typespoly types

Blanchette et al., TACAS 2013:Encoding Monomorphic and Polymorphic Types(Soundly, Completely, and Efficiently)A variety of encodings• based on tags or guards• full, lightweight, featherweight• factor in infiniteness knowledge

FroCoS 2013: Formal verification by Isabelle herself

Page 12: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Why Formal Verification

• Blanchette has finetuned the encodings makingthem as clutter-free as possibleHe can sleep better: they are still sound!

• General-purpose formalization of MFOL results:completeness, clausification, Low-Skolem

• Test/illustrate new Isabelle features• Theory of syntax with bindings• Codatatypes

Page 13: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Encodings

Σ: MFOL signatureΦ: set of Σ-formulas

(Σ, Φ)

MFOL

(Σ#, Φ#)

UFOL

M M#

NN $

Page 14: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Encodings

Example unary guard predicates for each erased sort

(Σ, Φ)

MFOL

(Σ#, Φ#)

UFOL

Σ : ({elem, list}, {nil, cons}, ∅)Φ : nil 6= cons(x, xs)Σ# : ({nil, cons}, {gelem, glist})AxΦ : glist(nil), glist(cons(x, xs))Φ# : AxΦ together withgelem(x) ∧ glist(xs) =⇒ nil 6= cons(x, xs)

Page 15: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Encodings

Example unary guard predicates for each erased sort

(Σ, Φ)

MFOL

(Σ#, Φ#)

UFOL

Σ : ({elem, list}, {nil, cons}, ∅)Φ : nil 6= cons(x, xs)Σ# : ({nil, cons}, {gelem, glist})AxΦ : /////////////////////////////////////glist(nil), glist(cons(x, xs))Φ# : AxΦ together with/////////////////////////gelem(x) ∧ glist(xs) =⇒ nil 6= cons(x, xs)

Page 16: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Encodings

Methodology: add decorations first, erase second# = e ◦ a

Sufficient: make Φa monotonic

(Σ, Φ)

MFOL

(Σ#, Φ#)

UFOL

(Σa, Φa)

MFOL

ae

Page 17: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Monotonicity

• Claessen et al., CADE 2011:Sort It Out with Monotonicity

• Φ monotonic: If Φ has a model, then it alsohas a larger model with all type interpretationsof equal size7→ types in Φ can be safely erased

• nil 6= cons(x, xs) already monotonic

• Syntactic criteria

Page 18: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

• MFOL and UFOL• basics: formulas, models, satisfaction, substitution• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 19: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

Locales: Fix types, constants and assumptionsProblems = Locales Encodings = Morphisms

MFOL Prob <a MFOL Mono Prob <e UFOL Prob

• MFOL and UFOL• basics: formulas, models, satisfaction, substitution• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 20: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

Can focus on at most countable modelsUse a fixed countable HOL type

Monotonicity analysis becomes manageable

• MFOL and UFOL• basics: formulas, models, satisfaction, substitution• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 21: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

• MFOL and UFOL• basics: formulas, models, satisfaction, substitution• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 22: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

• MFOL and UFOL• bureaucracy• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 23: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

New Isabelle theory of syntax with bindings

• MFOL and UFOL• bureaucracy• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 24: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

New Isabelle theory of syntax with bindingsRecursors that interact well with substitution

• MFOL and UFOL• bureaucracy• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 25: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

New Isabelle theory of syntax with bindingsRecursors that interact well with substitution

Optimized for semantic interpretations of syntax

• MFOL and UFOL• bureaucracy• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 26: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Our Formalization

Formalized tableau-based proof a la Beth/HintikkaInfinite proof trees captured as a codatatype

Used Isabelle’s codatatype package

• MFOL and UFOL• basics: formulas, models, satisfaction, substitution• classic results: completeness, compactness,

Lowenheim-Skolem, clausification

• Type encodings from Blanchette et al.

• Monotonicity criteria from Claessen et al.

• Soundness and completeness

Page 27: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Conclusions

• Have put Isabelle to work in order to verify itsown communication with ATPs

• Based on this, Isabelle might learn (how) totrust the ATPs

Page 28: Mechanizing the Metatheory of Sledgehammerandreipopescu.uk/slides/FROCOS2013-slides.pdf · Mechanizing the Metatheory of Sledgehammer Jasmin Blanchette and Andrei Popescu Fakult at

Mechanizing the Metatheoryof Sledgehammer

Jasmin Blanchette and Andrei Popescu

Fakultat fur InformatikTechnische Universitat Munchen