predicate calculus for algebraic theoriesmath.chapman.edu/~jipsen/seminarposters/christian... ·...

Post on 27-Jun-2020

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Predicate Calculus for Algebraic Theories

Christian Williamswilliams@math.ucr.edu

University of California, Riverside

ChapmanFeb. 21, 2020

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 1 / 21

Contents

0 Motivation RChain

1 Algebraic Theories

2 Presheaf Toposes

3 The Predicate Calculus

4 Theories with Binding

5 Application Namespace Logic

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 2 / 21

Motivation RChain

RChain is a public computing infrastructure based on a concurrentlanguage called the reflective higher-order π calculus, or ρ calculus.

π calculus

communication unifies internal and external.

ny | n(x).p⇒ p[y/x]

ρ calculus

reflection unifies data and code.

@ : P N : ∗

out(n, q) | in(n, x.p)⇒ p[@q/x]

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 3 / 21

Motivation RChain

In the ρ calculus, names have form, which provides large-scale structure toa network. We aim to use this structure, to think globally about the web.

Namespace Logic [1] is a framework for this reasoning. The theory is

ρ calculus + first-order logic + recursion = NL.

A formula ϕ of NL expresses a property of terms in the language. This isa type, used to condition the inputs and outputs of programs.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 4 / 21

Motivation RChain

Example

If ϕ is the “namespace” that a community trusts, they may use a“firewall” which asks any process: who else do you know?

soleAccessϕ := in(ϕ,>) ∧ ¬[in(¬ϕ,>)].

Security and liveness properties of systems are one of many applications ofnamespace logic. It can also function as a query language, which allowsone to search, not by keywords, but by the actual structure of code.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 5 / 21

Motivation RChain

How do we construct this logic generally, for any language?

Language : algebraic theory T

Logic : presheaf topos T.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 6 / 21

Algebraic Theories

A class of algebraic structure can be specified by a category in which

objects : products of base types t ∈ T

morphisms : composites of operations op ∈ O

diagrams : equations (op1, op2)∈ E.

This provides a presentation by generators and relations; the free cartesiancategory is the “theory” of this structure.

Definition

An algebraic theory is a category T equipped with presentation (T,O,E)which exhibits T as the free cartesian category on the presentation.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 7 / 21

Algebraic Theories

Th.Mon

m : M2 → M← 1 : e

M3 M2 M M2

assoc

M2 M M2 M

m×1

1×m m

1×e

e×1 m

unitr

m m

unitl

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 8 / 21

Presheaf Toposes

A presheaf on a category T is a functor Top → Set. There is a natural wayto embed T into its category of presheaves.

Definition

The Yoneda embedding of T is a functor

yT : T→ [Top,Set] =: T

which is defined

s 7→ T(−, s) =: s

o ↓ ↓ T(−, o) =: o

t 7→ T(−, t) =: t.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 9 / 21

Presheaf Toposes

Definition

A topos is a category F such that

F is cartesian closed,

F has finite co/limits, and

F has a subobject classifier Ω.

Any presheaf category T is a topos, with a rich internal logic. In particular,we can interpret and utilize subobjects as predicates.

Lemma

For any presheaf P : Top → Set, subfunctors of P form a Heyting algebra

T[P,Ω] =: Sub(P).

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 10 / 21

Presheaf Toposes

Let T be a category and t be an object. A sieve on t is a class ofmorphisms S ⊂ Mor(T) which is closed under precomposition.

Lemma

There is a natural bijection of sieves on t and subfunctors of T(−, t).

Puzzle: what is a sieve in an algebraic theory T?

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 11 / 21

The Predicate Calculus

The operations of T generate sieves:

S(m) . . . M2 M 1 . . . S(e).m e

These act as basic building blocks for predicates; they correspond tosubfunctors m, e T(−, M), to which we can apply the operations of theHeyting algebra. We can then build formulae such as:

[e] ∨ [m].

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 12 / 21

The Predicate Calculus

To complete the calculus, we need to lift the operations of the theory toalso act as constructors for predicates. We can then build up moresignificant formulae:

prime := ¬[e] ∧ ¬[m(¬[e],¬[e])].

This lifting is just like extending an operation to act on subsets: take theproduct, and then apply the operation pointwise:

Sub(T(−, M))2 Sub(T(−, M))

Sub(T(−, M)2) Sub(T(−, M2)).

×

m

∼〈−,−〉

Sub(T(−,m))

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 13 / 21

The Predicate Calculus

Theorem

Let T be an algebraic theory with presentation (T,O,E). Define the map

pred(T) : T→ HeyAlg∏i ti 7→

∏i Sub(ti )

[op :∏m

i ti → t] 7→ [op :∏m

i Sub(ti )→ Sub(t)],

where we define

op(ϕ1, . . . , ϕm)(s) = op(o1, . . . , om) | ∀i . oi ∈ ϕi (s).

Then pred(T) is a model of T, in the category of Heyting algebras.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 14 / 21

Theories with Binding

To apply this idea to programming languages, we need a richer notion oftheory which allows for operations to bind variables. This can be given bya systematic approach to contexts.

Λ

1 ≤ i ≤ n[ν]

n ` xi

n ` t0 n ` t1[@]

n ` app(t0, t1)

n + 1 ` t[λ]

n ` abs(xn+1.t)

This latter rule inputs a term with a distinguished free variable, andoutputs a term with that variable bound. This is an operation whose arityis not a finite set, but an exponent with more structure:

λ : X V ⇒ X

λn : X V(n) = X (n + 1)→ X (n).

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 15 / 21

Theories with Binding

Definition

A second-order algebraic theory 〈T; (T,O,E); X〉 is an algebraic theoryequipped with a set X of exponentiable objects. [2]

These theories generalize but remain faithful to universal algebra, withassociated equational logic and correspondence to monads and operads.

We can lift binding operations using a similar method given in the theorem,and we have a model pred(T) which preserves exponentiable objects.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 16 / 21

Theories with Binding

ρ calculus

0 : 1→ P in : N× [N⇒ P]→ P

@ : P→ N out : N× P→ P

∗ : N→ P par : P× P→ P

[P, par, 0] commutative monoid

[reify] ∗(@(p)) = p

[comm] par(out(a, q), in(a, p[x])) = p@q/x

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 17 / 21

Application Namespace Logic

Much of the complexity of distributed computing is in determining formany parallel processes a sequential evaluation.

In principle, many algorithms will want to analyze systems of “prime”processes, e.g. iteratively testing for race conditions.

prime ' single-threaded

single.thread := ¬[0] ∧ ¬[par(¬[0],¬[0])].

One could then build a predicate for “pairs of single-threaded processeswhich can communicate”.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 18 / 21

Application Namespace Logic

Let T := Th.ρ, and take pred(T) : T→ HeyAlg. This is really apolymorphic type system, with T as kinds, and im(pred(T)) as types.

Given n : 1→ N and Φ N, define

[n : Φ] := [n ∈ Φ(1)].

The compatibility of the operations of the theory and the lifted operationson predicates gives that the former are “polymorphic”:

Γ, x : Ψ ` n : Φ, p[x] : Ψ⇒ Θ[in]

Γ ` in(n, p[x]) : in(Φ, Ψ⇒ Θ).

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 19 / 21

Application Namespace Logic

In fact we get even more: because the model preserves exponentials, wecan now bind variables of types. The theory is now “parameterized”.

This provides a structural query system which lets us begin any programwith “receive from this namespace any code of the following form”.

Structural Query

Γ, q : P, Φ : N ` @q : Φ[COMMΦ]

Γ ` par(out(n, q), in(n, p[x : Φ]))⇒ p@q/x : P

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 20 / 21

References

L.G. Meredith and Matthias Radestock,Namespace Logic: A logic for a reflective higher-order calculus,Trustworthy Global Computing, Edinburgh 2005.

Marcelo Fiore and Ola Mahmoud,Second-Order Algebraic Theories,Mathematical Foundations of Computer Science, Heidelberg 2010.

Christian Williams williams@math.ucr.edu (University of California, Riverside)Predicate Calculus for Algebraic Theories Chapman Feb. 21, 2020 21 / 21

top related