Skip to content
IRC-Coding IRC-Coding
Boolean Algebra Logic Gates Truth Tables Switching Algebra Digital Electronics

Boolean Algebra: Logic Gates & Truth Tables

Boolean algebra with logic gates, truth tables & switching algebra. AND, OR, NOT, NAND, NOR, XOR with practical digital electronics examples.

S

schutzgeist

2 min read
Boolean Algebra: Logic Gates & Truth Tables

Boolean Algebra: Logic Gates, Truth Tables & Switching Algebra

This article is a comprehensive introduction to Boolean Algebra – including logic gates, truth tables and switching algebra with practical examples.

In a Nutshell

Boolean algebra is the mathematics of logic with only two values: true (1) and false (0). It is the foundation of all digital circuits and computers.

Compact Technical Description

Boolean Algebra is an algebraic system for describing logical operations. It was developed by George Boole and forms the foundation of digital technology.

Basic Operations:

AND (Conjunction)

  • Symbol: ∧, ·, AND
  • Truth: Only true when both inputs are true
  • Circuit: Series connection
  • Application: Safety functions, validation

OR (Disjunction)

  • Symbol: ∨, +, OR
  • Truth: True when at least one input is true
  • Circuit: Parallel connection
  • Application: Alternative decisions

NOT (Negation)

  • Symbol: ¬, ~, NOT, overlined
  • Truth: Inverts the truth value
  • Circuit: Inverter
  • Application: Signal inversion

NAND (Not-AND)

  • Symbol: ↑, NAND
  • Truth: Only false when both inputs are true
  • Circuit: AND with inverter
  • Application: Universal gate

NOR (Not-OR)

  • Symbol: ↓, NOR
  • Truth: Only true when both inputs are false
  • Circuit: OR with inverter
  • Application: Universal gate

XOR (Exclusive-OR)

  • Symbol: ⊕, XOR
  • Truth: True when inputs are different
  • Circuit: Parity gate
  • Application: Error detection, cryptography

Exam-Relevant Key Points

  • Boolean Algebra: Mathematics with two values (0 and 1)
  • Logic Gates: Electronic circuits for logical operations
  • Truth Tables: Systematic representation of all possible input combinations
  • Switching Algebra: Application of Boolean algebra to circuits
  • Universal Gates: NAND and NOR can replace all other gates
  • Karnaugh Diagram: Simplification of logical expressions
  • IHK-relevant: Foundation for digital circuits and programming

Core Components

  1. Boolean Variables: Only 0 or 1
  2. Logical Operations: AND, OR, NOT, NAND, NOR, XOR
  3. Truth Tables: Complete function description
  4. Switching Algebra: Laws and simplifications
  5. Logic Gates: Electronic implementation
  6. Circuit Design: Combinational and sequential circuits
  7. Minimization: Karnaugh diagrams, Quine-McCluskey
  8. Applications: Computer architecture, digital systems

Practical Examples

1. Basic Logic Gates in Java

public class BoolescheAlgebra {
    
    public static void main(String[] args) {
        // Input values
        boolean a = true;   // 1
        boolean b = false;  // 0
        
        System.out.println("=== Basic Logic Operations ===");
        System.out.println("a = " + a + " (1), b = " + b + " (0)");
        
        // AND (Conjunction)
        boolean and = a && b;
        System.out.println("a AND b = " + and + " (" + (and ? 1 : 0) + ")");
        
        // OR (Disjunction)
        boolean or = a || b;
        System.out.println("a OR b = " + or + " (" + (or ? 1 : 0) + ")");
        
        // NOT (Negation)
        boolean notA = !a;
        boolean notB = !b;
        System.out.println("NOT a = " + notA + " (" + (notA ? 1 : 0) + ")");
        System.out.println("NOT b = " + notB + " (" + (notB ? 1 : 0) + ")");
        
        // NAND (Not-AND)
        boolean nand = !(a && b);
        System.out.println("a NAND b = " + nand + " (" + (nand ? 1 : 0) + ")");
        
        // NOR (Not-OR)
        boolean nor = !(a || b);
        System.out.println("a NOR b = " + nor + " (" + (nor ? 1 : 0) + ")");
        
        // XOR (Exclusive-OR)
        boolean xor = a ^ b;
        System.out.println("a XOR b = " + xor + " (" + (xor ? 1 : 0) + ")");
        
        // Truth tables
        wahrheitstabellen();
        
        // Switching algebra laws
        schaltalgebraGesetze();
        
        // Practical applications
        praktischeAnwendungen();
    }
    
    private static void wahrheitstabellen() {
        System.out.println("\n=== Truth Tables ===");
        
        System.out.println("A B | AND | OR | XOR | NAND | NOR");
        System.out.println("---+-----+----+-----+------+----");
        
        for (int a = 0; a <= 1; a++) {
            for (int b = 0; b <= 1; b++) {
                boolean aBool = a == 1;
                boolean bBool = b == 1;
                
                int and = (aBool && bBool) ? 1 : 0;
                int or = (aBool || bBool) ? 1 : 0;
                int xor = (aBool ^ bBool) ? 1 : 0;
                int nand = !(aBool && bBool) ? 1 : 0;
                int nor = !(aBool || bBool) ? 1 : 0;
                
                System.out.printf("%d %d |  %d  | %d  |  %d  |  %d   | %d%n", 
                                a, b, and, or, xor, nand, nor);
            }
        }
    }
    
    private static void schaltalgebraGesetze() {
        System.out.println("\n=== Switching Algebra Laws ===");
        
        boolean x = true;
        boolean y = false;
        boolean z = true;
        
        // Commutative laws
        System.out.println("Commutative Laws:");
        System.out.println("x AND y = y AND x: " + ((x && y) == (y && x)));
        System.out.println("x OR y = y OR x: " + ((x || y) == (y || x)));
        
        // Associative laws
        System.out.println("\nAssociative Laws:");
        System.out.println("(x AND y) AND z = x AND (y AND z): " + 
                          ((x && y) && z == x && (y && z)));
        System.out.println("(x OR y) OR z = x OR (y OR z): " + 
                          ((x || y) || z == x || (y || z)));
        
        // Distributive laws
        System.out.println("\nDistributive Laws:");
        System.out.println("x AND (y OR z) = (x AND y) OR (x AND z): " + 
                          (x && (y || z) == (x && y) || (x && z)));
        System.out.println("x OR (y AND z) = (x OR y) AND (x OR z): " + 
                          (x || (y && z) == (x || y) && (x || z)));
        
        // De Morgan's laws
        System.out.println("\nDe Morgan's Laws:");
        System.out.println("NOT (x AND y) = NOT x OR NOT y: " + 
                          (!(x && y) == (!x || !y)));
        System.out.println("NOT (x OR y) = NOT x AND NOT y: " + 
                          (!(x || y) == (!x && !y)));
        
        // Idempotence laws
        System.out.println("\nIdempotence Laws:");
        System.out.println("x AND x = x: " + (x && x == x));
        System.out.println("x OR x = x: " + (x || x == x));
        
        // Null laws
        System.out.println("\nNull Laws:");
        System.out.println("x AND 0 = 0: " + (x && false == false));
        System.out.println("x OR 1 = 1: " + (x || true == true));
        
        // Identity laws
        System.out.println("\nIdentity Laws:");
        System.out.println("x AND 1 = x: " + (x && true == x));
        System.out.println("x OR 0 = x: " + (x || false == x));
        
        // Complement laws
        System.out.println("\nComplement Laws:");
        System.out.println("x AND NOT x = 0: " + (x && !x == false));
        System.out.println("x OR NOT x = 1: " + (x || !x == true));
        System.out.println("NOT (NOT x) = x: " + (!(!x) == x));
    }
    
    private static void praktischeAnwendungen() {
        System.out.println("\n=== Practical Applications ===");
        
        // Security system: Multiple conditions must be met
        boolean passwortKorrekt = true;
        boolean biometrieErfolgreich = true;
        boolean zugriffErlaubt = passwortKorrekt && biometrieErfolgreich;
        System.out.println("Access allowed (AND): " + zugriffErlaubt);
        
        // Emergency exit: At least one condition must be met
        boolean feuerMeldung = false;
        boolean notausGedrueckt = true;
        boolean alarmAktiv = feuerMeldung || notausGedrueckt;
        System.out.println("Alarm active (OR): " + alarmAktiv);
        
        // Parity check: XOR for error detection
        int daten = 0b1011001;  // 7 bits
        int paritaetsbit = 0;
        for (int i = 0; i < 7; i++) {
            paritaetsbit ^= (daten >> i) & 1;  // XOR for parity
        }
        System.out.println("Parity bit: " + paritaetsbit + " (even parity)");
        
        // Multiplexer selection
        int auswahl = 2;  // 0, 1, 2, or 3
        boolean auswahl0 = (auswahl & 1) == 0 && (auswahl & 2) == 0;
        boolean auswahl1 = (auswahl & 1) == 1 && (auswahl & 2) == 0;
        boolean auswahl2 = (auswahl & 1) == 0 && (auswahl & 2) == 2;
        boolean auswahl3 = (auswahl & 1) == 1 && (auswahl & 2) == 2;
        
        System.out.println("Multiplexer selection " + auswahl + ":");
        System.out.println("  Output 0: " + auswahl0);
        System.out.println("  Output 1: " + auswahl1);
        System.out.println("  Output 2: " + auswahl2);
        System.out.println("  Output 3: " + auswahl3);
    }
}

2. Logic Gates as Circuits (Python)

class LogikGatter:
    """Implementierung von Logik-Gattern"""
    
    @staticmethod
    def and_gatter(a, b):
        """AND-Gatter"""
        return a and b
    
    @staticmethod
    def or_gatter(a, b):
        """OR-Gatter"""
        return a or b
    
    @staticmethod
    def not_gatter(a):
        """NOT-Gatter (Inverter)"""
        return not a
    
    @staticmethod
    def nand_gatter(a, b):
        """NAND-Gatter"""
        return not (a and b)
    
    @staticmethod
    def nor_gatter(a, b):
        """NOR-Gatter"""
        return not (a or b)
    
    @staticmethod
    def xor_gatter(a, b):
        """XOR-Gatter"""
        return a != b
    
    @staticmethod
    def xnor_gatter(a, b):
        """XNOR-Gatter (Äquivalenz)"""
        return a == b

class SchaltungsDesign:
    """Design von digitalen Schaltungen"""
    
    @staticmethod
    def halbaddierer(a, b):
        """Half adder: Sum and carry"""
        summe = LogikGatter.xor_gatter(a, b)
        uebertrag = LogikGatter.and_gatter(a, b)
        return summe, uebertrag
    
    @staticmethod
    def volladdierer(a, b, c_in):
        """Full adder: With input carry"""
        # First half adder
        summe1, uebertrag1 = SchaltungsDesign.halbaddierer(a, b)
        
        # Second half adder
        summe2, uebertrag2 = SchaltungsDesign.halbaddierer(summe1, c_in)
        
        # Final carry
        uebertrag = LogikGatter.or_gatter(uebertrag1, uebertrag2)
        
        return summe2, uebertrag
    
    @staticmethod
    def multiplexer(a, b, s):
        """2-to-1 multiplexer"""
        # If s=0, output=a; if s=1, output=b
        not_s = LogikGatter.not_gatter(s)
        ausgang_a = LogikGatter.and_gatter(a, not_s)
        ausgang_b = LogikGatter.and_gatter(b, s)
        return LogikGatter.or_gatter(ausgang_a, ausgang_b)
    
    @staticmethod
    def demultiplexer(d, s):
        """1-to-2 demultiplexer"""
        # If s=0, y0=d, y1=0; if s=1, y0=0, y1=d
        not_s = LogikGatter.not_gatter(s)
        y0 = LogikGatter.and_gatter(d, not_s)
        y1 = LogikGatter.and_gatter(d, s)
        return y0, y1
    
    @staticmethod
    def rs_flipflop(r, s, q_alt):
        """RS-Flipflop (asynchronous)"""
        # Q_neu = (S OR (NOT R AND Q_alt))
        not_r = LogikGatter.not_gatter(r)
        temp = LogikGatter.and_gatter(not_r, q_alt)
        q_neu = LogikGatter.or_gatter(s, temp)
        q_bar_neu = LogikGatter.not_gatter(q_neu)
        return q_neu, q_bar_neu

def wahrheitstabelle_drucken(gatter_name, gatter_funktion):
    """Prints truth table for a gate"""
    print(f"\n=== {gatter_name} ===")
    print("A B | Output")
    print("---+--------")
    
    for a in [False, True]:
        for b in [False, True]:
            ergebnis = gatter_funktion(a, b)
            print(f"{int(a)} {int(b)} |   {int(ergebnis)}")

def main():
    """Main program with demonstrations"""
    
    # Truth tables
    wahrheitstabelle_drucken("AND", LogikGatter.and_gatter)
    wahrheitstabelle_drucken("OR", LogikGatter.or_gatter)
    wahrheitstabelle_drucken("NAND", LogikGatter.nand_gatter)
    wahrheitstabelle_drucken("NOR", LogikGatter.nor_gatter)
    wahrheitstabelle_drucken("XOR", LogikGatter.xor_gatter)
    wahrheitstabelle_drucken("XNOR", LogikGatter.xnor_gatter)
    
    # Circuit design demonstrations
    print("\n=== Half Adder ===")
    for a in [False, True]:
        for b in [False, True]:
            summe, uebertrag = SchaltungsDesign.halbaddierer(a, b)
            print(f"{int(a)} + {int(b)} = Sum: {int(summe)}, Carry: {int(uebertrag)}")
    
    print("\n=== Full Adder ===")
    for a in [False, True]:
        for b in [False, True]:
            for c_in in [False, True]:
                summe, uebertrag = SchaltungsDesign.volladdierer(a, b, c_in)
                print(f"{int(c_in)}{int(a)} + {int(b)} = Sum: {int(summe)}, Carry: {int(uebertrag)}")
    
    print("\n=== Multiplexer ===")
    for s in [False, True]:
        ausgang = SchaltungsDesign.multiplexer(True, False, s)
        print(f"Select {int(s)}: Output = {int(ausgang)}")
    
    print("\n=== RS-Flipflop ===")
    q_alt = False
    print(f"Q_alt = {int(q_alt)}")
    
    # Set
    q_neu, q_bar_neu = SchaltungsDesign.rs_flipflop(False, True, q_alt)
    print(f"S=1, R=0: Q={int(q_neu)}, Q_bar={int(q_bar_neu)}")
    
    # Hold
    q_neu, q_bar_neu = SchaltungsDesign.rs_flipflop(False, False, q_neu)
    print(f"S=0, R=0: Q={int(q_neu)}, Q_bar={int(q_bar_neu)}")
    
    # Reset
    q_neu, q_bar_neu = SchaltungsDesign.rs_flipflop(True, False, q_neu)
    print(f"S=0, R=1: Q={int(q_neu)}, Q_bar={int(q_bar_neu)}")

if __name__ == "__main__":
    main()

3. Boolean Algebra with Bit Operations (C++)

#include <iostream>
#include <bitset>
#include <string>

class BoolescheAlgebraCPP {
public:
    // Bit operations for logic gates
    static bool and_gatter(bool a, bool b) {
        return a & b;
    }
    
    static bool or_gatter(bool a, bool b) {
        return a | b;
    }
    
    static bool not_gatter(bool a) {
        return !a;
    }
    
    static bool nand_gatter(bool a, bool b) {
        return !(a & b);
    }
    
    static bool nor_gatter(bool a, bool b) {
        return !(a | b);
    }
    
    static bool xor_gatter(bool a, bool b) {
        return a ^ b;
    }
    
    // Boolean functions with multiple inputs
    static bool and_n(bool eingaenge[], int n) {
        bool ergebnis = true;
        for (int i = 0; i < n; i++) {
            ergebnis &= eingaenge[i];
        }
        return ergebnis;
    }
    
    static bool or_n(bool eingaenge[], int n) {
        bool ergebnis = false;
        for (int i = 0; i < n; i++) {
            ergebnis |= eingaenge[i];
        }
        return ergebnis;
    }
    
    // Parity check
    static bool gerade_paritat(unsigned int wert) {
        bool paritaet = false;
        while (wert > 0) {
            paritaet ^= (wert & 1);
            wert >>= 1;
        }
        return !paritaet;  // Even parity
    }
    
    // Gray code conversion
    static unsigned int dezimal_zu_gray(unsigned int dezimal) {
        return dezimal ^ (dezimal >> 1);
    }
    
    static unsigned int gray_zu_dezimal(unsigned int gray) {
        unsigned int dezimal = 0;
        while (gray > 0) {
            dezimal ^= gray;
            gray >>= 1;
        }
        return dezimal;
    }
    
    // Karnaugh diagram helper
    static void karnaugh_diagramm_drucken() {
        std::cout << "\n=== Karnaugh Diagram (2 Variables) ===\n";
        std::cout << "  AB\\CD  00  01  11  10\n";
        std::cout << "  -----------------------\n";
        
        // Example function: F = A'B + AB'
        for (int a = 0; a <= 1; a++) {
            for (int b = 0; b <= 1; b++) {
                std::string ab = std::to_string(a) + std::to_string(b);
                std::cout << "    " << ab << "   ";
                
                for (int c = 0; c <= 1; c++) {
                    for (int d = 0; d <= 1; d++) {
                        // F = A'B + AB'
                        bool f = (!a && b) || (a && !b);
                        std::cout << " " << f << "  ";
                    }
                }
                std::cout << "\n";
                break;  // Only one row for 2 variables
            }
        }
    }
};

int main() {
    std::cout << "=== Boolean Algebra in C++ ===\n";
    
    // Basic operations
    bool a = true;
    bool b = false;
    
    std::cout << "a = " << a << ", b = " << b << "\n";
    std::cout << "a AND b = " << BoolescheAlgebraCPP::and_gatter(a, b) << "\n";
    std::cout << "a OR b = " << BoolescheAlgebraCPP::or_gatter(a, b) << "\n";
    std::cout << "NOT a = " << BoolescheAlgebraCPP::not_gatter(a) << "\n";
    std::cout << "a XOR b = " << BoolescheAlgebraCPP::xor_gatter(a, b) << "\n";
    
    // Multiple inputs
    std::cout << "\n=== Multiple Inputs ===\n";
    bool eingaenge[4] = {true, false, true, false};
    std::cout << "AND of all inputs: " << BoolescheAlgebraCPP::and_n(eingaenge, 4) << "\n";
    std::cout << "OR of all inputs: " << BoolescheAlgebraCPP::or_n(eingaenge, 4) << "\n";
    
    // Parity check
    std::cout << "\n=== Parity Check ===\n";
    unsigned int werte[] = {0b1011001, 0b1101101, 0b1110000};
    for (unsigned int wert : werte) {
        std::cout << "Value: " << std::bitset<7>(wert) 
                  << ", even parity: " << BoolescheAlgebraCPP::gerade_paritat(wert) << "\n";
    }
    
    // Gray code
    std::cout << "\n=== Gray Code Conversion ===\n";
    for (unsigned int i = 0; i < 8; i++) {
        unsigned int gray = BoolescheAlgebraCPP::dezimal_zu_gray(i);
        unsigned int zurueck = BoolescheAlgebraCPP::gray_zu_dezimal(gray);
        std::cout << i << " -> " << std::bitset<3>(gray) 
                  << " -> " << zurueck << "\n";
    }
    
    // Bit manipulation
    std::cout << "\n=== Bit Manipulation ===\n";
    unsigned int register_wert = 0b10101010;
    
    std::cout << "Original: " << std::bitset<8>(register_wert) << "\n";
    
    // Set bit
    unsigned int bit_gesetzt = register_wert | (1 << 3);
    std::cout << "Set bit 3: " << std::bitset<8>(bit_gesetzt) << "\n";
    
    // Clear bit
    unsigned int bit_geloescht = register_wert & ~(1 << 5);
    std::cout << "Clear bit 5: " << std::bitset<8>(bit_geloescht) << "\n";
    
    // Toggle bit
    unsigned int bit_umgeschaltet = register_wert ^ (1 << 1);
    std::cout << "Toggle bit 1: " << std::bitset<8>(bit_umgeschaltet) << "\n";
    
    // Check bit
    bool bit_4_gesetzt = (register_wert & (1 << 4)) != 0;
    std::cout << "Bit 4 set: " << bit_4_gesetzt << "\n";
    
    // Karnaugh diagram
    BoolescheAlgebraCPP::karnaugh_diagramm_drucken();
    
    return 0;
}

4. Boolean Algebra and Simplification

public class Schaltalgebra {
    
    // Boolesche Ausdrücke als Methoden
    public static boolean ausdruck1(boolean a, boolean b, boolean c) {
        // Original: (A AND B) OR (A AND C)
        return (a && b) || (a && c);
    }
    
    public static boolean ausdruck1Vereinfacht(boolean a, boolean b, boolean c) {
        // Simplified: A AND (B OR C)  (Distributive Law)
        return a && (b || c);
    }
    
    public static boolean ausdruck2(boolean a, boolean b, boolean c) {
        // Original: (A OR B) AND (A OR C) AND (NOT B OR C)
        return (a || b) && (a || c) && (!b || c);
    }
    
    public static boolean ausdruck2Vereinfacht(boolean a, boolean b, boolean c) {
        // Simplified: A AND (NOT B OR C) OR (B AND C)
        return (a && (!b || c)) || (b && c);
    }
    
    public static boolean ausdruck3(boolean a, boolean b) {
        // Original: (A AND NOT B) OR (NOT A AND B)
        return (a && !b) || (!a && b);
    }
    
    public static boolean ausdruck3Vereinfacht(boolean a, boolean b) {
        // Simplified: A XOR B
        return a ^ b;
    }
    
    // Wahrheitstabellen für Vergleich
    public static void vergleicheAusdruecke() {
        System.out.println("=== Expression Comparisons ===");
        System.out.println("A B C | Orig1 | Simp1 | Orig2 | Simp2 | Orig3 | Simp3");
        System.out.println("-------+-------+-------+-------+-------+-------+-------");
        
        for (boolean a : new boolean[]{false, true}) {
            for (boolean b : new boolean[]{false, true}) {
                for (boolean c : new boolean[]{false, true}) {
                    boolean orig1 = ausdruck1(a, b, c);
                    boolean simp1 = ausdruck1Vereinfacht(a, b, c);
                    boolean orig2 = ausdruck2(a, b, c);
                    boolean simp2 = ausdruck2Vereinfacht(a, b, c);
                    boolean orig3 = ausdruck3(a, b);
                    boolean simp3 = ausdruck3Vereinfacht(a, b);
                    
                    System.out.printf("%d %d %d |  %d    |  %d    |  %d    |  %d    |  %d    |  %d%n",
                                    a?1:0, b?1:0, c?1:0,
                                    orig1?1:0, simp1?1:0,
                                    orig2?1:0, simp2?1:0,
                                    orig3?1:0, simp3?1:0);
                }
            }
        }
    }
    
    // NAND-NOR Implementierung (universelle Gatter)
    public static boolean andMitNand(boolean a, boolean b) {
        // AND = NOT(NAND(A,B))
        return !(!(a && b));
    }
    
    public static boolean orMitNand(boolean a, boolean b) {
        // OR = NOT(NAND(NOT(A), NOT(B)))
        return !(!a && !b);
    }
    
    public static boolean notMitNand(boolean a) {
        // NOT = NAND(A,A)
        return !(a && a);
    }
    
    public static boolean xorMitNand(boolean a, boolean b) {
        // XOR = NAND(NAND(A,NAND(A,B)), NAND(B,NAND(A,B)))
        boolean nand_ab = !(a && b);
        boolean nand_a_nandab = !(a && nand_ab);
        boolean nand_b_nandab = !(b && nand_ab);
        return !(nand_a_nandab && nand_b_nandab);
    }
    
    // NOR Implementierung
    public static boolean andMitNor(boolean a, boolean b) {
        // AND = NOR(NOR(A,A), NOR(B,B))
        return !(!a || !b);
    }
    
    public static boolean orMitNor(boolean a, boolean b) {
        // OR = NOT(NOR(A,B))
        return !(a || b);
    }
    
    public static boolean notMitNor(boolean a) {
        // NOT = NOR(A,A)
        return !(a || a);
    }
    
    public static void universaleGatterDemo() {
        System.out.println("\n=== Universal Gate Demonstration ===");
        
        boolean a = true;
        boolean b = false;
        
        System.out.println("a = " + a + ", b = " + b);
        
        // NAND-Implementierungen
        System.out.println("\nNAND Implementations:");
        System.out.println("AND with NAND: " + andMitNand(a, b));
        System.out.println("OR with NAND: " + orMitNand(a, b));
        System.out.println("NOT with NAND: " + notMitNand(a));
        System.out.println("XOR with NAND: " + xorMitNand(a, b));
        
        // NOR-Implementierungen
        System.out.println("\nNOR Implementations:");
        System.out.println("AND with NOR: " + andMitNor(a, b));
        System.out.println("OR with NOR: " + orMitNor(a, b));
        System.out.println("NOT with NOR: " + notMitNor(a));
    }
    
    public static void main(String[] args) {
        vergleicheAusdruecke();
        universaleGatterDemo();
        
        // Komplexere Schaltung: 4-zu-1 Multiplexer
        multiplexerDemo();
    }
    
    private static void multiplexerDemo() {
        System.out.println("\n=== 4-to-1 Multiplexer ===");
        
        boolean d0 = true, d1 = false, d2 = true, d3 = false;
        boolean s0 = true, s1 = false;  // Select lines
        
        // Multiplexer logic
        boolean y = (d0 && !s0 && !s1) || 
                   (d1 && s0 && !s1) || 
                   (d2 && !s0 && s1) || 
                   (d3 && s0 && s1);
        
        System.out.println("Data: D0=" + d0 + ", D1=" + d1 + ", D2=" + d2 + ", D3=" + d3);
        System.out.println("Select: S0=" + s0 + ", S1=" + s1);
        System.out.println("Output Y: " + y);
    }
}

Truth Tables Overview

Basic Gates (2 Inputs)

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

NOT Gate (1 Input)

ANOT
01
10

Boolean Algebra Laws

Commutative Laws

A ∧ B = B ∧ A
A ∨ B = B ∨ A

Associative Laws

(A ∧ B) ∧ C = A ∧ (B ∧ C)
(A ∨ B) ∨ C = A ∨ (B ∨ C)

Distributive Laws

A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)
A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)

De Morgan’s Laws

¬(A ∧ B) = ¬A ∨ ¬B
¬(A ∨ B) = ¬A ∧ ¬B

Idempotence Laws

A ∧ A = A
A ∨ A = A

Null and Unity Laws

A ∧ 0 = 0
A ∨ 1 = 1
A ∧ 1 = A
A ∨ 0 = A

Complement Laws

A ∧ ¬A = 0
A ∨ ¬A = 1
¬(¬A) = A

Logic Gate Symbols

ANSI/IEEE Symbols

  • AND: D-shaped gate
  • OR: Curved gate
  • NOT: Triangle with circle
  • NAND: AND with circle
  • NOR: OR with circle
  • XOR: OR with additional line

DIN Symbols (European)

  • AND: Rectangle with &
  • OR: Rectangle with ≥1
  • NOT: Rectangle with 1
  • NAND: Rectangle with &
  • NOR: Rectangle with ≥1
  • XOR: Rectangle with =1

Combinatorial Circuits

Adders

  • Half Adder: 2 bits → Sum + Carry
  • Full Adder: 3 bits → Sum + Carry
  • Ripple-Carry Adder: Multiple full adders

Multiplexer/Demultiplexer

  • Multiplexer: Selector from multiple inputs
  • Demultiplexer: Distributor to multiple outputs
  • Applications: Data buses, addressing

Encoder/Decoder

  • Encoder: Multiple inputs → Binary code
  • Decoder: Binary code → Multiple outputs
  • Applications: Keyboards, 7-segment displays

Advantages and Disadvantages

Advantages of Boolean Algebra

  • Simplicity: Only two states
  • Reliability: Robust digital circuits
  • Simplification: Complex logic can be minimized
  • Automation: Suitable for computer design

Disadvantages

  • Abstraction: Not intuitive for complex problems
  • Limitation: Only binary logic
  • Complexity: Large circuits become confusing

Frequently Asked Exam Questions

  1. Create the truth table for XOR! XOR is true when the inputs are different.

  2. What do De Morgan’s laws state? ¬(A ∧ B) = ¬A ∨ ¬B and ¬(A ∨ B) = ¬A ∧ ¬B

  3. Why are NAND and NOR universal gates? All other logical functions can be realized using only NAND or NOR.

  4. What is the difference between a half adder and a full adder? Half adder has 2 inputs, full adder has 3 inputs (incl. carry).

Most Important Sources

  1. https://de.wikipedia.org/wiki/Boolesche_Algebra
  2. https://de.wikipedia.org/wiki/Logikgatter
  3. https://www.tutorialspoint.com/digital_electronics/
Back to Blog
Share: