Difference between revisions of "Rules"

From BC$ MobileTV Wiki
Jump to: navigation, search
 
(7 intermediate revisions by one other user not shown)
Line 2: Line 2:
 
'''Rules''' are logical limitations or conditional cases placed upon a set of data or transfer of data.
 
'''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
 +
}}
  
  
Line 9: Line 13:
 
=== RIF ===
 
=== RIF ===
  
The mission of the Rule Interchange Format (RIF) Working Group is to produce W3C Recommendations for rules interchange
+
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 Core: http://www.w3.org/TR/rif-core/
Line 23: Line 27:
 
===== RuleML =====
 
===== RuleML =====
  
Father of RIF standards, RuleML was an early [[XML]] syntax for representing [[POSL]] rulebases more efficiently than their slightly verbose syntax.
+
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."
Line 87: Line 91:
 
   Transport.send(msg);    // Hand message to the default transport service for delivery
 
   Transport.send(msg);    // Hand message to the default transport service for delivery
 
  }
 
  }
catch (MessagingException mex) {
+
catch (MessagingException mex) {
mex.printStackTrace();
+
  mex.printStackTrace();
 
  }
 
  }
 
* [[wikipedia: Inference]]
 
* [[wikipedia: Inference]]
Line 97: Line 101:
  
  
=== Resources ===
+
== 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 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
 
* 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 ==
 
== External Links ==
  
 +
* [[wikipedia: Rule of inference]]
 
* [[wikipedia: Business rule]]
 
* [[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/
 
* Rules and Norms - Requirements for Rule Interchange Languages in the Legal Domain: http://www.springerlink.com/content/v81q672j251ln864/
  
 
== See Also ==
 
== See Also ==
  
[[Rule Engine]] | [[Description Logic]]
+
[[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