PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?work ?workLabel ?lang WHERE {
  ?work wdt:P31 wd:Q5185279 .
  ?work wdt:P6216 wd:Q19652 .
  OPTIONAL {
    ?work wdt:P407 ?lang .
  }
  FILTER ( ! BOUND( ?lang ) || ?lang = wd:Q1860 ) FILTER NOT EXISTS {
    ?work wdt:P51 ?audio
  }
  OPTIONAL {
    ?work rdfs:label ?workLabel .
    FILTER ( LANG( ?workLabel ) = "en" )
  }
}
LIMIT 200

Using entities:
- English (wd:Q1860), also known as English (language), English language, English-language, English the Global Language, The English language: is instance of modern language / is instance of standard language / is instance of language / is instance of natural language / is instance of macrolanguage / is instance of literary language / is subclass of Anglic / West Germanic language / West Germanic language of Indo-European family / West Germanic language originating in England
- public domain (wd:Q19652), also known as 🅮, DP, out of copyright, PD: is instance of legal concept / is instance of copyright status / is subclass of public good / no exclusive intellectual property rights apply / no exclusive intellectual property rights apply
- poem (wd:Q5185279), also known as poems, poetry: is instance of literary form / is instance of poetic form / is subclass of poetry / is subclass of Poetry / is subclass of literary work / form of literature, work of poetry, often composed of verses

Using properties:
- 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
- language of work or name (wd:P407 as wdt), 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)
- audio (wd:P51 as wdt), also known as audio file, audio recording, audio sample, recording, song, etc.: relevant sound / relevant sound / relevant sound. If available, use a more specific property. Samples: "spoken text audio" (P989), "pronunciation audio" (P443)
- copyright status (wd:P6216 as wdt), also known as copyrighted, copyright restriction, P6216: copyright status for intellectual creations like works of art, publications, software, etc.

Got 200 rows and 3 columns, showing the first 5 and last 5 rows below:
| work                                                   | workLabel                                         | lang               |
| ------------------------------------------------------ | ------------------------------------------------- | ------------------ |
| Death’s Ramble (wd:Q100774453)                         | Death’s Ramble (lang:en)                          | English (wd:Q1860) |
| Gerontion (wd:Q10289249)                               | Gerontion (lang:en)                               | English (wd:Q1860) |
| Endimion & Phœbe (wd:Q104450438)                       | Endimion & Phœbe (lang:en)                        | English (wd:Q1860) |
| Junior Yell (wd:Q104451306)                            | Junior Yell (lang:en)                             | English (wd:Q1860) |
| Philadelphia Rosary (wd:Q104591336)                    | Philadelphia Rosary (lang:en)                     | English (wd:Q1860) |
| ...                                                    | ...                                               | ...                |
| 'Tis easier to pity those when dead (wd:Q18910189)     | 'Tis easier to pity those when dead (lang:en)     | English (wd:Q1860) |
| 'Tis good — the looking back on Grief — (wd:Q18910190) | 'Tis good — the looking back on Grief — (lang:en) | English (wd:Q1860) |
| 'Tis little I — could care for Pearls — (wd:Q18910191) | 'Tis little I — could care for Pearls — (lang:en) | English (wd:Q1860) |
| 'Tis my first night beneath the Sun (wd:Q18910192)     | 'Tis my first night beneath the Sun (lang:en)     | English (wd:Q1860) |
| 'Tis not that Dying hurts us so — (wd:Q18910193)       | 'Tis not that Dying hurts us so — (lang:en)       | English (wd:Q1860) |

Answer:
I ran the query above on Wikidata. It returned 200 poems that match: instance of "poem", copyright status = public domain, language either English or not specified, and with no audio file (P51). I limited the query to 200 results; if you want the complete (unlimited) list or an exported CSV with all matches and labels, tell me and I will retrieve it. Sample matches returned include:
- wd:Q100774453 (Death’s Ramble)
- wd:Q10289249 (Gerontion)
- wd:Q104450438 (Endimion & Phœbe)
- wd:Q104451306 (Junior Yell)
- wd:Q104591336 (Philadelphia Rosary)

Do you want the full list, or additional filters (e.g., only English-language works, or include audio links if present)?

I ran the query above on Wikidata. It returned 200 poems that match: instance of "poem", copyright status = public domain, language either English or not specified, and with no audio file (P51). I limited the query to 200 results; if you want the complete (unlimited) list or an exported CSV with all matches and labels, tell me and I will retrieve it. Sample matches returned include:
- wd:Q100774453 (Death’s Ramble)
- wd:Q10289249 (Gerontion)
- wd:Q104450438 (Endimion & Phœbe)
- wd:Q104451306 (Junior Yell)
- wd:Q104591336 (Philadelphia Rosary)

Do you want the full list, or additional filters (e.g., only English-language works, or include audio links if present)?

SPARQL query over wikidata:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?work ?workLabel ?lang WHERE {
  ?work wdt:P31 wd:Q5185279 .
  ?work wdt:P6216 wd:Q19652 .
  OPTIONAL {
    ?work wdt:P407 ?lang .
  }
  FILTER ( ! BOUND( ?lang ) || ?lang = wd:Q1860 ) FILTER NOT EXISTS {
    ?work wdt:P51 ?audio
  }
  OPTIONAL {
    ?work rdfs:label ?workLabel .
    FILTER ( LANG( ?workLabel ) = "en" )
  }
}
LIMIT 200

Using entities:
- English (wd:Q1860), also known as English (language), English language, English-language, English the Global Language, The English language: is instance of modern language / is instance of standard language / is instance of language / is instance of natural language / is instance of macrolanguage / is instance of literary language / is subclass of Anglic / West Germanic language / West Germanic language of Indo-European family / West Germanic language originating in England
- public domain (wd:Q19652), also known as 🅮, DP, out of copyright, PD: is instance of legal concept / is instance of copyright status / is subclass of public good / no exclusive intellectual property rights apply / no exclusive intellectual property rights apply
- poem (wd:Q5185279), also known as poems, poetry: is instance of literary form / is instance of poetic form / is subclass of poetry / is subclass of Poetry / is subclass of literary work / form of literature, work of poetry, often composed of verses

Using properties:
- 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
- language of work or name (wd:P407 as wdt), 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)
- audio (wd:P51 as wdt), also known as audio file, audio recording, audio sample, recording, song, etc.: relevant sound / relevant sound / relevant sound. If available, use a more specific property. Samples: "spoken text audio" (P989), "pronunciation audio" (P443)
- copyright status (wd:P6216 as wdt), also known as copyrighted, copyright restriction, P6216: copyright status for intellectual creations like works of art, publications, software, etc.

Execution result:
Got 200 rows and 3 columns, showing the first 5 and last 5 rows below:
| work                                                   | workLabel                                         | lang               |
| ------------------------------------------------------ | ------------------------------------------------- | ------------------ |
| Death’s Ramble (wd:Q100774453)                         | Death’s Ramble (lang:en)                          | English (wd:Q1860) |
| Gerontion (wd:Q10289249)                               | Gerontion (lang:en)                               | English (wd:Q1860) |
| Endimion & Phœbe (wd:Q104450438)                       | Endimion & Phœbe (lang:en)                        | English (wd:Q1860) |
| Junior Yell (wd:Q104451306)                            | Junior Yell (lang:en)                             | English (wd:Q1860) |
| Philadelphia Rosary (wd:Q104591336)                    | Philadelphia Rosary (lang:en)                     | English (wd:Q1860) |
| ...                                                    | ...                                               | ...                |
| 'Tis easier to pity those when dead (wd:Q18910189)     | 'Tis easier to pity those when dead (lang:en)     | English (wd:Q1860) |
| 'Tis good — the looking back on Grief — (wd:Q18910190) | 'Tis good — the looking back on Grief — (lang:en) | English (wd:Q1860) |
| 'Tis little I — could care for Pearls — (wd:Q18910191) | 'Tis little I — could care for Pearls — (lang:en) | English (wd:Q1860) |
| 'Tis my first night beneath the Sun (wd:Q18910192)     | 'Tis my first night beneath the Sun (lang:en)     | English (wd:Q1860) |
| 'Tis not that Dying hurts us so — (wd:Q18910193)       | 'Tis not that Dying hurts us so — (lang:en)       | English (wd:Q1860) |

[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] Which poems are in the public domain, either in English or with no specified language, and do not have an audio recording?

[Assistant]
Step 1: I'll search for the Wikidata item for "poem" (the class) and relevant properties like language, copyright status, and audio recordings. I'll start by finding the entity for "poem".

Question: poem

Top 10 entity alternatives:
1. poem (wd:Q5185279), also known as poems, poetry: form of literature, work of poetry, often composed of verses / is instance of literary form / is subclass of literary work / is instance of poetic form / is subclass of poetry / is subclass of Poetry
2. long poem (wd:Q1782649, matched via poem), also known as poem: is instance of poetry genre / is instance of poetic form / poetry genre, poetic form / is subclass of poem
3. NPNT (wd:Q18053814, matched via POEM), also known as EGFL6L, nephronectin, POEM: protein-coding gene in the species Homo sapiens / is subclass of protein-coding gene / is instance of gene
4. The Sorrow of the Winds (wd:Q19099527, matched via Poem), also known as Poem: 1912
5. The Summer Moon (wd:Q19100286, matched via Poem), also known as Poem: is instance of version, edition or translation / 1912
6. The Morning Pool (wd:Q19094277, matched via Poem), also known as Poem: is instance of version, edition or translation / 1912
7. The Maze of Sleep (wd:Q19093692, matched via Poem), also known as Poem: is instance of version, edition or translation / 1912
8. poem (wd:Q19415001): poem written by Mostafa Saadeq Al-Rafe'ie / is instance of poem
9. Poem (wd:Q19423189), also known as Poetry: Poem written by Abdullah ibn al-Mu'tazz / Poetry by Abdullah ibn al-Mu'tazz / is instance of poem
10. Poem (wd:Q2893205): 1981 album by Bridges / is instance of album

[Assistant]
I'll search for properties related to language, copyright status (public domain), and audio recordings. First I'll look for properties for language of work and copyright status.

Question: language of work

Top 10 property alternatives:
1. language of work or name (wd:P407 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language of work), 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)
2. language used (wd:P2936 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via working 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
3. writing language (wd:P6886 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language of works), 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
4. programmed in (wd:P277 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language), also known as language, programming language, written in, P277: the programming language(s) in which the software is developed
5. languages spoken, written or signed (wd:P1412 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language), 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)
6. Ethnologue language status (wd:P3823 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, 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. Wikimedia language code (wd:P424 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language code), also known as language code, MediaWiki interlanguage prefix, Wikibase monolingual text language code, WMF language code, P424: identifier for a language or variant as used by Wikimedia projects / identifier for a language or variant as used by Wikimedia projects / identifier for a language or variant as used by Wikimedia projects
8. IETF language tag (wd:P305 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language code), also known as BCP 47 language code, ISO language code IETF implementation, language code, language tag IETF, P305: identifier for language or languoid per the Internet ... Format: 2 or 3 letters, followed by "-" if subtags present
9. original language of film or TV show (wd:P364 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via language of the original work), 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. exemplar of (wd:P1574 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via includes work), also known as contains work, contents, includes work, P1574: Links an individual copy of a work to the item for that work or edition / is subproperty of instance of

[Assistant]
I'll search for properties related to copyright status (e.g., "copyright status", "public domain").

Question: copyright status

Top 10 property alternatives:
1. copyright status (wd:P6216 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as copyrighted, copyright restriction, P6216: copyright status for intellectual creations like works of art, publications, software, etc.
2. copyright status as a creator (wd:P7763 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via copyright status of works), also known as copyright status as creator, copyright status of creator's works, copyright status of works, statut des droits d'auteur du createur, P7763: states if the body of work published during the lifetime of this creator is still copyrighted or in the public domain
3. copyright registration (wd:P9976 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as USA copyright registration, US copyright registration, P9976: ID assigned by the US copyright office recording the ... for a creative work, or the renewal of such a copyright
4. copyright license (wd:P275 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as content licence, content license, copyright licence, licence, license, etc.: licence under which this copyrighted work is released / licence under which this copyrighted work is released / license under which this copyrighted work is released
5. copyright holder (wd:P3931 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via copyright ‘owner’), also known as copyright ‘owner’, copyright owner, licensor, proprietor, P3931: person or organisation who holds the copyright of a work according to the Berne Convention / is subproperty of owned by
6. copyright exemption (wd:P7152 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as P7152: copyright exemption this file is covered by
7. phonographic copyright (wd:P12456 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as ℗, (P), P12456: person or organization that holds the phonographic copyright
8. public domain date (wd:P3893 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via copyright end date), also known as copyright end date, PD date, P3893: date the item enters into the public domain in a jurisdiction
9. digital rights management system (wd:P1032 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via copy protection system), also known as copy protection mechanism, copy protection system, DRM mechanism, DRM system, P1032: technologies  to control the use of digital content and devices after sale
10. RightsStatements.org statement according to source website (wd:P6426 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via rights), also known as rights, rights statement, RS, standardized rights statement, P6426: standardized RightsStatements.org rights statement that owning institution or similar authority has applied to this work

[Assistant]
I'll search for the object/entity representing "public domain" to match copyright status = public domain.

Question: public domain

Top 10 entity alternatives:
1. public domain (wd:Q19652), also known as 🅮, DP, out of copyright, PD: no exclusive intellectual property rights apply / no exclusive intellectual property rights apply / is instance of copyright status / is instance of legal concept / is subclass of public good
2. public sphere (wd:Q17945, matched via public domain), also known as public domain, publicity, public life: is subclass of social life / area in social life
3. public domain (wd:Q5871222): lands considered to belong to the whole community / is subclass of estate / is subclass of Estate
4. Public Domain (wd:Q7758689): is instance of online magazine / online magazine
5. Public Domain (wd:Q20813938): 2000 album by Dave Alvin / is instance of album / album by Dave Alvin / album by Dave Alvin
6. The Public Domain (wd:Q19824841, matched via Public Domain), also known as Public Domain: is instance of film / 2015 film
7. Public Domain (wd:Q20200052): is instance of musical group / British band
8. Public Domain (wd:Q7257358): 2003 Canadian film about reality TV directed by Kris Lefcoe / is instance of film
9. public domain (wd:Q15687061): duplicate of Q19652 used to test workaround for QuickStatements limitations / is instance of Wikimedia permanent duplicated page / is instance of Wikimedia permanent duplicate item / is instance of copyright status / is subclass of public good / is subclass of licence / is subclass of license
10. DP (wd:Q59754537, matched via public domain), also known as 00039657154 IPI, 00108158979 IPI, 00506142687 IPI, 00506142981 IPI, 00538373139 IPI, etc.: special purpose artist used for songwriting credits in the public domain / is instance of special purpose artist / has occupation composer / has occupation lyricist / has occupation Lyricist

[Assistant]
I'll search for properties that indicate the presence of audio recordings or sound files for a work (e.g., audio, audio file, sound recording).

Question: audio recording

Top 10 property alternatives:
1. audio (wd:P51 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via audio recording), also known as audio file, audio recording, audio sample, recording, song, etc.: relevant sound. If available, use a more specific property. Samples: "spoken text audio" (P989), "pronunciation audio" (P443) / relevant sound / relevant sound
2. recordist (wd:P10893 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via audio recorder), also known as audio recorder, audio recordist, recorded by, video recorder, video recordist, etc.: the person or other agent who recorded the audio and/or video for this file
3. featured track(s) (wd:P10664 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via audio track), also known as audio track, audio tracks, featured track, music track, music tracks, etc.: soundtrack of this audiovisual work
4. audio recording of the subject's spoken voice (wd:P990 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via voice recording), also known as audio clip, recording of the subject's spoken voice, speaking voice, spoken voice, voice recording, etc.: audio file representing the speaking voice of a person; or of an animated cartoon or other fictitious character / is subproperty of audio
5. recording or performance of (wd:P2550 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via recording of), also known as performance of, performance or recording of, recording of, P2550: item is a recording or release of this composition
6. recorded at studio or venue (wd:P483 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via recording studio), also known as recorded at event, recording studio, recording venue, studio, venue, etc.: studio or location where a musical composition/release was recorded / is subproperty of recording location
7. captured with (wd:P4082 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via recording device), also known as camera model, camera used, equipment used, filmed with, image captured with, etc.: equipment (e.g. model of camera, lens, microphone), used to capture this image, video, audio, or data
8. audio transcription (wd:P9533 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as transcription of audio, P9533: transcription of the word/text being spoken in this file
9. performer (wd:P175 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via recording by), also known as actor, actress, artist, dancer, musical artist, etc.: actor, musician, band or other performer associated with this role or musical work / actor, musician, music group or other performer associated with this work / is subproperty of contributor to the creative work or subject
10. produced sound (wd:P4733 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via sound produced), also known as call, makes call, makes sound, sound, sound emitted, etc.: item for the sound generated by the subject, for instance the cry of an animal

[Assistant]
I'll execute a SPARQL SELECT query that finds items which are instance of "poem" (wd:Q5185279), have copyright status "public domain" (wd:Q19652), have either English as language (wd:P407 wd:Q1860) or no specified language (no P407), and do not have an audio file (no P51). The query will return the work IRIs and optional English labels. I'll run it now.

execute

SELECT ?work ?workLabel ?lang WHERE {
  ?work wdt:P31 wd:Q5185279 .               # instance of poem
  ?work wdt:P6216 wd:Q19652 .               # copyright status = public domain
  OPTIONAL { ?work wdt:P407 ?lang. }       # optional language of work
  FILTER ( !BOUND(?lang) || ?lang = wd:Q1860 )  # either no language specified or English
  FILTER NOT EXISTS { ?work wdt:P51 ?audio }    # no audio file
  OPTIONAL { ?work rdfs:label ?workLabel . FILTER(LANG(?workLabel) = "en") }
}
LIMIT 200

Got 200 rows and 3 columns, showing the first 5 and last 5 rows below:
| work                                                   | workLabel                                         | lang               |
| ------------------------------------------------------ | ------------------------------------------------- | ------------------ |
| Death’s Ramble (wd:Q100774453)                         | Death’s Ramble (lang:en)                          | English (wd:Q1860) |
| Gerontion (wd:Q10289249)                               | Gerontion (lang:en)                               | English (wd:Q1860) |
| Endimion & Phœbe (wd:Q104450438)                       | Endimion & Phœbe (lang:en)                        | English (wd:Q1860) |
| Junior Yell (wd:Q104451306)                            | Junior Yell (lang:en)                             | English (wd:Q1860) |
| Philadelphia Rosary (wd:Q104591336)                    | Philadelphia Rosary (lang:en)                     | English (wd:Q1860) |
| ...                                                    | ...                                               | ...                |
| 'Tis easier to pity those when dead (wd:Q18910189)     | 'Tis easier to pity those when dead (lang:en)     | English (wd:Q1860) |
| 'Tis good — the looking back on Grief — (wd:Q18910190) | 'Tis good — the looking back on Grief — (lang:en) | English (wd:Q1860) |
| 'Tis little I — could care for Pearls — (wd:Q18910191) | 'Tis little I — could care for Pearls — (lang:en) | English (wd:Q1860) |
| 'Tis my first night beneath the Sun (wd:Q18910192)     | 'Tis my first night beneath the Sun (lang:en)     | English (wd:Q1860) |
| 'Tis not that Dying hurts us so — (wd:Q18910193)       | 'Tis not that Dying hurts us so — (lang:en)       | English (wd:Q1860) |

[Assistant]
I'll now provide the final SPARQL query and a summary of the results I obtained (I ran the query above and it returned 200 matching poems; the query below is the one I ran).

answer

SELECT ?work ?workLabel ?lang WHERE {
  ?work wdt:P31 wd:Q5185279 .               # instance of poem
  ?work wdt:P6216 wd:Q19652 .               # copyright status = public domain
  OPTIONAL { ?work wdt:P407 ?lang. }       # optional language of work
  FILTER ( !BOUND(?lang) || ?lang = wd:Q1860 )  # either no language specified or English
  FILTER NOT EXISTS { ?work wdt:P51 ?audio }    # no audio file
  OPTIONAL { ?work rdfs:label ?workLabel . FILTER(LANG(?workLabel) = "en") }
}
LIMIT 200

Answer:
I ran the query above on Wikidata. It returned 200 poems that match: instance of "poem", copyright status = public domain, language either English or not specified, and with no audio file (P51). I limited the query to 200 results; if you want the complete (unlimited) list or an exported CSV with all matches and labels, tell me and I will retrieve it. Sample matches returned include:
- wd:Q100774453 (Death’s Ramble)
- wd:Q10289249 (Gerontion)
- wd:Q104450438 (Endimion & Phœbe)
- wd:Q104451306 (Junior Yell)
- wd:Q104591336 (Philadelphia Rosary)

Do you want the full list, or additional filters (e.g., only English-language works, or include audio links if present)?


PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?country ?countryLabel ?capital ?capitalLabel WHERE {
  ?country wdt:P31 wd:Q3624078 .
  ?country p:P36 ?capStmt .
  ?capStmt ps:P36 ?capital .
  FILTER NOT EXISTS {
    ?capStmt pq:P582 ?end .
  }
  OPTIONAL {
    ?country rdfs:label ?countryLabel .
    FILTER ( LANG( ?countryLabel ) = "en" )
  }
  OPTIONAL {
    ?capital rdfs:label ?capitalLabel .
    FILTER ( LANG( ?capitalLabel ) = "en" )
  }
}
ORDER BY ?countryLabel

Using entities:
- sovereign state (wd:Q3624078), also known as country, nation, sovereign country, sovereign nation, Westphalian state: is subclass of country / is subclass of state / political organisation with a centralised independent government / political organisation with a centralised independent government / state that has the highest authority over a territory

Using properties:
- 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
- capital (wd:P36 as p/ps), also known as administrative capital, administrative center, administrative centre, administrative headquarters, administrative seat, etc.: city of governmental seat of the country, state or administrative subdivision / location (city, municipality) of governmental seat of the country, or administrative territorial entity / seat of government of a country, province, state or other type of administrative territorial entity
- end time (wd:P582 as pq), also known as abolished, cease date, cease operation, cease time, closed, etc.: is subproperty of point in time / indicates the time an item ceases to exist or a statement stops being valid / indicates the time an item ceases to exist or a statement stops being valid / moment when an entity ceases to exist and a statement stops being entirely valid or no longer be true

Got 210 rows and 4 columns, showing the first 5 and last 5 rows below:
| country               | countryLabel          | capital                     | capitalLabel               |
| --------------------- | --------------------- | --------------------------- | -------------------------- |
| Afghanistan (wd:Q889) | Afghanistan (lang:en) | Kabul (wd:Q5838)            | Kabul (lang:en)            |
| Albania (wd:Q222)     | Albania (lang:en)     | Tirana (wd:Q19689)          | Tirana (lang:en)           |
| Algeria (wd:Q262)     | Algeria (lang:en)     | Algiers (wd:Q3561)          | Algiers (lang:en)          |
| Andorra (wd:Q228)     | Andorra (lang:en)     | Andorra la Vella (wd:Q1863) | Andorra la Vella (lang:en) |
| Angola (wd:Q916)      | Angola (lang:en)      | Luanda (wd:Q3897)           | Luanda (lang:en)           |
| ...                   | ...                   | ...                         | ...                        |
| Vietnam (wd:Q881)     | Vietnam (lang:en)     | Hanoi (wd:Q1858)            | Hanoi (lang:en)            |
| Yemen (wd:Q805)       | Yemen (lang:en)       | Sanaa (wd:Q2471)            | Sanaa (lang:en)            |
| Yemen (wd:Q805)       | Yemen (lang:en)       | Aden (wd:Q131694)           | Aden (lang:en)             |
| Zambia (wd:Q953)      | Zambia (lang:en)      | Lusaka (wd:Q3881)           | Lusaka (lang:en)           |
| Zimbabwe (wd:Q954)    | Zimbabwe (lang:en)    | Harare (wd:Q3921)           | Harare (lang:en)           |

Answer: I executed the SPARQL query above. It returns country and capital IRIs plus English labels for items that are instance of "sovereign state" (wd:Q3624078), selecting capitals from the p:P36 / ps:P36 statements and excluding any capital statements that have an end date qualifier (pq:P582). The query returned 210 rows. Notes/caveats: (1) Some sovereign states have multiple current capitals (e.g., administrative vs legislative) and will appear on multiple rows. (2) This uses instance-of = sovereign state as the criterion for inclusion; if you want to include items classified differently (e.g., instance of country wd:Q6256) we can expand the criterion. (3) Capitals are included only if the specific capital statement lacks an end-date qualifier; historical capitals with end dates are excluded by design.

I executed the SPARQL query above. It returns country and capital IRIs plus English labels for items that are instance of "sovereign state" (wd:Q3624078), selecting capitals from the p:P36 / ps:P36 statements and excluding any capital statements that have an end date qualifier (pq:P582). The query returned 210 rows. Notes/caveats: (1) Some sovereign states have multiple current capitals (e.g., administrative vs legislative) and will appear on multiple rows. (2) This uses instance-of = sovereign state as the criterion for inclusion; if you want to include items classified differently (e.g., instance of country wd:Q6256) we can expand the criterion. (3) Capitals are included only if the specific capital statement lacks an end-date qualifier; historical capitals with end dates are excluded by design.

SPARQL query over wikidata:
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?country ?countryLabel ?capital ?capitalLabel WHERE {
  ?country wdt:P31 wd:Q3624078 .
  ?country p:P36 ?capStmt .
  ?capStmt ps:P36 ?capital .
  FILTER NOT EXISTS {
    ?capStmt pq:P582 ?end .
  }
  OPTIONAL {
    ?country rdfs:label ?countryLabel .
    FILTER ( LANG( ?countryLabel ) = "en" )
  }
  OPTIONAL {
    ?capital rdfs:label ?capitalLabel .
    FILTER ( LANG( ?capitalLabel ) = "en" )
  }
}
ORDER BY ?countryLabel

Using entities:
- sovereign state (wd:Q3624078), also known as country, nation, sovereign country, sovereign nation, Westphalian state: is subclass of country / is subclass of state / political organisation with a centralised independent government / political organisation with a centralised independent government / state that has the highest authority over a territory

Using properties:
- 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
- capital (wd:P36 as p/ps), also known as administrative capital, administrative center, administrative centre, administrative headquarters, administrative seat, etc.: city of governmental seat of the country, state or administrative subdivision / location (city, municipality) of governmental seat of the country, or administrative territorial entity / seat of government of a country, province, state or other type of administrative territorial entity
- end time (wd:P582 as pq), also known as abolished, cease date, cease operation, cease time, closed, etc.: is subproperty of point in time / indicates the time an item ceases to exist or a statement stops being valid / indicates the time an item ceases to exist or a statement stops being valid / moment when an entity ceases to exist and a statement stops being entirely valid or no longer be true

Execution result:
Got 210 rows and 4 columns, showing the first 5 and last 5 rows below:
| country               | countryLabel          | capital                     | capitalLabel               |
| --------------------- | --------------------- | --------------------------- | -------------------------- |
| Afghanistan (wd:Q889) | Afghanistan (lang:en) | Kabul (wd:Q5838)            | Kabul (lang:en)            |
| Albania (wd:Q222)     | Albania (lang:en)     | Tirana (wd:Q19689)          | Tirana (lang:en)           |
| Algeria (wd:Q262)     | Algeria (lang:en)     | Algiers (wd:Q3561)          | Algiers (lang:en)          |
| Andorra (wd:Q228)     | Andorra (lang:en)     | Andorra la Vella (wd:Q1863) | Andorra la Vella (lang:en) |
| Angola (wd:Q916)      | Angola (lang:en)      | Luanda (wd:Q3897)           | Luanda (lang:en)           |
| ...                   | ...                   | ...                         | ...                        |
| Vietnam (wd:Q881)     | Vietnam (lang:en)     | Hanoi (wd:Q1858)            | Hanoi (lang:en)            |
| Yemen (wd:Q805)       | Yemen (lang:en)       | Sanaa (wd:Q2471)            | Sanaa (lang:en)            |
| Yemen (wd:Q805)       | Yemen (lang:en)       | Aden (wd:Q131694)           | Aden (lang:en)             |
| Zambia (wd:Q953)      | Zambia (lang:en)      | Lusaka (wd:Q3881)           | Lusaka (lang:en)           |
| Zimbabwe (wd:Q954)    | Zimbabwe (lang:en)    | Harare (wd:Q3921)           | Harare (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 are the countries and their capitals for all sovereign states, excluding those where the capital has an end date? Please include the labels for both the countries and their capitals and order by country label.

[Assistant]
Step 1: I'll search for the Wikidata item for "sovereign state" to get its Q-id and confirm how to identify sovereign states. I'll also search for the property for "capital" to confirm the property id. I'll run two searches: one for the entity "sovereign state" and one for the property "capital". Then I'll inspect results and proceed.

Question: sovereign state

Top 10 entity alternatives:
1. sovereign state (wd:Q3624078), also known as country, nation, sovereign country, sovereign nation, Westphalian state: political organisation with a centralised independent government / political organisation with a centralised independent government / state that has the highest authority over a territory / is subclass of country / is subclass of state
2. Westphalian sovereignty (wd:Q442402, matched via state sovereignty), also known as state sovereignty, Westphalian system: concept of the sovereignty of nation-states in Europe / is subclass of world order / is instance of model
3. state sovereignty (wd:Q56350990), also known as national sovereignty
4. The Sovereign State (wd:Q7765603): is instance of literary work / book by Anthony Sampson
5. State Sovereignty Day (wd:Q130322685): Day commemorated in honor of the restoration of the ... Republic of Azerbaijan following the Anti-Terror Operation / is instance of holiday
6. Sovereign State of Forvik (wd:Q2011058): micronation founded on Forewick Holm in 2008 by Stuart Hill / is instance of micronation
7. Indonesian Sovereign State Party (wd:Q106361064), also known as Pandai Party: political party in Indonesia
8. Act on the national emblems of the state of Baden-Württemberg (wd:Q123225392, matched via State Sovereign Signs Act), also known as Land Sovereignty Signs Act, State Sovereign Signs Act: German state law on the design and use of the national emblems of the state of Baden-Württemberg / German state law on the design and use of the national emblems of the state of Baden-Württemberg / is instance of state law
9. New Union Treaty (wd:Q218877, matched via Union of Sovereign States), also known as Union of Sovereign States, Union of Soviet Sovereign Republics: is instance of proposed state merger / is instance of document / is instance of concept / draft treaty of 1991
10. Sovereign State of Aeterna Lucina (wd:Q7571613), also known as Aeterna Lucina: is instance of micronation / Micronation

[Assistant]
I'll search for the property corresponding to "capital" to confirm its property id (likely P36).

Question: capital

Top 10 property alternatives:
1. capital of (wd:P1376 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via capital), also known as administrative seat of, capital, county seat for, county seat of, is capital of, etc.: country, state, department, canton or other administrative division of which the municipality is the governmental seat / country, state, department, canton or other administrative division of which the municipality is the governmental seat / country, state, department, canton or other administrative division of which the municipality is the governmental seat / is subproperty of located in the administrative territorial entity
2. capital (wd:P36 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as administrative capital, administrative center, administrative centre, administrative headquarters, administrative seat, etc.: location (city, municipality) of governmental seat of the country, or administrative territorial entity / seat of government of a country, province, state or other type of administrative territorial entity / city of governmental seat of the country, state or administrative subdivision
3. net worth (wd:P2218 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via wealth), also known as declared patrimony, estimated net worth, net wealth, net worth estimate, personal assets, etc.: totality of wealth possessed by a person
4. prize money (wd:P2121 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via money), also known as money, purse, value, P2121: amount in a specific currency / amount in a specific currency
5. currency (wd:P38 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as base currency, used money, P38: is subproperty of uses / currency used by item / currency used by item / currency used by item
6. field of work (wd:P101 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via trade), also known as academic area, academic discipline, academic subject, activity, activity domain, etc.: specialisation of a person or organisation; see P106 for the occupation / specialization of a person or organization; see P106 for the occupation / specialization of a person or organization; see P106 for the occupation / specialization of a person or organization; see P106 for the occupation / is subproperty of interested in
7. industry (wd:P452 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via sector), also known as branch, economic branch, field of action, field of exercise, sector, etc.: specific industry of company or organization / is subproperty of part of
8. total equity (wd:P2137 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via equity), also known as equity, shareholder equity, P2137: amount of equity value for an entity
9. capital cost (wd:P2130 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p), also known as budget, cost, unit cost, P2130: amount of money spent on building or producing an object
10. number of matches played/races/starts (wd:P1350 as pq/pqn/prv/ps/psn/pqv/prn/wdt/psv/wdtn/pr/p, matched via caps), also known as appearances, caps, games pitched, games played, gp, etc.: matches or games a player or a team played during an event. ... a player officially appeared in during the whole career. / matches or games a player or a team played during an event. ... a player officially appeared in during the whole career. / by a sports team

[Assistant]
I'll run a SPARQL query that:
- selects items that are instance of "sovereign state" (wd:Q3624078),
- finds their capital statements via p:P36 / ps:P36,
- excludes capital statements that have an end time qualifier (pq:P582),
- returns the country and capital IRIs plus English labels,
- orders results by country label.

I'll execute this query now to verify results.

execute

SELECT ?country ?countryLabel ?capital ?capitalLabel WHERE {
  ?country wdt:P31 wd:Q3624078 .
  ?country p:P36 ?capStmt .
  ?capStmt ps:P36 ?capital .
  FILTER NOT EXISTS { ?capStmt pq:P582 ?end . }
  OPTIONAL { ?country rdfs:label ?countryLabel . FILTER(LANG(?countryLabel) = "en") }
  OPTIONAL { ?capital rdfs:label ?capitalLabel . FILTER(LANG(?capitalLabel) = "en") }
}
ORDER BY ?countryLabel

Got 210 rows and 4 columns, showing the first 5 and last 5 rows below:
| country               | countryLabel          | capital                     | capitalLabel               |
| --------------------- | --------------------- | --------------------------- | -------------------------- |
| Afghanistan (wd:Q889) | Afghanistan (lang:en) | Kabul (wd:Q5838)            | Kabul (lang:en)            |
| Albania (wd:Q222)     | Albania (lang:en)     | Tirana (wd:Q19689)          | Tirana (lang:en)           |
| Algeria (wd:Q262)     | Algeria (lang:en)     | Algiers (wd:Q3561)          | Algiers (lang:en)          |
| Andorra (wd:Q228)     | Andorra (lang:en)     | Andorra la Vella (wd:Q1863) | Andorra la Vella (lang:en) |
| Angola (wd:Q916)      | Angola (lang:en)      | Luanda (wd:Q3897)           | Luanda (lang:en)           |
| ...                   | ...                   | ...                         | ...                        |
| Vietnam (wd:Q881)     | Vietnam (lang:en)     | Hanoi (wd:Q1858)            | Hanoi (lang:en)            |
| Yemen (wd:Q805)       | Yemen (lang:en)       | Sanaa (wd:Q2471)            | Sanaa (lang:en)            |
| Yemen (wd:Q805)       | Yemen (lang:en)       | Aden (wd:Q131694)           | Aden (lang:en)             |
| Zambia (wd:Q953)      | Zambia (lang:en)      | Lusaka (wd:Q3881)           | Lusaka (lang:en)           |
| Zimbabwe (wd:Q954)    | Zimbabwe (lang:en)    | Harare (wd:Q3921)           | Harare (lang:en)           |

[Assistant]
I'll now finalize by returning the final SPARQL query I executed and a short summary of the results (count and any caveats).

answer

SELECT ?country ?countryLabel ?capital ?capitalLabel WHERE {
  ?country wdt:P31 wd:Q3624078 .
  ?country p:P36 ?capStmt .
  ?capStmt ps:P36 ?capital .
  FILTER NOT EXISTS { ?capStmt pq:P582 ?end . }
  OPTIONAL { ?country rdfs:label ?countryLabel . FILTER(LANG(?countryLabel) = "en") }
  OPTIONAL { ?capital rdfs:label ?capitalLabel . FILTER(LANG(?capitalLabel) = "en") }
}
ORDER BY ?countryLabel

Answer: I executed the SPARQL query above. It returns country and capital IRIs plus English labels for items that are instance of "sovereign state" (wd:Q3624078), selecting capitals from the p:P36 / ps:P36 statements and excluding any capital statements that have an end date qualifier (pq:P582). The query returned 210 rows. Notes/caveats: (1) Some sovereign states have multiple current capitals (e.g., administrative vs legislative) and will appear on multiple rows. (2) This uses instance-of = sovereign state as the criterion for inclusion; if you want to include items classified differently (e.g., instance of country wd:Q6256) we can expand the criterion. (3) Capitals are included only if the specific capital statement lacks an end-date qualifier; historical capitals with end dates are excluded by design.