Logic Models MD3

Logic Models MD3

Logic Models are small programs written in a logic programming language that, given a set of arguments (parameters), are able to deduce the value of another argument. In Match™ the logic programming language used is Prolog. Logic models cannot be used in tables, but can be accessed through variables. Logic models in Match™ are treated as separate isolated Prolog programs and cannot use each other’s parts.

Some Prolog syntax

bigger(elephant, monkey). This is a fact. It is what it says without conditions or exceptions.

ismore(Xnumber, Ynumber) :- Xnumber > Ynumber. This is a rule. The symbols :- are to be read as "if". elephant and monkey are atoms (constants), words starting with a lower case letter. Xnumber and Ynumber are variables, words starting with an upper case letter.

Facts and rules are closed by a period. Their names start with a lower case letter.

A text (or string) has at its beginning and end single quotes (apostrophes), or double quotes.

A percent sign (%) followed by text at the same line is comment. It serves as explanation and is ignored during execution.

For these language types there are more naming possibilities than mentioned here. Many language references, manuals and tutorials are available on the internet.

A call to a program is named a query, eg. ismore(5.41, 5.47). In a Prolog environment the "implicit" result will be 'false' or 'no'.

In Match the logic model name is the query without arguments. As a consequence the name must start with a lower case letter. For readability upper case and underscore can be used: isMore, is_more.

Moreover the result of the Prolog execution must be an explicit argument: ismore(Xnumber, Ynumber, Result). Match only supports such an explicit, single result to be received in a variable. In it Allow multiple values is not allowed.

In a variable's Properties, tab Consultation, section Inference Method, the query can be edited. Not as a single line, but in Properties Use logic model and Arguments.

Logic model example

Use of a logic model is best explained by an example KB. It accepts a text from user and derives the number of characters. Please download and unzip to get TextLengthLogicModel.kb.

The logic model is named textLength. Input argument is Stext, a string of text. Output argument is Number_chars, the number of characters. variable LengthFromLogicModel uses textLength for inference method. In the tables the user enters the text in variable TextFromUserTemp. The text is delimited with single quotes into variable TextFromUser. This variable is the first argument of logic model textLength. The second argument, result of the Prolog execution, is variable LengthFromLogicModel itself.

This is all detailed in the pages at the left.