PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?placeOfDeath ?placeOfDeathLabel WHERE {
  wd:Q1035 wdt:P20 ?placeOfDeath .
  OPTIONAL {
    ?placeOfDeath rdfs:label ?placeOfDeathLabel FILTER ( LANG( ?placeOfDeathLabel ) = "en" )
  }
}

Got 1 row and 2 columns:
| placeOfDeath             | placeOfDeathLabel |
| ------------------------ | ----------------- |
| Down House (wd:Q3038318) | Down House (en)   |

Charles Darwin died at Down House.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] where did charles darwin die?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
who was charles darwin married to?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q1035 wdt:P26 ?x .
}

Using entities:
Charles Darwin (wd:Q1035): English naturalist and biologist (1809–1882), travel writer, philosopher, ethologist, naturalist, geologist, botanist, explorer, writer

Using properties:
spouse, also known as married partner, married to, marry, partner, spouses (wd:P26 as wdt): the subject has the object as their spouse (husband, wife, partn...etc.). Use "unmarried partner" (P451) for non-married companions, significant person, relative

Example 2:
Question:
what book did charles darwin write on evolution?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P31 wd:Q47461344 ; wdt:P50 wd:Q1035 ; wdt:P921 ?y .
  ?y wdt:P279 | wdt:P361 + wd:Q1063 .
}

Using entities:
Charles Darwin (wd:Q1035): English naturalist and biologist (1809–1882), travel writer, philosopher, ethologist, naturalist, geologist, botanist, explorer, writer
evolution, also known as biological evolution (wd:Q1063): change in heritable characteristics of biological populations over successive generations
written work, also known as creative written work, written delivery (wd:Q47461344): any work expressed in writing, such as inscriptions, manuscripts, documents or maps

Using properties:
subclass of, also known as rdfs:subClassOf, sort of, subcategory of, subgenre of, subtype of (wd:P279 as wdt): this item is a subclass (subset) of that item; ALL instances of ...stance of volcanic landform); Everest is an instance of mountain
instance of, also known as unitary element of class, has type, unique individual of, type, item of type (wd:P31 as wdt): that class of which this subject is a particular example and mem...is a subclass of mountain (and an instance of volcanic landform)
part of, also known as of, within, system of, subsystem of, subgroup of (wd:P361 as wdt): object of which the subject is a part (if this subject is alread... of "has part" (P527, see also "has parts of the class" (P2670))
author, also known as writer, written by, poet, playwright, maker (wd:P50 as wdt): main creator(s) of a written work (use on works, not humans); us...hor name string) when Wikidata item is unknown or does not exist, creator
main subject, also known as primary topic, primary subject, primary keyword, plot keyword, of (wd:P921 as wdt): primary topic of a work (see also P180: depicts), depicts

Example 3:
Question:
what is the work of charles darwin?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P50 wd:Q1035 .
}

Using entities:
Charles Darwin (wd:Q1035): English naturalist and biologist (1809–1882), travel writer, philosopher, ethologist, naturalist, geologist, botanist, explorer, writer

Using properties:
author, also known as writer, written by, poet, playwright, maker (wd:P50 as wdt): main creator(s) of a written work (use on works, not humans); us...hor name string) when Wikidata item is unknown or does not exist, creator

[Assistant] From the examples, I see that Charles Darwin is represented by the entity wd:Q1035 in Wikidata. Now, I need to find the property that represents the place of death. I will search for properties related to "place of death" to find the appropriate property to use in the query.

[Tool]
Top 10 property alternatives:
1. place of death, also known as POD, location of death, killed in, deathplace, died in (wd:P20 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): most specific known (e.g. city instead of country, or hospital i... city) death location of a person, animal or fictional character, location
2. place of burial, also known as interment, interment location, interment place, interred at, location of burial (wd:P119 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): location of grave, resting place, place of ash-scattering, etc. ...veral places: e.g., re-burials, parts of body buried separately., location
3. date of death, also known as DOD, deathdate, died, died on, year of death (wd:P570 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): dissolved, abolished or demolished date, date on which the subject died, end time
4. category for people who died here, also known as category for place of death, category of people who died here (wd:P1465 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): category item for people who died in this location, related category
5. manner of death, also known as type of death, nature of death, death manner, death type, circumstance of death (wd:P1196 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): general circumstances of a person's death; e.g. natural causes, ...ysiological mechanism, e.g. heart attack, trauma, pneumonia etc.
6. number of deaths, also known as dead, qty fatalities, qty deaths, number of fatalities, fatalities (wd:P1120 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): total (cumulative) number of people who died since start as a direct result of an event or cause
7. category for people buried here, also known as buried here: Wikimedia category for, category of people buried here, category for place of burial, category for burials (wd:P1791 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): Wikimedia category for people with a burial site within this area, related category
8. cause of death, also known as death cause, murder method, method of murder, die of, die from (wd:P509 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): underlying or immediate cause of death.  Underlying cause (e.g. ...adest category, e.g. natural causes, accident, homicide, suicide
9. date of burial or cremation, also known as burial date, cremation date, date of cremation, funeral date (wd:P4602 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): date on which the person was buried or cremated soon after death, point in time
10. commemorates, also known as monument to, memorial to, memorializes, marks, in memory of (wd:P547 as prv/psv/pq/psn/pr/pqv/p/wdtn/ps/wdt/pqn/prn): what the place, monument, memorial, or holiday, commemorates, main subject

[Assistant] The property "place of death" is represented by wd:P20 in Wikidata. Now I will construct a SPARQL query to find the place of death of Charles Darwin (wd:Q1035) using this property.

[Tool]
Got 1 row and 2 columns:
| placeOfDeath             | placeOfDeathLabel |
| ------------------------ | ----------------- |
| Down House (wd:Q3038318) | Down House (en)   |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the place of death for Charles Darwin using the property wdt:P20. It returns the identifier and the English label for the place, which is Down House. The answer is accurate and complete based on the query result. No further refinement is needed.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?attraction ?attractionLabel WHERE {
  ?attraction wdt:P31 / wdt:P279 * wd:Q570116 ; wdt:P131 wd:Q16556 .
  OPTIONAL {
    ?attraction rdfs:label ?attractionLabel FILTER ( LANG( ?attractionLabel ) = "en" )
  }
}

Got 3 rows and 2 columns:
| attraction                                       | attractionLabel                         |
| ------------------------------------------------ | --------------------------------------- |
| Castles N' Coasters (wd:Q5050593)                | Castles N' Coasters (en)                |
| Six Flags Hurricane Harbor Phoenix (wd:Q7989946) | Six Flags Hurricane Harbor Phoenix (en) |
| Phoenix Art Museum (wd:Q977015)                  | Phoenix Art Museum (en)                 |

Notable tourist attractions to see in Phoenix, Arizona include Castles N' Coasters, Six Flags Hurricane Harbor Phoenix, and Phoenix Art Museum.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] what to see in phoenix arizona?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
what to do with kids in phx az?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P31 / wdt:P279 * wd:Q570116 ; wdt:P131 wd:Q16556 .
}

Using entities:
Phoenix, also known as City of Phoenix, Valley of the Sun, PHX, Phoenix, Arizona, Phoenix, AZ (wd:Q16556): city in Maricopa County, Arizona, United States
tourist attraction, also known as attraction for tourists, POI for tourists, tourism attraction, touristic attraction, tourist place (wd:Q570116): place of interest where tourists visit

Using properties:
located in the administrative territorial entity, also known as is in the settlement of, is in the voivodeship of, is in the shire of, is in the state of, is in the territory of (wd:P131 as wdt): the item is located on the territory of the following administra...if the item falls only partially into the administrative entity., location, part of
subclass of, also known as rdfs:subClassOf, sort of, subcategory of, subgenre of, subtype of (wd:P279 as wdt): this item is a subclass (subset) of that item; ALL instances of ...stance of volcanic landform); Everest is an instance of mountain
instance of, also known as unitary element of class, has type, unique individual of, type, item of type (wd:P31 as wdt): that class of which this subject is a particular example and mem...is a subclass of mountain (and an instance of volcanic landform)

Example 2:
Question:
what is there to see near the grand canyon?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P31 / wdt:P279 * wd:Q570116 ; wdt:P131 wd:Q118841 .
}

Using entities:
Grand Canyon, also known as Cañon of Colorado (wd:Q118841): steep-sided canyon carved by the Colorado River in Arizona, United States
tourist attraction, also known as attraction for tourists, POI for tourists, tourism attraction, touristic attraction, tourist place (wd:Q570116): place of interest where tourists visit

Using properties:
located in the administrative territorial entity, also known as is in the settlement of, is in the voivodeship of, is in the shire of, is in the state of, is in the territory of (wd:P131 as wdt): the item is located on the territory of the following administra...if the item falls only partially into the administrative entity., location, part of
subclass of, also known as rdfs:subClassOf, sort of, subcategory of, subgenre of, subtype of (wd:P279 as wdt): this item is a subclass (subset) of that item; ALL instances of ...stance of volcanic landform); Everest is an instance of mountain
instance of, also known as unitary element of class, has type, unique individual of, type, item of type (wd:P31 as wdt): that class of which this subject is a particular example and mem...is a subclass of mountain (and an instance of volcanic landform)

Example 3:
Question:
what is the newspaper in phoenix?

SPARQL:
SELECT DISTINCT ?x WHERE {
  {
    ?x wdt:P31 / wdt:P279 * wd:Q11032 .
  } UNION {
    ?x wdt:P31 / wdt:P279 * wd:Q1110794 .
  }
  ?x wdt:P131 wd:Q16556 .
}

Using entities:
newspaper, also known as news paper, news papers, newspapers (wd:Q11032): scheduled publication containing news of events, articles, features, editorials, and advertising
daily newspaper (wd:Q1110794): type of newspaper usually published daily
Phoenix, also known as City of Phoenix, Valley of the Sun, PHX, Phoenix, Arizona, Phoenix, AZ (wd:Q16556): city in Maricopa County, Arizona, United States

Using properties:
located in the administrative territorial entity, also known as is in the settlement of, is in the voivodeship of, is in the shire of, is in the state of, is in the territory of (wd:P131 as wdt): the item is located on the territory of the following administra...if the item falls only partially into the administrative entity., location, part of
subclass of, also known as rdfs:subClassOf, sort of, subcategory of, subgenre of, subtype of (wd:P279 as wdt): this item is a subclass (subset) of that item; ALL instances of ...stance of volcanic landform); Everest is an instance of mountain
instance of, also known as unitary element of class, has type, unique individual of, type, item of type (wd:P31 as wdt): that class of which this subject is a particular example and mem...is a subclass of mountain (and an instance of volcanic landform)

[Assistant]
From the similar examples, it is clear that to answer "what to see in Phoenix, Arizona," we should look for tourist attractions located in Phoenix. The entity for Phoenix is wd:Q16556 and the entity for tourist attraction is wd:Q570116.

I will now write a SPARQL query to find tourist attractions located in Phoenix, Arizona.

[Tool]
Got 3 rows and 2 columns:
| attraction                                       | attractionLabel                         |
| ------------------------------------------------ | --------------------------------------- |
| Castles N' Coasters (wd:Q5050593)                | Castles N' Coasters (en)                |
| Six Flags Hurricane Harbor Phoenix (wd:Q7989946) | Six Flags Hurricane Harbor Phoenix (en) |
| Phoenix Art Museum (wd:Q977015)                  | Phoenix Art Museum (en)                 |

[Assistant] I found some tourist attractions in Phoenix, Arizona: Castles N' Coasters, Six Flags Hurricane Harbor Phoenix, and Phoenix Art Museum. I will now check if there are more notable tourist attractions to include.

[Tool]
Got 3 rows and 2 columns:
| attraction                                       | attractionLabel                         |
| ------------------------------------------------ | --------------------------------------- |
| Castles N' Coasters (wd:Q5050593)                | Castles N' Coasters (en)                |
| Six Flags Hurricane Harbor Phoenix (wd:Q7989946) | Six Flags Hurricane Harbor Phoenix (en) |
| Phoenix Art Museum (wd:Q977015)                  | Phoenix Art Museum (en)                 |

[Assistant]
The results are the same with 3 tourist attractions: Castles N' Coasters, Six Flags Hurricane Harbor Phoenix, and Phoenix Art Museum. These are notable places to see in Phoenix, Arizona.

I will now provide the final answer with these attractions.

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves notable tourist attractions located in Phoenix, Arizona, using appropriate properties and classes. The answer lists relevant and well-known attractions, matching the query results. The query follows the rules by returning item identifiers and labels, and the answer is clear and informative. No further refinement is needed.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?spouse ?spouseLabel WHERE {
  wd:Q210172 wdt:P26 ?spouse .
  OPTIONAL {
    ?spouse rdfs:label ?spouseLabel FILTER ( LANG( ?spouseLabel ) = "en" )
  }
}

Kevin Jonas is married to Danielle Jonas.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] who is kevin jonas married to?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
who has been married to julia roberts?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q40523 wdt:P26 ?x .
}

Using entities:
Julia Roberts, also known as Julia Fiona Roberts (wd:Q40523): American actress (born 1967), television actor, film producer, voice actor, stage actor, film actor, actor, model

Using properties:
spouse, also known as married partner, married to, marry, partner, spouses (wd:P26 as wdt): the subject has the object as their spouse (husband, wife, partn...etc.). Use "unmarried partner" (P451) for non-married companions, significant person, relative

Example 2:
Question:
who is steve nash married to?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q192955 wdt:P26 ?x .
}

Using entities:
Steve Nash, also known as Stephen John Nash (wd:Q192955): Canadian basketball player and coach, basketball player, basketball coach, businessperson, film director

Using properties:
spouse, also known as married partner, married to, marry, partner, spouses (wd:P26 as wdt): the subject has the object as their spouse (husband, wife, partn...etc.). Use "unmarried partner" (P451) for non-married companions, significant person, relative

Example 3:
Question:
what is jonas brothers names?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q134233 wdt:P527 ?x .
}

Using entities:
Jonas Brothers, also known as The Jonas Brothers (wd:Q134233): American pop rock band

Using properties:
has part(s), also known as has component, incorporates, has ingredient, has ingredients, has member (wd:P527 as wdt): part of this subject; inverse property of "part of" (P361). See also "has parts of the class" (P2670).

[Assistant]
From the examples, the property for "married to" or "spouse" is wdt:P26. We need to find the entity for Kevin Jonas and then query for his spouse using this property.

Next, I will search for the entity "Kevin Jonas" in Wikidata.

[Tool]
Top 10 entity alternatives:
1. Kevin Jonas, also known as Paul Kevin Jonas II (wd:Q210172): American singer, actor and musician, singer-songwriter, television actor, voice actor, mandolinist, film actor, guitarist, composer, pianist, singer, actor
2. Kevin Jonas Sr. (wd:Q24849224): film producer
3. Jonah, also known as Jonas, Younas (wd:Q2468262): Biblical and Quranic prophet, preacher
4. Jonas, also known as Jonas Gonçalves Oliveira (wd:Q326476): association football player, Brazilian footballer, pharmacist
5. Jonas, also known as JONAS, Jonas L.A. (wd:Q217276): American TV series
6. Jonas Jonasson, also known as Pär-Ola Jonas Jonasson (wd:Q923556): Swedish journalist and writer, television producer, journalist, writer
7. Kevin, also known as Kevin, MT, Kevin, Montana (wd:Q962992): town in Toole County, Montana, United States
8. Kevin, also known as Kevin (first name), Kevin (given name) (wd:Q605834): male given name
9. Xu Kai, also known as Kevin (wd:Q56433872): Chinese actor and model, television actor, actor
10. Jonas (wd:Q4926920): name: given name and surname

[Assistant] The entity for Kevin Jonas is wd:Q210172. Now I will query for the spouse (property wdt:P26) of Kevin Jonas.

[Tool]
Got 1 row and 2 columns:
| spouse                        | spouseLabel         |
| ----------------------------- | ------------------- |
| Danielle Jonas (wd:Q50526598) | Danielle Jonas (en) |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the spouse of Kevin Jonas using the property wdt:P26 (spouse). It returns both the identifier and the English label of the spouse, which is Danielle Jonas. The answer is accurate and complete based on the query result. The query follows the rules by returning the actual identifier and optionally the label. No further refinement is necessary.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?causeOfDeath ?causeOfDeathLabel WHERE {
  wd:Q16397 wdt:P509 ?causeOfDeath .
  OPTIONAL {
    ?causeOfDeath rdfs:label ?causeOfDeathLabel FILTER ( LANG( ?causeOfDeathLabel ) = "en" )
  }
}

Got 1 row and 2 columns:
| causeOfDeath                | causeOfDeathLabel   |
| --------------------------- | ------------------- |
| cerebral edema (wd:Q979168) | cerebral edema (en) |

The cause of death for Bruce Lee was cerebral edema.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] what was the cause of death for bruce lee?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
what was the cause of death for sage stallone?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q440932 wdt:P509 ?x .
}

Using entities:
Sage Stallone (wd:Q440932): American actor, film director, and producer (1976-2012), film director, film producer, screenwriter, film actor, composer, actor

Using properties:
cause of death, also known as death cause, murder method, method of murder, die of, die from (wd:P509 as wdt): underlying or immediate cause of death.  Underlying cause (e.g. ...adest category, e.g. natural causes, accident, homicide, suicide

Example 2:
Question:
what did bob ross die of?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q455511 wdt:P509 ?x .
}

Using entities:
Bob Ross, also known as Robert Ross, Robert Norman "Bob" Ross, Bob Roos (wd:Q455511): American painter, art instructor, television host, and Air Force master sergeant (1942–1995), television presenter, clinical coder, painter

Using properties:
cause of death, also known as death cause, murder method, method of murder, die of, die from (wd:P509 as wdt): underlying or immediate cause of death.  Underlying cause (e.g. ...adest category, e.g. natural causes, accident, homicide, suicide

Example 3:
Question:
what did roy rogers die of?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q367129 wdt:P509 ?x .
}

Using entities:
Roy Rogers, also known as Leonard Slye, Leonard Sly, Leonard Frank Sly, Leonard Franklin Slye (wd:Q367129): American actor and singer (1911-1998), television actor, songwriter, film actor, yodeler, singer, actor

Using properties:
cause of death, also known as death cause, murder method, method of murder, die of, die from (wd:P509 as wdt): underlying or immediate cause of death.  Underlying cause (e.g. ...adest category, e.g. natural causes, accident, homicide, suicide

[Assistant] From the examples, it is clear that the property for cause of death in Wikidata is wdt:P509. Next, I will search for the entity Bruce Lee to get his Wikidata identifier.

[Tool]
Top 10 entity alternatives:
1. Bruce Lee, also known as Lee Jun-fan (wd:Q16397): Chinese-American martial artist and actor (1940–1973), stunt coordinator, television actor, stunt performer, martial artist, film director, film producer, screenwriter, film actor, director, writer, actor
2. Statue of Bruce Lee, also known as Bruce Lee, Statue of Bruce Lee, Hong Kong, Bruce Lee statue (wd:Q4353553): statue in Hong Kong
3. Bruce Lee (wd:Q924462): 1984 video game
4. Bruce Lee (wd:Q21646198): 2017 film directed by Prashanth Pandiraj
5. Statue of Bruce Lee, also known as Statue of Bruce Lee, Los Angeles, Bruce Lee statue in Los Angeles, Bruce Lee statue, Bruce Lee (wd:Q28222834): statue in Los Angeles, California
6. Bruce Lee (wd:Q4977859): 1999 single by Underworld
7. Bruce Y. Lee, also known as Bruce Y Lee, Bruce Lee (wd:Q65555428): researcher, journalist
8. Bruce Lee (wd:Q4977856): comic book series by Mike Baron
9. Benalla, also known as Bruce Lee (wd:Q55657662): family name
10. Bruce Lee (wd:Q100875335): college basketball player (1982–1983) Oklahoma, basketball player

[Assistant] The entity for Bruce Lee is wd:Q16397. Now I will query the cause of death (wdt:P509) for Bruce Lee.

[Tool]
Got 1 row and 2 columns:
| causeOfDeath                | causeOfDeathLabel   |
| --------------------------- | ------------------- |
| cerebral edema (wd:Q979168) | cerebral edema (en) |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the cause of death for Bruce Lee using the property wdt:P509. The query returns the identifier and the English label for the cause of death, which is cerebral edema. The answer is accurate and complete based on the data from Wikidata. No further refinement is necessary.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?occupation ?occupationLabel WHERE {
  wd:Q133622 wdt:P106 ?occupation .
  OPTIONAL {
    ?occupation rdfs:label ?occupationLabel FILTER ( LANG( ?occupationLabel ) = "en" )
  }
}

Got 14 rows and 2 columns, showing the first 5 and last 5 rows below:
| occupation                     | occupationLabel       |
| ------------------------------ | --------------------- |
| explorer (wd:Q11900058)        | explorer (en)         |
| ethnographer (wd:Q12347522)    | ethnographer (en)     |
| researcher (wd:Q1650915)       | researcher (en)       |
| world traveler (wd:Q1937330)   | world traveler (en)   |
| historian (wd:Q201788)         | historian (en)        |
| ...                            | ...                   |
| writer (wd:Q36180)             | writer (en)           |
| archaeologist (wd:Q3621491)    | archaeologist (en)    |
| marine biologist (wd:Q3640160) | marine biologist (en) |
| sailor (wd:Q45199)             | sailor (en)           |
| anthropologist (wd:Q4773904)   | anthropologist (en)   |

Thor Heyerdahl (wd:Q133622) was a Norwegian anthropologist and adventurer. His occupations include explorer, ethnographer, researcher, world traveler, historian, writer, archaeologist, marine biologist, sailor, and anthropologist.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] who is thor heyerdahl?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
who is henry david thoreau?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q131149 wdt:P106 ?x .
}

Using entities:
Henry David Thoreau, also known as Henry Thoreau, Thoreau, Henry D. Thoreau (wd:Q131149): American essayist, poet, and philosopher (1817–1862), environmentalist, autobiographer, abolitionist, philosopher, translator, naturalist, ecologist, essayist, diarist, writer, poet

Using properties:
occupation, also known as job, work, vocation, profession, employment (wd:P106 as wdt): occupation of a person; see also "field of work" (Property:P101), "position held" (Property:P39)

Example 2:
Question:
where did sir ernest shackleton come from?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q957543 wdt:P19 ?x .
}

Using entities:
Ernest Shackleton, also known as Sir Ernest Henry Shackleton (wd:Q957543): Anglo-Irish Antarctic explorer (1874–1922), military officer, polar explorer, traveler, explorer

Using properties:
place of birth, also known as POB, location of birth, location born, born in, birthplace (wd:P19 as wdt): most specific known birth location of a person, animal or fictional character, location

Example 3:
Question:
who was louis riel?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q313691 wdt:P106 ?x .
}

Using entities:
Louis Riel, also known as Louis "David" Riel (wd:Q313691): Métis leader in Canada (1844–1885), politician

Using properties:
occupation, also known as job, work, vocation, profession, employment (wd:P106 as wdt): occupation of a person; see also "field of work" (Property:P101), "position held" (Property:P39)

[Assistant]
The question "Who is Thor Heyerdahl?" is asking for information about the person Thor Heyerdahl, likely including his occupation or notable roles. From the similar examples, we see that the property "occupation" (wdt:P106) is commonly used to describe who a person is in terms of their profession or notable roles.

Step 1: Search for the entity "Thor Heyerdahl" in Wikidata to get his identifier.
Step 2: Query his occupation(s) using the property wdt:P106.

I will start by searching for the entity "Thor Heyerdahl" in Wikidata.

[Tool]
Top 10 entity alternatives:
1. Thor Heyerdahl, also known as Th. Heyerdahl, T. Heyerdahl, Dr Thor Heyerdahl (wd:Q133622): Norwegian anthropologist and adventurer (1914-2002), marine biologist, anthropologist, world traveler, archaeologist, film director, ethnographer, screenwriter, researcher, adventurer, historian, traveler, explorer, writer, sailor
2. Thor Heyerdahl, also known as IMO 5221491, Marga Henning, Minnow, Silke, Tinka (wd:Q1615407): schooner
3. Thor Heyerdahl (wd:Q108840549): 25 Sep 1869 Kristiana, Norway - 1957
4. Thor Heyerdahl, also known as Thor Heyerdahl jr. (wd:Q76360462): son of the adventurer Thor Heyerdahl, marine biologist, marine scientist, teacher
5. HNoMS Thor Heyerdahl, also known as F314 (wd:Q3436458): 2009 Fridtjof Nansen-class frigate
6. Thor Heyerdahl Archives (wd:Q28028353): Memory of the World inscription, submitted by Norway, added in 2011
7. Thorleif Heyerdahl (wd:Q96146229): draftsperson, painter
8. Thorvald Heyerdahl (wd:Q126167314): Nordic skiing
9. Thorbjørn Heyerdahl (wd:Q12006178): civil servant, (1854-1931)
10. Thor Heyerdahl Climate Park (wd:Q20992112): nature restoration park in Myanmar

[Assistant]
The entity "Thor Heyerdahl" we are interested in is wd:Q133622, a Norwegian anthropologist and adventurer (1914-2002).

Next, I will query the occupations of Thor Heyerdahl using the property wdt:P106.

[Tool]
Got 14 rows and 2 columns, showing the first 5 and last 5 rows below:
| occupation                     | occupationLabel       |
| ------------------------------ | --------------------- |
| explorer (wd:Q11900058)        | explorer (en)         |
| ethnographer (wd:Q12347522)    | ethnographer (en)     |
| researcher (wd:Q1650915)       | researcher (en)       |
| world traveler (wd:Q1937330)   | world traveler (en)   |
| historian (wd:Q201788)         | historian (en)        |
| ...                            | ...                   |
| writer (wd:Q36180)             | writer (en)           |
| archaeologist (wd:Q3621491)    | archaeologist (en)    |
| marine biologist (wd:Q3640160) | marine biologist (en) |
| sailor (wd:Q45199)             | sailor (en)           |
| anthropologist (wd:Q4773904)   | anthropologist (en)   |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The answer correctly identifies Thor Heyerdahl and provides a comprehensive list of his occupations as retrieved from Wikidata. The SPARQL query is well-formed, retrieving all occupations of Thor Heyerdahl along with their English labels. The query respects the requirement to return identifiers and labels optionally. The answer is complete and accurate based on the data available. No further refinement is necessary.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?country ?countryLabel WHERE {
  wd:Q34086 wdt:P27 ?country .
  OPTIONAL {
    ?country rdfs:label ?countryLabel FILTER ( LANG( ?countryLabel ) = "en" )
  }
}

Got 1 row and 2 columns:
| country         | countryLabel |
| --------------- | ------------ |
| Canada (wd:Q16) | Canada (en)  |

Justin Bieber comes from Canada.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] what country does justin bieber come from?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
where did justin bieber grew up?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q34086 wdt:P19 ?x .
}

Using entities:
Justin Bieber, also known as Justin Drew Bieber (wd:Q34086): Canadian singer (born 1994), musician

Using properties:
place of birth, also known as POB, location of birth, location born, born in, birthplace (wd:P19 as wdt): most specific known birth location of a person, animal or fictional character, location

Example 2:
Question:
what is the name of justin bieber brother?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q34086 wdt:P3373 ?x .
  ?x wdt:P21 wd:Q6581097 .
}

Using entities:
Justin Bieber, also known as Justin Drew Bieber (wd:Q34086): Canadian singer (born 1994), musician
male, also known as guy, m, male character, male gender, male human (wd:Q6581097): to be used in "sex or gender" (P21) to indicate that the human s...gender" (P10339) to indicate that a word refers to a male person

Using properties:
sex or gender, also known as gender or sex, sex, gender identity, gender expression, gender (wd:P21 as wdt): sex or gender identity of human or animal. For human: male, fema...m, female organism. Groups of same gender use subclass of (P279)
sibling, also known as is sister of, is the brother of, is the sibling of, is the sister of, sib (wd:P3373 as wdt): the subject and the object have at least one common parent (brot...law, etc.) and step-siblings (step-brothers, step-sisters, etc.), relative

Example 3:
Question:
where did rihanna come from?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q36844 wdt:P19 ?x .
}

Using entities:
Rihanna, also known as Barbadian singer, Rihana, Robyn Fenty, Robyn Rihanna Fenty (wd:Q36844): Barbadian singer and actress, singer

Using properties:
place of birth, also known as POB, location of birth, location born, born in, birthplace (wd:P19 as wdt): most specific known birth location of a person, animal or fictional character, location

[Assistant]
From the examples, the property "place of birth" (wdt:P19) is used to find the place where a person comes from. To answer the question "what country does Justin Bieber come from?" we need to find the country of his place of birth or nationality.

First, let's identify Justin Bieber's entity in Wikidata. From the examples, it is wd:Q34086. Next, we will check the country of his place of birth or his country of citizenship. The property for country of citizenship is wdt:P27.

I will now write a SPARQL query to get the country of citizenship for Justin Bieber.

[Tool]
Got 1 row and 2 columns:
| country         | countryLabel |
| --------------- | ------------ |
| Canada (wd:Q16) | Canada (en)  |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the country of citizenship for Justin Bieber using the property P27. The query returns the identifier and the English label of the country, which is Canada. The answer provided is accurate and complete based on the query result. No further refinement is needed.


PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?vicePresident ?vicePresidentLabel WHERE {
  ?vicePresident p:P39 ?vpPosition .
  ?vpPosition ps:P39 wd:Q11699 ; pq:P580 ?vpStartTime .
  wd:Q1124 p:P39 ?presPosition .
  ?presPosition ps:P39 wd:Q11696 ; pq:P580 ?presStartTime .
  FILTER ( ?vpStartTime = ?presStartTime ) OPTIONAL {
    ?vicePresident rdfs:label ?vicePresidentLabel .
    FILTER ( LANG( ?vicePresidentLabel ) = "en" )
  }
}

Got 1 row and 2 columns:
| vicePresident       | vicePresidentLabel |
| ------------------- | ------------------ |
| Al Gore (wd:Q19673) | Al Gore (en)       |

The vice president who served with Bill Clinton was Al Gore.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] who was vice president with bill clinton?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
who was the vice president when bill clinton was in office?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x p:P39 ?p .
  ?p ps:P39 wd:Q11699 ; pq:P580 ?y .
  wd:Q1124 p:P39 ?q .
  ?q ps:P39 wd:Q11696 ; pq:P580 ?z .
  FILTER ( ?y = ?z )
}

Using entities:
Bill Clinton, also known as William Jefferson Blythe, William Jefferson Blythe III, William Jefferson "Bill" Clinton, William Jefferson Clinton, WJC (wd:Q1124): President of the United States from 1993 to 2001, autobiographer, statesperson, saxophonist, politician, governor, diplomat, teacher, jurist, lawyer, writer
President of the United States, also known as US President, U.S. President, United States President, the president of the United States, President of the U.S. (wd:Q11696): head of state and head of government of the United States of America
Vice President of the United States, also known as President of the Senate, President of the United States Senate, United States Vice President, United States VP, USA VP (wd:Q11699): second-highest constitutional office in the United States

Using properties:
position held, also known as function, held position, holds position, job, office held (wd:P39 as ps/p): subject currently or formerly holds the object position or public office
start time, also known as start date, since, valid, join time, joined (wd:P580 as pq): time an entity begins to exist or a statement starts being valid, point in time

Example 2:
Question:
who was vice president under ronald reagan?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x p:P39 ?p .
  ?p ps:P39 wd:Q11699 ; pq:P580 ?y .
  wd:Q9960 p:P39 ?q .
  ?q ps:P39 wd:Q11696 ; pq:P580 ?z .
  FILTER ( ?y = ?z )
}

Using entities:
President of the United States, also known as US President, U.S. President, United States President, the president of the United States, President of the U.S. (wd:Q11696): head of state and head of government of the United States of America
Vice President of the United States, also known as President of the Senate, President of the United States Senate, United States Vice President, United States VP, USA VP (wd:Q11699): second-highest constitutional office in the United States
Ronald Reagan, also known as Ronald W Reagan, Ronald W. Reagan, R. W. Reagan, President Reagan, President Ronald Reagan (wd:Q9960): president of the United States from 1981 to 1989 and actor, television actor, military officer, character actor, game show host, autobiographer, anti-communist, trade unionist, art collector, statesperson, screenwriter, voice actor, film actor, politician, announcer, lifeguard, diarist, actor

Using properties:
position held, also known as function, held position, holds position, job, office held (wd:P39 as ps/p): subject currently or formerly holds the object position or public office
start time, also known as start date, since, valid, join time, joined (wd:P580 as pq): time an entity begins to exist or a statement starts being valid, point in time

Example 3:
Question:
who was president when nelson rockefeller was vice president?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x p:P39 ?y .
  ?y ps:P39 wd:Q11696 ; pq:P580 ?p ; pq:P582 ?q .
  wd:Q11237 p:P39 ?z .
  ?z ps:P39 wd:Q11699 ; pq:P580 ?w ; pq:P582 ?v .
  FILTER ( ( ?w >= ?p ) && ( ?v <= ?q ) )
}

Using entities:
Nelson Rockefeller, also known as Nelson A. Rockefeller, Nelson Aldrich Rockefeller (wd:Q11237): Vice President of the United States from 1974 to 1977, businessperson, philanthropist, art collector, politician
President of the United States, also known as US President, U.S. President, United States President, the president of the United States, President of the U.S. (wd:Q11696): head of state and head of government of the United States of America
Vice President of the United States, also known as President of the Senate, President of the United States Senate, United States Vice President, United States VP, USA VP (wd:Q11699): second-highest constitutional office in the United States

Using properties:
position held, also known as function, held position, holds position, job, office held (wd:P39 as ps/p): subject currently or formerly holds the object position or public office
start time, also known as start date, since, valid, join time, joined (wd:P580 as pq): time an entity begins to exist or a statement starts being valid, point in time
end time, also known as ends, stop time, endtime, fall date, ineffective (wd:P582 as pq): moment when an entity ceases to exist and a statement stops being entirely valid or no longer be true, point in time

[Assistant]
From the examples, the approach to find the vice president with Bill Clinton is to:
- Identify Bill Clinton's presidential term start time.
- Find the person who held the position of Vice President of the United States with the same start time.

I will now write a SPARQL query to find the vice president who served with Bill Clinton.

[Tool]
SPARQL execution failed:
Error while executing a SERVICE request to <http://wikiba.se:80/ontology#label>: SERVICE responded with HTTP status code: 301, Moved Permanently. First 100 bytes of the response: '<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently'

[Assistant] The query failed because the SERVICE wikibase:label is not supported by the endpoint. I will rewrite the query without using SERVICE wikibase:label and instead use optional rdfs:label to get the vice president's name.

[Tool]
Got 1 row and 2 columns:
| vicePresident       | vicePresidentLabel |
| ------------------- | ------------------ |
| Al Gore (wd:Q19673) | Al Gore (en)       |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly identifies Al Gore as the vice president who served with Bill Clinton by matching the start times of their respective positions. The query returns the vice president's identifier and label, which is appropriate. The answer is accurate and complete based on the data retrieved. No further refinement is necessary.


PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?actor WHERE {
  wd:Q23831 p:P161 ?castStatement .
  ?castStatement ps:P161 ?actor ; pq:P453 wd:Q4169030 .
}

The actor who plays Dwight Schrute in the American TV series The Office is Rainn Wilson.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] who plays dwight in the office?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
who does larry david play in seinfeld?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q23733 p:P161 ?p .
  ?p ps:P161 wd:Q23728 ; pq:P453 ?x .
}

Using entities:
Larry David, also known as Lawrence Gene David, Lawrence Gene "Larry" David, Lawrence David (wd:Q23728): American comedian, writer and actor (born 1947), television producer, television director, television actor, film producer, screenwriter, voice actor, film actor, comedian, writer, actor
Seinfeld (wd:Q23733): American television sitcom (1989–1998)

Using properties:
cast member, also known as feat., starring (film/play), film starring, starring, actor (wd:P161 as ps/p): actor in the subject production [use "character role" (P453) and...use "recorded participant" (P11108) for non-fiction productions], significant person, performer
character role, also known as role, plays, performer of, as, acting role (wd:P453 as pq): specific role played or filled by subject -- use only as qualifier of "cast member" (P161), "voice actor" (P725)

Example 2:
Question:
who played captain kirk in star trek?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?p p:P161 ?y .
  ?y ps:P161 ?x ; pq:P453 wd:Q16311 .
}

Using entities:
James T. Kirk, also known as James Kirk, James Tiberius Kirk, Jim Kirk, Captain Kirk, Captain James Tiberius Kirk (wd:Q16311): fictional character from Star Trek, spaceship captain, tactician, explorer

Using properties:
cast member, also known as feat., starring (film/play), film starring, starring, actor (wd:P161 as ps/p): actor in the subject production [use "character role" (P453) and...use "recorded participant" (P11108) for non-fiction productions], significant person, performer
character role, also known as role, plays, performer of, as, acting role (wd:P453 as pq): specific role played or filled by subject -- use only as qualifier of "cast member" (P161), "voice actor" (P725)

Example 3:
Question:
who played andy in toy story 3?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q187278 p:P725 ?p .
  ?p ps:P725 ?x ; pq:P453 wd:Q1808466 .
}

Using entities:
Andy Davis (wd:Q1808466): Toy Story character
Toy Story 3 (wd:Q187278): 2010 American animated film

Using properties:
character role, also known as role, plays, performer of, as, acting role (wd:P453 as pq): specific role played or filled by subject -- use only as qualifier of "cast member" (P161), "voice actor" (P725)
voice actor, also known as voice actors, voice dubber, voice actress, voice actresses, voiced by (wd:P725 as ps/p): performer of a spoken role in a creative work such as animation,... (P453) as qualifier] [use "cast member" (P161) for live acting], film crew member, cast member

[Assistant]
From the examples, it is clear that the query pattern to find the actor playing a character in a TV show is to find the TV show entity, then use the property "cast member" (P161) with a qualifier "character role" (P453) to specify the character.

Next, I need to find the Wikidata entity for "The Office" and the entity for the character "Dwight" in that show. Then I will construct the SPARQL query accordingly. I will start by searching for the entity "The Office".

[Tool]
Top 10 entity alternatives:
1. The Office, also known as Flor cabrera (wd:Q23831): American sitcom broadcast on NBC
2. The Office (wd:Q23829): British sitcom television series
3. The Office, also known as Office (wd:Q4006581): 1966 Short film directed by Krzysztof Kieślowski
4. The Office (wd:Q43129905): International series of mockumentary sitcoms
5. The Office (wd:Q7754718): 2007 video game
6. The Office (wd:Q3220664)
7. The Office (wd:Q65043588): Indian TV series
8. The Office (wd:Q130441989): Australian TV series
9. The Office (wd:Q130537628): pub in Warton, Polesworth, North Warwickshire, Warwickshire, England
10. The Office (wd:Q20709864): 1995 American television series

[Assistant]
There are multiple entities for "The Office." The most relevant for the popular TV series are:
- The Office (British sitcom) wd:Q23829
- The Office (American sitcom) wd:Q23831 (noted as American sitcom broadcast on NBC)
- The Office (International series of mockumentary sitcoms) wd:Q43129905

Since the user likely refers to the American version, I will use wd:Q23831 for the American sitcom "The Office."

Next, I will search for the character "Dwight" in the context of "The Office" (American version). I will search for the entity "Dwight" related to "The Office."

[Tool]
Top 10 entity alternatives:
1. The Office, also known as Flor cabrera (wd:Q23831): American sitcom broadcast on NBC
2. The Office (wd:Q23829): British sitcom television series
3. The Office, also known as Office (wd:Q4006581): 1966 Short film directed by Krzysztof Kieślowski
4. The Office (wd:Q43129905): International series of mockumentary sitcoms
5. The Office (wd:Q7754718): 2007 video game
6. The Office (wd:Q3220664)
7. The Office (wd:Q65043588): Indian TV series
8. The Office (wd:Q130441989): Australian TV series
9. The Office (wd:Q130537628): pub in Warton, Polesworth, North Warwickshire, Warwickshire, England
10. The Office (wd:Q20709864): 1995 American television series

[Assistant] The search for "Dwight The Office" did not return a direct entity for the character Dwight from The Office. I will try a different approach by searching for the property "character role" (P453) used in the context of "The Office" (American version) to find the character "Dwight." I will list the cast members of The Office (American version) with their character roles.

[Tool]
Got 1 row and 4 columns:
| actor                     | actorLabel        | character                    | characterLabel      |
| ------------------------- | ----------------- | ---------------------------- | ------------------- |
| Rainn Wilson (wd:Q349548) | Rainn Wilson (en) | Dwight Schrute (wd:Q4169030) | Dwight Schrute (en) |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly identifies the actor who plays Dwight Schrute in the American TV series The Office. It uses the property 'cast member' (P161) with the qualifier 'character role' (P453) to filter for the character Dwight Schrute (wd:Q4169030). The query returns the actor Rainn Wilson (wd:Q349548), which is accurate. The answer is clear and complete, and the query follows the rules by returning the identifier of the actor. No further refinement is needed.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?holiday ?holidayLabel WHERE {
  ?holiday wdt:P31 / wdt:P279 * wd:Q1197685 ; wdt:P140 wd:Q432 .
  OPTIONAL {
    ?holiday rdfs:label ?holidayLabel FILTER ( LANG( ?holidayLabel ) = "en" )
  }
}

Got 2 rows and 2 columns:
| holiday                  | holidayLabel     |
| ------------------------ | ---------------- |
| Eid al-Fitr (wd:Q464458) | Eid al-Fitr (en) |
| Eid al-Adha (wd:Q514400) | Eid al-Adha (en) |

The important holidays of Islam are Eid al-Fitr and Eid al-Adha.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] what are the important holidays of islam?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
what are the holidays of islam?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P31 / wdt:P279 * wd:Q1197685 ; wdt:P140 wd:Q432 .
}

Using entities:
public holiday, also known as legal holiday, national holiday, state holiday, statutory holiday (wd:Q1197685): holiday generally established by law, usually a non-working day for most people
Islam, also known as al-’islām, Islamic religion, religion of the Muslims, Mohammedanism, Muslim religion (wd:Q432): Abrahamic religion founded by Muhammad

Using properties:
religion or worldview, also known as believes, worldview, religious affiliation, religion or world view, religion (wd:P140 as wdt): religion of a person, organization or religious building, or associated with this subject
subclass of, also known as rdfs:subClassOf, sort of, subcategory of, subgenre of, subtype of (wd:P279 as wdt): this item is a subclass (subset) of that item; ALL instances of ...stance of volcanic landform); Everest is an instance of mountain
instance of, also known as unitary element of class, has type, unique individual of, type, item of type (wd:P31 as wdt): that class of which this subject is a particular example and mem...is a subclass of mountain (and an instance of volcanic landform)

Example 2:
Question:
who does the islam worship?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P1049 wd:Q432 .
}

Using entities:
Islam, also known as al-’islām, Islamic religion, religion of the Muslims, Mohammedanism, Muslim religion (wd:Q432): Abrahamic religion founded by Muhammad

Using properties:
worshipped by, also known as deity of (wd:P1049 as wdt): religion or group/civilization that worships a given deity, part of

Example 3:
Question:
what are the basic beliefs of islam religion?

SPARQL:
SELECT DISTINCT ?x WHERE {
  ?x wdt:P1049 wd:Q432 .
}

Using entities:
Islam, also known as al-’islām, Islamic religion, religion of the Muslims, Mohammedanism, Muslim religion (wd:Q432): Abrahamic religion founded by Muhammad

Using properties:
worshipped by, also known as deity of (wd:P1049 as wdt): religion or group/civilization that worships a given deity, part of

[Assistant]
From the similar example, we see that holidays related to Islam can be found by looking for entities that are instances or subclasses of "holiday" and are associated with the religion Islam (wd:Q432).

I will now try a query to find important holidays of Islam by looking for entities that are instances of holiday and are linked to Islam as their religion.

[Tool]
Got 2 rows and 2 columns:
| holiday                  | holidayLabel     |
| ------------------------ | ---------------- |
| Eid al-Fitr (wd:Q464458) | Eid al-Fitr (en) |
| Eid al-Adha (wd:Q514400) | Eid al-Adha (en) |

[Assistant] The important holidays of Islam found are Eid al-Fitr and Eid al-Adha. I will now provide the final answer with this information.

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves holidays that are instances or subclasses of 'holiday' and are associated with the religion Islam. The query returns the two well-known important Islamic holidays, Eid al-Fitr and Eid al-Adha, which matches the expected answer. The query also includes English labels for readability. The answer is accurate and complete for the question asked.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?country ?countryLabel WHERE {
  wd:Q1496 wdt:P27 ?country .
  OPTIONAL {
    ?country rdfs:label ?countryLabel FILTER ( LANG( ?countryLabel ) = "en" )
  }
}

Ferdinand Magellan represented the Kingdom of Portugal.

[System]
You are a question answering assistant. Your job is to generate a SPARQL query to answer a given user question.

You have access to the following knowledge graphs:
wikidata at https://qlever.cs.uni-freiburg.de/api/wikidata

You can use the following SPARQL prefixes implicitly in all functions:
cc: <http://creativecommons.org/ns#
data: <https://www.wikidata.org/wiki/Special:EntityData/
dct: <http://purl.org/dc/terms/
geo: <http://www.opengis.net/ont/geosparql#
geof: <http://www.opengis.net/def/function/geosparql/
imdb: <https://www.imdb.com/
math: <http://www.w3.org/2005/xpath-functions/math#
ontolex: <http://www.w3.org/ns/lemon/ontolex#
owl: <http://www.w3.org/2002/07/owl#
p: <http://www.wikidata.org/prop/
pq: <http://www.wikidata.org/prop/qualifier/
pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/
pqv: <http://www.wikidata.org/prop/qualifier/value/
pr: <http://www.wikidata.org/prop/reference/
prn: <http://www.wikidata.org/prop/reference/value-normalized/
prov: <http://www.w3.org/ns/prov#
prv: <http://www.wikidata.org/prop/reference/value/
ps: <http://www.wikidata.org/prop/statement/
psn: <http://www.wikidata.org/prop/statement/value-normalized/
psv: <http://www.wikidata.org/prop/statement/value/
qfn: <http://qlever.cs.uni-freiburg.de/function#
ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: <http://www.w3.org/2000/01/rdf-schema#
ref: <http://www.wikidata.org/reference/
s: <http://www.wikidata.org/entity/statement/
schema: <http://schema.org/
skos: <http://www.w3.org/2004/02/skos/core#
v: <http://www.wikidata.org/value/
wd: <http://www.wikidata.org/entity/
wdno: <http://www.wikidata.org/prop/novalue/
wdt: <http://www.wikidata.org/prop/direct/
wdtn: <http://www.wikidata.org/prop/direct-normalized/
wikibase: <http://wikiba.se/ontology#
xsd: <http://www.w3.org/2001/XMLSchema#
foaf: <http://xmlns.com/foaf/0.1/
dc: <http://purl.org/dc/elements/1.1/
gn: <http://www.geonames.org/ontology#
bd: <http://www.bigdata.com/rdf#
hint: <http://www.bigdata.com/queryHints#
qb: <http://purl.org/linked-data/cube#
void: <http://rdfs.org/ns/void#

You should follow a step-by-step approach to generate the SPARQL query:
1. Determine possible entities and properties implied by the user question.
2. Use the functions to search for entities and properties in the knowledge graphs. Where applicable, constrain the searches with already identified entities and properties.
3. Gradually build up the SPARQL query using the identified entities and properties. Start with simple queries and add more complexity as needed. Use the execute function to get feedback on intermediate queries. You can go back and forth between knowledge graph searches and SPARQL query executions to refine the query.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Additional rules:
1. Explain your thought process before and after each step and function call.
2. Do not assume or make up any entities or properties without verifying them with the knowledge graphs and functions.
3. The SPARQL query should always return the actual identifiers / IRIs of the items in its result. It additionally may return labels or other human-readable information, but they are optional and should be put within optional clauses unless explicitly requested by the user.
4. Do not stop early if there are still obvious improvements to be made to the SPARQL query. For example, keep refining your SPARQL query if its result contains irrelevant items or is missing items you expected.
5. Do not perform additional computation (e.g. filtering, sorting, calculations) on the result of the SPARQL query to determine the answer. All computation should be done solely within SPARQL.
6. For questions with a "True" or "False" answer the SPARQL query should be an ASK query.
7. Do not use 'SERVICE wikibase:label { bd:serviceParam wikibase:language ...' in SPARQL queries. It is not SPARQL standard and unsupported by the used QLever SPARQL endpoints. Use rdfs:label or similar properties to get labels instead.

[User] what country did magellan represent?

[Assistant] Let's start by looking at some similar examples.

[Tool]
Example 1:
Question:
what country did francis drake represent?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q36517 wdt:P27 ?x .
}

Using entities:
Francis Drake, also known as Sir Francis Drake (wd:Q36517): English sailor and privateer (c. 1540 – 1596), military personnel, politician, privateer, engineer, explorer, sailor

Using properties:
country of citizenship, also known as subject of (country), nation of citizenship, national of, nationality, nation (wd:P27 as wdt): the object is a country that recognizes the subject as its citizen, country

Example 2:
Question:
what country did francis drake explored for?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q36517 wdt:P27 ?x .
}

Using entities:
Francis Drake, also known as Sir Francis Drake (wd:Q36517): English sailor and privateer (c. 1540 – 1596), military personnel, politician, privateer, engineer, explorer, sailor

Using properties:
country of citizenship, also known as subject of (country), nation of citizenship, national of, nationality, nation (wd:P27 as wdt): the object is a country that recognizes the subject as its citizen, country

Example 3:
Question:
what country columbus was born?

SPARQL:
SELECT DISTINCT ?x WHERE {
  wd:Q7322 wdt:P19 ?p .
  ?p wdt:P17 ?x .
}

Using entities:
Christopher Columbus, also known as Cristóbal Colón, Cristoforo Colombo, Don Cristobál Colón, 'Christopher Columbus', Cristobal Colon, Christofer Columbus (wd:Q7322): Italian navigator, explorer, and colonist (1451–1506), explorer, seafarer, traveler, inventor, sailor

Using properties:
country, also known as sovereign state, state, land, host country (wd:P17 as wdt): sovereign state that this item is in (not to be used for human beings), located in the administrative territorial entity
place of birth, also known as POB, location of birth, location born, born in, birthplace (wd:P19 as wdt): most specific known birth location of a person, animal or fictional character, location

[Assistant]
From the similar examples, it appears that the property "country of citizenship" (wdt:P27) is used to indicate the country a person represented or was a citizen of.

Next, I will search for the entity "Magellan" to find the correct Wikidata identifier for him.

[Tool]
Top 10 entity alternatives:
1. Ferdinand Magellan, also known as Fernando de Magallanes, Fernão de Magalhães, Hernando de Magallanes, Magallanes, Magellan (wd:Q1496): Portuguese explorer in the service of Spain, seafarer, explorer, sailor
2. Magellan, also known as VRM, VOIR, Venus Radar Mapper, Magellan spacecraft, Magellan orbiter (wd:Q466932): NASA robotic space probe that studied the planet Venus
3. 4055 Magellan, also known as Magellan (wd:Q152597): asteroid
4. Magellan (wd:Q1883965): progressive metal group
5. Magellan (wd:Q3843119): fictional character from One Piece, prison warden
6. Magellan (wd:Q102045488): biography by Stefan Zweig
7. Magellan (wd:Q31669317): summit in New Zealand
8. GPS-III SV02, also known as GPS SVN 75, GPS-3 2, USA-293, Magellan, Navstar 78 (wd:Q106405833): GPS III satellite
9. Magellan (wd:Q11766140): Polish business
10. Magellan (wd:Q130438249)

[Assistant]
The entity "Ferdinand Magellan" (wd:Q1496) is the correct one for the Portuguese explorer in the service of Spain.

Now, I will query the country that Ferdinand Magellan represented using the property "country of citizenship" (wdt:P27).

[Tool]
Got 1 row and 2 columns:
| country                         | countryLabel             |
| ------------------------------- | ------------------------ |
| Kingdom of Portugal (wd:Q45670) | Kingdom of Portugal (en) |

[Assistant] Ferdinand Magellan represented the Kingdom of Portugal. I will now provide the final answer with the SPARQL query.

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the country of citizenship (wdt:P27) for Ferdinand Magellan (wd:Q1496), which is the Kingdom of Portugal. The answer matches historical facts that Magellan was Portuguese by nationality. The query also includes an optional label for readability. The output is accurate and complete for the user's question.