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

an introduction to nominal sets
SMART_READER_LITE
LIVE PREVIEW

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

An Introduction to Nominal Sets Andrew Pi t s Computer Science & Technology EWSCS 2020 1/70 Lecture 3 36/70 Outline L1 Structural recursion and induction in the presence of name-binding operations. L2 Introducing the category of nominal


slide-1
SLIDE 1

An Introduction to Nominal Sets

Andrew Pits

Computer Science & Technology

EWSCS 2020

1/70

slide-2
SLIDE 2

Lecture 3

36/70

slide-3
SLIDE 3

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

37/70

slide-4
SLIDE 4

Recall: 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]

38/70

slide-5
SLIDE 5

Freshness

For each nominal set 푋, we can define a relation # ⊆ A × 푋 of freshness: 푎 # 푥 푎 ∉ supp푥

39/70

more constructively, a is fresh for x if there is some finite support set A for x not containing a

slide-6
SLIDE 6

Freshness

For each nominal set 푋, we can define a relation # ⊆ A × 푋 of freshness: 푎 # 푥 푎 ∉ supp푥

◮ In N, 푎 # 푛 always. ◮ In A, 푎 # 푏 iff 푎 ≠ 푏. ◮ In Λ, 푎 # 푡 iff 푎 ∉ fv푡. ◮ In 푋 × 푌, 푎 # (푥,푦) iff 푎 # 푥 and 푎 # 푦. ◮ In 푋 fs 푌, 푎 # 푓 can be subtle! (and hence dito for Pfs푋)

39/70

slide-7
SLIDE 7

Freshness Qantifier

If 휑(푎) is a property of atoms 푎 ∈ A, we write N 푎, 휑(푎) to mean: {푎 ∈ A | ¬휑(푎)} is finite, i.e. 휑(푎) holds for all but finitely many 푎.

40/70

slide-8
SLIDE 8

Freshness Qantifier

If 휑(푎) is a property of atoms 푎 ∈ A, we write N 푎, 휑(푎) to mean: {푎 ∈ A | ¬휑(푎)} is finite, i.e. 휑(푎) holds for all but finitely many 푎.

  • Theorem. Writing 푆 = {푎 ∈ A | 휑(푎)}, then t.f.a.e.

(1) N 푎, 휑(푎) (2) 푆 ∈ PfsA and ∃푎 ∈ A, 푎 # 푆 ∧ 휑(푎) (3) 푆 ∈ PfsA and ∀푏 ∈ A, 푏 # 푆 ⇒ 휑(푏) So can read N 푎, 휑(푎) as “for some/any fresh 푎, 휑(푎) holds”

Proof.

40/70

slide-9
SLIDE 9

Freshness Qantifier

If 휑(푎) is a property of atoms 푎 ∈ A, we write N 푎, 휑(푎) to mean: {푎 ∈ A | ¬휑(푎)} is finite, i.e. 휑(푎) holds for all but finitely many 푎.

  • Theorem. Writing 푆 = {푎 ∈ A | 휑(푎)}, then t.f.a.e.

(1) N 푎, 휑(푎) (2) 푆 ∈ PfsA and ∃푎 ∈ A, 푎 # 푆 ∧ 휑(푎) (3) 푆 ∈ PfsA and ∀푏 ∈ A, 푏 # 푆 ⇒ 휑(푏) So can read N 푎, 휑(푎) as “for some/any fresh 푎, 휑(푎) holds”

  • Proof. If (1), then 퐴 A − 푆 is finite and necessarily supports 푆 w.r.t. action of A
  • n subsets of atoms. Since A is infinite and 퐴 finite, there is some 푎 ∈ 푆 = A − 퐴;

and 푎 # 푆 because 푎 ∉ 퐴. So (2) holds.

40/70

slide-10
SLIDE 10

Freshness Qantifier

If 휑(푎) is a property of atoms 푎 ∈ A, we write N 푎, 휑(푎) to mean: {푎 ∈ A | ¬휑(푎)} is finite, i.e. 휑(푎) holds for all but finitely many 푎.

  • Theorem. Writing 푆 = {푎 ∈ A | 휑(푎)}, then t.f.a.e.

(1) N 푎, 휑(푎) (2) 푆 ∈ PfsA and ∃푎 ∈ A, 푎 # 푆 ∧ 휑(푎) (3) 푆 ∈ PfsA and ∀푏 ∈ A, 푏 # 푆 ⇒ 휑(푏) So can read N 푎, 휑(푎) as “for some/any fresh 푎, 휑(푎) holds”

  • Proof. If (2), say 푎 ∈ 푆 and 푎 # 푆, then for any 푏 with 푏 # 푆, we have (푎 푏) · 푆 = 푆,

so 푏 = (푎 푏) · 푎 ∈ (푎 푏) · 푆 = 푆. So (3) holds.

40/70

slide-11
SLIDE 11

Freshness Qantifier

If 휑(푎) is a property of atoms 푎 ∈ A, we write N 푎, 휑(푎) to mean: {푎 ∈ A | ¬휑(푎)} is finite, i.e. 휑(푎) holds for all but finitely many 푎.

  • Theorem. Writing 푆 = {푎 ∈ A | 휑(푎)}, then t.f.a.e.

(1) N 푎, 휑(푎) (2) 푆 ∈ PfsA and ∃푎 ∈ A, 푎 # 푆 ∧ 휑(푎) (3) 푆 ∈ PfsA and ∀푏 ∈ A, 푏 # 푆 ⇒ 휑(푏) So can read N 푎, 휑(푎) as “for some/any fresh 푎, 휑(푎) holds”

  • Proof. If (3), then there is some finite 퐴 ⊆ A supporting 푆 w.r.t. action of A on

subsets of atoms. Since 퐴 is finite, to prove (1) it suffices to show A − 푆 ⊆ 퐴, i.e. A − 퐴 ⊆ 푆. But if 푏 ∉ 퐴, then because 퐴 supports 푆, we have 푏 # 푆 and so by (3) we do have 푏 ∈ 푆.

  • 40/70
slide-12
SLIDE 12

Name abstraction

Each 푋 ∈ Nom yields a nominal set [A]푋 of name-abstractions 푎푥 are ∼-equivalence classes of pairs (푎,푥) ∈ A × 푋, where (푎,푥) ∼ (푎′,푥′) ⇔ N 푏, (푏 푎) · 푥 = (푏 푎′) · 푥′

The Perm A-action on [A]푋 is well-defined by 휋 · 푎푥 = 휋(푎)(휋 · 푥) Fact: supp(푎푥) = supp푥 − {푎}, so that 푏 # 푎푥 ⇔ 푏 = 푎 ∨ 푏 # 푥

41/70

slide-13
SLIDE 13

Name abstraction

Each 푋 ∈ Nom yields a nominal set [A]푋 of name-abstractions 푎푥 are ∼-equivalence classes of pairs (푎,푥) ∈ A × 푋, where (푎,푥) ∼ (푎′,푥′) ⇔ N 푏, (푏 푎) · 푥 = (푏 푎′) · 푥′

We get a functor [A](−) : Nom Nom sending 푓 ∈ Nom(푋,푌) to [A]푓 ∈ Nom([A]푋, [A]푌) where [A]푓 (푎푥) = 푎(푓 푥)

41/70

slide-14
SLIDE 14

Name abstraction

[A](−) : Nom Nom is a kind of (affine) function space—it is right adjoint to the functor A ⊗ (−) : Nom Nom sending 푋 to A ⊗ 푋 = {(푎, 푥) | 푎 # 푥}. Co-unit of the adjunction is ‘concretion’ of an abstraction

@

: ([A]푋) ⊗ A → 푋 defined by computation rule:

∀푎,푥, N 푏, (푎푥) @ 푏 = (푏 푎) · 푥 [Ex. 6]

42/70

slide-15
SLIDE 15

Name abstraction

Generalising concretion, we have the following characterization of morphisms out of [A]푋

  • Theorem. 푓 ∈ (A × 푋) fs 푌 factors through the

subquotient A × 푋 ⊇ {(푎,푥) | 푎 # 푓 } [A]푋 to give a unique element of 푓 ∈ ([A]푋) fs 푌 satisfying N 푎, ∀푥, 푓 (푎푥) = 푓 (푎,푥) iff 푓 satisfies: N 푎, ∀푥, 푎 # 푓 (푎,푥).

42/70

slide-16
SLIDE 16

Initial algebras

◮ [A](−) has excellent exactness properties. It can be combined with ×, + and 푋 fs (−) to give functors T : Nom Nom that have initial algebras 퐼 : T 퐷 퐷 T 퐷

T푋

퐹 for all

퐷 푋

43/70

slide-17
SLIDE 17

Initial algebras

◮ [A](−) has excellent exactness properties. It can be combined with ×, + and 푋 fs (−) to give functors T : Nom Nom that have initial algebras 퐼 : T 퐷 퐷 T 퐷

T ˆ 퐹 퐼

T푋

ˆ 퐹 exists unique 푋

43/70

slide-18
SLIDE 18

Initial algebras

◮ [A](−) has excellent exactness properties. It can be combined with ×, + and 푋 fs (−) to give functors T : Nom Nom that have initial algebras 퐼 : T 퐷 퐷 ◮ For a wide class of such functors (nominal algebraic functors) the initial algebra 퐷 coincides with ASTs/훼-equivalence. E.g. Λ is the initial algebra for T(−) A + (− × −) + [A](−)

43/70

slide-19
SLIDE 19

Nominal algebraic signatures

◮ Sorts S ::= N name-sort (here just one, for simplicity) | D data-sorts | 1 unit | S , S pairs | N . S name-binding ◮ Typed operations op : S D Signature Σ is specified by the stuff in red.

44/70

slide-20
SLIDE 20

Nominal algebraic signatures

Example: 휆-calculus name-sort Var for variables, data-sort Term for terms, and operations V : Var → Term A : Term , Term → Term L : Var . Term → Term

44/70

slide-21
SLIDE 21

Nominal algebraic signatures

Example: 휋-calculus

name-sort Chan for channel names, data-sorts Proc, Pre and Sum for processes, prefixed processes and summations, and operations

S : Sum → Proc Comp : Proc , Proc → Proc Nu : Chan . Proc → Proc ! : Proc → Proc P : Pre → Sum O : 1 → Sum Plus : Sum , Sum → Sum Out : Chan , Chan , Proc → Pre In : Chan , (Chan . Proc) → Pre Tau : Proc → Pre Match : Chan , Chan , Pre → Pre

44/70

slide-22
SLIDE 22

Nominal algebraic signatures

Closely related notions: ◮ binding signatures of Fiore, Plotkin & Turi (LICS 1999) ◮ nominal algebras of Honsell, Miculan & Scagneto (ICALP 2001)

N.B. all these notions of signature restrict atention to iterated, but unary name-binding—there are other kinds of lexically scoped binder (e.g. see Potier’s C훼ml language, or Blanchete et al POPL 2019.)

44/70

slide-23
SLIDE 23

Σ(S) = raw terms over Σ of sort S

푎 ∈ A 푎 ∈ Σ(N) 푡 ∈ Σ(S)

  • p : S → D
  • p푡 ∈ Σ(D)

() ∈ Σ(1) 푡1 ∈ Σ(S1) 푡2 ∈ Σ(S2) 푡1 , 푡2 ∈ Σ(S1 , S2) 푎 ∈ A 푡 ∈ Σ(S) 푎 . 푡 ∈ Σ(N . S) Each Σ(S) is a nominal set once equipped with the

  • bvious Perm A-action—any finite set of atoms

containing all those occurring in 푡 supports 푡 ∈ Σ(S).

45/70

slide-24
SLIDE 24

Alpha-equivalence =훼 ⊆ Σ(S) × Σ(S)

푎 ∈ A 푎 =훼 푎 푡 =훼 푡′

  • p푡 =훼 op푡′

() =훼 () 푡1 =훼 푡′

1

푡2 =훼 푡′

2

푡1 , 푡2 =훼 푡′

1 , 푡′ 2

(푎1 푎) · 푡1 =훼 (푎2 푎) · 푡2 푎 # (푎1,푡1,푎2,푡2) 푎1 . 푡1 =훼 푎2 . 푡2

46/70

slide-25
SLIDE 25

Alpha-equivalence =훼 ⊆ Σ(S) × Σ(S)

Fact: =훼 is equivariant (푡1 =훼 푡2 ⇒ 휋 · 푡1 =훼 휋 · 푡2) and each quotient Σ훼(S) {[푡]훼 | 푡 ∈ Σ(S)} is a nominal set with 휋 · [푡]훼 = [휋 · 푡]훼 supp [푡]훼 = fn푡 where fn(푎 . 푡) = fn푡 − {푎} fn(푡1 , 푡2) = fn푡1 ∪ fn푡2 etc.

46/70

slide-26
SLIDE 26
  • Theorem. Given a nominal algebraic signature Σ

(for simplicity, assume Σ has a single data-sort D as well as a single name-sort N)

Σ훼(D) is an initial algebra for the associated functor TΣ : Nom → Nom.

47/70

slide-27
SLIDE 27
  • Theorem. Given a nominal algebraic signature Σ

(for simplicity, assume Σ has a single data-sort D as well as a single name-sort N)

Σ훼(D) is an initial algebra for the associated functor TΣ : Nom → Nom. TΣ(−) = S1(−) + · · · + S푛(−) where Σ has operations op푖 : S푖 → 퐷 (푖 = 1..푛) and S(−) : Nom → Nom is defined by: N(−) = A D(−) = (−) 1(−) = 1 S1 , S2(−) = S1(−) × S2(−) N . S(−) = [A](S(−))

47/70

slide-28
SLIDE 28
  • Theorem. Given a nominal algebraic signature Σ

(for simplicity, assume Σ has a single data-sort D as well as a single name-sort N)

Σ훼(D) is an initial algebra for the associated functor TΣ : Nom → Nom. E.g. for the 휆-calculus signature with operations V : Var → Term A : Term , Term → Term L : Var . Term → Term we have TΣ(−) = A + (− × −) + [A](−)

47/70

slide-29
SLIDE 29

훼-Structural recursion

For 휆-terms:

Theorem. Given any 푋 ∈ Nom and        푓1 ∈ A fs 푋 푓2 ∈ 푋 × 푋 fs 푋 푓3 ∈ [A]푋 fs 푋 ∃! ˆ 푓 ∈ Λ fs 푋 s.t.        ˆ 푓 푎 = 푓1 푎 ˆ 푓 (푒1 푒2) = 푓2( ˆ 푓 푒1, ˆ 푓 푒2) ˆ 푓 (휆푎.푒) = 푓3(푎( ˆ 푓 푒)) if 푎 # (푓1, 푓2, 푓3) The enriched functor [A](−) : Nom Nom sends 푓 ∈ 푋 fs 푌 to [A]푓 ∈ [A]푋 fs [A]푌 where [A]푓 (푎푥) = 푎(푓 푥) if 푎 # 푓

48/70

slide-30
SLIDE 30

Recall: Name abstraction

  • Theorem. 푓 ∈ (A × 푋) fs 푌 factors through the

subquotient A × 푋 ⊇ {(푎,푥) | 푎 # 푓 } [A]푋 to give a unique element of 푓 ∈ ([A]푋) fs 푌 satisfying N 푎, ∀푥, 푓 (푎푥) = 푓 (푎,푥) iff 푓 satisfies: N 푎, ∀푥, 푎 # 푓 (푎,푥).

49/70

slide-31
SLIDE 31

훼-Structural recursion

For 휆-terms:

Theorem. Given any 푋 ∈ Nom and        푓1 ∈ A fs 푋 푓2 ∈ 푋 × 푋 fs 푋 푓3 ∈ A × 푋 fs 푋 s.t. N 푎, ∀푥, 푎 # 푓3(푎, 푥) (FCB) ∃! ˆ 푓 ∈ Λ fs 푋 s.t.        ˆ 푓 푎 = 푓1 푎 ˆ 푓 (푒1 푒2) = 푓2( ˆ 푓 푒1, ˆ 푓 푒2) ˆ 푓 (휆푎.푒) = 푓3(푎, ˆ 푓 푒) if 푎 # (푓1, 푓2, 푓3)

50/70

slide-32
SLIDE 32

훼-Structural recursion

For 휆-terms:

Theorem. Given any 푋 ∈ Nom and        푓1 ∈ A fs 푋 푓2 ∈ 푋 × 푋 fs 푋 푓3 ∈ A × 푋 fs 푋 s.t. N 푎, ∀푥, 푎 # 푓3(푎, 푥) (FCB) ∃! ˆ 푓 ∈ Λ fs 푋 s.t.        ˆ 푓 푎 = 푓1 푎 ˆ 푓 (푒1 푒2) = 푓2( ˆ 푓 푒1, ˆ 푓 푒2) ˆ 푓 (휆푎.푒) = 푓3(푎, ˆ 푓 푒) if 푎 # (푓1, 푓2, 푓3) E.g. capture-avoiding substitution (−)[푒′/푎′] : Λ Λ is the ˆ 푓 for

푓1 푎

  • if 푎 = 푎′ then 푒′ else 푎

푓2(푒1,푒2)

  • 푒1 푒2

푓3(푎,푒)

  • 휆푎.푒

for which (FCB) holds, since 푎 # 휆푎.푒

50/70

slide-33
SLIDE 33

훼-Structural recursion

For 휆-terms:

Theorem. Given any 푋 ∈ Nom and        푓1 ∈ A fs 푋 푓2 ∈ 푋 × 푋 fs 푋 푓3 ∈ A × 푋 fs 푋 s.t. N 푎, ∀푥, 푎 # 푓3(푎, 푥) (FCB) ∃! ˆ 푓 ∈ Λ fs 푋 s.t.        ˆ 푓 푎 = 푓1 푎 ˆ 푓 (푒1 푒2) = 푓2( ˆ 푓 푒1, ˆ 푓 푒2) ˆ 푓 (휆푎.푒) = 푓3(푎, ˆ 푓 푒) if 푎 # (푓1, 푓2, 푓3) Non-example: trying to list the bound variables of a 휆-term

푓1 푎

  • nil

푓2(ℓ1, ℓ2)

  • ℓ1 @ ℓ2

푓3(푎, ℓ)

  • 푎 :: ℓ

for which (FCB) does not hold, since 푎 ∈ supp(푎 :: ℓ).

50/70

slide-34
SLIDE 34

훼-Structural recursion

For 휆-terms:

Theorem. Given any 푋 ∈ Nom and        푓1 ∈ A fs 푋 푓2 ∈ 푋 × 푋 fs 푋 푓3 ∈ A × 푋 fs 푋 s.t. N 푎, ∀푥, 푎 # 푓3(푎, 푥) (FCB) ∃! ˆ 푓 ∈ Λ fs 푋 s.t.        ˆ 푓 푎 = 푓1 푎 ˆ 푓 (푒1 푒2) = 푓2( ˆ 푓 푒1, ˆ 푓 푒2) ˆ 푓 (휆푎.푒) = 푓3(푎, ˆ 푓 푒) if 푎 # (푓1, 푓2, 푓3) Similar results hold for any nominal algebraic signature—see J ACM 53(2006)459–506. Implemented in Urban & Berghofer’s Nominal package for Isabelle/HOL (classical higher-order logic). Seems to capture informal usage well, but (FCB) can be tricky...

50/70

slide-35
SLIDE 35

Counting occurrences

  • f bound variables

For each 푒 ∈ Λ, cbv푒 푓 푒 휌0 ∈ N where we want 푓 ∈ Λ fs 푋 with 푋 = (A fs N) fs N to satisfy 푓 푎 휌 = 휌 푎 푓 (푒1 푒2) 휌 = (푓 푒1휌) + (푓 푒2 휌) 푓 (휆푎.푒) 휌 = 푓 푒 (휌[푎 ↦→ 1]) and where 휌0 ∈ A fs N is 휆(푎 ∈ A) 0.

E.g. when 푒 = (휆푎. 휆푏.푎) 푏 (with 푎 ≠ 푏), then 푒 has a single occurrence of a bound variable (called 푎) and cbv푒 = 1.

51/70

slide-36
SLIDE 36

Counting occurrences

  • f bound variables

For each 푒 ∈ Λ, cbv푒 푓 푒 휌0 ∈ N where we want 푓 ∈ Λ fs 푋 with 푋 = (A fs N) fs N to satisfy 푓 푎 휌 = 휌 푎 푓 (푒1 푒2) 휌 = (푓 푒1휌) + (푓 푒2 휌) 푓 (휆푎.푒) 휌 = 푓 푒 (휌[푎 ↦→ 1]) and where 휌0 ∈ A fs N is 휆(푎 ∈ A) 0.

Looks like we should take 푓3(푎, 푥) = 휆(휌 ∈ A fs N) 푥(휌[푎 ↦→ 1]), but this does not satisfy (FCB). Solution: take 푋 to be a certain nominal subset of (A fs N) fs N. [See Nominal Sets book, Example 8.20]

51/70