Skip to content

Logical Connectives

In Arden Syntax, you can use logical connectives to combine or manipulate conditions. You’ve probably seen AND, OR, and NOT before, they work as you’d expect with classical true/ false values:

  • AND is true only if both conditions are true.
  • OR is true if at least one condition is true.
  • NOT flips a true value to false, and vice versa.

What’s really cool is that Arden Syntax also plays nicely with fuzzy logic. This means you can combine “partially true” values like 0.3 AND 0.9 to get a result that reflects uncertainty or degrees of truth. If you want to explore fuzzy sets in more detail, check out our tutorial introducing a fuzzy approach to fever.

AND

Let’s calculate the risk of sepsis based on temperature and heart rate:

arden-syntax
data:
    temperature_C := 37.8;
    heartRate_bpm := 110;
    
    fever := fuzzy set (37.5, truth value 0), (38, truth value 1);
    tachycardia := fuzzy set (90, truth value 0.3), (110, truth value 0.8), (130, truth value 1);  
  ;;
  priority: 50;;
  evoke: ;;
  logic:
    sepsisRisk := temperature_C is in fever AND heartRate_bpm is in tachycardia;
    conclude true;
      ;;
  action:
    return sepsisRisk;
      ;;

Here, sepsisRisk gives a fuzzy truth value, combining how serious the fever is with the level of tachycardia, resulting in ~0.6.

OR

OR is handy when just one condition being true is enough. For example, deciding whether to give antibiotics:

arden-syntax
data:
    bpDiastolic_mmHg := 50;
    gcs := 12;
    
    hypotension := fuzzy set (40, truth value 1), (50, truth value 0.8), (60, truth value 0.1);
    alteredConsciousness := fuzzy set (6, truth value 1), (9, truth value 0.9), (12, truth value 0.5), (15, truth value 0);
  ;;
  priority: 50;;
  evoke: ;;
  logic:
    giveAntibiotic := bpDiastolic_mmHg is in hypotension OR gcs is in alteredConsciousness;
    conclude true;
      ;;
  action:
    return giveAntibiotic;
      ;;

giveAntibiotic will return a fuzzy truth value reflecting whether either of the conditions suggests treatment, in this case 0.8.

NOT

As mentioned before, use NOT to flip a condition. For example, we can check how unlikely septic shock is based on serum lactate:

arden-syntax
data:
    serumLactate_mmolL := 1.5;
    
    elevatedLactate := fuzzy set (0.5, truth value 0), (1.5, truth value 0.2), (2, truth value 0.4), (2.5, truth value 0.6), (3.5, truth value 0.8), (4, truth value 1);
  ;;
  priority: 50;;
  evoke: ;;
  logic:
    unlikelySepticShock := serumLactate_mmolL is NOT in elevatedLactate;
    conclude true;
      ;;
  action:
    return unlikelySepticShock;
      ;;

So septic shock is unlikely with a fuzzy value of 0.8.