### Fuzzy Logic theory -- Jos De Roo, Gijs Muys

PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX list: <http://www.w3.org/2000/10/swap/list#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX func: <http://www.w3.org/2007/rif-builtin-function#>
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
PREFIX fl: <http://eulersharp.sourceforge.net/2003/03swap/fl-rules#>

### classes
fl:Lower a rdfs:Class;
    rdfs:comment "class of things that are the first element of e:valuation object".

fl:Upper a rdfs:Class;
    rdfs:comment "class of things that are the last element of e:valuation object".

### properties
fl:mu a rdf:Property;
    rdfs:domain rdf:List;
    rdfs:range e:Number;
    rdfs:comment "to express fuzzy set membership e.g. (:x :C) fl:mu 0.8 says that :x a :C to a degree of 0.8".

fl:sigma a rdf:Property;
    rdfs:domain rdf:List;
    rdfs:range e:Number;
    rdfs:comment "to express fuzzy subsethood e.g. (:C :D) fl:sigma 0.9 says that :C rdfs:subClassOf :D to a degree of 0.9".

fl:pi a rdf:Property, e:Builtin;
    rdfs:domain rdf:List;
    rdfs:range e:Number;
    rdfs:comment "builtin to calculate fuzzy set membership according to Elpiniki Papageorgiou method".

# FGCM properties
fl:gmu a rdf:Property;
    rdfs:domain rdf:List;
    rdfs:range rdf:List;
    rdfs:comment "to express grey membership e.g. (:x :C) fl:gmu (0.1 0.4) means that :x belongs to :C with a degree between 0.1 and 0.4. It can be any value in-between but we do not know the exact value for sure.".

fl:gsigma a rdf:Property;
    rdfs:domain rdf:List;
    rdfs:range rdf:List;
        rdfs:comment "to express grey subsethood e.g. (:C :D) fl:gsigma (0.1 0.4) means that :C rdfs:subClassOf :D with a degree between 0.1 and 0.4. It can be any value in-between but we do not know the exact value for sure.";
        rdfs:comment "Sigma can also be considered as one way correlation where 0 is negative correlation and 1 is positive correlation.".

fl:gpi a rdf:Property, e:Builtin;
    rdfs:domain rdf:List;
    rdfs:range rdf:List;
    rdfs:comment "built-in to calculate fuzzy grey inference according to Elpiniki Papageorgiou method".

### conjunction according to Lukasiewicz
{
    ?C owl:intersectionOf ?E.
    ?E func:distinct-values ?U.
    ?U list:first ?A.
    ?U list:rest ?B.
     (?X ?A) fl:pi ?I.
     ?D owl:intersectionOf ?B.
     (?X ?D) fl:pi ?J.
     (?I ?J -1.0) math:sum ?K.
     (0.0 ?K) e:max ?M
 } => {
     (?X ?C) fl:pi ?M.
 }.

### disjunction according to Lukasiewicz
{
    ?C owl:unionOf ?E.
    ?E func:distinct-values ?U.
    ?U list:first ?A.
    ?U list:rest ?B.
    (?X ?A) fl:pi ?I.
    ?D owl:unionOf ?B.
    (?X ?D) fl:pi ?J.
    (?I ?J) math:sum ?K.
    (1.0 ?K) e:min ?M.
} => {
    (?X ?C) fl:pi ?M.
}.

### negation according to Lukasiewicz
{
    ?C owl:complementOf ?A.
    (?X ?A) fl:pi ?I.
    (1.0 ?I) math:difference ?M.
} => {
    (?X ?C) fl:pi ?M.
}.

### implication
{
    ?A rdfs:subClassOf ?B.
} => {
    (?A ?B) fl:sigma 1.0 .
}.

# Creates edge to itself (necessary calculation in algorithm)
{
    (?B ?A) fl:sigma ?I.
} => {
    (?A ?A) fl:sigma 1.0 .
}.

{
    ?C owl:complementOf ?A.
    (?B ?A) fl:sigma ?I.
    (1.0 ?I) math:difference ?M.
} => {
    (?B ?C) fl:sigma ?M.
}.

### Allows you to run FGCM algorithm on FCM model & ability to express non-grey nodes in FGCM model
{
    (?B ?A) fl:sigma ?I.
} => {
    (?B ?A) fl:gsigma (?I ?I).
}.

{
    (?B ?A) fl:mu ?I.
} => {
    (?B ?A) fl:gmu (?I ?I).
}.

{
    (?B ?A) fl:pi ?I.
} => {
    (?B ?A) fl:gpi (?I ?I).
}.

### Fuzzy Description Logic to Fuzzy Cognitive Map translation theory
{
    {?P a ?Q} e:valuation (?L ?U).
} => {
    (?P (?Q fl:Lower)) fl:mu ?L.
}.

{
    {?P a ?Q} e:valuation (?L ?U).
} => {
    (?P (?Q fl:Upper)) fl:mu ?U.
}.

{
    {?X rdfs:subClassOf ?Y} e:valuation (?L ?U).
} => {
    ((?X fl:Lower) (?Y fl:Lower)) fl:sigma ?L.
}.

{
    {?X rdfs:subClassOf ?Y} e:valuation (?L ?U).
} => {
    ((?X fl:Upper) (?Y fl:Upper)) fl:sigma ?U.
}.

{
    {?X owl:complementOf ?Q. ?Q rdfs:subClassOf ?Y} e:valuation (?L ?U).
    (1.0 ?L) math:difference ?M.
} => {
    ((?Y fl:Lower) (?X fl:Lower)) fl:sigma ?M.
}.

{
    {?X owl:complementOf ?Q. ?Q rdfs:subClassOf ?Y} e:valuation (?L ?U).
    (1.0 ?U) math:difference ?M.
} => {
    ((?Y fl:Upper) (?X fl:Upper)) fl:sigma ?M.
}.

{
    (?P (?C fl:Lower)) fl:pi ?X.
    (?P (?C fl:Upper)) fl:pi ?Y.
    ?Z e:optional {
        ?X math:notGreaterThan ?Y.
        ?S log:equalTo (?X ?Y).
    }.
    ?Z e:optional {
        ?X math:greaterThan ?Y.
        ?S log:equalTo (?Y ?X).
    }.
} => {
    {?P a ?C} e:valuation ?S.
}.

### support
owl:Thing owl:intersectionOf ().
owl:Nothing owl:unionOf ().

{
    ?C owl:intersectionOf ?U.
    ?U list:rest ?B.
} => {
    _:D owl:intersectionOf ?B.
}.

{
    ?C owl:unionOf ?U.
    ?U list:rest ?B.
} => {
    _:D owl:unionOf ?B.
}.

{
    (?X ?A) fl:mu ?I.
} => {
    (?X owl:Thing) fl:mu 1.0 .
}.

{
    (?X ?A) fl:mu ?I.
} => {
    (?X owl:Nothing) fl:mu 0.0 .
}.
