# A Gentle Introduction to Applications of Algorithmic Metatheorems for Space and Circuit Classes

## Abstract

**:**

## 1. Introduction

#### 1.1. A First-Year Student’s Approach to the Vertex Cover Problem

#### 1.1.1. Solving Vertex Cover Using Divide-and-Conquer?

#### 1.1.2. The Question of Why

#### 1.2. The Range of Applications of Algorithmic Metatheorems

#### 1.3. Intended Audience and Organization of This Paper

#### 1.4. Related Work

## 2. The Concepts and Ideas Behind Courcelle’s Theorem

“All monadic second-order properties of graphs of bounded tree width can be decided in linear time.”

#### 2.1. Describing The Problems: Monadic Second-Order Logic

#### 2.1.1. The Need for Metatheorems

**Theorem 4.4**

#### 2.1.2. Using Predicate Logic to Describe Problems

#### 2.1.3. The Need for Monadic Predicates

#### 2.2. Decomposing the Problems: Tree Decompositions

#### 2.2.1. The Scotland Yard Game

#### 2.2.2. Decompositions Are Game Strategies

#### 2.2.3. Defining Decompositions

- Connectedness property: for each vertex, $v\in V$, the set $\{n\in N\mid v\in B(n\left)\right\}$ is connected in T.
- Covering property: for each edge, $(u,v)\in E$, there is a node n with $u\in B\left(n\right)$ and $v\in B\left(n\right)$.

#### 2.3. The Proof Ideas for Courcelle’s Theorem

**Courcelle’s Theorem.**

**Proof Ideas.**

#### 2.4. A Look at the Hidden Constants

## 3. An Algorithmic Metatheorem for Logspace and Its Applications

**Theorem 1**

**Proof Ideas.**

- Compute a tree decomposition $(T,B)$ of the input graph G.
- Transform the formula φ into a formula ${\varphi}^{\prime}$.
- Transform the formula ${\varphi}^{\prime}$ into a tree automaton A.
- Run A on T.

#### 3.1. Applications: Low-Hanging Fruits

**Lemma**

**2.**

**Proof.**

**Lemma**

**3.**

**Proof.**

**Theorem 4**

#### 3.2. Applications: Special Fruits

**Lemma**

**5.**

**Lemma**

**6.**

#### 3.3. Applications: High-Hanging Fruits I—Cycle Modularity Problems

**Theorem**

**7.**

**Proof Ideas.**

#### 3.4. Applications: High-Hanging Fruits II—A Refined Version of Fagin’s Theorem

**Theorem 8**

**Proof Ideas.**

## 4. An Algorithmic Metatheorem for Log-Depth Circuits and Its Applications

- Compute a tree decomposition $(T,B)$ of the input graph G.
- Transform the formula φ into a formula ${\varphi}^{\prime}$.
- Transform the formula ${\varphi}^{\prime}$ into a tree automaton A.
- Run the tree automaton A on T.

**Theorem 9**

#### 4.1. Applications: Model Checking for Propositional Logic

**Lemma**

**10.**

**Proof Ideas.**

#### 4.2. Applications: Visibly Pushdown Languages

**Theorem**

**11.**

**Proof Ideas.**

`([()()][])`.

- It is “easy to compute” since, as explained earlier, the height of the stack at each horizontal position can be computed just by doing a simple subtraction. Clearly, adding the edges is also very easy to achieve.
- The graph has tree width 2, that is, three detectives suffice to corner Charlie wherever he might start: two detectives position themselves at the “forking vertex” and at the “joining vertex” of an area containing Charlie and then the third detective moves to an intermediate forking or joining vertex to cut of more of the graph. Note that not only does the graph have tree width 2, we can actually compute the tree decomposition just as easily as the graph itself since this tree decomposition just reflects the nesting structure of the stack.
- In order to decide whether the automaton accepts the input word, we use a formula that existentially guesses the contents of the stack at each moment, using unary predicates, and then verifies that the changes of the stack contents along edges are correct (mostly, this means that there may not be any change, except for the top of the stack, where the change must match the automaton’s behavior).

## 5. An Algorithmic Metatheorem for Constant-Depth Circuits and Its Applications

#### 5.1. The Unary Subset Sum Problem

**Theorem**

**12.**

**Proof Ideas.**

#### 5.2. Back to the Original Subset Sum Problem

**Corollary**

**13.**

**Proof Idea.**

#### 5.3. Bounded Tree Depth

**Definition**

**14.**

- Compute a tree decomposition $(T,B)$ of the input graph G.
- Transform the formula φ into a formula ${\varphi}^{\prime}$.
- Transform the formula ${\varphi}^{\prime}$ into a tree automaton A.
- Run the tree automaton A on T.

**Theorem 15**

- 1.
- Let φ be a formula in monadic second-order logic. Then, the language $\{\mathcal{G}\mid \mathcal{G}\models \varphi $ and $\mathcal{G}$ has tree depth at most $d\}$ can be decided by an AC${}^{0}$-circuit family.
- 2.
- Let $\varphi \left(X\right)$ be a formula in monadic second-order logic with a free monadic second-order variable X. Then, the language $\left\{\right(\mathcal{G},s)\mid \mathcal{G}\models \varphi (C)$ for some $C\subseteq V$ with $\left|C\right|=s$, and $\mathcal{G}$ has tree depth at most $d\}$ can be decided by a TC${}^{0}$-circuit family.

**Theorem**

**16.**

#### 5.4. Outlook to Other Problems

## 6. Conclusions

## Conflicts of Interest

## References

- Courcelle, B. Graph rewriting: An algebraic and logic approach. In Handbook of Theoretical Computer Science, Volume B: Formal Models and Semantics; van Leeuwen, J., Ed.; MIT Press: Cambridge, MA, USA, 1990; pp. 193–242. [Google Scholar]
- Grohe, M.; Kreutzer, S.; Siebertz, S. Deciding First-order Properties of Nowhere Dense Graphs. In Proceedings of the 46th Annual ACM Symposium on Theory of Computing; STOC ’14, Copenhagen, Denmark, 29 June–1 July 2014; pp. 89–98.
- Frick, M.; Grohe, M. Deciding First-order Properties of Locally Tree-decomposable Structures. J. ACM
**2001**, 48, 1184–1206. [Google Scholar] [CrossRef] - Courcelle, B.; Makowsky, J.A.; Rotics, U. Linear Time Solvable Optimization Problems on Graphs of Bounded Clique-Width. Theory Comput. Syst.
**2000**, 33, 125–150. [Google Scholar] [CrossRef] - Elberfeld, M.; Jakoby, A.; Tantau, T. Logspace Versions of the Theorems of Bodlaender and Courcelle. In Proceedings of the 51st Annual IEEE Symposium on Foundations of Computer Science (FOCS 2010), Las Vegas, NV, USA, 23–26 October 2010; pp. 143–152.
- Thomassen, C. On the presence of disjoint subgraphs of a specified type. J. Graph Theory
**1988**, 12, 101–111. [Google Scholar] [CrossRef] - Grohe, M. Logic, Graphs, and Algorithms. In Logic and Automata: History and Perspectives, Texts in Logic and Games; Flum, J., Grädel, E., Wilke, T., Eds.; Amsterdam University Press: Amsterdam, The Netherlands, 2007; Volume 2, pp. 357–422. [Google Scholar]
- Grohe, M.; Kreutzer, S. Methods for Algorithmic Meta Theorems. In Proceedings of the Model Theoretic Methods in Finite Combinatorics, Contemporary Mathematics: AMS-ASL Joint Special Session, Washington, DC, USA, 5–8 January 2009. In Contemporary Mathemetics; American Mathematical Society: Providence, RI, USA, 2011; Volume 558, pp. 181–206.
- Kreutzer, S. Algorithmic Meta-theorems. In Finite and Algorithmic Model Theory, London Mathematical Society Lecture Note Series; Esparza, J., Michaux, C., Steinhorn, C., Eds.; Cambridge University Press: Cambrigde, UK, 2011; Volume 379. [Google Scholar]
- Immerman, N. Descriptive Complexity; Springer: New York, NY, USA, 1999. [Google Scholar]
- Bodlaender, H.L. NC-algorithms for graphs with small treewidth. In Proceedings of the 14th International Workshop on Graph-Theoretic Concepts in Computer Science (WG 1988), Amsterdam, The Netherlands, 15–17 June 1988. In Lecture Notes in Computer Science; Springer: Heidelberg, Germany, 2010; Volume 344. pp. 1–10.
- Fagin, R. Generalized First-Order Spectra and Polynomial-Time Recognizable Sets. Complex. Comput.
**1974**, 7, 43–74. [Google Scholar] - Bodlaender, H.L. A Linear-Time Algorithm for Finding Tree-Decompositions of Small Treewidth. SIAM J. Comput.
**1996**, 25, 1305–1317. [Google Scholar] [CrossRef] - Frick, M.; Grohe, M. The Complexity of First-order and Monadic Second-order Logic Revisited. Ann. Pure Appl. Logic
**2004**, 130, 3–31. [Google Scholar] [CrossRef] - Buss, S.R. The Boolean formula value problem is in ALOGTIME. In Proceedings of the 19th Annual ACM Symposium on Theory of Computing (STOC 1987), New York, NY, USA, 25–27 May 1987; pp. 123–131.
- Reingold, O. Undirected connectivity in log-space. J. ACM
**2008**, 55, 1–24. [Google Scholar] [CrossRef] - Elberfeld, M.; Schweitzer, P. Canonizing Graphs of Bounded Tree Width in Logspace. In Proceedings of the 33rd Symposium on Theoretical Aspects of Computer Science (STACS 2016), Orleans, France, 17–20 February 2016. In Leibniz International Proceedings in Informatics; Volume 47, pp. 32:1–32:14.
- Das, B.; Datta, S.; Nimbhorkar, P. Log-space Algorithms for Paths and Matchings in k-trees. In Proceedings of the 27th International Symposium on Theoretical Aspects of Computer Science (STACS 2010), Nancy, France, 4–6 March 2010. In Leibniz International Proceedings in Informatics; Volume 5, pp. 215–226.
- Gottlob, G.; Kolaitis, P.G.; Schwentick, T. Existential second-order logic over graphs: Charting the tractability frontier. J. ACM
**2004**, 51, 312–362. [Google Scholar] [CrossRef] - Tantau, T. Existential Second-order Logic over Graphs: A Complete Complexity-theoretic Classification. In Proceedings of the 32nd International Symposium on Theoretical Aspects of Computer Science (STACS 2015), Garching, Germany, 4–7 March 2015. In Leibniz International Proceedings in Informatics (LIPIcs); Volume 30, pp. 703–715.
- Elberfeld, M.; Jakoby, A.; Tantau, T. Algorithmic Meta Theorems for Circuit Classes of Constant and Logarithmic Depth. In Proceedings of the 29th International Symposium on Theoretical Aspects of Computer Science (STACS 2012), Paris, France, 29 February–3 March 2012. In Leibniz International Proceedings in Informatics (LIPIcs); Volume 14, pp. 66–77.
- Dymond, P. Input-driven languages are in log n depth. Inf. Process. Lett.
**1988**, 26, 247–250. [Google Scholar] [CrossRef] - Krebs, A.; Limaye, N.; Mahajan, M. Counting Paths in VPA Is Complete for #NC
^{1}. In Proceedings of the 16th Annual International Conference on Computing and Combinatorics (COCOON 2010), Nha Trang, Vietnam, 19–21 July 2010. In Lecture Notes in Computer Science; Springer: Heidelberg, Germany, 2010; Volume 6196, pp. 44–53. - Cook, S.A. A taxonomy of problems with fast parallel algorithms. Inf. Control
**1985**, 64, 2–22. [Google Scholar] [CrossRef] - Lokshtanov, D.; Nederlof, J. Saving space by algebraization. In Proceedings of the 42nd ACM Symposium on Theory of computing (STOC 2010), Cambridge, MA, USA, 6–8 June 2010; pp. 321–330.

**Figure 1.**(

**Left**) a tree on which, in the Scotland Yard game, two detectives, Alice and Bob, suffice to catch a thief wherever he starts. The tree width of the tree, which is defined as the necessary number of detectives minus 1, is hence 1; (

**Right**) in contrast, on a cycle, Alice and Bob must enlist the help of a third detective, Dave, to catch the thief. Hence, the tree width of a cycle is 2.

**Figure 2.**The “strategy tree” in the Scotland Yard game for catching a thief on a circle using three detectives. A tree decomposition of the circle is obtained from this strategy tree by replacing the small graphs shown in the nodes by so-called “bags” consisting of the black vertices in each of the small graphs.

**Figure 3.**The parse tree corresponding to the propositional formula $(p\wedge \neg p)\vee (q\vee p)$ and the assignment $\beta \left(p\right)=0$ and $\beta \left(q\right)=1$. Note that this tree as well as a tree decomposition for it can be computed easily from the formula (“easily” meaning “in TC${}^{0}$” to be precise).

**Figure 4.**Two examples of the stack contents of two different pushdown automata as they parse the input words “

`([()()][])`” and “

`0010111100`”. In (

**Left**), for each opening parenthesis, a push-operation is performed, and, for each closing parenthesis, a pop-operation. In particular, whether or not a push or a pop operation is performed does not depend on the state of the automaton and, hence, the automaton in a visibly pushdown automaton. In contrast, in (

**Right**), each operation depends not only on the symbol read (

`0`or

`1`), but also on the internal state of the automaton. Indeed, the language accepted by the automaton (decide whether the number of

`0`and

`1`symbols is equal) cannot be accepted by a visibly pushdown automaton.

**Figure 5.**(

**Left**) once more, the stack contents from Figure 4a for the automaton that checks whether parentheses are balanced in an example input word; (

**Right**) a graph of tree width 2 that represents the stack “outline” for the stacks shown left. While this outline is easy to compute (by TC${}^{0}$-circuits, to be precise) for visibly pushdown automata, the contents of the stack is harder to compute and we use a second-order quantifier to “guess”.

© 2016 by the author; licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC-BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Tantau, T. A Gentle Introduction to Applications of Algorithmic Metatheorems for Space and Circuit Classes. *Algorithms* **2016**, *9*, 44.
https://doi.org/10.3390/a9030044

**AMA Style**

Tantau T. A Gentle Introduction to Applications of Algorithmic Metatheorems for Space and Circuit Classes. *Algorithms*. 2016; 9(3):44.
https://doi.org/10.3390/a9030044

**Chicago/Turabian Style**

Tantau, Till. 2016. "A Gentle Introduction to Applications of Algorithmic Metatheorems for Space and Circuit Classes" *Algorithms* 9, no. 3: 44.
https://doi.org/10.3390/a9030044