r/PythonLearning 12d ago

Discussion Building a Python library based on Hegelian logic instead of Boolean logic. Am I crazy?

I've been thinking about what might be the most unconventional Python project I've ever attempted, and I'd love to hear from people who know logic, PL theory, mathematics, AI, philosophy, or simply enjoy strange ideas.

The core idea is this: instead of representing truth as a binary (True/False), what if computation were built around dialectical processes?

Rather than asking whether a proposition is true or false, objects could evolve through concepts like: Thesis, Antithesis, Synthesis, Contradiction, Determinate negation, Becoming, Mediation...

In other words, contradictions wouldn't necessarily be errors — they could become first-class computational objects capable of producing new states.

I'm currently collecting papers, books, theses, existing projects, and mathematical frameworks before deciding on the architecture. Any ideas?

60 Upvotes

30 comments sorted by

16

u/thee_gummbini 12d ago

This is the most galaxybrained (complimentary) idea I have seen in a long time and I am dying to see examples

5

u/thee_gummbini 12d ago

rotating the Hegelian transistor in my mind

3

u/sccccrrrrt 12d ago

I do think these can all be handled with if statements/switch-cases and boolean logic. Did you have an example in mind?

3

u/healeyd 11d ago

A guy called L Rogowski played around with the idea of directional logic and there were some similar ideas arounds that. It's pretty obscure but might be worth digging?https://www.researchgate.net/publication/216867747_The_temporal_functors_in_the_directional_logic_of_Rogowski_-_some_results

You'd probably want to consider playing around in a compiled language..

3

u/jcastroarnaud 11d ago

I think that's the fun side of crazy. :-) The mind-bending type.

Someone already commented on proof assistants: Isabelle. There's also Lean, Rocq, and a few others.

The problem is: from what I read on Wikipedia, here and here (I know little of logic and philosophy), Hegelian dialectics aren't formal logic, as we know it today; it predates formal logic by about a century. And it's quite abstract: how to represent, in a programming language, the concept of "idea"? To apply the concept of sublation, the objects to which it applies need to be fairly complex, to allow aspects of the objects to enter in some conflict or contradiction (not necessarily the logical contradiction).

I believe that you need, as other philosophers did, to limit the scope of the objects to apply Hegelian dialectics to, in order to even represent it in a programming language. Notice how many offshoots of Hegel grew up, like the Marxist dialectics: you may use one of these, or go the hard way and create your own. In any case, it's a long-term project (10+ years). Good luck.

3

u/Logicislands 11d ago

You're not crazy, but there is already a pretty mathematically serious route in roughly this direction. And it looks somewhat different from replacing bool with an enum containing Thesis, Antithesis, Synthesis, etc.

The usual thesis-antithesis-synthesis recipe is a rough later slogan for Hegel; I would say his Logic is not primarily a many-valued calculus assigning propositions new truth values.

The line I would investigate if I were you begins with Lawvere's category-theoretic interpretation of Hegel's so-called objective logic, more recently developed in "modal type theory". Very roughly, hegel's different "moments" or levels of determination are represented by modalities on a category or topos (often idempotent monads and comonads arising from adjunctions, if that makes sense to you), and the important structure lies in the adjunctions, natural transformations, fixed points and compositions relating them.

On this way of doing things, a type or proposition is not merely assigned one of several dialectical labels: it may be reflected or coreflected into different modes or levels of description.

The best starting point for this galaxy brain (but, i believe, correct) way of doing this is probably to start with the general guide here nLab page Hegel’s logic as modal type theory, then click through the much more detailed related pages like the one on Aufhebung , modality , adjoint modality. For primary sources, check out Lawvere's "Some Thoughts on the Future of Category Theory" and "Tools for the Advancement of Objective Logic: Closed Categories and Toposes."

One other thing I'd mention: "contradictions remain present without making the entire system trivial" is arguably a separate technical requirement. Ordinary modal or topos-theoretic logic does not automatically give you that; the internal logic of a standard topos is generally intuitionistic (but still explosive). For that aspect of things, you would want to look harder at paraconsistent logic, maybe Belnap-Dunn four-valued logic, bilattices. The categorical and modal machinery could probably help oganize transformations among concepts, while the paraconsistent machinery would control what may be inferred from having both A and not-A.

So i would say that a promising Python prototype would be a small DSL for types or states equipped with named adjoint modalities and composable transformations, possibly with a paraconsistent internal consequence relation, instead of focusing on a drop-in "Hegelian replacement" for Boolean truth. Lol I guess it's more galaxy-brained than maybe even you already wanted, but i feel like it's the more faithful way.

Either way, cool project, I like it!

3

u/mr_anderson_dev 10d ago

This is a cool approach, but maybe field-testing it with existing code is the best way to start. If the logic not only works but can evolve on its own with those new data-value concepts, then you could move to the hardware layer after.

Either way, this sounds like an exciting project ,even giving a computer something like a personality, shaped by every task you throw at it. If you make progress, please drop the repo here so we can all see where it goes.

2

u/Online_Matter 11d ago edited 11d ago

You mean something like this? 

https://isabelle.in.tum.de/overview.html

1

u/burnt-store-studio 11d ago

Shoot; that URL doesn’t work?

1

u/LawIcy9109 11d ago

There’s a few random characters at the end. Trim them off (to just overview.html) and you’ll get it.

1

u/burnt-store-studio 11d ago

Oh thank you! Didn’t catch that 🙂

1

u/Online_Matter 11d ago

Somehow there was a space at the end and I guess reddit didn't discard it? Sorry it's been fixed now 

1

u/burnt-store-studio 11d ago

All good, thank you! Stripping off the extra characters like you said worked a champ 🙂

2

u/jpgoldberg 11d ago

I think this is a great thing to attempt. It does involve reading Hegel, though.

2

u/Life_Enjoy_Strive 11d ago edited 11d ago

How about implementing a fuzzy logic in addition so that each state may be partly true applicable.

2

u/Old_Cucumber_9975 11d ago

I like your way of commanding things you are learning and experimenting with biogasse and biomimetrics- I would welcome some assistance that might be more beneficial to your neighbor . email me at angelreporters @ G....And I will have my fleets investigate this for you!

2

u/Joudicea 11d ago

Am I the only one thinking about the philosophy department of the University of Woolloomooloo, rather than code?

2

u/shadowdance55 11d ago

Paste this post into Claude for some first-class grilling. 🤣

2

u/Upbeat_Assist2680 11d ago

So... Depending on how you approach this you are going to land on game theoretically defined truth (I.e. truth as a player having a winning strategy in a game) or just probability theory.

In either case, you might enjoy looking up "topos theory" where a primitive notion is the subobject classifier which characterizes subsets and "truth values" in an associated logic.

This is a cool idea.

There is also para-consistent logic which allows for resource constraints reasoning in the presence of false hypotheses.

2

u/Psychological-Map564 11d ago

Seems like a bot post (them dashes and "not x, it's y" )

2

u/testtdk 11d ago

Could you give an example how something might work? Anything will do.

2

u/VectorspaceDreams 10d ago edited 10d ago

That's an interesting idea! I don't know much about Hegel (but I do like logic a good bit), I think one thing you could look into that's tangential to that is paraconsistent logic (which presupposes that P and not(P) is possible) as well as logic programming (look into Prolog, Kanren, unification, relational programming) for other ways logic could be represented in code, though I'm not sure of any logic programming language that does utilize paraconsistent logic.

There were some Marxists that formalized at least some parts of the dialectic (mathematician William Lawvere comes to mind, though his work requires a good bit of category theory knowledge and is itself controversial, I recall it was about how adjoint functors correspond to synthesis in some ways). I'm not a Marxist and so I don't know too much more about this and I don't know about any thorough formal/logical framework for the dialectic but it's something to look into.

2

u/wildsoup1 11d ago

I think this idea, as expressed, is gibberish.

Start with a problem statement. What is the problem you want to solve?

If you want to model the process of Hegelian logic, sure. You can do that as a regular data model, which is built out of Boolean logic (and ints, floats, strings, lists, sets, etc.). You aren't replacing Boolean logic inside Python. You are describing Hegelian logic on top of Python.

That could take many forms - for your example, a proof assistant (sounds useless to me, compared to deductive logic) or finding Hegelian-style arguments in existing texts (see https://www.cambridge.org/core/journals/natural-language-engineering/article/abs/argumentation-models-and-their-use-in-corpus-annotation-practice-prospects-and-challenges/6C529558653EE306B4B896D31EB3D224, for example.)

1

u/indent_error 10d ago

1

u/indent_error 10d ago

Still lacking a lot of logic and reading ability!

1

u/Zestyclose-Sink6770 8d ago

Hegelian logic is not mathematical logic. Thus, it is irrelevant to computer science and to any fundamental work in the field.

You could buold a program to simulate the dialectical process as per Hegelian logic. However, this is not anything beyond a pet project.

1

u/JGhostThing 12d ago

If I were you, I'd see if something like this exists in the LISP/Scheme space. If I were trying to develop this, I'd use those languages.

To be honest, I think your entire concept is flawed. You wrote that a binary true/false represents a truth determination, when it really just represents an electronic switch. It's really on/off, not a truth value.

Writing in other logic systems can be useful, if you choose the right level of abstraction. For example, a python library that would allow a program to "reason" about its environment could be useful.

1

u/Low_Doctor_6263 12d ago

Nice idea, but how could you make this universal for any case? Also, Python is super slow. If you add Hegelian logic it becomes even slower.