Home

ORM+ rules in PROLOG


STAR Members>>Yan Tang>>ORM+ rules in PROLOG

PROLOG (Programming in Logic, e.g. in [B00]) is based on the mathematical notions of relations and logical inferences. It is a mainly declarative language that consists of a data base of facts (a fact here will be a DOGMA lexon) and axioms (also called rules of PROLOG at the DOGMA commitment layer).

We argue that PROLOG can be used for several purposes in ORM+, such as 1) to constraint and describe logic relationships amongst lexons or sets of lexons – we refer those logic relationships as the basic connectors in the business rule UoD (Universe of Discourse) on the application layer; 2) to provide reasoning facility which includes tracing the declarative meaning and the procedural meaning of the application rules, with which the agents can map correctly the application rules to the rule ontology on the conceptual level.

An ORM+ example in Prolog:

lexon(context,term1,role,corole,term2):-print('lexon<'),print(context),print(','),print(term1),print(','),print(role),print(','),print(corole),print(','),print(term2).

%the Cost (term1 in the lexon with ID 68502) has value that is always more than 0
l68502:-lexon('CCTONT','Cost','subClassOf','superClassOf','SomethingOfValue'),term1_value(V), V>0.

%the Debt (term1 in the lexon with ID 68503) has value that is always less than 0
l68503:-lexon('CCTONT','Debt','subClassOf','superClassOf','SomethingOfValue'), term1_value(V), V<0.

%the Assetion of a healthy company (term1 in the lexon with ID 68501) has value that is at least 0
l68501:-lexon('CCTONT','Asset','subClassOf','superClassOf','SomethingOfValue'),term1_value(V), V>=0.

%Action is only described by both of the Lexon with the ID of 57714 and the Lexon with the ID of 57715
action_definition:-conjunction_addition('L57714','L57715').
'L57714'.
'L57715'.

%Condition is only described by both of the lexon with the ID of 57716 and the lexon with the ID of 57717
condition_definition:-conjunction_addition('L57716','L57717').
'L57716'.
'L57717'.

%a definition of a Rule Column is given by both of the lexon 57722 and 57723.
rule_column_definition:-conjunction_addition('L57722','L57723').
'L57722'.
'L57723'.

%a rule can have many action entries
l57723:-conjunction_addition('L57722','L57723'), term2_occurence(Nbr),Nbr>0, role_cardinality('1:M'),corole_cardinality('M:1').

%follow CSA policy 1, thus the term2 occurence of the lexon with ID 57704 is checked
l57704:-'L57704',term2_occurence(Nbr),Nbr>=0.
'L57704'.

%the condition entry of a limited entry table has only the value of 'Yes' or 'No'. (CSA Z243.1-1970, page 8, item 2.2)
l57708_l57724:-'L57708','L57724', term2_value(Value),or(Value,['Yes','No']).
%lexon selection
'L57708'.
'L57724'.

% CSA policy 1: zero conditions is allowed (CSA Z243.1-1970, page 15, item A4)
p1 :- conditionSet(ConditionNbr), ConditionNbr>=0.
% CSA policy 2: to have multi-actions in one Rule is allowed, page 14, figure A1
p2 :- actionSet(ActionNbr), ActionNbr>0.
% CSA policy 3: a limited entry table has only the value of 'Yes' or 'No'.(CSA Z243.1-1970, page 8, item 2.2)
p3:- l57724. % refer to the rule on the lexon with ID 57724.

%to check if Value is one of the possiblities in the value list
or(Value,[Value|VList]).
or(Value,[X|VList]):- or(Value,VList).

% define the function conjunction_addition().
conjunction_addition(X,Y):-X,Y.

% to check if X is in the List.
is_member(X,[X,List]).
is_member(X,[Element|List]):-is_member(X,List).

%in business domain, a decision of Renting an equipment is choosen automatically if the budget is <=0
l900801:-l500065_term2_value(Value), Value=<0.
l500065_term2_value(Value):-'L200065', term2_value(Value).
'L200065'.

term1_value(V):-print('give me a value of term1 : '), read(V).
term2_value(V):-print('give me a value of term2 : '), read(V).

term1_occurence(Nbr):-print('give me the occurence number of term1 : '), read(Nbr).
term2_occurence(Nbr):-print('give me the occurence number of term2 : '), read(Nbr).

role_cardinality(Type):-print('The cardinality type of the role is '), print(Type).
corole_cardinality(Type):-print('The cardinality type of the corole is '), print(Type).

conditionSet(Nbr):-print('give me the condition number of your decision table: '),read(Nbr).
actionSet(Nbr):-print('check: how many actions do you get in one rule? '),read(Nbr).

%test, type test1 etc.
appl_info:-print('This is to test the axioms, rules and assertions in the commitment layer\n').
test1:-appl_info,print('test if it is a Cost -Lexon 68502-'),l68502.
test2:-appl_info,print('test if it is a Debt -Lexon 68503-'),l68503.
test3:-appl_info,print('test if it is an Asset of a healthy company -Lexon 68501-'),l68501.
test4:-appl_info,print('test if it is a legal decision table -Lexon 57704-'),l57704.
test5:-appl_info,print('the definition of Action - '),action_definition.
test6:-appl_info,print('the definition of Condition - '),condition_definition.
test7:-appl_info,print('the definition of rule column - '),rule_column_definition.
test8:-appl_info,print('the assertion on Lexon 57723 - '),l57723.
test9:-appl_info,print('test if it is a limited entry table, lexon 57724 and 57708 are selected - '),l57708_l57724.
test10:-appl_info,print('test the rule as if the budget value <=0, then decision is to borrow'),l900801.

More examples see the attachments.

Reference:

[B00] I. Bratko, Prolog Programming for Artificial Intelligence, Addison Wesley Publisher, 3rd edition, 2000.

[last updated at 16:51:09, 2006-09-06]

back to Yan Tang's home page

AttachmentSize
SDT_example_test.pl4.36 KB
lexonInitiation.pl460 bytes
lexonConstraints.pl489 bytes
lexonSelection.pl64 bytes