1 / 18

Topic 4 – Knowledge Representation

Topic 4 – Knowledge Representation. St Kentigern’s Academy Unit 3 – Artificial Intelligence. Semantic Net. A semantic net is a design methodology that is used when representing knowledge.

tekla
Download Presentation

Topic 4 – Knowledge Representation

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. Topic 4 – Knowledge Representation St Kentigern’s Academy Unit 3 – Artificial Intelligence

  2. Semantic Net • A semantic net is a design methodology that is used when representing knowledge. • Psuedocode would not work because the programs think differently. So instead of pseudocode or structured diagrams we draw a semantic net.

  3. Semantic Net • Here is expert information that has been collated about farm animals: • A pig has four legs, eats slurry, lives on a farm. Cows have four legs, live on a farm, eat grass. Chickens have two legs, live on a farm, eat corn.

  4. Semantic Net four legs two corn pig eats slurry eats legs is_a chicken is_a farm animal is_a cow eats legs grass four

  5. Prolog • These facts can now be turned into prolog. • is_a(pig,farm_animal). • is_a(cow, farm_animal). • is_a(chicken, farm_animal). • legs(pig, four). • legs(cow, four). • legs(chicken, two). • eats(pig, slurry). • eats(cow, grass). • eats(chicken, corn).

  6. Prolog • Rules for writing Prolog facts and rules: • There are no spaces; • There are no capitals unless a variable; • There must be a full stop at the end of each statement.

  7. Simple Facts • Prolog facts which have simple facts only have either one or two arguments. • male(peter). Means peter is male • female(susan). Means susan is female • manager(susan, peter).

  8. Simple Rules • Prolog rules allow us to create more relationships in the knowledge base. • Example: lives_in_sea(X) :- means that X lives in the is_a(X, fish). sea if X is a fish • The :- part means if in prolog. Rules are made up of a head which is the conclusion and a body which is made up of one or more sub-goals. • In order for the condition to be true all of the sub-goals must be true.

  9. Simple Queries • In order to get information from the knowledge base we need to query it. • There are two types of answers that we can get from a query: • If the query we enter does not have a variable (capital letter) then the answer is either yes/true or no/false. • If we enter the following query into our animals knowledge base: • ?legs(pig, four). • The answer would be YES

  10. Simple Queries • If we enter the following query into our animals knowledge base: • ?legs(pig, two). • The answer would be NO • If the query we enter has a variable in it, the answer we are looking for is X=… • If we enter the following query into our animals knowledge base: • ?legs(X, four). • The answer would be : X=pig, X=cow, No

  11. Operators • In our knowledge base we can also use basic arithmetic operators: • And – to connect two subgoals • > - is greater than; • < - is less than; & • = - equal to.

  12. Goals and Subgoals • The goal is what we are looking for when we query our knowledge base. • In order for a rule to be successful, each sub-goal of the rule must be successful.

  13. Trace Tables • A manual trace is when we write out the answer to a query the way that the program works through the query.

  14. Trace Tables • voice(kabira, excellent). • voice(sharon, excellent). • voice(ryan, fair). • voice(jumoke, excellent). • dance(kabira, fair). • dance(sharon, good). • dance(ryan, excellent). • dance(jumoke, excellent). • is_selected(X) if voice(X, excellent) and dance(X, excellent). • is_reserve(X) if voice(X, excellent) and dance(X, good).

  15. Trace Tables • Using the numbering system above to help you, trace how the system will evaluate the query: • is_reserve(X). • to the first solution.

  16. Trace Tables • 1. write out the query and the number of the first match: • ?is_reserve(X). Matches at 10 • 2. write out the rule at the first match: • is_reserve(X) IF voice(X, excellent) and dance(X, good). • 3. Take the first subgoal and try to find a match. • First subgoal voice(X, excellent). Matches at 1, X = kabira • 4. Take the second subgoal and try to find a match. • Second subgoal dance(kabira, good) No Match

  17. Trace Tables • 5. Go back to the first subgoal and carry on. • 1st subgoal voice(X, excellent) matches at 2, X = sharon • 6. Take the second subgoal and try to find a match. • 2nd subgoal sharon, good) matches at 6. • Subgoal returns Yes • Goal returns X = sharon

  18. Trace Tables • Your full answer would be: • ?is_reserve(X). Matches at 10 • is_reserve(X) IF voice(X, excellent) and dance(X, good). • 1st subgoal voice(X, excellent). • Matches at 1, X = kabira • 2nd subgoal dance(kabira, good) • No Match • 1st subgoal voice(X, excellent) matches at 2, • X = sharon • 2nd subgoal sharon, good) matches at 6. • Subgoal returns Yes • Goal returns X = sharon

More Related