NL (natural language) syntax

Pro/3 home page  -  documentation overview  -  What is Pro/3?
 syntax conventions  - syntax
» syntaxes  -  names

This syntax describes NL (natural language) syntax. NL-format is used for sentences, function definitions and queries. File-type 3NL signifies NL-format. The NL syntax applies to facts (sentences) (including function declaration sentences) queries, function definitions and to a limited extent to sentence rules (simple implication rules).

Syntax conventions

COMMENTS

 Refer to syntax - Comments.

NAMES

Refer to names.

STRING LITERALS

String literals are embedded between two quotes (e.g. "this is a string literal"). Starting with version 4.05, the following set of reserved characters should be avoided in string literals:

? ! " ' | [ ] { }

  • ?  is used to terminate a query (NL/PR)

  • ! is used to terminate a sentence or sentence rule (NL/PR)

  • " is used for string literals: "xxx"

  • ' is used by Pro/3 internally for literals within literals.

  • | is used by Pro/3 as a separator in internal string concatenations

  • [ ] is used to embed parameters in KB-queries and inexact rule questions

  • { } is used in internal string-encoding of terms (term-strings)

String literals within string literals

Occasionally it is important to be able to embed string literals within string literals. One example is the query text data element in the KB-query entity type. This data element contains a query, and, a query can of course include a string literal. The inner string literal is then framed by the ` character, as in the following example:

KB-query with menu-ID 8105, language English, menu name "Model names starting on R", format NL, query text "which bike model with name=`R%` is listed" and owner menu 8100 is in the model!

See also term-strings.

NUMBERS

The decimal point character is period . (e.g. 3.14). 

Numbers can include comma separators (e.g. 10,000). This represents a source of syntactical ambiguity in list of numbers (e.g. 111,120 and 13 could be understood both as a list of two numbers (111120 and 13) and of three numbers (111, 120 and 13). It can also give problems in ranges, where e.g. the range [12,100] could be read as the range from 12 to 100 or as the invalid syntax [12100].

The syntax convention adopted to avoid these ambiguities is that the comma used to separate numbers in lists or in ranges must be followed by at least one space character, e.g. as in the list 1000, 2000 and 3000 and the range [1, 10].  

GENERAL SYNTAX FOR LISTS

[<member> { , <member>}* and ] <member>

NL-syntax
<AllAboutQuery> { what is known about | all about } <SimpleLiteral> ?
This is hybrid between a query and a report. See queries for details.
<ArgumentCondition> [ the ] entityType [ with <DE_Conditions> ]
[ the ] entityType <Expression>
The second syntax is only allowed for atomic entity types.
<AssignmentOperator> =
<BinaryOperator> <AssignmentOperator>
<ComparisonOperator>
<BinarySentence> <Entity> binaryPredicateType <Entity> [ with <DE_Values> ]
<BinarySentenceCondition> <ArgumentCondition> binaryPredicateType <ArgumentCondition> [{ with | for }<DE_Conditions>]
<BinarySentenceQuery> interrogative <QueryArgument> binaryPredicateType <QueryArgument> [{ with | for }<DE_Conditions>] ?
<ComparisonOperator> { = | < | <= | > | >= | <> | like | unlike }
<Conclusion> <SentenceCondition>
The sentence condition in a conclusion must have an expression assigned to each and all of the data element types in the sentence type.
<Condition> <SentenceCondition>
<VariableCondition>
<CR_Parameter> inexactRule:dataElementType
this dataElementType
<DataElement> dataElementType
<DataElementReferenceQuery> interrogative = <DE_Reference> ?
<DE_Condition> <DataElement> <ComparisonOperator> <Expression>
<DataElement> { inside [ the range ] | outside [ the range ] } <Range>
<DE_Conditions> <DE_Condition>
<DE_Condition> { , <DE_Condition> }+ and <DE_Condition>
<DE_Reference> [the] [first] value of [the] <DataElement> { for | of | where } <SentenceCondition>
[the] [first] value of [the] <QualifiedDataElement> { for | of | where } <SentenceCondition>
<DE_Value> <SimpleDE_Value>
<DE_Values> <DE_Value> [ { , <DE_Value> }* and <DE_Value> ] 
<Entity> [ the ] entityType with <DE_Values>
[ the ] <Value> entityType
[ the ] entityType <Value>
The second and third syntax are alternative syntaxes which apply to atomary entity types only.
<Expression> <SimpleExpression>
(<SimpleExpression>)
(<Expression> <Operator> <Expression>)
<FunctionDefinition> function is defined by <FunctionStatement> { ; <FunctionStatement> }* !
<FunctionCall> function [ [ <ParameterAssignments> ] ]
function given <ParameterAssignments>
<FunctionCallQuery> interrogative = <FunctionCall> ?
<FunctionDeclaration> [the] [deterministic | non-deterministic] function with NL-name function, domain domain and [data element list <ParameterList>|no data element list] is in the sentence model for segment name "segment"
<FunctionParameter> function:dataElementType
this dataElementType
<FunctionStatement> <Variable> <BinaryOperator> <Expression>
return value <AssignmentOperator> <Expression>
The return value statement occurs once and only once as the last statement in the function definition.
<ListLiteral> <SimpleLiteral> 
<SimpleLiteral> { , <SimpleLiteral> }* and <SimpleLiteral>
<Literal> <ListLiteral>
<SimpleLiteral>
<Operator> +,_,*,/,^,mod
<Parameter> <CR_Parameter>
<FunctionParameter>
<ParameterAssignment>  dataElementType =d <Expression>
d is the short form of the data element type's domain.
<ParameterAssignments>  <ParameterAssignment>
 <ParameterAssignment> [ , <ParameterAssignment> ] and <ParameterAssignment>
<ParameterList> dataElementType
dataElementType [ , dataElementType ] and dataElementType 
dataElementType are names of simple data element types.
<QualifiedDataElement> entityType:<DataElement>
predicateType:<DataElement>
<DataElement> [argumentNumber]
argumentNumber is 0 (for data elements belonging to the predicate), 1 (for data elements belong to the first entity argument) or 2 (for data elements belonging to the second entity argument)
<Query> <SentenceQuery>
<YesNoQuery>
<DataElementReferenceQuery>
<FunctionCallQuery>
<SolutionSetSizeQuery>
<AllAboutQuery>
<QueryArgument> <SimpleVariable>
<ArgumentCondition>
<Range> { [ | < } <Expression> , <Expression> { [ | > }
<Sentence> <UnarySentence>
<BinarySentence>
<SentenceCondition> <BinarySentenceCondition>
<UnarySentenceCondition>
<SentenceQuery> <UnarySentenceQuery>
<BinarySentenceQuery>
<SimpleExpression> <Literal>
<Variable>
<DE_Reference>
<FunctionCall>
<SolutionSetSize>
<SimpleDE_Value> dataElementType [ <AssignmentOperator> ] <Literal>
no dataElementType
DE is the NL-name of a simple data element type. DOM is the short form of the destination domain. The second syntax variant is used for list data elements with an empty list is value.
<SimpleImplicationRule> if [it is not true that] <Condition> [{ ,[it is not true that] <Condition> }* and [it is not true that] <Condition>] then <Conclusion> !
<SimpleLiteral> An integer, fixed-point number, identifier (NL-name) or a string (always in quotes).
<SimpleVariable> See names.
<SolutionSetSize> { # | [the] number of [sentences of] [the] } <SentenceCondition>
<SolutionSetSizeQuery> interrogative = <SolutionSetSize> ?
<UnarySentence> <Entity> unaryPredicateType  [{ with | for }<DE_Values>]
<UnarySentenceCondition> <ArgumentCondition> unaryPredicateType [{ with | for }<DE_Conditions>]
<UnarySentenceQuery> interrogative unaryPredicateType [{ with | for }<DE_Conditions>] ?
interrogative <QueryArgument> unaryPredicateType [{ with | for }<DE_Conditions>] ?
<Variable> <Parameter> 
<SimpleVariable>
<VariableCondition> <SimpleVariable> {<ComparisonOperator>|<AssignmentOperator>} <Expression>
<YesNoQuery> is it true that <SentenceCondition> ?