1 / 26

Incremental, Systematic Acquiring of Knowledge (using Closure Algorithms)

Incremental, Systematic Acquiring of Knowledge (using Closure Algorithms). Roger L. Costello February 1, 2014. Example #1. Problem Statement. Problem: What cities can you get to from Boston?.

aquarius
Télécharger la présentation

Incremental, Systematic Acquiring of Knowledge (using Closure Algorithms)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Incremental, Systematic Acquiring of Knowledge(using Closure Algorithms) Roger L. Costello February 1, 2014

  2. Example #1

  3. Problem Statement • Problem: What cities can you get to from Boston? <Flights> <Flight> <From>Boston</From> <To>Miami</To> </Flight> <Flight> <From>Miami</From> <To>Houston</To> </Flight> <Flight> <From>Cleveland</From> <To>Akron</To> </Flight> <Flight> <From>Boston</From> <To>Denver</To> </Flight></Flights> It is easy to eyeball this sample XML and see that from Boston you can get to Miami, Houston (via Miami), and Denver. But if the XML document had thousands of flights, it would be impossible to eyeball it to get the answer.

  4. Need a Strategy • We need a systematic, incremental approach to obtaining the answer. • That’s what closure algorithms give us.

  5. Closure algorithms • A closure algorithmenables the incremental, systematic acquiring of knowledge. • Closure algorithms are characterized by two components: • An initialization, which is an assessment of what we know initially. • An inference rule, which is a rule telling how knowledge from several places is to be combined. • The inference rule(s) are repeated until nothing changes any more.

  6. Initial Knowledge This is what we know initially: • All the flights • From Boston we can get to Miami and Denver since there are direct flights to those cities. <Flights> <Flight> <From>Boston</From> <To>Miami</To> </Flight> <Flight> <From>Miami</From> <To>Houston</To> </Flight> <Flight> <From>Cleveland</From> <To>Akron</To> </Flight> <Flight> <From>Boston</From> <To>Denver</To> </Flight></Flights>

  7. Inference Rule • If we can get to the city identified in <From>, then we can get to the city identified in <To>.

  8. Initial knowledge • Go through the XML and for each <Flight> with a direct flight from Boston, mark it as “Can get there from Boston”.

  9. Build on top of our knowledge • Apply the inference rule to gain more knowledge. • This is round two (round one was marking the initial knowledge).

  10. Round Three • A third round yields no additional cities.

  11. Problem/Answer • Problem: What cities can you get to from Boston? • Answer: We can get to these cities: {Miami, Denver, Houston}

  12. Example #2

  13. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Document"> <xs:complexType> <xs:choice> <xs:sequence> <xs:element ref="A" /> <xs:element ref="B" /> </xs:sequence> <xs:sequence> <xs:element ref="D" /> <xs:element ref="E" /> </xs:sequence> </xs:choice> </xs:complexType> </xs:element> <xs:element name="A" type="xs:string" /> <xs:element name="B"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="C" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="C" type="xs:string" /> <xs:element name="D"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="F" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="E" type="xs:string" /> <xs:element name="F"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="D" /> </xs:sequence> </xs:complexType> </xs:element></xs:schema> Clean XML Schema • Problem: Are there any element declarations in the adjacent XML Schema that, if used, do not result in a valid XML instance document (e.g., perhaps because they loop infinitely)? In other words, are there any non-productive element declarations?

  14. Concise Notation • For brevity, let’s depict the element declarations this way: Document→A B | D E A→string B→stringC C→string D→d F E→string F→string D A→string means the value of element A is a string. B→string C means the value of element B is a string and a child element C (i.e., B has mixed content).

  15. Terminology These are rules. Each rule has a left-hand side and a right-hand side (the two sides are separated by an arrow →). Document, A, B, …, F are non-terminal symbols. string is a terminal symbol. Document→A B | D E A→string B→stringC C→string D→d F E→string F→string D

  16. Find the productive rules • We find the non-productive rules by finding the productive ones. • A rule is productive if its right-hand side consists of symbols all of which are productive. • Symbols that are productive: • Terminal symbols are productive since they produce values. • A non-terminal is productive if there is a productive rule for it.

  17. Initial knowledge • Go through the grammar and for each rule for which we know that all its right-hand side members are productive, mark the rule and the non-terminal it defines as “productive”.

  18. Build on top of our knowledge • Apply the inference rule to gain more knowledge.

  19. Round three

  20. Round four • A fourth round yields nothing new.

  21. Recap • We now know that Document, A, B, C, and E are productiveand D, F, and the rule Document→DE are not productive.

  22. Remove non-productive rules • We have pursued all possible avenues for productivity, and have not found any possibilities for D, F, and the second rule for Document. That means the rules for D, F, and the second rule for Document can be removed from the XML Schema. The XML Schema after removing non-productive rules

  23. Cleaned XML Schema • Problem: Does the XML Schema have any non-productive element declarations? • Answer: Yes, and the cleaned XML Schema is shown in the adjacent box. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Document"> <xs:complexType> <xs:sequence> <xs:element ref="A" /> <xs:element ref="B" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="A" type="xs:string" /> <xs:element name="B"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="C" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="C" type="xs:string" /> <xs:element name="E" type="xs:string" /></xs:schema>

  24. Bottom-up process • Removing the non-productive rules is a bottom-up process: only the bottom level, where the terminal symbols live, can we know what is productive.

  25. Why is it called “closure”? • We have seen two examples where new knowledge was incrementally, systematically acquired using a closure algorithm. • Question: Where does the term “closure” come from? • Answer: Applying the inference rule yields knowledge about existing symbols, without going outside the universe of discourse. • In the last example, applying the inference rule resulted in new knowledge about the elements that are productive in the XML Schema. Conversely, say the inference rule were to result in knowledge about elements in a completely different XML Schema, then the algorithm would not be closed. In a closure algorithm the universe of discourse is self-contained, no information outside of the universe is generated.

  26. Acknowledgement • Some of the information in these slides come from this fabulous book:Parsing Techniques by Dick Grune and CerielJacobs.X

More Related