Exercise 8: Datalog Database Theory 2020-06-08 Maximilian Marx, - - PowerPoint PPT Presentation

exercise 8 datalog
SMART_READER_LITE
LIVE PREVIEW

Exercise 8: Datalog Database Theory 2020-06-08 Maximilian Marx, - - PowerPoint PPT Presentation

Exercise 8: Datalog Database Theory 2020-06-08 Maximilian Marx, David Carral 1 / 47 Exercise 1 Exercise. A graph is planar if it can be drawn on the plane without intersections of edges. For example, the following graph A is planar, while


slide-1
SLIDE 1

Exercise 8: Datalog

Database Theory 2020-06-08 Maximilian Marx, David Carral

1 / 47

slide-2
SLIDE 2

Exercise 1

  • Exercise. A graph is planar if it can be drawn on the plane without intersections of edges. For example, the following

graph A is planar, while graph B is not:

Figure: A Figure: B

  • 1. Can the graphs A and B be distinguished by a FO query?
  • 2. Show that planarity is not FO-definable by using locality.

2 / 47

slide-3
SLIDE 3

Exercise 1

  • Exercise. A graph is planar if it can be drawn on the plane without intersections of edges. For example, the following

graph A is planar, while graph B is not:

Figure: A Figure: B

  • 1. Can the graphs A and B be distinguished by a FO query?
  • 2. Show that planarity is not FO-definable by using locality.

Solution.

3 / 47

slide-4
SLIDE 4

Exercise 1

  • Exercise. A graph is planar if it can be drawn on the plane without intersections of edges. For example, the following

graph A is planar, while graph B is not:

Figure: A Figure: B

  • 1. Can the graphs A and B be distinguished by a FO query?
  • 2. Show that planarity is not FO-definable by using locality.

Solution.

  • 1. This query matches B but not A:

∃x, y, z, w, v. E(x, y) ∧ E(y, z) ∧ E(z, w) ∧ E(w, x) ∧ E(x, v) ∧ E(y, v) ∧ E(z, v) ∧ E(w, v) ∧ E(x, z) ∧ E(y, w)

4 / 47

slide-5
SLIDE 5

Exercise 1

  • Exercise. A graph is planar if it can be drawn on the plane without intersections of edges. For example, the following

graph A is planar, while graph B is not:

Figure: A Figure: B

  • 1. Can the graphs A and B be distinguished by a FO query?
  • 2. Show that planarity is not FO-definable by using locality.

Solution.

  • 1. This query matches B but not A:

∃x, y, z, w, v. E(x, y) ∧ E(y, z) ∧ E(z, w) ∧ E(w, x) ∧ E(x, v) ∧ E(y, v) ∧ E(z, v) ∧ E(w, v) ∧ E(x, z) ∧ E(y, w)

  • 2. For ϕ with quantifier rank r, consider counterexamples of size d = 3r :

. . . . . . . . . . . . . . . . . . . . . . . . d d d d d d . . . . . . . . . . . . . . . . . . . . . . . . d d d d d d

5 / 47

slide-6
SLIDE 6

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

6 / 47

slide-7
SLIDE 7

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution.

7 / 47

slide-8
SLIDE 8

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 1. SameGeneration(evan, alice) Parent(evan, carla) Parent(alice, carla) SameGeneration(carla, carla) Mother(evan, carla) Mother(alice, carla) (2); { x → evan, y → carla } (2); { x → alice, y → carla } (6); { x → evan, v → carla, y → alice, w → carla } (c) (b) (5); { x → carla }

8 / 47

slide-9
SLIDE 9

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 2. T 0

P = ∅

9 / 47

slide-10
SLIDE 10

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 2. T 0

P = ∅

T 1

P = { Father(alice,bob), Mother(alice,carla), Mother(evan,carla), Father(carla,david) }

10 / 47

slide-11
SLIDE 11

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 2. T 0

P = ∅

T 1

P = { Father(alice,bob), Mother(alice,carla), Mother(evan,carla), Father(carla,david) }

T 2

P = T 1 P ∪ { Parent(alice,bob), Parent(alice,carla), Parent(evan,carla), Parent(carla,david), SameGeneration(alice,alice), SameGeneration(bob,bob), SameGeneration(carla,carla), SameGeneration(david,david), SameGeneration(evan,evan) }

11 / 47

slide-12
SLIDE 12

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 2. T 0

P = ∅

T 1

P = { Father(alice,bob), Mother(alice,carla), Mother(evan,carla), Father(carla,david) }

T 2

P = T 1 P ∪ { Parent(alice,bob), Parent(alice,carla), Parent(evan,carla), Parent(carla,david), SameGeneration(alice,alice), SameGeneration(bob,bob), SameGeneration(carla,carla), SameGeneration(david,david), SameGeneration(evan,evan) }

T 3

P = T 2 P ∪ { Ancestor(alice,bob), Ancestor(alice,carla), Ancestor(evan,carla), Ancestor(carla,david), SameGeneration(alice,evan), SameGeneration(evan,alice) }

12 / 47

slide-13
SLIDE 13

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 2. T 0

P = ∅

T 1

P = { Father(alice,bob), Mother(alice,carla), Mother(evan,carla), Father(carla,david) }

T 2

P = T 1 P ∪ { Parent(alice,bob), Parent(alice,carla), Parent(evan,carla), Parent(carla,david), SameGeneration(alice,alice), SameGeneration(bob,bob), SameGeneration(carla,carla), SameGeneration(david,david), SameGeneration(evan,evan) }

T 3

P = T 2 P ∪ { Ancestor(alice,bob), Ancestor(alice,carla), Ancestor(evan,carla), Ancestor(carla,david), SameGeneration(alice,evan), SameGeneration(evan,alice) }

T 4

P = T 3 P ∪ { Ancestor(alice,david), Ancestor(evan,david) } = T 5 P

13 / 47

slide-14
SLIDE 14

Exercise 2

  • Exercise. Consider the example Datalog program from the lecture:

(a) Father(alice,bob) (b) Mother(alice,carla) (c) Mother(evan,carla) (d) Father(carla,david)

Parent(x,y) ← Father(x,y)

(1)

Parent(x,y) ← Mother(x,y)

(2)

Ancestor(x,y) ← Parent(x,y)

(3)

Ancestor(x,z) ← Parent(x,y) ∧ Ancestor(y,z)

(4)

SameGeneration(x,x) ←

(5)

SameGeneration(x,y) ← Parent(x,v) ∧ Parent(y,w) ∧ SameGeneration(v,w)

(6)

  • 1. Give a proof tree for SameGeneration(evan, alice).
  • 2. Compute the sets T 0

P, T 1 P, T 2 P, . . . When is the fixed point reached?

Solution. 2. T 0

P = ∅

T 1

P = { Father(alice,bob), Mother(alice,carla), Mother(evan,carla), Father(carla,david) }

T 2

P = T 1 P ∪ { Parent(alice,bob), Parent(alice,carla), Parent(evan,carla), Parent(carla,david), SameGeneration(alice,alice), SameGeneration(bob,bob), SameGeneration(carla,carla), SameGeneration(david,david), SameGeneration(evan,evan) }

T 3

P = T 2 P ∪ { Ancestor(alice,bob), Ancestor(alice,carla), Ancestor(evan,carla), Ancestor(carla,david), SameGeneration(alice,evan), SameGeneration(evan,alice) }

T 4

P = T 3 P ∪ { Ancestor(alice,david), Ancestor(evan,david) } = T 5 P = T ∞ P

14 / 47

slide-15
SLIDE 15

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

15 / 47

slide-16
SLIDE 16

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution.

16 / 47

slide-17
SLIDE 17

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution. 1. Reachable(x, y) ← e(x, y, v) Reachable(x, z) ← e(x, y, v) ∧ Reachable(y, z) Ans(x) ← Reachable(n, x)

17 / 47

slide-18
SLIDE 18

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution.

  • 2. Not expressible, since Datalog is monotone: any query that is true for some set of ground facts I is also true for

every set of ground facts J ⊇ I, but the query is true on I = { e(n, n, a) }, but not on J = I ∪ { e(m, m, b) }.

18 / 47

slide-19
SLIDE 19

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution. 3. Reachable(x, y) ← e(x, y, v) Reachable(x, z) ← e(x, y, v) ∧ Reachable(y, z) Ans() ← Reachable(x, x)

19 / 47

slide-20
SLIDE 20

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution. 4. Reachable(x, y) ← e(x, y, v) Reachable(x, z) ← e(x, y, a), Reachable(y, w), e(w, z, a) Reachable(x, z) ← e(x, y, b), Reachable(y, w), e(w, z, b) Ans() ← Reachable(x, y)

20 / 47

slide-21
SLIDE 21

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution.

  • 5. Not expressible; consider I = { e(n, 1, a), e(1, 2, a) } and J = I ∪ { e(2, n, a) }.

21 / 47

slide-22
SLIDE 22

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution.

  • 6. Not expressible; consider I = { e(n, 1, a), e(1, 2, a) } and J = I ∪ { e(2, n, a) }.

22 / 47

slide-23
SLIDE 23

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution. 7. Reachable(x, y) ← e(x, y, b) Reachable(x, z) ← e(x, y, a), e(y, z, a) Reachable(x, z) ← e(x, y, a), Reachable(y, w), e(w, z, a) Reachable(x, z) ← Reachable(x, y), Reachable(y, z) Ans(x, y) ← Reachable(x, y)

23 / 47

slide-24
SLIDE 24

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution. 8. Reachable(x, z) ← e(x, y, a), e(y, z, b) Reachable(x, z) ← e(x, y, b), e(y, z, a) Reachable(x, z) ← Reachable(x, y), Reachable(y, z) Ans(x, y) ← Reachable(x, y)

24 / 47

slide-25
SLIDE 25

Exercise 3

  • Exercise. Consider databases that encode a labelled, directed graph by means of a ternary EDB predicate e (“edge”).

The first two parameters are the source and target nodes of the edge, while the third parameter is its label. For example, the edge m

a

− → n would be represented by the fact e(m, n, a). Moreover, assume that only constants a and b are used as labels. Can you express the following queries using Datalog?

  • 1. “Which nodes in the graph are reachable from the node n?”
  • 2. “Are all nodes of the graph reachable from the node n?”
  • 3. “Does the graph have a directed cycle?”
  • 4. “Does the graph have a path that is labelled by a palindrome?”

(a palindrome is a word that reads the same forwards and backwards)

  • 5. “Is the connected component that contains the node n 2-colourable?”
  • 6. “Is the graph 2-colourable?”
  • 7. “Which pairs of nodes are connected by a path with an even number of a labels?”
  • 8. “Which pairs of nodes are connected by a path with the same number of a and b labels?”
  • 9. “Is there a pair of nodes that is connected by two distinct paths?”

Solution.

  • 9. Not expressible, since Datalog is homomorphism-closed; consider I = { e(n, 1, a), e(1, m, a), e(n, 2, a), e(2, m, a) }

and J = { e(n, 1, a), e(1, m, a) } and the homomorphism ϕ : I → J = { 2 → 1 }.

25 / 47

slide-26
SLIDE 26

Exercise 4

  • Exercise. Consider a UCQ of the following form

(r11(x) ∧ r12(x)) ∨ . . . ∨ (rℓ1(x) ∧ rℓ2(x)) Find a Datalog query that expresses this UCQ. How many rules and how many additional IDB predicates does your solution use (depending on ℓ)?

26 / 47

slide-27
SLIDE 27

Exercise 4

  • Exercise. Consider a UCQ of the following form

(r11(x) ∧ r12(x)) ∨ . . . ∨ (rℓ1(x) ∧ rℓ2(x)) Find a Datalog query that expresses this UCQ. How many rules and how many additional IDB predicates does your solution use (depending on ℓ)? Solution.

27 / 47

slide-28
SLIDE 28

Exercise 4

  • Exercise. Consider a UCQ of the following form

(r11(x) ∧ r12(x)) ∨ . . . ∨ (rℓ1(x) ∧ rℓ2(x)) Find a Datalog query that expresses this UCQ. How many rules and how many additional IDB predicates does your solution use (depending on ℓ)? Solution. Ans(x) ← r11(x), r12(x) Ans(x) ← r21(x), r22(x) . . . . . . . . . Ans(x) ← rℓ1(x), rℓ2(x)

28 / 47

slide-29
SLIDE 29

Exercise 4

  • Exercise. Consider a UCQ of the following form

(r11(x) ∧ r12(x)) ∨ . . . ∨ (rℓ1(x) ∧ rℓ2(x)) Find a Datalog query that expresses this UCQ. How many rules and how many additional IDB predicates does your solution use (depending on ℓ)? Solution. Ans(x) ← r11(x), r12(x) Ans(x) ← r21(x), r22(x) . . . . . . . . . Ans(x) ← rℓ1(x), rℓ2(x) This solution uses ℓ rules and one additional IDB predicate.

29 / 47

slide-30
SLIDE 30

Exercise 5

  • Exercise. Consider a Datalog query of the following form:

A1(x) ← r11(x) . . . Aℓ(x) ← rℓ1(x) A1(x) ← r12(x) . . . Aℓ(x) ← rℓ2(x) Ans(x) ← A1(x), . . . , Aℓ(x) Find a UCQ that expresses this Datalog query. How many CQs does your solution contain (depending on ℓ)?

30 / 47

slide-31
SLIDE 31

Exercise 5

  • Exercise. Consider a Datalog query of the following form:

A1(x) ← r11(x) . . . Aℓ(x) ← rℓ1(x) A1(x) ← r12(x) . . . Aℓ(x) ← rℓ2(x) Ans(x) ← A1(x), . . . , Aℓ(x) Find a UCQ that expresses this Datalog query. How many CQs does your solution contain (depending on ℓ)? Solution.

31 / 47

slide-32
SLIDE 32

Exercise 5

  • Exercise. Consider a Datalog query of the following form:

A1(x) ← r11(x) . . . Aℓ(x) ← rℓ1(x) A1(x) ← r12(x) . . . Aℓ(x) ← rℓ2(x) Ans(x) ← A1(x), . . . , Aℓ(x) Find a UCQ that expresses this Datalog query. How many CQs does your solution contain (depending on ℓ)? Solution. ϕ11···1(x) = r11(x) ∧ r21(x) ∧ · · · ∧ rℓ1(x) ϕ21···1(x) = r12(x) ∧ r21(x) ∧ · · · ∧ rℓ1(x) ϕ12···1(x) = r11(x) ∧ r22(x) ∧ · · · ∧ rℓ1(x) ϕ22···1(x) = r12(x) ∧ r22(x) ∧ · · · ∧ rℓ1(x) . . . . . . . . . . . . ϕ22···2(x) = r12(x) ∧ r22(x) ∧ · · · ∧ rℓ2(x) ϕ =

  • i∈{ 11···1,21···1,...,22···2 } ϕi

32 / 47

slide-33
SLIDE 33

Exercise 5

  • Exercise. Consider a Datalog query of the following form:

A1(x) ← r11(x) . . . Aℓ(x) ← rℓ1(x) A1(x) ← r12(x) . . . Aℓ(x) ← rℓ2(x) Ans(x) ← A1(x), . . . , Aℓ(x) Find a UCQ that expresses this Datalog query. How many CQs does your solution contain (depending on ℓ)? Solution. ϕ11···1(x) = r11(x) ∧ r21(x) ∧ · · · ∧ rℓ1(x) ϕ21···1(x) = r12(x) ∧ r21(x) ∧ · · · ∧ rℓ1(x) ϕ12···1(x) = r11(x) ∧ r22(x) ∧ · · · ∧ rℓ1(x) ϕ22···1(x) = r12(x) ∧ r22(x) ∧ · · · ∧ rℓ1(x) . . . . . . . . . . . . ϕ22···2(x) = r12(x) ∧ r22(x) ∧ · · · ∧ rℓ2(x) ϕ =

  • i∈{ 11···1,21···1,...,22···2 } ϕi

This solution uses 2ℓ CQs.

33 / 47

slide-34
SLIDE 34

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

34 / 47

slide-35
SLIDE 35

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution.

35 / 47

slide-36
SLIDE 36

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅).

36 / 47

slide-37
SLIDE 37

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)).

37 / 47

slide-38
SLIDE 38

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P . 38 / 47

slide-39
SLIDE 39

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P . 39 / 47

slide-40
SLIDE 40

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P . 40 / 47

slide-41
SLIDE 41

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }. 41 / 47

slide-42
SLIDE 42

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }.

◮ But then H ∈ TP(T k

P ) = T k+1 P

⊆ T ∞

P , which contradicts H T ∞ P . 42 / 47

slide-43
SLIDE 43

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }.

◮ But then H ∈ TP(T k

P ) = T k+1 P

⊆ T ∞

P , which contradicts H T ∞ P .

2.

◮ First, note that TP is clearly monotone, i.e., that for sets I ⊆ J of ground facts, we have TP(I) ⊆ TP(J).

43 / 47

slide-44
SLIDE 44

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }.

◮ But then H ∈ TP(T k

P ) = T k+1 P

⊆ T ∞

P , which contradicts H T ∞ P .

2.

◮ First, note that TP is clearly monotone, i.e., that for sets I ⊆ J of ground facts, we have TP(I) ⊆ TP(J). ◮ Consider some fixed point F of TP. We show T i

P ⊆ F for all i ≥ 0. 44 / 47

slide-45
SLIDE 45

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }.

◮ But then H ∈ TP(T k

P ) = T k+1 P

⊆ T ∞

P , which contradicts H T ∞ P .

2.

◮ First, note that TP is clearly monotone, i.e., that for sets I ⊆ J of ground facts, we have TP(I) ⊆ TP(J). ◮ Consider some fixed point F of TP. We show T i

P ⊆ F for all i ≥ 0.

◮ Clearly, T 0

P = ∅ ⊆ F. 45 / 47

slide-46
SLIDE 46

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }.

◮ But then H ∈ TP(T k

P ) = T k+1 P

⊆ T ∞

P , which contradicts H T ∞ P .

2.

◮ First, note that TP is clearly monotone, i.e., that for sets I ⊆ J of ground facts, we have TP(I) ⊆ TP(J). ◮ Consider some fixed point F of TP. We show T i

P ⊆ F for all i ≥ 0.

◮ Clearly, T 0

P = ∅ ⊆ F.

◮ Assume that T i

P ⊆ F for some i ≥ 0. Then T i+1 P

= TP(T i

P) ⊆ TP(F) = F, by monotonicity and since F is a fixed point. 46 / 47

slide-47
SLIDE 47

Exercise 6

  • Exercise. Show that T ∞

P is the least fixed point of the TP operator.

  • 1. Show that it is a fixed point, i.e., that TP(T ∞

P ) = T ∞ P .

  • 2. Show that every fixed point of TP must contain every fact in T ∞

P .

Solution. 1.

◮ We first show that TP is extensive, i.e., that I ⊆ TP(I) for any set of ground facts I: Clearly ∅ ⊆ TP(∅). ◮ Assume that I ⊆ TP(I) for some set of ground facts I, and consider a ground fact H ∈ TP(I). Then there is some ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ I. Since I ⊆ TP(I), we have B1, . . . , Bn ∈ TP(I), and hence H ∈ TP(TP(I)). ◮ Thus, we have T i−1

P

⊆ T i

P, and, in particular, TP(T ∞ P ) ⊇ T ∞ P .

◮ Assume that we have some ground fact H ∈ TP(T ∞

P ), but H T ∞ P .

◮ Then there is a ground rule H ← B1, . . . , Bn ∈ ground(P) with B1, . . . , Bn ∈ T ∞

P .

◮ Since T ∞

P = i≥0 T i P, there are i1, . . . , in with Bij ∈ T ij P , and thus B1, . . . , Bn ∈ T k P with k = max{ i1, . . . , in }.

◮ But then H ∈ TP(T k

P ) = T k+1 P

⊆ T ∞

P , which contradicts H T ∞ P .

2.

◮ First, note that TP is clearly monotone, i.e., that for sets I ⊆ J of ground facts, we have TP(I) ⊆ TP(J). ◮ Consider some fixed point F of TP. We show T i

P ⊆ F for all i ≥ 0.

◮ Clearly, T 0

P = ∅ ⊆ F.

◮ Assume that T i

P ⊆ F for some i ≥ 0. Then T i+1 P

= TP(T i

P) ⊆ TP(F) = F, by monotonicity and since F is a fixed point.

◮ But then T i

P ⊆ F for all i ≥ 0, and hence also T ∞ P = i≥0 T i P ⊆ F. 47 / 47