Class BooleanAlgebra
java.lang.Object
org.episteme.core.mathematics.algebra.algebras.BooleanAlgebra
- All Implemented Interfaces:
Iterable<Boolean>, AbelianMonoid<Boolean>, Magma<Boolean>, Monoid<Boolean>, Semiring<Boolean>, FiniteSet<Boolean>, Set<Boolean>
Boolean algebra - a special algebraic structure for logic operations.
A Boolean algebra is a complemented distributive lattice. It provides the mathematical foundation for logic, digital circuits, and set operations.
Mathematical Definition
A Boolean algebra (B, ∧, ∨, ¬, 0, 1) consists of:
- A set B (typically {false, true} or {0, 1})
- Binary operations: ∧ (AND), ∨ (OR)
- Unary operation: ¬ (NOT)
- Constants: 0 (false), 1 (true)
Boolean Algebra Laws
Commutative: a ∧ b = b ∧ a, a ∨ b = b ∨ a Associative: (a ∧ b) ∧ c = a ∧ (b ∧ c) Distributive: a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) Identity: a ∧ 1 = a, a ∨ 0 = a Complement: a ∧ ¬a = 0, a ∨ ¬a = 1 De Morgan: ¬(a ∧ b) = ¬a ∨ ¬b
Applications
- Digital Logic: Circuit design, gates
- Programming: Conditional logic, bitwise operations
- Set Theory: ∩ (AND), ∪ (OR), complement (NOT)
- Database Queries: SQL WHERE clauses
- AI/Logic: Propositional logic, inference
Usage Examples
BooleanAlgebra bool = BooleanAlgebra.getInstance();
// Logic operations
Boolean result = bool.and(true, false); // false
Boolean result2 = bool.or(true, false); // true
Boolean result3 = bool.not(true); // false
Boolean result4 = bool.xor(true, true); // false
// De Morgan's laws
Boolean a = true, b = false;
assert bool.not(bool.and(a, b)).equals(
bool.or(bool.not(a), bool.not(b)));
// Digital circuit simulation
Boolean nandGate = bool.not(bool.and(input1, input2));
Relation to Other Structures
- Boolean algebra is NOT a field (no meaningful addition)
- It's a special case of a lattice
- Two-element Boolean algebra: {0, 1} or {false, true}
- Can have larger Boolean algebras (power sets)
References
- George Boole, "The Mathematical Analysis of Logic", Cambridge: Macmillan, Barclay, and Macmillan, 1847
- Claude E. Shannon, "A Symbolic Analysis of Relay and Switching Circuits", Master's Thesis, MIT, 1937
- Alfred North Whitehead and Bertrand Russell, "Principia Mathematica", Cambridge University Press, 1910-1913
- Since:
- 1.0
- Author:
- Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptionReturns the sum of two elements (additive notation).Logical AND (conjunction, meet, ∧).booleanTests whether this set contains the specified element.Returns a human-readable description of this set.equivalent(Boolean a, Boolean b) Logical equivalence (biconditional, â†â€).static BooleanAlgebraReturns the singleton instance.Logical implication (→).booleanisEmpty()Returnstrueif this set contains no elements.booleanTests whether multiplication is commutative in this semiring.iterator()Returns an iterator over the elements in this set.Returns the product of two elements.Logical NAND (NOT AND).Logical NOR (NOT OR).Logical NOT (complement, negation, ¬).one()Returns the multiplicative identity (one element).Performs the binary operation on two elements.Logical OR (disjunction, join, ∨).longsize()Returns the number of elements in this set (its cardinality).stream()Returns a sequentialStreamwith this set as its source.toString()Logical XOR (exclusive or, ⊕).zero()Returns the additive identity (zero element).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbelianMonoid
identity, isCommutativeMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Monoid
isAssociative
-
Method Details
-
getInstance
Returns the singleton instance.- Returns:
- the Boolean algebra instance
-
operate
Description copied from interface:MagmaPerforms the binary operation on two elements.This is the fundamental operation of a magma. The result must be an element of this magma (closure property).
Properties: None required (not necessarily associative or commutative)
-
add
Description copied from interface:AbelianMonoidReturns the sum of two elements (additive notation).Delegates to
Magma.operate(Object, Object).- Specified by:
addin interfaceAbelianMonoid<Boolean>- Parameters:
a- the first addendb- the second addend- Returns:
- a + b
-
zero
Description copied from interface:AbelianMonoidReturns the additive identity (zero element).Delegates to
AbelianMonoid.identity().- Specified by:
zeroin interfaceAbelianMonoid<Boolean>- Returns:
- the zero element
-
multiply
Description copied from interface:SemiringReturns the product of two elements.Multiplication must be associative and distribute over addition.
-
one
-
isMultiplicationCommutative
public boolean isMultiplicationCommutative()Description copied from interface:SemiringTests whether multiplication is commutative in this semiring.- Specified by:
isMultiplicationCommutativein interfaceSemiring<Boolean>- Returns:
trueif multiplication commutes
-
size
-
isEmpty
public boolean isEmpty()Description copied from interface:SetReturnstrueif this set contains no elements.The empty set (∅) is a fundamental concept in set theory. It is the unique set containing no elements.
-
contains
Description copied from interface:SetTests whether this set contains the specified element.This is the fundamental operation of a set - membership testing.
-
iterator
-
stream
-
description
Description copied from interface:SetReturns a human-readable description of this set.Examples:
- "â„ (Real Numbers)"
- "ℤ/12ℤ (Integers modulo 12)"
- "{1, 2, 3, 4, 5}"
- Specified by:
descriptionin interfaceSet<Boolean>- Returns:
- a description of this set
-
and
-
or
-
not
-
xor
-
nand
-
nor
-
implies
-
equivalent
-
toString
-