/* regulatory_compliance_concerns.kb

   Pharmex fuzzy regulatory-review model.

   Inputs
   ------
       sd
       ed
       cf
       vpf
       scf
       rsf

   Outputs
   -------
       misleading_claim_concern
       risk_minimisation_concern
       review_priority

   These outputs are review/concern indicators.
   They are not legal determinations of compliance.
*/


/* ======================================================================
   RULES: MISLEADING / UNSUPPORTED CLAIM CONCERN
   ====================================================================== */

/* SD high OR ED high OR CF high => high concern.
   Written as three rules rather than using OR syntax.
*/

if sd be high_score
then
misleading_claim_concern := high_concern.

if ed be high_score
then
misleading_claim_concern := high_concern.

if cf be high_score
then
misleading_claim_concern := high_concern.


/* Evidential weakness combined with apparently
   technical/scientific presentation.
*/

if ed be high_score
and cf be high_score
then
misleading_claim_concern := very_high_concern.


/* Nothing concerning on these three dimensions. */

if sd be low_score
and ed be low_score
and cf be low_score
then
misleading_claim_concern := low_concern.



/* ======================================================================
   RULES: RISK MINIMISATION / FAIR-BALANCE CONCERN
   ====================================================================== */

/* Material safety content exists but is strongly suppressed. */

if scf be high_score
and rsf be high_score
then
risk_minimisation_concern := very_high_concern.


/* Safety content is visible and not being suppressed. */

if scf be medium_score
and rsf be low_score
then
risk_minimisation_concern := low_concern.

if scf be high_score
and rsf be low_score
then
risk_minimisation_concern := low_concern.


/* Aspirational framing becomes relevant when paired
   with strong risk suppression.
*/

if vpf be high_score
and rsf be high_score
then
risk_minimisation_concern := high_concern.


/* VPF alone is not treated as a regulatory concern.
   If there is no safety concern and no suppression,
   risk-minimisation concern stays low regardless of VPF.
*/

if scf be low_score
and rsf be low_score
then
risk_minimisation_concern := low_concern.



/* ======================================================================
   RULES: OVERALL REVIEW PRIORITY
   ====================================================================== */

/* Strong evidential/scientific combination. */

if ed be high_score
and cf be high_score
then
review_priority := very_high_concern.


/* Safety information strongly suppressed. */

if scf be high_score
and rsf be high_score
then
review_priority := very_high_concern.


/* Individual misleading-claim indicators. */

if sd be high_score
then
review_priority := high_concern.

if ed be high_score
then
review_priority := high_concern.

if cf be high_score
then
review_priority := high_concern.


/* Positive framing plus risk suppression. */

if vpf be high_score
and rsf be high_score
then
review_priority := high_concern.


/* Low observable concern.

   VPF is intentionally absent:
   high vitality/aspirational framing alone is not
   sufficient to raise review priority.
*/

if sd be low_score
and ed be low_score
and cf be low_score
and scf be low_score
and rsf be low_score
then
review_priority := low_concern.



/* ======================================================================
   INPUT: SD
   ====================================================================== */

low( sd, 0 ).
high( sd, 1 ).
scale( sd, 'semantic score' ).

fuzzy_set( sd, low_score,
           tri( -0.5, 0, 0.5 ) ).

fuzzy_set( sd, medium_score,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( sd, high_score,
           tri( 0.5, 1, 1.5 ) ).



/* ======================================================================
   INPUT: ED
   ====================================================================== */

low( ed, 0 ).
high( ed, 1 ).
scale( ed, 'semantic score' ).

fuzzy_set( ed, low_score,
           tri( -0.5, 0, 0.5 ) ).

fuzzy_set( ed, medium_score,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( ed, high_score,
           tri( 0.5, 1, 1.5 ) ).



/* ======================================================================
   INPUT: CF
   ====================================================================== */

low( cf, 0 ).
high( cf, 1 ).
scale( cf, 'semantic score' ).

fuzzy_set( cf, low_score,
           tri( -0.5, 0, 0.5 ) ).

fuzzy_set( cf, medium_score,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( cf, high_score,
           tri( 0.5, 1, 1.5 ) ).



/* ======================================================================
   INPUT: VPF
   ====================================================================== */

low( vpf, 0 ).
high( vpf, 1 ).
scale( vpf, 'semantic score' ).

fuzzy_set( vpf, low_score,
           tri( -0.5, 0, 0.5 ) ).

fuzzy_set( vpf, medium_score,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( vpf, high_score,
           tri( 0.5, 1, 1.5 ) ).



/* ======================================================================
   INPUT: SCF
   ====================================================================== */

low( scf, 0 ).
high( scf, 1 ).
scale( scf, 'semantic score' ).

fuzzy_set( scf, low_score,
           tri( -0.5, 0, 0.5 ) ).

fuzzy_set( scf, medium_score,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( scf, high_score,
           tri( 0.5, 1, 1.5 ) ).



/* ======================================================================
   INPUT: RSF
   ====================================================================== */

low( rsf, 0 ).
high( rsf, 1 ).
scale( rsf, 'semantic score' ).

fuzzy_set( rsf, low_score,
           tri( -0.5, 0, 0.5 ) ).

fuzzy_set( rsf, medium_score,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( rsf, high_score,
           tri( 0.5, 1, 1.5 ) ).



/* ======================================================================
   OUTPUT: misleading claim concern
   ====================================================================== */

low( misleading_claim_concern, 0 ).
high( misleading_claim_concern, 1 ).
scale( misleading_claim_concern, 'concern score' ).

fuzzy_set( misleading_claim_concern, low_concern,
           tri( -0.25, 0, 0.25 ) ).

fuzzy_set( misleading_claim_concern, medium_concern,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( misleading_claim_concern, high_concern,
           tri( 0.5, 0.75, 1 ) ).

fuzzy_set( misleading_claim_concern, very_high_concern,
           tri( 0.75, 1, 1.25 ) ).



/* ======================================================================
   OUTPUT: risk minimisation concern
   ====================================================================== */

low( risk_minimisation_concern, 0 ).
high( risk_minimisation_concern, 1 ).
scale( risk_minimisation_concern, 'concern score' ).

fuzzy_set( risk_minimisation_concern, low_concern,
           tri( -0.25, 0, 0.25 ) ).

fuzzy_set( risk_minimisation_concern, medium_concern,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( risk_minimisation_concern, high_concern,
           tri( 0.5, 0.75, 1 ) ).

fuzzy_set( risk_minimisation_concern, very_high_concern,
           tri( 0.75, 1, 1.25 ) ).



/* ======================================================================
   OUTPUT: review priority
   ====================================================================== */

low( review_priority, 0 ).
high( review_priority, 1 ).
scale( review_priority, 'review priority' ).

fuzzy_set( review_priority, low_concern,
           tri( -0.25, 0, 0.25 ) ).

fuzzy_set( review_priority, medium_concern,
           tri( 0, 0.5, 1 ) ).

fuzzy_set( review_priority, high_concern,
           tri( 0.5, 0.75, 1 ) ).

fuzzy_set( review_priority, very_high_concern,
           tri( 0.75, 1, 1.25 ) ).

