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 ?instrument ?instrumentLabel WHERE {
  wd:Q154216 wdt:P1303 ?instrument .
  OPTIONAL {
    ?instrument rdfs:label ?instrumentLabel FILTER ( LANG( ?instrumentLabel ) = "en" )
  }
}

Got 4 rows and 2 columns:
| instrument              | instrumentLabel  |
| ----------------------- | ---------------- |
| voice (wd:Q17172850)    | voice (en)       |
| bass guitar (wd:Q46185) | bass guitar (en) |
| piano (wd:Q5994)        | piano (en)       |
| guitar (wd:Q6607)       | guitar (en)      |

Cat Stevens plays the following instruments: voice, bass guitar, piano, and guitar.

[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] Which instruments does Cat Stevens play?

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

[Tool]
Example 1:
Question:
What kind of music did Lou Reed play?

SPARQL:
SELECT DISTINCT ?uri WHERE {
  wd:Q189080 wdt:P136 ?uri .
}

Using entities:
Lou Reed, also known as Lewis Allen Reed, Lewis A. Reed, Lewis Allan Reed (wd:Q189080): American rock musician (1942–2013), singer-songwriter, record producer, music executive, film director, photographer, songwriter, guitarist, musician, composer, singer, actor, poet

Using properties:
genre, also known as genre of music, type of music, type of film, music genre, literary genre (wd:P136 as wdt): creative work's genre or an artist's field of work (P101). Use main subject (P921) to relate creative works to their topic

[Assistant] The example shows how to query the music genre of an artist using the property "genre" (wdt:P136). For instruments played by an artist, we need to find the appropriate property. Let's search for properties related to "instrument" for the entity Cat Stevens.

[Tool]
Top 10 entity alternatives:
1. Cat Stevens, also known as Yusuf Islam, Yusuf Islam (Cat Stevens), Yusuf/Cat Stevens, Yusuf (wd:Q154216): British musician (born 1948), singer-songwriter, recording artist, guitarist, musician, composer, singer
2. Cat Stevens (wd:Q123717389): 2001 box set by Cat Stevens
3. Catherine Crowe, also known as Catherine Ann Crowe, Mrs. Crowe, Catherine Stevens Crowe, Catherine Stevens (wd:Q2537956): English novelist, story writer, and playwright; spiritualist and spirit story collector (1790–1872), translator, writer
4. Catherine Stevens (wd:Q14918517): Belgian athletics competitor, athletics competitor
5. Catrin Stevens (wd:Q47124278): historian, editor, writer
6. Catherine Stevens (wd:Q96292350)
7. Catherine Hamersly, also known as Catherine Stevens, Kate Hamersly, Kate Stevens (wd:Q118198771): (1823-1893)
8. Barbara Stanwyck, also known as Ruby Stevens, Ruby Catherine Stevens (wd:Q94002): American actress (1907–1990), television actor, screenwriter, stage actor, film actor, actor, model
9. Catasetum stevensonii (wd:Q15443245): species of plant
10. Catherine Octavia Stevens (wd:Q105812567): British astronomer (1865–1959), astronomer

[Assistant] The entity for Cat Stevens as a British musician is wd:Q154216. Now let's search for properties related to "instrument" for this entity.

[Tool]
Top 10 property alternatives:
1. instrument, also known as uses this instrument, teaches instrument, instruments, plays this instrument, plays instrument (wd:P1303 as wdt/p): musical instrument that a person plays or teaches or used in a music occupation, uses
2. genre, also known as genre of music, type of music, type of film, music genre, literary genre (wd:P136 as wdt/p): creative work's genre or an artist's field of work (P101). Use main subject (P921) to relate creative works to their topic
3. instance of, also known as unitary element of class, has type, unique individual of, type, item of type (wd:P31 as wdt/p): that class of which this subject is a particular example and mem...is a subclass of mountain (and an instance of volcanic landform)
4. voice type, also known as range of voice, register, tessitura, type of voice, vocal type (wd:P412 as wdt/p): person's voice type. expected values: soprano, mezzo-soprano, contralto, countertenor, tenor, baritone, bass (and derivatives)
5. Pitchfork artist ID, also known as Pitchfork, Pitchfork ID (wd:P8819 as wdt/p): identifier for musical artists on the Pitchfork website
6. country of citizenship, also known as subject of (country), nation of citizenship, national of, nationality, nation (wd:P27 as wdt/p): the object is a country that recognizes the subject as its citizen, country
7. occupation, also known as job, work, vocation, profession, employment (wd:P106 as wdt/p): occupation of a person; see also "field of work" (Property:P101), "position held" (Property:P39)
8. described by source, also known as mentioned in, source of item, reviewed in, mentioned in news article, talked about in (wd:P1343 as wdt/p): work where this item is described, attested in
9. topic's main category, also known as article's main category, category, category for this topic, catmain, has category (wd:P910 as wdt/p): main Wikimedia category
10. image, also known as still capture, still, screenshot, screen capture, portrait (wd:P18 as wdt/p): image of relevant illustration of the subject; if available, als...tor map, flag image, signature image, logo image, collage image)

No other items found

[Assistant] The property "instrument" (wdt:P1303) is the appropriate property for the musical instrument that a person plays. Now let's query which instruments Cat Stevens (wd:Q154216) plays using this property.

[Tool]
Got 4 rows and 2 columns:
| instrument              | instrumentLabel  |
| ----------------------- | ---------------- |
| voice (wd:Q17172850)    | voice (en)       |
| bass guitar (wd:Q46185) | bass guitar (en) |
| piano (wd:Q5994)        | piano (en)       |
| guitar (wd:Q6607)       | guitar (en)      |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the instruments that Cat Stevens plays using the property wdt:P1303. The query returns the identifiers and English labels of the instruments, which matches the user's question. The answer listing voice, bass guitar, piano, and guitar is accurate and complete based on the query results. The query follows the rules by returning IRIs and labels optionally. 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 ?org ?orgLabel WHERE {
  ?org wdt:P31 / wdt:P279 * wd:Q2401749 .
  ?org ( wdt:P131 | wdt:P159 ) wd:Q31 .
  OPTIONAL {
    ?org rdfs:label ?orgLabel FILTER ( LANG( ?orgLabel ) = "en" )
  }
}

The telecommunications organization located in Belgium is WIN (wd:Q28033169).

[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] Which telecommunications organizations are located in Belgium?

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

[Tool] No examples found

[Assistant] No similar examples were found. Next, I will search for the entity "Belgium" in Wikidata to get its identifier. This will help us specify the location constraint in the query.

[Tool]
Top 10 entity alternatives:
1. Belgium, also known as Kingdom of Belgium, BEL, be, BE, 🇧🇪 (wd:Q31): country in western Europe
2. Belgium, also known as Belgium, IL, Belgium, Illinois (wd:Q2281631): village in Illinois, United States
3. Belgium, also known as Belgium, WI (wd:Q2025327): village in Ozaukee County, Wisconsin
4. Belgium (wd:Q1658699): town in Wisconsin, United States
5. Belgium, also known as Belgium, West Virginia, Belgium, WV (wd:Q2894385): unincorporated community in West Virginia, United States
6. Belgium in the Eurovision Young Musicians, also known as Belgium (wd:Q14849447): Belgium in youth classical music contest
7. Belgium in the long nineteenth century, also known as Belgium (wd:Q16951058): history of Belgium from 1789 to 1914
8. Belgium (wd:Q106879226): family name
9. Belgium (wd:Q109469128): 2019 single by Lil Peep
10. Belgium (wd:Q19072874): poem by Florence Earle Coates

[Assistant] I found that Belgium as a country in western Europe has the identifier wd:Q31. Next, I will search for properties related to "telecommunications organization" to identify the relevant property or class to filter organizations.

[Tool]
Top 10 entity alternatives:
1. Intelsat, also known as International Telecommunications Satellite Organization, International Telecommunications Satellite Corporation, Intelsat S.A. (wd:Q778126): Luxembourgish communications satellite services provider
2. OTE, also known as Organismos Tilepikinonion Ellados AE, HTO, Hellenic Telecommunications Organization S.A. (wd:Q206678): Greek telecommunication company
3. International Telecommunications Satellite Organization, also known as Agreement relating to the Intern...nications Satellite Organization (wd:Q15546770): intergovernmental organization
4. European Telecommunications Satellite Organization, also known as Eutelsat IGO (wd:Q47537350): European intergovernmental organisation
5. Globalization, International Organizations, and Telecommunications (wd:Q60140176): scholarly article by Kirsten Rodine-Hardy published September 2015 in Review of Policy Research
6. Intelsat headquarters, also known as 3400 International Drive, 4000 Connecticut Avenue, INTELSAT Headquarter Building, INTELSAT Headquarters Building, International Telecommunications...ganization Headquarters Building (wd:Q6044259): space age style building in Washington, DC
7. organization, also known as organizations, organization in sociology, organisation, institution, organisations (wd:Q43229): social entity established to meet needs or pursue goals
8. .org, also known as dot-org, .organization, .org domain (wd:Q32131): generic top-level domain
9. The Organization, also known as Organization (wd:Q1986084): 1971 film by Don Medford
10. telecommunications, also known as telephone industry, telecoms, telecommunications sector, telecommunications market, ISIC 61 (wd:Q2401742): telecommunications industry in general or providers of telecommunications networks and services

[Assistant] I found some telecommunications organizations and related entities, but I need to identify the class or property that indicates an organization is a telecommunications organization. I will search for the class "telecommunications company" or "telecommunications organization" to find the relevant Wikidata item.

[Tool]
Top 10 entity alternatives:
1. telephone company, also known as telco, phone company, telephone service provider, telecom operator, telecommunications company (wd:Q1266169): organization that provides telephone and/or other telecommunications service
2. telecommunication company, also known as telecom service provider, telecoms company, telecom company, telecom, telco (wd:Q2401749): company that operates in the telecommunications industry
3. telecommunications company (wd:L779293-S1)
4. mobile network operator, also known as Mobile Network Operator, MNO, wireless telecommunications company, wireless service provider, wireless carrier, mobile service provider (wd:Q1941618): cellular service provider
5. Omantel, also known as Oman Telecommunications Company (wd:Q1535581): telecommunication company in Oman
6. t2 (cellular operator), also known as Tele2 Russia, Tele2 (Russia), Tele2, T2 (telecommunications company), T2 (mobile operator) (wd:Q4050799): Mobile service provider in Russia
7. Vivacom, also known as BTC, Bulgarian Telecommunications Company (wd:Q7937522): Bulgarian telecommunications company
8. Gamtel, also known as Gambia Telecommunications Company (wd:Q1492955): Gambian telecommunication company
9. Miranda (telecommunications company) (wd:Q133119943): Russian mobile network operator
10. BTC, also known as Bahamas Telecommunications Company (wd:Q4837035): telecommunication company in the Bahamas

[Assistant] I found that "telecommunications company" is represented by wd:Q2401749 in Wikidata. Now, I will construct a SPARQL query to find telecommunications organizations (instances of wd:Q2401749) that are located in Belgium (wd:Q31). The property for location or headquarters is usually "located in the administrative territorial entity" (wdt:P131) or "headquarters location" (wdt:P159). I will try both to get a comprehensive result.

[Tool] Got no rows and 2 columns

[Assistant] No telecommunications organizations were found using the property "located in the administrative territorial entity" (wdt:P131) with Belgium. I will try using the property "headquarters location" (wdt:P159) instead to find telecommunications companies headquartered in Belgium.

[Tool] Got no rows and 2 columns

[Assistant] No telecommunications organizations were found using the property "headquarters location" (wdt:P159) with Belgium either. I will try a broader approach by checking if the organization is an instance of or subclass of telecommunications company and located in Belgium using either property wdt:P131 or wdt:P159.

[Tool]
Got 1 row and 2 columns:
| org                | orgLabel |
| ------------------ | -------- |
| WIN (wd:Q28033169) | WIN (en) |

[Assistant] I found one telecommunications organization located in Belgium: WIN (wd:Q28033169). I will now provide the final answer with this information.

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly identifies telecommunications organizations located in Belgium by selecting entities that are instances of telecommunications companies (wd:Q2401749) and are located in Belgium (wd:Q31) using the properties P131 (located in the administrative territorial entity) or P159 (headquarters location). The query returns the organization's identifier and English label, which is appropriate. The answer WIN (wd:Q28033169) is consistent with the query result. The query and answer are correct and complete for the user's question.


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 ?award ?awardLabel WHERE {
  wd:Q319308 wdt:P166 ?award .
  OPTIONAL {
    ?award rdfs:label ?awardLabel FILTER ( LANG( ?awardLabel ) = "en" )
  }
}

Got 8 rows and 2 columns:
| award                                                              | awardLabel                                               |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| Guggenheim Fellowship (wd:Q1316544)                                | Guggenheim Fellowship (en)                               |
| Albertus-Magnus professorate (wd:Q2639529)                         | Albertus-Magnus professorate (en)                        |
| Barwise Prize (wd:Q4865981)                                        | Barwise Prize (en)                                       |
| Fellow of the American Academy of Arts and Sciences (wd:Q52382875) | Fellow of the American Academy of Arts and Sciences (en) |
| National Book Award (wd:Q572316)                                   | National Book Award (en)                                 |
| CSS Fellow (wd:Q59766571)                                          | CSS Fellow (en)                                          |
| Fellow of the Committee for Skeptical Inquiry (wd:Q61745062)       | Fellow of the Committee for Skeptical Inquiry (en)       |
| Pulitzer Prize for General Nonfiction (wd:Q784589)                 | Pulitzer Prize for General Nonfiction (en)               |

Douglas Hofstadter won the following awards: Guggenheim Fellowship, Albertus-Magnus professorate, Barwise Prize, Fellow of the American Academy of Arts and Sciences, National Book Award, CSS Fellow, Fellow of the Committee for Skeptical Inquiry, and Pulitzer Prize for General Nonfiction.

[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] Which awards did Douglas Hofstadter win?

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

[Tool]
Example 1:
Question:
Which computer scientist won an oscar?

SPARQL:
SELECT DISTINCT ?uri WHERE {
  ?uri wdt:P106 wd:Q82594 .
  ?uri wdt:P166 ?award .
  ?award wdt:P31 wd:Q19020 .
}

Using entities:
Academy Awards, also known as Oscars, The Oscars (wd:Q19020): annual awards for cinematic achievements
computer scientist, also known as computer professional, computer specialist (wd:Q82594): one who studies or practises computer science

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)
award received, also known as win, winner of, recognition title, received award, prize received (wd:P166 as wdt): award or recognition received by a person, organization or creative work
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]
The example shows that to find awards won by a person, we can use the property "award received" (wdt:P166). We need to find the entity for Douglas Hofstadter and then query for the awards he received using this property.

Next, I will search for the entity Douglas Hofstadter in Wikidata.

[Tool]
Top 10 entity alternatives:
1. Douglas Hofstadter, also known as Douglas R. Hofstadter, Douglas Richard Hofstadter (wd:Q319308): American physicist, computer scientist and  professor of cognitive science, university teacher, computer scientist, philosopher, physicist, writer
2. Douglas, also known as Doolish, Douglas, Isle of Man (wd:Q18569): capital city of the Isle of Man
3. Douglas, also known as Douglas, Arizona, Douglas, AZ (wd:Q79878): city in Cochise County, Arizona, United States
4. Douglas, also known as Douglas, Wyoming, Douglas, WY (wd:Q983438): city in Converse County, Wyoming, United States
5. Douglas, also known as Douglas Aircraft Company (wd:Q651778): 1921-1967 aerospace manufacturer in the United States
6. Douglas, also known as Douglas, GA, Douglas, Georgia (wd:Q1004791): city in Coffee County, Georgia, United States
7. Douglas, also known as Douglas, AL (wd:Q66753): town in Marshall County, Alabama, in the United States
8. Douglas, also known as Douglas Pereira, Douglas Pereira dos Santos (wd:Q1988686): Brazilian association football player, born 1990, association football player
9. Douglas, also known as Douglas, MI, Douglas, Michigan (wd:Q2172413): city in Michigan, United States
10. Douglas, also known as Douglas, ND, Douglas, North Dakota (wd:Q2226686): city in Ward County, North Dakota, United States

[Assistant] The entity for Douglas Hofstadter is wd:Q319308. Now I will query for the awards he has won using the property "award received" (wdt:P166).

[Tool]
Got 8 rows and 2 columns:
| award                                                              | awardLabel                                               |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| Guggenheim Fellowship (wd:Q1316544)                                | Guggenheim Fellowship (en)                               |
| Albertus-Magnus professorate (wd:Q2639529)                         | Albertus-Magnus professorate (en)                        |
| Barwise Prize (wd:Q4865981)                                        | Barwise Prize (en)                                       |
| Fellow of the American Academy of Arts and Sciences (wd:Q52382875) | Fellow of the American Academy of Arts and Sciences (en) |
| National Book Award (wd:Q572316)                                   | National Book Award (en)                                 |
| CSS Fellow (wd:Q59766571)                                          | CSS Fellow (en)                                          |
| Fellow of the Committee for Skeptical Inquiry (wd:Q61745062)       | Fellow of the Committee for Skeptical Inquiry (en)       |
| Pulitzer Prize for General Nonfiction (wd:Q784589)                 | Pulitzer Prize for General Nonfiction (en)               |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves all awards received by Douglas Hofstadter using the property wdt:P166. The query also includes English labels for the awards, which is helpful for readability. The answer lists all the awards found in the query result, matching the data returned. The query and answer are complete and accurate for the user's question.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?areaCode WHERE {
  wd:Q64 wdt:P473 ?areaCode .
}

Got 1 row and 1 column:
| areaCode |
| -------- |
| 030      |

The area code of Berlin is 030.

[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 is the area code of Berlin?

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

[Tool] No examples found

[Assistant] There are no similar examples found for the question "What is the area code of Berlin?" Let's proceed by searching for the entity "Berlin" in Wikidata.

[Tool]
Top 10 entity alternatives:
1. Berlin, also known as Berlin (Germany), Berlin, Germany, DE-BE (wd:Q64): federated state, capital and largest city of Germany
2. Berlin, also known as Berlin, New Hampshire, Berlin, NH (wd:Q821244): city in Coos County, New Hampshire, United States
3. Lincoln, also known as Berlin, Lincoln, IA, Lincoln, Iowa (wd:Q1930098): city in Iowa, United States
4. Berlin (wd:Q614184): town in Maryland, United States
5. Berlin, also known as Berlin, New Jersey, Long-a-Coming, New Jersey, Berlin, NJ (wd:Q1086827): borough in Camden County, New Jersey, United States
6. Berlin, also known as Berlin, GA, Berlin, Georgia, USA, Berlin, USA (wd:Q2345711): town in Colquitt County, Georgia, United States
7. Berlin, also known as Berlin, WI, Berlin, Wisconsin (wd:Q1569850): city in Green Lake and Waushara counties, Wisconsin, United States
8. Berlin, also known as Berlin, ND, Berlin, North Dakota (wd:Q821229): city in North Dakota
9. Berlin (wd:Q2504681): village in Illinois, U.S.
10. Berlin (wd:Q821198): American synthpop band

[Assistant] The entity for Berlin, the capital and largest city of Germany, is wd:Q64. Next, I will search for properties related to "area code" for this entity.

[Tool]
Top 10 property alternatives:
1. local dialing code, also known as area code, dialling code, local calling code, local dialling code, STD code (wd:P473 as wdt/p): identifier dedicated to subject city by the area communication network
2. postal code, also known as pincode, PIN Code, postal index number, post code, postcode (wd:P281 as wdt/p): identifier assigned by postal authorities for the subject area or building
3. UN/LOCODE, also known as LOCCODE, LOCODE, UNECE location code, UNECE LOCODE, United Nations location code (wd:P1937 as wdt/p): geographic location code maintained by UNECE
4. social media followers, also known as number of subs, number of subscribers, sub count, sub number, subscriber number (wd:P8687 as wdt/p): number of subscribers on a particular social media website (use ... in time" and property for account. For Twitter, use numeric id.
5. area, also known as total area, surface area, surface, size, resolution (wd:P2046 as wdt/p): area occupied by an object
6. licence plate code, also known as license plate code, vehicle registration plate (wd:P395 as wdt/p): distinguishing signs or parts of license plate associated with t...al licence plate country code or distinguishing sign of vehicles
7. PM20 geo code (wd:P8483 as wdt/p): code for a geographical category in the 20th Century Press Archives' "countries" category system
8. HASC, also known as Hierarchical Administrative Subdivision Code (wd:P8119 as wdt/p): codes to represent country subdivisions
9. FIPS 10-4 (countries and regions), also known as fips country codes (wd:P901 as wdt/p): Identifier for countries and regions per former Federal Information Processing Standard FIPS 10-4
10. coordinate location, also known as point on a map, gps coordinates, gps location, latitude, location (wd:P625 as wdt/p): geocoordinates of the subject. For Earth, please note that only WGS84 coordinating system is supported at the moment

No other items found

[Assistant] The property "local dialing code" (wdt:P473) corresponds to the area code or local dialing code. Now I will query the local dialing code of Berlin (wd:Q64).

[Tool]
Got 1 row and 1 column:
| areaCode |
| -------- |
| 030      |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves the local dialing code (area code) for Berlin using the property wdt:P473. The query returns the expected result '030', which matches the known area code for Berlin. The answer is accurate and complete, and the query follows the rules by returning the identifier directly without unnecessary label services. 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 ?company ?companyLabel ?website WHERE {
  ?company wdt:P31 wd:Q4830453 .
  ?company wdt:P1128 ?employees .
  FILTER ( ?employees > 500000 ) .
  OPTIONAL {
    ?company wdt:P856 ?website
  }
  OPTIONAL {
    ?company rdfs:label ?companyLabel FILTER ( LANG( ?companyLabel ) = "en" )
  }
}

Got 23 rows and 3 columns, showing the first 5 and last 5 rows below:
| company                                           | companyLabel                              | website                                      |
| ------------------------------------------------- | ----------------------------------------- | -------------------------------------------- |
| G4S (wd:Q1322045)                                 | G4S (en)                                  | <http://www.g4s.com>                         |
| Tata Consultancy Services (wd:Q13227919)          | Tata Consultancy Services (en)            | <https://www.tcs.com/>                       |
| Volkswagen Group (wd:Q156578)                     | Volkswagen Group (en)                     | <https://www.volkswagenag.com/>              |
| Volkswagen Group (wd:Q156578)                     | Volkswagen Group (en)                     | <https://www.volkswagenag.com/de.html>       |
| Volkswagen Group (wd:Q156578)                     | Volkswagen Group (en)                     | <https://www.volkswagenag.com/en.html>       |
| ...                                               | ...                                       | ...                                          |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn:81/cnpc/index.shtml> |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn/en/>                 |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn/es/>                 |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn/ru/>                 |
| United States Postal Service (wd:Q668687)         | United States Postal Service (en)         | <https://www.usps.com/>                      |

There are multiple companies with more than 500000 employees. Some examples with their websites are:
- G4S: http://www.g4s.com
- Tata Consultancy Services: https://www.tcs.com/
- Volkswagen Group: https://www.volkswagenag.com/
- China National Petroleum Corporation: http://www.cnpc.com.cn/en/
- United States Postal Service: https://www.usps.com/

[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] Give me the websites of companies with more than 500000 employees.

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

[Tool]
Example 1:
Question:
Which Indian company has the most employees?

SPARQL:
SELECT DISTINCT ?uri WHERE {
  ?uri wdt:P31 wd:Q4830453 .
  ?uri wdt:P17 wd:Q668 .
  ?uri wdt:P1128 ?employees .
}
ORDER BY DESC ( ?employees )
LIMIT 1

Using entities:
business (wd:Q4830453): organization undertaking commercial, industrial, or professional activity
India, also known as Republic of India, Indostan, IND, Bharatvarsh, IN (wd:Q668): country in South Asia

Using properties:
employees, also known as workers, staff, personnel, number of employees, employee count (wd:P1128 as wdt): total number of employees of a company at a given "point in time...not deprecated rank). Add data for recent years, don't overwrite
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
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:
Give me a list of all Canadians that reside in the U.S.

SPARQL:
SELECT DISTINCT ?uri WHERE {
  ?uri wdt:P19 / wdt:P17 wd:Q16 .
  ?uri wdt:P551 wd:Q30 .
}

Using entities:
Canada, also known as CA, CAN, Dominion of Canada, ISO 3166-1:CA (wd:Q16): country in North America
United States, also known as the U.S. of A, United States of America, the US of America, United States of North America, U. S. (wd:Q30): country primarily located in North America

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
residence, also known as living in, place of residence, resided at, resided in, resident in (wd:P551 as wdt): the place where the person is or has been, resident, location

[Assistant]
From the examples, I see that the property for the number of employees is P1128 and the instance for companies is Q4830453. The property for the website of an organization is commonly P856.

I will now construct a SPARQL query to get companies (instance of Q4830453) with more than 500000 employees (P1128) and retrieve their websites (P856).

[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 we are using. I will rewrite the query without using SERVICE wikibase:label and instead use optional rdfs:label to get the company names in English.

[Tool]
Got 23 rows and 3 columns, showing the first 5 and last 5 rows below:
| company                                           | companyLabel                              | website                                      |
| ------------------------------------------------- | ----------------------------------------- | -------------------------------------------- |
| G4S (wd:Q1322045)                                 | G4S (en)                                  | <http://www.g4s.com>                         |
| Tata Consultancy Services (wd:Q13227919)          | Tata Consultancy Services (en)            | <https://www.tcs.com/>                       |
| Volkswagen Group (wd:Q156578)                     | Volkswagen Group (en)                     | <https://www.volkswagenag.com/>              |
| Volkswagen Group (wd:Q156578)                     | Volkswagen Group (en)                     | <https://www.volkswagenag.com/de.html>       |
| Volkswagen Group (wd:Q156578)                     | Volkswagen Group (en)                     | <https://www.volkswagenag.com/en.html>       |
| ...                                               | ...                                       | ...                                          |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn:81/cnpc/index.shtml> |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn/en/>                 |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn/es/>                 |
| China National Petroleum Corporation (wd:Q588786) | China National Petroleum Corporation (en) | <http://www.cnpc.com.cn/ru/>                 |
| United States Postal Service (wd:Q668687)         | United States Postal Service (en)         | <https://www.usps.com/>                      |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves companies (instances of business) with more than 500,000 employees and their official websites. The query uses appropriate properties (wdt:P31 for instance of business, wdt:P1128 for number of employees, and wdt:P856 for official website) and includes optional retrieval of English labels. The results include multiple companies with their websites, matching the user's question. The query and answer are complete, correct, and follow the guidelines. No further refinement is needed.


PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?cosmonaut WHERE {
  ?cosmonaut wdt:P106 wd:Q12634815 .
}

Got 8 rows and 1 column:
| cosmonaut                                       |
| ----------------------------------------------- |
| Void (wd:Q106373153)                            |
| Svetlana Oktyabrevna Omelchenko (wd:Q108169808) |
| Aleksandr Gorbunov (wd:Q109493064)              |
| Marina Vasilevskaya (wd:Q118185958)             |
| Ural Sultanov (wd:Q15210574)                    |
| Anna Kikina (wd:Q18352451)                      |
| Vladimír Remek (wd:Q254985)                     |
| Arnaldo Tamayo Méndez (wd:Q362902)              |

There are 8 cosmonauts found in Wikidata with the occupation property set to cosmonaut (wd:Q12634815). The query returns their Wikidata identifiers.

[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] Give me all cosmonauts.

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

[Tool]
Example 1:
Question:
Give me all federal chancellors of Germany.

SPARQL:
SELECT DISTINCT ?uri WHERE {
  ?uri wdt:P39 wd:Q4970706 .
}

Using entities:
Federal Chancellor of Germany, also known as German Federal Chancellor, prime minister of Germany, German Chancellor, Federal Chancellor of the Federal Republic of Germany, Federal Chancellor (wd:Q4970706): head of government of the Federal Republic of Germany (1949–present)

Using properties:
position held, also known as function, held position, holds position, job, office held (wd:P39 as wdt): subject currently or formerly holds the object position or public office

Example 2:
Question:
Give me all South American countries.

SPARQL:
SELECT DISTINCT ?uri WHERE {
  ?uri wdt:P31 wd:Q6256 .
  ?uri wdt:P30 wd:Q18 .
}

Using entities:
South America, also known as S America, S. America, South American continent (wd:Q18): continent
country, also known as countries (wd:Q6256): distinct territorial body or political entity

Using properties:
continent (wd:P30 as wdt): continent of which the subject is a part, located in/on physical feature
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:
Show me all books in Asimov's Foundation series.

SPARQL:
SELECT DISTINCT ?uri WHERE {
  wd:Q1564644 wdt:P527 ?uri
}

Using entities:
Foundation series, also known as The Foundation Series (wd:Q1564644): series of science fiction books by Isaac Asimov

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, it is clear that to get all cosmonauts, we need to find the entity for "cosmonaut" and then find all entities that have the property "instance of" (wdt:P31) with the value "cosmonaut".

Let's first search for the entity "cosmonaut" in Wikidata.

[Tool]
Top 10 entity alternatives:
1. astronaut, also known as cosmonaut, vyomanaut, taikonaut, spationaut, spacionaut (wd:Q11631): person who commands, pilots, or serves as a crew member of a spacecraft
2. The Cosmonaut, also known as Cosmonaut (wd:Q3016381): 2013 film directed by Nicolás Alcalá
3. Forsaken, also known as Cosmonaut, Forsaken: Mission Mars, Martian, Prishelets, The Cosmonaut (wd:Q55659194): 2018 Russian science fiction film by Aleksandr Kulikov
4. Cosmonaut, also known as Cosmonauta (wd:Q3695198): 2009 film directed by Susanna Nicchiarelli
5. cosmonaut, also known as Russian astronaut (wd:Q12634815): astronaut from the former Soviet Union and its satellite countries and today's Russia
6. Cosmonaut (wd:Q5174345): 2010 studio album by Bump of Chicken
7. COSMONAUT (wd:Q122343082): 2018 video game
8. cosmonaut (wd:L493546-S2)
9. cosmonaut (wd:L30879)
10. cosmonaut (wd:L30879-F1)

[Assistant]
The entity for "cosmonaut" as an astronaut from the former Soviet Union and its satellite countries and today's Russia is wd:Q12634815.

Now, we want to find all entities that are instances of this cosmonaut entity. The property for "instance of" is wdt:P31.

I will now construct a SPARQL query to get all cosmonauts.

[Tool] Got no rows and 1 columns

[Assistant]
The query returned no results, which means there might be a different way cosmonauts are classified in Wikidata. Instead of "instance of" (wdt:P31), cosmonauts might be classified using the property "occupation" (wdt:P106).

I will try a query to find all entities with occupation "cosmonaut" (wd:Q12634815).

[Tool]
Got 8 rows and 1 column:
| cosmonaut                                       |
| ----------------------------------------------- |
| Void (wd:Q106373153)                            |
| Svetlana Oktyabrevna Omelchenko (wd:Q108169808) |
| Aleksandr Gorbunov (wd:Q109493064)              |
| Marina Vasilevskaya (wd:Q118185958)             |
| Ural Sultanov (wd:Q15210574)                    |
| Anna Kikina (wd:Q18352451)                      |
| Vladimír Remek (wd:Q254985)                     |
| Arnaldo Tamayo Méndez (wd:Q362902)              |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly retrieves all individuals with the occupation property set to cosmonaut (wd:Q12634815). The query returns their Wikidata identifiers as required. The answer is complete and accurate, listing 8 cosmonauts found in 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 ?owner ?ownerLabel WHERE {
  wd:Q243278 wdt:P127 ?owner .
  OPTIONAL {
    ?owner rdfs:label ?ownerLabel FILTER ( LANG( ?ownerLabel ) = "en" )
  }
}

Got 3 rows and 2 columns:
| owner                                | ownerLabel                   |
| ------------------------------------ | ---------------------------- |
| ValueAct Capital (wd:Q22032185)      | ValueAct Capital (en)        |
| Credit Suisse (wd:Q372657)           | Credit Suisse (en)           |
| Capital Group Companies (wd:Q505275) | Capital Group Companies (en) |

The owners of Rolls-Royce Holdings plc are ValueAct Capital, Credit Suisse, and Capital Group Companies.

[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 the owner of Rolls-Royce?

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

[Tool]
Example 1:
Question:
What is Elon Musk famous for?

SPARQL:
SELECT DISTINCT ?uri WHERE {
  wd:Q317521 wdt:P61 ?uri .
}

Using entities:
Elon Musk, also known as Elon Reeve Musk (wd:Q317521): South African-Canadian-American businessperson, engineer, inventor, philanthropist and political figure (born 1971), technology entrepreneur, businessperson, civil servant, entrepreneur, programmer, politician, investor, engineer

Using properties:
discoverer or inventor, also known as inventor or discoverer, inventor, invented by, invented, introduced by (wd:P61 as wdt): subject who discovered, first described, invented, or developed this discovery or invention or scientific hypothesis or theory

[Assistant]
The example found is about what Elon Musk is famous for, which uses property P61 (discoverer or inventor). This is not directly related to ownership but shows how to query for a specific property of an entity.

Now, I will search for the entity "Rolls-Royce" in Wikidata to identify the correct entity for the company. Then I will search for properties related to ownership for that entity.

[Tool]
Top 10 entity alternatives:
1. Rolls-Royce, also known as Rolls-Royce Holdings plc (wd:Q243278): British multinational public holding company
2. Rolls-Royce (wd:Q125141709): car brand
3. Rolls-Royce, also known as Rolls-Royce plc (wd:Q85623218): British company
4. Rolls-Royce Limited, also known as Rolls Royce Limited (wd:Q679888): 1906-1987 automobile and aerospace manufacturer in the United Kingdom
5. Merlin, also known as Merlin engine, Rolls-Royce Merlin, RR Merlin (wd:Q1412885): 12-cylinder V piston engine family by Rolls-Royce
6. The Yellow Rolls-Royce, also known as Yellow Rolls-Royce (wd:Q2474758): 1964 film by Anthony Asquith
7. Rolls-Royce Ghost (wd:Q1510648): car model
8. Rolls-Royce Trent (wd:Q1738127): turbofan aircraft engine family
9. Rolls-Royce Griffon (wd:Q2164325): 1930s British piston aircraft engine
10. Rolls-Royce RB211, also known as RB211 (wd:Q1636078): 1960s British turbofan aircraft engine

[Assistant]
There are multiple entities related to Rolls-Royce. The most relevant for ownership is likely "Rolls-Royce Holdings plc" (wd:Q243278), which is a British multinational public holding company.

Next, I will search for properties related to ownership for the entity Rolls-Royce Holdings plc (wd:Q243278).

[Tool]
Top 10 property alternatives:
1. owned by, also known as belongs to, stockholders, stockholder, shareholders, shareholder (wd:P127 as wdt/p): owner of the subject
2. owner of, also known as owns, owns property, shareholder of (wd:P1830 as wdt/p): entities owned by the subject
3. has subsidiary, also known as subordinate body, subsidiary body, subordinate unit, subsidiary, subsidiary company (wd:P355 as wdt/p): subsidiary of a company or organization; generally a fully owned...siness division" (P199). Opposite of parent organization (P749)., has part(s), owner of
4. parent organization, also known as parent company, parent institution, parent organisation, parent unit, part of (wd:P749 as p): parent organization of an organization, opposite of subsidiaries (P355), owned by, part of
5. founded by, also known as starter, co-founded by, started by, institutor, instituted by (wd:P112 as wdt/p): founder or co-founder of this organization, religion, place or entity, creator
6. part of, also known as of, within, system of, subsystem of, subgroup of (wd:P361 as wdt/p): 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))
7. chairperson, also known as dean, headed by, leader, president, chairwoman (wd:P488 as wdt/p): presiding member of an organization, group or body, director / manager, significant person
8. inception, also known as initial release date, founded in, founded on, founded on date, founding date (wd:P571 as wdt/p): time when an entity begins to exist; for date of official opening use P1619, start time
9. chief executive officer, also known as executive director, CEO, chief executive (wd:P169 as wdt/p): highest-ranking corporate officer appointed as the CEO within an organization, director / manager, corporate officer
10. board member, also known as member of the board, member of the board of directors (wd:P3320 as wdt/p): member(s) of the board for the organization

No other items found

[Assistant]
The property "owned by" (wdt:P127) is the most relevant for finding the owner of Rolls-Royce Holdings plc (wd:Q243278).

I will now write a SPARQL query to find the owner(s) of Rolls-Royce Holdings plc using property P127.

[Tool]
Got 3 rows and 2 columns:
| owner                                | ownerLabel                   |
| ------------------------------------ | ---------------------------- |
| ValueAct Capital (wd:Q22032185)      | ValueAct Capital (en)        |
| Credit Suisse (wd:Q372657)           | Credit Suisse (en)           |
| Capital Group Companies (wd:Q505275) | Capital Group Companies (en) |

[Assistant]
The owners of Rolls-Royce Holdings plc are ValueAct Capital, Credit Suisse, and Capital Group Companies.

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 owners of Rolls-Royce Holdings plc using the property 'owned by' (wdt:P127). The query returns the identifiers and English labels of the owners, which are ValueAct Capital, Credit Suisse, and Capital Group Companies. The answer is accurate and complete based on the data from Wikidata. 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 ?politician ?politicianLabel ?spouse ?spouseLabel WHERE {
  ?politician wdt:P106 wd:Q82955 .
  ?politician wdt:P26 ?spouse .
  ?spouse wdt:P27 wd:Q183 .
  OPTIONAL {
    ?politician rdfs:label ?politicianLabel FILTER ( LANG( ?politicianLabel ) = "en" )
  }
  OPTIONAL {
    ?spouse rdfs:label ?spouseLabel FILTER ( LANG( ?spouseLabel ) = "en" )
  }
}
LIMIT 100

Got 100 rows and 4 columns, showing the first 5 and last 5 rows below:
| politician                          | politicianLabel             | spouse                                 | spouseLabel                  |
| ----------------------------------- | --------------------------- | -------------------------------------- | ---------------------------- |
| Eberhard Gothein (wd:Q100765)       | Eberhard Gothein (en)       | Marie-Luise Gothein (wd:Q97309)        | Marie-Luise Gothein (en)     |
| Hans-Peter Bartels (wd:Q101192)     | Hans-Peter Bartels (en)     | Susanne Gaschke (wd:Q104875)           | Susanne Gaschke (en)         |
| Karl Trimborn (wd:Q101327)          | Karl Trimborn (en)          | Jeanne Trimborn (wd:Q1686020)          | Jeanne Trimborn (en)         |
| Siegfried Balleis (wd:Q101881)      | Siegfried Balleis (en)      | Angelika Balleis (wd:Q41543230)        | Angelika Balleis (en)        |
| Joachim von Ribbentrop (wd:Q101886) | Joachim von Ribbentrop (en) | Annelies von Ribbentrop (wd:Q15531167) | Annelies von Ribbentrop (en) |
| ...                                 | ...                         | ...                                    | ...                          |
| Irmhild Boßdorf (wd:Q126504934)     | Irmhild Boßdorf (en)        | Peter Bossdorf (wd:Q112379649)         | Peter Bossdorf (en)          |
| Ibrahim El-Zayat (wd:Q126785)       | Ibrahim El-Zayat (en)       | Sabiha El-Zayat (wd:Q43382630)         | Sabiha El-Zayat (en)         |
| Carl Schurz (wd:Q127437)            | Carl Schurz (en)            | Margarethe Schurz (wd:Q92170)          | Margarethe Schurz (en)       |
| Edmund Collein (wd:Q1286116)        | Edmund Collein (en)         | Lotte Gerson (wd:Q80220015)            | Lotte Gerson (en)            |
| Eduard Alexander (wd:Q1289205)      | Eduard Alexander (en)       | Gertrud Alexander (wd:Q1515514)        | Gertrud Alexander (en)       |

There are politicians who were married to a German. For example, Eberhard Gothein was married to Marie-Luise Gothein, Hans-Peter Bartels was married to Susanne Gaschke, and Joachim von Ribbentrop was married to Annelies von Ribbentrop. The query returns up to 100 such politicians and their German spouses.

[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] Which politicians were married to a German?

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

[Tool]
Example 1:
Question:
Give me all federal chancellors of Germany.

SPARQL:
SELECT DISTINCT ?uri WHERE {
  ?uri wdt:P39 wd:Q4970706 .
}

Using entities:
Federal Chancellor of Germany, also known as German Federal Chancellor, prime minister of Germany, German Chancellor, Federal Chancellor of the Federal Republic of Germany, Federal Chancellor (wd:Q4970706): head of government of the Federal Republic of Germany (1949–present)

Using properties:
position held, also known as function, held position, holds position, job, office held (wd:P39 as wdt): subject currently or formerly holds the object position or public office

Example 2:
Question:
Whom did Lance Bass marry?

SPARQL:
SELECT DISTINCT ?uri WHERE {
  wd:Q443120 wdt:P26 ?uri .
}

Using entities:
Lance Bass (wd:Q443120): American singer, dancer, actor, and film and television producer, television producer, television actor, autobiographer, film producer, stage actor, voice actor, film actor, dancer, singer, actor

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

[Assistant]
From the examples, we see that the property "spouse" (wdt:P26) is used to indicate marriage. We want to find politicians who have a spouse that is German.

Step 1: Identify politicians.
Step 2: Check their spouses.
Step 3: Filter spouses who are German.

Let's first find the property for "politician" as an occupation or instance. Then we will build the query to find politicians married to Germans.

[Tool]
Top 10 entity alternatives:
1. politician, also known as pol, political leader, polit., political figure (wd:Q82955): person who holds or seeks positions in government
2. Almudena Martínez del Junco, also known as politician, Spanish (wd:Q127427405): politician in Spain, politician
3. Politician (wd:Q104854338): 1985 novel by Piers Anthony
4. Politician, also known as Jeongchiinssa (wd:Q97217684): South Korea's radio channels
5. Rohit Pal, also known as politician (wd:Q4699959): public figure
6. Cecilia Achieng Ayot, also known as Politician (wd:Q115153599): Kenyan Politician Member of County Assembly Ward Laini Saba, politician
7. David Ruong'o Okelo, also known as Politician (wd:Q115153352): Kenyan Politician, politician
8. Ahmed Abdullahi, also known as Politician (wd:Q114862677): Kenyan Politician
9. Babacar J. Diop, also known as Politician (wd:Q121790292): Babacar J. Diop is current Special Adviser of Youth Policies and...19 to 2022, he served as National Youth Program Officer for UNDP, politician
10. antony kiragu karanja, also known as Politician (wd:Q115153332): Kenyan Politician Minority Leader, politician

[Tool]
Top 10 property alternatives:
1. occupation, also known as job, work, vocation, profession, employment (wd:P106 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): occupation of a person; see also "field of work" (Property:P101), "position held" (Property:P39)
2. field of this occupation, also known as practice, works in, profession's field, practices, field of this profession (wd:P425 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): field corresponding to this occupation or profession (use only f...fessions - for people use Property:P101, for companies use P452)
3. members have occupation, also known as profession of members, organization of, organization for, organisation of, organisation for (wd:P3989 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): some or all members of this group share the occupation
4. practiced by, also known as proponent, studied by, practitioners, practioner, occupation of this field (wd:P3095 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): type of agents that study this subject or work in this field
5. position held, also known as function, held position, holds position, job, office held (wd:P39 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): subject currently or formerly holds the object position or public office
6. employer, also known as working at, working for, working place, works at, works for (wd:P108 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): person or organization for which the subject works or worked, affiliation
7. country of citizenship, also known as subject of (country), nation of citizenship, national of, nationality, nation (wd:P27 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): the object is a country that recognizes the subject as its citizen, country
8. occupant, also known as tenant, resident, renter, occupiers, lessee (wd:P466 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): person or organization occupying property, used by
9. field of work, also known as scientific discipline, scientific area, responsible for, research on, research fields (wd:P101 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): specialization of a person or organization; see P106 for the occupation, interested in
10. work location, also known as work place, working from, working at, worked from, worked at (wd:P937 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): location where persons or organisations were actively participating in employment, business or other work, significant place, location

[Tool]
Top 10 entity alternatives:
1. German, also known as de, German language (wd:Q188): West Germanic language spoken mainly in Central Europe
2. culture of Germany, also known as culture (Germany), culture in Germany, German, German culture, Germany culture (wd:Q1979615): pattern of human activity and symbolism associated with Germany and its people
3. German (wd:Q2990861): village in Stolichna municipality, Sofia Capital oblast, Bulgaria
4. German (wd:Q3708826): town in Chenango County, New York, United States
5. German Standard German, also known as Bundesdeutsch, German German (wd:Q258318): language
6. Agios Germanos, also known as German (wd:Q3298944): village in Florina, Greece
7. German (wd:Q3071702): village in North Macedonia
8. German (wd:Q2635930): South Slavic mythological being
9. German, also known as German, Isle of Man (wd:Q2734574): parish in the Isle of Man
10. German, also known as Garman, German, Shahrud, Gorgan, Kurqan, Qurghan (wd:Q5807368): village in Shahrud County, Iran

[Tool]
Top 10 entity alternatives:
1. Germany, also known as BR Deutschland, Bundesrepublik Deutschland, Deutschland, Federal Republic of Germany (wd:Q183): country in Central Europe
2. Weimar Republic, also known as German Republic, Weimar Germany, Republic of Germany, Germany, German Reich (wd:Q41304): Germany in the years 1918/1919–1933
3. German Reich, also known as Deutsches Reich, German Empire, German Realm, Germany, Imperial Germany (wd:Q1206012): official name for the German nation state from 1871 to 1945, and name of Germany until 1949
4. Burg Drachenfels, also known as Germany (wd:Q1011486): castle
5. Germany (wd:Q5552078): European Parliament constituency
6. Geilenkirchen-Heinsberg, also known as Germany (wd:Q2268218)
7. Germany, also known as Germany, IN, Germany, Indiana (wd:Q18151573): unincorporated community in Clark County, Indiana
8. Germany (wd:Q19147844): poem by Vladimir Mayakovsky
9. Germany, also known as Ludwig, West (wd:Q3839160): Hetalia character
10. Germany, also known as Germany, Texas, Germany, TX (wd:Q15221573): unincorporated community in Houston County, Texas, United States

[Tool]
Top 10 property alternatives:
1. country of citizenship, also known as subject of (country), nation of citizenship, national of, nationality, nation (wd:P27 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): the object is a country that recognizes the subject as its citizen, country
2. place of birth, also known as POB, location of birth, location born, born in, birthplace (wd:P19 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): most specific known birth location of a person, animal or fictional character, location
3. date of birth, also known as year of birth, birthdate, DOB, born on, born (wd:P569 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): date on which the subject was born, inception
4. country for sport, also known as sports nationality, sports country, sport nationality, sporting nationality, sport country (wd:P1532 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): country a person or a team represents when playing a sport, country
5. valid in place, also known as applies to country, applies to location, applies to place, country, true in (wd:P3005 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): place where a statement is valid, applies to part
6. country of origin, also known as origin country, place of origin, originates from, country, CoO (wd:P495 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): country of origin of this item (creative work, food, phrase, product, etc.), significant place, country
7. country, also known as sovereign state, state, land, host country (wd:P17 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): sovereign state that this item is in (not to be used for human beings), located in the administrative territorial entity
8. birth name, also known as née, name at birth, name before marriage, ne, né (wd:P1477 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): full name of a person at birth, if different from their current, generally used name, name
9. permanent resident of, also known as landed immigrant of, PR (wd:P5389 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): country or region where a person has the legal status of permanent resident
10. residence, also known as living in, place of residence, resided at, resided in, resident in (wd:P551 as pq/pqn/psv/pr/wdt/wdtn/prn/psn/ps/pqv/prv/p): the place where the person is or has been, resident, location

[Assistant]
We have identified the following:
- Politician entity: wd:Q82955
- Spouse property: wdt:P26
- Country of citizenship property: wdt:P27
- Germany entity: wd:Q183

Now, we will build a SPARQL query to find politicians who have a spouse whose country of citizenship is Germany.

[Tool]
Got 100 rows and 4 columns, showing the first 5 and last 5 rows below:
| politician                          | politicianLabel             | spouse                                 | spouseLabel                  |
| ----------------------------------- | --------------------------- | -------------------------------------- | ---------------------------- |
| Eberhard Gothein (wd:Q100765)       | Eberhard Gothein (en)       | Marie-Luise Gothein (wd:Q97309)        | Marie-Luise Gothein (en)     |
| Hans-Peter Bartels (wd:Q101192)     | Hans-Peter Bartels (en)     | Susanne Gaschke (wd:Q104875)           | Susanne Gaschke (en)         |
| Karl Trimborn (wd:Q101327)          | Karl Trimborn (en)          | Jeanne Trimborn (wd:Q1686020)          | Jeanne Trimborn (en)         |
| Siegfried Balleis (wd:Q101881)      | Siegfried Balleis (en)      | Angelika Balleis (wd:Q41543230)        | Angelika Balleis (en)        |
| Joachim von Ribbentrop (wd:Q101886) | Joachim von Ribbentrop (en) | Annelies von Ribbentrop (wd:Q15531167) | Annelies von Ribbentrop (en) |
| ...                                 | ...                         | ...                                    | ...                          |
| Irmhild Boßdorf (wd:Q126504934)     | Irmhild Boßdorf (en)        | Peter Bossdorf (wd:Q112379649)         | Peter Bossdorf (en)          |
| Ibrahim El-Zayat (wd:Q126785)       | Ibrahim El-Zayat (en)       | Sabiha El-Zayat (wd:Q43382630)         | Sabiha El-Zayat (en)         |
| Carl Schurz (wd:Q127437)            | Carl Schurz (en)            | Margarethe Schurz (wd:Q92170)          | Margarethe Schurz (en)       |
| Edmund Collein (wd:Q1286116)        | Edmund Collein (en)         | Lotte Gerson (wd:Q80220015)            | Lotte Gerson (en)            |
| Eduard Alexander (wd:Q1289205)      | Eduard Alexander (en)       | Gertrud Alexander (wd:Q1515514)        | Gertrud Alexander (en)       |

[Tool] Stopped generation process

[User]
Feedback (status=done):
The SPARQL query correctly identifies politicians (occupation P106 wd:Q82955) who have spouses (P26) with German citizenship (P27 wd:Q183). It returns the politicians and their spouses along with their English labels, which is helpful for readability. The query limits results to 100, which is reasonable for demonstration. The answer provides concrete examples from the query results, confirming that the query works as intended. No further refinement is necessary.