{
  "id": "boolean-algebra",
  "version": "157c625fdfd9",
  "status": "published",
  "name": "Boolean Algebra Calculator",
  "question": "How do I simplify Boolean algebra?",
  "summary": "Simplifies a Boolean expression, or a list of minterms with don’t-cares, to a minimal sum of products and product of sums (Quine-McCluskey), with its minterms and maxterms.",
  "category": "logic",
  "subcategory": "binary",
  "url": "https://www.acalculator.org/logic/boolean-algebra-calculator",
  "markdown": "https://www.acalculator.org/logic/boolean-algebra-calculator.md",
  "kind": "function",
  "method": "Truth table from the expression; prime implicants by the Quine-McCluskey method; a minimal cover by exact search (fewest terms, then fewest literals, then a fixed order). The product of sums is the complement’s minimal sum, by De Morgan’s laws.",
  "assumptions": [
    "Variables are single letters (case does not matter); at most 5 of them.",
    "A row number reads the variables as binary digits, the first variable (in alphabetical order) the highest bit.",
    "When several forms are equally short, one is chosen by a fixed order, so another correct answer may exist."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "from": {
        "title": "Start from",
        "description": "A Boolean expression, or the minterm numbers of a function.",
        "type": "string",
        "enum": [
          "expr",
          "minterms"
        ]
      },
      "f": {
        "title": "Expression",
        "description": "Letters are variables; + or OR, · or AND or side by side, ’ after or ! before for NOT, ^ or XOR.",
        "type": "string",
        "maxLength": 200
      },
      "n": {
        "title": "Number of variables",
        "description": "How many variables the function has; they are named A, B, C and so on.",
        "type": "integer",
        "minimum": 1,
        "maximum": 5
      },
      "m": {
        "title": "Minterms",
        "description": "The input rows where the function is 1, as numbers separated by commas.",
        "type": "string",
        "maxLength": 1200
      },
      "d": {
        "title": "Don’t cares (optional)",
        "description": "Rows where the output does not matter, as numbers separated by commas.",
        "type": "string",
        "maxLength": 1200
      }
    }
  },
  "outputs": {
    "sop": {
      "label": "Simplest sum of products",
      "description": "A minimal OR of ANDs: fewest terms, then fewest letters.",
      "format": "text"
    },
    "pos": {
      "label": "Simplest product of sums",
      "description": "A minimal AND of ORs.",
      "format": "text"
    },
    "minterms": {
      "label": "Minterms",
      "description": "The rows of the truth table where the function is 1.",
      "format": "text"
    },
    "maxterms": {
      "label": "Maxterms",
      "description": "The rows where the function is 0 (don’t cares left out).",
      "format": "text"
    },
    "vars": {
      "label": "Variables",
      "description": "The variables, first one the highest bit of a row number.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "from": "expr",
      "f": "AB + AB' + A'B",
      "n": 4,
      "m": "4, 8, 10, 11, 12, 15",
      "d": "9, 14"
    },
    "outputs": {
      "sop": "A + B",
      "pos": "(A + B)",
      "minterms": "Σm(1, 2, 3)",
      "maxterms": "ΠM(0)",
      "vars": "A, B"
    },
    "text": "The simplest form is A + B."
  },
  "examples": [
    {
      "given": {
        "from": "minterms",
        "n": 4,
        "m": "4, 8, 10, 11, 12, 15",
        "d": "9, 14"
      },
      "expect": {
        "sop": "AB' + AC + BC'D'",
        "minterms": "Σm(4, 8, 10, 11, 12, 15)",
        "maxterms": "ΠM(0, 1, 2, 3, 5, 6, 7, 13)"
      },
      "source": "Wikipedia, Quine–McCluskey algorithm: f(A,B,C,D) = Σm(4,8,10,11,12,15) + d(9,14) has the minimal forms BC′D′ + AB′ + AC and BC′D′ + AD′ + AC, https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm; the fixed order in content.mdx picks AB′ over AD′"
    },
    {
      "given": {
        "from": "expr",
        "f": "A + A'B"
      },
      "expect": {
        "sop": "A + B",
        "pos": "(A + B)",
        "minterms": "Σm(1, 2, 3)",
        "vars": "A, B"
      },
      "source": "Kuphaldt, Lessons in Electric Circuits Vol. IV, §7.5 Boolean Rules for Simplification (A + AB = A, A + A′B = A + B), LibreTexts, https://workforce.libretexts.org/Bookshelves/Electronics_Technology/Electric_Circuits_IV_-_Digital_Circuitry_(Kuphaldt)/07:_Boolean_Algebra/7.05:_Boolean_Rules_for_Simplification"
    },
    {
      "given": {
        "from": "expr",
        "f": "A + AB"
      },
      "expect": {
        "sop": "A",
        "pos": "A",
        "minterms": "Σm(2, 3)"
      },
      "source": "Kuphaldt, Lessons in Electric Circuits Vol. IV, §7.5 Boolean Rules for Simplification (A + AB = A, A + A′B = A + B), LibreTexts, https://workforce.libretexts.org/Bookshelves/Electronics_Technology/Electric_Circuits_IV_-_Digital_Circuitry_(Kuphaldt)/07:_Boolean_Algebra/7.05:_Boolean_Rules_for_Simplification"
    },
    {
      "given": {
        "from": "expr",
        "f": "AB + BC(B + C)"
      },
      "expect": {
        "sop": "AB + BC",
        "pos": "(A + C)B",
        "minterms": "Σm(3, 6, 7)"
      },
      "source": "Kuphaldt, Lessons in Electric Circuits Vol. IV, §7.6 Circuit Simplification Examples (AB + BC(B + C) = B(A + C)), LibreTexts, https://workforce.libretexts.org/Bookshelves/Electronics_Technology/Electric_Circuits_IV_-_Digital_Circuitry_(Kuphaldt)/07:_Boolean_Algebra/7.06:_Circuit_Simplification_Examples"
    },
    {
      "given": {
        "from": "expr",
        "f": "AB + AB' + A'B"
      },
      "expect": {
        "sop": "A + B",
        "maxterms": "ΠM(0)"
      },
      "source": "Kuphaldt, Lessons in Electric Circuits Vol. IV, §7.5 Boolean Rules for Simplification (A + AB = A, A + A′B = A + B), LibreTexts, https://workforce.libretexts.org/Bookshelves/Electronics_Technology/Electric_Circuits_IV_-_Digital_Circuitry_(Kuphaldt)/07:_Boolean_Algebra/7.05:_Boolean_Rules_for_Simplification (AB + AB′ = A, then A + A′B = A + B)"
    },
    {
      "given": {
        "from": "expr",
        "f": "A XOR B"
      },
      "expect": {
        "sop": "AB' + A'B",
        "pos": "(A' + B')(A + B)"
      },
      "source": "Kuphaldt, Lessons in Electric Circuits Vol. IV, §7.5 Boolean Rules for Simplification (A + AB = A, A + A′B = A + B), LibreTexts, https://workforce.libretexts.org/Bookshelves/Electronics_Technology/Electric_Circuits_IV_-_Digital_Circuitry_(Kuphaldt)/07:_Boolean_Algebra/7.05:_Boolean_Rules_for_Simplification; hand calculation in content.mdx: A ⊕ B is 1 on rows 1 and 2"
    }
  ],
  "sources": [
    "Wikipedia, Quine–McCluskey algorithm: prime implicants by merging minterms, the prime implicant chart, and the example f(A,B,C,D) = Σm(4,8,10,11,12,15) + d(9,14) with minimal forms BC′D′ + AB′ + AC and BC′D′ + AD′ + AC. Retrieved 2026-10-02. https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm",
    "Kuphaldt, Lessons in Electric Circuits, Volume IV, section 7.5 Boolean Rules for Simplification (A + AB = A, A + A′B = A + B, (A + B)(A + C) = A + BC) and section 7.6 Circuit Simplification Examples (AB + BC(B + C) = B(A + C)), LibreTexts, CC BY. Retrieved 2026-10-02. https://workforce.libretexts.org/Bookshelves/Electronics_Technology/Electric_Circuits_IV_-_Digital_Circuitry_(Kuphaldt)/07:_Boolean_Algebra/7.05:_Boolean_Rules_for_Simplification"
  ],
  "related": [
    "binary",
    "xor",
    "hex"
  ],
  "changelog": []
}
