diff --git a/spec/create-markdown.py b/spec/create-markdown.py index 6730a80..2675360 100644 --- a/spec/create-markdown.py +++ b/spec/create-markdown.py @@ -212,7 +212,7 @@ def parse_seeAlso(result): name = builtin_name(result.seeAlso) return f'{name}' -for p in prefixes: +for p in sorted(prefixes): # print(f"processing {p}") md_string += f"## {p} ##" + " {#" + p + "}\n" diff --git a/spec/index.bs b/spec/index.bs index eaca37f..76f9dd0 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -336,9 +336,9 @@ Appends the lists from the subject list into a single list as object. **Schema**
`( $s.i?[*] )+ list:append $o?`
where:
`$s.i`: `rdf:List`
`$o`: `rdf:List`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Is the list (1 2 3 4) equal to appending (1), (2 3) , (4)? +Append (3 4) to the list (1 2).

Formula: ``` @@ -346,22 +346,22 @@ Is the list (1 2 3 4) equal to appending (1), (2 3) , (4)? @prefix : . @prefix list: . -{ ( (1) (2 3) (4) ) list:append (1 2 3 4) . } => { :result :is true . } . +{ ( (1 2) (3 4) ) list:append ?list . } => { :result :is ?list . } . ```

Result: ``` @prefix : . -:result :is true. +:result :is (1 2 3 4). ```

-try in editor 🚀
+try in editor 🚀

-Append (3 4) to the list (1 2). +What do we need to prepend to (3 4) to get (1 2 3 4)?

Formula: ``` @@ -369,14 +369,14 @@ Append (3 4) to the list (1 2). @prefix : . @prefix list: . -{ ( (1 2) (3 4) ) list:append ?list . } => { :result :is ?list . } . +{ ( ?what (3 4) ) list:append (1 2 3 4) . } => { :result :is ?what . } . ```

Result: ``` @prefix : . -:result :is (1 2 3 4). +:result :is (1 2). ```

@@ -405,9 +405,9 @@ What do we need to append to (1 2) to get (1 2 3 4)?
-try in editor 🚀
+try in editor 🚀

-What do we need to prepend to (3 4) to get (1 2 3 4)? +Is the list (1 2 3 4) equal to appending (1), (2 3) , (4)?

Formula: ``` @@ -415,14 +415,14 @@ What do we need to prepend to (3 4) to get (1 2 3 4)? @prefix : . @prefix list: . -{ ( ?what (3 4) ) list:append (1 2 3 4) . } => { :result :is ?what . } . +{ ( (1) (2 3) (4) ) list:append (1 2 3 4) . } => { :result :is true . } . ```

Result: ``` @prefix : . -:result :is (1 2). +:result :is true. ```

@@ -550,9 +550,9 @@ Iterate over the list ("dog" "penguin" "cat").
-try in editor 🚀
+try in editor 🚀

-Is "cat" the third item in the list ("dog" "penguin" "cat")? +What is the index of "cat" in the list ("dog" "penguin" "cat")?

Formula: ``` @@ -563,11 +563,11 @@ Is "cat" the third item in the list ("dog" "penguin" "cat")? :let :param ("dog" "penguin" "cat") . { :let :param ?param . - ?param list:iterate (2 "cat") . + ?param list:iterate (?index "cat") . } => { - :result :is true . + :result :is ?index . } . ``` @@ -575,15 +575,15 @@ Is "cat" the third item in the list ("dog" "penguin" "cat")? ``` @prefix : . -:result :is true . +:result :is 2 . ```

-try in editor 🚀
+try in editor 🚀

-What is the index of "cat" in the list ("dog" "penguin" "cat")? +Is "cat" the third item in the list ("dog" "penguin" "cat")?

Formula: ``` @@ -594,11 +594,11 @@ What is the index of "cat" in the list ("dog" "penguin" "cat")? :let :param ("dog" "penguin" "cat") . { :let :param ?param . - ?param list:iterate (?index "cat") . + ?param list:iterate (2 "cat") . } => { - :result :is ?index . + :result :is true . } . ``` @@ -606,7 +606,7 @@ What is the index of "cat" in the list ("dog" "penguin" "cat")? ``` @prefix : . -:result :is 2 . +:result :is true . ```

@@ -715,9 +715,9 @@ Checks whether the subject list contains the object. **Schema**
`$s+ list:member $o-[*]`
where:
`$s`: `rdf:List`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Is "cat" a member of the list ("dog" "penguin" "cat")? +Determine the members of the list ("dog" "penguin" "cat").

Formula: ``` @@ -725,31 +725,24 @@ Is "cat" a member of the list ("dog" "penguin" "cat")? @prefix : . @prefix list: . -:let :param ("dog" "penguin" "cat") . - -{ - :let :param ?param . - ?param list:member "cat" . -} -=> -{ - :result :is true . -} . +{ ("dog" "penguin" "cat") list:member ?member . } => { :result :is ?member . } . ```

Result: ``` @prefix : . -:result :is true. +:result :is "dog". +:result :is "penguin". +:result :is "cat". ```

-try in editor 🚀
+try in editor 🚀

-Determine the members of the list ("dog" "penguin" "cat"). +Is "cat" a member of the list ("dog" "penguin" "cat")?

Formula: ``` @@ -757,16 +750,23 @@ Determine the members of the list ("dog" "penguin" "cat"). @prefix : . @prefix list: . -{ ("dog" "penguin" "cat") list:member ?member . } => { :result :is ?member . } . +:let :param ("dog" "penguin" "cat") . + +{ + :let :param ?param . + ?param list:member "cat" . +} +=> +{ + :result :is true . +} . ```

Result: ``` @prefix : . -:result :is "dog". -:result :is "penguin". -:result :is "cat". +:result :is true. ```

@@ -915,74 +915,88 @@ Remove "penguin" from the list ("dog" "penguin" "cat" "penguin").
-## time ## {#time} -### time:day ### {#time:day} -Gets as object the integer day component of the subject xsd:dateTime. +## log ## {#log} +### log:collectAllIn ### {#log:collectAllIn} +Collects all values matching a given clause and adds them to a list. -`true` if and only if `$o` is the integer day component of `$s`. +`true` if and only if, for every valid substitution of clause `$s.2`, + i.e., a substitution of variables with terms that generates an instance of `$s.2` that is contained in the scope, + the instance of `$s.1` generated by the same substitution is a member of list `$s.3`. +This applies scoped quantification. -**Schema**
`$s+ time:day $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

+**Schema**
`( $s.1- $s.2+ $s.3- )+ log:collectAllIn $o?`
where:
`$s.2`: `log:Formula`, `$s.3`: `rdf:List`
`$o`: (Scope of the builtin. Leave as a variable to use current N3 document as scope.)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Return the day component of the date "2023-04-01T18:06:04Z" . +Set of basic examples for log:collectAllIn.

Formula: ``` @prefix : . -@prefix xsd: . -@prefix time: . +@prefix log: . +@prefix string: . -:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . +:Let :param "Huey" . +:Let :param "Dewey" . +:Let :param "Louie" . { - :Let :param ?param . - ?param time:day ?result . + ( ?param { :Let :param ?param } ?allParams ) log:collectAllIn _:x . + + # Variable to be collected can also be part of a list or graph term + ( (?param) { :Let :param ?param } ?nestedParams ) log:collectAllIn _:x . + + # Add some extra criteria on variable values to be collected + ( ?param + { + :Let :param ?param . + ?param string:lessThan "Louie" . + } + ?filteredParams ) log:collectAllIn _:x . } -=> -{ - :result :is ?result . +=> +{ + :result1 :is ?allParams . + :result2 :is ?nestedParams . + :result3 :is ?filteredParams . } . - + ```

Result: ``` @prefix : . -:result :is 1. - + +:result1 :is ("Huey" "Dewey" "Louie"). +:result2 :is (("Huey") ("Dewey") ("Louie")). +:result3 :is ("Huey" "Dewey"). + ```

- -### time:minute ### {#time:minute} -Gets as object the integer minutes component of the subject xsd:dateTime. - -`true` if and only if `$o` is the integer minutes component of `$s`. - -**Schema**
`$s+ time:minute $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Return the minute component of the date "2023-04-01T18:06:04Z" . +Example where the list is already given; in that case, the collected list will be compared with the given list.

Formula: ``` @prefix : . -@prefix xsd: . -@prefix time: . +@prefix log: . +@prefix string: . -:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . +:Let :param "Huey" . +:Let :param "Dewey" . +:Let :param "Louie" . { - :Let :param ?param . - ?param time:minute ?result . + ( ?param { :Let :param ?param } ("Huey" "Dewey" "Louie") ) log:collectAllIn _:x . } -=> -{ - :result :is ?result . +=> +{ + :result :is true . } . ``` @@ -990,39 +1004,43 @@ Return the minute component of the date "2023-04-01T18:06:04Z" . ``` @prefix : . -:result :is 6. - + +:result :is true . + ```

-### time:month ### {#time:month} -Gets as object the integer month component of the subject xsd:dateTime. +### log:conclusion ### {#log:conclusion} +Gets all possible conclusions from the subject graph term, including rule inferences (deductive closure), as the object graph term. -`true` if and only if `$o` is the integer month component of `$s`. +`true` if and only if `$o` is the set of conclusions which can be drawn from `$s` (deductive closure), +by applying any rules it contains to the data it contains. -**Schema**
`$s+ time:month $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

+**Schema**
`$s+ log:conclusion $o?`
where:
`$s`: `log:Formula`
`$o`: `log:Formula`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Return the month component of the date "2023-04-01T18:06:04Z" . +Draw all conclusions from the formula ":Felix a :Cat . { ?X a :Cat } => { ?X :says "Meow" . }".

Formula: ``` @prefix : . -@prefix xsd: . -@prefix time: . +@prefix log: . -:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . +:let :param { + :Felix a :Cat . + { ?X a :Cat . } => { ?X :says "Meow" . } . +} . -{ - :Let :param ?param . - ?param time:month ?result . -} -=> -{ - :result :is ?result . +{ + :let :param ?param . + ?param log:conclusion ?conclusion . +} +=> +{ + :result :is ?conclusion . } . ``` @@ -1030,39 +1048,42 @@ Return the month component of the date "2023-04-01T18:06:04Z" . ``` @prefix : . -:result :is 4. +:result :is { + :Felix a :Cat. + :Felix :says "Meow". + { ?S a :Cat . } => { ?S :says "Meow" . } . +} . ```

-### time:second ### {#time:second} -Gets as object the integer seconds component of the subject xsd:dateTime. +### log:conjunction ### {#log:conjunction} +Merges the graph terms from the subject list into a single graph term as object. -`true` if and only if `$o` is the integer seconds component of `$s`. +`true` if and only if `$o` is a graph term that is the logical conjunction of each of the graph terms `$s.i` (i.e., includes all their triples, removing any duplicates) . -**Schema**
`$s+ time:second $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

+**Schema**
`( $s.i+ )+ log:conjunction $o?`
where:
`$s.i`: `log:Formula`
`$o`: `log:Formula`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Return the seconds component of the date "2023-04-01T18:06:04Z" . +Merge the formulas "{ :Felix a :Cat . }" , "{ :Pluto a :Dog . }", "{ :Pingu a :Penguin . }" .

Formula: ``` @prefix : . -@prefix xsd: . -@prefix time: . - -:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . +@prefix log: . -{ - :Let :param ?param . - ?param time:second ?result . -} -=> -{ - :result :is ?result . +{ + ( { :Felix a :Cat . } + { :Pluto a :Dog . } + { :Pingu a :Penguin . } + ) log:conjunction ?merged . +} +=> +{ + :result :is ?merged . } . ``` @@ -1070,79 +1091,77 @@ Return the seconds component of the date "2023-04-01T18:06:04Z" . ``` @prefix : . -:result :is 4. +:result :is { + :Felix a :Cat . + :Pingu a :Penguin . + :Pluto a :Dog . +} . ```

-### time:timeZone ### {#time:timeZone} -Gets as object the trailing timezone offset of the subject xsd:dateTime (e.g., "-05:00"). - -`true` if and only if `$o` is the timezone offset of `$s`. +### log:content ### {#log:content} +Dereferences the subject IRI and retrieves the online resource as the object string. -**Schema**
`$s+ time:timeZone $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:string`

+`true` if and only if `$o` is a string that represents the online resource to which `$s` is dereferenced. + +**Schema**
`$s+ log:content $o?`
where:
`$s`: `log:Uri`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Return the time zone component of the date "2023-04-01T18:06:04Z" . +Fetch the content of https://www.w3.org/People/Berners-Lee/card.

Formula: ``` @prefix : . -@prefix xsd: . -@prefix time: . - -:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . +@prefix log: . -{ - :Let :param ?param . - ?param time:minute ?result . -} -=> -{ - :result :is ?result . +{ + log:content ?content . +} +=> +{ + :result :is ?content . } . ```

Result: ``` -@prefix : . -:result :is "Z". +:result :is "...the content of https://www.w3.org/People/Berners-Lee/card ...". ```

-### time:year ### {#time:year} -Gets as object the integer year component of the subject xsd:dateTime. +### log:dtlit ### {#log:dtlit} +Creates a datatyped literal as object, based on the string value and datatype IRI in the subject list. -`true` if and only if `$o` is the integer year component of `$s`. +`true` if and only if `$o` is a datatyped literal with string value corresponding to `$s.1` and datatype IRI corresponding to `$s.2`. -**Schema**
`$s+ time:year $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

+**See also**
log:langlit + +**Schema**
`( $s.1? $s.2? )? log:dtlit $o?`
where:
`$s.1`: `xsd:string`, `$s.2`: `log:Uri`
`$o`: `log:Literal`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Return the minute component of the date "2023-04-01T18:06:04Z" . +Parse the datatyped literal "1971-05-05"^^xsd:date into a string and data type IRI.

Formula: ``` @prefix : . -@prefix xsd: . -@prefix time: . - -:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . +@prefix xsd: . +@prefix log: . -{ - :Let :param ?param . - ?param time:year ?result . -} -=> -{ - :result :is ?result . +{ + ( ?string ?type ) log:dtlit "1971-05-05"^^xsd:date . +} +=> +{ + :result :is ( ?string ?type ) . } . ``` @@ -1150,492 +1169,428 @@ Return the minute component of the date "2023-04-01T18:06:04Z" . ``` @prefix : . -:result :is 2023. +@prefix xsd: . +:result :is ("1971-05-05" xsd:date). ```

- -## string ## {#string} -### string:concatenation ### {#string:concatenation} -Concatenates the strings from the subject list into a single string as object. - -`true` if and only if the string concatenation of `$s.i` equals `$o`. - -**Schema**
`( $s.i+ )+ string:concatenation $o-`
where:
`$s.i`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Concatenates the string "hello", " " and "world!". +Create a datatyped literal from the string "1971-05-05" and the type xsd:date.

Formula: ``` @prefix : . -@prefix string: . - -:Let :param ( "hello" " " "world!" ) . +@prefix xsd: . +@prefix log: . -{ - :Let :param ?param . - ?param string:concatenation ?result . -} -=> -{ - :result :is ?result . -} . +{ ( "1971-05-05" xsd:date ) log:dtlit ?typed } => { :result :is ?typed . } . ```

Result: ``` @prefix : . -:result :is "hello world!". +@prefix xsd: . +:result :is "1971-05-05"^^xsd:date. ```

-### string:contains ### {#string:contains} -Checks whether the subject string contains the object string. +### log:equalTo ### {#log:equalTo} +Checks whether the subject and object N3 terms are the same (comparison occurs on the syntax level). +Can also be used to bind values to variables (see examples). -`true` if and only if `$s` contains `$o`. +`true` if and only if `$s` and `$o` are the same N3 term. +Not to be confused with owl:sameAs. +Literals will be compared exactly: their datatypes must be identical (in case of strings, language tags must be identical). -**See also**
string:containsIgnoringCase +**See also**
log:notEqualTo -**Schema**
`$s+ string:contains $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**Schema**
`$s? log:equalTo $o?`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Checks whether the string "hello world!" contains the string "llo worl". +Assign a value to an existential or universal variable.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 "llo worl". { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:contains ?param2 . + _:x log:equalTo 42 . + ?q log:equalTo "Cat"@en . + + # This will fail because _:x is already assigned to 42 . + # _:x log:equalTo 17 . } => { - :result :is true . -} . + :result :is ?q . +} . ```

Result: ``` @prefix : . -:result :is true . +:result :is "Cat"@en . ```

- -### string:containsIgnoringCase ### {#string:containsIgnoringCase} -Checks whether the subject string contains the object string, ignoring differences between lowercase and uppercase. - -`true` if and only if `$s` contains `$o` when ignoring case differences. - -**See also**
string:contains - -**Schema**
`$s+ string:containsIgnoringCase $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Checks whether the string "hello world!" contains the string "lLO woRl". +Determine if "Cat" is equal to "Cat"@en .

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 "lLO woRl". { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:containsIgnoringCase ?param2 . + # This will fail + "Cat" log:equalTo "Cat"@en . } => { :result :is true . -} . +} . ```

Result: ``` @prefix : . -:result :is true . +# no results ```

- -### string:endsWith ### {#string:endsWith} -Checks whether the subject string ends with the object string. - -`true` if and only if `$s` ends with `$o`. - -**Schema**
`$s+ string:endsWith $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Checks whether the string "hello world!" ends with "orld!". +Assign values from the object list to universal variables given in the subject list. +This can be compared to "destructuring" or "unpacking" in programming languages such as JavaScript or Python. +In contrast to those languages, however, it works in either direction in N3. +This mechanism works because an effort is made to ensure the truth of builtin statements in N3.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 "orld!". { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:endsWith ?param2 . + ( ?x ?y ?z ) log:equalTo ( 1 2 3 ) } => { - :result :is true . -} . + :result :is ?x , ?y , ?z . +} . ```

Result: ``` @prefix : . -:result :is true . +:result :is 1 , 2 , 3 . # objects can be in any order ```

- -### string:equalIgnoringCase ### {#string:equalIgnoringCase} -Checks whether the subject string is the same as the object string, ignoring differences between lowercase and uppercase. - -`true` if and only if `$s` is the same string as `$o` when ignoring case differences. - -**Schema**
`$s+ string:equalIgnoringCase $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Checks whether the string "hello world!" is equal to "hELLo wORld!" ignoring the case . +Determine <http://famous.web.site> is equal to itself .

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . +@prefix owl: . + + owl:sameAs . -:Let :param1 "hello world!" . -:Let :param2 "hELLo wORld!" . { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:equalIgnoringCase ?param2 . + log:equalTo . + + # But not + # + # log:equalTo . + # + # and not + # + # log:equalTo . + # } => { :result :is true . -} . +} . ```

Result: ``` @prefix : . -:result :is true . +:result :is true. ```

- -### string:format ### {#string:format} -Calculates the object as the result of replacing the tags in the first string from the subject list with the remaining strings from the subject list. -See C's sprintf function for details on these tags. - -`true` if and only if `$o` is the result of replacing the tags found in `$s.(i=1)` with the strings `$s.(i>1)` - -**Schema**
`( $s.i+ )+ string:format $o-`
where:
`$s.i`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Calculate the result of applying the format "%s://%s/%s" to the strings "https", "w3c.github.io" and "N3/spec" . +Determine if 1 is equal to 1 and "Cat" is equal to "Cat" and { :A :B :C . :D :E :F } is equal to { :D :E :F . :A :B :C }.

Formula: ``` @prefix : . -@prefix string: . - -:Let :param ( "%s://%s/%s" "https" "w3c.github.io" "N3/spec/" ) . +@prefix log: . { - :Let :param ?param . - ?param string:format ?result . + 1 log:equalTo 1 . + "Cat" log:equalTo "Cat" . + { :A :B :C . :D :E :F . } log:equalTo { :D :E :F . :A :B :C . } . } => { - :result :is ?result . -} . + :result :is true . +} . ```

Result: ``` @prefix : . -:result :is "https://w3c.github.io/N3/spec/". +:result :is true. ```

- -### string:greaterThan ### {#string:greaterThan} -Checks whether the subject string is greater than the object string, according to Unicode code order. - -`true` if and only if `$s` is greater than `$o` as per the Unicode code order. - -**See also**
string:notGreaterThan - -**Schema**
`$s+ string:greaterThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Checks whether the string "Pengiun" is greater than the string "Cat" . +Assign values from the subject list to universal variables given in the object list. +This can be compared to "destructuring" or "unpacking" in programming languages such as JavaScript or Python. +In contrast to those languages, however, it works in either direction in N3. +This mechanism works because an effort is made to ensure the truthfulness of builtin statements in N3.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "Penguin" . -:Let :param2 "Cat". { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:greaterThan ?param2 . + ( "War and Peace" "Leo Tolstoy" 1225 ) log:equalTo ( ?title ?author ?numPages ) . } => { - :result :is true . -} . + :result :is ?title , ?author , ?numPages . +} . ```

Result: ``` @prefix : . -:result :is true . +:result :is "War and Peace" , "Leo Tolstoy" , 1225 . # objects can be in any order ```

-### string:lessThan ### {#string:lessThan} -Checks whether the subject string is less than the object string, according to Unicode code order. - -`true` if and only if `$s` is less than `$o` as per the Unicode code order. +### log:forAllIn ### {#log:forAllIn} +Two clauses are given in the subject list: for every match of the first clause, + the builtin checks whether the second clause also holds for that match. -**See also**
string:notLessThan +`true` if and only if, for every valid substitution of clause `$s.1`, + i.e., a substitution of variables with terms that generates an instance of `$s.1` that is contained in the scope, + the instance of `$s.2` generated by the same substitution is also contained in the scope. +This applies a scoped quantification. -**Schema**
`$s+ string:lessThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**Schema**
`( $s.1+ $s.2+ )+ log:forAllIn $o?`
where:
`$s.1`: `log:Formula`, `$s.2`: `log:Formula`
`$o`: (Scope of the builtin. Leave as a variable to use current N3 document as scope.)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Checks whether the string "Cat" is less than the string "Penguin" . +For each subtask of a composite task, check whether the subtask is completed.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . + +:c a :CompositeTask ; + :subTask :s1 , :s2 , :s3 . +:s1 :state :Completed . +:s2 :state :Completed . +:s3 :state :Completed . -:Let :param1 "Cat" . -:Let :param2 "Penguin". { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:lessThan ?param2 . + ?c a :CompositeTask . + ( { ?c :subTask ?s } { ?s :state :Completed } ) log:forAllIn _:t . } => { :result :is true . -} . +} . ```

Result: ``` @prefix : . -:result :is true . +:result :is true. ```

-### string:matches ### {#string:matches} -Checks whether the subject string matches the object regular expression. -The regular expression follows the perl, python style. +### log:includes ### {#log:includes} +Checks whether the subject graph term includes the object graph term (taking into account variables). +Can also be used to bind variables to values within the graph contents (see examples). -`true` if and only if string `$s` matches the regular expression `$o` +`true` if and only if there exists some substitution which, when applied to `$s` and `$o`, +creates graph terms `$s`' and `$o`' such that every statement in `$o`' is also in `$s`''. +Variable substitution is applied recursively to nested compound terms such as graph terms and lists. -**See also**
string:notMatches +**See also**
log:notIncludes -**Schema**
`$s+ string:matches $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**Schema**
`$s+ log:includes $o+`
where:
`$s`: `log:Formula`
(Can also be left as a variable to use current N3 document as scope.)
`$o`: `log:Formula`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Checks whether the string "hello world!" matches the regular expression ".*(l)+o wo.*". - +Check whether the formula { :Felix a :Cat } includes { ?X a :Cat }. +

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 ".*(l)+o wo.*". -{ - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:matches ?param2 . -} +{ + { :Felix a :Cat } log:includes { ?X a :Cat } . +} => { - :result :is true . + :result :is ?X . } . - + ```

Result: ``` @prefix : . -:result :is true . +:result :is :Felix . ```

- -### string:notEqualIgnoringCase ### {#string:notEqualIgnoringCase} -Checks whether the subject string is not the same as the object string, ignoring differences between lowercase and uppercase. - -`true` if and only if `$s` is not the same string as `$o` when ignoring case differences. - -**Schema**
`$s+ string:notEqualIgnoringCase $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Checks whether the string "hello world!" is not equal to "hELLo dunia!" ignorning the case . - +Check whether the current N3 document includes { ?X a :Cat }. +

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 "hELLo dunia!" . -{ - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:notEqualIgnoringCase ?param2 . -} +:Felix a :Cat . +:Tom a :Cat . +:Rex a :Dog . + +{ + _:t log:includes { ?X a :Cat } . +} => { - :result :is true . + :result :is ?X . } . - + ```

Result: ``` @prefix : . -:result :is true . - +@prefix log: . + +:result :is :Felix. +:result :is :Tom. + ```

-### string:notGreaterThan ### {#string:notGreaterThan} -Checks whether the subject string is not greater than the object string, according to Unicode code order. -You can use this as an equivalent of a lessThanOrEqual operator. +### log:langlit ### {#log:langlit} +Creates a language-tagged literal as object, based on the string value and language tag (see BCP47) in the subject list. -`true` if and only if `$s` is not greater than `$o` as per the Unicode code order. -**See also**
string:greaterThan +`true` if and only if `$o` is a language-tagged literal with string value corresponding to `$s.1` and language tag corresponding to `$s.2`. +`$s.2` should be a string in the form of a BCP47 language tag. -**Schema**
`$s+ string:notGreaterThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**See also**
log:dtlit + +**Schema**
`( $s.1? $s.2? )? log:langlit $o?`
where:
`$s.1`: `xsd:string`, `$s.2`: `xsd:string`
`$o`: `log:Literal`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Checks whether the string "Cat" is not greater than the string "Penguin" . +Create a language-tagged literal from the string "hello" and language tag "en".

Formula: ``` @prefix : . -@prefix string: . - -:Let :param1 "Cat" . -:Let :param2 "Penguin". -{ - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:notGreaterThan ?param2 . -} -=> -{ - :result :is true . -} . +@prefix log: . +{ ("hello" "en") log:langlit ?X } => { ?X a :Result } . ```

Result: ``` @prefix : . -:result :is true . +"hello"@en a :Result . ```

-### string:notLessThan ### {#string:notLessThan} -Checks whether the subject string is not less than the object string, according to Unicode code order. -You can use this as an equivalent of a greaterThanOrEqual operator. +### log:notEqualTo ### {#log:notEqualTo} +Checks whether the subject and object N3 terms are _not_ the same (comparison occurs on the syntax level). -`true` if and only if `$s` is not less than `$o` as per the Unicode code order. +`true` if and only if `$s` and `$o` are _not_ the same N3 term. -**See also**
string:lessThan +**See also**
log:equalTo -**Schema**
`$s+ string:notLessThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**Schema**
`$s+ log:notEqualTo $o+`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Checks whether the string "Penguin" is not less than the string "Cat" . +Check whether two graph terms, one containing a universal variable, are not equal.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "Penguin". -:Let :param2 "Cat" . { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:notLessThan ?param2 . + + { :A :B :C . } log:notEqualTo { :A :B ?c } . } => { @@ -1647,161 +1602,124 @@ Checks whether the string "Penguin" is not less than the string "Cat" . ``` @prefix : . -:result :is true . +# no result (?c can be unified with :C) ```

- -### string:notMatches ### {#string:notMatches} -Checks whether the subject string does not match the object regular expression. -The regular expression follows the perl, python style. - -`true` if and only if string `$s` does not match the regular expression `$o` - -**See also**
string:matches - -**Schema**
`$s+ string:notMatches $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Checks whether the string "hello world!" no matches the regular expression ".*(l)+o dunia.*". +Check if an existential or universal variable is not equal to a value.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 ".*(l)+o dunia.*". { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:notMatches ?param2 . + _:x log:notEqualTo 42 . + ?q log:notEqualTo "Cat"@en . } => { :result :is true . -} . +} . ```

Result: ``` @prefix : . -:result :is true . +# no result (the variables _:x and ?q are not bounded) ```

- -### string:replace ### {#string:replace} -Calculates the object as the result of, given the strings in the subject list, replacing all occurrences of the second string in the first string with the third string. - -`true` if and only if `$o` is the result of replacing all occurrences of `$s.2` in `$s.1` with `$s.3` - -**Schema**
`( $s.1+ $s.2+ $s.3+ )+ string:replace $o-`
where:
`$s.1`: `xsd:string`, `$s.2`: `xsd:string`, `$s.3`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Replace all "l"-s in the string "hello world!" with the bracket version "[l]" . +Determine if 1 is not equal to 2 and "Cat" is not equal to "CAT" and { :A :B :C . } is not equal to { :C :B :A }.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :data "hello world!" . -:Let :search "(l)" . -:Let :replace "[$1]" . { - :Let :data ?data . - :Let :search ?search . - :Let :replace ?replace . - (?data ?search ?replace) string:replace ?result . + 1 log:notEqualTo 2 . + "Cat" log:notEqualTo "CAT" . + { :A :B :C . } log:notEqualTo { :C :B :A . } . } => { - :result :is ?result . -} . + :result :is true . +} . ```

Result: ``` @prefix : . -:result :is "he[l][l]o wor[l]d!". +:result :is true . ```

- -### string:scrape ### {#string:scrape} -Calculates the object as the first matching group when, given the subject list, matching the second string as regular expression (with exactly 1 group) against the first string. - -`true` if and only if `$o` is the first matching group when matching `$s.2` as a regular expression against `$s.1` - -**Schema**
`( $s.1+ $s.2+ )+ string:scrape $o-`
where:
`$s.1`: `xsd:string`, `$s.2`: `xsd:string`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Extract from the string "https://w3c.github.io/N3/spec/" the last path element using a regular expression . +Determine if "Cat" is not equal to "Cat"@en .

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "https://w3c.github.io/N3/spec/" . -:Let :param2 ".*/([^/]+/)$" . { - :Let :param1 ?param1 . - :Let :param2 ?param2 . - (?param1 ?param2) string:scrape ?result . + "Cat" log:notEqualTo "Cat"@en . } => { - :result :is ?result . -} . + :result :is true . +} . ```

Result: ``` @prefix : . -:result :is "spec/". +:result :is true . ```

-### string:startsWith ### {#string:startsWith} -Checks whether the subject string starts with the object string. +### log:notIncludes ### {#log:notIncludes} +Checks whether the subject graph term _does not_ include the object graph term (taking into account variables) -`true` if and only if `$s` starts with `$o`. +`true` if and only if `$s log:includes $o` is `false`. -**Schema**
`$s+ string:startsWith $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**See also**
log:includes + +**Schema**
`$s+ log:notIncludes $o+`
where:
`$s`: `log:Formula`
`$o`: `log:Formula`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Checks whether the string "hello world!" starts with "hello" . +Check whether the formula { :Felix a :Cat } does not include { ?X :eats ?Y }.

Formula: ``` @prefix : . -@prefix string: . +@prefix log: . -:Let :param1 "hello world!" . -:Let :param2 "hello". -{ - :Let :param1 ?param1 . - :Let :param2 ?param2 . - ?param1 string:startsWith ?param2 . -} +{ + { :Felix a :Cat } log:notIncludes { ?X :eats ?Y } . +} => { :result :is true . @@ -1812,119 +1730,91 @@ Checks whether the string "hello world!" starts with "hello" . ``` @prefix : . -:result :is true . +:result :is true. ```

- -## log ## {#log} -### log:collectAllIn ### {#log:collectAllIn} -Collects all values matching a given clause and adds them to a list. - -`true` if and only if, for every valid substitution of clause `$s.2`, - i.e., a substitution of variables with terms that generates an instance of `$s.2` that is contained in the scope, - the instance of `$s.1` generated by the same substitution is a member of list `$s.3`. -This applies scoped quantification. - -**Schema**
`( $s.1- $s.2+ $s.3- )+ log:collectAllIn $o?`
where:
`$s.2`: `log:Formula`, `$s.3`: `rdf:List`
`$o`: (Scope of the builtin. Leave as a variable to use current N3 document as scope.)

-**Examples**
-try in editor 🚀
+
+try in editor 🚀

-Set of basic examples for log:collectAllIn. +Check whether the formula { :a :b :c } does not include { :a :b :d }.

Formula: ``` @prefix : . @prefix log: . -@prefix string: . - -:Let :param "Huey" . -:Let :param "Dewey" . -:Let :param "Louie" . +{ + # Dynamic evaluation of ?X and ?Y + ?X log:notIncludes ?Y . + ?X log:equalTo { :a :b :c }. + ?Y log:equalTo { :a :b :d }. +} +=> { - ( ?param { :Let :param ?param } ?allParams ) log:collectAllIn _:x . - - # Variable to be collected can also be part of a list or graph term - ( (?param) { :Let :param ?param } ?nestedParams ) log:collectAllIn _:x . - - # Add some extra criteria on variable values to be collected - ( ?param - { - :Let :param ?param . - ?param string:lessThan "Louie" . - } - ?filteredParams ) log:collectAllIn _:x . -} -=> -{ - :result1 :is ?allParams . - :result2 :is ?nestedParams . - :result3 :is ?filteredParams . + :result :is true . } . - + ```

Result: ``` @prefix : . - -:result1 :is ("Huey" "Dewey" "Louie"). -:result2 :is (("Huey") ("Dewey") ("Louie")). -:result3 :is ("Huey" "Dewey"). - +:result :is true. + ```

-
-try in editor 🚀
+ +### log:outputString ### {#log:outputString} +The N3 reasoner will print the object strings in the order of the subject keys, instead of printing the derivations or deductive closure. This may require a reasoner flag to be set. + +The concrete semantics of this builtin (e.g., which N3 resource types are supported) will depend on the N3 reasoner. + +**Schema**
`$s+ log:outputString $o+`
where:
`$o`: `xsd:string`

+**Examples**
+try in editor 🚀

-Example where the list is already given; in that case, the collected list will be compared with the given list. +Print the two string "This is the first line +" , "This is the second line +" to the output.

Formula: ``` @prefix : . @prefix log: . -@prefix string: . -:Let :param "Huey" . -:Let :param "Dewey" . -:Let :param "Louie" . - -{ - ( ?param { :Let :param ?param } ("Huey" "Dewey" "Louie") ) log:collectAllIn _:x . -} -=> -{ - :result :is true . -} . +_:2 log:outputString "This is the second line\n" . +_:1 log:outputString "This is the first line\n" . ```

Result: ``` -@prefix : . - -:result :is true . - +# If the reasoner support the outputString options +This is the first line +This is the second line + ```

-### log:conclusion ### {#log:conclusion} -Gets all possible conclusions from the subject graph term, including rule inferences (deductive closure), as the object graph term. +### log:parsedAsN3 ### {#log:parsedAsN3} +Parses the subject string into an object graph term. -`true` if and only if `$o` is the set of conclusions which can be drawn from `$s` (deductive closure), -by applying any rules it contains to the data it contains. +`true` if and only if `$s`, when parsed as N3, gives `$o`. +`$s` should be a syntactically valid string in N3 format. -**Schema**
`$s+ log:conclusion $o?`
where:
`$s`: `log:Formula`
`$o`: `log:Formula`

+**See also**
log:semantics + +**Schema**
`$s+ log:parsedAsN3 $o-`
where:
`$s`: `xsd:string`
(should be a syntactically valid string in N3 format)
`$o`: `log:Formula`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Draw all conclusions from the formula ":Felix a :Cat . { ?X a :Cat } => { ?X :says "Meow" . }". +Parse the string ':Socrates a :Human .' as N3.

Formula: ``` @@ -1932,18 +1822,18 @@ Draw all conclusions from the formula ":Felix a :Cat . { ?X a :Cat } => { ?X :sa @prefix : . @prefix log: . -:let :param { - :Felix a :Cat . - { ?X a :Cat . } => { ?X :says "Meow" . } . -} . +:Let :param """ +@prefix : . +:Socrates a :Human . +""" . -{ - :let :param ?param . - ?param log:conclusion ?conclusion . -} -=> -{ - :result :is ?conclusion . +{ + :Let :param ?X . + ?X log:parsedAsN3 ?Y . +} +=> +{ + :result :is ?Y . } . ``` @@ -1951,26 +1841,23 @@ Draw all conclusions from the formula ":Felix a :Cat . { ?X a :Cat } => { ?X :sa ``` @prefix : . -:result :is { - :Felix a :Cat. - :Felix :says "Meow". - { ?S a :Cat . } => { ?S :says "Meow" . } . -} . +:result :is { a . } . ```

-### log:conjunction ### {#log:conjunction} -Merges the graph terms from the subject list into a single graph term as object. +### log:rawType ### {#log:rawType} +Gets the type of the N3 resource. -`true` if and only if `$o` is a graph term that is the logical conjunction of each of the graph terms `$s.i` (i.e., includes all their triples, removing any duplicates) . +`true` if and only if the N3 resource type of `$s` is `$o`. +N3 resource types include `log:Formula`, `log:Literal`, `rdf:List` or `log:Other`. -**Schema**
`( $s.i+ )+ log:conjunction $o?`
where:
`$s.i`: `log:Formula`
`$o`: `log:Formula`

+**Schema**
`$s+ log:rawType $o-`
where:
`$o`: `log:Uri`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Merge the formulas "{ :Felix a :Cat . }" , "{ :Pluto a :Dog . }", "{ :Pingu a :Penguin . }" . +Get the type of lists and graph terms.

Formula: ``` @@ -1978,15 +1865,13 @@ Merge the formulas "{ :Felix a :Cat . }" , "{ :Pluto a :Dog . }", "{ :Pingu a :P @prefix : . @prefix log: . -{ - ( { :Felix a :Cat . } - { :Pluto a :Dog . } - { :Pingu a :Penguin . } - ) log:conjunction ?merged . +{ + (1 2 3 4) log:rawType ?listType . + { :s :p :o } log:rawType ?graphType . } -=> -{ - :result :is ?merged . +=> +{ + :result :is ( ?listType ?graphType ) . } . ``` @@ -1994,26 +1879,47 @@ Merge the formulas "{ :Felix a :Cat . }" , "{ :Pluto a :Dog . }", "{ :Pingu a :P ``` @prefix : . -:result :is { - :Felix a :Cat . - :Pingu a :Penguin . - :Pluto a :Dog . -} . +@prefix rdf: . +@prefix log: . +:result :is ( rdf:List log:Formula ) . ```

+
+try in editor 🚀
+

+Get the type of resources. + +

Formula: +``` -### log:content ### {#log:content} -Dereferences the subject IRI and retrieves the online resource as the object string. +@prefix : . +@prefix log: . -`true` if and only if `$o` is a string that represents the online resource to which `$s` is dereferenced. +{ + log:rawType ?resourceType . +} +=> +{ + :result :is ?resourceType . +} . + +``` +

Result: +``` -**Schema**
`$s+ log:content $o?`

where:
`$s`: `log:Uri`
`$o`: `xsd:string`

-**Examples**
-try in editor 🚀
+@prefix : . +@prefix log: . +:result :is log:Other. + +``` +
+
+
+try in editor 🚀

-Fetch the content of https://www.w3.org/People/Berners-Lee/card. +Get the type of literal resources.

Formula: ``` @@ -2021,148 +1927,134 @@ Fetch the content of https://www.w3.org/People/Berners-Lee/card. @prefix : . @prefix log: . -{ - log:content ?content . -} -=> -{ - :result :is ?content . +{ + "Hello" log:rawType ?stringType . + 42 log:rawType ?integerType . + true log:rawType ?trueType . + false log:rawType ?falseType . +} +=> +{ + :result :is ( ?stringType ?integerType ?trueType ?falseType ) . } . ```

Result: ``` -:result :is "...the content of https://www.w3.org/People/Berners-Lee/card ...". +@prefix : . +@prefix log: . +:result :is ( log:Literal log:Literal log:Literal log:Literal ) . ```

-### log:dtlit ### {#log:dtlit} -Creates a datatyped literal as object, based on the string value and datatype IRI in the subject list. - -`true` if and only if `$o` is a datatyped literal with string value corresponding to `$s.1` and datatype IRI corresponding to `$s.2`. +### log:semantics ### {#log:semantics} +Gets as object the graph term that results from parsing an online (N3) string, found by dereferencing the subject IRI. -**See also**
log:langlit +`true` if and only if `$o` is a graph term that results from parsing the string that results from dereferencing `$s`. -**Schema**
`( $s.1? $s.2? )? log:dtlit $o?`
where:
`$s.1`: `xsd:string`, `$s.2`: `log:Uri`
`$o`: `log:Literal`

+**Schema**
`$s+ log:semantics $o?`
where:
`$s`: `log:Uri`
`$o`: `log:Formula`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Parse the datatyped literal "1971-05-05"^^xsd:date into a string and data type IRI. +Read the contents of the file `` and parse it as Notation3. +We assume `` contains the text: +``` + @prefix : . + :Socrates a :Human . +```

Formula: ``` @prefix : . -@prefix xsd: . @prefix log: . -{ - ( ?string ?type ) log:dtlit "1971-05-05"^^xsd:date . -} -=> -{ - :result :is ( ?string ?type ) . -} . +{ log:semantics ?semantics . } => { :result :is ?semantics } . ```

Result: ``` @prefix : . -@prefix xsd: . -:result :is ("1971-05-05" xsd:date). +:result :is { :Socrates a :Human . } . ```

-
-try in editor 🚀
+ +### log:semanticsOrError ### {#log:semanticsOrError} +Either gets as object the graph term that results from parsing an online (N3) string, found by dereferencing the subject IRI; or an error message that explains what went wrong. + +`true` if and only if (a) `$o` is a graph term that results from parsing the string that results from dereferencing `$s`; or (b) an error message explaining what went wrong. + +**Schema**
`$s+ log:semanticsOrError $o?`
where:
`$s`: `log:Uri`
`$o`: (either a log:Formula or xsd:string)

+**Examples**
+try in editor 🚀

-Create a datatyped literal from the string "1971-05-05" and the type xsd:date. +Read the contents a non existing `` and parse it as Notation3 (which of course will fail).

Formula: ``` @prefix : . -@prefix xsd: . @prefix log: . -{ ( "1971-05-05" xsd:date ) log:dtlit ?typed } => { :result :is ?typed . } . - +{ log:semanticsOrError ?semantics } => { :result :is ?semantics } . ```

Result: ``` @prefix : . -@prefix xsd: . -:result :is "1971-05-05"^^xsd:date. + +:result :is "error(existence_error(source_sink,/error.data),context(system:open/4,No such file or directory))" . ```

-### log:equalTo ### {#log:equalTo} -Checks whether the subject and object N3 terms are the same (comparison occurs on the syntax level). -Can also be used to bind values to variables (see examples). - -`true` if and only if `$s` and `$o` are the same N3 term. -Not to be confused with owl:sameAs. -Literals will be compared exactly: their datatypes must be identical (in case of strings, language tags must be identical). +### log:skolem ### {#log:skolem} +Gets as object a skolem IRI that is a function of the subject (commonly a list) and a concrete reasoning run (implicit); for one reasoning run, the same subject will always result in the same skolem IRI. -**See also**
log:notEqualTo +`true` if and only if `$o` is a skolem IRI that is produced by applying a skolem function to the subject. -**Schema**
`$s? log:equalTo $o?`

+**Schema**
`$s+ log:skolem $o-`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Determine <http://famous.web.site> is equal to itself . +Generate a unique Skolem IRI from the list (:abc 77 "xyz") .

Formula: ``` @prefix : . @prefix log: . -@prefix owl: . - - owl:sameAs . - -{ - log:equalTo . - # But not - # - # log:equalTo . - # - # and not - # - # log:equalTo . - # -} -=> -{ - :result :is true . -} . +{ (:abc 77 "xyz") log:skolem ?skolem . } => { :result :is ?skolem } . ```

Result: ``` @prefix : . -:result :is true. +:result :is . ```

-
-try in editor 🚀
+ +### log:uri ### {#log:uri} +Gets as object the string representation of the subject URI. + +`true` if and only if `$o` is the string representation of `$s`. + +**Schema**
`$s? log:uri $o?`
where:
`$s`: (a URI)
`$o`: `xsd:string`

+**Examples**
+try in editor 🚀

-Assign values from the subject list to universal variables given in the object list. -This can be compared to "destructuring" or "unpacking" in programming languages such as JavaScript or Python. -In contrast to those languages, however, it works in either direction in N3. -This mechanism works because an effort is made to ensure the truthfulness of builtin statements in N3. +Parse the URI into a string .

Formula: ``` @@ -2170,393 +2062,439 @@ This mechanism works because an effort is made to ensure the truthfulness of bui @prefix : . @prefix log: . -{ - ( "War and Peace" "Leo Tolstoy" 1225 ) log:equalTo ( ?title ?author ?numPages ) . -} -=> -{ - :result :is ?title , ?author , ?numPages . -} . +{ log:uri ?uri . } => { :result :is ?uri . } . ```

Result: ``` @prefix : . -:result :is "War and Peace" , "Leo Tolstoy" , 1225 . # objects can be in any order +:result :is "https://www.w3.org" . ```

-
-try in editor 🚀
+ +## math ## {#math} +### math:absoluteValue ### {#math:absoluteValue} +Calculates as object the absolute value of the subject. + +`true` if and only if `$o` is the absolute value of `$s`. + +**Schema**
`$s+ math:absoluteValue $o-`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Assign values from the object list to universal variables given in the subject list. -This can be compared to "destructuring" or "unpacking" in programming languages such as JavaScript or Python. -In contrast to those languages, however, it works in either direction in N3. -This mechanism works because an effort is made to ensure the truth of builtin statements in N3. +Calculate the absolute value of the value -2.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param -2 . { - ( ?x ?y ?z ) log:equalTo ( 1 2 3 ) + :Let :param ?param . + ?param math:absoluteValue ?result . } => { - :result :is ?x , ?y , ?z . -} . + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is 1 , 2 , 3 . # objects can be in any order +:result :is 2. ```

-
-try in editor 🚀
+ +### math:acos ### {#math:acos} +Calculates the object as the arc cosine value of the subject. + +`true` if and only if `$o` is the arc cosine value of `$s`. + +**See also**
math:cos
math:cosh + +**Schema**
`$s? math:acos $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Determine if 1 is equal to 1 and "Cat" is equal to "Cat" and { :A :B :C . :D :E :F } is equal to { :D :E :F . :A :B :C }. +Calculate the arc cosine of the value 1.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param 1 . { - 1 log:equalTo 1 . - "Cat" log:equalTo "Cat" . - { :A :B :C . :D :E :F . } log:equalTo { :D :E :F . :A :B :C . } . + :Let :param ?param . + ?param math:acos ?result . } => { - :result :is true . -} . + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is true. +:result :is 0.0 . ```

-
-try in editor 🚀
+ +### math:asin ### {#math:asin} +Calculates the object as the arc sine value of the subject. + +`true` if and only if `$o` is the arc sine value of `$s`. + +**See also**
math:sinh
math:sin + +**Schema**
`$s? math:asin $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Determine if "Cat" is equal to "Cat"@en . +Calculate the arc sine of the value 1.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param 1 . { - # This will fail - "Cat" log:equalTo "Cat"@en . + :Let :param ?param . + ?param math:asin ?result . } => { - :result :is true . -} . + :result :is ?result . +} . ```

Result: ``` @prefix : . -# no results +:result :is 1.5707963267948966 . ```

-
-try in editor 🚀
+ +### math:atan ### {#math:atan} +Calculates the object as the arc tangent value of the subject. + +`true` if and only if `$o` is the arc tangent value of `$s`. + +**See also**
math:tan
math:tanh + +**Schema**
`$s? math:atan $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Assign a value to an existential or universal variable. +Calculate the arc tangent of the value 1.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -{ - _:x log:equalTo 42 . - ?q log:equalTo "Cat"@en . +:Let :param 1 . - # This will fail because _:x is already assigned to 42 . - # _:x log:equalTo 17 . +{ + :Let :param ?param . + ?param math:atan ?result . } => { - :result :is ?q . -} . + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is "Cat"@en . +:result :is 0.7853981633974483 . ```

-### log:forAllIn ### {#log:forAllIn} -Two clauses are given in the subject list: for every match of the first clause, - the builtin checks whether the second clause also holds for that match. +### math:cos ### {#math:cos} +Calculates the object as the cosine value of the subject. -`true` if and only if, for every valid substitution of clause `$s.1`, - i.e., a substitution of variables with terms that generates an instance of `$s.1` that is contained in the scope, - the instance of `$s.2` generated by the same substitution is also contained in the scope. -This applies a scoped quantification. +`true` if and only if `$o` is the cosine value of `$s`. -**Schema**
`( $s.1+ $s.2+ )+ log:forAllIn $o?`
where:
`$s.1`: `log:Formula`, `$s.2`: `log:Formula`
`$o`: (Scope of the builtin. Leave as a variable to use current N3 document as scope.)

+**See also**
math:acos
math:cosh + +**Schema**
`$s? math:cos $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-For each subtask of a composite task, check whether the subtask is completed. +Calculate the cosine of the value 0.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -:c a :CompositeTask ; - :subTask :s1 , :s2 , :s3 . -:s1 :state :Completed . -:s2 :state :Completed . -:s3 :state :Completed . +:Let :param 0 . { - ?c a :CompositeTask . - ( { ?c :subTask ?s } { ?s :state :Completed } ) log:forAllIn _:t . + :Let :param ?param . + ?param math:cos ?result . } => { - :result :is true . -} . + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is true. +:result :is 1.0 . ```

-### log:includes ### {#log:includes} -Checks whether the subject graph term includes the object graph term (taking into account variables). -Can also be used to bind variables to values within the graph contents (see examples). +### math:cosh ### {#math:cosh} +Calculates the object as the hyperbolic cosine value of the subject. -`true` if and only if there exists some substitution which, when applied to `$s` and `$o`, -creates graph terms `$s`' and `$o`' such that every statement in `$o`' is also in `$s`''. -Variable substitution is applied recursively to nested compound terms such as graph terms and lists. +`true` if and only if `$o` is the hyperbolic cosine value of `$s`. -**See also**
log:notIncludes +**See also**
math:acos
math:cos -**Schema**
`$s+ log:includes $o+`
where:
`$s`: `log:Formula`
(Can also be left as a variable to use current N3 document as scope.)
`$o`: `log:Formula`

+**Schema**
`$s? math:cosh $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check whether the formula { :Felix a :Cat } includes { ?X a :Cat }. - +Calculate the hyperbolic cosine of the value 0. +

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -{ - { :Felix a :Cat } log:includes { ?X a :Cat } . -} +:Let :param 0 . + +{ + :Let :param ?param . + ?param math:cosh ?result . +} => { - :result :is ?X . + :result :is ?result . } . - + ```

Result: ``` @prefix : . -:result :is :Felix . +:result :is 1.0 . ```

-
-try in editor 🚀
-

-Check whether the current N3 document includes { ?X a :Cat }. +### math:degrees ### {#math:degrees} +Calculates the object as the value in degrees corresponding to the radians value of the subject. + +`true` if and only if `$o` is the value in degrees corresponding to the radians value of `$s`. + +**Schema**
`$s? math:degrees $o?`

where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀
+

+Calculate the degrees of the radians value 1.57079632679. +

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -:Felix a :Cat . -:Tom a :Cat . -:Rex a :Dog . +:Let :param 1.57079632679 . -{ - _:t log:includes { ?X a :Cat } . -} +{ + :Let :param ?param . + ?param math:degrees ?result . +} => { - :result :is ?X . + :result :is ?result . } . - + ```

Result: ``` @prefix : . -@prefix log: . - -:result :is :Felix. -:result :is :Tom. - +:result :is 89.99999999971946 . + ```

-### log:langlit ### {#log:langlit} -Creates a language-tagged literal as object, based on the string value and language tag (see BCP47) in the subject list. - - -`true` if and only if `$o` is a language-tagged literal with string value corresponding to `$s.1` and language tag corresponding to `$s.2`. -`$s.2` should be a string in the form of a BCP47 language tag. +### math:difference ### {#math:difference} +Calculates the object by subtracting the second number from the first number given in the subject list. -**See also**
log:dtlit +`true` if and only if `$o` is the result of subtracting `$s.2` from `$s.1`. -**Schema**
`( $s.1? $s.2? )? log:langlit $o?`
where:
`$s.1`: `xsd:string`, `$s.2`: `xsd:string`
`$o`: `log:Literal`

+**Schema**
`( $s.1+ $s.2+ )+ math:difference $o-`
where:
`$s.1`: (`xsd:decimal` | `xsd:double` | `xsd:float`), `$s.2`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Create a language-tagged literal from the string "hello" and language tag "en". +Calculate the value of 7 minus 2.

Formula: ``` @prefix : . -@prefix log: . -{ ("hello" "en") log:langlit ?X } => { ?X a :Result } . +@prefix math: . + +:Let :param (7 2) . + +{ + :Let :param ?param . + ?param math:difference ?result . +} +=> +{ + :result :is ?result . +} . ```

Result: ``` @prefix : . -"hello"@en a :Result . +:result :is 5. ```

-### log:notEqualTo ### {#log:notEqualTo} -Checks whether the subject and object N3 terms are _not_ the same (comparison occurs on the syntax level). +### math:equalTo ### {#math:equalTo} +Checks whether the subject and object are the same number. -`true` if and only if `$s` and `$o` are _not_ the same N3 term. +`true` if and only if `$s` is the same number as `$o`. -**See also**
log:equalTo +**See also**
math:notEqualTo -**Schema**
`$s+ log:notEqualTo $o+`

+**Schema**
`$s? math:equalTo $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Determine if "Cat" is not equal to "Cat"@en . +Check if the numbers 42 and 42 are equal .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param (42 42) . { - "Cat" log:notEqualTo "Cat"@en . + :Let :param (?X ?Y) . + ?X math:equalTo ?Y . } => { :result :is true . -} . +} . ```

Result: ``` @prefix : . -:result :is true . +:result :is true . ```

-
-try in editor 🚀
+ +### math:exponentiation ### {#math:exponentiation} +Calculates the object as the result of raising the first number to the power of the second number in the subject list. +You can also use this to calculate the logarithm of the object, with as base the first number of the subject list (see examples). + +`true` if and only if `$o` is the result of raising `$s.1` to the power of `$s.2` + +**Schema**
`( $s.1+ $s.2? )+ math:exponentiation $o?`
where:
`$s.1`: (`xsd:decimal` | `xsd:double` | `xsd:float`), `$s.2`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Check if an existential or universal variable is not equal to a value. +Calculate the logarithm of 49 base 2 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . { - _:x log:notEqualTo 42 . - ?q log:notEqualTo "Cat"@en . + (7 ?result) math:exponentiation 49 . } => { - :result :is true . -} . + :result :is ?result . +} . ```

Result: ``` @prefix : . -# no result (the variables _:x and ?q are not bounded) +:result :is 2.0 . ```

-try in editor 🚀
+try in editor 🚀

-Check whether two graph terms, one containing a universal variable, are not equal. +Calculate the value of 7 raised to the power of 2 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param (7 2) . { - - { :A :B :C . } log:notEqualTo { :A :B ?c } . + :Let :param ?param . + ?param math:exponentiation ?result . } => { - :result :is true . + :result :is ?result . } . ``` @@ -2564,31 +2502,41 @@ Check whether two graph terms, one containing a universal variable, are not equa ``` @prefix : . -# no result (?c can be unified with :C) +:result :is 49 . ```

-
-try in editor 🚀
+ +### math:greaterThan ### {#math:greaterThan} +Checks whether the subject is a number that is greater than the object. + +`true` if and only if `$s` is a number that is greater than `$o`. + +**See also**
math:notGreaterThan + +**Schema**
`$s+ math:greaterThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Determine if 1 is not equal to 2 and "Cat" is not equal to "CAT" and { :A :B :C . } is not equal to { :C :B :A }. +Check if 42 is greater than 41 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param (42 41) . { - 1 log:notEqualTo 2 . - "Cat" log:notEqualTo "CAT" . - { :A :B :C . } log:notEqualTo { :C :B :A . } . + :Let :param (?X ?Y) . + ?X math:greaterThan ?Y . } => { :result :is true . -} . +} . ```

Result: @@ -2601,32 +2549,32 @@ Determine if 1 is not equal to 2 and "Cat" is not equal to "CAT" and { :A :B :C

-### log:notIncludes ### {#log:notIncludes} -Checks whether the subject graph term _does not_ include the object graph term (taking into account variables) +### math:lessThan ### {#math:lessThan} +Checks whether the subject is a number that is less than the object. -`true` if and only if `$s log:includes $o` is `false`. +`true` if and only if `$s` is a number that is less than `$o`. -**See also**
log:includes +**See also**
math:notLessThan -**Schema**
`$s+ log:notIncludes $o+`
where:
`$s`: `log:Formula`
`$o`: `log:Formula`

+**Schema**
`$s+ math:lessThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check whether the formula { :a :b :c } does not include { :a :b :d }. +Check if 41 is less than 42 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -{ - # Dynamic evaluation of ?X and ?Y - ?X log:notIncludes ?Y . - ?X log:equalTo { :a :b :c }. - ?Y log:equalTo { :a :b :d }. -} -=> +:Let :param (41 42) . + +{ + :Let :param (?X ?Y) . + ?X math:lessThan ?Y . +} +=> { :result :is true . } . @@ -2636,28 +2584,38 @@ Check whether the formula { :a :b :c } does not include { :a :b :d }. ``` @prefix : . -:result :is true. +:result :is true . ```

-
-try in editor 🚀
+ +### math:negation ### {#math:negation} +Calculates the object as the negation of the subject. + +`true` if and only if `$o` is the negation of `$s`. + +**Schema**
`$s? math:negation $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Check whether the formula { :Felix a :Cat } does not include { ?X :eats ?Y }. +Calculate the negation of the value 42 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -{ - { :Felix a :Cat } log:notIncludes { ?X :eats ?Y } . -} +:Let :param 42 . + +{ + :Let :param ?param . + ?param math:negation ?result . +} => { - :result :is true . + :result :is ?result . } . ``` @@ -2665,78 +2623,82 @@ Check whether the formula { :Felix a :Cat } does not include { ?X :eats ?Y }. ``` @prefix : . -:result :is true. +:result :is -42 . ```

-### log:outputString ### {#log:outputString} -The N3 reasoner will print the object strings in the order of the subject keys, instead of printing the derivations or deductive closure. This may require a reasoner flag to be set. +### math:notEqualTo ### {#math:notEqualTo} +Checks whether the subject and object are not the same number. -The concrete semantics of this builtin (e.g., which N3 resource types are supported) will depend on the N3 reasoner. +`true` if and only if `$s` is the not same number as `$o`. -**Schema**
`$s+ log:outputString $o+`
where:
`$o`: `xsd:string`

+**See also**
math:equalTo + +**Schema**
`$s+ math:notEqualTo $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Print the two string "This is the first line -" , "This is the second line -" to the output. +Check if the numbers 41 and 42 are not equal .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -_:2 log:outputString "This is the second line\n" . -_:1 log:outputString "This is the first line\n" . +:Let :param (41 42) . + +{ + :Let :param (?X ?Y) . + ?X math:notEqualTo ?Y . +} +=> +{ + :result :is true . +} . ```

Result: ``` -# If the reasoner support the outputString options -This is the first line -This is the second line +@prefix : . +:result :is true . ```

-### log:parsedAsN3 ### {#log:parsedAsN3} -Parses the subject string into an object graph term. +### math:notGreaterThan ### {#math:notGreaterThan} +Checks whether the subject is a number that is not greater than the object. +You can use this as an equivalent of a lessThanOrEqual operator. -`true` if and only if `$s`, when parsed as N3, gives `$o`. -`$s` should be a syntactically valid string in N3 format. +`true` if and only if `$s` is a number that is not greater than `$o`. -**See also**
log:semantics +**See also**
math:greaterThan -**Schema**
`$s+ log:parsedAsN3 $o-`
where:
`$s`: `xsd:string`
(should be a syntactically valid string in N3 format)
`$o`: `log:Formula`

+**Schema**
`$s+ math:notGreaterThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Parse the string ':Socrates a :Human .' as N3. +Check if 41 is not greater than 42 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -:Let :param """ -@prefix : . -:Socrates a :Human . -""" . +:Let :param (41 42) . { - :Let :param ?X . - ?X log:parsedAsN3 ?Y . + :Let :param (?X ?Y) . + ?X math:notGreaterThan ?Y . } => { - :result :is ?Y . + :result :is true . } . ``` @@ -2744,37 +2706,41 @@ Parse the string ':Socrates a :Human .' as N3. ``` @prefix : . -:result :is { a . } . +:result :is true . ```

-### log:rawType ### {#log:rawType} -Gets the type of the N3 resource. +### math:notLessThan ### {#math:notLessThan} +Checks whether the subject is a number that is not less than the object. +You can use this as an equivalent of a greaterThanOrEqual operator. -`true` if and only if the N3 resource type of `$s` is `$o`. -N3 resource types include `log:Formula`, `log:Literal`, `rdf:List` or `log:Other`. +`true` if and only if `$s` is a number that is not less than `$o`. -**Schema**
`$s+ log:rawType $o-`
where:
`$o`: `log:Uri`

+**See also**
math:lessThan + +**Schema**
`$s+ math:notLessThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Get the type of lists and graph terms. +Check if 42 is not less than 41 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param (42 41) . { - (1 2 3 4) log:rawType ?listType . - { :s :p :o } log:rawType ?graphType . -} + :Let :param (?X ?Y) . + ?X math:notLessThan ?Y . +} => { - :result :is ( ?listType ?graphType ) . + :result :is true . } . ``` @@ -2782,30 +2748,38 @@ Get the type of lists and graph terms. ``` @prefix : . -@prefix rdf: . -@prefix log: . -:result :is ( rdf:List log:Formula ) . +:result :is true . ```

-
-try in editor 🚀
+ +### math:product ### {#math:product} +Calculates the object as the product of the numbers given in the subject list. + +`true` if and only if `$o` is the arithmetic product of all numbers `$s.i` + +**Schema**
`( $s.i+ )+ math:product $o-`
where:
`$s.i`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Examples**
+try in editor 🚀

-Get the type of resources. +Calculate the product of 2,4,6, and 8 .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param (2 4 6 8) . { - log:rawType ?resourceType . + :Let :param ?param . + ?param math:product ?result . } => { - :result :is ?resourceType . + :result :is ?result . } . ``` @@ -2813,32 +2787,31 @@ Get the type of resources. ``` @prefix : . -@prefix log: . -:result :is log:Other. +:result :is 384. ```

-try in editor 🚀
+try in editor 🚀

-Get the type of literal resources. +Calculate the product of 2 and 21.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . + +:Let :param (2 21) . { - "Hello" log:rawType ?stringType . - 42 log:rawType ?integerType . - true log:rawType ?trueType . - false log:rawType ?falseType . + :Let :param ?param . + ?param math:product ?result . } => { - :result :is ( ?stringType ?integerType ?trueType ?falseType ) . + :result :is ?result . } . ``` @@ -2846,161 +2819,200 @@ Get the type of literal resources. ``` @prefix : . -@prefix log: . -:result :is ( log:Literal log:Literal log:Literal log:Literal ) . +:result :is 42. ```

-### log:semantics ### {#log:semantics} -Gets as object the graph term that results from parsing an online (N3) string, found by dereferencing the subject IRI. +### math:quotient ### {#math:quotient} +Calculates the object by dividing the first number by the second number given in the subject list. -`true` if and only if `$o` is a graph term that results from parsing the string that results from dereferencing `$s`. +`true` if and only if `$o` is the result of dividing `$s.1` by `$s.2`. -**Schema**
`$s+ log:semantics $o?`
where:
`$s`: `log:Uri`
`$o`: `log:Formula`

+**Schema**
`( $s.1+ $s.2+ )+ math:quotient $o-`
where:
`$s.1`: (`xsd:decimal` | `xsd:double` | `xsd:float`), `$s.2`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Read the contents of the file `` and parse it as Notation3. -We assume `` contains the text: -``` - @prefix : . - :Socrates a :Human . -``` +Calculate the quotient of 42 and 2.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -{ log:semantics ?semantics . } => { :result :is ?semantics } . +:Let :param (42 2) . + +{ + :Let :param ?param . + ?param math:quotient ?result . +} +=> +{ + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is { :Socrates a :Human . } . +:result :is 21. ```

-### log:semanticsOrError ### {#log:semanticsOrError} -Either gets as object the graph term that results from parsing an online (N3) string, found by dereferencing the subject IRI; or an error message that explains what went wrong. +### math:remainder ### {#math:remainder} +Calculates the object as the remainder of the division of the first integer by the second integer given in the subject list. -`true` if and only if (a) `$o` is a graph term that results from parsing the string that results from dereferencing `$s`; or (b) an error message explaining what went wrong. +`true` if and only if `$o` is the remainder of dividing `$s.1` by `$s.2`. -**Schema**
`$s+ log:semanticsOrError $o?`
where:
`$s`: `log:Uri`
`$o`: (either a log:Formula or xsd:string)

+**Schema**
`( $s.1+ $s.2+ )+ math:remainder $o-`
where:
`$s.1`: `xsd:integer`, `$s.2`: `xsd:integer`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Read the contents a non existing `` and parse it as Notation3 (which of course will fail). +Calculate the remainder of 10 divided by 3.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . -{ log:semanticsOrError ?semantics } => { :result :is ?semantics } . +:Let :param (10 3) . + +{ + :Let :param ?param . + ?param math:remainder ?result . +} +=> +{ + :result :is ?result . +} . + ```

Result: ``` @prefix : . - -:result :is "error(existence_error(source_sink,/error.data),context(system:open/4,No such file or directory))" . +:result :is 1. ```

-### log:skolem ### {#log:skolem} -Gets as object a skolem IRI that is a function of the subject (commonly a list) and a concrete reasoning run (implicit); for one reasoning run, the same subject will always result in the same skolem IRI. +### math:rounded ### {#math:rounded} +Calculates the object as the integer that is closest to the subject number. -`true` if and only if `$o` is a skolem IRI that is produced by applying a skolem function to the subject. +`true` if and only if `$o` is the integer that is closest to `$s`. +If there are two such numbers, then the one closest to positive infinity is returned. -**Schema**
`$s+ log:skolem $o-`

+ +**Schema**
`$s+ math:rounded $o-`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Generate a unique Skolem IRI from the list (:abc 77 "xyz") . +Calculate the rounded version of 3.3.

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . +@prefix xsd: . -{ (:abc 77 "xyz") log:skolem ?skolem . } => { :result :is ?skolem } . +:Let :param "3.3"^^xsd:double . + +{ + :Let :param ?param . + ?param math:rounded ?result . +} +=> +{ + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is . +:result :is 3. ```

-### log:uri ### {#log:uri} -Gets as object the string representation of the subject URI. +### math:sin ### {#math:sin} +Calculates the object as the sine value of the subject. -`true` if and only if `$o` is the string representation of `$s`. +`true` if and only if `$o` is the sine value of `$s`. -**Schema**
`$s? log:uri $o?`
where:
`$s`: (a URI)
`$o`: `xsd:string`

+**See also**
math:asin
math:sinh + +**Schema**
`$s? math:sin $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Parse the URI into a string . +Calculate the sin of pi/2 (1.57079632679) .

Formula: ``` @prefix : . -@prefix log: . +@prefix math: . +@prefix xsd: . -{ log:uri ?uri . } => { :result :is ?uri . } . +:Let :param "1.57079632679"^^xsd:double . + +{ + :Let :param ?param . + ?param math:sin ?result . +} +=> +{ + :result :is ?result . +} . ```

Result: ``` @prefix : . -:result :is "https://www.w3.org" . +@prefix xsd: . +:result :is "1.0"^^xsd:double . ```

-## math ## {#math} -### math:absoluteValue ### {#math:absoluteValue} -Calculates as object the absolute value of the subject. +### math:sinh ### {#math:sinh} +Calculates the object as the hyperbolic sine value of the subject. -`true` if and only if `$o` is the absolute value of `$s`. +`true` if and only if `$o` is the hyperbolic sine value of `$s`. -**Schema**
`$s+ math:absoluteValue $o-`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**See also**
math:sin
math:asin + +**Schema**
`$s? math:sinh $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the absolute value of the value -2. +Calculate the sinh of log(1 + sqrt(2)) (0.88137358701954302).

Formula: ``` @prefix : . @prefix math: . +@prefix xsd: . -:Let :param -2 . +:Let :param "0.88137358701954302"^^xsd:double. { :Let :param ?param . - ?param math:absoluteValue ?result . + ?param math:sinh ?result . } => { @@ -3012,24 +3024,22 @@ Calculate the absolute value of the value -2. ``` @prefix : . -:result :is 2. +:result :is 1.0. ```

-### math:acos ### {#math:acos} -Calculates the object as the arc cosine value of the subject. - -`true` if and only if `$o` is the arc cosine value of `$s`. +### math:sum ### {#math:sum} +Calculates the object as the sum of the numbers given in the subject list. -**See also**
math:cos
math:cosh +`true` if and only if `$o` is the arithmetic sum of all numbers `$s.i` -**Schema**
`$s? math:acos $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`( $s.i+ )+ math:sum $o-`
where:
`$s.i`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the arc cosine of the value 1. +Calculate the sum of 1,2,3,4,5,6,7,8,9,10.

Formula: ``` @@ -3037,11 +3047,11 @@ Calculate the arc cosine of the value 1. @prefix : . @prefix math: . -:Let :param 1 . +:Let :param (1 2 3 4 5 6 7 8 9 10) . { :Let :param ?param . - ?param math:acos ?result . + ?param math:sum ?result . } => { @@ -3053,36 +3063,37 @@ Calculate the arc cosine of the value 1. ``` @prefix : . -:result :is 0.0 . +:result :is 55. ```

-### math:asin ### {#math:asin} -Calculates the object as the arc sine value of the subject. +### math:tan ### {#math:tan} +Calculates the object as the tangent value of the subject. -`true` if and only if `$o` is the arc sine value of `$s`. +`true` if and only if `$o` is the tangent value of `$s`. -**See also**
math:sinh
math:sin +**See also**
math:tanh
math:atan -**Schema**
`$s? math:asin $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s? math:tan $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the arc sine of the value 1. +Calculate the tangent of the value 0.7853981633974483 .

Formula: ``` @prefix : . @prefix math: . +@prefix xsd: . -:Let :param 1 . +:Let :param "0.7853981633974483"^^xsd:double . { :Let :param ?param . - ?param math:asin ?result . + ?param math:tan ?result . } => { @@ -3094,36 +3105,38 @@ Calculate the arc sine of the value 1. ``` @prefix : . -:result :is 1.5707963267948966 . +@prefix xsd: . +:result :is "0.9999999999999999"^^xsd:double. ```

-### math:atan ### {#math:atan} -Calculates the object as the arc tangent value of the subject. +### math:tanh ### {#math:tanh} +Calculates the object as the hyperbolic tangent value of the subject. -`true` if and only if `$o` is the arc tangent value of `$s`. +`true` if and only if `$o` is the hyperbolic tangent value of `$s`. -**See also**
math:tan
math:tanh +**See also**
math:atan
math:tan -**Schema**
`$s? math:atan $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s? math:tanh $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the arc tangent of the value 1. +Calculate the hyperbolic tanget of 0.549306 .

Formula: ``` @prefix : . @prefix math: . +@prefix xsd: . -:Let :param 1 . +:Let :param "0.549306"^^xsd:double . { :Let :param ?param . - ?param math:atan ?result . + ?param math:tanh ?result . } => { @@ -3135,36 +3148,36 @@ Calculate the arc tangent of the value 1. ``` @prefix : . -:result :is 0.7853981633974483 . +@prefix xsd: . +:result :is "0.49999989174945103"^^xsd:double. ```

-### math:cos ### {#math:cos} -Calculates the object as the cosine value of the subject. - -`true` if and only if `$o` is the cosine value of `$s`. +## string ## {#string} +### string:concatenation ### {#string:concatenation} +Concatenates the strings from the subject list into a single string as object. -**See also**
math:acos
math:cosh +`true` if and only if the string concatenation of `$s.i` equals `$o`. -**Schema**
`$s? math:cos $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`( $s.i+ )+ string:concatenation $o-`
where:
`$s.i`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the cosine of the value 0. +Concatenates the string "hello", " " and "world!".

Formula: ``` @prefix : . -@prefix math: . +@prefix string: . -:Let :param 0 . +:Let :param ( "hello" " " "world!" ) . { :Let :param ?param . - ?param math:cos ?result . + ?param string:concatenation ?result . } => { @@ -3176,40 +3189,41 @@ Calculate the cosine of the value 0. ``` @prefix : . -:result :is 1.0 . +:result :is "hello world!". ```

-### math:cosh ### {#math:cosh} -Calculates the object as the hyperbolic cosine value of the subject. +### string:contains ### {#string:contains} +Checks whether the subject string contains the object string. -`true` if and only if `$o` is the hyperbolic cosine value of `$s`. +`true` if and only if `$s` contains `$o`. -**See also**
math:acos
math:cos +**See also**
string:containsIgnoringCase -**Schema**
`$s? math:cosh $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:contains $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the hyperbolic cosine of the value 0. +Checks whether the string "hello world!" contains the string "llo worl".

Formula: ``` @prefix : . -@prefix math: . - -:Let :param 0 . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 "llo worl". { - :Let :param ?param . - ?param math:cosh ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:contains ?param2 . } => { - :result :is ?result . + :result :is true . } . ``` @@ -3217,38 +3231,41 @@ Calculate the hyperbolic cosine of the value 0. ``` @prefix : . -:result :is 1.0 . +:result :is true . ```

-### math:degrees ### {#math:degrees} -Calculates the object as the value in degrees corresponding to the radians value of the subject. +### string:containsIgnoringCase ### {#string:containsIgnoringCase} +Checks whether the subject string contains the object string, ignoring differences between lowercase and uppercase. -`true` if and only if `$o` is the value in degrees corresponding to the radians value of `$s`. +`true` if and only if `$s` contains `$o` when ignoring case differences. -**Schema**
`$s? math:degrees $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**See also**
string:contains + +**Schema**
`$s+ string:containsIgnoringCase $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the degrees of the radians value 1.57079632679. +Checks whether the string "hello world!" contains the string "lLO woRl".

Formula: ``` @prefix : . -@prefix math: . - -:Let :param 1.57079632679 . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 "lLO woRl". { - :Let :param ?param . - ?param math:degrees ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:containsIgnoringCase ?param2 . } => { - :result :is ?result . + :result :is true . } . ``` @@ -3256,38 +3273,39 @@ Calculate the degrees of the radians value 1.57079632679. ``` @prefix : . -:result :is 89.99999999971946 . +:result :is true . ```

-### math:difference ### {#math:difference} -Calculates the object by subtracting the second number from the first number given in the subject list. +### string:endsWith ### {#string:endsWith} +Checks whether the subject string ends with the object string. -`true` if and only if `$o` is the result of subtracting `$s.2` from `$s.1`. +`true` if and only if `$s` ends with `$o`. -**Schema**
`( $s.1+ $s.2+ )+ math:difference $o-`
where:
`$s.1`: (`xsd:decimal` | `xsd:double` | `xsd:float`), `$s.2`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:endsWith $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the value of 7 minus 2. +Checks whether the string "hello world!" ends with "orld!".

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (7 2) . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 "orld!". { - :Let :param ?param . - ?param math:difference ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:endsWith ?param2 . } => { - :result :is ?result . + :result :is true . } . ``` @@ -3295,36 +3313,35 @@ Calculate the value of 7 minus 2. ``` @prefix : . -:result :is 5. +:result :is true . ```

-### math:equalTo ### {#math:equalTo} -Checks whether the subject and object are the same number. - -`true` if and only if `$s` is the same number as `$o`. +### string:equalIgnoringCase ### {#string:equalIgnoringCase} +Checks whether the subject string is the same as the object string, ignoring differences between lowercase and uppercase. -**See also**
math:notEqualTo +`true` if and only if `$s` is the same string as `$o` when ignoring case differences. -**Schema**
`$s? math:equalTo $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:equalIgnoringCase $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check if the numbers 42 and 42 are equal . +Checks whether the string "hello world!" is equal to "hELLo wORld!" ignoring the case .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (42 42) . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 "hELLo wORld!" . { - :Let :param (?X ?Y) . - ?X math:equalTo ?Y . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:equalIgnoringCase ?param2 . } => { @@ -3342,26 +3359,29 @@ Check if the numbers 42 and 42 are equal .

-### math:exponentiation ### {#math:exponentiation} -Calculates the object as the result of raising the first number to the power of the second number in the subject list. -You can also use this to calculate the logarithm of the object, with as base the first number of the subject list (see examples). +### string:format ### {#string:format} +Calculates the object as the result of replacing the tags in the first string from the subject list with the remaining strings from the subject list. +See C's sprintf function for details on these tags. -`true` if and only if `$o` is the result of raising `$s.1` to the power of `$s.2` +`true` if and only if `$o` is the result of replacing the tags found in `$s.(i=1)` with the strings `$s.(i>1)` -**Schema**
`( $s.1+ $s.2? )+ math:exponentiation $o?`
where:
`$s.1`: (`xsd:decimal` | `xsd:double` | `xsd:float`), `$s.2`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`( $s.i+ )+ string:format $o-`
where:
`$s.i`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the logarithm of 49 base 2 . +Calculate the result of applying the format "%s://%s/%s" to the strings "https", "w3c.github.io" and "N3/spec" .

Formula: ``` @prefix : . -@prefix math: . +@prefix string: . + +:Let :param ( "%s://%s/%s" "https" "w3c.github.io" "N3/spec/" ) . { - (7 ?result) math:exponentiation 49 . + :Let :param ?param . + ?param string:format ?result . } => { @@ -3373,31 +3393,41 @@ Calculate the logarithm of 49 base 2 . ``` @prefix : . -:result :is 2.0 . +:result :is "https://w3c.github.io/N3/spec/". ```

-
-try in editor 🚀
+ +### string:greaterThan ### {#string:greaterThan} +Checks whether the subject string is greater than the object string, according to Unicode code order. + +`true` if and only if `$s` is greater than `$o` as per the Unicode code order. + +**See also**
string:notGreaterThan + +**Schema**
`$s+ string:greaterThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

+**Examples**
+try in editor 🚀

-Calculate the value of 7 raised to the power of 2 . +Checks whether the string "Pengiun" is greater than the string "Cat" .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (7 2) . +@prefix string: . +:Let :param1 "Penguin" . +:Let :param2 "Cat". { - :Let :param ?param . - ?param math:exponentiation ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:greaterThan ?param2 . } => { - :result :is ?result . + :result :is true . } . ``` @@ -3405,36 +3435,37 @@ Calculate the value of 7 raised to the power of 2 . ``` @prefix : . -:result :is 49 . +:result :is true . ```

-### math:greaterThan ### {#math:greaterThan} -Checks whether the subject is a number that is greater than the object. +### string:lessThan ### {#string:lessThan} +Checks whether the subject string is less than the object string, according to Unicode code order. -`true` if and only if `$s` is a number that is greater than `$o`. +`true` if and only if `$s` is less than `$o` as per the Unicode code order. -**See also**
math:notGreaterThan +**See also**
string:notLessThan -**Schema**
`$s+ math:greaterThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:lessThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check if 42 is greater than 41 . +Checks whether the string "Cat" is less than the string "Penguin" .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (42 41) . +@prefix string: . +:Let :param1 "Cat" . +:Let :param2 "Penguin". { - :Let :param (?X ?Y) . - ?X math:greaterThan ?Y . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:lessThan ?param2 . } => { @@ -3446,36 +3477,38 @@ Check if 42 is greater than 41 . ``` @prefix : . -:result :is true . +:result :is true . ```

-### math:lessThan ### {#math:lessThan} -Checks whether the subject is a number that is less than the object. +### string:matches ### {#string:matches} +Checks whether the subject string matches the object regular expression. +The regular expression follows the perl, python style. -`true` if and only if `$s` is a number that is less than `$o`. +`true` if and only if string `$s` matches the regular expression `$o` -**See also**
math:notLessThan +**See also**
string:notMatches -**Schema**
`$s+ math:lessThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:matches $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check if 41 is less than 42 . +Checks whether the string "hello world!" matches the regular expression ".*(l)+o wo.*".

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (41 42) . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 ".*(l)+o wo.*". { - :Let :param (?X ?Y) . - ?X math:lessThan ?Y . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:matches ?param2 . } => { @@ -3487,38 +3520,39 @@ Check if 41 is less than 42 . ``` @prefix : . -:result :is true . +:result :is true . ```

-### math:negation ### {#math:negation} -Calculates the object as the negation of the subject. +### string:notEqualIgnoringCase ### {#string:notEqualIgnoringCase} +Checks whether the subject string is not the same as the object string, ignoring differences between lowercase and uppercase. -`true` if and only if `$o` is the negation of `$s`. +`true` if and only if `$s` is not the same string as `$o` when ignoring case differences. -**Schema**
`$s? math:negation $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:notEqualIgnoringCase $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the negation of the value 42 . +Checks whether the string "hello world!" is not equal to "hELLo dunia!" ignorning the case .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param 42 . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 "hELLo dunia!" . { - :Let :param ?param . - ?param math:negation ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:notEqualIgnoringCase ?param2 . } => { - :result :is ?result . + :result :is true . } . ``` @@ -3526,36 +3560,38 @@ Calculate the negation of the value 42 . ``` @prefix : . -:result :is -42 . +:result :is true . ```

-### math:notEqualTo ### {#math:notEqualTo} -Checks whether the subject and object are not the same number. +### string:notGreaterThan ### {#string:notGreaterThan} +Checks whether the subject string is not greater than the object string, according to Unicode code order. +You can use this as an equivalent of a lessThanOrEqual operator. -`true` if and only if `$s` is the not same number as `$o`. +`true` if and only if `$s` is not greater than `$o` as per the Unicode code order. -**See also**
math:equalTo +**See also**
string:greaterThan -**Schema**
`$s+ math:notEqualTo $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:notGreaterThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check if the numbers 41 and 42 are not equal . +Checks whether the string "Cat" is not greater than the string "Penguin" .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (41 42) . +@prefix string: . +:Let :param1 "Cat" . +:Let :param2 "Penguin". { - :Let :param (?X ?Y) . - ?X math:notEqualTo ?Y . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:notGreaterThan ?param2 . } => { @@ -3567,37 +3603,38 @@ Check if the numbers 41 and 42 are not equal . ``` @prefix : . -:result :is true . +:result :is true . ```

-### math:notGreaterThan ### {#math:notGreaterThan} -Checks whether the subject is a number that is not greater than the object. -You can use this as an equivalent of a lessThanOrEqual operator. +### string:notLessThan ### {#string:notLessThan} +Checks whether the subject string is not less than the object string, according to Unicode code order. +You can use this as an equivalent of a greaterThanOrEqual operator. -`true` if and only if `$s` is a number that is not greater than `$o`. +`true` if and only if `$s` is not less than `$o` as per the Unicode code order. -**See also**
math:greaterThan +**See also**
string:lessThan -**Schema**
`$s+ math:notGreaterThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:notLessThan $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check if 41 is not greater than 42 . +Checks whether the string "Penguin" is not less than the string "Cat" .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (41 42) . +@prefix string: . +:Let :param1 "Penguin". +:Let :param2 "Cat" . { - :Let :param (?X ?Y) . - ?X math:notGreaterThan ?Y . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:notLessThan ?param2 . } => { @@ -3609,37 +3646,38 @@ Check if 41 is not greater than 42 . ``` @prefix : . -:result :is true . +:result :is true . ```

-### math:notLessThan ### {#math:notLessThan} -Checks whether the subject is a number that is not less than the object. -You can use this as an equivalent of a greaterThanOrEqual operator. +### string:notMatches ### {#string:notMatches} +Checks whether the subject string does not match the object regular expression. +The regular expression follows the perl, python style. -`true` if and only if `$s` is a number that is not less than `$o`. +`true` if and only if string `$s` does not match the regular expression `$o` -**See also**
math:lessThan +**See also**
string:matches -**Schema**
`$s+ math:notLessThan $o+`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:notMatches $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Check if 42 is not less than 41 . +Checks whether the string "hello world!" no matches the regular expression ".*(l)+o dunia.*".

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (42 41) . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 ".*(l)+o dunia.*". { - :Let :param (?X ?Y) . - ?X math:notLessThan ?Y . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:notMatches ?param2 . } => { @@ -3651,34 +3689,37 @@ Check if 42 is not less than 41 . ``` @prefix : . -:result :is true . +:result :is true . ```

-### math:product ### {#math:product} -Calculates the object as the product of the numbers given in the subject list. +### string:replace ### {#string:replace} +Calculates the object as the result of, given the strings in the subject list, replacing all occurrences of the second string in the first string with the third string. -`true` if and only if `$o` is the arithmetic product of all numbers `$s.i` +`true` if and only if `$o` is the result of replacing all occurrences of `$s.2` in `$s.1` with `$s.3` -**Schema**
`( $s.i+ )+ math:product $o-`
where:
`$s.i`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`( $s.1+ $s.2+ $s.3+ )+ string:replace $o-`
where:
`$s.1`: `xsd:string`, `$s.2`: `xsd:string`, `$s.3`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the product of 2,4,6, and 8 . +Replace all "l"-s in the string "hello world!" with the bracket version "[l]" .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (2 4 6 8) . +@prefix string: . +:Let :data "hello world!" . +:Let :search "(l)" . +:Let :replace "[$1]" . { - :Let :param ?param . - ?param math:product ?result . + :Let :data ?data . + :Let :search ?search . + :Let :replace ?replace . + (?data ?search ?replace) string:replace ?result . } => { @@ -3690,27 +3731,35 @@ Calculate the product of 2,4,6, and 8 . ``` @prefix : . -:result :is 384. +:result :is "he[l][l]o wor[l]d!". ```

-
-try in editor 🚀
+ +### string:scrape ### {#string:scrape} +Calculates the object as the first matching group when, given the subject list, matching the second string as regular expression (with exactly 1 group) against the first string. + +`true` if and only if `$o` is the first matching group when matching `$s.2` as a regular expression against `$s.1` + +**Schema**
`( $s.1+ $s.2+ )+ string:scrape $o-`
where:
`$s.1`: `xsd:string`, `$s.2`: `xsd:string`
`$o`: `xsd:string`

+**Examples**
+try in editor 🚀

-Calculate the product of 2 and 21. +Extract from the string "https://w3c.github.io/N3/spec/" the last path element using a regular expression .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (2 21) . +@prefix string: . +:Let :param1 "https://w3c.github.io/N3/spec/" . +:Let :param2 ".*/([^/]+/)$" . { - :Let :param ?param . - ?param math:product ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + (?param1 ?param2) string:scrape ?result . } => { @@ -3722,38 +3771,39 @@ Calculate the product of 2 and 21. ``` @prefix : . -:result :is 42. +:result :is "spec/". ```

-### math:quotient ### {#math:quotient} -Calculates the object by dividing the first number by the second number given in the subject list. +### string:startsWith ### {#string:startsWith} +Checks whether the subject string starts with the object string. -`true` if and only if `$o` is the result of dividing `$s.1` by `$s.2`. +`true` if and only if `$s` starts with `$o`. -**Schema**
`( $s.1+ $s.2+ )+ math:quotient $o-`
where:
`$s.1`: (`xsd:decimal` | `xsd:double` | `xsd:float`), `$s.2`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ string:startsWith $o+`
where:
`$s`: `xsd:string`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the quotient of 42 and 2. +Checks whether the string "hello world!" starts with "hello" .

Formula: ``` @prefix : . -@prefix math: . - -:Let :param (42 2) . +@prefix string: . +:Let :param1 "hello world!" . +:Let :param2 "hello". { - :Let :param ?param . - ?param math:quotient ?result . + :Let :param1 ?param1 . + :Let :param2 ?param2 . + ?param1 string:startsWith ?param2 . } => { - :result :is ?result . + :result :is true . } . ``` @@ -3761,34 +3811,36 @@ Calculate the quotient of 42 and 2. ``` @prefix : . -:result :is 21. +:result :is true . ```

-### math:remainder ### {#math:remainder} -Calculates the object as the remainder of the division of the first integer by the second integer given in the subject list. +## time ## {#time} +### time:day ### {#time:day} +Gets as object the integer day component of the subject xsd:dateTime. -`true` if and only if `$o` is the remainder of dividing `$s.1` by `$s.2`. +`true` if and only if `$o` is the integer day component of `$s`. -**Schema**
`( $s.1+ $s.2+ )+ math:remainder $o-`
where:
`$s.1`: `xsd:integer`, `$s.2`: `xsd:integer`
`$o`: `xsd:integer`

+**Schema**
`$s+ time:day $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the remainder of 10 divided by 3. +Return the day component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . +@prefix xsd: . +@prefix time: . -:Let :param (10 3) . +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:remainder ?result . + ?param time:day ?result . } => { @@ -3800,37 +3852,35 @@ Calculate the remainder of 10 divided by 3. ``` @prefix : . -:result :is 1. +:result :is 1. ```

-### math:rounded ### {#math:rounded} -Calculates the object as the integer that is closest to the subject number. - -`true` if and only if `$o` is the integer that is closest to `$s`. -If there are two such numbers, then the one closest to positive infinity is returned. +### time:hour ### {#time:hour} +Gets as object the integer hour component of the subject xsd:dateTime. +`true` if and only if `$o` is the integer hour component of `$s`. -**Schema**
`$s+ math:rounded $o-`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: `xsd:integer`

+**Schema**
`$s+ time:hour $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the rounded version of 3.3. +Return the hour component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . -@prefix xsd: . +@prefix xsd: . +@prefix time: . -:Let :param "3.3"^^xsd:double . +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:rounded ?result . + ?param time:hour ?result . } => { @@ -3842,37 +3892,35 @@ Calculate the rounded version of 3.3. ``` @prefix : . -:result :is 3. +:result :is 18. ```

-### math:sin ### {#math:sin} -Calculates the object as the sine value of the subject. - -`true` if and only if `$o` is the sine value of `$s`. +### time:minute ### {#time:minute} +Gets as object the integer minutes component of the subject xsd:dateTime. -**See also**
math:sinh
math:asin +`true` if and only if `$o` is the integer minutes component of `$s`. -**Schema**
`$s? math:sin $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ time:minute $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the sin of pi/2 (1.57079632679) . +Return the minute component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . -@prefix xsd: . +@prefix xsd: . +@prefix time: . -:Let :param "1.57079632679"^^xsd:double . +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:sin ?result . + ?param time:minute ?result . } => { @@ -3884,38 +3932,35 @@ Calculate the sin of pi/2 (1.57079632679) . ``` @prefix : . -@prefix xsd: . -:result :is "1.0"^^xsd:double . +:result :is 6. ```

-### math:sinh ### {#math:sinh} -Calculates the object as the hyperbolic sine value of the subject. - -`true` if and only if `$o` is the hyperbolic sine value of `$s`. +### time:month ### {#time:month} +Gets as object the integer month component of the subject xsd:dateTime. -**See also**
math:sin
math:asin +`true` if and only if `$o` is the integer month component of `$s`. -**Schema**
`$s? math:sinh $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ time:month $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the sinh of log(1 + sqrt(2)) (0.88137358701954302). +Return the month component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . -@prefix xsd: . +@prefix xsd: . +@prefix time: . -:Let :param "0.88137358701954302"^^xsd:double. +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:sinh ?result . + ?param time:month ?result . } => { @@ -3927,34 +3972,35 @@ Calculate the sinh of log(1 + sqrt(2)) (0.88137358701954302). ``` @prefix : . -:result :is 1.0. +:result :is 4. ```

-### math:sum ### {#math:sum} -Calculates the object as the sum of the numbers given in the subject list. +### time:second ### {#time:second} +Gets as object the integer seconds component of the subject xsd:dateTime. -`true` if and only if `$o` is the arithmetic sum of all numbers `$s.i` +`true` if and only if `$o` is the integer seconds component of `$s`. -**Schema**
`( $s.i+ )+ math:sum $o-`
where:
`$s.i`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ time:second $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the sum of 1,2,3,4,5,6,7,8,9,10. +Return the seconds component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . +@prefix xsd: . +@prefix time: . -:Let :param (1 2 3 4 5 6 7 8 9 10) . +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:sum ?result . + ?param time:second ?result . } => { @@ -3966,37 +4012,35 @@ Calculate the sum of 1,2,3,4,5,6,7,8,9,10. ``` @prefix : . -:result :is 55. +:result :is 4. ```

-### math:tan ### {#math:tan} -Calculates the object as the tangent value of the subject. - -`true` if and only if `$o` is the tangent value of `$s`. +### time:timeZone ### {#time:timeZone} +Gets as object the trailing timezone offset of the subject xsd:dateTime (e.g., "-05:00"). -**See also**
math:atan
math:tanh +`true` if and only if `$o` is the timezone offset of `$s`. -**Schema**
`$s? math:tan $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ time:timeZone $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:string`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the tangent of the value 0.7853981633974483 . +Return the time zone component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . -@prefix xsd: . +@prefix xsd: . +@prefix time: . -:Let :param "0.7853981633974483"^^xsd:double . +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:tan ?result . + ?param time:minute ?result . } => { @@ -4008,38 +4052,35 @@ Calculate the tangent of the value 0.7853981633974483 . ``` @prefix : . -@prefix xsd: . -:result :is "0.9999999999999999"^^xsd:double. +:result :is "Z". ```

-### math:tanh ### {#math:tanh} -Calculates the object as the hyperbolic tangent value of the subject. - -`true` if and only if `$o` is the hyperbolic tangent value of `$s`. +### time:year ### {#time:year} +Gets as object the integer year component of the subject xsd:dateTime. -**See also**
math:tan
math:atan +`true` if and only if `$o` is the integer year component of `$s`. -**Schema**
`$s? math:tanh $o?`
where:
`$s`: (`xsd:decimal` | `xsd:double` | `xsd:float`)
`$o`: (`xsd:decimal` | `xsd:double` | `xsd:float`)

+**Schema**
`$s+ time:year $o-`
where:
`$s`: `xsd:dateTime`
`$o`: `xsd:integer`

**Examples**
-try in editor 🚀
+try in editor 🚀

-Calculate the hyperbolic tanget of 0.549306 . +Return the minute component of the date "2023-04-01T18:06:04Z" .

Formula: ``` @prefix : . -@prefix math: . -@prefix xsd: . +@prefix xsd: . +@prefix time: . -:Let :param "0.549306"^^xsd:double . +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . { :Let :param ?param . - ?param math:tanh ?result . + ?param time:year ?result . } => { @@ -4051,8 +4092,7 @@ Calculate the hyperbolic tanget of 0.549306 . ``` @prefix : . -@prefix xsd: . -:result :is "0.49999989174945103"^^xsd:double. +:result :is 2023. ```

diff --git a/spec/src/time/hour.n3 b/spec/src/time/hour.n3 new file mode 100644 index 0000000..aef40a5 --- /dev/null +++ b/spec/src/time/hour.n3 @@ -0,0 +1,56 @@ +@prefix fnon: . +@prefix time: . +@prefix log: . +@prefix dcterms: . +@prefix fno: . +@prefix rdf: . +@prefix rdfs: . +@prefix vs: . +@prefix xsd: . + +time:hour a fno:Function ; + vs:term_status "testing" ; + fnon:tldr "Gets as object the integer hour component of the subject xsd:dateTime." ; + dcterms:comment """`true` if and only if `$o` is the integer hour component of `$s`.""" ; + fno:example ( + [ a fno:Test , fno:TestSkip ; + dcterms:description """ +Return the hour component of the date "2023-04-01T18:06:04Z" . + """ ; + rdfs:seeAlso <> ; + fno:expression """ +@prefix : . +@prefix xsd: . +@prefix time: . + +:Let :param "2023-04-01T18:06:04Z"^^xsd:dateTime . + +{ + :Let :param ?param . + ?param time:hour ?result . +} +=> +{ + :result :is ?result . +} . + """ ; + fno:result """ +@prefix : . +:result :is 18. + """ + ] + ) ; + fno:name "hour" ; + fno:parameter ( [ + a fno:Parameter ; + fno:predicate "$s" ; + fno:mode "+" ; + fnon:position fnon:subject ; + fno:type xsd:dateTime + ] [ + a fno:Parameter ; + fno:predicate "$o" ; + fno:mode "-" ; + fnon:position fnon:object ; + fno:type xsd:integer + ] ) .