{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $X$ be a set, let $M(X)$ be the [[free magma|ZZF8XPBG3Z]] on $X$, and let $\\iota \\colon X \\to M(X)$ be the inclusion of the generators.\nLet $N$ be a [[magma|9689SFPVE9]] and let $f \\colon X \\to N$ be a map.\nThen there is exactly one magma [[homomorphism|KBXSZC6BV1]] $h \\colon M(X) \\to N$ such that $h \\circ \\iota = f$.\n\n## Remarks\n\nExistence: define $h$ by recursion on the construction of elements, with $h(x) = f(x)$ for $x \\in X$ and $h(u \\cdot v) = h(u) \\cdot h(v)$.\nThis recursion is valid because each element of $M(X)$ is either a generator or a product $u \\cdot v$ for exactly one pair $(u, v)$.\nUniqueness: two homomorphisms that agree on $X$ agree on all elements, by induction on the construction.\nExample: with $N = (\\Z, +)$ and $f(x) = 1$ for all $x$, the homomorphism $h$ sends each element to its number of leaves.\nWith $N = (\\N, \\max(a, b) + 1)$ and $f(x) = 0$, the homomorphism $h$ sends each element to the height of its binary tree.\nIn Mathlib this is `FreeMagma.lift`, an equivalence between maps $X \\to N$ and magma homomorphisms $M(X) \\to N$.\n\n## Explanations\n\n### L1 human\n\nTo map the free magma into another magma, it is enough to say where each letter goes.\nThe image of every bracketed product is then forced: it is the same product, bracketed the same way, of the images of the letters.\nSince the free magma has no rules, nothing can go wrong.\n\n### L2 human\n\nThe proposition says that the free magma is the free algebra of the variety of all magmas.\nThe free semigroup on $X$ has the same kind of universal property, and it is the quotient of $M(X)$ by the congruence generated by associativity.\nRecursive definitions on binary trees, such as size and height, are instances of this proposition.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "ZZF8XPBG3Z"
    ],
    "kind": "statement",
    "msc": [
      "08B20",
      "20N02"
    ],
    "name": "Universal property of the free magma",
    "role": "proposition",
    "sources": [
      {
        "locator": "Free magma",
        "url": "https://en.wikipedia.org/wiki/Magma_(algebra)"
      }
    ],
    "tag": "4YN1TB9CXN",
    "uses": [
      "ZZF8XPBG3Z",
      "9689SFPVE9",
      "KBXSZC6BV1"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/4YN1TB9CXN/",
  "links": [
    {
      "field": "about",
      "target": "ZZF8XPBG3Z"
    },
    {
      "field": "uses",
      "target": "ZZF8XPBG3Z"
    },
    {
      "field": "uses",
      "target": "9689SFPVE9"
    },
    {
      "field": "uses",
      "target": "KBXSZC6BV1"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/4YN1TB9CXN.md",
  "msc": [
    "08B20",
    "20N02"
  ],
  "name": "Universal property of the free magma",
  "prov": null,
  "role": "proposition",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/4YN/4YN1TB9CXN.md",
  "status": null,
  "tag": "4YN1TB9CXN",
  "uri": "m2://4YN1TB9CXN",
  "url": "https://tamnd.github.io/math2/wiki/universal-property-of-the-free-magma/",
  "writing": {
    "tag": "4YN1TB9CXN",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
