Lecture 4: wSkS

wSkS

Let $𝒳_1, 𝒳_2$ be two countable sets.

\[φ ≝ x = ε \mid x = yi \mid x = y \\ \mid ε ∈ X \mid x ∈ X \mid ¬ φ \\ \mid φ ∧ φ \mid ∃x. φ \mid ∃ X. φ\]

$x, y ∈ 𝒳_1, \; X ∈ X_2, 1 ≤ i ≤ k$

Semantics

$wSkS ⊨_{v_1, v_2} φ$

  • $v_1: 𝒳_1 ⟶ \lbrace 1, \ldots, k \rbrace^\ast$
  • $v_2: 𝒳_2 ⟶ ℙ_{finite}(\lbrace 1, \ldots, k \rbrace^\ast)$
  1. $⊨_{v_1, v_2} x =ε$ iff $v_1(x) = ε$
  2. $⊨_{v_1, v_2} x = yi$ iff $v_1(x) = v_1(y) \cdot i$
  3. $⊨_{v_1, v_2} x = y$ iff $v_1(x) = v_1(y)$
  4. $⊨_{v_1, v_2} ε ∈ X$ iff $ε ∈ v_2(X)$

the rest is standard…

  digraph {
    rankdir=TB;
    NFTA -> EMSO[label=poly];
    EMSO -> MSO;
    NFTA -> MSO[label=poly];
    MSO -> NFTA[label="   tower"];
    MSO -> WSkS[label=poly];
    WSkS -> NFTA[label=tower];
  }

Formulae variables in WSkS

$x ≤ y$ (prefix ordering):
\[∀X. \bigg(x ∈ X ∧ \Big(∀x_1, x_2. (x_1 ∈ X ∧ \bigvee_{1 ≤ i ≤ k} x_2 = x_1 i) ⟹ x_2 ∈ X \Big) \bigg)⟹ y ∈ X\]

Ex: 121 ≤ 12131

$partition(X, X_1, \ldots, X_n), \; X ∩ Y = Z$: as before

For a finite ranked alphabet $ℱ ≝ \lbrace f_1^{(r_1)}, ⋯, f_n^{(r_n)} \rbrace$ with $r_j ≤ k, ∀j$, write a formula $φ_ℱ(X, X_1, ⋯, X_n)$ of wSkS such that:

  • $X$ is the domain of a tree in $T(ℱ)$
  • $∀j. X_j$ encodes the letter $f_j$
\[φ_ℱ(X, X_1, ⋯, X_n) ≝ prefix-closed(X) \\ ∧ ∃x. x ∈ X \qquad \text{(non empty)}\\ ∧ partition(X, X_1, ⋯, X_n) \\ ∧ \bigwedge_{1 ≤ j ≤ n} ∀x. x∈ X_j ⟹ \Big( \bigwedge_{1 ≤ r ≤ r_j} ∃x_r. x_r = x \cdot r ∧ x_r ∈ X \\ ∧ \bigwedge_{r_j ≤ r ≤ k} ∃y_r. y_r = x \cdot r ∧ y_r ∉ X\Big) \qquad \text{(arities are consistent with labelling)}\] \[prefix-closed(X) ≝ ∀x, y. (x ≤ y ∧ y ∈ X) ⟹ x ∈ X\]

Th: Given an MSO formula $ψ$ on trees in $T(ℱ)$ of arity at most $k$, we can construct a wSkS formula $φ$ such that

  • $t ⊨{v_1, v_2} ψ$ iff $t ⊨{v_1, v’_2} φ$
  • where $X, X_1, ⋯, X_n$ are fresh variables and \(v'_2 ≝ v_2[X ⟼ Pos(t), (X_j ⟼ P^t_{f_j})_{1 ≤ j ≤ n}]\)
\[φ ≝ ∃X, X_1, ⋯, X_n. φ_ℱ(X, X_1, ⋯, X_n) ∧ ψ\]

where we interpret:

  • $x \downarrow_i y ≝ y = xi$
  • $P_{f_j}(x) ≝ x ∈ X_j$
  • $∃ x. ψ’ ≝ ∃x. x ∈ X ∧ ψ’$
  • $∃ Y. ψ’ ≝ ∃Y. Y ⊆ X ∧ ψ’$

Ex: $wSkS ⊨ ∀x, ∃y. y = x i$

Reduction to NFTA

We need a notion of valuated tree as in the case of MSO

Ex: $X_1, X_2, X_3$, $k=2$

  • $v_2(X_1) ≝ \lbrace ε, 11 \rbrace$
  • $v_2(X_2) ≝ ∅$
  • $v_2(X_3) ≝ \lbrace 11, 22 \rbrace$

valuation alphabet: $V_3 ≝ \lbrace 0, 1, ⊥ \rbrace$

Minimisation of deterministic complete bottom-up finite tree automata

Syntactic congruence $≡_L$ of a tree laguage $L$

\[t ≡_L t' \qquad\text{ iff }\qquad ∀C. C[t] ∈ L ⟹ C[t'] ∈ L\]

Th: $L$ is regular iff $≡_L$ has finite index

(seen during exercises sessions)

As part of the proof, we saw how to build an automaton

\[𝒜_L ≝ (Q_L, ℱ, Δ, Q_{f_L})\]

where

  • \[Q_L ≝ T(ℱ)/≡_L\]
  • \[Q_{f_L} ≝ L/≡_L\]
  • \[Δ ≝ \lbrace f^{(n)}([t_1], ⋯, [t_n]) ⟶ [f^{(n)}(t_1, ⋯, t_n)] \rbrace\]

which is the minimal automaton for $L$.

How to minimize?

First, determinize it!

Nerode congruence on an automaton:

$q \sim q’ \qquad\text{ iff }\qquad L_q = L_{q’}$

Computing the Nerode congruence

  • $q \sim_0 q’$ iff $q∈ Q_f ⟺ q’∈Q_f$
  • $q \sim_{i+1} q’$ iff $q \sim_i q’$ and $∀n, ∀f∈ℱ_n, ∀ 1 ≤ j ≤n, ∀q_1, ⋯, q_{j-1}, q_{j+1}, ⋯, q_n ∈ Q$: \(Δ_f(q_1, ⋯, q_{j-1}, q, q_{j+1}, ⋯, q_n) \sim_i Δ_f(q_1, ⋯, q_{j-1}, q', q_{j+1}, ⋯, q_n)\)

$∃k≤ \vert Q \vert, ∀j, \sim_{k+1} = \sim_k$ and then $\sim = \sim_k$

(same proof as in the word case)

Unranked finite ordered labelled trees

$Σ$ finite alphabet, no ranks.

  graph {
    rankdir=TB;
    b1, b2, b3[label=b];
    a1, a2, a3[label=a];
    c1, c2[label=c];
    d1, d2[label=d];
    a1 -- b1, a2, c1, d1;
    b1 -- b2;
    a2 -- a3, d2;
    d1 -- c2, b3;
  }
\[\newcommand{\dom}{\mathop{\rm dom}\nolimits} \newcommand{\Pos}{\mathop{\rm Pos}\nolimits}\]

formally:

An unranked finite tree over $Σ$ is:

a partial function $t: (ℕ_{>0})^\ast ⟶ Σ$ s.t. $\dom t$ (a.k.a $\Pos t$) is

  • finite
  • non-empty
  • prefix-closed: $pp’ ∈ \dom t$, then $p ∈ \dom t$
  • predecessor-closed: $p(i+1) ∈ \dom t$ for $p ∈ ℕ^\ast_{>0}, i∈ℕ_{>0}$, then $pi ∈ \dom t$
Inductive definition:
  • a tree is $f(σ)$ for $f∈Σ$ and $σ$ a forest
  • a forest is a finite sequence of trees
\[T(Σ) ≝ \lbrace f(σ) \mid f ∈ Σ, σ∈ F(Σ) \rbrace \\ F(Σ) ≝ T(Σ)^\ast\]

Finite hedge automata

A NFHA is a tuple $𝒜 ≝ (Q, Σ, Δ, Q_f)$:

where

  • $Q$ is a finite set of states
  • $Σ$ is a finite alphabet
  • $Q_f ⊆ Q$ is a set of accepting states
  • $Δ ⊆_{finite} Q × Σ × Rat(Q^\ast)$

Semantics

given a tree $t$ over $Σ$:

a run of $𝒜$:

is a tree $ρ$ over $Q$ s.t.

  • $\dom ρ = \dom t$
  • $∀p∈ \dom ρ, ∀ a ∈ Σ, ∀ q ∈ Q, \; ∀n, ∀q_1, ⋯, q_n∈ Q$, \(t(p) = a \text{ and } ρ(p) = q \text{ and } ∀ 1 ≤ i ≤ n, ρ(pi) = qi \text{ and } p(n+1) ∉ \dom t ⟹ ∃ (q, a, R) ∈ Δ; q_1 ⋯ q_n ∈ R\)

It is accepting if $ρ(ε) ∈ Q_f$

Rewriting-style (bottom-up):
\[a(q_1, ⋯, q_n) ⟶ q \qquad\text{ if } (q, a, R) ∈ Δ \text{ and } q_1, ⋯, q_n ∈ R\]

Notation in TATA (chap. 8):

$(q, a, R)$ is written $a(R)⟶q$

Example: $Σ = \lbrace a, b, c \rbrace$

$L = $ “trees with two positions labelled $b$ and least common ancestor labelled $c$”

\[L ≝ \lbrace t ∈ T(Σ) \mid ∃ p≠p'∈ \dom t, t(p) = t(p') = b \text{ and } t(p ∧ p') = c \rbrace\]
  • $Q ≝ \lbrace q_a, q_b, q_c, q \rbrace$
  • $Q_f = \lbrace q_c \rbrace$

$Δ$:

  • $a(q^\ast) ⟶ q$
  • $a((q+q_b)^\ast q_b (q+q_b)^\ast) ⟶ q_b$
  • $b((q+q_b)^\ast)⟶ q_b$
  • $c(q^\ast)⟶q$
  • $c((q+q_b)^\ast q_b (q+q_b)^\ast) ⟶ q_b$
  • $c(Q^\ast q_b Q^\ast q_b Q^\ast) ⟶ q_c$
  • $a(Q^\ast q_c Q^\ast)⟶ q_c$
  • $b(Q^\ast q_c Q^\ast)⟶ q_c$
  • $c(Q^\ast q_c Q^\ast)⟶ q_c$

Ex: $Σ = \lbrace ∧, ∨, ¬, ⊥, ⊤ \rbrace$

\[L = \lbrace t \text{ well-formed that evaluate to true} \rbrace\]
  • $Q = \lbrace q_0, q_1 \rbrace$
  • $Q_f = \lbrace q_1 \rbrace$

$Δ$:

  • $⊤(ε) ⟶ q_1$
  • $⊥(ε) ⟶ q_0$
  • $¬(q_0) ⟶ q_1$
  • $¬(q_1) ⟶ q_0$
  • $∧(Q^\ast q_0 Q^\ast) ⟶ q_0$
  • $∧(q_1^\ast) ⟶ q_1$
  • $∨(Q^\ast q_1 Q^\ast) ⟶ q_1$
  • $∨(q_0^\ast) ⟶ q_0$

is deterministic.


A NFHA is

normalized:

if $∀a∈ Σ, q∈Q, (q, a, R), (q, a, R’)∈ Δ ⟹ R = R’$

deterministic (bottom-up):

if $∀a∈ Σ, q, q’∈Q, (q, a, R), (q’, a, R’)∈ Δ ⟹ R ∩ R’ = ∅ ∨ q = q’$

Leave a comment