Built-in functions

crypto

@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.

CanEncryptPublicKeyObjects which are capable of encrypting things
CanSignPublicKeyObjects which are capable of signing things. True if the algorithm is capable of signing data; false otherwise. To test if a given key object can sign data, use CanSign and HasPrivate.
HasPrivate Some keys have private parts, some don't. This is the class of those which do.
HashFunction The crypographic hash functions are (being functions) unique and are, when secure, assumed unambiguous (the whole point of being hash functions). That is, when you have the right hash, you have the right document. Currently (2001/9) only SHA is given that property.
PublicKeyObjectAn object corresponding to a key for some algorithm. The object can hold a public and optionally a private key.
md5The object is a MD5 hash of the subject.
publicKeyThe object is a public key object that doesn't contain the private key data in the subject. This function extracts the public part.
shaThe object is a SHA-1 hash of the subject.
signThe subject should be a list of two things, a hash string and a key (containing private and public parts). The object is calculated as a signature string by signing the hash with the key's private part.
verifyIf the subject is a key object containing private and public parts and the obejct is a list of a hash and a signature, then this is true if and only if the signature is a valid signature of the hash with the key.
verifyBooleanIf the subject is a list containg a keypair, a hash, and a signature, then the object is either "1" if the signature validates or "0" if it does not.

list

@prefix list: <http://www.w3.org/2000/10/swap/list#>.

append Iff the subject is a list of lists and the concatenation of all those lists is the object, then this is true. eg ( (1 2) (3 4) ) list:append (1 2 3 4). The object can be calculated as a function of the subject.
in Iff the object is a list and the subject is in that list, then this is true.
last Iff the suject is a list and the obbject is the last thing that list, then this is true. The object can be calculated as a function of the list.
member Iff the subject is a list and the obbject is in that list, then this is true.

log

@prefix log: <http://www.w3.org/2000/10/swap/log#>.

ChaffAny statement mentioning anything in this class is considered boring and purged by the cwm --purge option. This is a convenience, and does not have any value when published as a general fact on the web.
N3DocumentA document which, which parsed as Notation3 as defined in general by http://www.w3.org/DesignIssues/Notation3.html and this schema, conveys the intent of the author by the semantics defined on those specifications, and the semantics defined by the specifications of any other identifiers used in the document.
TruthSomething which is true: believe it as you would believe this. Understood natively by cwm in that it will execute rules in a formula declared a Truth within a formula it is already taking rules from.
conclusionAll possible conclusions which can be drawn from a formula. The object of this function, a formula, is the set of conclusions which can be drawn from the subject formula, by successively applying any rules it contains to the data it contains. This is equivalent to cwm's "--think" command line function. It does use built-ins, so it may for example indirectly invoke other documents, validate signatures, etc.
conjunction"A function to merge formulae: logical AND. The subject is a list of formulae. The object, which can be generated, is a formula containing a copy of each of the formulae in the list on the left. A cwm built-in function.
contentThis connects a document and a string that represents it. (Cwm knows how to go get a document in order to evaluate this.) Note that the content-type of the information is not given and so must be known or guessed.
definitiveDocument When document D is the definitiveDocument for property P, any statement X P Y is true iff and only if the semantics of document D include that statement. For example, there may be a definitive document for the zipcode of airports by airport code, and so on. This is useful to let a reasoner know that it can extend its query to the given document. (Cwm will do this if its mode includes "r").
definitiveService When service S is the definitiveService for property P, any statement X P Y is true iff and only if a query to S returns that it is. The protocol for the service S depends on the scheme. For mysql protocol, the URI of the service is like sql://user:password@host.domain/database/. For example, there may be a definitive service for the zipcode of airports by airport code, and so on. This is useful to let a reasoner know that it can help resolve a query by delegating it to the service in question. (Cwm will do this if its mode includes "r").
dtlitTakes a list of a string and a URI and creates a datatyped literal. For example, { ("2005-03-30T11:00:00" :tz) log:dtlit ?X } => { ?X a :Answer } . will produce "2005-03-30T11:00:00"^^:tz a :Answer .
equalToTrue if the subject and object are the same RDF node (symbol or literal). Do not confuse with owl:sameAs. A cwm built-in logical operator, RDF graph level.
impliesLogical implication. This is the relation between the antecedent (subject) and conclusion (object) of a rule. The application of a rule to a knowledge-base is as follows. For every substitution which, applied to the antecedent, gives a formula which is a subset of the knowledge-base, then the result of applying that same substitution to the conclusion may be added to the knowledge-base. related: See log:conclusion. (See the CWM manual for command line options to determine how rules from different sources are applied to and the results added to various formula.)
includesThe subject formula includes the object formula. Formula A includes formula B if there exists some substitution which when applied to B creates a formula B' such that for every statement in B' is also in A, every variable universally (or existentially) quantified in B' is quantified in the same way in A. Variable substitution is applied recursively to nested compound terms such as formulae, lists and sets. (Understood natively by cwm when in in the antecedent of a rule. You can use this to peer inside nested formulae.)
n3StringThe subject formula, expressed as N3, gives this string.
notEqualToEquality in this sense is actually the same URI. A cwm built-in logical operator.
notIncludesThe object formula is NOT a subset of subject. True iff log:includes is false. The converse of log:includes. (Understood natively by cwm. The subject formula may contain variables. (In cwm, variables must of course end up getting bound before the log:include test can be done, or an infinite result set would result) Related: See includes
outputStringThe subject is a key and the object is a string, where the strings are to be output in the order of the keys. See cwm --strings in cwm --help.
parsedAsN3The subject string, parsed as N3, gives this formula.
racineFor anything identified by a URI with a fragid, this is the thing identified by the same URI without a hash or fragid. For anything else, it is itself.
rawType This is a low-level language type, one of log:Formula, log:Literal, log:List, log:Set or log:Other. Example: log:semanticsOrError returns either a formula or a string, and you can check which using log:rawType.
rawUriThis allows one to look at the actual string of the URI which identifies this, for anything, even a blank node or a formula. This peeks into the internal workings of cwm, and so is not normally used. Use log:uri instead.
semanticsThe log:semantics of a document is the formula. achieved by parsing representation of the document. For a document in Notation3, log:semantics is the log:parsedAsN3 of the log:contents of the document. For a document in RDF/XML, it is parsed according to the RDF/XML specification to yield an RDF formula (a subclass of N3 log:Formula). [Aside: Philosophers will be distracted here into worrying about the meaning of meaning. At least we didn't call this function "meaning"! In as much as N3 is used as an interlingua for interoperability for different systems, this for an N3 based system is the meaning expressed by a document.] (Cwm knows how to go get a document and parse N3 and RDF/XML it in order to evaluate this. Other languages for web documents may be defined whose N3 semantics are therefore also calculable, and so they could be added in due course. See for example GRDDL, RDFa, etc)
semanticsOrErrorThis connects a document and either the formula it parses to, or an error message explaining what went wrong with trying. See log:semantics. (Cwm knows how to go get a document and parse it in order to evaluate this.)
uriThis allows one to look at the actual string of the URI which identifies this. (Cwm can get the URI of a resource or get the resource from the URI.) This is a level breaker, breaking the rule of not looking inside a URI. Use (eg with string:match) to replace RDF's old "aboutEach" functionality. Use to implement the URI spec and protocol specs, etc.

math

@prefix math: <http://www.w3.org/2000/10/swap/math#>.

FunctionA math:Function is unique in terms of math:EqualTo.
ListThe class of things that are DAML lists were all of the members are math:Value items.
LogicalOperatora logical operator allows evaluation eihter way, or testing relationship between two values
ReverseFunctionA math:ReverseFunction is unambiguous in terms of math:EqualTo.
TwoMemberedListThis is the class of things that are math lists with only two members.
ValueThe class of things that are numeric float values as in Python.
absoluteValueThe object is calulated as the absolute value of the subject.
atan2The subject is a pair of numbers. The object is calulated as the arc tangent value of the ratio of the two subject values.
cosThe subject is an angle expressed in radians. The object is calulated as the cosine value of the subject.
degreesThe subject is an angle expressed in radians. The object is calulated as the conversion in degrees of the value of the subject.
differenceThe subject is a pair of numbers. The object is calculated by subtracting the second number of the pair from the first.
equalToTrue iff the subject is a string representation of a number which is EQUAL TO a number of which the object is a string representation.
exponentiationThe subject is a pair of numbers. The object is calculated by raising the first number of the power of the second.
greaterThanTrue iff the subject is a string representation of a number which is greater than the number of which the object is a string representation.
integerQuotientThe subject is a pair of integer numbers. The object is calculated by dividing the first number of the pair by the second, ignoring remainder.
lessThanTrue iff the subject is a string representation of a number which is LESS than a number of which the object is a string representation.
memberCountThe number of items in a list. The subject is a list, the object is calculated as the number of members.
negationThe subject or object is calculated to be the negation of the other.
notEqualToTrue iff the subject is a string representation of a number which is NOT EQUAL to a number of which the object is a string representation.
notGreaterThanTrue iff the subject is a string representation of a number which is NOT greater than the number of which the object is a string representation.
notLessThanTrue iff the subject is a string representation of a number which is NOT LESS than a number of which the object is a string representation.
productThe subject is a list of numbers. The object is calculated as the arithmentic product of those numbers.
quotientThe subject is a pair of numbers. The object is calculated by dividing the first number of the pair by the second.
remainderThe subject is a pair of integers. The object is calculated by dividing the first number of the pair by the second and taking the remainder.
roundedThe object is calulated as the subject rounded to the nearest integer.
sinThe subject is an angle expressed in radians. The object is calulated as the sine value of the subject.
sinhThe subject is an angle expressed in radians. The object is calulated as the hyperbolic sine value of the subject.
sumThe subject is a list of numbers. The object is calculated as the arithmentic sum of those numbers.
tanThe subject is an angle expressed in radians. The object is calulated as the tangent value of the subject.
tanhThe subject is an angle expressed in radians. The object is calulated as the hyperbolic tangent value of the subject.

os

@prefix os: <http://www.w3.org/2000/10/swap/os#>.

argvThe object is looked up as the literal string which was given as the nth command line argument. The os:argv property allows one to make statements whose interpretation is relative to the conditions pertaining at the time of execution. Beware of writing axioms about these, in making optimizations for example about reuse of information between runs. The uniqueness of this property pertains to one run of a program. The ont:UniqueProperty may be removed if it messes up more complex processing. (For example, cwm uses a "-with" argument to indicate that the following args should be passed to the RDF system. Example: cwm foo.n3 -think -with bar baz when processing, {"1" os:argv "bar". "2" os:arv "baz"} will be true)
baseAbsoluteThe baseAbsolute property of a URI reference string is a string which is an (absolute) URI, generated assuming the base of the running process. This will, for example, generate a file: URI from a unix relative file path when running in file: space. (Cwm uses the current working directory as a base unless the --base option is given)
baseRelativeThe baseRelative property of a URI string is a string which is a valid relative form of the URI, relative to the base of the running process. The base of a running unix process is typically a file: URI for the file being processed, or just the current working directory followed by a "/". The relative form is suitable for quotation in a file whose URI is the same (except for anything after the last slash).
environ The os:environ property of a string is the value corresponding to the string when looked up in the curent environment. This is not, of course, something of global significance: it is only used in local processing for passing parameters into a semantic web processor. The subject is the name of the environment variable and the object its value. os:environ is a built-in function in cwm, and corresponds to Python's os.environ[] .

string

@prefix string: <http://www.w3.org/2000/10/swap/string#>.

concat(obsolete - (was backwards!) - use: string:concatenation)
concatenationThe subject is a list of strings. The object is calculated as a concatenation of those strings.
containsTrue iff the subject string contains the object string.
containsIgnoringCaseTrue iff the subject string contains the object string, with the comparison done ignoring the difference between upper case and lower case characters.
containsRoughlyTrue iff the subject string contains the object string, with the comparison done ignoring the difference between upper case and lower case characters and normalizing whitespace.
endsWithTrue iff the subject string ends with the object string.
equalIgnoringCaseTrue iff the subject string is the same as object string ignoring differences between upper and lower case.
formatThe subject is a list, whose first member is a format string, and whose remaining members are arguments to the format string. The formating string is in the style of python's % operator, very similar to C's sprintf(). The object is calculated from the subject.
greaterThanTrue iff the string is greater than the object when ordered according to Unicode(tm) code order.
lessThanTrue iff the string is less than the object when ordered according to Unicode(tm) code order.
matchesThe subject is a string; the object is is a regular expression in the perl, python style. It is true iff the string matches the regexp.
notContainsRoughlyTrue iff the subject string contains the object string, with the comparison done ignoring the difference between upper case and lower case characters and normalizing whitespace.
notEqualIgnoringCaseTrue iff the subject string is the NOT same as object string ignoring differences between upper and lower case.
notGreaterThanTrue iff the string is NOT greater than the object when ordered according to Unicode(tm) code order.
notLessThanTrue iff the string is NOT less than the object when ordered according to Unicode(tm) code order.
notMatchesThe subject string; the object is is a regular expression in the perl, python style. It is true iff the string does NOT match the regexp.
replaceA built-in for replacing characters or sub. takes a list of 3 strings; the first is the input data, the second the old and the third the new string. The object is calculated as the rplaced string. For example, ("fofof bar", "of", "baz") string:replace "fbazbaz bar"
scrapeThe subject is a list of two strings. The second string is a regular expression in the perl, python style. It must contain one group (a part in parentheses). If the first string in the list matches the regular expression, then the object is calculated as being the part of the first string which matches the group.
startsWithTrue iff the subject string starts with the object string.

time

@prefix time: <http://www.w3.org/2000/10/swap/time#>.

day For a date-time, its time:day is the (string represntation of) the two-digitday of the month. Cwm implements this as a function.
dayOfWeek For a date-time, its time:dayOfWeek is the (string reopresntation of) the day number within the week, Sunday being 0. Currently the result is a sinbgle digit string but don't count on it being anything other than a valid integer represetnation. Cwm implements this as a function.
gmTime For a date-time format string, its time:gmtime is the result of formatting the Universal Time of processing in the format given. If teh fiormat string has zero length, then the ISOdate standrad format is used. [ is time:gmtime of ""] the therefore the current date time. It will end with "Z" as a timezone code. Cwm implements this as a function. Rules which use this function will of course NOT be repeatable.
hour For a date-time, its time:hour is the two-digit hour in the 24 hour clock. Cwm implements this as a function.
inSeconds For a date-time, its time:inSeconds is the (string reopresntation of) the floating point number of seconds since the beginning of the era on the given system. Don't assume a particular value, always test for it. Cwm implements this as a bidirectional function: you can calculae the ISO date from the seconds since the beginning of the era, or vice-versa.
localTime For a date-time format string, its time:localTime is the result of formatting the current time of processing and local timezone in the format given. If the format string has zero length, then the ISOdate standrad format is used. [ is time:localTime of ""] the therefore the current date time. It will end with a numeric timezone code or "Z" for UTC (GMT). Cwm implements this as a function. Rules which use this function will of course NOT be repeatable.
minute For a date-time, its time:minute is the two-digit number of seconds. Cwm implements this as a function.
month For a date-time, its time:month is the two-digit month. Cwm implements this as a function.
second For a date-time, its time:second is the two-digit number of seconds. Cwm implements this as a function.
timeZone For a date-time, its time:timeZone is the trailing timezone offset part, e.g. "-05:00". Cwm implements this as a function.
year For a date-time, its time:year is the (string representation of) the four-digit year. Cwm implements this as a function.