An Introduction to Nominal Sets Andrew Pi tu s Computer Science & Technology EWSCS 2020 1/70
An introduction to nominal techniques motivated by Programming language semantics/verification Constructive type theory for theorem-provers (leaving out motivations from Automata theory, alas) 2/70
Names in programming languages ‘A pure [atomic] name is nothing but a bit-pa tu ern that is an identifier, and is only useful for comparing for identity with other such bit-pa tu erns — which includes looking up in tables to find other information. The intended contrast is with names which yield information by examination of the names themselves, whether by reading the text of the name or otherwise. ...like most good things in computer science, pure names help by pu tu ing in an extra stage of indirection; but they are not much good for anything else.’ RM Needham, Names (ACM, 1989) p 90 3/70
Local names ◮ Local variables in Algol-like languages: new 푋 in ⟨ command ⟩ ◮ Generativity + local declarations in ML-like languages: let 푥 = ref ⟨ val ⟩ in ⟨ exp ⟩ ◮ Channel- name restriction in 휋 -like process calculi: ( 휈푎 ) ⟨ process ⟩ ◮ Use of fresh names in meta-programming/reasoning, e.g. A-nf ( 푒 1 푒 2 ) � let 푣 1 = 푒 1 , 푣 2 = 푒 2 in 푣 1 푣 2 where 푣 1 푣 2 are fresh variables 4/70
Local names ◮ Local variables in Algol-like languages: new 푋 in ⟨ command ⟩ ◮ Generativity + local declarations in ML-like languages: let 푥 = ref ⟨ val ⟩ in ⟨ exp ⟩ ◮ Channel- name restriction in 휋 -like process calculi: ( 휈푎 ) ⟨ process ⟩ ◮ Use of fresh names in meta-programming/reasoning, e.g. A-nf ( 푒 1 푒 2 ) � let 푣 1 = 푒 1 , 푣 2 = 푒 2 in 푣 1 푣 2 where 푣 1 푣 2 are fresh variables What is the mathematical foundation for these locality constructs? Is it the same in each case? 4/70
Nominal sets provide a mathematical theory of atomic names based on some simple math to do with properties invariant under permuting names. 5/70
Impact can take a long time The mathematics behind nominal sets goes back a long way... Abraham Fraenkel, Der Begri fg “definit” und die Unabh¨ angigkeit des Auswahlsaxioms , Sitzungsberichte der Preussischen Akademie der Wissenscha fu en, Physikalisch-mathematische Klasse (1922), 253–257. Andrzej Mostowski, Uber die Unabh¨ angigkeit des Wohlordnungssatzes vom Ordnungsprinzip , Fundamenta Mathematicae 32 (1939), 201–252. 6/70
Outline L1 Structural recursion and induction in the presence of name-binding operations. L2 Introducing the category of nominal sets. L3 Nominal algebraic data types and 훼 -structural recursion. L4 Dependently typed 휆 -calculus with locally fresh names and name-abstraction. References: AMP, Nominal Sets: Names and Symmetry in Computer Science , CUP 2013 AMP, Alpha-Structural Recursion and Induction , JACM 53(2006)459-506. AMP, J. Ma tu hiesen and J. Derikx, A Dependent Type Theory with Abstractable Names , ENTCS 312(2015)19-50. 7/70
Lecture 1 8/70
Nominal sets provide a mathematical theory of atomic names based on some simple math to do with properties invariant under permuting names. Application area: computing with / proving properties of data involving name-binding & scoped local names in functional programming languages and theorem-proving systems. Theory of nominal sets yields principles of structural recursion and induction for syntax modulo renaming of bound names which is close to informal practice and yet fully formal. 9/70
For semantics, concrete syntax letrec f x = if x > 100 then x − 10 else f ( f ( x + 11 ) ) in f ( x + 100 ) is unimportant compared to abstract syntax (ASTs) letrec @ f x if − @ + f > @ x 100 x 10 f x 100 + f x 11 since we should aim for compositional semantics of program constructions, rather than of whole programs. 10/70
ASTs enable two fundamental (and inter-linked) tools in programming language semantics: ◮ Definition of functions on syntax by recursion on its structure. ◮ Proof of properties of syntax by induction on its structure. 11/70
Structural recursion Recursive definitions of functions whose values at a structure are given functions of their values at immediate substructures . ◮ G¨ odel System T (1958): structure = numbers structural recursion = primitive recursion for N . ◮ Burstall, Martin-L¨ of et al (1970s) generalized this to ASTs. 12/70
Running example Set of ASTs for 휆 -terms Tr � { 푡 :: = V 푎 | A ( 푡 , 푡 ) | L ( 푎 , 푡 )} where 푎 ∈ A , fixed infinite set of names of variables. Operations for constructing these ASTs: V : A � Tr A : Tr × Tr � Tr L : A × Tr � Tr 13/70
Structural recursion for Tr Theorem. Given 푓 1 ∈ A � 푋 푓 2 ∈ 푋 × 푋 � 푋 푓 3 ∈ A × 푋 � 푋 ˆ exists unique ∈ Tr � 푋 satisfying 푓 ˆ 푓 ( V 푎 ) = 푓 1 푎 푓 ( A ( 푡 , 푡 ′ )) = 푓 2 ( ˆ ˆ 푓 푡 , ˆ 푓 푡 ′ ) 푓 ( L ( 푎 , 푡 )) = 푓 3 ( 푎 , ˆ ˆ 푓 푡 ) 14/70
Structural recursion for Tr E.g. the finite set var 푡 of variables occurring in 푡 ∈ Tr : var ( V 푎 ) = { 푎 } var ( A ( 푡 , 푡 ′ )) = ( var 푡 ) ∪ ( var 푡 ′ ) var ( L ( 푎 , 푡 )) = ( var 푡 ) ∪ { 푎 } is defined by structural recursion using ◮ 푋 = P f ( A ) (finite sets of variables) ◮ 푓 1 푎 = { 푎 } ◮ 푓 2 ( 푆 , 푆 ′ ) = 푆 ∪ 푆 ′ ◮ 푓 3 ( 푎 , 푆 ) = 푆 ∪ { 푎 } . 15/70
Structural recursion for Tr E.g. swapping: ( 푎 푏 ) · 푡 = result of transposing all occurrences of 푎 and 푏 in 푡 For example ( 푎 푏 ) · L ( 푎 , A ( V 푏 , V 푐 )) = L ( 푏 , A ( V 푎 , V 푐 )) 16/70
Structural recursion for Tr E.g. swapping: ( 푎 푏 ) · 푡 = result of transposing all occurrences of 푎 and 푏 in 푡 ( 푎 푏 ) · V 푐 = if 푐 = 푎 then V 푏 else if 푐 = 푏 then V 푎 else V 푐 ( 푎 푏 ) · A ( 푡 , 푡 ′ ) = A (( 푎 푏 ) · 푡 , ( 푎 푏 ) · 푡 ′ ) ( 푎 푏 ) · L ( 푐 , 푡 ) = if 푐 = 푎 then L ( 푏 , ( 푎 푏 ) · 푡 ) else if 푐 = 푏 then L ( 푎 , ( 푎 푏 ) · 푡 ) else L ( 푐 , ( 푎 푏 ) · 푡 ) is defined by structural recursion using... 16/70
Structural recursion for Tr Theorem. Given 푓 1 ∈ A � 푋 푓 2 ∈ 푋 × 푋 � 푋 푓 3 ∈ A × 푋 � 푋 ˆ exists unique ∈ Tr � 푋 satisfying 푓 ˆ 푓 ( V 푎 ) = 푓 1 푎 푓 ( A ( 푡 , 푡 ′ )) = 푓 2 ( ˆ ˆ 푓 푡 , ˆ 푓 푡 ′ ) 푓 ( L ( 푎 , 푡 )) = 푓 3 ( 푎 , ˆ ˆ 푓 푡 ) 17/70
Structural recursion for Tr ! t Theorem. n u o c c Given 푓 1 ∈ A � 푋 a o t 푓 2 ∈ 푋 × 푋 � 푋 n i g 푓 3 ∈ A × 푋 � 푋 n i d n ˆ exists unique ∈ Tr � 푋 satisfying 푓 i b e k ˆ a 푓 ( V 푎 ) = 푓 1 푎 t t 푓 ( A ( 푡 , 푡 ′ )) = 푓 2 ( ˆ ˆ 푓 푡 , ˆ 푓 푡 ′ ) ’ n s e 푓 ( L ( 푎 , 푡 )) = 푓 3 ( 푎 , ˆ ˆ o 푓 푡 ) D 17/70
Alpha-equivalence Smallest binary relation = 훼 on Tr closed under the rules: 푡 1 = 훼 푡 ′ 푡 2 = 훼 푡 ′ 푎 ∈ A 1 2 A ( 푡 1 , 푡 2 ) = 훼 A ( 푡 ′ 1 , 푡 ′ V 푎 = 훼 V 푎 2 ) ( 푎 푏 ) · 푡 = 훼 ( 푎 ′ 푏 ) · 푡 ′ 푏 ∉ { 푎 , 푎 ′ } ∪ var ( 푡 ) ∪ var ( 푡 ′ ) L ( 푎 , 푡 ) = 훼 L ( 푎 ′ , 푡 ′ ) E.g. A ( L ( 푎 , A ( V 푎 , V 푏 )) , V 푐 ) A ( L ( 푐 , A ( V 푐 , V 푏 )) , V 푐 ) = 훼 A ( L ( 푏 , A ( V 푏 , V 푏 )) , V 푐 ) ̸ = 훼 Fact: = 훼 is transitive (and reflexive & symmetric). [Ex. 1] 18/70
ASTs mod alpha equivalence Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding operations) ◮ di fg icult to formalise/mechanise without losing sight of common informal practice: 19/70
ASTs mod alpha equivalence Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding operations) ◮ di fg icult to formalise/mechanise without losing sight of common informal practice: “We identify expressions up to alpha-equivalence”... 19/70
ASTs mod alpha equivalence Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding operations) ◮ di fg icult to formalise/mechanise without losing sight of common informal practice: “We identify expressions up to alpha-equivalence”... ...and then forget about it, referring to alpha-equivalence classes [ 푡 ] 훼 only via representatives 푡 . 19/70
ASTs mod alpha equivalence Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding operations) ◮ di fg icult to formalise/mechanise without losing sight of common informal practice: E.g. notation for 휆 -terms: Λ � {[ 푡 ] 훼 | 푡 ∈ Tr } means [ V 푎 ] 훼 ( = { V 푎 } ) 푎 푒 푒 ′ [ A ( 푡 , 푡 ′ )] 훼 , where 푒 = [ 푡 ] 훼 and 푒 ′ = [ 푡 ′ ] 훼 means means [ L ( 푎 , 푡 )] 훼 where 푒 = [ 푡 ] 훼 휆푎 . 푒 19/70
Informal structural recursion E.g. capture-avoiding substitution: 푓 = ( − )[ 푒 1 / 푎 1 ] : Λ � Λ 푓 푎 = if 푎 = 푎 1 then 푒 1 else 푎 푓 ( 푒 푒 ′ ) = ( 푓 푒 ) ( 푓 푒 ′ ) 푓 ( 휆푎 . 푒 ) = if 푎 ∉ var ( 푎 1 , 푒 1 ) then 휆푎 . ( 푓 푒 ) else don’t care! Not an instance of structural recursion for Tr . Why is 푓 well-defined and total? 20/70
Recommend
More recommend