Buddhist philosophy represented in Prolog

Although it can be very handy, when we convert philosophical texts into algebra and propositional logic, there are some hard limitations, and not just the loss of tone and dialogue. What about modularly representing causality, being or not being, before and after, or qualities of things? Those can only be contained to a single string of a statement, but actually contain further logical info to be extracted.

How can we most simply represent the statements below, without losing any logical information?

ignorance causes despair.
birth is suffering.
whatever arises goes away.

A conforming resolution is to represent each of those things as facts, represented here in Prolog’s syntax, which is a language used to store info and then make logical inferences and solve proofs:

causes(ignorance, despair).
suffering(birth).
‘goes away’(X) :- arises(X).

verb(subject, object)
is object(subject)

I think this flexible format comes closest to being able to represent anything that the original text represents, and it still supports typical logic (not, and, if, iff).

Longer explanation of Prolog

Prolog (Programming in Logic) is a programming language different from the usual ones people mention as it focuses on (predictably) logic and storing info. Its code is essentially a readable database (knowledgebase) of facts formatted like this:

conditions(contact, feelings).  % contact is a condition for feelings
conditions(feelings, desire).
says(noble_truth(suffering), [suffering(birth), suffering(death)]). % embeded predicates, a list

Given those facts, you can make queries like

conditions(X, feelings).

which is like asking “X is a condition for what?”, and it would reply with X=contact. If it conditioned anything else, then you could keep asking it for what else it conditions, but it stops here.

It also supports creating rules or functions which will generalize behavior, like when goes_away(X) :- arises(X) meant “X goes away if X arises”.

So if we had the fact arises(feelings), then we could query goes_away(feelings) and it would respond true without first manually defining that feelings go away because our defined rule related goes_away with arises.

As a result of this format, this language can easily do some things very strongly like solve constraint satisfaction problems such as sudoku or parse grammar.

This does not have to be in just English, and there are ways to work in both the original language and the translated language simultaneously, such as with some kind of structure like this: conditions(en_pl(feelings, vedana), en_pl(desire, taṇha)). And the logic should probably be based off of the original text even if its shown in a translated language (unless you want to show how translated text logically lines up with the original?). That could even be extended to compare the logic of the parallels between ancient languages.


I converted AN8.66 to Prolog here: https://swish.swi-prolog.org/p/AN8.66.pl. This showcases a lot of features and potential from a relatively simple sutta.

Here’s two examples of how Prolog could manage a hierarchical knowledgebase such as for sectioning off particular canons, editions, books, suttas, or lines so they are logically independent and their facts don’t overlap/intersect: https://swish.swi-prolog.org/p/SN22.59.pl

I have seen Prolog used in philosophy and general problem solving, but I could not find many mentions of it used with Buddhist philosophy (only from Mitsuyuki Shimizu), so that’s why I’m bringing up its potential relationship.

At this point, there’s two possible uses:

Using this freely when discussing a particular sutta when necessary as a syntactical format for representing data and then running queries on that as a means of showcase or proof;

Or, generating a knowledgebase of the the Buddhist canons with the ability to browse specific suttas, exclude certain sections of knowledge (e.g. select MA/patton, MN30:3.1-7.5/sujato, and Dt2.1/unarada together), and use queries to reach deeper logical implications or conflicts that we can’t manage with just remembering. Generating this Prolog definitely can be aided with AI, maybe even JIT upon request, but it does have problems. Namely that there’s different interpretations of a text and many ways to do the same logically equivalent thing in programming.

It could also keep track of location as a side-effect as discussed recently. Even correlating themes, topics, or types of proofs with particular cities the Buddha stayed at, which likely also correlates to the beliefs of the students / non-Buddhists from that area which the Buddha would address.

That sort of project and its purpose isn’t primary and doesn’t solve primary problems. Reading the texts is good. This would aid just some philosophical problems for some students who want it. It’d also serve as a search, even allowing you to search for types of proofs such as what the thread on LEMs has been discussing. Some people use AI itself in a similar way by querying philosophical questions, but this app would be more reliable as each supporting statement can be traced directly to the lines of text it came from, so I hope it wouldn’t support laziness but encourage learning. Do you think that sort of project would be useful? Is a similar proof-solving logic language better for the job? I’m willing to set up and work on such a project.

5 Likes

Nice. I think it would be useful for mind mapping the sutta including detailed analysis of the contents. And grouping the same contents together so that we have a mega book of sorts without repetition, but labeling of which points are included in which suttas.

Ok, read your examples, I don’t find them easy to read. I was thinking of just doing them on Obsidian as a personal wiki of sorts.

2 Likes

Hello @Bran,

I’ve been mulling something of a similar nature, but I have something quite a bit more ambitious in mind. In many Tibetan monasteries, debate is held daily in such a way as to require following formal logical rules. It is also held in such a way that discourages ego building and instead fosters mutual understanding and skill in logic with the goal of deepening dhamma exploration and understanding.

Often debate on this forum breaks down into polemic with many ambiguities and misunderstandings as well as logical fallacies. I’d like to explore the idea of creating a debate/dialog system that enforces debate according to logical rules that would provide some safeguards against fallacy and misunderstanding. It might actually help people to communicate in a productive way or so I dream.

Instead of using prolog I thought of using game semantics and in particular dialogical logic to create a web-based game/forum where two players - the Opponent and Proponent of a thesis - argue in a more formal way according to very well established rules: either of classical logic or constructive logic. It is my hypothesis that constructive logic is more suited to dhamma debate, but a system that allows either to be toggled should be possible. LEM is not allowed as a move in constructive logic, but it is in classical.

The way I envision, two players would sign up (and perhaps spectators could view) as the Proponent of a Thesis and an Opponent. NOTE: The dialogical framework is actually very closely akin to a computer checked mathematical proof: ie, four outcomes are possible:

  1. The Proponent wins the debate, but not because they have proved anything, but because the Opponent did not choose a good “attack” strategy
  2. The Opponent wins the debate, but not because they have proved the thesis false, but because the Proponent did not choose a good “defense” strategy
  3. The Proponent wins the debate because it can be shown that no matter what attack strategy the Opponent had tried the Proponent would win: aka PROOF
  4. The Opponent wins the debate because it can be shown that no matter what defense strategy the Proponent had tried the Opponent would win: aka PROOF of negation of the thesis

This could be accomplished in web forms, but the thesis would have to be broken down and parsed into logical propositions, formulas, terms and predicates.

The first step might be providing some example games with thesis in more or less “plain english” and example attacks/defenses and the rules by which the game evolves etc.

What do you think? Venerable @NgXinZhao or @Soren, perhaps you might be interested as well?

:pray:

1 Like

The thing about introducing atomic formulas like causes(ignorance, despair) is that they are only useful if you have some other axioms which tell you what you can do with them. For example, trivially,

causes(ignorance,despair) IMPLIES is_caused_by(despair,ignorance)

but this doesn’t really tell you much. If we can say causes(X,Y), why do we care? How is that useful? One thing you might be interested is modal logic. Modal logic can sort of get at the notion of casuality with an atomic formula of phenomena existing in a possible world. If we say causes(X,Y) then this can be cast in a few equivalent forms

For all possible worlds, if X exists, then Y exists.
Necessarily, if X exists then Y exists.
ql_e36d92d65ff6c9112f79c3728185e458_l3

Of course, if “I” have ignorance, that doesn’t necessarily mean “you” will have despair. So you would need some way to identify unique conscious streams. Something like:

ql_a7e385ee5ed7a2354b951ecffb15a8a4_l3

Which says that

It is necessarily the case that if x is an element of the set of conscious streams, then if there exists ignorance in the conscious stream of x, then there will exist despair in the conscious stream of x.

Converting expressions in natural language to propositional form is not necessarily easy, and it can take a lot of work! I am not familiar with the Prolog, but it looks very flexible. The bulk of the work is getting axioms that people agree on so that once you are done translating you can make meaningful deductions. Also, it is not clear to me how you would deal with the tetralemma, because most modern logic does not use it.

I personally think it could be very interesting! You would have to get a critical mass of people involved, and I am not sure how large of an audience there is for this.

1 Like

Awesome! I’m glad you see the potential. BTW, if anyone is interested in what debate looks like in the Tibetan monasteries here is a western explanation. I tried to explain a bit about it here.

The first step is to learn constructive logic and this intro seems to do a decent job. Apparently this is part of a course held by Carnegie Mellon.

After that, the step will involve coming up with example games that meet the formalism of that logic with natural language thesis and the game as described here.

:pray:

1 Like

Hello Venerable @NgXinZhao,

To be honest I was quite hoping to hear your reaction to the idea ^^. Do you think it would be interesting or worthwhile? I think you definitely have the capacity to learn the logic and evaluate the proposal… :pray:

I don’t think I can comment without learning this whole course: Index of /cs/15317/lectures

But anyway, it certainly looks like it’s possible for me to learn as it’s just maths in philosophy and debate. Basically maths. It’s just not on my focus now. I am learning Pāli and to balance my monk’s life.

1 Like

@yeshe.tenley Unaddressed to me, but I am quite interested in learning logic more formally, especially constructivist logic in this context, and applying it to philosophical reasoning and friendly Dhamma debate. I agree with the limitations and challenges of conversations here (especially) and elsewhere generally. I tend to prefer “down to earth” language and conversation, despite how it might seem! :laughing: I think the Buddha and his disciples tended towards plain, clear language. That said, there is a case for specialized use of more technical formats in the name of learning. :pray:

1 Like

Yes, I do as well. When we use specialized jargon it can tend to exacerbate the habit to reify concepts into fundamental things. It can also really hurt communication with those who don’t accept our jargon. I prefer to try and relate and use common definitions/words where possible.

That said, I find the constructive logic an interesting way of relating - which by the way as far as I know I’m the first to make this leap - the idea of what Tibetans call a non-affirming negation. When I made that connection that this was what they were talking about it made things much easier to understand to my mind. :pray:

Quite attractive. Thanks, very interesting post. They would have to agree on definitions (and some words have many) and maybe on certain things being true in their own experiences as well. You remind me of this website too https://www.kialo.com. Also consider the language Coq. I could imagine having fun creating an interface that links with it, and I’ve made my own proof solver before.

On its own it’s not meaningful, until put into some other context or relate it with your own life. For example, with causes(X, nirvana). uncaused(nirvana)., it could create a problem that needs to be reconciled. In a fuller context, it could contradict, reveal holes, or reveal the unknown strength of other arguments like maybe it adds to not-self arguments because of the interconnected implications.