An Introduction to Nominal Sets Andrew Pi tu s Computer Science - - PowerPoint PPT Presentation

an introduction to nominal sets
SMART_READER_LITE
LIVE PREVIEW

An Introduction to Nominal Sets Andrew Pi tu s Computer Science - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

An Introduction to Nominal Sets

Andrew Pitus

Computer Science & Technology

EWSCS 2020

1/70

slide-2
SLIDE 2

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

slide-3
SLIDE 3

Names in programming languages

‘A pure [atomic] name is nothing but a bit-patuern that is an identifier, and is only useful for comparing for identity with other such bit-patuerns — 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 putuing in an extra stage of indirection; but they are not much good for anything else.’ RM Needham, Names (ACM, 1989) p 90

3/70

slide-4
SLIDE 4

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

slide-5
SLIDE 5

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

slide-6
SLIDE 6

Nominal sets provide a mathematical theory of atomic names based on some simple math to do with properties invariant under permuting names.

5/70

slide-7
SLIDE 7

Impact can take a long time

The mathematics behind nominal sets goes back a long way...

Abraham Fraenkel, Der Begrifg “definit” und die Unabh¨ angigkeit des Auswahlsaxioms, Sitzungsberichte der Preussischen Akademie der Wissenschafuen, Physikalisch-mathematische Klasse (1922), 253–257. Andrzej Mostowski, Uber die Unabh¨ angigkeit des Wohlordnungssatzes vom Ordnungsprinzip, Fundamenta Mathematicae 32 (1939), 201–252.

6/70

slide-8
SLIDE 8

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. Matuhiesen and J. Derikx, A Dependent Type Theory with Abstractable Names, ENTCS 312(2015)19-50.

7/70

slide-9
SLIDE 9

Lecture 1

8/70

slide-10
SLIDE 10

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

slide-11
SLIDE 11

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 > x 100 − x 10 @ f @ f + x 11 @ f + x 100 since we should aim for compositional semantics of program constructions, rather than of whole programs.

10/70

slide-12
SLIDE 12

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

slide-13
SLIDE 13

Structural recursion

Recursive definitions of functions whose values at a structure are given functions of their values at immediate substructures. ◮ G¨

  • del System T (1958):

structure = numbers structural recursion = primitive recursion for N. ◮ Burstall, Martin-L¨

  • f et al (1970s) generalized this to

ASTs.

12/70

slide-14
SLIDE 14

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

slide-15
SLIDE 15

Structural recursion for Tr

Theorem. Given 푓1 ∈ A 푋 푓2 ∈ 푋 × 푋 푋 푓3 ∈ A × 푋 푋 exists unique ˆ 푓 ∈ Tr 푋 satisfying ˆ 푓 (V푎) = 푓1 푎 ˆ 푓 (A(푡,푡′)) = 푓2( ˆ 푓 푡, ˆ 푓 푡′) ˆ 푓 (L(푎,푡)) = 푓3(푎, ˆ 푓 푡)

14/70

slide-16
SLIDE 16

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 ◮ 푋 = Pf(A) (finite sets of variables) ◮ 푓1 푎 = {푎} ◮ 푓2(푆,푆′) = 푆 ∪ 푆′ ◮ 푓3(푎,푆) = 푆 ∪ {푎}.

15/70

slide-17
SLIDE 17

Structural recursion for Tr

E.g. swapping: (푎 푏) · 푡 = result of transposing all

  • ccurrences of 푎 and 푏 in 푡

For example (푎 푏) · L(푎, A(V푏, V푐)) = L(푏, A(V푎, V푐))

16/70

slide-18
SLIDE 18

Structural recursion for Tr

E.g. swapping: (푎 푏) · 푡 = result of transposing all

  • ccurrences 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

slide-19
SLIDE 19

Structural recursion for Tr

Theorem. Given 푓1 ∈ A 푋 푓2 ∈ 푋 × 푋 푋 푓3 ∈ A × 푋 푋 exists unique ˆ 푓 ∈ Tr 푋 satisfying ˆ 푓 (V푎) = 푓1 푎 ˆ 푓 (A(푡,푡′)) = 푓2( ˆ 푓 푡, ˆ 푓 푡′) ˆ 푓 (L(푎,푡)) = 푓3(푎, ˆ 푓 푡)

17/70

slide-20
SLIDE 20

Structural recursion for Tr

Theorem. Given 푓1 ∈ A 푋 푓2 ∈ 푋 × 푋 푋 푓3 ∈ A × 푋 푋 exists unique ˆ 푓 ∈ Tr 푋 satisfying ˆ 푓 (V푎) = 푓1 푎 ˆ 푓 (A(푡,푡′)) = 푓2( ˆ 푓 푡, ˆ 푓 푡′) ˆ 푓 (L(푎,푡)) = 푓3(푎, ˆ 푓 푡)

D

  • e

s n ’ t t a k e b i n d i n g i n t

  • a

c c

  • u

n t !

17/70

slide-21
SLIDE 21

Alpha-equivalence

Smallest binary relation =훼 on Tr closed under the rules: 푎 ∈ A V푎 =훼 V푎 푡1 =훼 푡′

1

푡2 =훼 푡′

2

A(푡1,푡2) =훼 A(푡′

1,푡′ 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

slide-22
SLIDE 22

ASTs mod alpha equivalence

Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding

  • perations)

◮ difgicult to formalise/mechanise without losing sight of common informal practice:

19/70

slide-23
SLIDE 23

ASTs mod alpha equivalence

Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding

  • perations)

◮ difgicult to formalise/mechanise without losing sight of common informal practice: “We identify expressions up to alpha-equivalence”...

19/70

slide-24
SLIDE 24

ASTs mod alpha equivalence

Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding

  • perations)

◮ difgicult 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

slide-25
SLIDE 25

ASTs mod alpha equivalence

Dealing with issues to do with binders and alpha equivalence is ◮ pervasive (very many languages involve binding

  • perations)

◮ difgicult to formalise/mechanise without losing sight of common informal practice: E.g. notation for 휆-terms: Λ {[푡]훼 | 푡 ∈ Tr}

푎 means [V푎]훼 ( = {V푎}) 푒 푒′ means [A(푡, 푡′)]훼, where 푒 = [푡]훼 and 푒′ = [푡′]훼 휆푎.푒 means [L(푎, 푡)]훼 where 푒 = [푡]훼

19/70

slide-26
SLIDE 26

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

slide-27
SLIDE 27

Informal structural recursion

E.g. denotation of 휆-term in a suitable domain 퐷: − : Λ ((A 퐷) 퐷)

푎휌 = 휌 푎 푒 푒′휌 = app(푒휌 , 푒′휌) 휆푎. 푒휌 = fun(휆(푑 ∈ 퐷) 푒(휌[푎 푑])) where

  • app

∈ 퐷 × 퐷 cts 퐷 fun ∈ (퐷 cts 퐷) cts 퐷 are continuous functions satisfying...

20/70

slide-28
SLIDE 28

Informal structural recursion

E.g. denotation of 휆-term in a suitable domain 퐷: − : Λ ((A 퐷) 퐷)

푎휌 = 휌 푎 푒 푒′휌 = app(푒휌 , 푒′휌) 휆푎. 푒휌 = fun(휆(푑 ∈ 퐷) 푒(휌[푎 푑])) why is this very standard definition independent of the choice of bound variable 푎? 휌[푎 푑] is the element of A 퐷 that maps 푎 to 푑 and otherwise acts like 휌

20/70

slide-29
SLIDE 29

Is there a recursion principle for Λ that legitimises these ‘definitions’ of (−)[푒1/푎1] : Λ Λ and − : Λ 퐷 (and many other e.g.s)?

21/70

slide-30
SLIDE 30

Is there a recursion principle for Λ that legitimises these ‘definitions’ of (−)[푒1/푎1] : Λ Λ and − : Λ 퐷 (and many other e.g.s)? Yes! — 훼-structural recursion.

21/70

slide-31
SLIDE 31

Is there a recursion principle for Λ that legitimises these ‘definitions’ of (−)[푒1/푎1] : Λ Λ and − : Λ 퐷 (and many other e.g.s)? Yes! — 훼-structural recursion. What about other languages with binders?

21/70

slide-32
SLIDE 32

Is there a recursion principle for Λ that legitimises these ‘definitions’ of (−)[푒1/푎1] : Λ Λ and − : Λ 퐷 (and many other e.g.s)? Yes! — 훼-structural recursion. What about other languages with binders? Yes! — available for any nominal signature.

21/70

slide-33
SLIDE 33

Is there a recursion principle for Λ that legitimises these ‘definitions’ of (−)[푒1/푎1] : Λ Λ and − : Λ 퐷 (and many other e.g.s)? Yes! — 훼-structural recursion. What about other languages with binders? Yes! — available for any nominal signature.

  • Great. What’s the catch?

21/70

slide-34
SLIDE 34

Is there a recursion principle for Λ that legitimises these ‘definitions’ of (−)[푒1/푎1] : Λ Λ and − : Λ 퐷 (and many other e.g.s)? Yes! — 훼-structural recursion. What about other languages with binders? Yes! — available for any nominal signature.

  • Great. What’s the catch?

Need to learn a bit of possibly unfamiliar math, to do with permutations and support.

21/70