[FRIAM] The entropy of thought
Marcus Daniels
marcus at snoutfarm.com
Thu May 29 17:43:16 EDT 2025
George has sympy.logic in its Python sandbox, so it can compare direct inference to actual logic. For real world things, formalizing knowledge and causality would be more involved, but I don’t see any obvious obstacles. Here is one example:
Title: Symbolic Logic for Medical Triage Reasoning
Overview:
This document demonstrates how propositional logic can be used to encode and evaluate medical triage rules for determining whether a patient is considered "urgent" based on symptoms and risk factors. The example uses the sympy.logic module to perform logical inference in Python.
Variables:
* ChestPain: Patient reports chest pain.
* ShortBreath: Patient reports shortness of breath.
* HighBP: Patient has high blood pressure.
* Sweating: Patient is sweating excessively.
* HistoryHeartDisease: Patient has a history of heart disease.
* AgeOver60: Patient is older than 60.
* Urgent: Patient should be marked as urgent for care.
Logic Rules:
1. If the patient has chest pain and shortness of breath, then they are urgent.
* ChestPain ∧ ShortBreath → Urgent
2. If the patient has chest pain and a history of heart disease, then they are urgent.
* ChestPain ∧ HistoryHeartDisease → Urgent
3. If the patient has high blood pressure, sweating, and is over 60, then they are urgent.
* HighBP ∧ Sweating ∧ AgeOver60 → Urgent
4. If none of the above conditions apply, the patient is not urgent.
* ¬(Rule1 ∨ Rule2 ∨ Rule3) → ¬Urgent
Python Code:
from sympy import symbols
from sympy.logic.boolalg import And, Or, Not, Implies
from sympy.logic.inference import satisfiable
# Define symbols for symptoms and outcome
ChestPain, ShortBreath, HighBP, Sweating = symbols('ChestPain ShortBreath HighBP Sweating')
HistoryHeartDisease, AgeOver60 = symbols('HistoryHeartDisease AgeOver60')
Urgent = symbols('Urgent')
# Encode medical triage rules
rules = And(
Implies(And(ChestPain, ShortBreath), Urgent), # Rule 1
Implies(And(ChestPain, HistoryHeartDisease), Urgent), # Rule 2
Implies(And(HighBP, Sweating, AgeOver60), Urgent), # Rule 3
Implies(Not(Or(
And(ChestPain, ShortBreath),
And(ChestPain, HistoryHeartDisease),
And(HighBP, Sweating, AgeOver60)
)), Not(Urgent)) # Rule 4: default case
)
# Define test cases as dictionaries of patient symptoms and demographics
test_cases = [
{'name': 'Patient A', 'ChestPain': True, 'ShortBreath': True, 'HighBP': False, 'Sweating': False, 'HistoryHeartDisease': False, 'AgeOver60': False},
{'name': 'Patient B', 'ChestPain': True, 'ShortBreath': False, 'HighBP': False, 'Sweating': False, 'HistoryHeartDisease': True, 'AgeOver60': False},
{'name': 'Patient C', 'ChestPain': False, 'ShortBreath': False, 'HighBP': True, 'Sweating': True, 'HistoryHeartDisease': False, 'AgeOver60': True},
{'name': 'Patient D', 'ChestPain': False, 'ShortBreath': False, 'HighBP': True, 'Sweating': True, 'HistoryHeartDisease': False, 'AgeOver60': False},
{'name': 'Patient E', 'ChestPain': False, 'ShortBreath': False, 'HighBP': False, 'Sweating': False, 'HistoryHeartDisease': False, 'AgeOver60': False}
]
# Evaluate each test case
results = []
for case in test_cases:
assumptions = And(*[
symbol if val else Not(symbol)
for symbol, val in zip(
[ChestPain, ShortBreath, HighBP, Sweating, HistoryHeartDisease, AgeOver60],
[case['ChestPain'], case['ShortBreath'], case['HighBP'], case['Sweating'], case['HistoryHeartDisease'], case['AgeOver60']]
)
])
full_expr = And(rules, assumptions)
model = satisfiable(full_expr)
case_result = bool(model and model.get(Urgent, False))
results.append((case['name'], case_result))
for name, urgent in results:
print(f"{name}: {'URGENT' if urgent else 'Not Urgent'}")
Execution Output:
Patient A: URGENT
Patient B: URGENT
Patient C: URGENT
Patient D: Not Urgent
Patient E: Not Urgent
Applications:
* Triage decision support systems.
* Rule-based expert systems for emergency settings.
* Explainable AI pipelines in healthcare.
Extensions:
* Incorporate probabilistic or fuzzy logic for uncertainty.
* Add contraindications or medication-based logic.
* Output justifications or causal chains for each decision.
Conclusion:
This example illustrates how symbolic logic provides a transparent and interpretable method for encoding domain knowledge in medical decision-making. It also serves as a foundation for more advanced neurosymbolic reasoning systems.
From: Friam <friam-bounces at redfish.com> on behalf of steve smith <sasmyth at swcp.com>
Date: Thursday, May 29, 2025 at 1:31 PM
To: friam at redfish.com <friam at redfish.com>
Subject: Re: [FRIAM] The entropy of thought
>
> As for GPT's introspective (especially retrospective) explanations:
> I'm starting to sincerely doubt the sanity of such queries. I haven't
> looked into it much.
After I sent that, I realized that I don't trust George to actually have
introspected/retrospected, but rather that it *reconstructed* the prompt
and then instrumented it's response?
I may pursue it or not... i'm clearly too easily entertained!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://redfish.com/pipermail/friam_redfish.com/attachments/20250529/4666c596/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 8422 bytes
Desc: not available
URL: <http://redfish.com/pipermail/friam_redfish.com/attachments/20250529/4666c596/attachment-0001.bin>
More information about the Friam
mailing list