Ontology for specifying concrete elements (CEs), KRL notations and exports

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

1.  Concrete element for a token
    1.1.  Concrete element for a constant
        1.1.1.  Concrete element for an Identifier
        1.1.2.  Concrete element for a Value_token
    1.2.  Concrete element for a name or a variable
    1.3.  Lexical-grammar_character-set

2.  Structured concrete element
    2.1.  Initial+obsolete+impractical subtype hierarchy for Structured_CE
    2.2.  Top-level relation/function types for representing structured CEs

3.  Direct exporting

4.  Direct importing



1.  Concrete element for a token

CE_for_a_token  /* /^ Concrete_element, //see the definition of CE in d_KRLmodelsTop.html */
 r_CE of: a Token,
 \. partition { CE_part Full_cE }
    CE_for_a_constant  CE_for_a_name  CE_for_a_variable;


r_CE_to_CE ~[CE, CE]
 \. (rc_begin-end_marks   //e.g.: String_no-op-CR rc_begin-end_marks: .{'"','"'} .{"'", "'"}
      \.  rc_operator_begin-end_marks  rc_operator_begin-end_marks )
    (rc_begin-mark \.  rc_operator_begin  rc_parts_begin)
    (rc_end-mark   \.  rc_operator_end    rc_parts_end) 
    (rc_separator  \.  rc_parts_separator
                            (rc_white-space_separator  \.  rc_parts_white-space-separator) )
    rc_operator_position/*_wrt_arguments*/ 
    rc_particular_argument_position //rc_infix-operator_position 
    rc_annotation_position; //-1: before the operator


f_string_type ~[?begin_mark, ?separator, ?end_mark] 
   = ^(String  rc_begin_mark: ?begin_mark,  rc_list_member_separator: ?separator, 
               rc_end_mark: ?end_mark,  rc_token_separator: "");

f_character_type ~[?set_of_character_instances]
   = ^(Character  r_direct-or-not_member of: ?set_of_character_instances);


1.1. Concrete element for a Constant

CE_for_a_constant
  \. (Constant_ct_part
        \. exclusion { Identifier_ct_part  Value_token_ct_part }
           (w3c#Literal \. (w3c#UNICODESTRING = 0..* f_string_type _(.[0..* Unicode_character])))
     )
     (Constant_ct  rc_type of: Constant,  r_part: 1..* Constant_ct_part,
        \. exclusion { Identifier_ct  Value_token_ct }
           (w3c_constant_ct  rc_type of: Constant,
             \. partition
                { (w3c_expanded_constant_ct = w3c_constant_ct_via_string_and_symbol-space  w3c#Const,
                    = f_string_type _(.["", fc_ARGS_(.[1 w3c#Literal, 1 w3c#SYMSPACE],"^^"), ""]) )
                      
                  (w3c_shortcut_constant_ct = w3c#CONSTSHORT,
                    \. exclusion                                      //shortcut for ...
                       { w3c_shortcut_for_absolute_referring_token_ct //" ..."^^rif:iri (IRI_REF,CURIE)
                         w3c_shortcut_for_local_referring_token_ct    // "..."^^rif:local
                         Number_ct                                    // "..."^^xs:integer, ...
                         Delimited_string                             // "..."^^xs:string
                         String_with_language_tag_ct                  // "..."^^rdf:PlainLiteral
                       } )
                } ) 
     );



1.1.2.  Concrete element for an Identifier

Identifier_ct_part
  \. partition { Character_for_an_identifier_ct  Name-part_for_an_identifier_ct };


Character_for_an_identifier_ct 
  \. (Base_character_for_an_identifier_ct
       \. (CLIF_base_character_for_a_name 
            /^ f_character_type _(.{Letter, Digit, "_-./:", '~',
                                    "!#%&*+,", ";<=>?", "[]^`", "{|}" }) )
          (sparql#WS = f_character_type _(.{ #x20 #x9 #xD #xA }))
          (W3C_base_character_for_a_name    //"PN_": XML stuff
            \. (w3c#PN_CHARS_BASE = f_character_type _(
                 .{ %[- 'A'-'Z'], %[- 'a'-'z'], %[- #x00C0-#x00D6], %[- #x00D8-#x00F6],
                      %[- #x00F8-#x02FF], %[- #x0370-#x037D], %[- #x037F-#x1FFF], %[- #x200C-#x200D],
                      %[- #x2070-#x218F], %[- #x2C00-#x2FEF], %[- #x3001-#xD7FF], %[- #xF900-#xFDCF],
                      %[- #xFDF0-#xFFFD], %[- #x10000-#xEFFFF]
                  } ))
               (w3c#PN_CHARS_U = PN_CHARS_BASE_or_underscore,                      //PN_CHARS_BASE|'_'
                 = f_character_type _(.{'_',w3c#PN_CHARS_BASE}) )
               (PN_CHARS_U_or_digit \. partition {w3c#PN_CHARS_U  Digit},          //PN_CHARS_U|Digit
                 \. w3c_first_character_for_local_part_of_prefixed_name )
               (w3c#PN_CHARS                                             //stuff|'-'|PN_CHARS_U|Digit
                 /^ f_character_type _(.{PN_CHARS_U, Digit, '-',
                                         #x00B7, %[- #x0300-#x036F], %[- #x203F-#x2040] }) )
               (PN_CHARS_or_dot = f_character_type _(.{w3c#PN_CHARS,'.'})          //PN_CHARS|'.'
                 \. (w3c#NCNameChar = XML_non-first_character_for_unprefixed_local_name) )
          ) )
     (First_character_for_an_identifier_ct 
       \. (w3c#NCNameStartChar = XML_first_character_for_unprefixed_local_name,    //PN_CHARS_U
            /^ f_character_type _(.{w3c#PN_CHARS_U}) )
          (PN_CHARS_U_or_colon = w3c#NameStartChar XML_first_character_for_name,   //PN_CHARS_U|":'
            /^ f_character_type _(.{":",w3c#PN_CHARS_U}) )
     )
     (Non-first_character_for_an_identifier_ct
       \. (w3c#NameChar = XML_non-first_character_for_name,                 //':'|.'|PN_CHARS
            /^ f_character_type_(.{':',PN_CHARS_or_dot}) )
     )
     (w3c_IRI_REF_char_extended = f_character_type _(.[^ < > " { } | ^ ` \ ]),
       \. partition { w3c_IRI_REF_char  f_character_type_(.[- #x00-#x20]) } )
     ;


Name-part_for_an_identifier_ct
  \. (w3c_some-PN-CHARS-or-dot_and_1_PN_CHARS = f_string_type _(.[0..* PN_CHARS_or_dot, 1 PN_CHARS]))
     (w3c#PN_PREFIX = f_string_type _(.[1 w3c#PN_CHARS_BASE,
                                         0..1 w3c_some-PN-CHARS-or-dot_and_1_PN_CHARS]))
     (w3c#PN_LOCAL  = f_string_type _(.[1 w3c#PN_CHARS_U_or_digit,
                                              0..1 w3c_some-PN-CHARS-or-dot_and_1_PN_CHARS]))
           //SPARQL local names allow leading digits while XML/RIF local names do not
     (w3c#NCName   //NCName ::= NCNameStartChar NCNameChar*  //= PN_PREFIX+':' + '.'afterExceptAtEnd
       = f_string_type _(.[1 w3c#PN_CHARS_U, 0..* PN_CHARS_or_dot]) )
     ;


Identifier_CE  rc_type of: Identifier,
  \. exclusion              
     { (w3c_shortcut_for_absolute_referring_token_CE  //shortcut for "..."^^rif:iri
         \. exclusion
            { (w3c_IRI_within_angle_brackets = w3c#ANGLEBRACKIRI,
                \. (w3c#IRI_REF = f_string_type _(.["<" 0..* w3c_IRI_REF_char ">"])) )
              (w3c_compact_URI = w3c#CURIE  sparql#PrefixedName,  //xs:decimal, rif:iri, ...
                \. exclusion       //CURIE ::= PNAME_NS | PNAME_LN  / :=  (NCName? ':')? (ref=PN_LOCAL)
                   { (w3c_CURIE_prefix_part = w3c#PNAME_NS, = f_string_type _(.[0..1 PN_PREFIX, ':']))
                     (w3c_CURIE_local_part  = w3c#PNAME_LN f_string_type _(.[1 PNAME_NS, 1 PN_LOCAL]))
                   } )  
            } )
       (w3c_shortcut_for_local_referring_token_ct  //shortcut for "..."^^rif:local  
         \. (RIF_shortcut_for_local_referring_token_ct = f_string_type _(.['_', 0..1 w3c#NCName]))
            (sparql#BlankNode 
              \. (sparql#BLANK_NODE_LABEL = f_string_type _(.['_:', 0..1 w3c#PN_LOCAL]))
                 (sparql#ANON  = f_string_type _(.['[', 0..* sparql#WS, ']']))
            ) ) //SPARQL local names allow leading digits while XML/RIF local names do not
     }
     (Symbol-space_ct  rc_type of: 1..* Symbol_space,
        \. (w3c#SYMSPACE \. w3c_shortcut_for_referring_token_ct) );

/* Note: rif#Name ::= NCName | '"' UNICODESTRING '"'
         rif#Var  ::= '?' Name */


1.1.2.  Concrete element for a Value_token

Value_token_ct_part
  \. (w3c#EXPONENT /^ f_string_type _(.[1 ^or{'e','E'}, 0..1 ^or{'+','-'}, 1..* Digit]))
     (Language_ID_ct  rc_type of: xs#language,
       \. (w3c#LANGTAG /^ f_string_type _(.[1..* Letter,
                                             0..1 f_string_type _(.['-', 1..* Letter_or_digit]) ])) )
     (w3C_STRING_LITERAL1_char = f_character_type _(.{Space_character, %[^ ' \ \r \n] }))
                                                                     // [^#x27#x5C#xA#xD]%W3C-EBNF
     (w3C_STRING_LITERAL2_char = f_character_type _(.{Space_character, %[^ " \ \r \n]}) 
                                                                     // [^#x22#x5C#xA#xD]%W3C-EBNF
     (W3C_any_char_but_an_unescaped_single_quote = f_character_type _(.{w3c#ECHAR, %[^ ' \]}))
     (w3C_STRING_LITERAL_LONG1_chars \. f_string_type _(.[0..2 '"',  
                                               1 W3C_any_char_but_an_unescaped_single_quote] ))
     (W3C_any_char_but_an_unescaped_double_quote = f_character_type _(.{w3c#ECHAR, %[^ " \]}))
     (w3C_STRING_LITERAL_LONG2_chars \. f_string_type _(.[ 0..2 "'",
                                               1 W3C_any_char_but_an_unescaped_double_quote] ));


Value_token_ct  rc_type of: Value_token,
  \. partition
     { (Structured_value_token_ct  rc_type of: Structured_value_token,
         \. exclusion
            { (String_value_token_ct  rc_type of: String_value_token,
                \. (Delimited_string  rc_type of: xs#string,
                     \. (Delimited_Unicode_string = f_string_type _(.[1 Delimiter,
                                                            0..* Unicode_character, 1 Delimiter] ))
                        (Quoted_string
                          \. (String_delimited_by_escapable_double_quote \. f_string_type _(.['"',
                                1..* f_character_type_with_escape_for_ (w3c#Char,"\\",'"'),'"'] ))
                             (String_delimited_by_escapable_single_quote \. f_string_type_(.["'",
                                1..* f_character_type_with_escape_for_ (w3c#Char,"\\","'"),"'"] ))
                             (W3c_quoted_string
                              \. (String_without-line-break_delimited_by_1_non-escapable_double_quote
                                   \. (w3c#STRING_LITERAL2 = f_string_type _(.['"',
                                                  1..* w3C_STRING_LITERAL1_char,'"'] )) )
                                 (String_without-line-break_delimited_by_1_non-escapable_single_quote
                                   \. (w3c#STRING_LITERAL1 = f_string_type _(.["'",
                                                  1..* w3C_STRING_LITERAL1_char,"'"] )) )
                                 (String_delimited_by_3_escapable_double_quote
                                   \. (w3c#STRING_LITERAL_LONG2 = f_string_type _(.['"""',
                                                 1..* w3C_STRING_LITERAL_LONG1_chars,'"""'] )) )
                                 (String_delimited_by_3_escapable_single_quote
                                   \. (w3c#STRING_LITERAL_LONG1 = f_string_type _(.["'''",
                                                 1..* w3C_STRING_LITERAL_LONG2_chars,"'''"] )) )
                             )
                        ) )
                   (String_with_language_tag_ct  rc_type of: String_with_language_tag,
                     r_operator: 1 w3c#LANGTAG,  r_arg: 1 Delimited_string,
                     \. (w3c_string_with_language_tag_ct
                          \. f_string_type _(.[1 W3c_quoted_string, '@', 1 w3c#LANGTAG]) ) )
              )
              (Time_value_token_ct  rc_type of: Time_value_token
              )
            } )
       (Atomic_value_token_ct  rc_type of: Atomic_value_token,
         \. exclusion
            { (Boolean_ct  rc_type of: xs:boolean,
                \. (True_ct  rc_type of: True,
                     \. f_string_type_(.['"true"'])  f_string_type_(.["true"]) )
                   (False_ct rc_type of: False,
                     \. f_string_type_(.['"false"']) f_string_type_(.["false"]) )
              )
              (Character_ct  rc_type of: Character,
                \. f_string_type _(.["'",
                                  1 f_character_type_with_escape_for_ (Character,"\\","'"),"'"] )
              )
              (Number_ct  rc_type of: Number,
                \. (Integer_ct  rc_type of: Integer,
                     \. (Unsigned_integer = w3C#INTEGER, /^ f_string_type _(.[1..* Digit]))
                        (Positive_integer /^ f_string_type _(.['+', 1..* Digit]))
                     \. (Negative_integer /^ f_string_type _(.['-', 1..* Digit]))
                   )
                   (Decimal  rc_type of: Decimal,
                     \. (w3c#DECIMAL
                          \. (W3c_decimal_1 /^ f_string_type _(.[1..* Digit, '.', 0..* Digit]))
                             (W3c_decimal_2 /^ f_string_type _(.[            '.', 1..* Digit]))
                        )
                        (w3c#DECIMAL_POSITIVE /^ f_string_type _(.['+', 1..* w3c#DECIMAL]))
                        (w3c#DECIMAL_NEGATIVE /^ f_string_type _(.['-', 1..* w3c#DECIMAL]))
                   )
                   (Double   rc_type of: Double,
                     \. (w3c#DOUBLE
                          \. (W3c_double_1 /^ f_string_type _(.[1 W3c_decimal_1, 1 w3c#EXPONENT]))
                             (W3c_double_2 /^ f_string_type _(.[1 W3c_decimal_2, 1 w3c#EXPONENT]))
                             (W3c_double_3 /^ f_string_type _(.[1..* Digit     , 1 w3c#EXPONENT]))
                        )
                        (w3c#DOUBLE_POSITIVE /^ f_string_type _(.['+', 1..* w3c#DOUBLE]))
                        (w3c#DOUBLE_NEGATIVE /^ f_string_type _(.['-', 1..* w3c#DOUBLE]))
                   )
              )
           } )
     };



1.2.  Concrete element for a name or a variable

Name_ct  rc_type of: Name,
 \. (w3c#Name  \. NCName  W3c_quoted_string); 

Variable_ct  rc_type of: Variable,
 \. (w3c#Var \.  f_string_type _(.["?" 1 w3c#Name]));



1.3.  Lexical-grammar_character-set

Lexical-grammar_character-set
 \. (Lexical-grammar_character-or-set
      /^ ^(f_string_type _(.["[", 1..* Character_range, "]"])) )
    (Lexical-grammar_character_exclusion 
      /^ ^(f_string_type _(.["[^", 1..* Character_range, "]"])) )
    (Letter_or_letter-code
      \. (Letter  \. Letter_range_1  Letter_range_2)
         (Letter_code
           \. (Letter_code_with_hexadecimal
                /^ ^(f_string_type _(.["#", 1 Hexadecimal])),
                \. Letter-code__range_1  Letter-code_range_2 )
         ) )
    (character_range 
      \. (Letter_range
           /^ ^(f_string_type _(.[1 Letter_range_1,"-",0..1 Letter_range_2])) )
         (Letter-code_range
           /^ ^(f_string_type _(.[1 Letter-code_range_1,"-",0..1 Letter-code_range_2])) )
    )
    (Space_or_fully-delimited-comment
       \. (Space /^ ^(f_string_type _(.[1..* Space_character])))
          (Comment
            \. (Multi-line_comment
                  /^ ^(f_string_type _(.["/*", 0..* Character,"*/"])) )
               (Line-comment /^ ^(f_string_type _(.["//",0..* Character]))) )
    )
    (Non-ascii_character
      \. ^(f_string_type _(.["\u",4 Hexa_character]))
         ^(f_string_type _(.["\U",4 Hexa_character]))
    );



2.  Structured concrete element

2.1.  Initial+obsolete+impractical subtype hierarchy for Structured_CE

This hierarchy was an attempt to categorize all main possible prefix/infix/postfix notation forms for an AE structure. The initial goal was, for each of these forms, to create a function that i) accepted some parameters for variations the user needed, and ii) returned a represention of this parameterized form using presentation primitives. This led to many functions with long names and many parameters. Despite the long names, it was hard to understand or remember what each function specified exactly. Finally, the functions had a lot of code in common.
The function fc_type – and associated functions – of Section 0.3 bring more flexibility. They permit the user to describe arbitrary notation forms in a a concise way.

In the hierarchy below, comments give examples. Those for FL forms are in bold characters. With the delimiters FL uses, FL has all major types of Structured_CE and still only requires an LALR(1) analyser.
Within the examples, "f" is an operator/frame-head-object,
A, B and C are parts/parameters, and kA:vA is an example of a keyed parameter.
A keyed parameter - alias, "half-link" - is composed of a key (mark/relation/name) and a keyed value (e.g., a relation destination).
Reminder: in a frame, f is the head object (rarely a relation/function) and each link from it is a keyed parameter.

Structured_CE  /* /^ Concrete_element, //see the definition of CE in d_KRLmodelsTop.html */
  //With the default delimiters of FL within comments below, an LRC can have
  // all such Structured_CE and still only require an LALR(1) analyser.
 rc_begin-end_marks: .{"", ""},          //Links also available: rc_begin_mark, rc_end_mark. 
 rc_parts_begin-end_marks: .{"(", ")"},  //Also available: rc_parts_begin_mark, rc_parts_end_mark. 
 rc_escaped_escape-string-for-begin-end_marks: "\\", 
 rc_separator: 1..* Space_character, //before/after every CE except begin/end marks (even other
                                     // separators and hence between parts except if overridden)
 rc_white-space_separator: 1..* Space_character,
 rc_parts_separator: ",",  //"( p1 , pN )"
 rc_parts_white-space-separator: 0..* Space_character, //overrides rc_white-space_separator
 rc_operator_position: -1.1, //an operator is a function/relation type or a frame head
      //The following set of presentation values can be extended by adding fractions
      //  0: no operator;   0.5: middle of list (of parameters) for binary operator;
      //0.4: anywhere in the list but immediately prefixed by a key (mark/relation/name)
      //0.6: anywhere in the list but immediately postfixed by a key
      //0.61 (theoretical): anywhere in it but followed by a CE and then a key
      // -1: head of list; -1.1: just before the list;  -1.2: before a CE before the list; ...
      //  1: last of list;  1.1: just after the list;    1.2: after a CE after the list; ...
 rc_particular_parameter_position: 0, //The following can be extended by adding lesser fractions
      //   0: positional, i.e., no key nor particular position for any of the parameters;
      // 0.4: at least some parameters may be immediately prefixed by a key
      // 0.6: at least some parameters may be immediately followed by a key
      // 0.61 (theoretical): some parameters may be followed by a CE and then a key
      //0.11: only the first parameter may be immediately prefixed by a key
      //0.12: only the second parameter may be immediately prefixed by a key
      //-1.1: the first parameter is before the rc_parts_begin mark
      //-1.2: the first two parameters are before the rc_parts_begin mark
      // 1.1: the first parameter is before the rc_parts_end mark
      // 1.2: the first two parameters are before the rc_parts_end mark.
 rc_operator_key_begin-end_marks: .{"", ""},  rc_parameter_key_begin-end_marks: .{"", ":"}, 
 \. partition
    {(Structured_CE_without_operator  //representing an AE with or without operator
       rc_operator_position: 0,
       \. partition
          {(Structured_CE_without_operator_nor_white-space_separator
             rc_parts_separator: "",  rc_white-space_separator: "",
             \. (String_no-op-CE rc_begin-end_marks: .{'"','"'} .{"'", "'"},
                   \. (Single_quoted_CE  rc_begin-end_marks: .{'"','"'}),  //'"pN"': "ABC"
                      (Double_quoted_CE  rc_begin-end_marks: .{"'", "'"})  //"'p+'": 'ABC'
                ) )
           (Structured_CE_without_operator_but_with_white-space_separator
             \. exclusion  //with some list elements prefixed by a key or not
                {(List_no-op-CE  //inherited:  rc_begin-end_marks: .{"(", ")"},
                   \. (Classic_list_CE                               //" (  p1 , pN )"
                        \. (FL_list_CE_no_sep  rc_begin_mark: ".(")  //".(  p1   pN )"
                           FL_list_CE_with_or_without_sep            //".[  p1 , pN ]"
                           FL_interval                               //".[- p1 - pN ]"
                           FL_distributive_interval                  //"%[- p1 - pN ]"
                           FL_distributive_list                      //"%[  p1   pN ]"
                                                                     //?%sequence_variable
                           FL_statement                              //" [ b? r1:c , r2:d ]"
                           FL_statement_from_signature               //"^[ b? r1:c , r2:d ]"
                           FL_frame_without_op                       //" (    r1:c , r2:d )"
                           FL_lambda_abstraction                     //"^( b? r1:c , r2:d )"
                           FL_postfix_relation_context_argument )    //"__[   r1:c , r2:d ]"
                      (List_with_isolated_1st_element_CE          //".( p1 | p2 , pN )"
                             = Prefix_list_CE, //Abbreviation
                               rc_operator_position: -1.1,  rc_parts_begin-end_marks: .{":",""},
                               rc_parts_separator: "",
                             \. Half-link_CE ) ) //" f : p1 pN "

                 (Set_no-op-CE  rc_begin-end_marks: .{"{", "}"},
                   \. (Classic_set_CE                                //" {  p1 , pN }"
                        \. (FL_set_CE  rc_begin_mark: ".{")          //".{  p1   pN }"
                           FL_distributive_set_CE                    //"%{  p1   pN }"
                           FL_exclusion_character_set_CE             //".[^ c1   cN ]"
                           FL_distributive_exclusion_character_set   //"%[^ c1   cN ]"
                           (FL_implicit_set_CE                       //"    p1   pN  "
                             rc_begin-end_marks: .{"", ""}, rc_parts_separator: "" )
                           (Keyed_classic_set_CE                     //"{ k1 : d1 , kN : dN }",
                             rc_particular_parameter_position: 0.4,
                             \. Set-like_frame_CE ) ) //JSON-LD: "{ rN : dN , @id: op , rN : dN}
                      (Set_no-op-CE_with_isolated_1st_element        //"p1 ..{ p2 , pN }"
                         rc_begin_mark: "..{",  rc_operator_position: -1.1 ) )
                 (Untyped_sentence-conjunction_CE  rc_parts_separator: ";",
                   \. (FL_untyped_sentence-conjunction_CE            //"[ p1 ; pN ]" or "p1 ; pN"
                         rc_begin-end_marks: .{"[", "]"}  .{"", ""},
                         \. (FL_untyped_embedded-sentence-conjunction_CE
                               rc_begin-end_marks: .{"_[", "]"} ) ) )
                } )
            } )
     (Structured_CE_with_operator  //with some parameters prefixed by a key or not
       rc_operator-name: "", //By default, the name of the individual or relation/function type
       rc_operator_begin-end_marks: .{"", ""},                                      // is used.
       \. partition   
          {(Prefix_operator_CE   //Inherited:  rc_operator_position: -1.1
             \. exclusion                //Positional by default (this is not a necessary condition)
                {(Prefix_fct-like_CE                                 //"op ( p1 , pN )"
                   \. (Prefix_fct-like_keyed_CE                      //"op ( k1 : d1 , kN : dN )"
                         rc_particular_parameter_position: 0.4,    
                         \. (FL_prefix_fct-like_CE                   //"op _( p1 , pN )"
                               rc_parts_begin: "_(" )
                            (FL_prefix_context1-like_CE              //"op _[ r1 : d1 , pN ])"
                               rc_parts_begin-end_marks: .{"_[", "]"} )
                            (FL_prefix_context2-like_CE              //"op _{ r1 : d1 , pN })"
                               rc_parts_begin-end_marks: .{"_{", "}"} ) 
                            (FL_function_type_with_signature         //"op ~[ ?t1 , ?tN ] =: ?f"
                              rc_parts_begin-end_marks: .{'~[',']'})
                            (FL_relation_type_with_signature         //"op ~[ ?t1 , ?tN ] ?r"
                              rc_parts_begin-end_marks: .{'~[',']'}) //"op ~[ ?t1 -: ?tN]"
                            (FL_concept_type_with_signature          //"op ~{ ?ct }"
                              rc_parts_begin-end_marks: .{'~{','}'}) //"op ~{ .[] =: ?ct }"
                            (FL_typed_distributive_set               //"op  { p1 , pN }"
                                 rc_parts_begin-end_marks:: .{"{","}"}  //if not typed: .{}
                            ) ) )
                 (Prefix_list-like_CE  rc_operator_position: -1,  //As in LISP: "( op p1 pN )"
                   rc_begin-end_marks: .{"(", ")"},  rc_parts_begin-end_marks: .{"", ""},
                   \. (Prefix_list-like_keyed_CE                     //As in LISP: "( op k1 : d1 , pN )"
                         rc_particular_parameter_position: 0.4, 
                         \. (FL_prefix_list-like_CE                  //"(_. op k1 : d1 , pN )"
                               rc_parts_begin: "(_." )
                            (FL_frame-with-op_CE                     //"( op  r1 : d1 , rN : dN )
                               rc_begin-end_marks: .{"",""} .{"(",")"}, 
                               \. (FL_embedded_frame_CE  rc_begin-end_marks: .{"(",")"}) )
                            Alternating-XML_CE ) )
                } )
           (Postfix_operator_CE  rc_operator_position: 1.1, //By default: positional
             \. exclusion
                {(Postfix_fct-like_CE                                //"(p1 , pN ) op" 
                   \. (Postfix_fct-like_keyed_CE                     //"(k1 : d1 , kN : dN ) op"
                         rc_particular_parameter_position: 0.4,     
                         \. (FL_postfix_fct-like_CE                  //"(_ p1 , pN ) op"
                               rc_parts_begin: "(_" )
                            (FL_postfix_context1_like_CE             //"[_ r1 : d1 , rN : dN ] op
                               rc_parts_begin-end_marks: .{"[_", "]"} )  
                      ) ) 
                 (Postfix_list-like_CE  rc_operator_position: 1,     //"( p1 , pN ,? op )"
                   rc_begin-end_marks: .{"(", ")"},  rc_parts_begin-end_marks: .{"", ""},
                   \. (FL_postfix_list-like_CE                       //(._ p1 , pN  op )
                         rc_particular_parameter_position: 0.4,  rc_parts_begin: "(._" ) )
                } )
           (Infix_operator_CE  rc_operator_position: 0.5,
             \. partition
                {(Un-keyed_infix_operator_CE                         //"(... p1 pN op pN )"
                   \. (Un-keyed_infix_binary_CE  \. partition
                        { Classic_infix_2ary_CE                      //e.g., A = B;  A r: B;
                          Right-to-left_infix_2ary_CE } )            //e.g., (- B r: A)
                 Keyed_infix_operator_CE                             //"(pN @ op pN)
                } )
          } )
    }; 


2.2.  Top-level relation/function types for representing structured CEs

rc_spec ~[AE ?x, List ?ceSpaceOrNonSpacePartsSpecsForNotationSet
                        /* what fc_spec returns */ ]
  \. (rc_space_specifications ~[AE ?x, List ?ceSpacePartsSpecsForNotationSet]
        = rc_sSpec );

fc_spec ~[?cePartsSpecs, ?notationSet] := .[ ?cePartsSpecs, ?notationSet];

fc_OP ~[?ae]        := .[r_op,  ?ae]; 
fc_ARG ~[?ae]       := .[r_arg, ?ae]; 
fc_ARGS ~[?ae]      := .[r_args, ?ae];
fc_OP_from ~[?ae]   := .[r_op,  (?ae.rc_operator_name ) ? ?ae.rc_operator_name : ?ae.r_op];
fc_ARG_from ~[?ae]  := .[r_arg, ?ae.r_arg]; 
fc_ARGS_from ~[?ae] := .[r_args,?ae.r_args];

fc_ARGS ~[?ae, ?space_specs]  := .[r_args, ?ae, ?space_specs];
fc_ARGS_from ~[?ae, space_specs] := .[r_args, ?ae.r_args, ?space_specs];




3.  Direct exporting

fc_parts ~[AE ?ae, ?notationSet, ?spaceSpecs]  /^ Generation_function,
 := fc_apply_specs _(fc_find_specs _(?ae,?notationSet),?spaceSpecs);

fc_parts ~[AE ?ae, ?notationSet]   /^ Generation_function,
 := fc_apply_specs _(fc_find_specs _(?ae,?notationSet),
                     fc_find_other_space_specs _(?ae,?notationSet), ?notationSet );

fc_AEs_parts ~[?List_of_AE, ?notationSet, ?spaceSpecs]
 := if_then_else( [?List_of_AE = List(%censp_1st | %censp_rest)], //if not empty
     /*then*/fc_append_with_spaces _(fc_parts(%censp_1st,?notationSet),
                                     fc_AEs_parts(%censp_rest,?notationSet),
                                     ?spaceSpecs),
     /*else*/ "" );

fc_AEs_parts ~[?List_of_AE, ?notationSet]
 := if_then_else( [?List_of_AE = List(%censp_1st | %censp_rest)],
     /*then*/ fc_append_with_spaces _(fc_parts(%censp_1st,?notationSet),
                                      fc_AEs_parts(%censp_rest,?notationSet),
                                      fc_find_other_space_specs(?ae,?notationSet)),
     /*else*/ "" );


 //Reminder (and example) on the specification of CE for an AE:
 //  f_in(AE RIF) ?rifAE 
 //     rc_spec: .[fc_OP_from(?rifAE) "(" fc_ARGS_from _(?rifAE) ")"],
 //                .{RIF-PS}]
fc_find_specs ~[AE ?ae, ?notationSet] 
 := (the List ?specs r_1st_arg of: (a List r_2nd_arg: ?notationSet, 
                                           /*most direct*/rc_spec of: ?ae )); 

fc_find_other_space_specs ~[AE ?ae, ?notationSet]
 := (the List ?s_specs r_2nd_arg of: (a List r_2nd_arg: ?notationSet, 
                                             /*most direct*/rc_sSpec of: ?ae ));


//cf. fc_type, e.g., ?ceType = .[fc_OP_from(?rifAE) "(" fc_ARGS_from_(?rifAE) ")"]
fc_apply_specs ~[AE ?ae, ?ceNonSpacePartsSpecs,
                                ?ceSpacePartsSpecs, ?notationSet]
 /^ Generation_function,
 := if-then-else_( [?ceNonSpacePartsSpec = .[%censp_1st | %censp_rest]],
     /*then*/ fc_append_with_spaces _(fc_apply_spec(?ae,%censp_1st,?notationSet),
                                      fc_apply_specs_(?ae,%censp_rest),
                                      ?ceSpacePartsSpecs ),
     /*else*/ .[] );

fc_apply_spec ~[AE ?ae, ?ceNonSpacePart, ?notationSet]
 /^ Generation_function,
 := if-then-else_( [?ceNonSpacePart /^^ String],
     /*then*/.[?ceNonSpacePart],
     /*else*/if-then-else_( [?ceNonSpacePart.r_1st_arg = r_args],
                     //e.g.: ?ceNonSpacePart= .[r_args, ?ae.r_args, ?space_specs]
              /*then*/if_then_else( [?ceNonSpacePart.r_3rd_arg = .[]],
                       /*then*/fc_AEs_parts(?ceNonSpacePart.r_2nd_arg,?notationSet),
                       /*else*/fc_AEs_parts(?ceNonSpacePart.r_2nd_arg,?notationSet,
                                            ?ceNonSpacePart.r_3rd_arg ) ),
              /*else*/fc_parts _(?ceNonSpacePart.r_2nd_arg,//e.g., ?ae.r_arg
                                        ?notationSet) ) );

fc_append_with_spaces ~[?str1, ?str2, ?ceSpacePartsSpecs/*e.g.,= " "*/]
 /^ Generation_function,
 := if-then-else_( [?ceNonSpacePart /^^ String],
     /*then*/fc_append _(?str1,?ceNonSpacePart,?str2),
     /*else*/fc_append _(?str1," ",?str2) );




4.  Direct importing

Author: Jérémy Bénard (jb).

f_import_list_of_token_to_AE
  input: 1 List ?list_of_token,
  param: 1 KRL_model ?model  1 KRL_notation ?notation,
  output: 1 AE,
  := f_import_fct _(?list_of_token,?model,?notation) . first;  //1st solution

f_import_fct  //returns null if no valid rule was found
  input: 1 List ?list_of_token, //list transmitted to the sub-functions 
  param: 1 KRL_model ?model  1 KRL_notation,
  output: 1 List,
  := jb#Simple_graph_map _(f_all_possible_new_AE_instances _(?model,?notation),
                           f_test_spec,
                           f_thing_that_does_not_have_for_r-part_a_parse_error);

f_all_possible_new_AE_instances  //returns a list of individuals with 
  param: 1 KRL_model ?model             //  type one of the EA types in ?model
         1 KRL_notation ?notation,      //  and for ?notation
  output: 1 List,
  := jb#Simple_graph_map 
       _(?model.r_KRL_type_of, ^(fquery_has_specs  input: ?notation),
         fquery_build_list_of_instances_of_AE);

fquery_has_specs
  input: 1 AE ?ae  1 KRL_notation ?notation,
  := [ [?ae rc_spec: (a Set r_2nd_arg: (?notationSet r_member: ?notation))] ];

fquery_build_list_of_instances_of_AE
  input: 1 AE ?ae,    output: 1 List ?result,
  := [ [?result   head: (Individual type: ?ae),   tail: 1 List] ];

f_test_spec //return null(error) or the parts (operator+arguments) of ?ae
  input: 1 AE ?ae,    param: 1 List ?list_of_token,    output: 1 List,
  := jb#Simple_graph_map _(fc_find_specs _(?ae  ?notation)
                             ^(f_compare_spec_element_with_string_token
                                 input: ?list_of_token.head) );

f_compare_spec_element_with_string_token
   //compares each element of ?spec_element with ?string_token, and 
   //creates relations between ?ae and it parts
  input: 1 List_or_string ?spec_element  //e.g., "(", fc_op_from(?ae)
         1 String ?string_token
         1 AE ?ae,
  := 
   if_then_else([?spec_element.first  type: String],
    /*then*/if_then_else _([?spec_element = ?string_token],
             /*then*/.[null, f_next(?list_of_token)], //no error, no EA to import
             /*else*/.[jb#parse_error, ?string_token] ), //unapplicable rule
    /*else*/if_then_else _([?spec_element.second = ?string_token],
             /*then*/f_add_operator_name(?ae ?string_token),
             /*else*/if_then_else _([?spec_element.first = r_args],
                      /*then*/List(jb#Simple_graph_map _(
                                    f_import_fct(?list_of_token,?model,?notation)
                                    [?ae r_args: ?list_element] ),
                                  ?list_of_token ),
                      /*else*/if_then_else
                               _(fc_find_specs _(?ae .(?spec_element.first),
                                                 ?model, ?notation),
                               /*then*/f_test_spec _(f_build_AE _( 
                                             [AE ?spec_element.first of: ?ae] ),
                                                     ?list_of_token),
                               /*else*/f_add_relation_to_Type_as_AE _(
                                         ?string_token, ?spec_element) ) ) ) );

f_add_operator_name  /^ Generation_function,
  input: 1 AE ?ae  1 String ?string_token, 
  output: 1 List ?result,
  := [?result  r_1rst: (?ae  rc_operator_name: ?string_token),
               r_2nd:  f_next(?list_of_token) ];

f_add_relation_to_Type_as_AE   /^ Generation_function,
  input: 1 String ?string_token  1 function_or_string ?spec_element  1 AE ?ae,
  output: 1 List ?result,
  := [?result
        r_1rst: (?ae  ?spec_element.first:
                          (Type_as_AE  r_description_instrument of:
                                              find_content _(?string_token)) ),
        r_2nd: f_next _(?list_of_token) ];