Specification of particular KRL notations

Dr Ph. MARTIN

This document mixes HTML and FL (a KRL, i.e., a Knowledge Representation Language; it is here used in the preformatted text parts). It is an input+backup+presentation file for the Multi-Source Ontology (MSO). The MSO  i) aligns and extends several ontologies, and  ii) can be extended by Web users via the shared KB server WebKB-2 and its shared KB (knowledge base) editing protocols.
In this document, for supertype links, "/^" is used instead of the more common "<" symbol.
Similarly, for subtype links, "\." is used instead of the more common ">" symbol.

The ontology in this document is original. Some content is added to it from time to time.
It is part of complementary "ontologies on formal languages":

The goals, underlying ideas, conventions and content of these ontologies are explained and illustrated in this article.


Table of contents

0.  Relations between particular KRL notations     (figure)

1.  KRL notation that is mostly not graph based
    1.1.  Prefix operator based KRL notation
        1.1.1.  RIF-PS
        1.1.2.  CLIF
        1.1.3.  KIF
        1.1.4.  OWL Functional-Style Syntax (FSS)
    1.2.  Infix operator based KRL notation
        1.2.1.  N-Triples
        1.2.2.  N-Quads

2.  KRL notation that is mostly graph based
    2.1.  KRL notation mostly graph based but not markup based
        2.1.1.  The notation of JSON-LD
    2.2.  KRL notation mostly graph based and markup based
        2.2.1.  RDF/XML




0.  Relations between particular KRL notations     (figure)


KRL_notation 
 \. exclusion
    { (KRL-notation_mostly_non_graph_based
        = KRL-notation_mostly_relation_based 
          KRL-notation_mostly_based_on_an_AND-set_of_statements_with_an_operator_and_its_arguments
          KRL-notation_mostly_based_on_positional_or_named_arguments,
        \. exclusion
           { KRL-notation_that_is_mainly_postfix-based
             (KRL-notation_that_is_mainly_infix-based
               \. N-triples  N-Quads )
             (KRL-notation_that_is_mainly_prefix-based  //the operator appears first
               \. exclusion
                  { (S-expression_based_KRL-notation
                      = KRL-notation_based_on_list-like_operators-with-parameters,
                      \. (Second-order_S-expression_based_KRL-notation
                            r_model_type: Higher-order-logic_model, 
                            \. (KIF_notation = LISP_based_KIF  KIF, r_model_type: KIF_model ) )
                         (First-order_S-expression_based_KRL-notation \. CLIF  CGIF))
                    (M-expression_based_KRL-notation
                      = KRL-notation_based_on_function-like_prefix_operators-with-parameters,
                      \. (RIF_PS  r_model_type: RIF, 
                           \. (RIF-FLD_PS  r_model_type: RIF-FLD)
                              (RIF-BLD_PS  r_model_type: RIF-BLD)
                              (RIF-Core_PS r_model_type: RIF-Core) )
                         (OWL_Functional-Style-Syntax  r_model_type: OWL2) )
                  } )
           } )
      (KRL-notation_mostly_graph_based
        = KRL-notation_mostly_concept_node_based  KRL-notation_mostly_object_based,
        \. exclusion
           { (KRL-notation_mostly_graph_based_and_markup_based
               \. (XML_based_notation
                    \.  (RDF/XML r_model_type: RDF)  (XCL r_model_type: CL)
                        (RIF/XML  r_model_type: RIF, 
                          \. (RIF-FLD/XML  r_model_type: RIF-FLD)
                             (RIF-BLD/XML  r_model_type: RIF-BLD)
                             (RIF-Core/XML r_model_type: RIF-Core) ) ) ) 
             (KRL-notation_mostly_graph_based_but_not_markup_based 
               \. (Turtle  r_model_type: RDF)  (Turtle r_part-type: N-triples)
                  (Notation3 r_part-type: Turtle)
                  (JSON-LD_notation  r_model_type: JSON-LD_model)
                  (CGLF  r_model_type: Higher-order-logic_model)
                  (FL r_model_type: FL_model) )
           } )
    };




1. KRL notation that is mostly not graph based


1.1.  Prefix operator based KRL notation

S-expression_based_KRL-notation  /* cf. S-expression ('S' for "Symbolic") */
 \. (Parenthesis_delimited_S-expression_based_KRL-notation
       = ^(KRL_notation ?n  r_KRL of: 1..* ^(CE  rc of=: (an AE ?ae
                 rc_spec: fc_spec_(.[ "(" fc_OP_from_(?ae)
                                          fc_ARGS_from_(?ae) ")" ],.{?n} ) ) )
          );  

M-expression-like_based_KRL-notation  /* cf. M-expression ('M' for "Mathematics") */
 \. (Parenthesis_delimited_M-expression_based_KRL-notation
       = ^(KRL_notation ?n  r_KRL of: 1..* ^(CE  rc of=: (an AE ?ae
                 rc_spec: fc_spec_(.[ fc_OP_from_(?ae)   "("
                                      fc_ARGS_from_(?ae) ")" ],.{?n} ) ) )
          ) ); 


1.1.1.  RIF-PS

RIF-PS uses a function-style presentation for relationships except for rules.
However, RIF-PS is not particularly regular and hence its grammars (for RIF-FLD, RIF-BLD, ...) are not short.
In other words, RIF-PS is not defined via 1 (or a few) grammar rules and an ontology.
This is why its specifications below are not short either.

//--------- STRUCTURES:
Abstract_element@RIF ?a  /* this figure illustrates the first relations */
  rc_spec:  fc_spec_(.[ fc_OP_from_(?a) "(" fc_ARGS_from_(?a) ")" ],.{RIF_PS}),  //by default
  \. (RIF_abstract_element_that_has_also_and_preferably_an_infix_presentation_in_RIF_PS ?i
        rc_spec: fc_spec _(.[fc_ARG_(?i.r_link_source)  fc_OP_from(?i)
                             fc_ARG_(?i.r_link_destination) ], .{RIF_PS} ),
        \. Rule@RIF  Equality@RIF  Typing@RIF  Supertyping@RIF )
     (RIF_abstract_element_displayed_as_a_whitespace_separated_list_of_elements_in_RIF_PS ?sl
        rc_spec: fc_spec _(.[fc_ARGS_(?sl)], .{RIF_PS}),
        \. RIF_document_context  Quantification_guard_list  Quantification_variable_list )
     (RIF_module_context_link ?l
        rc: only ^(Concrete_element  r_part of: RIF_PS,   //reminder:  rc = r_CE
        rc of: Module_context@RIF), //no direct display
        rc_spec: fc_spec _(.[fc_ARG_(?l.r_link_destination)],
                           .{RIF_PS} ), //only the destination is shown
     (Annotation@RIF ?a  rc_spec: fc_spec _(.[fc_OP_from_(?a) fc_ARG_from_(?a) ],.{RIF_PS}) )
     (RIF_annotation_link ?l 
       rc_spec: fc_spec _(.["(*" fc_ARG_(?l.r_link_destination) "*)"  fc_OP_(?l.r_link_source) ],
                          .{RIF_PS} ) );

//reminder: Document@RIF-FLD = f_link_type_("",r_context,Module_body@RIF,Module_context@RIF-FLD)); 
//   Document ::= IRIMETA? 'Document' '(' Base? Prefix* Import* Group? ')'
Document@RIF ?d 
  rc_spec: fc_spec _(.[fc_op_("Document") "(" fc_ARG_(?d.r_link_destination)
                                              fc_ARG_(?d.r_link_source) ")" ], .{RIF_PS} );
Module_context@RIF ?mc 
  rc_spec: fc_spec _(.[fc_ARGS(.[every ^(Phrase r_part of: ?mc, /^ Module_dialect_link@RIF-FLD)])
                       fc_ARGS(.[every ^(Phrase r_part of: ?mc, /^ Module_base_IRI_link@RIF-FLD)])
                       fc_ARGS(.[every ^(Phrase r_part of: ?mc, /^ rif#Prefix)])
                       fc_ARGS(.[every ^(Phrase r_part of: ?mc, /^ Module_import_link@RIF)])
                       fc_ARGS(.[every ^(Phrase r_part of: ?mc, /^ Remote_module_naming_link@RIF-FLD)])
                      ], .{RIF_PS} );


r_not  rc_type .: fc_spec _(.["Neg"], .{RIF_PS});

Frame@RIF ?f  
  rc_spec: fc_spec _(.[fc_OP_from(?f) '[' fc_ARGS_from(?f) ']' ], .{RIF_PS});

Half_link@RIF   rc_spec: fc_spec _(.[fc_OP_from(?f) "->" fc_ARG(?f)], .{RIF_PS});

Named_argument@RIF ?na rc_spec: fc_spec_(.[fc_ARG_from(?na) "->" fc_OP_from(?na)], .{RIF_PS});


//--------- REFERENCES and VALUES:
Constant@RIF  rc_spec: w3c_constant_ct;
String_value_token@RIF  rc_spec: String_delimited_by_escapable_double_quote;

Variable@RIF  rc_spec: w3c#Var,  /^ Explicitly_bound_variable;
Name@RIF  rc_spec: w3c#Name;
Importation_profile@RIF  rc_spec: w3c_IRI_within_angle_brackets;

Aggregate_function@RIF ?a 
  rc_spec: fc_spec _(.[fc_OP_from_(?a) "{" fc_ARGS_from_(?a,"|") "}"],.{RIF_PS});
Aggregate_function_bound_list@RIF ?bl
  rc_spec: fc_spec _(.[fc_OP_from_(?bl) "[" fc_ARGS_from_(?bl) "]"],.{RIF_PS}); 

Open_list@RIF ?f  rc_spec: fc_spec_(.[fc_OP("List") "(" fc_ARG_from(?f)], .{RIF_PS});
Open_list_sequence_variable@RIF  rc_spec: fc_spec_(.["|" fc_OP_from_(?f)], .{RIF_PS});

Structured_reference_to_a_element_in_a_remote_module@RIF ?r
  rc_spec: fc_spec_(.[fc_OP_from(?r) "@" fc_ARG_from(?r)], .{RIF_PS});

Structured_reference_to_externally_defined_element@RIF ?r
  rc_spec: fc_spec_(.[fc_OP("External") "(" fc_OP_from_(?r) fc_ARG_from(?r) ")" ], .{RIF_PS});


1.1.2.  CLIF

See the ISO/IEC document of 2007 on CL.
 
//--------- STRUCTURES:  
Abstract_element@CL ?a
  rc_spec:  fc_spec_(.[ "(" fc_OP_from_(?a) fc_ARGS_from_(?a) ")" ],.{CLIF}),
  \. (CL_abstract_element_presented_in_CLIF_via_its_arguments_separated_by_spaces
        rc_spec: fc_spec _(.[fc_ARGS_(?sl)], .{CLIF}),
        \. Module_body@CL  cl#Module_context  Excluded_elements  cl#Sub-phrase_list )
     (CL_link_for_which_only_the_destination_is_presented_in_CLIF ?l
        rc_spec: fc_spec _(.[fc_ARG_(?l.r_link_destination)], .{CLIF}),
        \. cl#Module_name_link_in_module_context );

^(cl#Text  r_link_destination: (a Module_context  r_part: a Module_name_link ?l)) ?t
    rc_spec: fc_spec_(.[ "(" fc_OP_("cl:text")  fc_ARG_(?l.r_link_destination)
                             fc_ARGS_( (.[every ^(Phrase r_part of: ?t, != ?l)] /^ cl#Sub_phrases) )
                         ")" ],.{CLIF} );                               
^(cl#Text  r_link_destination: (a Module_context  r_part: 0 Module_name_link)) ?t
    rc_spec: fc_spec_(.[ fc_ARG_(?t.r_destination) ],.{CLIF} );

^(cl#Module  r_link_destination: (a Module_context
                                    r_part: 1 Module_name_link ?l
                                            0 Module_excluded_element_link )) ?m
    rc_spec: fc_spec_(.[ "(" fc_OP_("cl:module") fc_ARG_(?l.r_link_destination)
                             fc_ARGS_( (.[every ^(Phrase r_part of: ?m, != ?l)] /^ cl#Sub_phrases) )
                         ")" ],.{CLIF} );
^(cl#Module  r_link_destination: (a Module_context
                                   r_part: 1 Module_name_link ?l
                                           1 Module_excluded_element_link ?et)) ?m
    rc_spec: fc_spec_(.[ "(" fc_OP_("cl:module") fc_ARG_(?l.r_link_destination)
                             fc_ARG_(?et /^ cl#Module_excluded_element_link_in_module_context)
                             fc_ARGS_( (.[every ^(Phrase r_part of: ?m, != ?l)] /^ cl#Sub-phrase_list) )
                         ")" ],.{CLIF} );
cl#Module_excluded_element_link_in_module_context ?l
  rc_spec: fc_spec_(.[ "(" fc_OP_("cl:excludes")  fc_ARGS_(?l.r_link_destination) ")" ],.{CLIF});

^(Module_import_link r_member of: a cl#Sub-phrase_list) ?l
  rc_spec: fc_spec_(.[ "(" fc_OP_("cl:imports")  fc_ARGS_(?l.r_link_destination) ")" ],.{CLIF});

^(CLIF_annotation_link ?l = f_link_type _("",r_annotation,Phrase,String@CL),
   rc_spec: fc_spec _(.["(" fc_OP_("cl:comment") fc_ARG_(?l.r_link_destination)
                                                 fc_ARG_(?l.r_link_source) ")" ],.{CLIF});



1.1.3.  KIF

Abstract_element@KIF_model ?a 
  rc_spec:  fc_spec_(.[ "(" fc_OP_from_(?a) fc_ARGS_from_(?a) ")" ],.{KIF});


1.1.4.  OWL Functional-Style Syntax (FSS)

OWL_Functional-Style-Syntax  r_short_name: FSS;

^(Abstract_element@OWL  not r_operator: r_member) ?a
  rc_spec:  fc_spec_(.[ fc_OP_from_(?a) "(" fc_ARGS_from_(?a) ")" ],.{FSS});

^(Abstract_element@OWL  r_operator: r_member) ?a
  rc_spec:  fc_spec_(.[ fc_OP_from_(?a) "(" fc_ARG_(?a.r_link_source)
                        fc_ARGS_(.[every ?a.r_link_destination.r_member]) ")" ], .{FSS} );


//Reminder:  Document@OWL /^ Module; 
//           Module = f_link_type _("",r_context,Module_body,Module_context);
//           Module_context /^ f_relation_type _("Context",r_and,.[0..* Link_in_module_context]);
//           Module_body  /^ f_relation_type _("Group",r_and,.[0..* Formula]);
//Grammar at https://www.w3.org/TR/owl2-syntax (sections 3.7 and 13)
//  ontologyDocument := { prefixDeclaration } Ontology 
//  Ontology := 'Ontology' '(' [ ontologyIRI [ versionIRI ] ] directlyImportsDocuments
//                             ontologyAnnotations   axioms ')'
Document@OWL ?d
  rc_spec: fc_spec_(.[ fc_ARG_(.[every ^(Module_context_namespace-definition_link 
                                          r_part of: (a Module_context r_link_destination of: ?d) ) ])
                       fc_ARG_(?d.r_link_source) ], .{FSS} );

Module_context_namespace-definition_link@OWL ?l
  rc_spec: fc_spec _(.[fc_op_("Prefix") "(" fc_ARG_(?l.r_link_source)  "="
                                            fc_ARG_(?d.r_link_destination) ")" ], .{FSS} );

Module_body@OWL ?mb
  rc_spec: fc_spec _(.[fc_op_("Ontology") "(" fc_ARG_(?mb.r_identifier) fc_ARG(?mb.owl#versionInfo)
                       fc_ARGS_(.[every ^(Module_import_link_with_IRI@OWL 
                              _            r_part of: (a Module_context  r_context of: ?mb) ) ])
                       fc_ARGS(.[every ^(Module_import_link_with_IRI@OWL
                                          r_part of: (a Module_context  r_context of: ?mb) ) ])
                       fc_ARGS_(.[every ^(Module_annotation_link@OWL
                                          r_part of: (a Module_context r_context of: ?mb) ) ])
                       fc_ARGS_from_(?mb) ")" ], .{FSS} );

^(owl#Axiom  r_operator: r_member) ?a
  rc_spec: fc_spec _(.[fc_op_(?a.r_name) "(" fc_ARGS_(.[every ?d.r_annotation])
                       fc_ARG_(?a.r_link_source)
                       fc_ARGS_(.[every ?a.r_link_destination.r_member]) ")" ], .{FSS} );
^(owl#Axiom  not r_operator: r_member) ?a
  rc_spec: fc_spec _(.[fc_op_(?a.r_name) "(" fc_ARGS_(.[every ?d.r_annotation])
                       fc_ARG_(?a.r_link_source)  fc_ARG_(?a.r_link_destination) ")" ], .{FSS} );


owl#Restriction ?r
  rc_spec: fc_spec _(.[fc_OP_(?r.r_name) "("  fc_ARGS_from_(?r) ")" ], .{FSS} );

owl#PropertyRestriction ?r
  rc_spec: fc_spec _(.[fc_OP_(?r.r_name) "(" fc_ARG_(?r.owl#onProperty) 
                                             fc_ARGS_from_(?r) ")" ], .{FSS} );

owl#PropertyCardinalityRestriction ?r
  rc_spec: fc_spec _(.[fc_OP_(?r.r_name) "(" 
                       fc_ARG_(?r.owl#r_relation_from_restriction_to_nonNegativeInteger)
                       fc_ARG_(?r.owl#onProperty)  fc_ARGS_from_(?r)  ")" ], .{FSS} );
  \. (^(owl#ObjectPropertyCardinalityRestriction owl#onProperty_restriction: owl#Thing_IRI)
          rc_spec: fc_spec _(.[fc_OP_(?r.r_name) "(" 
                               fc_ARG_(?r.owl#r_relation_from_restriction_to_nonNegativeInteger)
                               fc_ARG_(?r.owl#onProperty)  ")" ], .{FSS} ) );



1.2.  Infix operator based KRL notation


1.2.1.  N-Triples

Conjunction_of_formulas@RDF  
  rc_spec: fc_spec_(.[ fc_ARGS_from_(?a) ],.{N-Triples});

NR_link@RDF ?l  rc_spec: fc_spec_(.[fc_ARG_(?l.r_link_source)  fc_OP_(?l)
                                    fc_ARG_(?l.r_link_destination) ],.{N-Triples} );


1.2.2.  N-Quads

Conjunction_of_formulas@RDF  
  rc_spec: fc_spec_(.[ fc_ARGS_from_(?a) ],.{N-Quads});

NR_link@RDF ?l  rc_spec: fc_spec_(.[fc_ARG_(?l.r_link_source)  fc_OP_(?l)
                                    fc_ARG_(?l.r_link_destination)  fc_ARG_(?l.r_context)
                                   ],.{N-Quads} );




2.  KRL notation that is mostly graph based


2.1.  KRL notation mostly graph based but not markup based


2.1.1.  The notation of JSON-LD

JSON-LD_notation  r_short_name: JN;   JSON-LD_model  r_short_name: JM;  

//--------- STRUCTURES:
^(Conjunction_phrase@JM   not /^  NR_frame) ?cp
   rc_spec: fc_spec _(.[ "["  fc_ARGS_from_(?cp,",")  "]"  ], .{JN});

Minimal-frame_as_NR-phrase@JM ?mf
   rc_spec: fc_spec _(.[ "{"  fc_ARGS_from_(?mf,",")  "}"  ], .{JN});

Minimal_half-link@JM ?mh
  rc_spec: fc_spec _(.[ fc_OP_from(?mh) ":" fc_ARG_(?mh.r_link_destination) ], .{JN})
  \. (Minimal_half-link_in_rel-type-def_context@JM 
        \. (Minimal_half-link_in_rel-type-destination-def_context@JM ?mh
              rc_spec: fc_spec _(.[fc_OP_(`"@type"') ":" fc_ARG_(?mh.r_link_destination) ], .{JN})
           ) );

Link_from_a_module_body@JM 
  rc: only ^(Concrete_element  r_part of: JN,  rc of: a Module_context@JM), //no direct display
  \. Module_base_IRI_link@JM  Module_context_namespace-definition_link@JM;

Module_context_namespace-definition_link@JM ?d
  rc_spec: fc_spec _(.[fc_ARG_(?d.r_link_destination) ], .{JN});
Namespace_shortcut_definition_in_context@JM ?d
  rc_spec: fc_spec _(.[fc_ARG_(?d.r_link_source) ":" fc_ARG_(?d.r_link_destination) ], .{JN});

Module_context_type-definition_link@JM ?d 
  rc_spec: fc_spec _(.[fc_ARG_(?d.r_link_destination) ], .{JN});
Relation-type_definition_in_context@JM ?d
  rc_spec: fc_spec _(.[fc_OP_(?d.r_frame_head) ":"
                       fc_ARG_(.["{" fc_ARGS_from(?d) "}"]) ], .{JN});

r_binary_relation_type_predefined_in_JN  //w3.org/TR/json-ld/#syntax-tokens-and-keywords (3.3) 
  \. (r_context@JM ~[Module_body@JM-:Module_context@JM}] rc.: `"@context"'@JN)
     (r_id@J ~[?-:ID@J]                               rc.: `"@id"'@JN)
     (r_value ~[?-:Built-in_value@J]                  rc.: `"@value"'@JN)
     (r_language@J ~[String@JN-:Language@J]           rc.: `"@language"'@JN)
     (r_type@J ~[Typable_object-:ID@J]                rc.: `"@type"'@JN)
     (r_container_type@J ~[?-:Container_type@J]       rc.: `"@container"'@JN)
     (r_list_items@J ~[?-:Container@J]                rc.: `"@list"'@JN)
     (r_set_items@J ~[?-:Container@J]                 rc.: `"@set"'@JN)
     (r_reverse@J ~[?-:Objectified_link@J]            rc.: `"@reverse"'@JN)
     (r_key_name_@J ~[?-:string@J]                    rc.: `"@index"'@JN)
     (r_base_IRI@J ~[Context_frame@J-:Absolute_IRI@J] rc.: `"@base"'@JN)
     (r_default_namespace@J ~[Context_frame@J-:IRI@J] rc.: `"@vocab"'@JN)
     (r_graph_items@J ~[Phrase@J-:set{Frame}]         rc.: `"@graph"'@JN);


//--------- REFERENCES and VALUES: 
JM_AE_with_string_like_representation_in_JN ?a
 rc_spec: fc_stringSpec _(.[ '"'  ?a.r_value  '"' ],'\\',.{JN}),
 \.  String@JM  IRI@JM  Language@JM;

Blank_node_identifier@JM ?b 
  rc_spec: fc_stringSpec _(.[ '"_:'  ?b.r_value ],'',.{JN});



2.2.  KRL notation mostly graph based and markup based

2.2.1.  RDF/XML

^(Abstract_element@RDF   not r_part: an AE) ?a
  rc_spec: fc_spec _(.[""], .{RDF/XML} );

^(Frame_as_reference@RDF  r_part: an AE) ?a
  rc_spec: fc_spec _(.["<"fc_op_(?a.r_op.r_name)">" fc_ARGS_from_(?a)
                       "" ], .{RDF/XML} );

^(Frame_as_reference@RDF  r_part: 0 ^(Half_link  not r_link_destination: a Token@RDF) ?a
  rc_spec: fc_spec _(.["<"fc_op_(?a.r_op.r_name)" fc_ARGS_from_(?a)"/>" ], .{RDF/XML} );

Half_link@RDF 
  rc_spec: fc_spec _(.["<"fc_op_(?a.r_op.r_name)" fc_ARG_(?a.r_link_destination)"/>"
                      ], .{RDF/XML} );