boostorg / boostorg/logic

modern logic classes

Open
#30 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
12
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Hello,
I have implemented (single header library) the logic classes bool4, bool3 and bool2:
- bool4
https://de.wikipedia.org/wiki/Belnaps_vierwertige_Logik
https://en.wikipedia.org/wiki/Four-valued_logic
- bool3 (similar to tribool)
https://de.wikipedia.org/wiki/Dreiwertige_Logik
https://en.wikipedia.org/wiki/Three-valued_logic
- bool2 (similar to bool)

These provide additional support:
- weak negation https://de.wikipedia.org/wiki/Dreiwertige_Logik#Starke_und_schwache_Negation
implemented as operator~
- charconv
boost::charconv::from_chars/to_chars
if available (C++17) std::from_chars/to_chars
- type traits
boost::is_logic
- std::numeric_limits

Differences to bool/tribool
- operator>>(stream) always returns false in the event of an error

Implementation
- If standard functions/classes are available these are used, otherwise (fallback) boost.
- I used my small (single header) library streamutil. This simplifies a few things, but is not absolutely necessary.
- For tribool I added the functions/type traits/limits/operators.

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

todo
- Remove tribool, then the classes can be implemented in boost::logic. For compatibility reasons, "using tribool = bool3;" can be provided (temporarily).
- For bool4/bool3 there are more logical operators 1.). Perhaps it would be possible to provide these as well. However, I am not a mathematician and cannot judge whether this would make sense, as the functions/operators would have to be provided uniformly for bool4/3/2.

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

many thanks
Gero

Code
[logic2.hpp.txt](https://github.com/boostorg/logic/files/15113419/logic2.hpp.txt)
[streamutil.hpp.txt](https://github.com/boostorg/logic/files/15113421/streamutil.hpp.txt)
[is_integer.hpp.txt](https://github.com/boostorg/logic/files/15113547/is_integer.hpp.txt)

1.)
- bool4
https://de.wikipedia.org/wiki/Belnaps_vierwertige_Logik#Wahrheitstafeln
- bool3
https://de.wikipedia.org/wiki/Dreiwertige_Logik#%C5%813_und_K3
https://en.wikipedia.org/wiki/Three-valued_logic#Logics

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.