Proof pearl: Abella formalization of λ-calculus cube property Beniamino Accattoli INRIA (Parsifal) & Ecole polytechnique (LIX) Carnegie Mellon University

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

1 / 26

3 mini-pearls

This proof pearl consists of three more or less independent mini-pearls: 1

Representing and reasoning about untyped terms in Abella.

2

A beautiful definition of residuals, due to G´erard Huet.

3

A clean and simple proof of the cube property for residuals.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

2 / 26

Outline

1

1) Representing untyped terms in Abella, and the diamond property

2

2) Representing residuals

3

3) The cube property

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

3 / 26

Abella

Abella is a recent proof assistant, developed by Andrew Gacek. It is based on work of Gacek, Miller, Nadathur, and Tiu. It is maintained by Kaustuv Chaudhuri at INRIA (Parsifal team). Its features: Higher-Order Abstract Syntax (HOAS); Nominal quantifier ∇, called nabla; Induction and co-induction.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

4 / 26

Untyped terms in Abella

HOAS: handles naturally binders and capt.-avoiding substitution. HOAS-based tools usually do not naturally manage free variables. Nabla: handles free variables very naturally.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

5 / 26

λ-calculus in HOAS Encoding of λ-calculus in HOAS: app : tm -> tm -> tm. abs : (tm -> tm) -> tm. The predicate M is a term: Define is_a_term : tm -> prop by nabla x, is_a_term x; is_a_term (abs M) := nabla x, is_a_term (M x); is_a_term (app M N) := is_a_term M /\ is_a_term N. A β-redex (λx.M)N is given by app (abs M) N. M is a function, and M N denotes function application. Hence, the reduct M{x/N} is simply noted M N. Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

6 / 26

Confluence for λ-calculus A rewriting system (S, →) if confluent when: *

t

u1

*

t

u1

implies ∃s s.t. *

*

u2

u2

*

s

*

Confluence in general is difficult to prove. It is easy if the system has the diamond property: t

u1

t

u1

u2

s

implies ∃s s.t. u2

λ-calculus is not an easy case. Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

7 / 26

Parallel reductions

Confluence for λ-calculus by Tait-Martin-L¨ of’s technique. Idea: find a new reduction ⇒ s.t.: 1

⇒ extends →β : →β ⊆ ⇒ ⊆ →∗β .

2

⇒ is confluent because it has the diamond property.

By (1) we get ⇒∗ = →∗β . So →β is confluent. We focus on the diamond property, of which residuals are a generalization.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

8 / 26

Parallel reduction Let’s define ⇒: x ⇒x

t ⇒ t0 λx.t ⇒ λx.t 0

t ⇒ t0 u ⇒ u0 tu ⇒ t 0 u 0

t ⇒ t0 u ⇒ u0 (λx.t)u ⇒ t 0 {x/u 0 }

In Abella: Define pred : tm -> tm -> prop by nabla x, pred x x; pred (abs T) (abs T’) := nabla x, pred (T x) (T’ x); pred (app T U) (app T’ U’) := pred T T’ /\ pred U U’; pred (app (abs T) U) (T’ U’) := nabla x, pred (T x) (T’ x) /\ pred U U’.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

9 / 26

Proof of the diamond property Lemma (Substitution lemma for ⇒) If t ⇒ t 0 and u ⇒ u 0 then t{x/u} ⇒ t 0 {x/u 0 }.

Proof. By induction on t ⇒ t 0 . The formal proof is as it would be on the blackboard: Theorem pred_sub : forall T T’ U U’, nabla x, pred (T x) (T’ x) -> pred U U’ -> pred (T U) (T’ U’). induction on 1. intros. case H1. search. % Base case (T x) = x search. % Base case (T x) = y apply IH to H3 H2. search. apply IH to H3 H2. apply IH to H4 H2. search. apply IH to H3 H2. apply IH to H4 H2. search. Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

10 / 26

Proof of the diamond property 2 Theorem (Diamond property) t

u1

t

u1

u2

s

implies ∃s s.t. u2

Proof. By induction on t ⇒ u1 and case analysis of t ⇒ u2 . Theorem diamond : forall T U1 U2, pred T U1 -> pred T U2 -> exists S, pred U1 S /\ pred U2 S. induction on 1. intros. case H1. case H2. search. case H2. apply IH to H3 H4. search. case H2. apply IH to H3 H5. apply IH to H4 H6. search. case H3. apply IH to H4 H5. apply IH to H7 H6. apply pred_sub to H11 H9. search. case H2. case H5. apply IH to H3 H6. apply IH to H4 H7. apply pred_sub to H10 H8. search. apply IH to H3 H5. apply IH to H4 H6. apply pred_sub to H9 H7. apply pred_sub to H10 H8. search. Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

11 / 26

Outline

1

1) Representing untyped terms in Abella, and the diamond property

2

2) Representing residuals

3

3) The cube property

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

12 / 26

Residuals Residuals are a refinement of parallel reduction. The refinement consist in: R

1

Expliciting the set of redexes R reduced in a parallel step ⇒, and

2

Adding a tracing system for redexes satisfying the

3

Parallel moves property: the redexes reduced to close (local) diagrams can be traced back to the starting term: t

P

u1

R

u2

t

implies ∃s, R/P, P/R s.t.

P

u1 R/P

R

u2

P/R

s

R/P is the set of redexes which are residuals of R after P. Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

13 / 26

Examples in λ-calculus Let I := λx.x. P/R is the empty set: P

(λx.y )( II ) R

y

P/R

(λx.y )I R/P

y

P/R has more than one element: (λx.xx)( II )

P

(λx.xx)I R/P

R P/R

( II )( II )

Accattoli (INRIA & CMU)

II

Proof pearl: Abella formalization of λ-calculus cube property

14 / 26

Representing sets of redexes

A set of redexes R of a term t is a decoration of t, where the redexes in R have been underlined: R, P, S :: x | λx.R | RP | (λx.R)P Example: the four possible sets of redexes of (λx.(II ))I are (λx.(II ))I

(λx.(II ))I

(λx.(II ))I

(λx.(II ))I

Simplification: redexes—and not applications—are marked. Consequence: no notion of well-formed term is required (called regular terms in Huet’s paper).

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

15 / 26

Huet’s pearl Idea: residuals as parallel reduction indexed by a set of redexes. A set of residuals R/P is a set of redexes, i.e. a marked term. P

R/P is defined as the term R 0 s.t. R ⇒ R 0 , where: S

R ⇒ R0

x

x ⇒ x

λx.S

λx.R ⇒ λx.R 0 Q

P

R ⇒ R0

S ⇒ S0 PQ

RS ⇒ R 0 S 0 Q

P

R ⇒ R0 (λx.R)S

Accattoli (INRIA & CMU)

S ⇒ S0

(λx.P)Q



(λx.R 0 )S 0

Q

P

R ⇒ R0 (λx.R)S

S ⇒ S0

(λx.P)Q



Q

P

R ⇒ R0 (λx.R)S

R 0 {x/S 0 } S ⇒ S0

(λx.P)Q



R 0 {x/S 0 }

Proof pearl: Abella formalization of λ-calculus cube property

16 / 26

Outline

1

1) Representing untyped terms in Abella, and the diamond property

2

2) Representing residuals

3

3) The cube property

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

17 / 26

The diamond property: t

u1

u2

s

Lifts via residuals to the parallel moves property: t

P

u1 R/P

R

u2

P/R

s

For the cube property (due to J.J. L´evy) just replace t with S: S

P

S/P

R

S/R

R/P P/R

Q

The cube is a contextual refinement of the parallel moves: P R/P

R P/R

⇒ ⇒ and ⇒ ⇒ act in the same way on any set of redexes S Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

18 / 26

The substitution lemma

Residuals satisfy a substitution property:

Lemma (substitution lemma for residuals) P

Q

If R ⇒ R 0 and S ⇒ S 0 then R{x/S}

P{x/Q}



R 0 {x/S 0 }.

Proof. P

By induction on R ⇒ R 0 . Compare with parallel reduction: If t ⇒ t 0 and u ⇒ u 0 then t{x/u} ⇒ t 0 {x/u 0 }.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

19 / 26

Cube property The cube property can be proved exactly as the diamond property:

Theorem (Diamond property) S

P

S/P

S

implies ∃Q s.t.

R

S/R

P

S/P

R

S/R

R/P P/R

Q

Proof. P

R

By induction on S ⇒ S/P and case analysis of S ⇒ S/R. 1 def., 1 lemma, 1 theorem: much simpler than Huet’s development.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

20 / 26

Cube and prism Huet’s proof uses a more fundamental prism property. In the abstract theory of residuals (van Oostrom-de Vrijer) the cube is an axiom, not the prism. Our proof does not use the prism, but we can include it, revisiting Huet’s approach. Define the union R ∪ S as the term with the marks in R or S. The cube-prism property: S

P

R∪P

R

S/R

S/P

P/R

R/P

S/(R∪P)

proved exactly as the cube property. Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

21 / 26

Abella development The formalization: 2 definitions, 1 lemma, and 1 theorem: Define res : mtm -> mtm -> mtm -> prop by nabla x, res x x x; res (mabs R) (mabs P) (mabs R’) := nabla x, res (R x) (P x) (R’ x); res (mapp R S) (mapp P Q) (mapp R’ S’) := res R P R’ /\ res S Q S’; res (mredex R S) (mapp (mabs P) Q) (mredex R’ S’) := nabla x, res (R x) (P x) (R’ x) /\ res S Q S’; res (mapp (mabs R) S) (mredex P Q) (R’ S’) := nabla x, res (R x) (P x) (R’ x) /\ res S Q S’; res (mredex R S) (mredex P Q) (R’ S’) := nabla x, res (R x) (P x) (R’ x) /\ res S Q S’. Define res_union : mtm -> mtm -> mtm -> prop by nabla x, res_union x x x; res_union (mabs R) (mabs P) (mabs Q) := nabla x, res_union res_union (mapp R S) (mapp P T) (mapp Q U) := res_union R P Q /\ res_union S T U; res_union (mredex R S) (mredex P T) (mredex Q U) := nabla x, res_union (R x) (P x) (Q x) /\ res_union S res_union (mapp (mabs R) S) (mredex P T) (mredex Q U) := nabla x, res_union (R x) (P x) (Q x) /\ res_union S res_union (mredex R S) (mapp (mabs P) T) (mredex Q U) := nabla x, res_union (R x) (P x) (Q x) /\ res_union S

Accattoli (INRIA & CMU)

(R x) (P x) (Q x);

T U; T U; T U.

Proof pearl: Abella formalization of λ-calculus cube property

22 / 26

Theorem res_subst : forall R P R’ S Q S’, nabla x, res (R x) (P x) (R’ x) -> res S Q S’ -> res (R S) (P Q) (R’ S’). induction on 1. intros. case H1. search. search. apply IH to H3 H2. search. apply IH to H3 H2. apply IH to H4 H2. search. apply IH to H3 H2. apply IH to H4 H2. search. apply IH to H3 H2. apply IH to H4 H2. search. apply IH to H3 H2. apply IH to H4 H2. search. Theorem prism_cube : forall Q P R Q’ Q’’, res Q R Q’’ -> res Q P Q’ -> exists P’ R’ RunionP S, res P R P’ /\ res R P R’ /\ res Q’ R’ S /\ res Q’’ P’ S /\ res Q RunionP S /\ res_union P R RunionP. induction on 1. intros. case H1. case H2. search. case H2. apply IH to H3 H4. search. case H2. apply IH to H3 H5. apply IH to H4 H6. search. case H3. apply IH to H4 H6. apply IH to H7 H5. apply res_subst to H16 H10. search. case H2. apply IH to H3 H5. apply IH to H4 H6. search. apply IH to H3 H5. apply IH to H4 H6. apply res_subst to H9 H15. search. case H2. case H5. apply IH to H3 H7. apply IH to H4 H6. apply res_subst to H11 H17. search. apply IH to H3 H5. apply IH to H4 H6. apply res_subst to H9 H15. apply res_subst to H10 H16. search. case H2. apply IH to H3 H5. apply IH to H4 H6. apply res_subst to H10 H16. search. apply IH to H3 H5. apply IH to H4 H6. apply res_subst to H9 H15. apply res_subst to H10 H16. search.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

23 / 26

Complete developments A form of prism property is also true for parallel reduction: t

u1

u2

s

The proof of the diamond property via complete developments (by Takahashi) is an instance. Let t ◦ be the complete development of t. Then: t

u1

u2

t◦

Once again, the proof structure is the same. Randy Pollack’s formalization in Abella has 18 lemmas, mine has 2! Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

24 / 26

Conclusions

Abella is an excellent tool for untyped calculi with binders. Formalized proofs faithfully reflect pen-and-paper proofs. Our case study: a strikingly simple formalization of λ-calculus cube property. Work in progress: formalization of Bohm’s separation theorem.

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

25 / 26

THANKS!

Accattoli (INRIA & CMU)

Proof pearl: Abella formalization of λ-calculus cube property

26 / 26

Proof pearl: Abella formalization of -calculus cube ...

M)N is given by app (abs M) N. M is a function, and M N denotes function application. .... 1 def., 1 lemma, 1 theorem: much simpler than Huet's development.

261KB Sizes 4 Downloads 141 Views

Recommend Documents

On the Formalization of -Calculus Confluence and ...
Application: t s. Representation of the λ-calculus: Kind tm type. Type ap tm -> tm -> tm. Type abs. (tm -> tm) -> tm. Representation of β-reduction (λx.M)N →β M{xN}: ... Clash Between ∀ and λ. The quantifier ∀ is not adequate to reason abo

Cultures of Formalization
Mar 9, 2010 - Amsterdam, The Netherlands). Anne Beaulieu .... Data-sharing also demands formalization: of notions of authorship and ownership of data, the ...

Abella Anderson.pdf
Download free abella anderson wallpapers for your mobile phone. Amazon.comabella anderson live wallpaper appstore for android. Based laces on twitter ...

Abella danger sweat
Windows 7 guide pdf.37359849224 - Download Abella danger sweat.Princesse mononokefre. ... Tragically hip 320.Ifstaffwe'reto abella danger sweat what tasks ...

Objective: Cube and Cube Roots
You can also find the cube root of fractions and decimals. Examples: 1. √. 1. 8. 3. = 2. √0.125. 3. = ______. 3. √. 8. 27. 3. = 4. √0.008. 3. = VIC #4. Sometimes, cube roots are not whole numbers. In those situations, you will need to decide

Download-This-File-Formalization-O.pdf
2004, BARCELONA, SPAIN, NOVEMBER 18-19, 2004, PROCEEDINGS (LECTURE NOTES IN. COMPUTER SCIENCE). Study Online and Download Ebook ...

Formalization of control-flow criteria of software testing
Importance of the software testing is increasing as a result of the extension .... with previously defined criteria and using a definition from [22] as a base:.

Abella Danger, Phoenix Marie
Hot pursuitsubs.41791338599. Antman ... Simpo PDF to. Word. ... Android development for beginners by udacity. ... Microsoftandroid apps. ... Top 40 june 2015.

Proof Without Words: A Trigonometric Proof of the Arithmetic Mean ...
We prove wordlessly the arithmetic mean-geometric mean inequality for two positive numbers by an equivalent trigonometric inequality. Reference. 1. L. Tan, Proof without words: Eisenstein's duplication formula, Math. Mag. 71 (1998) 207, http:// · dx.

Interchange Heterozygote of Pearl Millet
... Extn. 342. Fax Na oo so ssssa. ... tween the semidwarf T3–6 interchange homozygote line IP12781 and a genic male sterile segregant of a normal ... In 45 ovules, the endosperm was still in the free nucleate stage with a fewer number of ...

Abella danger,kissa sins
Happyland s01e08 720p.Abella danger ... pdf.Carnage – iliketuh.Pap puts down theidea ofHuck getting an education. Twain does use humor in hiscrazy ... forevermoreshall bethe plot of"To Build a Fire"is based around atruestory. Returning ...

pearl of great price pdf
pearl of great price pdf. pearl of great price pdf. Open. Extract. Open with. Sign In. Main menu. Displaying pearl of great price pdf.

Formalization and applications of the Precautionary ...
renewable energy sources is an act which does not correspond to an .... (2). We immediately see that µ∗. F is a non additive probability on P(Ω) satisfying. µ∗.

Formalization of Evidence: A Comparative Study
focus on domain-independent usages of the concept, and ignore the ..... to check the truthfulness of a general statement, they more often seek positive .... First, the availability of a prior probability distribution is problematic (Kyburg, 1983a).

Proof of pudding.pdf
Page. 1. /. 1. Loading… Page 1 of 1. Page 1 of 1. Proof of pudding.pdf. Proof of pudding.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Proof of pudding.pdf. Page 1 of 1.

PDF The Cube
Just in time to satisfy the kids of all ages who received ... logic, brain dexterity, and memory. Puzzle Masters. Jerry Slocum, David. Singmaster, Dieter Gebhardt,.

Pearl Shockley Scholarship.pdf
Pearl Shockley Scholarship.pdf. Pearl Shockley Scholarship.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Pearl Shockley Scholarship.pdf.

CUBE Augmented Reality_onepager.pdf
broadcast technology company. Our on-site capture ... see the analytic elements. require tracking ... Page 3 of 3. CUBE Augmented Reality_onepager.pdf.