Skip to content

Instantly share code, notes, and snippets.

@wolfmcnally
Last active April 24, 2024 20:12
Show Gist options
  • Save wolfmcnally/9703faec5ea3f1a6a131fd4839acfd50 to your computer and use it in GitHub Desktop.
Save wolfmcnally/9703faec5ea3f1a6a131fd4839acfd50 to your computer and use it in GitHub Desktop.
Gordian Envelope Notation LLM Training Prompt
Here is the general format for "Envelope Notation":
```envelope
<subject> [
<predicate1>: <object1>
<predicate2>: <object2>
]
```
A subject with no assertions is:
```envelope
<subject>
```
An assertion is:
```envelope
<predicate>: <object>
```
Any of the elements in angle brackets above can be:
- In double quotes, a UTF-8 string:
- "Alice"
- In single quotes, a "known value" (a symbolic value):
- 'isA'
- In no quotes, a CBOR structure:
- PublicKeyBase
- An ISO-8601 date or time:
- 2020-01-01
- 2020-01-01T00:00:00Z
- A CBOR item in diagnostic notation:
- [1, 2, 3]
- {"a": 1, "b": 2, "c": 3}
- 1234("Tagged Value")
- h'010203ff'
Any of the elements can have additional assertions.
- Assertions on the envelope (the envelope is "wrapped" so assertions can be added on it as a whole):
```envelope
{
<subject> [
<predicate1>: <object1>
<predicate2>: <object2>
]
} [
<predicate3>: <object3>
<predicate4>: <object4>
]
```
- Assertions on assertions (the assertion is "wrapped"):
```envelope
<subject> [
<predicate1>: <object1>
{
<predicate2>: <object2>
} [
<predicate3>: <object3>
<predicate4>: <object4>
]
]
```
- Assertions on a predicate:
```envelope
<subject> [
<predicate1>: <object1>
<predicate2> [
<predicate3>: <object3>
<predicate4>: <object4>
]: <object2>
]
```
- Assertions on an object:
```envelope
<subject> [
<predicate1>: <object1>
<predicate2>: <object2> [
<predicate3>: <object3>
<predicate4>: <object4>
]
]
```
"Jane knows John" is:
```envelope
"Jane" [
'knows': "John"
]
```
That same envelope wrapped and signed:
```envelope
{
"Jane" [
'knows': "John"
]
} [
'verifiedBy': Signature
]
```
Sample RDF triples (informal):
```
<Bob> <is a> <person>.
<Bob> <is a friend of> <Alice>.
<Bob> <is born on> <the 4th of July 1990>.
<Bob> <is interested in> <the Mona Lisa>.
<the Mona Lisa> <was created by> <Leonardo da Vinci>.
<the video 'La Joconde à Washington'> <is about> <the Mona Lisa>
```
Translated to Envelope Notation, where each subject is a separate envelope:
```envelope
"Bob" [
'isA': "person"
'friendOf': "Alice"
'born': 1990-07-04
'interestedIn': "the Mona Lisa"
]
```
```envelope
"the Mona Lisa" [
'isA': "painting"
'createdBy': "Leonardo da Vinci"
]
```
```envelope
"La Joconde à Washington" [
'isA': "video"
'subject': "the Mona Lisa"
]
```
The above three envelopes combined in a single envelope:
```envelope
"Facts about Bob" [
'fact': "Bob" [
'isA': "person"
'friendOf': "Alice"
'born': 1990-07-04
'interestedIn': "the Mona Lisa"
]
'fact': "the Mona Lisa" [
'isA': "painting"
'createdBy': "Leonardo da Vinci"
]
'fact': "La Joconde à Washington" [
'isA': "video"
'subject': "the Mona Lisa"
]
]
A JSON-LD example:
```json
{
"@context": "example-context.json",
"@id": "http://example.org/bob#me",
"@type": "Person",
"birthdate": "1990-07-04",
"knows": "http://example.org/alice#me",
"interest": {
"@id": "http://www.wikidata.org/entity/Q12418",
"title": "Mona Lisa",
"subject_of": "http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619",
"creator": "http://dbpedia.org/resource/Leonardo_da_Vinci"
}
}
```
Converted to Envelope Notation:
```envelope
"http://example.org/bob#me" [
'isA': "Person"
'birthdate': 1990-07-04
'knows': "http://example.org/alice#me"
'interest': "http://www.wikidata.org/entity/Q12418" [
'title': "Mona Lisa"
'subjectOf': "http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619" [
'isA': "video"
'title': "La Joconde à Washington"
]
'createdBy': "http://dbpedia.org/resource/Leonardo_da_Vinci"
]
]
```
RDF Turtle:
```turtle
@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dbo: <http://dbpedia.org/ontology/> .
ex:TheBeatles
a dbo:MusicalGroup ;
foaf:name "The Beatles" ;
dbo:genre ex:RockMusic ;
dbo:formationDate "1960" ;
dbo:member ex:JohnLennon, ex:PaulMcCartney, ex:GeorgeHarrison, ex:RingoStarr ;
dbo:album ex:AbbeyRoad, ex:Revolver .
ex:JohnLennon
a foaf:Person ;
foaf:name "John Lennon" .
ex:PaulMcCartney
a foaf:Person ;
foaf:name "Paul McCartney" .
ex:GeorgeHarrison
a foaf:Person ;
foaf:name "George Harrison" .
ex:RingoStarr
a foaf:Person ;
foaf:name "Ringo Starr" .
ex:RockMusic
a dbo:Genre ;
foaf:name "Rock" .
ex:AbbeyRoad
a dbo:Album ;
foaf:name "Abbey Road" ;
dbo:releaseDate "1969-09-26" ;
dbo:track ex:ComeTogether, ex:Something, ex:HereComesTheSun .
ex:Revolver
a dbo:Album ;
foaf:name "Revolver" ;
dbo:releaseDate "1966-08-05" ;
dbo:track ex:EleanorRigby, ex:YellowSubmarine .
ex:ComeTogether
a dbo:MusicalWork ;
foaf:name "Come Together" .
ex:Something
a dbo:MusicalWork ;
foaf:name "Something" .
ex:HereComesTheSun
a dbo:MusicalWork ;
foaf:name "Here Comes the Sun" .
ex:EleanorRigby
a dbo:MusicalWork ;
foaf:name "Eleanor Rigby" .
ex:YellowSubmarine
a dbo:MusicalWork ;
foaf:name "Yellow Submarine" .
```
Converted to Envelope Notation:
```envelope
"ex:TheBeatles" [
'isA': "MusicalGroup"
'name': "The Beatles"
'genre': "ex:RockMusic"
'formationDate': 1960
'member': "ex:JohnLennon" [
'isA': "Person"
'name': "John Lennon"
]
'member': "ex:PaulMcCartney" [
'isA': "Person"
'name': "Paul McCartney"
]
'member': "ex:GeorgeHarrison" [
'isA': "Person"
'name': "George Harrison"
]
'member': "ex:RingoStarr" [
'isA': "Person"
'name': "Ringo Starr"
]
'album': "ex:AbbeyRoad" [
'isA': "Album"
'name': "Abbey Road"
'releaseDate': 1969-09-26
'track': "ex:ComeTogether" [
'isA': "MusicalWork"
'name': "Come Together"
]
'track': "ex:Something" [
'isA': "MusicalWork"
'name': "Something"
]
'track': "ex:HereComesTheSun" [
'isA': "MusicalWork"
'name': "Here Comes the Sun"
]
]
'album': "ex:Revolver" [
'isA': "Album"
'name': "Revolver"
'releaseDate': 1966-08-05
'track': "ex:EleanorRigby" [
'isA': "MusicalWork"
'name': "Eleanor Rigby"
]
'track': "ex:YellowSubmarine" [
'isA': "MusicalWork"
'name': "Yellow Submarine"
]
]
]
```
Here is an example in N-Triples:
```
<http://dbpedia.org/resource/Bob_Marley> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
<http://dbpedia.org/resource/Bob_Marley> <http://www.w3.org/2000/01/rdf-schema#label> "Bob Marley"@en .
<http://dbpedia.org/resource/Bob_Marley> <http://www.w3.org/2000/01/rdf-schema#label> "Bob Marley"@fr .
<http://dbpedia.org/resource/Bob_Marley> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://dbpedia.org/resource/Rastafari> .
<http://dbpedia.org/resource/Bob_Marley> <http://dbpedia.org/ontology/birthPlace> <http://dbpedia.org/resource/Jamaica> .
<http://dbpedia.org/resource/Jamaica> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Country> .
<http://dbpedia.org/resource/Jamaica> <http://www.w3.org/2000/01/rdf-schema#label> "Jamaica"@en .
<http://dbpedia.org/resource/Jamaica> <http://www.w3.org/2000/01/rdf-schema#label> "Giamaica"@it .
<http://dbpedia.org/resource/Jamaica> <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "17.9833"^^<http://www.w3.org/2001/XMLSchema#float> .
<http://dbpedia.org/resource/Jamaica> <http://www.w3.org/2003/01/geo/wgs84_pos#long> "-76.8"^^<http://www.w3.org/2001/XMLSchema#float> .
<http://dbpedia.org/resource/Jamaica> <http://xmlns.com/foaf/0.1/homepage> <http://jis.gov.jm/> .
```
Converted to Envelope Notation:
```envelope
"http://dbpedia.org/resource/Bob_Marley" [
'isA': "http://xmlns.com/foaf/0.1/Person"
'label': "Bob Marley" [
'language': "en"
]
'label': "Bob Marley" [
'language': "fr"
]
'seeAlso': "http://dbpedia.org/resource/Rastafari"
'birthPlace': "http://dbpedia.org/resource/Jamaica" [
'isA': "http://schema.org/Country"
'label': "Jamaica" [
'language': "en"
]
'label': "Giamaica" [
'language': "it"
]
'latLong': [17.9833, -76.8]
'homepage': "http://jis.gov.jm/"
]
]
```
Here is a RDF schema:
```turtle
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@base <http://example.org/schemas/vehicles>
:MotorVehicle a rdfs:Class.
:PassengerVehicle a rdfs:Class;
rdfs:subClassOf :MotorVehicle.
:Truck a rdfs:Class;
rdfs:subClassOf :MotorVehicle.
:Van a rdfs:Class;
rdfs:subClassOf :MotorVehicle.
:MiniVan a rdfs:Class;
rdfs:subClassOf :Van.
rdfs:subClassOf :PassengerVehicle;
:Person a rdfs:Class.
xsd:integer a rdfs:Datatype.
:registeredTo a rdf:Property;
rdfs:domain :MotorVehicle;
rdfs:range :Person.
:rearSeatLegRoom a rdf:Property;
rdfs:domain rdf:resource :MotorVehicle;
rdfs:range xsd:integer.
:driver a rdf:Property;
rdfs:domain :MotorVehicle.
:primaryDriver a rdf:Property;
rdfs:subPropertyOf :driver.
```
Converted to Envelope Notation:
```envelope
"http://example.org/schemas/vehicles" [
'isA': "Schema"
'class': "MotorVehicle" [
'isA': "rdfs:Class"
]
'class': "PassengerVehicle" [
'isA': "rdfs:Class"
'subClassOf': "MotorVehicle"
]
'class': "Truck" [
'isA': "rdfs:Class"
'subClassOf': "MotorVehicle"
]
'class': "Van" [
'isA': "rdfs:Class"
'subClassOf': "MotorVehicle"
]
'class': "MiniVan" [
'isA': "rdfs:Class"
'subClassOf': "Van"
'subClassOf': "PassengerVehicle"
]
'class': "Person" [
'isA': "rdfs:Class"
]
'datatype': "xsd:integer" [
'isA': "rdfs:Datatype"
]
'property': "registeredTo" [
'isA': "rdf:Property"
'domain': "MotorVehicle"
'range': "Person"
]
'property': "rearSeatLegRoom" [
'isA': "rdf:Property"
'domain': "MotorVehicle"
'range': "xsd:integer"
]
'property': "driver" [
'isA': "rdf:Property"
'domain': "MotorVehicle"
]
'property': "primaryDriver" [
'isA': "rdf:Property"
'subPropertyOf': "driver"
]
]
```
Now when you are asked to convert knowledge to Envelope Notation, you know how to do it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment