Difference between revisions of "Rules"

From BC$ MobileTV Wiki
Jump to: navigation, search
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''Rules''' are logical limitations or cases placed upon a set of data or transfer of data.
+
[[Image:Rules.png|thumb|200px|Rule Inference process]]
 +
'''Rules''' are logical limitations or conditional cases placed upon a set of data or transfer of data.
  
 +
{{#widget:SlideShare
 +
|doc=rules-tutorial-100721120729-phpapp02
 +
|width=425
 +
|height=348
 +
}}
  
== RuleML ==
+
 
 +
== Specifications ==
 +
 
 +
=== RIF ===
 +
 
 +
The mission of the Rule Interchange Format (RIF) Working Group is to produce W3C Recommendations for rules interchange, which could support each of its predecessor languages: [[#SWRL | SWRL]], [[#RuleML | RuleML]], [[#POSL | POSL]] and other derivaties such as [http://www.jboss.org/drools/drools-expert.html Drools Business Rules], [http://www.ebpml.org/bpml.htm BPML] or [[BPEL]].
 +
 
 +
* RIF Core: http://www.w3.org/TR/rif-core/
 +
* RIF Working Group: http://www.w3.org/2005/rules/wiki/RIF_Working_Group
 +
 
 +
==== SWRL ====
 +
 
 +
A '''S'''emantic '''W'''eb '''R'''ule '''L'''anguage combining [[OWL]] and [[#RuleML | RuleML]] (SWRL)
 +
 
 +
* SWRL Spec: http://www.w3.org/Submission/SWRL/
 +
* RuleML page on SWRL: http://www.ruleml.org/swrl/
 +
 
 +
===== RuleML =====
 +
 
 +
Father of RIF standards, RuleML was an early [[XML]] syntax for representing [[#POSL | POSL]] rulebases more efficiently than their slightly verbose syntax.
  
 
"Rules in (and for) the Web have become a mainstream topic since inference rules were marked up for E-Commerce and were identified as a Design Issue of the Semantic Web, and since transformation rules were put to practice for document generation from a central XML repository (as used here). Moreover, rules have continued to play an important role in AI shells for knowledge-based systems and in Intelligent Agents, today both needing a Web interchange format, and such XML/RDF-standardized rules are now also usable for the declarative specification of Web Services."
 
"Rules in (and for) the Web have become a mainstream topic since inference rules were marked up for E-Commerce and were identified as a Design Issue of the Semantic Web, and since transformation rules were put to practice for document generation from a central XML repository (as used here). Moreover, rules have continued to play an important role in AI shells for knowledge-based systems and in Intelligent Agents, today both needing a Web interchange format, and such XML/RDF-standardized rules are now also usable for the declarative specification of Web Services."
  
 
* RuleML Home: http://www.ruleml.org/
 
* RuleML Home: http://www.ruleml.org/
* Are your Rules online? Four Web Rule Essentials: http://www.ruleml.org/talks/RuleEssentials-talk.pdf
+
* RuleML 1.0 spec & schema: http://ruleml.org/1.0/
 +
* Reaction RuleML Translator: http://ibis.in.tum.de/research/ReactionRuleML/translation.htm
 +
* Are your Rules online? Four Web Rule Essentials [TALK]: http://www.ruleml.org/talks/RuleEssentials-talk.pdf
 +
* RuleML -- The Overarching Specification of Web Rules: http://www.cs.unb.ca/~boley/papers/RuleML-Overarching.pdf
 +
* RuleML -- The Overarching Specification of Web Rules [TALK]: http://www.cs.unb.ca/~boley/talks/RuleML-Overarching-Talk.ppt
  
 +
====== POSL ======
  
 +
'''POSL''' is the grandfather of the RIF standard and started as a research initiative into Rule Engines at [[NRC]]-IIT (in Canada).
  
== RIF ==
+
* POSL - : http://ojs.academypublisher.com/index.php/jetwi/article/view/0204343353
  
The mission of the Rule Interchange Format (RIF) Working Group is to produce W3C Recommendations for rules interchange
 
  
* RIF Core: http://www.w3.org/TR/rif-core/
 
* RIF Working Group: http://www.w3.org/2005/rules/wiki/RIF_Working_Group
 
  
  
 +
== Inference ==
  
== SWRL ==
+
Inference is what happens when a rule base or logic set is triggered (i.e. run in the backend) to evaluate outcomes against some incoming inputs. An example is that you have a rule base representing a patient (i.e. vital signs) and you want to check whether their blood pressure exceeded a specific threshold (i.e. 150/80 where "150" is the systolic blood pressure measurement and we don't want it going any higher than 150, and, "80" is diastolic blood pressure measurement and we don't want it going any lower than 80), and if so, send a warning message to their nurse, doctor or other healthcare providers of interest.
  
SWRL: A Semantic Web Rule Language Combining OWL and RuleML
+
The (raw) input would look as follows:
 +
blood_pressure = 150/80
  
* SWRL Spec: http://www.w3.org/Submission/SWRL/
+
The Rule Engine parses the blood pressure measurement and produces actionable inputs:
* RuleML page on SWRL: http://www.ruleml.org/swrl/
+
blood_pressure = 150/80
 +
blood_pressure_systolic = 150
 +
blood_pressure_diastolic = 80
  
 +
The rule-base might look as follows:
 +
IF blood_pressure_systolic > 150
 +
  OR
 +
    blood_pressure_diastolic < 80
 +
THEN
 +
  notify Nurse ==> blood_pressure, patient_name
  
 +
The Nurse object would correspond to some data or query built into the system, such as the [[SQL]] statement:
 +
SELECT nurse_name,nurse_email,nurse_phone FROM patient_nurses LEFT JOIN nurses ON patient_nurses.nid=nurses.nurse_id WHERE patient.patient_id=12345;
 +
(although it wouldn't necessarily need to be SQL, and data or object persistence system could be interacted with to do the inference).
  
 +
The inference would then occur according to the definition of the ''action'' which was to "notify" the Nurse (in a specific programming language, i.e. Java):
 +
import java.util.*;
 +
import javax.mail.*;
 +
import javax.mail.internet.*;
 +
import javax.activation.*;
 +
...
 +
Properties props = System.getProperties();
 +
  props.put("mail.host", host);
 +
  props.put("mail.transport.protocol", "smtp");
 +
Session session = Session.getDefaultInstance(props, null);
 +
  session.setDebug(false);
 +
try {
 +
  Message msg = new MimeMessage(session);  // Instantiate new MimeMessage and fill with required information
 +
  msg.setFrom(new InternetAddress(from));
 +
  InternetAddress[] address = {new InternetAddress(to)};
 +
    msg.setRecipients(Message.RecipientType.TO, address);
 +
    msg.setSubject(subject);
 +
    msg.setSentDate(new Date());
 +
    msg.setText(messageText);
 +
  Transport.send(msg);    // Hand message to the default transport service for delivery
 +
}
 +
catch (MessagingException mex) {
 +
  mex.printStackTrace();
 +
}
 +
* [[wikipedia: Inference]]
  
== External Links ==
 
  
* SPIN Diff: Rule-based Comparison of RDF Models: http://www.semanticweb.com/insight/article.php/3832126
 
  
  
  
 +
 +
== Resources ==
 +
 +
* '''Why are business rules better than traditional code?: http://www.edmblog.com/weblog/2005/11/why_are_busines.html'''
 +
* SPIN Diff -- Rule-based Comparison of RDF Models: http://www.semanticweb.com/insight/article.php/3832126
 +
* SPIN -- An object-oriented framework for business rules using SPARQL: http://vimeo.com/5544950
 +
* No Danglers Rule in Communications (writing/debate): http://austhink.com/reason/tutorials/Tutorial_2/9_No_Danglers/no_danglers.htm
 +
 +
 +
== Tutorials ==
 +
 +
* '''Real-World Rule Engines: http://www.infoq.com/articles/Rule-Engines'''
 +
* Implement business logic with the Drools rules engine: http://www.ibm.com/developerworks/java/library/j-drools/
 +
* Rules-based Programming with JBoss Rules/Drools: http://www.codeodor.com/index.cfm/2007/9/10/Rules-based-Programming-with-JBoss-RulesDrools/1600#drools
 +
* Introduction to Programming with Jess in Java http://www.jessrules.com/jess/docs/71/library.html
 +
* Getting Started With the Java Rule Engine API (JSR 94): Toward Rule-Based Applications: http://java.sun.com/developer/technicalArticles/J2SE/JavaRule.html
 +
* Argument Mapping Tutorials: http://austhink.com/reason/tutorials/ (communications for writing/debating)
 +
 +
 +
== External Links ==
 +
 +
* [[wikipedia: Rule of inference]]
 +
* [[wikipedia: Business rule]]
 +
* [[wikipedia: Business rules engine]]
 +
* [[wikipedia: Rule of law]]
 +
* [[wikipedia: Ethics]]
 +
* [[wikipedia: Normative ethics]]
 +
* [[wikipedia: Deontological ethics]]
 +
* [[wikipedia: Virtue ethics]]
 +
* [[wikipedia: Consequentialism]]
 +
* [[wikipedia: Ethics of care]]
 +
* [[wikipedia: Pragmatic ethics]]
 +
* Rules and Norms - Requirements for Rule Interchange Languages in the Legal Domain: http://www.springerlink.com/content/v81q672j251ln864/
  
 
== See Also ==
 
== See Also ==
  
[[Rule Engine]]
+
[[Rule Engine]] | [[Description Logic]] | [[Law]]

Latest revision as of 21:21, 2 January 2013

Rule Inference process

Rules are logical limitations or conditional cases placed upon a set of data or transfer of data.


Specifications

RIF

The mission of the Rule Interchange Format (RIF) Working Group is to produce W3C Recommendations for rules interchange, which could support each of its predecessor languages: SWRL, RuleML, POSL and other derivaties such as Drools Business Rules, BPML or BPEL.

SWRL

A Semantic Web Rule Language combining OWL and  RuleML (SWRL)
RuleML

Father of RIF standards, RuleML was an early XML syntax for representing POSL rulebases more efficiently than their slightly verbose syntax.

"Rules in (and for) the Web have become a mainstream topic since inference rules were marked up for E-Commerce and were identified as a Design Issue of the Semantic Web, and since transformation rules were put to practice for document generation from a central XML repository (as used here). Moreover, rules have continued to play an important role in AI shells for knowledge-based systems and in Intelligent Agents, today both needing a Web interchange format, and such XML/RDF-standardized rules are now also usable for the declarative specification of Web Services."

POSL

POSL is the grandfather of the RIF standard and started as a research initiative into Rule Engines at NRC-IIT (in Canada).



Inference

Inference is what happens when a rule base or logic set is triggered (i.e. run in the backend) to evaluate outcomes against some incoming inputs. An example is that you have a rule base representing a patient (i.e. vital signs) and you want to check whether their blood pressure exceeded a specific threshold (i.e. 150/80 where "150" is the systolic blood pressure measurement and we don't want it going any higher than 150, and, "80" is diastolic blood pressure measurement and we don't want it going any lower than 80), and if so, send a warning message to their nurse, doctor or other healthcare providers of interest.

The (raw) input would look as follows:

blood_pressure = 150/80

The Rule Engine parses the blood pressure measurement and produces actionable inputs:

blood_pressure = 150/80
blood_pressure_systolic = 150
blood_pressure_diastolic = 80

The rule-base might look as follows:

IF blood_pressure_systolic > 150
  OR 
   blood_pressure_diastolic < 80
THEN 
  notify Nurse ==> blood_pressure, patient_name

The Nurse object would correspond to some data or query built into the system, such as the SQL statement:

SELECT nurse_name,nurse_email,nurse_phone FROM patient_nurses LEFT JOIN nurses ON patient_nurses.nid=nurses.nurse_id WHERE patient.patient_id=12345;

(although it wouldn't necessarily need to be SQL, and data or object persistence system could be interacted with to do the inference).

The inference would then occur according to the definition of the action which was to "notify" the Nurse (in a specific programming language, i.e. Java):

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
...
Properties props = System.getProperties();
  props.put("mail.host", host);
  props.put("mail.transport.protocol", "smtp");
Session session = Session.getDefaultInstance(props, null);
  session.setDebug(false);
try {
  Message msg = new MimeMessage(session);   // Instantiate new MimeMessage and fill with required information
  msg.setFrom(new InternetAddress(from));
  InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setSubject(subject);
    msg.setSentDate(new Date());
    msg.setText(messageText);
  Transport.send(msg);    // Hand message to the default transport service for delivery
}
catch (MessagingException mex) {
 mex.printStackTrace();
}




Resources


Tutorials


External Links

See Also

Rule Engine | Description Logic | Law