# =============================================================================================================================  
# Deep Taxonomy - depth 10 - ARC style
# See https://web.archive.org/web/20220119222608/http://responder.ruleml.org/WellnessRules/files/WellnessRulesN3-2009-11-10.pdf
#
# This example is a stress test for deep classification. One individual starts
# in class N0. Each rule moves that individual one level deeper in the taxonomy
# and also adds two side labels. If reasoning reaches N10, the final rule
# derives A2 and the test succeeds.
# =============================================================================================================================  

@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#>.

# fact
:ind a :N0.

# rules
{:ind a :A2} => {:test :is true}.

{?X a :N0} => {?X a :N1, :I1, :J1}.
{?X a :N1} => {?X a :N2, :I2, :J2}.
{?X a :N2} => {?X a :N3, :I3, :J3}.
{?X a :N3} => {?X a :N4, :I4, :J4}.
{?X a :N4} => {?X a :N5, :I5, :J5}.
{?X a :N5} => {?X a :N6, :I6, :J6}.
{?X a :N6} => {?X a :N7, :I7, :J7}.
{?X a :N7} => {?X a :N8, :I8, :J8}.
{?X a :N8} => {?X a :N9, :I9, :J9}.
{?X a :N9} => {?X a :N10, :I10, :J10}.

{?X a :N10} => {?X a :A2}.

@prefix log: <http://www.w3.org/2000/10/swap/log#>.

# ARC checks
{ :ind a :N0. }
    => { :arc :check1 "C1 OK - the starting classification N0 is present." . } .

{ :ind a :N1, :I1, :J1. }
    => { :arc :check2 "C2 OK - the first expansion produced N1 together with side labels I1 and J1." . } .

{ :ind a :N5, :I5, :J5. }
    => { :arc :check3 "C3 OK - the chain reaches the midpoint N5 and still carries both side-label branches." . } .

{ :ind a :N9, :N10. }
    => { :arc :check4 "C4 OK - the final taxonomy step from N9 to N10 was completed." . } .

{ :ind a :N10, :A2. }
    => { :arc :check5 "C5 OK - once N10 is reached, the terminal class A2 is derived." . } .

{ :ind a :A2. :test :is true. }
    => { :arc :check6 "C6 OK - the success flag is raised only after the terminal class A2 is present." . } .

# ARC report
{
    :test :is true.
    :arc :check1 ?C1; :check2 ?C2; :check3 ?C3; :check4 ?C4; :check5 ?C5; :check6 ?C6.
}
    =>
{
    :report log:outputString "Deep Taxonomy - deep classification benchmark

Answer
The test succeeds: starting from one individual classified as N0, the rules eventually classify it as N10 and then as A2.

Reason Why
Each rule moves the same individual one level deeper in the taxonomy and also adds two side labels. Because that chain continues all the way from N0 to N10, the final rule deriving A2 fires, and that in turn makes the test true.

Check
C1 OK - the starting classification N0 is present.
C2 OK - the first expansion produced N1 together with side labels I1 and J1.
C3 OK - the chain reaches the midpoint N5 and still carries both side-label branches.
C4 OK - the final taxonomy step from N9 to N10 was completed.
C5 OK - once N10 is reached, the terminal class A2 is derived.
C6 OK - the success flag is raised only after the terminal class A2 is present.
" .
} .
