boostorg / logic

Boost.org logic module
http://boost.org/libs/logic
Boost Software License 1.0
10 stars 37 forks source link

modern logic classes #30

Open gpeterhoff opened 5 months ago

gpeterhoff commented 5 months ago

Hello, I have implemented (single header library) the logic classes bool4, bool3 and bool2:

These provide additional support:

Differences to bool/tribool

Implementation

Unfortunately I can't provide bool4/3/2 in the namespace boost::logic because it conflicts with indeterminate.

todo

In principle, you should take another look at the code/tables to detect errors :-)

many thanks Gero

Code logic2.hpp.txt streamutil.hpp.txt is_integer.hpp.txt

1.)

gpeterhoff commented 5 months ago

Hello, here is a new version.

Compatibility with tribool

better

new

logic.hpp.txt

thx Gero

gpeterhoff commented 4 months ago

Hello Andrzej,

You could also ask why there is e.g. boost::math::quaternion/octonion. I don't know of a specific purpose for this either, but it makes sense to have them generally available.

Interesting. It looks like we have two quaternion implementations in Boost. The other being in Boost.QVM. It is nicely documented there, along with its motivation (for representing rotations in 3D space. The following thread demonstrates that people want it: https://groups.google.com/g/boost-developers-archive/c/gl4GxscZ1OU

I think it's a design flaw to have 2 different implementations of quaternion. Just like boost::string_view and boost:::core::string_view. octonionen does not seem to be affected. This should be consolidated. But that's not the point here.

So it looks like you are saying that you wanted to provide a better tribool and bool2 and bool4 are just a byproduct of this endeavour. Is that right?

There are conversion constructors with which you can control the exact behavior. In this sense, bool2 is actually a helper class.

For bool3 I can at least imagine a use case (true false and "I don't know"), but the docs do not give us any example that would show how the third state would be called. For bool4 I do not even imagine how fthe four states would be called. The literature that you provide (the part that is not in german) offers at least two different models for four-state bool logic. What nming did you choose? Can the documentation show it?

The above description says that for a three-value logic there are three kinds of negation: the standard one, the weak, and the strong. Give the rationale (in the documentation) why you provide only two.

You use the two operators for the two negations. But your choice of symbols is absolutely arbitrary. It would be less error-prone if the other negations were named functions.

Also, the documentation should say why you decided to put all the negation operations in the same type rather than offering three different types with different negation semantics. It is not clear to me if any use case requires all of these negation types together.

These are also my questions. In principle, there are 3 different negations (standard, weak, strong), but only 2 meaningful C++ operators (! ~) with which this could be mapped. How should this be handled ? bool4 contains even more operations, but these would have to be implemented as a function. As I said, I'm not a mathematician. With bool4 I followed Belnap. I would like to discuss whether all this is correct.

The german wikipedia entries are more detailed, which is why I have included them.

regards Gero