Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Erice 2005, the Analysis of Patterns. Grammatical Inference 1 Colin de la Higuera Grammatical inference: techniques and algorithms.

Similar presentations


Presentation on theme: "1 Erice 2005, the Analysis of Patterns. Grammatical Inference 1 Colin de la Higuera Grammatical inference: techniques and algorithms."— Presentation transcript:

1 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 1 Colin de la Higuera Grammatical inference: techniques and algorithms

2 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 2 Acknowledgements Laurent Miclet, Tim Oates, Jose Oncina, Rafael Carrasco, Paco Casacuberta, Pedro Cruz, Rémi Eyraud, Philippe Ezequel, Henning Fernau, Jean-Christophe Janodet, Thierry Murgue, Frédéric Tantini, Franck Thollard, Enrique Vidal,... … and a lot of other people to whom I am grateful

3 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 3 Outline 1 An introductory example 2 About grammatical inference 3 Some specificities of the task 4 Some techniques and algorithms 5 Open issues and questions

4 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 4 1 How do we learn languages? A very simple example

5 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 5 The problem: You are in an unknown city and have to eat. You therefore go to some selected restaurants. Your goal is therefore to build a model of the city (a map).

6 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 6 The data Up Down Right Left Left  Restaurant Down Down Right  Not a restaurant Left Down  Restaurant

7 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 7 Hopefully something like this: N N R u u d r d d,l u,r R

8 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 8 R R R R R N N N N d d rd N d u u u u d u u d

9 9 9 Further arguments (1) How did we get hold of the data? –Random walks –Following someone someone knowledgeable Someone trying to lose us Someone on a diet –Exploring

10 10 Erice 2005, the Analysis of Patterns. Grammatical Inference 10 Further arguments (2) Can we not have better information (for example the names of the restaurants)? But then we may only have the information about the routes to restaurants (not to the “non restaurants”)…

11 11 Erice 2005, the Analysis of Patterns. Grammatical Inference 11 Further arguments (3) What if instead of getting the information “Elimo” or “restaurant”, I get the information “good meal” or “7/10”? Reinforcement learning: POMDP

12 12 Erice 2005, the Analysis of Patterns. Grammatical Inference 12 Further arguments (4) Where is my algorithm to learn these things? Perhaps should I consider several algorithms for the different types of data?

13 13 Erice 2005, the Analysis of Patterns. Grammatical Inference 13 Further arguments (5) What can I say about the result? What can I say about the algorithm?

14 14 Erice 2005, the Analysis of Patterns. Grammatical Inference 14 Further arguments (6) What if I want something richer than an automaton? –A context-free grammar –A transducer –A tree automaton…

15 15 Erice 2005, the Analysis of Patterns. Grammatical Inference 15 Further arguments (7) Why do I want something as rich as an automaton? What about –A simple pattern? –Some SVM obtained from features over the strings? –A neural network that would allow me to know if some path will bring me or not to a restaurant, with high probability?

16 16 Erice 2005, the Analysis of Patterns. Grammatical Inference 16 Our goal/idea Old Greeks: A whole is more than the sum of all parts Gestalt theory A whole is different than the sum of all parts

17 17 Erice 2005, the Analysis of Patterns. Grammatical Inference 17 Better said There are cases where the data cannot be analyzed by considering it in bits There are cases where intelligibility of the pattern is important

18 18 Erice 2005, the Analysis of Patterns. Grammatical Inference 18 Nothing Lots What do people know about formal language theory?

19 19 Erice 2005, the Analysis of Patterns. Grammatical Inference 19 A small reminder on formal language theory Chomsky hierarchy + and – of grammars

20 20 Erice 2005, the Analysis of Patterns. Grammatical Inference 20 A crash course in Formal language theory Symbols Strings Languages Chomsky hierarchy Stochastic languages

21 21 Erice 2005, the Analysis of Patterns. Grammatical Inference 21 Symbols are taken from some alphabet  Strings are sequences of symbols from 

22 22 Erice 2005, the Analysis of Patterns. Grammatical Inference 22 Languages are sets of strings over  Languages are subsets of  *

23 23 Erice 2005, the Analysis of Patterns. Grammatical Inference 23 Special languages Are recognised by finite state automata Are generated by grammars

24 24 Erice 2005, the Analysis of Patterns. Grammatical Inference 24 a b a b a b DFA: Deterministic Finite State Automaton

25 25 Erice 2005, the Analysis of Patterns. Grammatical Inference 25 a b a b a b abab  L

26 26 Erice 2005, the Analysis of Patterns. Grammatical Inference 26 What is a context free grammar? A 4-tuple (Σ, S, V, P) such that: –Σ is the alphabet; –V is a finite set of non terminals; –S is the start symbol; –P  V  (V  Σ) * is a finite set of rules.

27 27 Erice 2005, the Analysis of Patterns. Grammatical Inference 27 Example of a grammar The Dyck 1 grammar –(Σ, S, V, P) –Σ = {a, b} –V = {S} –P = {S  aSbS, S  }

28 28 Erice 2005, the Analysis of Patterns. Grammatical Inference 28 Derivations and derivation trees S  aSbS  aaSbSbS  aabSbS  aabbS  aabb a a b b S SS S S

29 29 Erice 2005, the Analysis of Patterns. Grammatical Inference 29 Chomsky Hierarchy Level 0: no restriction Level 1: context-sensitive Level 2: context-free Level 3: regular

30 30 Erice 2005, the Analysis of Patterns. Grammatical Inference 30 Chomsky Hierarchy Level 0: Whatever Turing machines can do Level 1: –{a n b n c n : n   } –{a n b m c n d m : n,m   } –{uu: u  *} Level 2: context-free –{a n b n : n   } –brackets Level 3: regular –Regular expressions (GREP)

31 31 Erice 2005, the Analysis of Patterns. Grammatical Inference 31 The membership problem Level 0: undecidable Level 1: decidable Level 2: polynomial Level 3: linear

32 32 Erice 2005, the Analysis of Patterns. Grammatical Inference 32 The equivalence problem Level 0: undecidable Level 1: undecidable Level 2: undecidable Level 3: Polynomial only when the representation is DFA.

33 33 Erice 2005, the Analysis of Patterns. Grammatical Inference 33 b b a a a b PFA: Probabilistic Finite (state) Automaton

34 34 Erice 2005, the Analysis of Patterns. Grammatical Inference 34 0.1 0.3 a b a b a b 0.65 0.35 0.9 0.7 0.3 0.7 DPFA: Deterministic Probabilistic Finite (state) Automaton

35 35 Erice 2005, the Analysis of Patterns. Grammatical Inference 35 What is nice with grammars? Compact representation Recursivity Says how a string belongs, not just if it belongs Graphical representations (automata, parse trees)

36 36 Erice 2005, the Analysis of Patterns. Grammatical Inference 36 What is not so nice with grammars? Even the easiest class (level 3) contains SAT, Boolean functions, parity functions… Noise is very harmful: –Think about putting edit noise to language {w: |w| a =0[2]  |w| b =0[2]}

37 37 Erice 2005, the Analysis of Patterns. Grammatical Inference 37 2 Specificities of grammatical inference Grammatical inference consists (roughly) in finding the (a) grammar or automaton that has produced a given set of strings (sequences, trees, terms, graphs).

38 38 Erice 2005, the Analysis of Patterns. Grammatical Inference 38 Inductive InferencePattern Recognition Grammatical Inference The field Machine Learning Computational linguisticsComputational biologyWeb technologies

39 39 Erice 2005, the Analysis of Patterns. Grammatical Inference 39 The data Strings, trees, terms, graphs Structural objects Basically the same gap of information as in programming between tables/arrays and data structures

40 40 Erice 2005, the Analysis of Patterns. Grammatical Inference 40 Alternatives to grammatical inference 2 steps: –Extract features from the strings –Use a very good method over  n.

41 41 Erice 2005, the Analysis of Patterns. Grammatical Inference 41 Examples of strings A string in Gaelic and its translation to English: Tha thu cho duaichnidh ri èarr àirde de a’ coisich deas damh You are as ugly as the north end of a southward traveling ox

42 42 Erice 2005, the Analysis of Patterns. Grammatical Inference 42

43 43 Erice 2005, the Analysis of Patterns. Grammatical Inference 43

44 44 Erice 2005, the Analysis of Patterns. Grammatical Inference 44 >A BAC=41M14 LIBRARY=CITB_978_SKB AAGCTTATTCAATAGTTTATTAAACAGCTTCTTAAATAGGATATAAGGCAGTGCCATGTA GTGGATAAAAGTAATAATCATTATAATATTAAGAACTAATACATACTGAACACTTTCAAT GGCACTTTACATGCACGGTCCCTTTAATCCTGAAAAAATGCTATTGCCATCTTTATTTCA GAGACCAGGGTGCTAAGGCTTGAGAGTGAAGCCACTTTCCCCAAGCTCACACAGCAAAGA CACGGGGACACCAGGACTCCATCTACTGCAGGTTGTCTGACTGGGAACCCCCATGCACCT GGCAGGTGACAGAAATAGGAGGCATGTGCTGGGTTTGGAAGAGACACCTGGTGGGAGAGG GCCCTGTGGAGCCAGATGGGGCTGAAAACAAATGTTGAATGCAAGAAAAGTCGAGTTCCA GGGGCATTACATGCAGCAGGATATGCTTTTTAGAAAAAGTCCAAAAACACTAAACTTCAA CAATATGTTCTTTTGGCTTGCATTTGTGTATAACCGTAATTAAAAAGCAAGGGGACAACA CACAGTAGATTCAGGATAGGGGTCCCCTCTAGAAAGAAGGAGAAGGGGCAGGAGACAGGA TGGGGAGGAGCACATAAGTAGATGTAAATTGCTGCTAATTTTTCTAGTCCTTGGTTTGAA TGATAGGTTCATCAAGGGTCCATTACAAAAACATGTGTTAAGTTTTTTAAAAATATAATA AAGGAGCCAGGTGTAGTTTGTCTTGAACCACAGTTATGAAAAAAATTCCAACTTTGTGCA TCCAAGGACCAGATTTTTTTTAAAATAAAGGATAAAAGGAATAAGAAATGAACAGCCAAG TATTCACTATCAAATTTGAGGAATAATAGCCTGGCCAACATGGTGAAACTCCATCTCTAC TAAAAATACAAAAATTAGCCAGGTGTGGTGGCTCATGCCTGTAGTCCCAGCTACTTGCGA GGCTGAGGCAGGCTGAGAATCTCTTGAACCCAGGAAGTAGAGGTTGCAGTAGGCCAAGAT GGCGCCACTGCACTCCAGCCTGGGTGACAGAGCAAGACCCTATGTCCAAAAAAAAAAAAA AAAAAAAGGAAAAGAAAAAGAAAGAAAACAGTGTATATATAGTATATAGCTGAAGCTCCC TGTGTACCCATCCCCAATTCCATTTCCCTTTTTTGTCCCAGAGAACACCCCATTCCTGAC TAGTGTTTTATGTTCCTTTGCTTCTCTTTTTAAAAACTTCAATGCACACATATGCATCCA TGAACAACAGATAGTGGTTTTTGCATGACCTGAAACATTAATGAAATTGTATGATTCTAT

45 45 Erice 2005, the Analysis of Patterns. Grammatical Inference 45

46 46 Erice 2005, the Analysis of Patterns. Grammatical Inference 46

47 47 Erice 2005, the Analysis of Patterns. Grammatical Inference 47

48 48 Erice 2005, the Analysis of Patterns. Grammatical Inference 48

49 49 Erice 2005, the Analysis of Patterns. Grammatical Inference 49 ]> Catullus II Gaius Valerius Catullus

50 50 Erice 2005, the Analysis of Patterns. Grammatical Inference 50

51 51 Erice 2005, the Analysis of Patterns. Grammatical Inference 51 A logic program learned by GIFT color_blind(Arg1) :- start(Arg1,X), p11(Arg1,X). start(X,X). p11(Arg1,P) :- mother(M,P),p4(Arg1, M). p4(Arg1,X) :- woman(X),father(F,X),p3(Arg1,F). p4(Arg1,X) :- woman(X),mother(M,X),p4(Arg1,M). p3(Arg1,X) :- man(X),color_blind(X).

52 52 Erice 2005, the Analysis of Patterns. Grammatical Inference 52 3 Hardness of the task –One thing is to build algorithms, another is to be able to state that it works. –Some questions: –Does this algorithm work? –Do I have enough learning data? –Do I need some extra bias? –Is this algorithm better than the other? –Is this problem easier than the other?

53 53 Erice 2005, the Analysis of Patterns. Grammatical Inference 53 Alternatives to answer these questions: –Use well admitted benchmarks –Build your own benchmarks –Solve a real problem –Prove things

54 54 Erice 2005, the Analysis of Patterns. Grammatical Inference 54 Use well admitted benchmarks yes: allows to compare no: many parameters problem: difficult to better (also, in GI, not that many about!)

55 55 Erice 2005, the Analysis of Patterns. Grammatical Inference 55 Build your own benchmarks yes: allows to progress no: against one-self problem: one invents the benchmark where one is best!

56 56 Erice 2005, the Analysis of Patterns. Grammatical Inference 56 Solve a real problem yes: it is the final goal no: we don’t always know why things work problem: how much pre- processing?

57 57 Erice 2005, the Analysis of Patterns. Grammatical Inference 57 Theory Because you may want to be able to say something more than « seems to work in practice ».

58 58 Erice 2005, the Analysis of Patterns. Grammatical Inference 58 Identification in the limit LPres  X X A class of languages A class of grammars G L A learner The naming function yields  f(  )=g(  )  yields(f)=yields(g) L (  (f) )= yields(f)

59 59 Erice 2005, the Analysis of Patterns. Grammatical Inference 59 f1f1 f2f2 h1h1 h2h2 fnfn hnhn fifi hihi  hn hn L ( hi )= L L is identifiable in the limit in terms of G from Pres iff  L  L,  f  Pres (L)

60 60 Erice 2005, the Analysis of Patterns. Grammatical Inference 60 No quería componer otro Quijote —lo cual es fácil— sino el Quijote. Inútil agregar que no encaró nunca una transcripción mecánica del original; no se proponía copiarlo. Su admirable ambición era producir unas páginas que coincidieran ­palabra por palabra y línea por línea­ con las de Miguel de Cervantes. […] “Mi empresa no es difícil, esencialmente” leo en otro lugar de la carta. “Me bastaría ser inmortal para llevarla a cabo.” Jorge Luis Borges(1899–1986) Pierre Menard, autor del Quijote (El jardín de senderos que se bifurcan) Ficciones

61 61 Erice 2005, the Analysis of Patterns. Grammatical Inference 61 4 Algorithmic ideas

62 62 Erice 2005, the Analysis of Patterns. Grammatical Inference 62 The space of GI problems Type of input (strings) Presentation of input (batch) Hypothesis space (subset of the regular grammars) Success criteria (identification in the limit)

63 63 Erice 2005, the Analysis of Patterns. Grammatical Inference 63 Types of input thecathatesthedogStrings: Structural Examples: catdogthe hates (+) (-) Graphs:

64 64 Erice 2005, the Analysis of Patterns. Grammatical Inference 64 Types of input - oracles Membership queries –Is string S in the target language? Equivalence queries –Is my hypothesis correct? –If not, provide counter example Subset queries –Is the language of my hypothesis a subset of the target language?

65 65 Erice 2005, the Analysis of Patterns. Grammatical Inference 65 Presentation of input Arbitrary order Shortest to longest All positive and negative examples up to some length Sampled according to some probability distribution

66 66 Erice 2005, the Analysis of Patterns. Grammatical Inference 66 Presentation of input Text presentation –A presentation of all strings in the target language Complete presentation (informant) –A presentation of all strings over the alphabet of the target language labeled as + or -

67 67 Erice 2005, the Analysis of Patterns. Grammatical Inference 67 Hypothesis space Regular grammars –A welter of subclasses Context free grammars –Fewer subclasses Hyper-edge replacement graph grammars

68 68 Erice 2005, the Analysis of Patterns. Grammatical Inference 68 Success criteria Identification in the limit –Text or informant presentation –After each example, learner guesses language –At some point, guess is correct and never changes PAC learning

69 69 Erice 2005, the Analysis of Patterns. Grammatical Inference 69 Theorem’s due to Gold The good news –Any recursively enumerable class of languages can be learned in the limit from an informant (Gold, 1967) The bad news –A language class is superfinite if it includes all finite languages and at least one infinite language –No superfinite class of languages can be learned in the limit from a text (Gold, 1967) –That includes regular and context- free

70 70 Erice 2005, the Analysis of Patterns. Grammatical Inference 70 A picture Little information A lot of information Poor languagesRich Languages Sub-classes of reg, from pos Mildly context sensitive, from queries DFA, from queries Context-free, from pos DFA, from pos+neg

71 71 Erice 2005, the Analysis of Patterns. Grammatical Inference 71 Algorithms RPNI K-Reversible GRIDS SEQUITUR L*

72 72 Erice 2005, the Analysis of Patterns. Grammatical Inference 72 4.1 RPNI Regular Positive and Negative Grammatical Inference Identifying regular languages in polynomial time Jose Oncina & Pedro García 1992

73 73 Erice 2005, the Analysis of Patterns. Grammatical Inference 73 It is a state merging algorithm; It identifies any regular language in the limit; It works in polynomial time; It admits polynomial charac- teristic sets.

74 74 Erice 2005, the Analysis of Patterns. Grammatical Inference 74 The algorithm function rmerge(A,p,q) A = merge(A,p,q) while  a , p,q  A (r,a), p  q do rmerge(A,p,q)

75 75 Erice 2005, the Analysis of Patterns. Grammatical Inference 75 A=PTA(X); Fr ={  (q 0,a): a  }; K ={q 0 }; While Fr  do choose q from Fr if  p  K: L(rmerge(A,p,q))  X-=  then A = rmerge(A,p,q) else K = K  {q} Fr = {  (q,a): q  K} – {K}

76 76 Erice 2005, the Analysis of Patterns. Grammatical Inference 76 X + ={, aaa, aaba, ababa, bb, bbaaa} a a a a b b b a a a b ab a X - ={aa, ab, aaaa, ba} 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

77 77 Erice 2005, the Analysis of Patterns. Grammatical Inference 77 Try to merge 2 and 1 a a a a b b b a a a b ab a X - ={aa, ab, aaaa, ba} 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

78 78 Erice 2005, the Analysis of Patterns. Grammatical Inference 78 Needs more merging for determinization a a a a b b b a a a b ab a X - ={aa, ab, aaaa, ba} 1,2 3 4 5 6 7 8 9 10 11 12 13 14 15

79 79 Erice 2005, the Analysis of Patterns. Grammatical Inference 79 But now string aaaa is accepted, so the merge must be rejected a b ba a a a b a X - ={aa, ab, aaaa, ba} 1,2,4,7 3,5,8 6 9, 11 10 12 13 14 15

80 80 Erice 2005, the Analysis of Patterns. Grammatical Inference 80 Try to merge 3 and 1 a a a a b b b a a a b ab a X - ={aa, ab, aaaa, ba} 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

81 81 Erice 2005, the Analysis of Patterns. Grammatical Inference 81 Requires to merge 6 with {1,3} a a a a b b a a a b ab a X - ={aa, ab, aaaa, ba} 1,3 2 4 5 6 7 8 9 10 11 12 13 14 15 b

82 82 Erice 2005, the Analysis of Patterns. Grammatical Inference 82 And now to merge 2 with 10 a a a a b a a a b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2 4 5 7 8 9 10 11 12 13 14 15 b

83 83 Erice 2005, the Analysis of Patterns. Grammatical Inference 83 And now to merge 4 with 13 a a a a b a b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4 5 7 8 9 11 12 13 14 15 b a

84 84 Erice 2005, the Analysis of Patterns. Grammatical Inference 84 And finally to merge 7 with 15 a a a a b a b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4,13 5 7 8 9 11 12 14 15 b

85 85 Erice 2005, the Analysis of Patterns. Grammatical Inference 85 No counter example is accepted so the merges are kept a a a a b b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4,13 5 7,15 8 9 11 12 14 b

86 86 Erice 2005, the Analysis of Patterns. Grammatical Inference 86 Next possible merge to be checked is {4,13} with {1,3,6} a a a a b b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4,13 5 7,15 8 9 11 12 14 b

87 87 Erice 2005, the Analysis of Patterns. Grammatical Inference 87 a a a b b ab a X - ={aa, ab, aaaa, ba} 1,3,4,6,13 2,10 5 7,15 8 9 11 12 14 b a More merging for determinization is needed

88 88 Erice 2005, the Analysis of Patterns. Grammatical Inference 88 a b ab a X - ={aa, ab, aaaa, ba} 1,3,4,6, 8,13 2,7,10,11,15 5 9 12 14 b a But now aa is accepted

89 89 Erice 2005, the Analysis of Patterns. Grammatical Inference 89 So we try {4,13} with {2,10} a a a a b b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4,13 5 7,15 8 9 11 12 14 b

90 90 Erice 2005, the Analysis of Patterns. Grammatical Inference 90 After determinizing, negative string aa is again accepted a b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,4,7,10, 13,15 5,8 9,11 12 14 b a

91 91 Erice 2005, the Analysis of Patterns. Grammatical Inference 91 So we try 5 with {1,3,6} a a a a b b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4,13 5 7,15 8 9 11 12 14 b

92 92 Erice 2005, the Analysis of Patterns. Grammatical Inference 92 But again we accept ab a a a a b b X - ={aa, ab, aaaa, ba} 1,3,5,6,12 2,9,10,14 4,13 7,15 8 11 b

93 93 Erice 2005, the Analysis of Patterns. Grammatical Inference 93 So we try 5 with {2,10} a a a a b b ab a X - ={aa, ab, aaaa, ba} 1,3,6 2,10 4,13 5 7,15 8 9 11 12 14 b

94 94 Erice 2005, the Analysis of Patterns. Grammatical Inference 94 Which is OK. So next possible merge is {7,15} with {1,3,6} a a a a b b X - ={aa, ab, aaaa, ba} 1,3,6 2,5,10 4,9,13 7,15 8,12 11,14 b

95 95 Erice 2005, the Analysis of Patterns. Grammatical Inference 95 Which is OK. Now try to merge {8,12} with {1,3,6,7,15} a a a a b a X - ={aa, ab, aaaa, ba} 1,3,6, 7,15 2,5,10 4,9,13 8,12 11,14 b b

96 96 Erice 2005, the Analysis of Patterns. Grammatical Inference 96 And ab is accepted a a b a X - ={aa, ab, aaaa, ba} 1,3,6,7, 8,12,15 2,5,10,11,14 4,9,13 b b

97 97 Erice 2005, the Analysis of Patterns. Grammatical Inference 97 Now try to merge {8,12} with {4,9,13} a a a a b a X - ={aa, ab, aaaa, ba} 1,3,6, 7,15 2,5,10 4,9,13 8,12 11,14 b b

98 98 Erice 2005, the Analysis of Patterns. Grammatical Inference 98 This is OK and no more merge is possible so the algorithm halts. a a a b a X - ={aa, ab, aaaa, ba} 1,3,6,7, 11,14,15 2,5,10 4,8,9,12,13 b b

99 99 Erice 2005, the Analysis of Patterns. Grammatical Inference 99 Definitions Let  be the length-lex ordering over  * Let Pref(L) be the set of all prefixes of strings in some language L.

100 10 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 100 Short prefixes Sp(L)={u  Pref(L):  (q 0,u)=  (q 0,v)  u  v} There is one short prefix per useful state 0 1 2 a b a b b a Sp(L)={, a}

101 10 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 101 Kernel-sets N(L)={ua  Pref(L): u  Sp(L)}  { } There is an element in the Kernel-set for each useful transition 0 1 2 a b a b b a N(L)={, a, b, ab}

102 10 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 102 A characteristic sample A sample is characteristic (for RPNI) if –  x  Sp(L)  xu  X + –  x  Sp(L),  y  N(L),  (q 0,x)  (q 0,y)  z  *: xz  X +  yz  X -  xz  X -  yz  X +

103 10 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 103 About characteristic samples If you add more strings to a characteristic sample it still is characteristic; There can be many different characteristic samples; Change the ordering (or the exploring function in RPNI) and the characteristic sample will change.

104 10 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 104 Conclusion RPNI identifies any regular language in the limit; RPNI works in polynomial time. Complexity is in O (║X + ║ 3.║X - ║); There are many significant variants of RPNI; RPNI can be extended to other classes of grammars.

105 10 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 105 Open problems RPNI’s complexity is not a tight upper bound. Find the correct complexity. The definition of the characteristic set is not tight either. Find a better definition.

106 10 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 106 Algorithms RPNI K-Reversible GRIDS SEQUITUR L*

107 10 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 107 4.2 The k-reversible languages The class was proposed by Angluin (1982). The class is identifiable in the limit from text. The class is composed by regular languages that can be accepted by a DFA such that its reverse is deterministic with a look-ahead of k.

108 10 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 108 Let A=( , Q, , I, F) be a NFA, we denote by A T =( , Q,  T, F, I) the reversal automaton with:  T (q,a)={q’  Q: q  (q’,a)}

109 10 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 109 0 1 3 b 2 4 a b a a a a 0 1 3 b 2 4 a b a a a a A ATAT

110 11 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 110 Some definitions u is a k-successor of q if │u│=k and  (q,u) . u is a k-predecessor of q if │u│=k and  T (q,u T ) . is 0-successor and 0- predecessor of any state.

111 11 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 111 0 1 3 b 2 4 b a a a a A aa is a 2-successor of 0 and 1 but not of 3. a is a 1-successor of 3. aa is a 2-predecessor of 3 but not of 1. a

112 11 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 112 A NFA is deterministic with look-ahead k iff  q,q’  Q: q  q’ (q,q’  I)  (q,q’  (q”,a))  (u is a k-successor of q)  (v is a k-successor of q’)  uvuv

113 11 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 113 Prohibited: 2 1 a a u u │u│=k│u│=k

114 11 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 114 Example This automaton is not deterministic with look-ahead 1 but is deterministic with look-ahead 2. 0 1 3 b 2 4 a b a a a a

115 11 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 115 K-reversible automata A is k-reversible if A is deterministic and A T is deterministic with look-ahead k. Example 0 1 b 2 b a a b 0 1 b 2 b a a b deterministic deterministic with look-ahead 1

116 11 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 116 Violation of k-reversibility Two states q, q’ violate the k-reversibility condition iff –they violate the deterministic condition: q,q’  (q”,a); or –they violate the look-ahead condition: q,q’  F,  u  k : u is k-predecessor of both;  u  k,  (q,a)=  (q’,a) and u is k- predecessor of both q and q’.

117 11 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 117 Learning k-reversible automata Key idea: the order in which the merges are performed does not matter! Just merge states that do not comply with the conditions for k-reversibility.

118 11 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 118 K-RL Algorithm (  k-RL ) Data: k  , X sample of a k-RL L A=PTA(X) While  q,q’ k-reversibility violators do A=merge(A,q,q’)

119 11 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 119 Let X={a, aa, abba, abbbba} a ababb aa abbbbabbbabbbba abba a bbbba a a k=2 Violators, for u= ba

120 12 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 120 Let X={a, aa, abba, abbbba} a ababb aa abbbbabbb abba a bbbb a a a k=2 Violators, for u= bb

121 12 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 121 Let X={a, aa, abba, abbbba} a ababb aa abbb abba a bbb b a a k=2

122 12 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 122 Properties (1)  k  0,  X,  k-RL (X) is a k- reversible language. L(  k-RL (X)) is the smallest k- reversible language that contains X. The class L k-RL is identifiable in the limit from text.

123 12 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 123 Properties (2) Any regular language is k- reversible iff (u 1 v) -1 L  (u 2 v) -1 L  and │v│=k  (u 1 v) -1 L=(u 2 v) -1 L (if two strings are prefixes of a string of length at least k, then the strings are Nerode-equivalent)

124 12 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 124 Properties (3) L k-RL (X)  L (k+1)-RL (X) L k-TSS (X)  L (k-1)-RL (X)

125 12 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 125 Properties (4) The time complexity is O(k║X║ 3 ). The space complexity is O(║X║). The algorithm is not incremental.

126 12 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 126 Properties (4) Polynomial aspects Polynomial characteristic sets Polynomial update time But not necessarily a polynomial number of mind changes

127 12 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 127 Extensions Sakakibara built an extension for context-free grammars whose tree language is k-reversible Marion & Besombes propose an extension to tree languages. Different authors propose to learn these automata and then estimate the probabilities as an alternative to learning stochastic automata.

128 12 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 128 Exercises Construct a language L that is not k-reversible,  k  0. Prove that the class of k- reversible languages is not in TxtEx. Run  k-RL on X={aa, aba, abb, abaaba, baaba} for k=0,1,2,3

129 12 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 129 Solution (idea) L k ={a i : i  k} Then for each k: L k is k- reversible but not k-1- reversible. And U L k = a * So there is an accumulation point…

130 13 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 130 Algorithms RPNI K-Reversible GRIDS SEQUITUR L*

131 13 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 131 4.4 Active Learning: learning DFA from membership and equivalence queries: the L* algorithm

132 13 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 132 The classes C and H sets of examples representations of these sets the computation of L(x) (and h(x)) must take place in time polynomial in  x .

133 13 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 133 Correct learning A class C is identifiable with a polynomial number of queries of type T if there exists an algorithm  that: 1)  L  C identifies L with a polynomial number of queries of type T; 2)does each update in time polynomial in  f  and in  x i , {x i } counter- examples seen so far.

134 13 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 134 Algorithm L* Angluin’s papers Some talks by Rivest Kearns and Vazirani Balcazar, Diaz, Gavaldà & Watanabe

135 13 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 135 Some references Learning regular sets from queries and counter-examples, D. Angluin, Information and computation, 75, 87-106, 1987. Queries and Concept learning, D. Angluin, Machine Learning, 2, 319- 342, 1988. Negative results for Equivalence Queries, D. Angluin, Machine Learning, 5, 121-150, 1990.

136 13 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 136 The Minimal Adequate Teacher You are allowed: –strong equivalence queries; –membership queries.

137 13 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 137 General idea of L* find a consistent table (representing a DFA); submit it as an equivalence query; use counterexample to update the table; submit membership queries to make the table complete; Iterate.

138 13 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 138 An observation table a a ab aa b 10 00 01 00 01

139 13 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 139 The states (S) or test set The transitions (T) The experiments (E) a a ab aa b 10 00 01 00 01

140 14 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 140 Meaning  (q 0,. )  F   L a a ab aa b 10 00 01 00 01

141 14 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 141  (q 0, ab.a)  F  aba  L a a ab aa b 10 00 01 00 01

142 14 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 142 Equivalent prefixes These two rows are equal, hence  (q 0, )=  (q 0,ab) a a ab aa b 10 00 01 00 01

143 14 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 143 Building a DFA from a table a a ab aa b 10 00 01 00 01 a a

144 14 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 144 a a ab aa b 10 00 01 00 01 a a b a b

145 14 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 145 a a ab aa b 10 00 01 00 01 a a b a b Some rules This set is prefix- closed This set is suffix-closed S\S=TS\S=T

146 14 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 146 An incomplete table a a ab aa b 10 0 01 0 01 a a b a b

147 14 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 147 Good idea We can complete the table by making membership queries... u v ? uv  L ? Membership query:

148 14 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 148 A table is closed if any row of T corresponds to some row in S a a ab aa b 10 00 01 10 01 Not closed

149 14 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 149 And a table that is not closed a a ab aa b 10 00 01 10 01 a a b a b ?

150 15 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 150 What do we do when we have a table that is not closed? Let s be the row (of T) that does not appear in S. Add s to S, and  a  sa to T.

151 15 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 151 An inconsistent table a ab aa 10 a b 00 00 01 0 1 bb ba 01 0 0 Are a and b equivalent?

152 15 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 152 A table is consistent if Every equivalent pair of rows in H remains equivalent in S after appending any symbol row(s 1 )=row(s 2 )   a , row(s 1 a)=row(s 2 a)

153 15 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 153 What do we do when we have an inconsistent table? Let a  be such that row(s 1 )=row(s 2 ) but row(s 1 a)  row(s 2 a) If row(s 1 a)  row(s 2 a), it is so for experiment e Then add experiment ae to the table

154 15 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 154 What do we do when we have a closed and consistent table ? We build the corresponding DFA We make an equivalence query!!!

155 15 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 155 What do we do if we get a counter- example? Let u be this counter-example  w  Pref (u) do –add w to S –  a , such that wa  Pref (u) add wa to T

156 15 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 156 Run of the algorithm a b 1 1 1 Table is now closed and consistent b a

157 15 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 157 An equivalence query is made! b a Counter example baa is returned

158 15 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 158 a b 1 1 0 baa ba baaa bb bab baab 1 0 1 1 1 1 Not consistent Because of

159 15 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 159 a a b 1 1 0 baa ba baaa bb bab baab 1 0 1 1 0 1 1 Table is now closed and consistent ba baa a b a b b a 0 0 0 1 1

160 16 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 160 Proof of the algorithm Sketch only Understanding the proof is important for further algorithms Balcazar et al. is a good place for that.

161 16 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 161 Termination / Correctness For every regular language there is a unique minimal DFA that recognizes it. Given a closed and consistent table, one can generate a consistent DFA. A DFA consistent with a table has at least as many states as different rows in S. If the algorithm has built a table with n different rows in S, then it is the target.

162 16 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 162 Finiteness Each closure failure adds one different row to S. Each inconsistency failure adds one experiment, which also creates a new row in S. Each counterexample adds one different row to S.

163 16 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 163 Polynomial |E|  n at most n-1 equivalence queries |membership queries|  n(n-1)m where m is the length of the longest counter-example returned by the oracle

164 16 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 164 Conclusion With an MAT you can learn DFA –but also a variety of other classes of grammars; –it is difficult to see how powerful is really an MAT; –probably as much as PAC learning. –Easy to find a class, a set of queries and provide and algorithm that learns with them; –more difficult for it to be meaningful. Discussion: why are these queries meaningful?

165 16 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 165 Algorithms RPNI K-Reversible GRIDS SEQUITUR L*

166 16 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 166 4.5 SEQUITUR ( http://sequence.rutgers.edu/sequitur/ ) (Neville Manning & Witten, 97) Idea: construct a CF grammar from a very long string w, such that L(G)={w} –No generalization –Linear time (+/-) –Good compression rates

167 16 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 167 Principle The grammar with respect to the string: –Each rule has to be used at least twice; –There can be no sub-string of length 2 that appears twice.

168 16 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 168 Examples S  abcdbc S  AbAab A  aa S  aAdA A  bc S  aabaaab S  AaA A  aab

169 16 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 169 abcabdabcabd

170 17 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 170 In the beginning, God created the heavens and the earth. And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters. And God said, Let there be light: and there was light. And God saw the light, that it was good: and God divided the light from the darkness. And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day. And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters. And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so. And God called the firmament Heaven. And the evening and the morning were the second day.

171 17 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 171

172 17 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 172 appending a symbol to rule S; using an existing rule; creating a new rule; and deleting a rule. Sequitur options

173 17 3 Erice 2005, the Analysis of Patterns. Grammatical Inference 173 Results On text: –2.82 bpc –compress 3.46 bpc –gzip 3.25 bpc –PPMC 2.52 bpc

174 17 4 Erice 2005, the Analysis of Patterns. Grammatical Inference 174 Algorithms RPNI K-Reversible GRIDS SEQUITUR L*

175 17 5 Erice 2005, the Analysis of Patterns. Grammatical Inference 175 4.6 Using a simplicity bias (Langley & Stromsten, 00) Based on algorithm GRIDS (Wolff, 82) Main characteristics: –MDL principle; –Not characterizable; –Not tested on large benchmarks.

176 17 6 Erice 2005, the Analysis of Patterns. Grammatical Inference 176 Two learning operators Creation of non terminals and rules NP  ART ADJ NOUN NP  ART ADJ ADJ NOUN NP  ART AP1 NP  ART ADJ AP1 AP1  ADJ NOUN

177 17 7 Erice 2005, the Analysis of Patterns. Grammatical Inference 177 Merging two non terminals NP  ART AP1 NP  ART AP2 AP1  ADJ NOUN AP2  ADJ AP1 NP  ART AP1 AP1  ADJ NOUN AP1  ADJ AP1

178 17 8 Erice 2005, the Analysis of Patterns. Grammatical Inference 178 Scoring function: MDL principle:  G  +  w  T  d(w)  Algorithm: –find best merge that improves current grammar –if no such merge exists, find best creation –halt when no improvement

179 17 9 Erice 2005, the Analysis of Patterns. Grammatical Inference 179 Results On subsets of English grammars (15 rules, 8 non terminals, 9 terminals): 120 sentences to converge on (ab) * : all (15) strings of length  30 on Dyck 1 : all (65) strings of length  12

180 18 0 Erice 2005, the Analysis of Patterns. Grammatical Inference 180 Algorithms RPNI K-Reversible GRIDS SEQUITUR L*

181 18 1 Erice 2005, the Analysis of Patterns. Grammatical Inference 181 5 Open questions and conclusions dealing with noise classes of languages that adequately mix Chomsky’s hierarchy with edit distance compacity stochastic context-free grammars polynomial learning from text learning POMDPs fast algorithms

182 18 2 Erice 2005, the Analysis of Patterns. Grammatical Inference 182 ERNESTO SÁBATO, EL TÚNEL Intuí que había caído en una trampa y quise huir. Hice un enorme esfuerzo, pero era tarde: mi cuerpo ya no me obedecía. Me resigné a presenciar lo que iba a pasar, como si fuera un acontecimiento ajeno a mi persona. El hombre aquel comenzó a transformarme en pájaro, en un pájaro de tamaño humano. Empezó por los pies: vi cómo se convenían poco a poco en unas patas de gallo o algo así. Después siguió la transformación de todo el cuerpo, hacia arriba, como sube el agua en un estanque. Mi única esperanza estaba ahora en los amigos, que inexplicablemente no habían llegado. Cuando por fin llegaron, sucedió algo que me horrorizó: no notaron mi transformación. Me trataron como siempre, lo que probaba que me veían como siempre. Pensando que el mago los ilusionaba de modo que me vieran como una persona normal, decidí referir lo que me había hecho. Aunque mi propósito era referir el fenómeno con tranquilidad, para no agravar la situación irritando al mago con una reacción demasiado violenta (lo que podría inducirlo a hacer algo todavía peor), comencé a contar todo a gritos. Entonces observé dos hechos asombrosos: la frase que quería pronunciar salió convertida en un áspero chillido de pájaro, un chillido desesperado y extraño, quizá por lo que encerraba de humano; y, lo que era infinitamente peor, mis amigos no oyeron ese chillido, como no habían visto mi cuerpo de gran pájaro; por el contrario, parecían oír mi voz habitual diciendo cosas habituales, porque en ningún momento mostraron el menor asombro. Me callé, espantado. El dueño de casa me miró entonces con un sarcástico brillo en sus ojos, casi imperceptible y en todo caso sólo advertido por mí. Entonces comprendí que nadie, nunca, sabría que yo había sido transformado en pájaro. Estaba perdido para siempre y el secreto iría conmigo a la tumba.


Download ppt "1 Erice 2005, the Analysis of Patterns. Grammatical Inference 1 Colin de la Higuera Grammatical inference: techniques and algorithms."

Similar presentations


Ads by Google