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

Using entities:
- Eva Perón (wd:Q40933), also known as Eva, Eva Duarte Ibarguren, Eva Peron, Evita, Evita Perón, etc.: has occupation film actor / has occupation trade unionist / has occupation stage actor / has occupation suffragist / has occupation women's rights activist / has occupation politician / is instance of human / Argentine actress and politician (1919–1952)

Using properties:
- cause of death (wd:P509 as wdt), also known as death cause, died of, die from, die of, method of murder, etc.: an item describing the cause of a person or specific organism's death. Samples: leukaemia, car crash / medical cause of a person or specific organism's death (not to be confused with P1196) / underlying or immediate cause of death.  Underlying cause ... category, e.g. natural causes, accident, homicide, suicide / underlying or immediate cause of death.  Underlying cause ... category, e.g. natural causes, accident, homicide, suicide

Got 1 row and 1 column:
| causeOfDeathLabel               |
| ------------------------------- |
| cervix uterine cancer (lang:en) |

Answer: Eva Perón died from cervix uterine cancer.

Eva Perón died from cervix uterine cancer.

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

Using entities:
- Eva Perón (wd:Q40933), also known as Eva, Eva Duarte Ibarguren, Eva Peron, Evita, Evita Perón, etc.: has occupation film actor / has occupation trade unionist / has occupation stage actor / has occupation suffragist / has occupation women's rights activist / has occupation politician / is instance of human / Argentine actress and politician (1919–1952)

Using properties:
- cause of death (wd:P509 as wdt), also known as death cause, died of, die from, die of, method of murder, etc.: an item describing the cause of a person or specific organism's death. Samples: leukaemia, car crash / medical cause of a person or specific organism's death (not to be confused with P1196) / underlying or immediate cause of death.  Underlying cause ... category, e.g. natural causes, accident, homicide, suicide / underlying or immediate cause of death.  Underlying cause ... category, e.g. natural causes, accident, homicide, suicide

Execution result:
Got 1 row and 1 column:
| causeOfDeathLabel               |
| ------------------------------- |
| cervix uterine cancer (lang:en) |

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

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. Search for the 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. Execute intermediate queries to get feedback and to verify your assumptions. You may need to refine or rethink your current plan based on the query results and go back to step 2 if needed, possibly multiple times.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Available knowledge graphs:
- wikidata at http://localhost:7001 with prefix index for entities and similarity index for properties, and notes:
  - P106 = occupation. Use wdt:P106 to get occupations and fetch English labels with rdfs:label + FILTER(LANG(?label)="en"). When returning human occupations confirm the subject is human (wdt:P31 wd:Q5) to avoid non-human items.
  - Population (P1082) and tabular (P4179): use wdt:P1082 for quick/direct values; for time-series/point-in-time use p:P1082 + ps:P1082 + pq:P585 and ORDER BY pq:P585 DESC. Inspect statement qualifiers (e.g., 'applies to part') and prov:wasDerivedFrom references (pr:P854 etc.) to detect city-proper vs metro/prefecture scopes before using values.
  - Common person properties: P31 (instance of human Q5), P106 (occupation), P569 (date of birth), P19 (place of birth), P27 (country of citizenship), P21 (sex/gender), P166 (award received). Use wdt: for direct values when possible.
  - P17 (country) can be incomplete/misleading for places (historical/overseas tags). To get modern cities in a country combine: instance-of city (P31=Q515) + wdt:P17 OR use wdt:P131* to find an admin parent whose wdt:P17 = the country. Also cross-check coordinates (P625) or admin hierarchy to spot outliers.
  - When filtering by date of birth (P569) use xsd:dateTime comparisons (e.g. >= "1900-01-01T00:00:00Z"^^xsd:dateTime). Be aware many items have year-only or imprecise dates and coverage is biased toward notable/public figures (sportspeople, politicians, artists).
  - To retrieve qualifiers (e.g., award year) use the statement/qualifier pattern: p:Pxxx / ps:Pxxx / pq:P585. Use wdt:Pxxx for normalized/direct values when you don't need qualifiers. Example: p:P166 + pq:P585 gives award year.
  - To get a person's occupations: use wdt:P106 for direct/normalized values and rdfs:label for human-readable names (FILTER(LANG(...))). Example: wd:Q... wdt:P106 ?occ . ?occ rdfs:label ?occLabel . FILTER(LANG(?occLabel)="en").
  - P166 = award received. Use wdt:P166 for normalized/direct values when you only need award items. To get award years or qualifiers use p:P166 / ps:P166 / pq:P585. Many statements lack pq:P585 — use OPTIONAL { ?stmt pq:P585 ?date } and ORDER BY DESC(?date). When listing award winners, filter ?person wdt:P31 wd:Q5 to ensure humans.
  - Population time-series pattern: wd:Q... p:P1082 ?stmt . ?stmt ps:P1082 ?pop . OPTIONAL { ?stmt pq:P585 ?date } . ORDER BY DESC(?date). pq:P585 is the point-in-time qualifier. IMPORTANT: time-series may mix scopes (city proper vs metro) — e.g., Tokyo has a 2016 entry ~38,140,000 likely metro vs smaller city figures. Inspect qualifiers/references for scope before use.
  - Use wdt:P131* to traverse the admin hierarchy and compare wdt:P17 on the place vs an admin parent to detect historical/colonial country assignments. When mismatches appear, inspect the admin parent's instance-of (P31), labels, qualifiers and references to interpret the historical scope.
  - wdt:P106 often yields multiple occupations for a person. Use GROUP_CONCAT(DISTINCT ?occLabel; separator=", ") or return multiple rows. Always fetch labels with rdfs:label + FILTER(LANG(?label)="en") to get readable occupation names.
  - When a search_entity returns multiple hits (person vs sculpture vs memorial), confirm you selected the human/statements by checking wdt:P31 (instance of) and relevant wdt: properties (e.g., wdt:P106). This avoids using a non-human QID by mistake.
  - search_autocomplete can be constrained with a SPARQL pattern containing ?search (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }). Use constraints to focus results (e.g., humans) and avoid ambiguous fallbacks; if it returns no results, fallback to search_entity and verify wdt:P31.
  - Use search_property_of_entity to find relevant properties for an entity (e.g., 'award' -> P166) and search_object_of_property to discover candidate objects (e.g., 'physicist' for P106). This reduces guessing P/Q ids and surfaces qualifiers.
  - Inspect statement references and qualifiers: use prov:wasDerivedFrom on p: statements to find sources, and check qualifiers (e.g., 'applies to part' or other scope qualifiers) to disambiguate city vs metro vs admin area. Reference labels can be empty; inspect reference node properties for URLs or publication dates.

Index types used for entities and properties:
- Prefix index: Retrieves items by overlap between query keywords and item words. The query keywords can match item words exactly or as prefixes.
- Similarity index: Retrieves items by cosine similarity between their embeddings and the query embedding.

General notes across knowledge graphs:
- Use rdfs:label + FILTER(LANG(?label)="en") for labels; avoid SERVICE wikibase:label. Use wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access statement qualifiers (e.g., award year via pq:P585). When dates matter, prefer xsd:dateTime and watch for year-only precision.
- Practical query patterns: use rdfs:label + FILTER(LANG(...)) for labels. Use wdt:Pxxx for direct/normalized values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (dates via pq:P585). For dates use xsd:dateTime and expect year-only precision. For places: combine P17 with P131 or coordinate (P625) filters to avoid historical/overseas mismatches.
- Use OPTIONAL for pq: qualifiers (e.g., pq:P585), sort by qualifier (ORDER BY pq:P585 DESC) to prefer recent values. Use GROUP_CONCAT to combine multiple labels/values in one row. Watch for typed literals (xsd:dateTime, xsd:decimal) when filtering or sorting.
- Before querying, use search_entity to resolve human-friendly names to wd:Q identifiers and verify instance-of (e.g., check wdt:P31 = wd:Q5 for humans) to avoid ambiguous matches. Prefer the top match but programmatically confirm P31 before using its data.
- Use search_property to confirm property identifiers (e.g., "country" -> P17) before embedding them in queries. This prevents mistakes from assuming an ID and helps pick the best property if multiple choices exist.
- search_autocomplete can fall back to an unconstrained search or error when there are too many candidates. If this happens (e.g., "more than the maximum supported number of subject candidates"), retry with narrower constraints such as instance-of (wdt:P31), additional type filters, or short prefixes to reduce the candidate set; otherwise fallback to search_entity and verify wdt:P31.
- Use list(...) to inspect all triples on an entity for exploration, but expect large results for notable items. Prefer wdt: properties or targeted p:/ps:/pq: patterns in SPARQL when you need normalized values or qualifiers, respectively.
- Before embedding property or item IDs in SPARQL, use search_property, search_property_of_entity, and search_object_of_property to discover the appropriate P/PID or object QIDs. This reduces errors from guessing IDs and surfaces better property alternatives and qualifiers.
- search_constrained and search_autocomplete can return no results for constrained queries or when the index is large. If they fail, fallback to search_entity + verify P31 (or use search_property_of_entity). Constrain with instance-of (wdt:P31) or other properties in the SPARQL to improve matches.
- When selecting awards by year, prefer xsd:dateTime range filters (e.g., >= "2001-01-01T00:00:00Z"^^xsd:dateTime && < "2002-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for portability and precision.
- When selecting award winners via wdt:P166, filter ?person wdt:P31 wd:Q5 to ensure humans — fictional characters or non-humans may have award claims. If you need award years use p:P166 / ps:P166 / pq:P585 and OPTIONAL { ?stmt pq:P585 ?year } to retrieve qualifier years.
- Use wdt:P625 (coordinates) together with wdt:P131* and wdt:P17 checks to validate a place's modern country or to filter by geography. When country labels mismatch historically, inspect admin parents and coordinates to resolve whether the item refers to historical/colonial scope or current boundaries.
- Prefer wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (e.g., pq:P585 for award year). Always fetch labels with rdfs:label + FILTER(LANG(?label) = "en").
- If search_autocomplete returns too many candidates or errors, retry with constraints (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }) or narrower query text. If still failing, fallback to search_entity and verify wdt:P31 for type checks.
- For award-year queries use p:P166 / ps:P166 / pq:P585 to access award statements and year qualifiers. Filter by xsd:dateTime ranges (e.g., >= "2020-01-01T00:00:00Z"^^xsd:dateTime && < "2021-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for robustness.
- Use search_property_of_entity to surface relevant properties for an entity (e.g., 'birth' -> P569/P19). list(...) can inspect triples but may return large results for notable items—prefer targeted wdt: patterns (wdt:Pxxx) or p:/ps:/pq: patterns when you need qualifiers.

SPARQL prefixes for use in function calls:
- bd: <http://www.bigdata.com/rdf#
- cc: <http://creativecommons.org/ns#
- data: <https://www.wikidata.org/wiki/Special:EntityData/
- dc: <http://purl.org/dc/elements/1.1/
- dct: <http://purl.org/dc/terms/
- foaf: <http://xmlns.com/foaf/0.1/
- geo: <http://www.opengis.net/ont/geosparql#
- geof: <http://www.opengis.net/def/function/geosparql/
- gn: <http://www.geonames.org/ontology#
- hint: <http://www.bigdata.com/queryHints#
- 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/
- qb: <http://purl.org/linked-data/cube#
- qfn: <http://qlever.cs.uni-freiburg.de/function#
- ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
- qlss: <https://qlever.cs.uni-freiburg.de/spatialSearch/
- 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/
- void: <http://rdfs.org/ns/void#
- 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#

Additional rules to follow:
- Explain your thought process before and after each step and function call.
- Do not just use or make up entity or property identifiers without verifying their existence in the knowledge graphs first.
- Do not ask the user for clarifications without first attempting to complete the task. If the task input is incomplete or ambiguous, try to make reasonable assumptions and document them.
- 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.
- Always execute your final SPARQL query before giving an answer to make sure it returns the expected results.
- 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.
- 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.
- 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.
- For questions with a "True" or "False" answer the SPARQL query should be an ASK query.

[User] what type of cancer did eva peron die from?

[Assistant]
To determine the type of cancer Eva Perón died from, I will follow these steps:

1. Identify the entity for Eva Perón in Wikidata.
2. Look for properties related to her cause of death or medical condition, particularly focusing on cancer type.
3. Construct a SPARQL query to retrieve the specific type of cancer she died from.

### Step 1: Search for Eva Perón in Wikidata
I will first search for the entity corresponding to Eva Perón.

Question: Eva Peron

Top 10 entity alternatives:
1. Eva Perón (wd:Q40933), also known as Eva, Eva Duarte Ibarguren, Eva Peron, Evita, Evita Perón, etc.: Argentine actress and politician (1919–1952) / has occupation women's rights activist / has occupation trade unionist / has occupation stage actor / has occupation film actor / has occupation suffragist / has occupation politician / is instance of human
2. Eva Perón: The True Story (wd:Q953441, matched via Eva Peron), also known as Eva Peron, Eva Perón: 1996 film by Juan Carlos Desanzo / is instance of film
3. Fray Luis Beltrán (wd:Q113059537, matched via Eva Perón), also known as Eva Perón, Eva Perón tanker, Fray Luis Beltrán tanker: is instance of tanker / is instance of Tanker / tanker
4. Eva Perón (wd:Q113030601): is instance of tanker / is instance of Tanker / tanker
5. Uruguay (wd:Q113330807, matched via Eva Perón), also known as Eva Perón: is instance of passenger vessel / 1951 passenger ship
6. Hospital Lagomarsino (wd:Q5902632, matched via Eva Perón), also known as Eva Perón: hospital in Merlo, Buenos Aires / is instance of hospital
7. Eva Perón (wd:Q47512378): painting by Boris Chaliapin / painting by Boris Chaliapin / is instance of painting
8. Estadio Eva Perón (wd:Q5400194), also known as Estadio Eva Peron: is instance of association football venue / football stadium in Junín, Argentina
9. Puerto Eva Perón (wd:Q972928): ciudad en la provincia de Chaco, Argentina / is instance of municipality / is instance of locality
10. Eva Perón Foundation (wd:Q2004004): is instance of organisation / is instance of organization / former Argentine foundation / is instance of foundation

[Assistant]
The top result is **Eva Perón (wd:Q40933)**, the Argentine actress and politician. This is the correct entity we are looking for. Now, I will investigate her properties to find information about her cause of death, particularly the type of cancer.

### Step 2: Explore properties related to cause of death
I will use `search_property_of_entity` to find properties related to death or medical conditions for Eva Perón.

Question: cause of death

Top 10 property alternatives:
1. cause of death (wd:P509 as p/wdt), also known as death cause, died of, die from, die of, method of murder, etc.: underlying or immediate cause of death.  Underlying cause ... category, e.g. natural causes, accident, homicide, suicide / underlying or immediate cause of death.  Underlying cause ... category, e.g. natural causes, accident, homicide, suicide / an item describing the cause of a person or specific organism's death. Samples: leukaemia, car crash / medical cause of a person or specific organism's death (not to be confused with P1196)
2. manner of death (wd:P1196 as p/wdt, matched via circumstance of death), also known as circumstance of death, death manner, death type, nature of death, type of death, etc.: general circumstances of a person's death; e.g. natural ... mechanism, e.g. heart attack, trauma, pneumonia etc. / general circumstances of a person's death; e.g. natural ... mechanism, e.g. heart attack, trauma, pneumonia etc. / general circumstances of a person's death; e.g. natural ... mechanism, e.g. heart attack, trauma, pneumonia...
3. place of death (wd:P20 as p/wdt, matched via died), also known as death location, death place, deathplace, died, died in, etc.: most specific known (e.g. city instead of country, or ... death location of a person, animal or fictional character / most specific known (e.g. city instead of country, or ... death location of a person, animal or fictional character / most specific known (e.g. city instead of country, or ... death location of a person, animal or fictional character / is subproperty of location
4. date of death (wd:P570 as p/wdt, matched via died), also known as date of the end, dead, death, death date, deathdate, etc.: is subproperty of dissolved, abolished or demolished date / is subproperty of dissolved, abolished or demolished / date on which the subject died / date on which the subject died / date on which the subject died / is subproperty of end time
5. place of burial (wd:P119 as p/wdt, matched via interment), also known as ashes scattered at, burial location, burial place, buried at, buried in, etc.: location of grave, resting place, place of ash-scattering, ... places: e.g., re-burials, parts of body buried separately. / location of grave, resting place, place of ash-scattering, ... places: e.g., re-burials, parts of body buried separately. / location of grave, resting place, place of ash-scattering, ... e.g. re-burials, cenotaphs, parts of body buried separately / location of grave, resting place, place of ash-scattering, etc, (e.g. city or cemetery) for a person / is subproperty of location
6. described by source (wd:P1343 as p/wdt, matched via described by obituary), also known as defined in, described by biography, described by encyclopedia, described by obituary, described by reference work, etc.: dictionary, encyclopaedia, etc. where this item is described / work where this item is described / is subproperty of attested in
7. birth name (wd:P1477 as p/wdt, matched via né), also known as birthname, bn, bname, born as, full birth name, etc.: full name of a person at birth, if different from their ... John Peter Doe for Joe Doe, Ann Smith for Ann Miller) / full name of a person at birth, if different from their current, generally used name / full name of a person at birth, if different from their current name / is subproperty of name
8. place of birth (wd:P19 as p/wdt, matched via born), also known as birth city, birth location, birth place, birthplace, born, etc.: most specific known (e.g. city instead of country, or ... birth location of a person, animal or fictional character / most specific known (e.g. city instead of country, or ... birth location of a person, animal or fictional character / most specific known birth location of a person, animal or fictional character / is subproperty of location
9. date of birth (wd:P569 as p/wdt, matched via born), also known as birth date, birthdate, birth year, birthyear, born, etc.: is subproperty of date of foundation or creation / date on which the subject was born / date on which the subject was born / date on which the subject was born / is subproperty of inception
10. religion or worldview (wd:P140 as p/wdt, matched via life stance), also known as belief system, believes, denomination, devotee of, faith, etc.: religion of a person, organisation or religious building, or associated with this subject / religion of a person, organisation or religious building, or associated with this subject / religion of a person, organization or religious building, or associated with this subject

No other items found

[Assistant]
The property **"cause of death" (wd:P509)** is the most relevant one for our purpose. It directly refers to the underlying or immediate cause of death, which in this case would be the type of cancer.

### Step 3: Retrieve the cause of death for Eva Perón
I will now query Wikidata to get the value of `wdt:P509` (cause of death) for Eva Perón (wd:Q40933).

execute

SELECT ?causeOfDeath WHERE { wd:Q40933 wdt:P509 ?causeOfDeath }

[Assistant]
Eva Perón died from **cervical cancer**, which is represented in Wikidata as **cervix uterine cancer (wd:Q160105)**.

To provide a more human-readable answer, I will also retrieve the English label for this cancer type.

SELECT ?causeOfDeathLabel WHERE { wd:Q40933 wdt:P509 ?causeOfDeath . ?causeOfDeath rdfs:label ?causeOfDeathLabel FILTER(LANG(?causeOfDeathLabel) = "en") }

Got 1 row and 1 column:
| causeOfDeathLabel               |
| ------------------------------- |
| cervix uterine cancer (lang:en) |

[Assistant]
Eva Perón died from **cervix uterine cancer**.

I now have the final answer and can provide the SPARQL query that retrieves this information.

The SPARQL query to answer the question is:

```sparql
SELECT ?causeOfDeathLabel WHERE {
  wd:Q40933 wdt:P509 ?causeOfDeath .
  ?causeOfDeath rdfs:label ?causeOfDeathLabel
  FILTER(LANG(?causeOfDeathLabel) = "en")
}
```

This query retrieves the English label of the cause of death for Eva Perón (wd:Q40933), which is "cervix uterine cancer".

I will now finalize the answer.

answer

SELECT ?causeOfDeathLabel WHERE { wd:Q40933 wdt:P509 ?causeOfDeath . ?causeOfDeath rdfs:label ?causeOfDeathLabel FILTER(LANG(?causeOfDeathLabel) = "en") }

Answer: Eva Perón died from cervix uterine cancer.


PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?language ?languageLabel WHERE {
  {
    wd:Q408 wdt:P37 ?language .
  } UNION {
    ?state wdt:P17 wd:Q408 .
    ?state wdt:P31 ?type .
    FILTER ( ?type IN ( wd:Q5852411 , wd:Q14192199 , wd:Q11687019 ) ) .
    ?state wdt:P37 ?language .
  }
  .
  ?language rdfs:label ?languageLabel .
  FILTER ( LANG( ?languageLabel ) = "en" )
}

Using entities:
- external territory of Australia (wd:Q11687019), also known as Australian external territory: is subclass of overseas territory / is subclass of territory of Australia / subdivision of Australia
- territory of Australia (wd:Q14192199), also known as Australian territory: is subclass of state or territory of Australia / is subclass of federal district / is subclass of territory / Australian administrative territorial subdivision
- Australia (wd:Q408), also known as AU, AUS, Aussieland, Commonwealth of Australia, Down Under, etc.: is instance of sovereign state / is instance of federation / is instance of country / country in Oceania / country in Oceania / country in Oceania / country in Oceania
- state of Australia (wd:Q5852411), also known as Australian state: is instance of designation for an administrative territorial entity of a single country / is subclass of first-level administrative division / is subclass of federated state / is subclass of Federated state / is subclass of state or territory of Australia / is subclass of constituency / is subclass of electoral unit / is subclass of riding / administrative subdivision in Australia

Using properties:
- country (wd:P17 as wdt), also known as host country, land, sovereign state, state, P17: is subproperty of located in the administrative territorial entity / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings)
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- official language (wd:P37 as wdt), also known as language official, language spoken, speaking, spoken in, P37: is subproperty of language used / language designated as official by this item / language designated as official by this item / language designated as official by this item / language designated as official by this item

Got 13 rows and 2 columns, showing the first 5 and last 5 rows below:
| language                       | languageLabel                |
| ------------------------------ | ---------------------------- |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| ...                            | ...                          |
| Auslan (wd:Q29525)             | Auslan (lang:en)             |
| Norfuk (wd:Q33797)             | Norfuk (lang:en)             |
| Norfuk (wd:Q33797)             | Norfuk (lang:en)             |
| Australian English (wd:Q44679) | Australian English (lang:en) |
| Australian English (wd:Q44679) | Australian English (lang:en) |

Answer: People in Australia primarily speak English (including Australian English), Auslan (the sign language of the Deaf community), and Norfuk (spoken on Norfolk Island). While many other languages are spoken due to immigration and Indigenous communities, these are the only ones officially recognized at the national or territorial level.

People in Australia primarily speak English (including Australian English), Auslan (the sign language of the Deaf community), and Norfuk (spoken on Norfolk Island). While many other languages are spoken due to immigration and Indigenous communities, these are the only ones officially recognized at the national or territorial level.

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?language ?languageLabel WHERE {
  {
    wd:Q408 wdt:P37 ?language .
  } UNION {
    ?state wdt:P17 wd:Q408 .
    ?state wdt:P31 ?type .
    FILTER ( ?type IN ( wd:Q5852411 , wd:Q14192199 , wd:Q11687019 ) ) .
    ?state wdt:P37 ?language .
  }
  .
  ?language rdfs:label ?languageLabel .
  FILTER ( LANG( ?languageLabel ) = "en" )
}

Using entities:
- external territory of Australia (wd:Q11687019), also known as Australian external territory: is subclass of overseas territory / is subclass of territory of Australia / subdivision of Australia
- territory of Australia (wd:Q14192199), also known as Australian territory: is subclass of state or territory of Australia / is subclass of federal district / is subclass of territory / Australian administrative territorial subdivision
- Australia (wd:Q408), also known as AU, AUS, Aussieland, Commonwealth of Australia, Down Under, etc.: is instance of sovereign state / is instance of federation / is instance of country / country in Oceania / country in Oceania / country in Oceania / country in Oceania
- state of Australia (wd:Q5852411), also known as Australian state: is instance of designation for an administrative territorial entity of a single country / is subclass of first-level administrative division / is subclass of federated state / is subclass of Federated state / is subclass of state or territory of Australia / is subclass of constituency / is subclass of electoral unit / is subclass of riding / administrative subdivision in Australia

Using properties:
- country (wd:P17 as wdt), also known as host country, land, sovereign state, state, P17: is subproperty of located in the administrative territorial entity / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings) / sovereign state that this item is in (not to be used for human beings)
- instance of (wd:P31 as wdt), also known as example of, has type, is a, is an, is of type, etc.: that class of which this subject is a particular example and ... a subclass of mountain (and an instance of volcanic landform) / type to which this subject corresponds/belongs. Different ... and the volcano is a type (instance) of volcanic landform
- official language (wd:P37 as wdt), also known as language official, language spoken, speaking, spoken in, P37: is subproperty of language used / language designated as official by this item / language designated as official by this item / language designated as official by this item / language designated as official by this item

Execution result:
Got 13 rows and 2 columns, showing the first 5 and last 5 rows below:
| language                       | languageLabel                |
| ------------------------------ | ---------------------------- |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| ...                            | ...                          |
| Auslan (wd:Q29525)             | Auslan (lang:en)             |
| Norfuk (wd:Q33797)             | Norfuk (lang:en)             |
| Norfuk (wd:Q33797)             | Norfuk (lang:en)             |
| Australian English (wd:Q44679) | Australian English (lang:en) |
| Australian English (wd:Q44679) | Australian English (lang:en) |

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

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. Search for the 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. Execute intermediate queries to get feedback and to verify your assumptions. You may need to refine or rethink your current plan based on the query results and go back to step 2 if needed, possibly multiple times.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Available knowledge graphs:
- wikidata at http://localhost:7001 with prefix index for entities and similarity index for properties, and notes:
  - P106 = occupation. Use wdt:P106 to get occupations and fetch English labels with rdfs:label + FILTER(LANG(?label)="en"). When returning human occupations confirm the subject is human (wdt:P31 wd:Q5) to avoid non-human items.
  - Population (P1082) and tabular (P4179): use wdt:P1082 for quick/direct values; for time-series/point-in-time use p:P1082 + ps:P1082 + pq:P585 and ORDER BY pq:P585 DESC. Inspect statement qualifiers (e.g., 'applies to part') and prov:wasDerivedFrom references (pr:P854 etc.) to detect city-proper vs metro/prefecture scopes before using values.
  - Common person properties: P31 (instance of human Q5), P106 (occupation), P569 (date of birth), P19 (place of birth), P27 (country of citizenship), P21 (sex/gender), P166 (award received). Use wdt: for direct values when possible.
  - P17 (country) can be incomplete/misleading for places (historical/overseas tags). To get modern cities in a country combine: instance-of city (P31=Q515) + wdt:P17 OR use wdt:P131* to find an admin parent whose wdt:P17 = the country. Also cross-check coordinates (P625) or admin hierarchy to spot outliers.
  - When filtering by date of birth (P569) use xsd:dateTime comparisons (e.g. >= "1900-01-01T00:00:00Z"^^xsd:dateTime). Be aware many items have year-only or imprecise dates and coverage is biased toward notable/public figures (sportspeople, politicians, artists).
  - To retrieve qualifiers (e.g., award year) use the statement/qualifier pattern: p:Pxxx / ps:Pxxx / pq:P585. Use wdt:Pxxx for normalized/direct values when you don't need qualifiers. Example: p:P166 + pq:P585 gives award year.
  - To get a person's occupations: use wdt:P106 for direct/normalized values and rdfs:label for human-readable names (FILTER(LANG(...))). Example: wd:Q... wdt:P106 ?occ . ?occ rdfs:label ?occLabel . FILTER(LANG(?occLabel)="en").
  - P166 = award received. Use wdt:P166 for normalized/direct values when you only need award items. To get award years or qualifiers use p:P166 / ps:P166 / pq:P585. Many statements lack pq:P585 — use OPTIONAL { ?stmt pq:P585 ?date } and ORDER BY DESC(?date). When listing award winners, filter ?person wdt:P31 wd:Q5 to ensure humans.
  - Population time-series pattern: wd:Q... p:P1082 ?stmt . ?stmt ps:P1082 ?pop . OPTIONAL { ?stmt pq:P585 ?date } . ORDER BY DESC(?date). pq:P585 is the point-in-time qualifier. IMPORTANT: time-series may mix scopes (city proper vs metro) — e.g., Tokyo has a 2016 entry ~38,140,000 likely metro vs smaller city figures. Inspect qualifiers/references for scope before use.
  - Use wdt:P131* to traverse the admin hierarchy and compare wdt:P17 on the place vs an admin parent to detect historical/colonial country assignments. When mismatches appear, inspect the admin parent's instance-of (P31), labels, qualifiers and references to interpret the historical scope.
  - wdt:P106 often yields multiple occupations for a person. Use GROUP_CONCAT(DISTINCT ?occLabel; separator=", ") or return multiple rows. Always fetch labels with rdfs:label + FILTER(LANG(?label)="en") to get readable occupation names.
  - When a search_entity returns multiple hits (person vs sculpture vs memorial), confirm you selected the human/statements by checking wdt:P31 (instance of) and relevant wdt: properties (e.g., wdt:P106). This avoids using a non-human QID by mistake.
  - search_autocomplete can be constrained with a SPARQL pattern containing ?search (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }). Use constraints to focus results (e.g., humans) and avoid ambiguous fallbacks; if it returns no results, fallback to search_entity and verify wdt:P31.
  - Use search_property_of_entity to find relevant properties for an entity (e.g., 'award' -> P166) and search_object_of_property to discover candidate objects (e.g., 'physicist' for P106). This reduces guessing P/Q ids and surfaces qualifiers.
  - Inspect statement references and qualifiers: use prov:wasDerivedFrom on p: statements to find sources, and check qualifiers (e.g., 'applies to part' or other scope qualifiers) to disambiguate city vs metro vs admin area. Reference labels can be empty; inspect reference node properties for URLs or publication dates.

Index types used for entities and properties:
- Prefix index: Retrieves items by overlap between query keywords and item words. The query keywords can match item words exactly or as prefixes.
- Similarity index: Retrieves items by cosine similarity between their embeddings and the query embedding.

General notes across knowledge graphs:
- Use rdfs:label + FILTER(LANG(?label)="en") for labels; avoid SERVICE wikibase:label. Use wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access statement qualifiers (e.g., award year via pq:P585). When dates matter, prefer xsd:dateTime and watch for year-only precision.
- Practical query patterns: use rdfs:label + FILTER(LANG(...)) for labels. Use wdt:Pxxx for direct/normalized values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (dates via pq:P585). For dates use xsd:dateTime and expect year-only precision. For places: combine P17 with P131 or coordinate (P625) filters to avoid historical/overseas mismatches.
- Use OPTIONAL for pq: qualifiers (e.g., pq:P585), sort by qualifier (ORDER BY pq:P585 DESC) to prefer recent values. Use GROUP_CONCAT to combine multiple labels/values in one row. Watch for typed literals (xsd:dateTime, xsd:decimal) when filtering or sorting.
- Before querying, use search_entity to resolve human-friendly names to wd:Q identifiers and verify instance-of (e.g., check wdt:P31 = wd:Q5 for humans) to avoid ambiguous matches. Prefer the top match but programmatically confirm P31 before using its data.
- Use search_property to confirm property identifiers (e.g., "country" -> P17) before embedding them in queries. This prevents mistakes from assuming an ID and helps pick the best property if multiple choices exist.
- search_autocomplete can fall back to an unconstrained search or error when there are too many candidates. If this happens (e.g., "more than the maximum supported number of subject candidates"), retry with narrower constraints such as instance-of (wdt:P31), additional type filters, or short prefixes to reduce the candidate set; otherwise fallback to search_entity and verify wdt:P31.
- Use list(...) to inspect all triples on an entity for exploration, but expect large results for notable items. Prefer wdt: properties or targeted p:/ps:/pq: patterns in SPARQL when you need normalized values or qualifiers, respectively.
- Before embedding property or item IDs in SPARQL, use search_property, search_property_of_entity, and search_object_of_property to discover the appropriate P/PID or object QIDs. This reduces errors from guessing IDs and surfaces better property alternatives and qualifiers.
- search_constrained and search_autocomplete can return no results for constrained queries or when the index is large. If they fail, fallback to search_entity + verify P31 (or use search_property_of_entity). Constrain with instance-of (wdt:P31) or other properties in the SPARQL to improve matches.
- When selecting awards by year, prefer xsd:dateTime range filters (e.g., >= "2001-01-01T00:00:00Z"^^xsd:dateTime && < "2002-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for portability and precision.
- When selecting award winners via wdt:P166, filter ?person wdt:P31 wd:Q5 to ensure humans — fictional characters or non-humans may have award claims. If you need award years use p:P166 / ps:P166 / pq:P585 and OPTIONAL { ?stmt pq:P585 ?year } to retrieve qualifier years.
- Use wdt:P625 (coordinates) together with wdt:P131* and wdt:P17 checks to validate a place's modern country or to filter by geography. When country labels mismatch historically, inspect admin parents and coordinates to resolve whether the item refers to historical/colonial scope or current boundaries.
- Prefer wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (e.g., pq:P585 for award year). Always fetch labels with rdfs:label + FILTER(LANG(?label) = "en").
- If search_autocomplete returns too many candidates or errors, retry with constraints (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }) or narrower query text. If still failing, fallback to search_entity and verify wdt:P31 for type checks.
- For award-year queries use p:P166 / ps:P166 / pq:P585 to access award statements and year qualifiers. Filter by xsd:dateTime ranges (e.g., >= "2020-01-01T00:00:00Z"^^xsd:dateTime && < "2021-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for robustness.
- Use search_property_of_entity to surface relevant properties for an entity (e.g., 'birth' -> P569/P19). list(...) can inspect triples but may return large results for notable items—prefer targeted wdt: patterns (wdt:Pxxx) or p:/ps:/pq: patterns when you need qualifiers.

SPARQL prefixes for use in function calls:
- bd: <http://www.bigdata.com/rdf#
- cc: <http://creativecommons.org/ns#
- data: <https://www.wikidata.org/wiki/Special:EntityData/
- dc: <http://purl.org/dc/elements/1.1/
- dct: <http://purl.org/dc/terms/
- foaf: <http://xmlns.com/foaf/0.1/
- geo: <http://www.opengis.net/ont/geosparql#
- geof: <http://www.opengis.net/def/function/geosparql/
- gn: <http://www.geonames.org/ontology#
- hint: <http://www.bigdata.com/queryHints#
- 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/
- qb: <http://purl.org/linked-data/cube#
- qfn: <http://qlever.cs.uni-freiburg.de/function#
- ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
- qlss: <https://qlever.cs.uni-freiburg.de/spatialSearch/
- 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/
- void: <http://rdfs.org/ns/void#
- 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#

Additional rules to follow:
- Explain your thought process before and after each step and function call.
- Do not just use or make up entity or property identifiers without verifying their existence in the knowledge graphs first.
- Do not ask the user for clarifications without first attempting to complete the task. If the task input is incomplete or ambiguous, try to make reasonable assumptions and document them.
- 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.
- Always execute your final SPARQL query before giving an answer to make sure it returns the expected results.
- 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.
- 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.
- 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.
- For questions with a "True" or "False" answer the SPARQL query should be an ASK query.

[User] what do people in australia speak?

[Assistant]
To determine what people in Australia speak, I need to find the languages spoken in Australia. This involves identifying the relevant property for "language spoken" and then querying for the languages associated with Australia.

### Step 1: Identify the entity for Australia
I'll start by searching for the entity representing Australia.

Question: Australia

Top 10 entity alternatives:
1. Australia (wd:Q408), also known as AU, AUS, Aussieland, Commonwealth of Australia, Down Under, etc.: is instance of sovereign state / is instance of federation / is instance of country / country in Oceania / country in Oceania / country in Oceania / country in Oceania
2. Australian continent (wd:Q3960, matched via Australia), also known as Australia, Australia (continent), Australinea, Meganesia, New Holland, etc.: continent in the Earth's Southern Hemisphere / continent in Earth's Southern Hemisphere / is instance of continent / continent
3. Australia (wd:Q275180): 2008 film by Baz Luhrmann / is instance of film
4. Australia (wd:Q205546): 1989 film by Jean-Jacques Andrien / is instance of film
5. Australia (wd:Q4823546): 1996 single by Manic Street Preachers / is instance of single
6. Australia (wd:Q16835533): is instance of Horse / is instance of horse / Racehorse
7. Australia (wd:Q781244): is instance of board game / board game
8. Australia (wd:Q4823541), also known as Australia (KA–5): yacht that raced in the Americas Cup / is instance of sailing yacht
9. Australia (wd:Q12887638): village and ''consejo popular'' in Cuba / is instance of human settlement
10. Australia (wd:Q25907685): albedo feature on the planet Mercury / is instance of albedo feature

[Assistant]
The top result is `wd:Q408`, which represents Australia as a sovereign state. This is the correct entity to use for querying languages spoken in Australia.

### Step 2: Find the property for "language spoken"
I need to find the property that links a country to the languages spoken there. I'll search for properties related to "language" or "spoken language".

Question: language spoken

Top 10 property alternatives:
1. official language (wd:P37 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via language spoken), also known as language official, language spoken, speaking, spoken in, P37: language designated as official by this item / language designated as official by this item / language designated as official by this item / language designated as official by this item / is subproperty of language used
2. languages spoken, written or signed (wd:P1412 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via language spoken), also known as language, language of expression, language read, language signed, languages of expression, etc.: language(s) that a person or a people speaks, writes or signs, including the native language(s) / language(s) that a person speaks or writes, including the native language(s) / language(s) that a person speaks or writes, including the native language(s)
3. language of work or name (wd:P407 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via used language), also known as audio language, available in, broadcasting language, language, language of name, etc.: language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this creative work (such as books, ... (P103) and "languages spoken, written or signed" (P1412)) / language associated with this work or name (for persons use P103 and P1412)
4. language used (wd:P2936 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via used language), also known as languages used, medium of instruction, used language, uses language, working language, etc.: language widely used (spoken or written) in this place or at this event or organisation
5. writing language (wd:P6886 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via languages written), also known as language for writing, language of works, language of writings, languages for writing, languages of works, etc.: is subproperty of languages spoken, written or signed / language in which the writer has written their work
6. Ethnologue language status (wd:P3823 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via language status), also known as EGIDS, language status, P3823: language status identifier by Ethnologue.com using EGIDS scale / language status identifier by Ethnologue.com using EGIDS scale
7. programmed in (wd:P277 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via language), also known as language, programming language, written in, P277: the programming language(s) in which the software is developed
8. native language (wd:P103 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via first language), also known as first language, L1 speaker of, language native, mother tongue, P103: language or languages a person has learned from early childhood / is subproperty of languages spoken, written or signed / language or languages a person has learned from birth / language or languages a person has learned from birth
9. original language of film or TV show (wd:P364 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via media language), also known as created on language, language of the original work, media language, original language, P364: language in which a film or a performance work was originally ... and songs; use P407 ("language of work or name") instead. / language in which a film or a performance work was originally ... written works; use P407 ("language of work or name") instead. / language in which a film or a performance work was originally ... written works; use P407 ("language of work or name") instead. / is subproperty of language of work or name
10. language style (wd:P6191 as ps/psv/p/pqv/pqn/psn/pq/wdt/pr/prn/prv/wdtn, matched via language use), also known as archaic, childish, context, dated, form register, etc.: to denote of the way a sense of a word is used, e.g., slang, vulgarism, babytalk, colloquialism, etc.

[Assistant]
The most relevant property for "languages spoken" in a country is `wdt:P1412` ("languages spoken, written or signed"). This property is directly associated with places and represents the languages used by the population.

### Step 3: Query for languages spoken in Australia
Now I will construct a SPARQL query to retrieve the languages spoken in Australia (`wd:Q408`) using `wdt:P1412`. I will also fetch the English labels for these languages to make the results human-readable.

The query will:
1. Select the language items (`?language`) linked to Australia via `wdt:P1412`.
2. Retrieve the English labels for these languages using `rdfs:label` and `FILTER(LANG(?label) = "en")`.

Let me execute this query.

execute

SELECT ?language ?label WHERE { wd:Q408 wdt:P1412 ?language . ?language rdfs:label ?label . FILTER(LANG(?label) = "en") }

[Assistant]
The query returned no results, which is unexpected. This suggests that `wdt:P1412` might not be directly used for Australia, or the data might be stored differently. Let me investigate further.

### Step 4: Check if Australia has any language-related properties
I'll use the `list` function to inspect the triples for Australia (`wd:Q408`) to see what language-related properties are present.

list

wd:Q408

[Assistant]
The `list` query for `wdt:P1412` returned no results, confirming that Australia does not have a direct `wdt:P1412` statement. This suggests that the languages spoken in Australia might be stored differently—perhaps via the "official language" property (`wdt:P37`) or another indirect method.

### Step 5: Check for official languages of Australia
I'll now check if Australia has any official languages using `wdt:P37` (official language).

wd:Q408

[Assistant]
Great! I now see that Australia has two official languages listed:
1. **Auslan** (`wd:Q29525`) — the sign language used by the Deaf community in Australia.
2. **Australian English** (`wd:Q44679`) — the variety of English spoken in Australia.

However, Australian English is not the only language spoken in Australia. Many other languages are spoken due to immigration and Indigenous communities. The `wdt:P37` property only lists *official* languages, but we need to find *all* languages spoken.

### Step 6: Explore other language-related properties
Let me check if `wdt:P1412` (languages spoken, written or signed) is used on any administrative subdivisions of Australia (e.g., states or territories), which might provide a more complete picture.

I'll first check if Australia has any administrative subdivisions using `wdt:P131` (located in the administrative territorial entity).

wd:Q408

[Assistant]
The `wdt:P131` property does not directly link Australia to its subdivisions because Australia is a country, and its subdivisions (states/territories) are linked *to* Australia, not the other way around. So I need to find the subdivisions of Australia by querying for items where `wdt:P17` (country) is Australia.

### Step 7: Find Australian states and territories
I'll search for entities that are administrative subdivisions of Australia (i.e., have `wdt:P17 = wd:Q408`).

execute

SELECT ?state ?stateLabel WHERE { ?state wdt:P17 wd:Q408 . ?state wdt:P31 wd:Q16838475 . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } }

[Assistant]
The query returned no results because I used an incorrect instance type. Australian states and territories are not necessarily classified as `wd:Q16838475` (administrative territorial entity). Let me instead look for any entities that are part of Australia using `wdt:P131` (located in the administrative territorial entity) in reverse — that is, find items where Australia is the parent.

Actually, the correct approach is to find items that have `wdt:P17 = wd:Q408` and are instances of a state or territory. Let me try with `wdt:P31` (instance of) for common types like `wd:Q16838475` (administrative territorial entity) or `wd:Q16838475` might not be correct. Let me check what the actual instance types are for Australian states.

Alternatively, I can look for any item that has `wdt:P17 = wd:Q408` and is a human settlement or administrative division.

Let me try a broader query:

SELECT ?item ?itemLabel WHERE { ?item wdt:P17 wd:Q408 . ?item wdt:P31 ?type . FILTER(?type IN (wd:Q16838475, wd:Q16838475, wd:Q515, wd:Q156381)) . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } LIMIT 10

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: '
<title>301 Moved Permanently</title>

301 Moved Permanently'

[Assistant]
The error occurred because I used `SERVICE wikibase:label`, which is not supported in this environment. I must use `rdfs:label` with `FILTER(LANG(?label) = "en")` instead.

Let me rewrite the query without `SERVICE wikibase:label`:

SELECT ?item ?itemLabel WHERE { ?item wdt:P17 wd:Q408 . ?item wdt:P31 ?type . FILTER(?type IN (wd:Q16838475, wd:Q515, wd:Q156381)) . ?item rdfs:label ?itemLabel . FILTER(LANG(?itemLabel) = "en") } LIMIT 10

Got 10 rows and 2 columns:
| item                             | itemLabel                    |
| -------------------------------- | ---------------------------- |
| Southport (wd:Q1002144)          | Southport (lang:en)          |
| Ipswich (wd:Q1009253)            | Ipswich (lang:en)            |
| Colac (wd:Q1009509)              | Colac (lang:en)              |
| Maryborough (wd:Q1014561)        | Maryborough (lang:en)        |
| Victor Harbor (wd:Q1015796)      | Victor Harbor (lang:en)      |
| Wangaratta (wd:Q1024728)         | Wangaratta (lang:en)         |
| Grafton (wd:Q1025587)            | Grafton (lang:en)            |
| Sale (wd:Q1026976)               | Sale (lang:en)               |
| City of Gold Coast (wd:Q1069385) | City of Gold Coast (lang:en) |
| Frankston (wd:Q1136771)          | Frankston (lang:en)          |

[Assistant]
The results show cities in Australia, not states or territories. This means I need to refine my search for Australian states and territories.

Let me check what the correct instance type is for Australian states. I'll search for "Australian state" to find the correct QID.

Question: Australian state

Top 10 entity alternatives:
1. state of Australia (wd:Q5852411, matched via Australian state), also known as Australian state: is instance of designation for an administrative territorial entity of a single country / is subclass of first-level administrative division / is subclass of state or territory of Australia / administrative subdivision in Australia / is subclass of federated state / is subclass of Federated state / is subclass of electoral unit / is subclass of constituency / is subclass of riding
2. Australian State Coach (wd:Q4824709): horse-drawn carriage used by the British Royal Family / is instance of official state coach
3. Australian state constitution (wd:Q7603668): constitution of a state of Australia / is subclass of constitution
4. premier of an Australian state (wd:Q7240389, matched via premier of Australian state), also known as premier of Australian state, Premiers of the Australian states: is subclass of head of government of an Australian state or territory / head of government in a state of Australia / is subclass of premier
5. Australian State Netball League (wd:Q4824710): australia's premier netball league before the Commonwealth Bank Trophy
6. West Australian State Premiership (wd:Q7984362): defunct Australian rules football match / is instance of championship
7. South Australian state election (wd:Q56185179), also known as South Australian colonial election: is subclass of legislative election / South Australian general election / is instance of class of election
8. 2017 Western Australian state election (wd:Q7987594), also known as Western Australian state election, 2017: state general election for Western Australia, held on 11 March 2017 / is instance of legislative election
9. 2022 South Australian state election (wd:Q55633554), also known as South Australian state election, 2022: is instance of South Australian state election / South Australian general election
10. 2021 Western Australian state election (wd:Q29325343), also known as Western Australian state election, 2021: state general election for Western Australia, held on 13 March 2021 / is instance of legislative election

[Assistant]
The correct entity for "state of Australia" is `wd:Q5852411`. Now I can query for Australian states and territories by looking for items that are instances of `wd:Q5852411` and have `wdt:P17 = wd:Q408`.

Let me execute the query:

SELECT ?state ?stateLabel WHERE { ?state wdt:P31 wd:Q5852411 . ?state wdt:P17 wd:Q408 . ?state rdfs:label ?stateLabel . FILTER(LANG(?stateLabel) = "en") }

Got 6 rows and 2 columns:
| state                        | stateLabel                  |
| ---------------------------- | --------------------------- |
| Western Australia (wd:Q3206) | Western Australia (lang:en) |
| New South Wales (wd:Q3224)   | New South Wales (lang:en)   |
| Tasmania (wd:Q34366)         | Tasmania (lang:en)          |
| South Australia (wd:Q35715)  | South Australia (lang:en)   |
| Queensland (wd:Q36074)       | Queensland (lang:en)        |
| Victoria (wd:Q36687)         | Victoria (lang:en)          |

[Assistant]
Now I have the six Australian states. I still need to include territories. Let me check for Australian territories.

I'll search for "Australian territory":

Question: Australian territory

Top 10 entity alternatives:
1. territory of Australia (wd:Q14192199, matched via Australian territory), also known as Australian territory: Australian administrative territorial subdivision / is subclass of state or territory of Australia / is subclass of federal district / is subclass of territory
2. Australian Capital Territory (wd:Q3258), also known as ACT, Australia, AU-ACT, Australia Capital Territory, Australian capital territory, Australian Capital Territory, Australia, etc.: federal territory of Australia, containing the capital city, Canberra / is instance of mainland territory of Australia / is instance of territory of Australia / is instance of enclave
3. Australian Antarctic Territory (wd:Q178994): is instance of territorial claims in Antarctica / is instance of external territory of Australia / Australia's territorial claim in Antarctica
4. external territory of Australia (wd:Q11687019, matched via Australian external territory), also known as Australian external territory: is subclass of territory of Australia / is subclass of overseas territory / subdivision of Australia
5. Division of Australian Capital Territory (wd:Q5284491, matched via Australian Capital Territory), also known as Australian Capital Territory, Division of ACT: is instance of division of the Australian House of Representatives / Australian federal electoral division
6. Australian Capital Territory (wd:Q56649107): is instance of constituency of the Senate of Australia / constituency of the Australian senate
7. Australian Capital Territory (wd:Q58351056): is instance of scholarly article / is instance of academic article / article
8. Canberra (wd:Q3114, matched via Canberra, Australian Capital Territory), also known as Canberra, Australia, Canberra, Australian Capital Territory: is instance of planned national capital / is instance of federal capital / is instance of political city / capital city of Australia / is instance of big city / capital of Australia / is instance of city
9. flag of the Australian Capital Territory (wd:Q252995, matched via Australian Capital Territory flag), also known as Australian Capital Territory flag, the Australian Capital Territory flag: flag of the Australian Capital Territory, Australia / is instance of flag of a country subdivision
10. Acton (wd:Q482055, matched via Acton, Australian Capital Territory), also known as Acton, ACT, Acton, Australia, Acton, Australian Capital Territory, Acton, Australian Capital Territory, Australia, Acton, Canberra: suburb of Canberra, Australia / is instance of suburb

[Assistant]
The main Australian territories are:
- **Australian Capital Territory** (`wd:Q3258`)
- **Australian Antarctic Territory** (`wd:Q178994`)
- Other external territories (e.g., Norfolk Island, Christmas Island, etc.)

Let me check for all territories that are instances of `wd:Q14192199` (territory of Australia) or `wd:Q11687019` (external territory of Australia) and have `wdt:P17 = wd:Q408`.

I'll execute a query to find all Australian territories:

SELECT ?territory ?territoryLabel WHERE { ?territory wdt:P17 wd:Q408 . ?territory wdt:P31 ?type . FILTER(?type IN (wd:Q14192199, wd:Q11687019)) . ?territory rdfs:label ?territoryLabel . FILTER(LANG(?territoryLabel) = "en") }

Got 12 rows and 2 columns, showing the first 5 and last 5 rows below:
| territory                                         | territoryLabel                                |
| ------------------------------------------------- | --------------------------------------------- |
| Heard Island and McDonald Islands (wd:Q131198)    | Heard Island and McDonald Islands (lang:en)   |
| Ashmore and Cartier Islands (wd:Q133888)          | Ashmore and Cartier Islands (lang:en)         |
| Jervis Bay Territory (wd:Q15577)                  | Jervis Bay Territory (lang:en)                |
| Coral Sea Islands (wd:Q172216)                    | Coral Sea Islands (lang:en)                   |
| Australian Antarctic Territory (wd:Q178994)       | Australian Antarctic Territory (lang:en)      |
| ...                                               | ...                                           |
| Christmas Island (wd:Q31063)                      | Christmas Island (lang:en)                    |
| Australian Capital Territory (wd:Q3258)           | Australian Capital Territory (lang:en)        |
| Cocos (Keeling) Islands (wd:Q36004)               | Cocos (Keeling) Islands (lang:en)             |
| Australian Indian Ocean Territories (wd:Q4824275) | Australian Indian Ocean Territories (lang:en) |
| Central Australia (territory) (wd:Q85751210)      | Central Australia (territory) (lang:en)       |

[Assistant]
Now I have all Australian states and territories. Next, I need to find the languages spoken in these subdivisions. I'll use `wdt:P1412` (languages spoken, written or signed) on each of these entities.

I'll construct a query that:
1. Gets all Australian states and territories (6 states + 12 territories).
2. Finds the languages spoken in each using `wdt:P1412`.
3. Retrieves the English labels for those languages.

Let me execute this query:

SELECT ?language ?languageLabel WHERE { { ?state wdt:P17 wd:Q408 . ?state wdt:P31 wd:Q5852411 . } UNION { ?state wdt:P17 wd:Q408 . ?state wdt:P31 ?type . FILTER(?type IN (wd:Q14192199, wd:Q11687019)) . } . ?state wdt:P1412 ?language . ?language rdfs:label ?languageLabel . FILTER(LANG(?languageLabel) = "en") }

[Assistant]
The query returned no results, which is surprising. This suggests that `wdt:P1412` is not directly used on Australian states or territories either. This is a known issue in Wikidata — many countries and subdivisions lack direct `wdt:P1412` statements, and language data is often inferred from other sources.

### Step 8: Alternative approach — Use "official language" (`wdt:P37`) on Australia and its subdivisions
Since `wdt:P1412` is not reliably used, I'll collect all official languages from:
1. Australia itself (`wd:Q408`) — we already know it has Australian English and Auslan.
2. Australian states and territories — some may have official languages.

Let me query for all official languages (`wdt:P37`) of Australia and its states/territories.

I'll combine:
- Australia's official languages (`wd:Q408`)
- Official languages of Australian states and territories

Here's the query:

SELECT ?language ?languageLabel WHERE { { wd:Q408 wdt:P37 ?language . } UNION { ?state wdt:P17 wd:Q408 . ?state wdt:P31 ?type . FILTER(?type IN (wd:Q5852411, wd:Q14192199, wd:Q11687019)) . ?state wdt:P37 ?language . } . ?language rdfs:label ?languageLabel . FILTER(LANG(?languageLabel) = "en") }

Got 13 rows and 2 columns, showing the first 5 and last 5 rows below:
| language                       | languageLabel                |
| ------------------------------ | ---------------------------- |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| English (wd:Q1860)             | English (lang:en)            |
| ...                            | ...                          |
| Auslan (wd:Q29525)             | Auslan (lang:en)             |
| Norfuk (wd:Q33797)             | Norfuk (lang:en)             |
| Norfuk (wd:Q33797)             | Norfuk (lang:en)             |
| Australian English (wd:Q44679) | Australian English (lang:en) |
| Australian English (wd:Q44679) | Australian English (lang:en) |

[Assistant]
Now I have a clear picture. The languages spoken in Australia, as officially recognized at the national or territorial level, are:

### Official Languages:
1. **English** (`wd:Q1860`) — the de facto national language, used in government, education, and media.
2. **Australian English** (`wd:Q44679`) — the distinct variety of English spoken in Australia.
3. **Auslan** (`wd:Q29525`) — the sign language of the Australian Deaf community.
4. **Norfuk** (`wd:Q33797`) — the creole language spoken on Norfolk Island (an external territory of Australia).

### Additional Notes:
- English appears multiple times because multiple states/territories list it as an official language.
- While many other languages are spoken in Australia (e.g., Mandarin, Arabic, Vietnamese, Indigenous languages), they are **not officially recognized** at the national or territorial level, so they do not appear in `wdt:P37`.
- For a complete picture of languages spoken by the population (including non-official ones), we would need data from censuses or surveys, which are not directly encoded in Wikidata as `wdt:P1412` for Australia.

### Final Answer:
People in Australia primarily speak **English** (including Australian English), **Auslan** (sign language), and **Norfuk** (on Norfolk Island). Many other languages are spoken due to immigration and Indigenous communities, but only these are officially recognized.

I will now provide the final SPARQL query and answer.

answer

SELECT ?language ?languageLabel WHERE { { wd:Q408 wdt:P37 ?language . } UNION { ?state wdt:P17 wd:Q408 . ?state wdt:P31 ?type . FILTER(?type IN (wd:Q5852411, wd:Q14192199, wd:Q11687019)) . ?state wdt:P37 ?language . } . ?language rdfs:label ?languageLabel . FILTER(LANG(?languageLabel) = "en") }

Answer: People in Australia primarily speak English (including Australian English), Auslan (the sign language of the Deaf community), and Norfuk (spoken on Norfolk Island). While many other languages are spoken due to immigration and Indigenous communities, these are the only ones officially recognized at the national or territorial level.


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

Using entities:
- Italy (wd:Q38), also known as 🇮🇹, IT, ITA, Italia, Italian Republic, etc.: is instance of sovereign state / is instance of country / country in Europe / country in Southern Europe / republic in Southern Europe

Using properties:
- currency (wd:P38 as wdt), also known as base currency, used money, P38: is subproperty of uses / currency used by item / currency used by item / currency used by item

Got 1 row and 1 column:
| currencyLabel  |
| -------------- |
| euro (lang:en) |

Answer:
The official currency of Italy is the **euro**.

### Final SPARQL Query
The final SPARQL query retrieves the currency of Italy and its English label for clarity:

```sparql
SELECT ?currencyLabel WHERE {
  wd:Q38 wdt:P38 ?currency .
  ?currency rdfs:label ?currencyLabel FILTER(LANG(?currencyLabel) = "en")
}
```

### Answer
The money used in Italy is called the **euro**.

The official currency of Italy is the **euro**.

### Final SPARQL Query
The final SPARQL query retrieves the currency of Italy and its English label for clarity:

```sparql
SELECT ?currencyLabel WHERE {
  wd:Q38 wdt:P38 ?currency .
  ?currency rdfs:label ?currencyLabel FILTER(LANG(?currencyLabel) = "en")
}
```

### Answer
The money used in Italy is called the **euro**.

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?currencyLabel WHERE {
  wd:Q38 wdt:P38 ?currency .
  ?currency rdfs:label ?currencyLabel
  FILTER ( LANG( ?currencyLabel ) = "en" )
}

Using entities:
- Italy (wd:Q38), also known as 🇮🇹, IT, ITA, Italia, Italian Republic, etc.: is instance of sovereign state / is instance of country / country in Europe / country in Southern Europe / republic in Southern Europe

Using properties:
- currency (wd:P38 as wdt), also known as base currency, used money, P38: is subproperty of uses / currency used by item / currency used by item / currency used by item

Execution result:
Got 1 row and 1 column:
| currencyLabel  |
| -------------- |
| euro (lang:en) |

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

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. Search for the 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. Execute intermediate queries to get feedback and to verify your assumptions. You may need to refine or rethink your current plan based on the query results and go back to step 2 if needed, possibly multiple times.
4. Use the answer or cancel function to finalize your answer and stop the generation process.

Available knowledge graphs:
- wikidata at http://localhost:7001 with prefix index for entities and similarity index for properties, and notes:
  - P106 = occupation. Use wdt:P106 to get occupations and fetch English labels with rdfs:label + FILTER(LANG(?label)="en"). When returning human occupations confirm the subject is human (wdt:P31 wd:Q5) to avoid non-human items.
  - Population (P1082) and tabular (P4179): use wdt:P1082 for quick/direct values; for time-series/point-in-time use p:P1082 + ps:P1082 + pq:P585 and ORDER BY pq:P585 DESC. Inspect statement qualifiers (e.g., 'applies to part') and prov:wasDerivedFrom references (pr:P854 etc.) to detect city-proper vs metro/prefecture scopes before using values.
  - Common person properties: P31 (instance of human Q5), P106 (occupation), P569 (date of birth), P19 (place of birth), P27 (country of citizenship), P21 (sex/gender), P166 (award received). Use wdt: for direct values when possible.
  - P17 (country) can be incomplete/misleading for places (historical/overseas tags). To get modern cities in a country combine: instance-of city (P31=Q515) + wdt:P17 OR use wdt:P131* to find an admin parent whose wdt:P17 = the country. Also cross-check coordinates (P625) or admin hierarchy to spot outliers.
  - When filtering by date of birth (P569) use xsd:dateTime comparisons (e.g. >= "1900-01-01T00:00:00Z"^^xsd:dateTime). Be aware many items have year-only or imprecise dates and coverage is biased toward notable/public figures (sportspeople, politicians, artists).
  - To retrieve qualifiers (e.g., award year) use the statement/qualifier pattern: p:Pxxx / ps:Pxxx / pq:P585. Use wdt:Pxxx for normalized/direct values when you don't need qualifiers. Example: p:P166 + pq:P585 gives award year.
  - To get a person's occupations: use wdt:P106 for direct/normalized values and rdfs:label for human-readable names (FILTER(LANG(...))). Example: wd:Q... wdt:P106 ?occ . ?occ rdfs:label ?occLabel . FILTER(LANG(?occLabel)="en").
  - P166 = award received. Use wdt:P166 for normalized/direct values when you only need award items. To get award years or qualifiers use p:P166 / ps:P166 / pq:P585. Many statements lack pq:P585 — use OPTIONAL { ?stmt pq:P585 ?date } and ORDER BY DESC(?date). When listing award winners, filter ?person wdt:P31 wd:Q5 to ensure humans.
  - Population time-series pattern: wd:Q... p:P1082 ?stmt . ?stmt ps:P1082 ?pop . OPTIONAL { ?stmt pq:P585 ?date } . ORDER BY DESC(?date). pq:P585 is the point-in-time qualifier. IMPORTANT: time-series may mix scopes (city proper vs metro) — e.g., Tokyo has a 2016 entry ~38,140,000 likely metro vs smaller city figures. Inspect qualifiers/references for scope before use.
  - Use wdt:P131* to traverse the admin hierarchy and compare wdt:P17 on the place vs an admin parent to detect historical/colonial country assignments. When mismatches appear, inspect the admin parent's instance-of (P31), labels, qualifiers and references to interpret the historical scope.
  - wdt:P106 often yields multiple occupations for a person. Use GROUP_CONCAT(DISTINCT ?occLabel; separator=", ") or return multiple rows. Always fetch labels with rdfs:label + FILTER(LANG(?label)="en") to get readable occupation names.
  - When a search_entity returns multiple hits (person vs sculpture vs memorial), confirm you selected the human/statements by checking wdt:P31 (instance of) and relevant wdt: properties (e.g., wdt:P106). This avoids using a non-human QID by mistake.
  - search_autocomplete can be constrained with a SPARQL pattern containing ?search (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }). Use constraints to focus results (e.g., humans) and avoid ambiguous fallbacks; if it returns no results, fallback to search_entity and verify wdt:P31.
  - Use search_property_of_entity to find relevant properties for an entity (e.g., 'award' -> P166) and search_object_of_property to discover candidate objects (e.g., 'physicist' for P106). This reduces guessing P/Q ids and surfaces qualifiers.
  - Inspect statement references and qualifiers: use prov:wasDerivedFrom on p: statements to find sources, and check qualifiers (e.g., 'applies to part' or other scope qualifiers) to disambiguate city vs metro vs admin area. Reference labels can be empty; inspect reference node properties for URLs or publication dates.

Index types used for entities and properties:
- Prefix index: Retrieves items by overlap between query keywords and item words. The query keywords can match item words exactly or as prefixes.
- Similarity index: Retrieves items by cosine similarity between their embeddings and the query embedding.

General notes across knowledge graphs:
- Use rdfs:label + FILTER(LANG(?label)="en") for labels; avoid SERVICE wikibase:label. Use wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access statement qualifiers (e.g., award year via pq:P585). When dates matter, prefer xsd:dateTime and watch for year-only precision.
- Practical query patterns: use rdfs:label + FILTER(LANG(...)) for labels. Use wdt:Pxxx for direct/normalized values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (dates via pq:P585). For dates use xsd:dateTime and expect year-only precision. For places: combine P17 with P131 or coordinate (P625) filters to avoid historical/overseas mismatches.
- Use OPTIONAL for pq: qualifiers (e.g., pq:P585), sort by qualifier (ORDER BY pq:P585 DESC) to prefer recent values. Use GROUP_CONCAT to combine multiple labels/values in one row. Watch for typed literals (xsd:dateTime, xsd:decimal) when filtering or sorting.
- Before querying, use search_entity to resolve human-friendly names to wd:Q identifiers and verify instance-of (e.g., check wdt:P31 = wd:Q5 for humans) to avoid ambiguous matches. Prefer the top match but programmatically confirm P31 before using its data.
- Use search_property to confirm property identifiers (e.g., "country" -> P17) before embedding them in queries. This prevents mistakes from assuming an ID and helps pick the best property if multiple choices exist.
- search_autocomplete can fall back to an unconstrained search or error when there are too many candidates. If this happens (e.g., "more than the maximum supported number of subject candidates"), retry with narrower constraints such as instance-of (wdt:P31), additional type filters, or short prefixes to reduce the candidate set; otherwise fallback to search_entity and verify wdt:P31.
- Use list(...) to inspect all triples on an entity for exploration, but expect large results for notable items. Prefer wdt: properties or targeted p:/ps:/pq: patterns in SPARQL when you need normalized values or qualifiers, respectively.
- Before embedding property or item IDs in SPARQL, use search_property, search_property_of_entity, and search_object_of_property to discover the appropriate P/PID or object QIDs. This reduces errors from guessing IDs and surfaces better property alternatives and qualifiers.
- search_constrained and search_autocomplete can return no results for constrained queries or when the index is large. If they fail, fallback to search_entity + verify P31 (or use search_property_of_entity). Constrain with instance-of (wdt:P31) or other properties in the SPARQL to improve matches.
- When selecting awards by year, prefer xsd:dateTime range filters (e.g., >= "2001-01-01T00:00:00Z"^^xsd:dateTime && < "2002-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for portability and precision.
- When selecting award winners via wdt:P166, filter ?person wdt:P31 wd:Q5 to ensure humans — fictional characters or non-humans may have award claims. If you need award years use p:P166 / ps:P166 / pq:P585 and OPTIONAL { ?stmt pq:P585 ?year } to retrieve qualifier years.
- Use wdt:P625 (coordinates) together with wdt:P131* and wdt:P17 checks to validate a place's modern country or to filter by geography. When country labels mismatch historically, inspect admin parents and coordinates to resolve whether the item refers to historical/colonial scope or current boundaries.
- Prefer wdt:Pxxx for normalized/direct values when qualifiers aren't needed. Use p:Pxxx / ps:Pxxx / pq:Pxxx to access qualifiers (e.g., pq:P585 for award year). Always fetch labels with rdfs:label + FILTER(LANG(?label) = "en").
- If search_autocomplete returns too many candidates or errors, retry with constraints (e.g., SELECT * WHERE { ?search wdt:P31 wd:Q5 }) or narrower query text. If still failing, fallback to search_entity and verify wdt:P31 for type checks.
- For award-year queries use p:P166 / ps:P166 / pq:P585 to access award statements and year qualifiers. Filter by xsd:dateTime ranges (e.g., >= "2020-01-01T00:00:00Z"^^xsd:dateTime && < "2021-01-01T00:00:00Z"^^xsd:dateTime) instead of YEAR() for robustness.
- Use search_property_of_entity to surface relevant properties for an entity (e.g., 'birth' -> P569/P19). list(...) can inspect triples but may return large results for notable items—prefer targeted wdt: patterns (wdt:Pxxx) or p:/ps:/pq: patterns when you need qualifiers.

SPARQL prefixes for use in function calls:
- bd: <http://www.bigdata.com/rdf#
- cc: <http://creativecommons.org/ns#
- data: <https://www.wikidata.org/wiki/Special:EntityData/
- dc: <http://purl.org/dc/elements/1.1/
- dct: <http://purl.org/dc/terms/
- foaf: <http://xmlns.com/foaf/0.1/
- geo: <http://www.opengis.net/ont/geosparql#
- geof: <http://www.opengis.net/def/function/geosparql/
- gn: <http://www.geonames.org/ontology#
- hint: <http://www.bigdata.com/queryHints#
- 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/
- qb: <http://purl.org/linked-data/cube#
- qfn: <http://qlever.cs.uni-freiburg.de/function#
- ql: <http://qlever.cs.uni-freiburg.de/builtin-functions/
- qlss: <https://qlever.cs.uni-freiburg.de/spatialSearch/
- 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/
- void: <http://rdfs.org/ns/void#
- 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#

Additional rules to follow:
- Explain your thought process before and after each step and function call.
- Do not just use or make up entity or property identifiers without verifying their existence in the knowledge graphs first.
- Do not ask the user for clarifications without first attempting to complete the task. If the task input is incomplete or ambiguous, try to make reasonable assumptions and document them.
- 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.
- Always execute your final SPARQL query before giving an answer to make sure it returns the expected results.
- 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.
- 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.
- 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.
- For questions with a "True" or "False" answer the SPARQL query should be an ASK query.

[User] what is money called in italy?

[Assistant]
To determine what money is called in Italy, I need to find the official currency used in Italy. This information is typically stored in Wikidata with properties such as "currency" (P38) associated with the country Italy (Q38).

### Step 1: Identify the entity for Italy
I will first search for the entity representing Italy in Wikidata.

Question: Italy

Top 10 entity alternatives:
1. Italy (wd:Q38), also known as 🇮🇹, IT, ITA, Italia, Italian Republic, etc.: is instance of sovereign state / republic in Southern Europe / country in Southern Europe / is instance of country / country in Europe
2. Italian Peninsula (wd:Q145694, matched via Italy), also known as Apennine Peninsula, Italic Peninsula, Italy, lo Stivale, península Itálica, etc.: peninsula of southern Europe / is instance of peninsula
3. Kingdom of Italy (wd:Q172579, matched via Italy), also known as IT, Italy, Regno d’Italia: kingdom in Southern Europe from 1861 to 1946 / is instance of historical country
4. Kingdom of Italy (wd:Q223936, matched via Italy), also known as Italian Kingdom, Italy, Napoleonic Kingdom of Italy, Regno d'Italia, Royaume d’Italie: kingdom in southern Europe between 1805 and 1814 / is instance of historical country
5. Kingdom of Italy (wd:Q838931, matched via Italy), also known as Italian Kingdom, Italy, Regnum Italiae, Regnum Italicorum, Regnum Italicum: (817–1014) constituent kingdom of the Holy Roman Empire / is instance of state in the Holy Roman Empire / is instance of historical country
6. Italy (wd:Q977238), also known as Italy, Texas, Italy, TX: town in Ellis County, Texas, United States / is instance of town in the United States / town in Texas
7. Italy (wd:Q3708720), also known as Italy, NY: is instance of town in the United States / is instance of town of New York / town in New York
8. Kingdom of Italy (wd:Q5343710, matched via Italy), also known as Italian Kingdom, Italy, Regno d'Italia, Regnum Italicum: kingdom in Southern Europe between 781 and 962 / is instance of historical country / is instance of realm
9. Pessione (wd:Q2028109, matched via Italy), also known as Italy: human settlement in Chieri, Metropolitan City of Turin, Piedmont, Italy / is instance of neighbourhood / is instance of frazione
10. Monastero di Mirteto (wd:Q3858945, matched via Italy), also known as Italy: human settlement in San Giuliano Terme, Province of Pisa, Tuscany, Italy / is instance of locality

[Assistant]
The primary entity for Italy is **wd:Q38**, which represents the modern sovereign state of Italy. I will now find the currency used in Italy by checking the property "currency" (P38) associated with this entity.

### Step 2: Retrieve the currency of Italy
I will query Wikidata to find the currency used in Italy using the property `wdt:P38` (currency).

execute

SELECT ?currency WHERE { wd:Q38 wdt:P38 ?currency }

[Assistant]
The currency used in Italy is the **euro**, represented by the Wikidata entity `wd:Q4916`.

To confirm, I will retrieve the label for this currency in English to ensure clarity.

### Step 3: Get the English label for the currency
I will now fetch the English label for the currency entity `wd:Q4916`.

SELECT ?currencyLabel WHERE { wd:Q4916 rdfs:label ?currencyLabel FILTER(LANG(?currencyLabel) = "en") }

Got 1 row and 1 column:
| currencyLabel  |
| -------------- |
| euro (lang:en) |

[Assistant]
The official currency of Italy is the **euro**.

### Final SPARQL Query
The final SPARQL query retrieves the currency of Italy and its English label for clarity:

```sparql
SELECT ?currencyLabel WHERE {
  wd:Q38 wdt:P38 ?currency .
  ?currency rdfs:label ?currencyLabel FILTER(LANG(?currencyLabel) = "en")
}
```

### Answer
The money used in Italy is called the **euro**.