https://github.com/nsajko/twoelementbooleanalgebra.jl
Simplest non-trivial Boolean algebra, the two-element Boolean algebra
https://github.com/nsajko/twoelementbooleanalgebra.jl
boolean boolean-algebra boolean-logic logic logical-operators
Last synced: 4 months ago
JSON representation
Simplest non-trivial Boolean algebra, the two-element Boolean algebra
- Host: GitHub
- URL: https://github.com/nsajko/twoelementbooleanalgebra.jl
- Owner: nsajko
- License: mit
- Created: 2025-10-01T18:39:34.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-10-03T16:47:10.000Z (4 months ago)
- Last Synced: 2025-10-03T18:40:07.701Z (4 months ago)
- Topics: boolean, boolean-algebra, boolean-logic, logic, logical-operators
- Language: Julia
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TwoElementBooleanAlgebra
[](https://github.com/nsajko/TwoElementBooleanAlgebra.jl/actions/workflows/CI.yml?query=branch%3Amain)
[](https://juliahub.com/ui/Packages/General/TwoElementBooleanAlgebra)
[](https://juliahub.com/ui/Packages/General/TwoElementBooleanAlgebra?t=2)
[](https://codecov.io/gh/nsajko/TwoElementBooleanAlgebra.jl)
[](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/B/TwoElementBooleanAlgebra.html)
[](https://github.com/JuliaTesting/Aqua.jl)
A software package for the Julia programming language implementing the simplest non-trivial Boolean algebra, the two-element Boolean algebra.
The only public binding is the type, `Boole`. It is different from `Bool` in that `one(Boole) + one(Boole)` equals one instead of two.
## Usage example
```julia-repl
julia> using TwoElementBooleanAlgebra
julia> Boole(0)
Boole(0)
julia> Boole(0) + Boole(0)
Boole(0)
julia> Boole(0) + Boole(1)
Boole(1)
julia> Boole(1) + Boole(1)
Boole(1)
julia> Boole(0) * Boole(1)
Boole(0)
julia> !Boole(0)
Boole(1)
```
## An application: represent a relation with a logical array
A logical array represents a mathematical relation. Specifically, an `X::AbstractMatrix{Boole}` represents a binary relation. Then:
* matrix addition (`X + Y`) corresponds to relation union
* pointwise multiplication (`X .* Y`) of matrices corresponds to relation intersection
* matrix multiplication (`X * Y`) corresponds to relation composition
* matrix transpose (`transpose(X)`) or adjoint (`adjoint(X)` or `X'`) results in the converse relation
* pointwise negation (`(!).(X)`) results in the complementary relation
* pointwise partial order (`all(splat(≤), zip(X, Y))`) corresponds to the subset/inclusion predicate