This is an archive of an inactive wiki and cannot be modified.

# RIF example UC6: Ruleset Integration for Medical Decision Support

## Summary

This is an attempt to encode some rules for the use case Ruleset Integration for Medical Decision Support, using the RIF Core language designed by Harold Boley and Michael Kifer. Full striping is used.

## Choices and Issues in Translation: Temporal Reasoning

Temporal representation is an important concern in medical rules. One reasons about actions in the past, future prognoses, and ongoing treatments. Thus, it is important to use a comprehensive and flexible temporal representation language. For this exercise, we have chosen to use a situation-calculus dialect. This exercise therefore serves as a test case for translating from sitcalc to RIF Core.

In the situation calculus, one would often writes a rule in the form: Holds(T1, F1(X1, .... , Xn)) :- Holds(T2, F2(Y1, ...., Ym))

For example:

Holds(t23, Lit(Lightbulb)) :- Holds(t23, On(Switch))

It is important to realize that Lit(Lightbulb)) and On(Switch)) are terms, not sentences. That, if the second argument of the Holds predicate is F(X1, ..., Xn), then F is a function mapping X1, ..., Xn (to the set of time instances in which intuitively, the fluent holds). Reification (advocated by John McCarthy in his work on the situation calculus) allows us to interpret F(Y1, ..., Ym) as a term, rather than as a sentence.

This therefore brings up the issue of representing reification in RIF.

## Source Rules

Rule 1: If a Type II diabetes patient's current level of HbA1c is high, then the patient's current treatment is considered to be ineffective.

Formalization in first-order logic, situation-calculus style:

1a. (Forall X, T, P) Holds(T, Ineffective(P,X, diabetesTypeII)) :- Holds(T, HasDisease(X, diabetesTypeII)) & Holds(T, Elevated(LevelOf(hbA1c,X))) & Holds(T, TreatmentPlan(X, P)).

1 b. (Forall T,X,L,J,K,Z) Holds(T,Elevated(LevelOf(L,X))) :- NormalRange(L,J,K) & Holds(T, LevelOf(L,X) = Z) & Z > K.

Rule 2: If an oral monotherapy at recommended doses of a sulfonylurea or biguanide, combined with lifestyle changes, is ineffective, then the monotherapy should be replaced by an oral bitherapy.

Formalization in FOL, SC:

2. (Forall P, T, X, M) Do(Replace(P, OralMonotherapy,OralBitherapy),T):- Holds(T, Ineffective(P, X, DiabetesTypeII)) & PartOfTreatmentPlan(P, X, DiabetesTypeII, LifeStyleChange) & PartOfTreatmentPlan(P, X, DiabetesTypeII, OralMonotherapy, M) & (Isa(M, sulfonylurea) | Isa(M, biguanide)).

## Translation into RIF Core

Translation of 1.a

(Forall X, T, P) Holds(T, Ineffective(P,X, diabetesTypeII)) :- Holds(T, HasDisease(X, diabetesTypeII)) & Holds(T, Elevated(LevelOf(hbA1c,X))) & Holds(T, TreatmentPlan(X, P)).

```<Forall>
<Var>X</Var>
<Var>T</Var>
<Var>P</Var>
<Implies>
<then>
<Uniterm>
<op><Const>Holds</Const>L</op>
<arg><Var>T</Var><arg>
<arg>
<Uniterm>
<op><Const>Ineffective</Const></op>
<arg><Var>P</Var></arg>
<arg><Var>X</Var></arg>
<arg><Const>diabetesTypeII</Const></arg>
</Uniterm>
</arg>
</Uniterm>
</then>
<if>
<And>
<Uniterm>
<op><Const>Holds</Const></op>
<arg><Var>T</Var></arg>
<arg>
<Uniterm>
<op><Const>HasDisease</Const></op>
<arg><Var>X</Var></arg>
<arg><Const>diabetesTypeII</Const></arg>
</Uniterm>
</arg>
</Uniterm>
<Uniterm>
<op><Const>Holds</Const></op>
<arg><Var>T</Var></arg>
<arg>
<Uniterm>
<op><Const>Elevated</Const></op>
<arg>
<Uniterm>
<op><Const>LevelOf</Const></op>
<arg><Const>hbA1c</Const></arg>
<arg><Var>X</Var></arg>
</Uniterm>
</arg>
</Uniterm>
</arg>
</Uniterm>
</arg>
<Uniterm>
<op><Const>Holds</Const></op>
<arg><Var>T</Var></arg>
<arg>
<Uniterm>
<op><Const>TreatmentPlan</Const></op>
<arg><Var>X</Var></arg>
<arg><Var>P</Var></arg>
</Uniterm>
</arg>
</Uniterm>
</And>
</if>
</Implies>
</Forall>

```

Translation of Rule 1b: (Forall T,X,L,J,K,Z) Holds(T,Elevated(LevelOf(L,X))) :- NormalRange(L,J,K) & Holds(T, LevelOf(L,X) = Z) & Z > K.

```<Forall>
<Var>T</Var>
<Var>X</Var>
<Var>L</Var>
<Var>J</Var>
<Var>K</Var>
<Var>Z</Var>
<Implies>
<then>
<Uniterm>
<op><Const>Holds</Const></op>
<arg><Var>T</Var></arg>
<arg>
<Uniterm>
<op><Const>Elevated</Const></op>
<arg>
<Uniterm>
<op><Const>LevelOf</Const></op>
<arg><Var>L</Var></arg>
<arg><Var>X</Var></arg>
</Uniterm>
</arg>
</Uniterm>
</arg>
</Uniterm>
</then>
<if>
<And>
<Uniterm>
<op><Const>NormalRange</Const></op>
<arg><Var>L</Var></arg>
<arg><Var>J</Var></arg>
<arg><Var>K</Var></arg>
</Uniterm>
<Uniterm>
<op><Const>Holds</Const></op>
<arg><Var>T</Var></arg>
<arg>
<Formula>
<Equal>
<side>
<Uniterm>
<op><Const>LevelOf</Const></op>
<arg><Var>L</Var></arg>
<arg><Var>X</Var></arg>
</Uniterm>
</side>
<side>
<Const>Z</Const>
</side>
</Equal>
</Formula>
</arg>
</Uniterm>
<Uniterm>
<op><Const>Greater</Const></op>
<arg><Var>Z</Var></arg>
<arg><Var>K</Var></arg>
<Uniterm>
</And>
</if>
</Implies>
</Forall>

```

Translation of Rule 2:

2. (Forall P, T, X, M) Do(Replace(P, OralMonotherapy,OralBitherapy),T):- Holds(T, Ineffective(P, X, DiabetesTypeII)) & PartOfTreatmentPlan(P, X, DiabetesTypeII, LifeStyleChange) & PartOfTreatmentPlan(P, X, DiabetesTypeII, OralMonotherapy, M) & (Isa(M, sulfonylurea) | Isa(M, biguanide)).

``` <Forall>
<Var>T</Var>
<Var>X</Var>
<Var>P</Var>
<Var>M</Var>
<Implies>
<then>
<Uniterm>
<op><Const>Do</Const></op>
<arg>
<Uniterm>
<op><Const>Replace</Const></op>
<arg><Var>P</Var></arg>
<arg><Const>OralMonotherapy</Const></arg>
<arg><Const>OralBitherapy</Const><arg>
</Uniterm>
</arg>
<arg><Var>T</Var></arg>
</Uniterm>
</then>
<if>
<And>
<Uniterm>
<op><Const>Holds</Const></op>
<arg><Var>T</Var></arg>
<arg>
<Uniterm>
<op><Const>Ineffective</Const></op>
<arg><Var>P</Var></arg>
<arg><Var>X</Var></arg>
<arg><Const>DiabetesTypeII</Const></arg>
</Uniterm>
</arg>
</Uniterm>
<Uniterm>
<op><Const>PartOfTreatmentPlan</Const></op>
<arg><Var>P</Var></arg>
<arg><Var>X</Var></arg>
<arg><Const>DiabetesTypeII</Const></arg>
<arg><Const>LifeStyleChange</Const></arg>
</Uniterm>
<Uniterm>
<op><Const>PartOfMedTreatmentPlan</Const></op>
<arg><Var>P</Var></arg>
<arg><Var>X</Var></arg>
<arg><Const>DiabetesTypeII</Const></arg>
<arg><Const>OralMonotherapy</Const></arg>
<arg><Var>M</Var></arg>
</Uniterm>
<Uniterm>
<Or>
<Uniterm>
<op><Const>Isa</Const></op>
<arg><Var>M</Var></arg>
<arg><Const>sulfonylurea</Const></arg>
</Uniterm>
<Uniterm>
<op><Const>Isa</Const></op>
<arg><Var>M</Var></arg>
<arg><Const>sulfonylurea</Const></arg>
</Uniterm>
</Or>
</Uniterm>
</And>
</if>
</Implies>
</Forall>

```