a relational logic for higher order programs
play

A Relational Logic for Higher-Order Programs Alejandro Aguirre 1 - PowerPoint PPT Presentation

A Relational Logic for Higher-Order Programs Alejandro Aguirre 1 Gilles Barthe 1 Marco Gaboardi 2 Deepak Garg 3 Pierre-Yves Strub 4 ICFP, Sep 5 2017 1 Imdea Software; 2 University at Buffalo, SUNY; 3 MPI-SWS; 4 cole Polytechnique 1 Relational


  1. A Relational Logic for Higher-Order Programs Alejandro Aguirre 1 Gilles Barthe 1 Marco Gaboardi 2 Deepak Garg 3 Pierre-Yves Strub 4 ICFP, Sep 5 2017 1 Imdea Software; 2 University at Buffalo, SUNY; 3 MPI-SWS; 4 École Polytechnique 1

  2. Relational properties a.k.a. 2-properties (I) Two runs of two programs, e.g. equivalence... 2

  3. Relational properties a.k.a. 2-properties (II) ...or two runs of the same program, e.g. non-interference 3

  4. Relational refinement types (I) Refinement types extend types with logical properties: Γ ⊢ t : { x : N | ∃ z . x = 2 ∗ z } Relational refinement types 1 generalize them to a relational setting: Γ ⊢ t 1 ∼ t 2 : { x : N | x 1 = x 2 } 1Gilles Barthe, Cédric Fournet, Benjamin Grégoire, Pierre-Yves Strub, Nikhil Swamy, and Santiago Zanella Béguelin. Probabilistic relational verification for cryptographic implementations (POPL ’14) 4

  5. Relational refinement types (II) Pros: • Very intuitive (e.g. { x : N | x 1 ≤ x 2 } → { y : N | y 1 ≤ y 2 } types monotonic functions) • Syntax directed • Exploit structural similarities if b then 2 ∗ x else x +1 ∼ if b then 2 ∗ x else x − 1 • Lots of theoretical and practical developments for unary refinements could be reused 5

  6. Limits of RRT We want to prove: take n ( map f l ) = map f ( take n l ) 6

  7. Limits of RRT We want to prove: take n ( map f l ) = map f ( take n l ) Which type to give it? take n ( map f l ) ∼ map f ( take n l ) : { x : list N | x 1 = x 2 } 6

  8. Limits of RRT We want to prove: take n ( map f l ) = map f ( take n l ) Which type to give it? take n ( map f l ) ∼ map f ( take n l ) : { x : list N | x 1 = x 2 } We apply [APP] rule... take ∼ map : { x :? | ? } 6

  9. Our contributions • A foundational system to prove relational properties • in a syntax directed way • not restricted by types or structure 7

  10. Base logic: HOL • λ -terms over simple + inductive types • (Axiomatically defined) Predicates: P ( t 1 , . . . , t n ) ∀ l . prefix ([] , l ) ∀ xtl . prefix ( t , l ) ⇒ prefix ( x :: t , x :: l ) • Propositional connectives: ∧ , ∨ , ⇒ • Quantification over simple/inductive types: ∀ ( x : τ ), ∃ ( x : τ ) 8

  11. Base logic: HOL • λ -terms over simple + inductive types • (Axiomatically defined) Predicates: P ( t 1 , . . . , t n ) ∀ l . prefix ([] , l ) ∀ xtl . prefix ( t , l ) ⇒ prefix ( x :: t , x :: l ) • Propositional connectives: ∧ , ∨ , ⇒ • Quantification over simple/inductive types: ∀ ( x : τ ), ∃ ( x : τ ) Why not just use this? 8

  12. Base logic: HOL • λ -terms over simple + inductive types • (Axiomatically defined) Predicates: P ( t 1 , . . . , t n ) ∀ l . prefix ([] , l ) ∀ xtl . prefix ( t , l ) ⇒ prefix ( x :: t , x :: l ) • Propositional connectives: ∧ , ∨ , ⇒ • Quantification over simple/inductive types: ∀ ( x : τ ), ∃ ( x : τ ) Why not just use this? No syntax directedness or structural reasoning 8

  13. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  14. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  15. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  16. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  17. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  18. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  19. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  20. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  21. Relational HOL Judgements combine types and logic : Assertions over Γ Γ | Ψ ⊢ φ HOL: Context Predicate UHOL: Γ | Ψ ⊢ t 1 : τ 1 | φ ( r ) Term Predicate RHOL: Γ | Ψ ⊢ t 1 : τ 1 ∼ t 2 : τ 2 | φ ( r 1 , r 2 ) 1st term 2nd term Predicate 9

  22. Refinement types vs RHOL Key Idea : separation of concerns between types and assertions • Unary ⊢ t : { x : τ | φ ( x ) } − → t : τ | φ ( r ) • Relational t 1 ∼ t 2 : { x : τ | φ ( x 1 , x 2 ) } − → t 1 : τ ∼ t 2 : τ | φ ( r 1 , r 2 ) 10

  23. Two-sided and one-sided rules Two-sided rules relate two terms with the same top term former λ x 1 . t 1 ∼ λ x 2 . t 2 One-sided rules relate two terms with different top term former λ x 1 . t 1 ∼ t 2 u 2 11

  24. Two-sided rules Judgements combine types and logic : Abstraction Γ , x 1 : τ 1 , x 2 : τ 2 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ λ x 2 . t 2 : τ 2 → σ 2 | ∀ x 1 , x 2 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ][ r 2 x 2 / r 2 ] 12

  25. Two-sided rules Judgements combine types and logic : Abstraction Γ , x 1 : τ 1 , x 2 : τ 2 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ λ x 2 . t 2 : τ 2 → σ 2 | ∀ x 1 , x 2 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ][ r 2 x 2 / r 2 ] 12

  26. Two-sided rules Judgements combine types and logic : Abstraction Γ , x 1 : τ 1 , x 2 : τ 2 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ λ x 2 . t 2 : τ 2 → σ 2 | ∀ x 1 , x 2 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ][ r 2 x 2 / r 2 ] 12

  27. Two-sided rules Judgements combine types and logic : Abstraction Γ , x 1 : τ 1 , x 2 : τ 2 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ λ x 2 . t 2 : τ 2 → σ 2 | ∀ x 1 , x 2 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ][ r 2 x 2 / r 2 ] 12

  28. Two-sided rules Judgements combine types and logic : Abstraction Γ , x 1 : τ 1 , x 2 : τ 2 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ λ x 2 . t 2 : τ 2 → σ 2 | ∀ x 1 , x 2 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ][ r 2 x 2 / r 2 ] Application Γ | Ψ ⊢ t 1 : τ 1 → σ 1 ∼ t 2 : τ 2 → σ 2 | ∀ x 1 , x 2 .φ ′ [ x 1 / r 1 ][ x 2 / r 2 ] ⇒ φ [ r 1 x 1 / r 1 ][ r 2 x 2 / r 2 ] Γ | Ψ ⊢ u 1 : τ 1 ∼ u 2 : τ 2 | φ ′ Γ | Ψ ⊢ t 1 u 1 : σ 1 ∼ t 2 u 2 : σ 2 | φ [ u 1 / x 1 ][ u 2 / x 2 ] 12

  29. One-sided rules Abstraction Γ , x 1 : τ 1 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ t 2 : σ 2 | ∀ x 1 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ] Application Γ | Ψ ⊢ t 1 : τ 1 → σ 1 ∼ u 2 : σ 2 | ∀ x 1 .φ ′ [ x 1 / r 1 ] ⇒ φ [ r 1 x 1 / r 1 ] Γ | Ψ ⊢ u 1 : σ 1 | φ ′ Γ | Ψ ⊢ t 1 u 1 : σ 1 ∼ u 2 : σ 2 | φ [ u 1 / x 1 ] 13

  30. One-sided rules Abstraction Γ , x 1 : τ 1 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ t 2 : σ 2 | ∀ x 1 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ] Application Γ | Ψ ⊢ t 1 : τ 1 → σ 1 ∼ u 2 : σ 2 | ∀ x 1 .φ ′ [ x 1 / r 1 ] ⇒ φ [ r 1 x 1 / r 1 ] Γ | Ψ ⊢ u 1 : σ 1 | φ ′ Γ | Ψ ⊢ t 1 u 1 : σ 1 ∼ u 2 : σ 2 | φ [ u 1 / x 1 ] 13

  31. One-sided rules Abstraction Γ , x 1 : τ 1 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ t 2 : σ 2 | ∀ x 1 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ] Application Γ | Ψ ⊢ t 1 : τ 1 → σ 1 ∼ u 2 : σ 2 | ∀ x 1 .φ ′ [ x 1 / r 1 ] ⇒ φ [ r 1 x 1 / r 1 ] Γ | Ψ ⊢ u 1 : σ 1 | φ ′ Γ | Ψ ⊢ t 1 u 1 : σ 1 ∼ u 2 : σ 2 | φ [ u 1 / x 1 ] 13

  32. One-sided rules Abstraction Γ , x 1 : τ 1 | Ψ , φ ′ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ Γ | Ψ ⊢ λ x 1 . t 1 : τ 1 → σ 1 ∼ t 2 : σ 2 | ∀ x 1 .φ ′ ⇒ φ [ r 1 x 1 / r 1 ] Application Γ | Ψ ⊢ t 1 : τ 1 → σ 1 ∼ u 2 : σ 2 | ∀ x 1 .φ ′ [ x 1 / r 1 ] ⇒ φ [ r 1 x 1 / r 1 ] Γ | Ψ ⊢ u 1 : σ 1 | φ ′ Γ | Ψ ⊢ t 1 u 1 : σ 1 ∼ u 2 : σ 2 | φ [ u 1 / x 1 ] 13

  33. The SUB rule Allows us to fall back to HOL: Γ | Ψ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ ′ Γ | Ψ ⊢ HOL φ ′ [ t 1 / r 1 ][ t 2 / r 2 ] ⇒ φ [ t 1 / r 1 ][ t 2 / r 2 ] Γ | Ψ ⊢ t 1 : σ 1 ∼ t 2 : σ 2 | φ 14

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend