Fictional Universes and OWL! – Part I

In the second year of me teaching the Stanford BMI 210 course on modeling biomedical ontologies and terminologies, I thought of making the assignments more interesting and fun with two-fold goals: 1) students can understand how the tools and methods taught in this class can relate to “current” trends, and 2) students with a weak background in biomedicine can find this class more interesting (while not alienating students with a strong background). 

In 2016, Pokemon GO was quite a sensation! I wondered if the assignments can be catered towards this game, and if students can model the Pokemon fictional universe using Ontologies (classification of different Pokemon species, modeling the different events in a Pokemon Trainer’s life can feel right at home in the BMI 210 Class!). Once this fictional universe is modeled and saved as an OWL file, we can do other cool assignments such as using Bayesian reasoning to predict the probability that Ash Ketchum is going to win a PokemonBattle, given statistics on the number of times a given Pokemon won a fight!, or using Rule-based reasoning (e.g. SWRL) for deterministic inferences. In this post, I will go step-by-step on the different sections of the Pokemon Ontology assignments!

pokemon


Pokemon Ontology (or GOntology!) modeling with OWL!

The Pokemon fictional universe is filled with different trainers traveling the world, catching creatures (or Pokemon) of different types of species and using those creatures in battles. We will develop a simplified OWL model to capture different concepts and relations in a small microcosm of the Pokemon universe, that correspond to the following statements given below!

  1. There are two main kinds of Organism: Human and Pokemon.
  2. Humans can either be PokemonTrainer or SimpleHuman
  3. There are different kinds of Pokemon, based on their type: FirePokemon, WaterPokemon, GrassPokemon, PoisonPokemon, FlyingPokemon, ElectricPokemon and NormalPokemon.
  4. We will create only the following Pokemon species, under one or a combination of Pokemon types, created before:
    1. Bulbasaur (GrassPokemon)
    2. Ivysaur (GrassPokemon and PoisonPokemon)
    3. Charmeleon (FirePokemon)
    4. Charizard (FirePokemon and FlyingPokemon)
    5. Pikachu (ElectricPokemon)
    6. Zapados (ElectricPokemon and FlyingPokemon)
    7. Eevee (NormalPokemon)
    8. Vaporeon (WaterPokemon)
    9. Jolteon (ElectricPokemon)
    10. Moltres (FirePokemon and FlyingPokemon)
    11. Squirtle (WaterPokemon)
    12. WarTortle (WaterPokemon)
  5. A Pokemon of one kind may have a weakness to a Pokemon of another kind:
    1. WaterPokemon have weakness to ElectricPokemon or GrassPokemon
    2. FirePokemon have weakness to ElectricPokemon or WaterPokemon
    3. GrassPokemon have weakness to FirePokemon or FlyingPokemon
    4. ElectricPokemon have weakness to GrassPokemon
    5. NormalPokemon have weakness to PoisonPokemon
  6. A Pokemon may evolve into another Pokemon specifically:
    1. Bulbasaur evolves to Ivysaur
    2. Charmeleon evolves to Charizard
    3. Eevee can evolve to either Vaporeon or Jolteon
    4. Squirtle evolves to WarTortle
  7. Create the following data-type properties:
    1. demographic : height, weight, age (numerical), region (string)
    2. characteristic: power, heart, wingSpan (numerical), feature (string)
    3. name, description
  8. A Pokemon has the following attributes:
    1. height, weight, power, heart and
    2. feature. The feature attribute is restricted to take values only from the following array [“seed”, “flower”, “mammal”, “reptile”, “bird”, “rodent”]
    3. region. The region attribute is restricted to take values only from the following array [“kanto”, “johto”]
  9. A FlyingPokemon has an additional attribute: wingSpan
  10. Moltres and Zapados have a property restriction on wingSpan to be > 500.
  11. Bulbasaur and Squirtle have a restriction on height < 50 and weight < 50
  12. Eevee has a property restriction on height < 100
  13. A PokemonTrainer has the following attributes:
    1. height, weight, age
  14. All Organism have name
  15. We will create two more equivalent classes:
    1. StarterPokemon: height < 100 and weight < 100
    2. LegendaryPokemon: FlyingPokemon and wingSpan > 300
  16. We will create some Skills: ElectricShock, ElectricField, Shield, Whip, Harden, SporeRelease, FireBall, WaterGun
  17. We will create an object property: hasSkill, and two sub-properties: hasAttack, and hasDefense
  18. We will also create the following restrictions:
    1. ElectricPokemon hasAttack ElectricShock
    2. ElectricPokemon hasDefense ElectricField
    3. PoisonPokemon hasAttack SporeRelease
    4. FirePokemon hasAttack FireBall
    5. WaterPokemon hasAttack WaterGun
    6. FlyingPokemon hasDefense Shield
    7. GrassPokemon hasAttack Whip
    8. WaterPokemon hasDefense Harden
    9. NormalPokemon hasDefense Shield
  19. There also exist different PokemonItem: Potion, PokeBall and Lure
  20. Potion can either be NormalPotion or SuperPotion
  21. PokeBall can either be NormalPokeBall or GreatPokeBall
  22. A PokemonTrainer may possess some PokemonItem
  23. A PokeBall can contain at maximum 1 Pokemon only.
  24. A PokemonTrainer can participate in a PokemonBattle
  25. A PokemonBattle has the following attributes:
    1. Description, region (restrict to [“kanto”, “johto”])
  26. A PokemonBattle involves some PokemonFight
  27. A Pokemon can participate in some PokemonFight.

Using PokemonBattle and PokemonFight, our model aims to capture Pokemon battles between trainers (that may contain several individual Pokemon fights), as well as one-on-one Pokemon fights (such as to capture other wild Pokemon) 🙂

Note: We are ignoring the temporal aspect here, since a trainer may have a Pokemon at a given period of time, which then evolves to another Pokemon at a subsequent period of time!

Classifying the Ontology

Here we will use the Hermit Reasoner to classify our ontology. Under the Reasoner menu, first select the Hermit reasoner, and then “Start reasoner”. Now open the inferred Class hierarchy tab.

  1. Which Pokemon are classified under Legendary Pokemon and Starter Pokemon? Where is Legendary Pokemon classified? Is this what is expected?
  2. Suppose you click on Normal Pokemon and go to Edit-> Make Primitive Siblings Disjoint. Now if you synchronise the reasoner, what changes do you observe in the Inferred hierarchy tab? Explain in 2 sentences your observations.

Making your Model Informative

In this problem, we will further refine our model to make it more informative for users. Essentially, we will add altLabel and rdfs:comment annotations to different concepts that we defined in Question 1, as follows:

  1. Pokemon:
    1. altLabel: Pocket Monster
    2. comment: Fantasy creatures in the Pokemon world, drawn as if mutated from real-world creatures
  2. PokemonTrainer:
    1. altLabel: Pokemon Battle player
    2. comment: Trains Pokemon to fight battles with other Trainers, and capture other Pokemon

Adding Instances

In this problem, we will add instances to our model. You should note that in OWL and Protégé, instances are called “Individuals”.

Ash Ketchum and Gary Oak are prominent Pokemon trainers in the actual Pokemon World, so we will add the following instances and property assertions.

  1. Add the following instances to the model:
    1. “AshKetchum” and “GaryOak”, of type PokemonTrainer
    2. “Pikachu1”, “Charmeleon1”, “Charizard1”, “Bulbasaur1”, “Wartortle1” of the respective types.
    3. “PB1”, “PB2”, “PB3”, “PB4” of type NormalPokeBall.
    4. “FinalBattle” of type PokemonBattle
    5. Fight1”, “Fight2” of type PokemonFight
  2. Add the following Object Property Assertions to the model:
    1. AshKetchum: participates FinalBattle, GaryOak: participates FinalBattle
    2. FinalBattle: involves Fight1, Fight2
    3. PB1: contain Pikachu1, PB2: contain Charmeleon1, PB3: contain Bulbasaur1, PB4: contain Wartortle1
    4. AshKetchum: possess PB1, PB2, GaryOak: possess PB3, PB4
    5. Pikachu1: participates Fight1, Bulbasaur1: participates Fight1
    6. Charmaleon1: evolves Charizard1
    7. Charizard1: participates Fight2, Wartortle1: participates Fight2
  3. Add Data Property Assertions, as follows:
    1. Pikachu1: power 300
    2. FinalBattle: description “The final battle between Ash and Gary at the Johto League”
    3. FinalBattle: region “johto”
  4. It is always helpful to link to existing knowledge while developing your ontology. For example, we may wish to add knowledge from the Bulbapedia to our trainers and the battle. Add the following seeAlso annotations to your individuals:
    1. AshKetchum – http://bulbapedia.bulbagarden.net/wiki/Ash_Ketchum
    2. GaryOak – http://bulbapedia.bulbagarden.net/wiki/Gary_Oak
    3. FinalBattle – http://bulbapedia.bulbagarden.net/wiki/EP269

What happens if you synchronize the reasoner now? Explain your observation in 2 sentences. How will you correct the error?

pokemon
VOWL visualization of a section of the Pokemon Ontology!

————————————————————————————————————————-

SWRL Rules (Semantic Web Rule Language) over the Pokemon GOntology!

  1. Formulate the following SWRL Rules to classify the individuals:
    1. A PokeBall with a weight greater than 100 is a SuperPokeBall
    2. A PokeBall with a weight less than or equal to 100 is a NormalPokeBall
    3. A Human that possesses a PokeBall that contains a StarterPokemon
      and has an age less than 12 is a BeginnerPokemonTrainer
    4. A Human that has an age greater than or equal to 12 and possesses
      PokeBall is an AdvancedPokemonTrainer
    5. All SuperPokemon are LegendaryPokemon
    6. All FlyingPokemon with a wingspan greater than 300 are LegendaryPokemon
    7. LegendaryPokemon that are contained in a SuperPokeBall should be assigned isCaptured = true
    8. FirePokemon of height less than or equal to 100 have a weakness to WaterPokemon of height greater than 100.
    9. Individuals under (FirePokemon and FlyingPokemon) have a weakness to ElectricPokemon of height greater than 200.
    10. All ElectricPokemon have weakness towards all GrassPokemon
    11. PokemonFight hasVictor PokemonTrainer of the participantA Pokemon
      1. if power of participantA Pokemon is greater than power of participantB Pokemon by 100 units
    12. PokemonFight hasVictor PokemonTrainer of the participantB Pokemon
      1. if power of participantB Pokemon is greater than power of participantA Pokemon by 50 units, and
      2. participantA Pokemon has weakness to participantB Pokemon
  2. Answer the following questions below after writing the SWRL rules:
    1. List all instances of LegendaryPokemon, and which of those LegendaryPokemon are captured (isCaptured=true)?
    2. List AdvancedPokemonTrainers and BeginnerPokemonTrainers
    3. Which Pokemon does chrz1 of type Charizard have weakness towards?
    4. Which PokemonTrainer is the victor in each of the three fights in FinalBattle?
  3. As the ontology developer, you think that the model is a bit unintuitive as to determine the set of Pokemon a PokemonTrainer has, you need to formulate a complicated query. We would like to make it a bit simple, so you can directly determine the set of Pokemon using the Protege UI.
    1. Create an ObjectProperty hasPokemon
    2. Instead of manually adding ObjectProperty assertions, create a SWRL Rule that can automatically infer the set of Pokemon a PokemonTrainer has, based on the PokeBalls he possesses and the Pokemon contained in the PokeBalls. Assign this set to create hasPokemon ObjectProperty assertions between the PokemonTrainer and his Pokemon.
    3. List Pokemon of AshKetchum, Misty and GaryOak (screenshots allowed)
  4. May and Tracey live in the “Johto” region of the Pokemon World. They
    have a different currency, that is used to describe the price of PokeBall.
    However, our model only indicates the price of PokeBall in kantoDollar.

    1. Create a SWRL rule to indicate the price of PokeBall in johtoDollar for
      only those PokemonTrainer that live in “Johto” region of the Pokemon
      World. (johtoDollar = 0.93*kantoDollar)
    2. What is the price of May’s and Tracey’s PokeBall in johtoDollar (You can
      manually look at the prices in “Individual” tab, or write another SWRL rule
      to extract this information in a separate class 🙂 )