une approche unifiante pour programmer s urement avec de
play

Une approche unifiante pour programmer s urement avec de la syntaxe - PowerPoint PPT Presentation

Une approche unifiante pour programmer s urement avec de la syntaxe du premier ordre contenant des lieurs Nicolas Pouillard INRIA Soutenance de th` ese 13 Janvier 2012 Jury compos e de : Pr esident M. Roberto Di Cosmo Rapporteurs


  1. Une approche unifiante pour programmer sˆ urement avec de la syntaxe du premier ordre contenant des lieurs Nicolas Pouillard INRIA Soutenance de th` ese 13 Janvier 2012 Jury compos´ e de : Pr´ esident M. Roberto Di Cosmo Rapporteurs M. Andrew Pitts M. Dale Miller Examinateurs M. Daniel Hirschkoff M. Conor McBride Directeur M. Fran¸ cois Pottier 1

  2. Outline First steps: programming with binders The NomPa library: interface and usage Safety of the approach: logical relations and parametricity 2

  3. What is a program? Web browsers, software (word processing, image processing, accounting, management, development), operating systems, drivers, games, and so forth... 3

  4. What is a program? Web browsers, software (word processing, image processing, accounting, management, development), operating systems, drivers, games, and so forth... At a first sight it is a text, such as: print "Hello! 2 times 21 is equal to " >> print ( show ( 2 * 21 )) 3

  5. What is a program? Web browsers, software (word processing, image processing, accounting, management, development), operating systems, drivers, games, and so forth... At a first sight it is a text, such as: print "Hello! 2 times 21 is equal to " >> print ( show ( 2 * 21 )) Data processing: an essential activity of programs Simple data: numbers, texts... Complex data: music, images, videos, presentations.. Structured data: lists, arrays, trees, graphs... 3

  6. What is a programming language? Examples of languages: Java, C, C++, Ruby, Python, OCaml, Haskell, Agda... A language is defined by rules: To select possible programs To give them a meaning Rules for safety: Scopes of variables Strong and static typing Formal specifications (correctness proofs) 4

  7. Programs as data... Definition Meta-program: a program processing programs. 5

  8. Programs as data... Definition Meta-program: a program processing programs. For instance a compiler is a meta- program. A compiler automatically translate programs from one language to an- other passing through intermediate languages. We can object language (resp. object program) languages and programs that a meta-program process. 5

  9. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 f 13 6

  10. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 f 13 � ( λ x → 3 * x + 3 ) 13 6

  11. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 f 13 � ( λ x → 3 * x + 3 ) 13 � 3 * 13 + 3 6

  12. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 f 13 � ( λ x → 3 * x + 3 ) 13 � 3 * 13 + 3 � 39 + 3 6

  13. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 f 13 � ( λ x → 3 * x + 3 ) 13 � 3 * 13 + 3 � 39 + 3 � 42 6

  14. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 f 13 � ( λ x → 3 * x + 3 ) 13 � 3 * 13 + 3 � 39 + 3 � 42 6

  15. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � ( λ x → 3 * x + 3 ) 13 � 3 * 13 + 3 � 39 + 3 � 42 6

  16. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � 42 � ( λ x → 3 * x + 3 ) 13 � 3 * 13 + 3 � 39 + 3 � 42 6

  17. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � 42 � ( λ x → 3 * x + 3 ) 13 WRONG � 3 * 13 + 3 � 39 + 3 � 42 6

  18. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � 42 � ( λ x → 3 * x + 3 ) 13 WRONG � 3 * 13 + 3 � 39 + 3 ( λ x → λ y → x + y ) y 21 � 42 6

  19. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � 42 � ( λ x → 3 * x + 3 ) 13 WRONG � 3 * 13 + 3 � 39 + 3 ( λ x → λ y → x + y ) y 21 � 42 � ( λ x → λ z → x + z ) y 21 6

  20. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � 42 � ( λ x → 3 * x + 3 ) 13 WRONG � 3 * 13 + 3 � 39 + 3 ( λ x → λ y → x + y ) y 21 � 42 � ( λ x → λ z → x + z ) y 21 � ( λ z → y + z ) 21 6

  21. λ -abstractions and variables scope Function definition: “ λ -abstraction” Definition In the construct λ x → e , the binder x scopes f : N → N f = λ x → 3 * x + 3 over the expression e and represent the function argument. ( λ x → λ y → x + y ) y 21 � ( λ y → y + y ) 21 � 21 + 21 f 13 � 42 � ( λ x → 3 * x + 3 ) 13 WRONG � 3 * 13 + 3 � 39 + 3 ( λ x → λ y → x + y ) y 21 � 42 � ( λ x → λ z → x + z ) y 21 � ( λ z → y + z ) 21 � y + 21 6

  22. Data types and nominal style Meta-programming is made easier by the introduction of data types to represent programming languages. λ x → 3 * x + 3 7

  23. Data types and nominal style Meta-programming is made easier by the introduction of data types to represent programming languages. λ x → 3 * x + 3 λ x add mul num num V 3 3 x 7

  24. Data types and nominal style Meta-programming is made easier by the introduction of data types to represent programming languages. λ x → 3 * x + 3 Name : Set x N y N . . . : Name λ data Tm : Set where num : N → Tm add : Tm → Tm → Tm x add mul : Tm → Tm → Tm : Name → Tm V mul num : Name → Tm → Tm ň · : Tm → Tm → Tm num V 3 ex 1 : Tm ex 1 = ň x N ( add ( mul ( num 3 ) ( V x N )) 3 x ( num 3 )) 7

  25. Closed terms and well-formed terms An open term (non-closed): A closed term: λ f → λ x → f x λ x → f x Definition A term is well-formed when all variables are either bound by a binder of the term either bound in the environment . Well-formed in the environment containing f : Ill-formed: ǫ ⊢ λ x → f x f ⊢ λ x → f x Definition A term is closed if and only if it is well-formed in the empty environment. 8

  26. Goal 1: To guarantee that we manipulate only well-scoped terms 9

  27. α -equivalence & α -purity -- λ x → x -- λ y → y id x : Tm id y : Tm id x = ň x N ( V x N ) id y = ň y N ( V y N ) 10

  28. α -equivalence & α -purity α -purity of functions: -- λ x → x -- λ y → y id x : Tm id y : Tm ∀ ( f : Tm → Bool ) → id x = ň x N ( V x N ) id y = ň y N ( V y N ) f id x ≡ f id y Definition A function is α -pure if and only if it returns α -equivalent results when given α -equivalent inputs. 10

  29. α -equivalence & α -purity α -purity of functions: -- λ x → x -- λ y → y id x : Tm id y : Tm ∀ ( f : Tm → Bool ) → id x = ň x N ( V x N ) id y = ň y N ( V y N ) f id x ≡ f id y Definition A function is α -pure if and only if it returns α -equivalent results when given α -equivalent inputs. What about this function? compare-bound-atoms : Tm → Bool ) = z == N x N compare-bound-atoms ( ň z compare-bound-atoms = false 10

  30. Goal 2: Computation should preserve α -equivalence 11

  31. NomPa: interface and examples 12

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