Why are URIs sometimes treated as literals in RDF?

The RDF data model distinguishes URIs and literals. When URIs appear in RDF syntaxes, they are marked up as URIs. For example, a triple with three URIs:

<http://richard.cyganiak.de/#me>
    <http://xmlns.com/foaf/0.1/homepage>
        <http://richard.cyganiak.de/> .

But sometimes, URIs appear as literals. This is often by mistake, but sometimes intentional. For example, vann:preferredNamespaceUri from the VANN vocabulary is supposed to be used like this:

<http://purl.org/vocab/vann/>
    <http://purl.org/vocab/vann/preferredNamespaceUri>
        "http://purl.org/vocab/vann/" .

I'm struggling to come up with a good explanation for this when teaching RDF or providing feedback to publishers. After all, if it's syntactically a URI, and the language provides a construct for URIs, then why not use the URI construct?

So my question is, can someone articulate a clear and simple rule for when URIs should be treated as literals in RDF? Something that's reasonably intuitive to developers and data modelers without deep knowledge of model theory and web architecture? Something short and sweet?

You use the literal (preferably of type xsd:anyURI) to talk about the URI, and you use the URI to talk about the thing denoted by it. For example, in the following statement:

<http://zimmer.aprilfoolsreview.com/antoine#me> <http://ex.org/hasURI> "http://zimmer.aprilfoolsreview.com/antoine#me"^^xsd:anyURI .

the subject is me (a human being), who is not composed of hashes and slashes, while the object is the URI that denotes me, which does not have eyes, arms and brain. I cannot replace one by the other because one is identifying me while the other is identifying a sequence of characters.

I chose to model that property with a Literal because I felt that it was a declaration of a literal string rather than a resource, i.e. this is the actual string you need to use as a namespace prefix. A secondary reason was that I wanted to insulate it from any potential inference rules such as owl:sameAs.

For the particular property you cite, there is another interesting reason that this is not a URI. In RDF/XML the namespace string does not have to be a complete URI. For example:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
               xmlns:ex1="http://example.com/schema#"
               xmlns:ex2="http://example.com/schema#ed"
               xmlns:ex3="http://example."
               xmlns:ex4="http://"
        >
  <rdf:Description rdf:about="http://example.com/foo">
    <ex1:editor>Foo1</ex1:editor>
    <ex2:itor>Foo2</ex2:itor>
    <ex3:com>Foo3</ex3:com>
    <ex4:example.com>Foo4</ex4:example.com>
  </rdf:Description>
</rdf:RDF>

Produces

<http://example.com/foo> <http://example.com/schema#editor> "Foo1" .
<http://example.com/foo> <http://example.com/schema#editor> "Foo2" .
<http://example.com/foo> <http://example.com> "Foo3" .
<http://example.com/foo> <http://example.com> "Foo4" .

Simply put to distinguish between the use of the URI as an identifier for something and the URI as a literal value.

In some cases this might make things more readable:

e.g.

<ex:subject> <ex:predicate> <http://example.org/my%20URI%20with%20escapes%20in%20it> .

<ex:subject> <ex:predicate> "http://example.org/my URI with escapes in it" .

Though realistically most people aren't using nasty looking URIs like this.

A better example is actually your second snippet above. The URI is a URI for the subject since it is used to identify the Vocabulary but as a Literal for the object since it is expressing a literal value.

More generally speaking you it should be used as a URI if you intend the data to point to that URI/use it as an identifier and as a literal if you are just mentioning the value.

Expanding upon Ian's comment on OWL inferencing, imagine a vocabulary that has a purl.org URI that redirects to a URI at example.net. It seems fair to say:

<http://purl.org/NET/myvocab#> owl:sameAs <http://example.net/rdf/myvocab#> .

The vocab might contain this data:

<http://purl.org/NET/myvocab#> vann:preferredNamespacePrefix "mine" ;
        vann:preferredNamespacePrefix <http://purl.org/NET/myvocab#> .
                                      # ^^^ note a resource, not a literal

Then an OWL-capable tool will be able to conclude the following:

<http://purl.org/NET/myvocab#> vann:preferredNamespacePrefix <http://example.net/rdf/myvocab#> .

Which is false and could cause problems further down the line if people start believing it.

<http://tobyinkster.co.uk/#i> and "http://tobyinkster.co.uk/#i"^^xsd:anyURI are simply different things. The first one is a person, and the second is a URI. The second one, as literarymachine put it, has letters in it; the first one only has letters in it after I've been eating alphabet soup.

# This is true...
<http://tobyinkster.co.uk/#i> owl:sameAs <http://identi.ca/user/36737> .

# This is false, though not expressable in RDF anyway...
"http://tobyinkster.co.uk/#i" owl:sameAs "http://identi.ca/user/36737" .