SLIDE 1
Transductions in affjne logic
Nguyễn Lê Thành Dũng (a.k.a. Tito) — nltd@nguyentito.eu LIPN, Université Paris 13 Trends in Linear Logic and Applications, Dortmund, June 30th, 2019
1/18
SLIDE 2 Transductions in typed λ-calculi
- 1. Motivation: the simply-typed λ-calculus
functions on Church encodings and automata theory
λ-defjnable string functions are related to transducers, i.e. automata with output (many possible variants).
- 2. Capturing a class of transductions with affjne typing,
via linearity in streaming string transducers Details on (2) in my 5-page abstract. I’ve come to think that (1) is more important. But (2) came fjrst, triggered by a question by M. Bojańczyk. Counterexample to “provinciality” of linear logic.
2/18
SLIDE 3 Transductions in typed λ-calculi
- 1. Motivation: the simply-typed λ-calculus
functions on Church encodings and automata theory
λ-defjnable string functions are related to transducers, i.e. automata with output (many possible variants).
- 2. Capturing a class of transductions with affjne typing,
via linearity in streaming string transducers Details on (2) in my 5-page abstract. I’ve come to think that (1) is more important. But (2) came fjrst, triggered by a question by M. Bojańczyk. − → Counterexample to “provinciality” of linear logic.
2/18
SLIDE 4 Simply typed functions on Church numerals (1)
Church encodings of (unary) natural numbers:
- Nat = o → (o → o) → o
- n ∈ N ⇝ n = λx. λf. f (. . . (f x) . . .) : Nat with n times f
For t : Nat → Nat, F(t)(n) = m ⇐ ⇒ t n =β m. Theorem (Schwichtenberg 1975) The functions defjnable by simply-typed λ-terms of type Nat → Nat are the extended polynomials (generated by 0,1,+,×,ifzero). Let’s add a bit of (meta-level) polymorphism: t Nat A Nat where Nat A Nat A o A A A A Open question t A simple type t Nat A Nat
3/18
SLIDE 5 Simply typed functions on Church numerals (1)
Church encodings of (unary) natural numbers:
- Nat = o → (o → o) → o
- n ∈ N ⇝ n = λx. λf. f (. . . (f x) . . .) : Nat with n times f
For t : Nat → Nat, F(t)(n) = m ⇐ ⇒ t n =β m. Theorem (Schwichtenberg 1975) The functions defjnable by simply-typed λ-terms of type Nat → Nat are the extended polynomials (generated by 0,1,+,×,ifzero). Let’s add a bit of (meta-level) polymorphism: t = Nat[A] → Nat where Nat[A] = Nat[A/o] = A → (A → A) → A Open question {F(t) | A simple type, t : Nat[A] → Nat} = ?
3/18
SLIDE 6 Simply typed functions on Church numerals (2)
Take mult = λn.λm.λf. n (m f) : Nat → Nat → Nat. mult 2 : Nat → Nat can be iterated by a Nat[Nat]… − → exp2 = λn. n (mult 2) 1 : Nat[Nat] → Nat which cannot be iterated! Smaller types, still heterogenous: exp2 n n 2 Nat o
Towers of exponentials of any fjxed height Nat T A Nat A . This is the fastest possible growth for simply typed
4/18
SLIDE 7 Simply typed functions on Church numerals (2)
Take mult = λn.λm.λf. n (m f) : Nat → Nat → Nat. mult 2 : Nat → Nat can be iterated by a Nat[Nat]… − → exp2 = λn. n (mult 2) 1 : Nat[Nat] → Nat which cannot be iterated! Smaller types, still heterogenous: exp2 = λn. n 2 : Nat[o → o] → Nat Towers of exponentials of any fjxed height Nat T A Nat A . This is the fastest possible growth for simply typed
4/18
SLIDE 8
Simply typed functions on Church numerals (2)
Take mult = λn.λm.λf. n (m f) : Nat → Nat → Nat. mult 2 : Nat → Nat can be iterated by a Nat[Nat]… − → exp2 = λn. n (mult 2) 1 : Nat[Nat] → Nat which cannot be iterated! Smaller types, still heterogenous: exp2 = λn. n 2 : Nat[o → o] → Nat Towers of exponentials of any fjxed height Nat[T[A]] → Nat[A]. This is the fastest possible growth for simply typed λ-terms.
4/18
SLIDE 9 Simply typed functions on Church numerals (3)
Towers of exponentials of any fjxed height Nat[T[A]] → Nat[A]. On the other hand: Theorem (Statman 198?) Subtraction cannot be defjned as a simply typed λ-term of type Nat[A] → Nat[B] → Nat. More weirdness: some “easy” 1-variable functions, e.g. n → ⌊√n⌋, are also undefjnable. Does this really correspond to any interesting class, or is
- ur open problem a “typical misguided natural question”?
(cf. Gromov, Spaces and questions)
Might explain lack of progress on this question…
5/18
SLIDE 10 Simply typed functions on Church numerals (3)
Towers of exponentials of any fjxed height Nat[T[A]] → Nat[A]. On the other hand: Theorem (Statman 198?) Subtraction cannot be defjned as a simply typed λ-term of type Nat[A] → Nat[B] → Nat. More weirdness: some “easy” 1-variable functions, e.g. n → ⌊√n⌋, are also undefjnable. − → Does this really correspond to any interesting class, or is
- ur open problem a “typical misguided natural question”?
(cf. Gromov, Spaces and questions)
Might explain lack of progress on this question…
5/18
SLIDE 11
A fjrst interesting result: predicates on Church integers
My POV: the question is actually interesting. Illustration on restricted case: predicates (Bool = o → o → o). Theorem (Joly 2001) A subset of N is decidable by some t : Nat[A] → Bool if and only if it is ultimately periodic. Corollary For all simple types A and all t Nat A Nat, X ultimately periodic t
1 X ultimately periodic.
A not quite trivial necessary condition!
6/18
SLIDE 12
A fjrst interesting result: predicates on Church integers
My POV: the question is actually interesting. Illustration on restricted case: predicates (Bool = o → o → o). Theorem (Joly 2001) A subset of N is decidable by some t : Nat[A] → Bool if and only if it is ultimately periodic. Corollary For all simple types A and all t : Nat[A] → Nat, X ⊆ N ultimately periodic = ⇒ F(t)−1(X) ultimately periodic. A not quite trivial necessary condition!
6/18
SLIDE 13 Simply typed functions on Church-encoded strings
To gain more insight, let’s generalize! Nat = Str{1} Church encodings of strings over alphabet Σ = {a1, . . . , a|Σ|}:
- StrΣ = o → (o → o) → . . . |Σ| times . . . → (o → o) → o
- w ∈ Σ∗ ⇝ w = λx. λf1. . . . λf|Σ|. fi1 (. . . (fin x) . . .) : StrΣ
where w = ai1 . . . ain Characterizations of {F(t) | t : StrΓ → StrΣ} (no subst.) exist1. Open question {F(t) | A simple type, t : StrΓ[A] → StrΣ} = ?
1e.g. Zaionc 1987, Word operation defjnable in the typed λ-calculus
7/18
SLIDE 14
Simply typed predicates on Church-encoded strings
Theorem (Hillebrand & Kanellakis 1995) A subset of Σ∗ is decidable by some t : StrΣ[A] → Bool ifg it is a regular language. (Note: X ⊆ {1}∗ regular ⇐ ⇒ X ⊆ N ultimately periodic) Corollary L ⊆ Σ∗ regular = ⇒ F(t)−1(L) regular for t : StrΓ[A] → StrΣ. − → look for an automata-theoretic function class with regularity preservation + hyperexponential growth
8/18
SLIDE 15 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X → Xa Y → aY b → X → Xb Y → bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over : start with X Y
9/18
SLIDE 16 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over : start with X Y
9/18
SLIDE 17 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: start with X = ε Y = ε
9/18
SLIDE 18 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: X = a Y = a
9/18
SLIDE 19 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: X = ab Y = ba
9/18
SLIDE 20 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: X = aba Y = aba
9/18
SLIDE 21 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: X = abaa Y = aaba
9/18
SLIDE 22 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: f(abaa) = abaaaaba X = abaa Y = aaba
9/18
SLIDE 23 Register transducers
For input alphabet Γ, output alphabet Σ:
- Finite set of Σ∗-valued registers e.g. R = {X, Y}
- Initial values R → Σ∗ e.g. Xinit = Yinit = ε
- Register update function u : Γ → (R → (Σ ∪ R)∗) e.g.
a → X := Xa Y := aY b → X := Xb Y := bY
- “output function” ∈ (Σ ∪ R)∗ e.g. out = XY
Execution over abaa: f(abaa) = abaaaaba, f : w → w · reverse(w) X = abaa Y = aaba
9/18
SLIDE 24 Register transducers with states
- Finite set of Σ∗-valued registers R, initial values R → Σ∗
- fjnite state machine (i.e. DFA) (Q, qinit ∈ Q, δ : Γ × Q → Q)
- updates Γ × Q → (Σ ∪ R)∗, “output function” Q → (Σ ∪ R)∗
Theorem (Filiot & Reynier 2017) Let f . The following are equivalent:
- f can be computed by a register transducer
- f can be computed by a register transducer with states
- f can be specifjed by a HDT0L system
(variant of Lindenmayer systems from the 1960s) Furthermore, L regular f
1 L regular for such f. 10/18
SLIDE 25 Register transducers with states
- Finite set of Σ∗-valued registers R, initial values R → Σ∗
- fjnite state machine (i.e. DFA) (Q, qinit ∈ Q, δ : Γ × Q → Q)
- updates Γ × Q → (Σ ∪ R)∗, “output function” Q → (Σ ∪ R)∗
Theorem (Filiot & Reynier 2017) Let f : Γ∗ → Σ∗. The following are equivalent:
- f can be computed by a register transducer
- f can be computed by a register transducer with states
- f can be specifjed by a HDT0L system
(variant of Lindenmayer systems from the 1960s) Furthermore, L regular = ⇒ f−1(L) regular for such f.
10/18
SLIDE 26
Exponential growth of HDT0L transductions
Γ = Σ = {1} R = {X} Xinit = 1 X := XX = ⇒ f : Γ∗ → Σ∗ such that |f(w)| = 2|w| Proposition (Exponential upper bound) Conversely, for any HDT0L f , f w 2O w . Corollary HDT0L transductions are not closed under composition. Their closure under comp. has elementary growth. HDT0L+composition all transduction classes that I know
(to be fair, I don’t know many)
See also: Sénizergues 2007, Sequences of level 1,2,…,k,…
11/18
SLIDE 27
Exponential growth of HDT0L transductions
Γ = Σ = {1} R = {X} Xinit = 1 X := XX = ⇒ f : Γ∗ → Σ∗ such that |f(w)| = 2|w| Proposition (Exponential upper bound) Conversely, for any HDT0L f : Γ∗ → Σ∗, |f(w)| = 2O(|w|). Corollary HDT0L transductions are not closed under composition. Their closure under comp. has elementary growth. HDT0L+composition all transduction classes that I know
(to be fair, I don’t know many)
See also: Sénizergues 2007, Sequences of level 1,2,…,k,…
11/18
SLIDE 28
Exponential growth of HDT0L transductions
Γ = Σ = {1} R = {X} Xinit = 1 X := XX = ⇒ f : Γ∗ → Σ∗ such that |f(w)| = 2|w| Proposition (Exponential upper bound) Conversely, for any HDT0L f : Γ∗ → Σ∗, |f(w)| = 2O(|w|). Corollary HDT0L transductions are not closed under composition. Their closure under comp. has elementary growth. HDT0L+composition ⊃ all transduction classes that I know
(to be fair, I don’t know many)
See also: Sénizergues 2007, Sequences of level 1,2,…,k,…
11/18
SLIDE 29
Returning to λ-defjnable functions
Theorem The class of functions defjned by simply typed λ-terms of type StrΓ[A] → StrΣ contains HDT0L+composition. Proof. It is closed under composition and can encode register transducers (programming exercise). ST subsumes many classes of regularity-preserving functions! Open question (concrete proposal) What about the converse? That is, ST -defjnable = HDT0L+composition? Possible connections with iterated pushdown automata.
12/18
SLIDE 30
Returning to λ-defjnable functions
Theorem The class of functions defjned by simply typed λ-terms of type StrΓ[A] → StrΣ contains HDT0L+composition. Proof. It is closed under composition and can encode register transducers (programming exercise). STλ subsumes many classes of regularity-preserving functions! Open question (concrete proposal) What about the converse? That is, STλ-defjnable = HDT0L+composition? Possible connections with iterated pushdown automata.
12/18
SLIDE 31
Linearity in register transducers
X := XX is a non-linear register update − → as usual, duplication causes complexity (2O(n) growth) Whereas affjne updates lead to O(n) growth, e.g. |f(w)| = 2|w| for f : w → w · reverse(w) X := Xa Y := aY ↭ x ⊗ y → xa ⊗ ay (In the automata theory literature: “copyless assignments”.) Defjnition A streaming string transducer (SST) is a register transducer with states and with affjne register updates.
13/18
SLIDE 32
Linearity in register transducers
X := XX is a non-linear register update − → as usual, duplication causes complexity (2O(n) growth) Whereas affjne updates lead to O(n) growth, e.g. |f(w)| = 2|w| for f : w → w · reverse(w) X := Xa Y := aY ↭ x ⊗ y → xa ⊗ ay (In the automata theory literature: “copyless assignments”.) Defjnition A streaming string transducer (SST) is a register transducer with states and with affjne register updates.
13/18
SLIDE 33 Regular functions
Defjnition A streaming string transducer (SST) is a register transducer with states and with affjne register updates. Theorem (Alur & Černý 2010) The functions computed by SSTs are the regular functions. Closed under composition, linear growth, f−1(reg. lang) is reg. Many other characterizations:
- two-way fjnite state transducers without registers
- Monadic Second-Order Logic
- basic functions + combinators (at least 3 possible variants)
- etc.
14/18
SLIDE 34
Inspiration from implicit complexity in linear logic
Goal: regular functions in an affjne programming language. We use the elementary affjne λ-calculus (EAλ). Theorem (Baillot, De Benedetti & Ronchi Della Rocca 2014) The languages defjned by EAλ-terms with type fjxpoints of type !StrΣ ⊸ !!Bool are exactly those decidable in polynomial time. Where StrΣ = ∀α. (!(α ⊸ α))|Σ| ⊸ !(α ⊸ α) Theorem (my talk at TLLA 2018!) The languages defjned by EA -terms of type Str Bool are exactly the regular languages over . Good news: Str Str regularity-preserving functions.
15/18
SLIDE 35
Inspiration from implicit complexity in linear logic
Goal: regular functions in an affjne programming language. We use the elementary affjne λ-calculus (EAλ). Theorem (Baillot, De Benedetti & Ronchi Della Rocca 2014) The languages defjned by EAλ-terms with type fjxpoints of type !StrΣ ⊸ !!Bool are exactly those decidable in polynomial time. Where StrΣ = ∀α. (!(α ⊸ α))|Σ| ⊸ !(α ⊸ α) Theorem (my talk at TLLA 2018!) The languages defjned by EAλ-terms of type !StrΣ ⊸ !!Bool are exactly the regular languages over Σ. Good news: !StrΓ ⊸ !StrΣ ⇝ regularity-preserving functions.
15/18
SLIDE 36
A characterization of regular functions
Good news: !StrΓ ⊸ !StrΣ ⇝ regularity-preserving functions. Bad news: they have super-linear growth (Θ(nk) for any k). Idea: drop the exponentials on the Str. Theorem f regular f defjned by EA term t Str Str . Proof of . Encode the streaming string transducer in EA . Proof of (with Pistone, Seiller & Tortora de Falco). Much more diffjcult: we need to construct a kind of “fjnitely parameterized semantics” of 2nd-order affjne MLL (+ constants) via combinatorial study of proof nets
(looks like concurrent games?)
16/18
SLIDE 37
A characterization of regular functions
Good news: !StrΓ ⊸ !StrΣ ⇝ regularity-preserving functions. Bad news: they have super-linear growth (Θ(nk) for any k). Idea: drop the exponentials on the Str. Theorem f : Γ∗ → Σ∗ regular ⇐ ⇒ f defjned by EAλ term t : StrΓ ⊸ StrΣ. Proof of . Encode the streaming string transducer in EA . Proof of (with Pistone, Seiller & Tortora de Falco). Much more diffjcult: we need to construct a kind of “fjnitely parameterized semantics” of 2nd-order affjne MLL (+ constants) via combinatorial study of proof nets
(looks like concurrent games?)
16/18
SLIDE 38
A characterization of regular functions
Good news: !StrΓ ⊸ !StrΣ ⇝ regularity-preserving functions. Bad news: they have super-linear growth (Θ(nk) for any k). Idea: drop the exponentials on the Str. Theorem f : Γ∗ → Σ∗ regular ⇐ ⇒ f defjned by EAλ term t : StrΓ ⊸ StrΣ. Proof of ( = ⇒ ). Encode the streaming string transducer in EAλ. Proof of (⇐ =) (with Pistone, Seiller & Tortora de Falco). Much more diffjcult: we need to construct a kind of “fjnitely parameterized semantics” of 2nd-order affjne MLL (+ constants) via combinatorial study of proof nets
(looks like concurrent games?)
16/18
SLIDE 39
Relationship with implicit complexity in linear logic, again
Theorem (Simplifjcation of a result by Baillot et al. 2014) The functions defjned by EAλ-terms with type fjxpoints of type !StrΓ ⊸ !StrΣ are exactly those computable in polynomial time. So, what about !StrΓ ⊸ !StrΣ in EAλ w/o type fjxpoints? Some class of functions that must be regularity-preserving… regular this polyregular functions (Bojańczyk 2018)
(last inclusion probably strict; also, polyregular HDT0L+composition)
“Slogan: Polyregular functions are the polynomial growth fjnite state transducers.” Unpublished paper (arXiv:1810.08760).
17/18
SLIDE 40
Relationship with implicit complexity in linear logic, again
Theorem (Simplifjcation of a result by Baillot et al. 2014) The functions defjned by EAλ-terms with type fjxpoints of type !StrΓ ⊸ !StrΣ are exactly those computable in polynomial time. So, what about !StrΓ ⊸ !StrΣ in EAλ w/o type fjxpoints? Some class of functions that must be regularity-preserving… regular ⊊ this ⊆ polyregular functions (Bojańczyk 2018)
(last inclusion probably strict; also, polyregular ⊊ HDT0L+composition)
“Slogan: Polyregular functions are the polynomial growth fjnite state transducers.” Unpublished paper (arXiv:1810.08760).
17/18
SLIDE 41 Conclusion
This is only the start! Our concrete results for now:
- register transducers (HDT0L) + composition
can be encoded in simply typed λ-calculus (STλ)
- regular functions can be characterized
in the elementary affjne λ-calculus
- not mentioned here: tree transducers vs additive ‘&’
Why this might be interesting:
- reviving an old question on ST
- recent surge of interest in transductions with super-linear
growth (HDT0L systems, polyregular functions)
gives the largest (?) such “natural” class known
Paper: https://nguyentito.eu/tmp/transducer-p1.pdf
18/18
SLIDE 42 Conclusion
This is only the start! Our concrete results for now:
- register transducers (HDT0L) + composition
can be encoded in simply typed λ-calculus (STλ)
- regular functions can be characterized
in the elementary affjne λ-calculus
- not mentioned here: tree transducers vs additive ‘&’
Why this might be interesting:
- reviving an old question on STλ
- recent surge of interest in transductions with super-linear
growth (HDT0L systems, polyregular functions)
- STλ gives the largest (?) such “natural” class known
Paper: https://nguyentito.eu/tmp/transducer-p1.pdf
18/18
SLIDE 43 Conclusion
This is only the start! Our concrete results for now:
- register transducers (HDT0L) + composition
can be encoded in simply typed λ-calculus (STλ)
- regular functions can be characterized
in the elementary affjne λ-calculus
- not mentioned here: tree transducers vs additive ‘&’
Why this might be interesting:
- reviving an old question on STλ
- recent surge of interest in transductions with super-linear
growth (HDT0L systems, polyregular functions)
- STλ gives the largest (?) such “natural” class known
Paper: https://nguyentito.eu/tmp/transducer-p1.pdf
18/18