200

# Factor Oracle for Machine Improvisation ## Jaime Arias Almeida

September 19, 2016

## Transcript

1. ### Factor Oracle for Machine Improvisation Jaime Arias Université de Bordeaux,

LaBRI, UMR 5800 Inria - Bordeaux Sud-Ouest Septembre 2016

3. ### Preliminaries Word A word s is a finite sequence s

= s1 s2 ... sm of length |s| = m on a finite alphabet Σ.  # # +  # + /  # + s = Factor A word x ∈ Σ∗ is a factor of s if and only if s can be written s = uxv with u, v ∈ Σ∗. Given integers i, j where 1 ≤ i ≤ j ≤ m, we denote a factor of s as s[i ... j] = si si+1 ... sj .  # # +  # + /  # + s = s[3, 5] Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 1/10 1/10
4. ### Preliminaries Prefix A factor x of s is a prefix

of s if s = xu with u ∈ Σ∗. The ith prefix of s, denoted prefs (i), is the prefix s[1 ... i].  # # +  # + /  # + s = prefs (4) Suffix A factor x of s is a suffix of s if s = ux with u ∈ Σ∗. The ith suffix of s, denoted suﬀs (i), is the suffix s[i ... m].  # # +  # + /  # + s = suﬀs (6) Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 2/10 2/10
5. ### Preliminaries Longest Repeated Suffix (LRS) A factor x of s

is the longest repeated suffix of s if x is a suffix of s and |x| is maximal.  # # +  # + /  # + s = lrs(s) Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 3/10 3/10

7. ### Factor Oracle Overview 0 1 a 0 2 b 0

3 b 1 4 c 0 5 a 1 6 b 2 7 c 2 8 d 0 9 a 1 10 b 2 11 c 3 b c c d d Forward Links Suffix Links Factor Oracle The factor oracle of a word s of length m is a deterministic finite automaton (Q, q0 , F, δ) where Q = {0, 1, ... , m} is the set of states, q0 = 0 is the starting state, F = Q is the set of terminal states and δ is the transition function. Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 4/10 4/10
8. ### Factor Oracle Overview 0 1 a 0 2 b 0

3 b 1 4 c 0 5 a 1 6 b 2 7 c 2 8 d 0 9 a 1 10 b 2 11 c 3 b c c d d Forward Links Suffix Links Suffix Link The suffix link of a state i of the factor oracle of a word s, is equal to the state in which the longest repeated suffix (lrs) of s[1 ... i] is recognized. Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 4/10 4/10
9. ### Factor Oracle Overview 0 1 a 0 2 b 0

3 b 1 4 c 0 5 a 1 6 b 2 7 c 2 8 d 0 9 a 1 10 b 2 11 c 3 b c c d d Suffix Links • s = abbcabcdabc Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 5/10 5/10
10. ### Factor Oracle Overview 0 1 a 0 2 b 0

3 b 1 4 c 0 5 a 1 6 b 2 7 c 2 8 d 0 9 a 1 10 b 2 11 c 3 b c c d d Suffix Links • s = abbcabcdabc • lrs(s) = abc Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 5/10 5/10
11. ### Factor Oracle Overview 0 1 a 0 2 b 0

3 b 1 4 c 0 5 a 1 6 b 2 7 c 2 8 d 0 9 a 1 10 b 2 11 c 3 b c c d d Suffix Links • s = abbcabcdabc • lrs(s) = abc • S(11) = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 5/10 5/10
12. ### Factor Oracle Algorithm - Construction Algorithm 1 Construction of a

Factor Oracle 1: function FactorOracle(p = p1p2 ... pm ) 2: Create a new oracle P with an initial state 0 3: SP (0) ← −1 4: for i ← 1, m do 5: Oracle(p = p1p2 ... pi ) ← AddLetter(Oracle(p = p1p2 ... pi−1), pi ) 6: end for 7: return Oracle(p = p1p2 ... pm) 8: end function Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 6/10 6/10
13. ### Factor Oracle Algorithm - Construction Algorithm 1 Construction of a

Factor Oracle 1: function FactorOracle(p = p1p2 ... pm ) 2: Create a new oracle P with an initial state 0 3: SP (0) ← −1 4: for i ← 1, m do 5: Oracle(p = p1p2 ... pi ) ← AddLetter(Oracle(p = p1p2 ... pi−1), pi ) 6: end for 7: return Oracle(p = p1p2 ... pm) 8: end function  # # +  # + /  # + p = Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 6/10 6/10
14. ### Factor Oracle Algorithm - Construction Algorithm 1 Construction of a

Factor Oracle 1: function FactorOracle(p = p1p2 ... pm ) 2: Create a new oracle P with an initial state 0 3: SP (0) ← −1 4: for i ← 1, m do 5: Oracle(p = p1p2 ... pi ) ← AddLetter(Oracle(p = p1p2 ... pi−1), pi ) 6: end for 7: return Oracle(p = p1p2 ... pm) 8: end function  # # +  # + /  # + p = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 6/10 6/10
15. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
16. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 0 m = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
17. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  0 m = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
18. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  0 m = 0 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
19. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  0 m = 0 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
20. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  0 m = 0 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
21. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  0 m = 0 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
22. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  0 0 m = 0 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
23. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  0 0 m = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
24. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 0 0 m = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
25. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 0 0 m = 1 π1 = 1 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
26. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 0 0 m = 1 π1 = 1 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
27. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 m = 1 π1 = 1 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
28. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 m = 1 π1 = 0 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
29. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 m = 1 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
30. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 m = 1 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
31. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 m = 1 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
32. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 0 m = 1 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
33. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # b 0 0 0 m = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
34. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 m = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
35. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 m = 2 π1 = 2 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
36. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 m = 2 π1 = 2 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
37. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 m = 2 π1 = 2 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
38. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 m = 2 π1 = 2 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
39. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 1 m = 2 π1 = 2 k = 0 lcs(2, 1) = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
40. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # b 0 0 0 1 m = 3 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
41. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b 0 0 0 1 m = 3 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
42. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b 0 0 0 1 m = 3 π1 = 3 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
43. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b 0 0 0 1 m = 3 π1 = 3 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
44. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c 0 0 0 1 m = 3 π1 = 3 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
45. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c 0 0 0 1 m = 3 π1 = 2 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
46. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c 0 0 0 1 m = 3 π1 = 2 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
47. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 m = 3 π1 = 2 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
48. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 m = 3 π1 = 0 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
49. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 m = 3 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
50. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 m = 3 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
51. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 m = 3 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
52. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 0 m = 3 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
53. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + b c c 0 0 0 1 0 m = 4 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
54. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 m = 4 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
55. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 m = 4 π1 = 4 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
56. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 m = 4 π1 = 4 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
57. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 m = 4 π1 = 4 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
58. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 m = 4 π1 = 4 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
59. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 1 m = 4 π1 = 4 k = 0 lcs(4, 0) = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
60. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  b c c 0 0 0 1 0 1 m = 5 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
61. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 m = 5 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
62. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 m = 5 π1 = 5 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
63. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 m = 5 π1 = 5 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
64. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 m = 5 π1 = 5 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
65. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 m = 5 π1 = 5 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
66. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 2 m = 5 π1 = 5 k = 1 lcs(5, 1) = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
67. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # b c c 0 0 0 1 0 1 2 m = 6 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
68. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 m = 6 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
69. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 m = 6 π1 = 6 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
70. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 m = 6 π1 = 6 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
71. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 m = 6 π1 = 6 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
72. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 m = 6 π1 = 6 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
73. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 2 m = 6 π1 = 6 k = 2 lcs(6, 3) = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
74. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + b c c 0 0 0 1 0 1 2 2 m = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
75. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c 0 0 0 1 0 1 2 2 m = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
76. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c 0 0 0 1 0 1 2 2 m = 7 π1 = 7 k = 4 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
77. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c 0 0 0 1 0 1 2 2 m = 7 π1 = 7 k = 4 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
78. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d 0 0 0 1 0 1 2 2 m = 7 π1 = 7 k = 4 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
79. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d 0 0 0 1 0 1 2 2 m = 7 π1 = 4 k = 4 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
80. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d 0 0 0 1 0 1 2 2 m = 7 π1 = 4 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
81. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 m = 7 π1 = 4 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
82. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 m = 7 π1 = 0 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
83. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 m = 7 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
84. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 m = 7 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
85. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 m = 7 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
86. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: Spσ ← 0 5: lrspσ ← 0 6: else 7: ... 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 0 m = 7 π1 = 0 k = −1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
87. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / b c c d d 0 0 0 1 0 1 2 2 0 m = 8 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
88. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 m = 8 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
89. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 m = 8 π1 = 8 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
90. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 m = 8 π1 = 8 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
91. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 m = 8 π1 = 8 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
92. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 m = 8 π1 = 8 k = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
93. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 1 m = 8 π1 = 8 k = 0 lcs(8, 0) = 0 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
94. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  b c c d d 0 0 0 1 0 1 2 2 0 1 m = 9 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
95. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 m = 9 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
96. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 m = 9 π1 = 9 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
97. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 m = 9 π1 = 9 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
98. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 m = 9 π1 = 9 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
99. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 m = 9 π1 = 9 k = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
100. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 9 π1 = 9 k = 1 lcs(9, 1) = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
101. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 10 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
102. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 10 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
103. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: Create state m + 1 3: Create a new transition from m to m + 1 labeled by σ ◃ δ(m, σ) = m + 1 4: π1 ← m 5: k ← Sp(m) 6: ... 7: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 10 π1 = 10 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
104. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: while k > −1 and there is no transition from k by σ do 4: Create a new transition from k to m + 1 by σ ◃ δ(k, σ) = m + 1 5: π1 ← k 6: k ← Sp(k) 7: end while 8: ... 9: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 10 π1 = 10 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
105. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 10 π1 = 10 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
106. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 m = 10 π1 = 10 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
107. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 k = 2 lcs(10, 3) = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
108. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: if k = −1 then 4: ... 5: else 6: Spσ ← state that leads the transition from k by σ 7: lrspσ ← LengthCommonSuffix(π1, S(m + 1) − 1) + 1 8: end if 9: ... 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
109. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: k ← FindBetter(m + 1, p[m + 1 − lrs(m + 1)]) 4: if k ̸= 0 then 5: lrspσ ← lrs(m + 1) + 1 6: Spσ ← k 7: end if 8: T(Spσ ) ← T(S(m + 1)) ∪ {m + 1} ◃ T(i) = {j | S(j) = i ∧ i < j ≤ m} 9: return Oracle(p = p1p2 ... pmσ) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 k = 2 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
110. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: k ← FindBetter(m + 1, p[m + 1 − lrs(m + 1)]) 4: if k ̸= 0 then 5: lrspσ ← lrs(m + 1) + 1 6: Spσ ← k 7: end if 8: T(Spσ ) ← T(S(m + 1)) ∪ {m + 1} ◃ T(i) = {j | S(j) = i ∧ i < j ≤ m} 9: return Oracle(p = p1p2 ... pmσ) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 k = 7 FindBetter(11, a) = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
111. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: k ← FindBetter(m + 1, p[m + 1 − lrs(m + 1)]) 4: if k ̸= 0 then 5: lrspσ ← lrs(m + 1) + 1 6: Spσ ← k 7: end if 8: T(Spσ ) ← T(S(m + 1)) ∪ {m + 1} ◃ T(i) = {j | S(j) = i ∧ i < j ≤ m} 9: return Oracle(p = p1p2 ... pmσ) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 3 m = 10 π1 = 10 k = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
112. ### Factor Oracle Algorithm - Construction Algorithm 2 Incremental update of

Factor Oracle 1: function AddLetter(Oracle(p = p1, p2 ... pm), σ) 2: ... 3: k ← FindBetter(m + 1, p[m + 1 − lrs(m + 1)]) 4: if k ̸= 0 then 5: lrspσ ← lrs(m + 1) + 1 6: Spσ ← k 7: end if 8: T(Spσ ) ← T(S(m + 1)) ∪ {m + 1} ◃ T(i) = {j | S(j) = i ∧ i < j ≤ m} 9: return Oracle(p = p1p2 ... pmσ) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 3 m = 10 π1 = 10 k = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 7/10 7/10
113. ### Factor Oracle Algorithm - Construction Algorithm 3 Length Common Suffix

Algorithm 1: function LengthCommonSuffix(π1, π2 ) 2: if S(π1) = π2 then 3: return lrs(π1) 4: else 5: while S(π1) ̸= S(π2) do 6: π2 ← S(π2) 7: end while 8: end if 9: return min(lrs(π1), lrs(π2)) 10: end function Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 8/10 8/10
114. ### Factor Oracle Algorithm - Construction Algorithm 3 Length Common Suffix

Algorithm 1: function LengthCommonSuffix(π1, π2 ) 2: if S(π1) = π2 then 3: return lrs(π1) 4: else 5: while S(π1) ̸= S(π2) do 6: π2 ← S(π2) 7: end while 8: end if 9: return min(lrs(π1), lrs(π2)) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 π2 = 3 lcs(10, 3) = Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 8/10 8/10
115. ### Factor Oracle Algorithm - Construction Algorithm 3 Length Common Suffix

Algorithm 1: function LengthCommonSuffix(π1, π2 ) 2: if S(π1) = π2 then 3: return lrs(π1) 4: else 5: while S(π1) ̸= S(π2) do 6: π2 ← S(π2) 7: end while 8: end if 9: return min(lrs(π1), lrs(π2)) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 π2 = 3 lcs(10, 3) = Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 8/10 8/10
116. ### Factor Oracle Algorithm - Construction Algorithm 3 Length Common Suffix

Algorithm 1: function LengthCommonSuffix(π1, π2 ) 2: if S(π1) = π2 then 3: return lrs(π1) 4: else 5: while S(π1) ̸= S(π2) do 6: π2 ← S(π2) 7: end while 8: end if 9: return min(lrs(π1), lrs(π2)) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 π2 = 3 lcs(10, 3) = Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 8/10 8/10
117. ### Factor Oracle Algorithm - Construction Algorithm 3 Length Common Suffix

Algorithm 1: function LengthCommonSuffix(π1, π2 ) 2: if S(π1) = π2 then 3: return lrs(π1) 4: else 5: while S(π1) ̸= S(π2) do 6: π2 ← S(π2) 7: end while 8: end if 9: return min(lrs(π1), lrs(π2)) 10: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 π1 = 10 π2 = 3 lcs(10, 3) = 1 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 8/10 8/10
118. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(i) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
119. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
120. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 i = 11 σ = a FindBetter(11, a) = Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
121. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 i = 11 σ = a FindBetter(11, a) = Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
122. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 i = 11 σ = a FindBetter(11, a) = T(S(11)) = {7} Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
123. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 i = 11 σ = a FindBetter(11, a) = T(S(11)) = {7} j = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
124. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 i = 11 σ = a FindBetter(11, a) = T(S(11)) = {7} j = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
125. ### Factor Oracle Algorithm - Construction Algorithm 4 Find Better Algorithm

1: function FindBetter(i, σ) 2: for all the elements j of T(S(i)) in increasing order do 3: if lrs(j) = lrs(i) and p[j − lrs(i)] = σ then 4: return j 5: end if 6: end for 7: return 0 8: end function  # # +  # + /  # + p = 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 m = 10 i = 11 σ = a FindBetter(11, a) = 7 T(S(11)) = {7} j = 7 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 9/10 9/10
126. ### Factor Oracle Algorithm - Improvisation Algorithm 5 FO-Generate function Require:

Oracle P = p1, p2 ... pm in active state i, a generated sequence v, and a continuation parameter 0 ≤ q ≤ 1. 1: Generate uniformly distribute random number u 2: if u < q then 3: i ← i + 1 v ← vpi 4: else 5: Choose at random a symbol σ ∈ {σj | δ(S(i), σj ) ̸= ⊥} 6: i ← δ(S(i), σ) v ← vσ 7: end if 8: return Sequence v Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 10/10 10/10
127. ### Factor Oracle Algorithm - Improvisation Algorithm 5 FO-Generate function Require:

Oracle P = p1, p2 ... pm in active state i, a generated sequence v, and a continuation parameter 0 ≤ q ≤ 1. 1: Generate uniformly distribute random number u 2: if u < q then 3: i ← i + 1 v ← vpi 4: else 5: Choose at random a symbol σ ∈ {σj | δ(S(i), σj ) ̸= ⊥} 6: i ← δ(S(i), σ) v ← vσ 7: end if 8: return Sequence v 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 v = cabc q = 0.5 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 10/10 10/10
128. ### Factor Oracle Algorithm - Improvisation Algorithm 5 FO-Generate function Require:

Oracle P = p1, p2 ... pm in active state i, a generated sequence v, and a continuation parameter 0 ≤ q ≤ 1. 1: Generate uniformly distribute random number u 2: if u < q then 3: i ← i + 1 v ← vpi 4: else 5: Choose at random a symbol σ ∈ {σj | δ(S(i), σj ) ̸= ⊥} 6: i ← δ(S(i), σ) v ← vσ 7: end if 8: return Sequence v 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 v = cabc q = 0.5 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 10/10 10/10
129. ### Factor Oracle Algorithm - Improvisation Algorithm 5 FO-Generate function Require:

Oracle P = p1, p2 ... pm in active state i, a generated sequence v, and a continuation parameter 0 ≤ q ≤ 1. 1: Generate uniformly distribute random number u 2: if u < q then 3: i ← i + 1 v ← vpi 4: else 5: Choose at random a symbol σ ∈ {σj | δ(S(i), σj ) ̸= ⊥} 6: i ← δ(S(i), σ) v ← vσ 7: end if 8: return Sequence v 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 v = cabc q = 0.5 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 10/10 10/10
130. ### Factor Oracle Algorithm - Improvisation Algorithm 5 FO-Generate function Require:

Oracle P = p1, p2 ... pm in active state i, a generated sequence v, and a continuation parameter 0 ≤ q ≤ 1. 1: Generate uniformly distribute random number u 2: if u < q then 3: i ← i + 1 v ← vpi 4: else 5: Choose at random a symbol σ ∈ {σj | δ(S(i), σj ) ̸= ⊥} 6: i ← δ(S(i), σ) v ← vσ 7: end if 8: return Sequence v 0 1  2 # 3 # 4 + 5  6 # 7 + 8 / 9  10 # 11 + b c c d d 0 0 0 1 0 1 2 2 0 1 2 2 v = cabca q = 0.5 Jaime Arias - Equipe PoSET, Inria Bordeaux Sud-Ouest, LaBRI Factor Oracle for Machine Improvisation 10/10 10/10

132. ### Factor Oracle for Machine Improvisation Jaime Arias Université de Bordeaux,

LaBRI, UMR 5800 Inria - Bordeaux Sud-Ouest Septembre 2016
133. ### References Gerard Assayag and Shlomo Dubnov. Using Factor Oracles for

Machine Improvisation. Soft Computing, 8(9), sep 2004. Shlomo Dubnov, Gérard Assayag, and Arshia Cont. Audio Oracle: a New Algorithm for Fast Learning of audio Structures. In International Computer Music Conference, 2007. Arnaud Lefebvre, Thierry Lecroq, and Joël Alexandre. An Improved Algorithm for Finding Longest Repeats with a Modified Factor Oracle. J. Autom. Lang. Comb., 8(4):647–657, 2003. Greg Surges and Shlomo Dubnov. Feature Selection and Composition Using PyOracle. In AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment, 2013.