{
  "id": "logic-foundations-v1",
  "title": "Small ideas. Strong foundations.",
  "subtitle": "Sets, relations and functions · A short course in mathematical thinking",
  "source": {
    "title": "Open Logic Text",
    "authors": "The Open Logic Project contributors",
    "url": "https://openlogicproject.org/",
    "license": "CC BY 4.0",
    "license_url": "https://creativecommons.org/licenses/by/4.0/",
    "notice": "A condensed teaching adaptation by StudeeBuddy, with new examples and exercises. The Open Logic Project does not endorse StudeeBuddy. This course text is CC BY 4.0; the software and AI-generated responses are separate."
  },
  "lessons": [
    {
      "id": "sets",
      "title": "A collection, not a sequence",
      "minutes": 3,
      "body": "A **set** describes which objects belong together. We write $x \\in A$ when\n$x$ belongs to the set $A$, and $x \\notin A$ when it does not.\n\nImagine a tray containing a red tile, a blue tile and a green tile. Let\n$T = \\{\\text{red}, \\text{blue}, \\text{green}\\}$. Moving the tiles around does not\nchange their membership. For sets, order is irrelevant. Listing red twice does not add\nanother distinct member either.\n\nTwo sets are equal exactly when they have the same members. Consequently,\n$\\{2,4,6\\} = \\{6,2,4,4\\}$. Both descriptions identify the same three numbers.\n\n### Smaller collections\n\n$A$ is a **subset** of $B$, written $A \\subseteq B$, when every member of $A$ is also\nin $B$. For example, $\\{2,6\\} \\subseteq \\{2,4,6\\}$. A set is always a subset of\nitself. The empty set, $\\varnothing$, has no members and is a subset of every set.\n\nMembership and inclusion answer different questions: $2 \\in A$ asks about an object;\n$\\{2\\} \\subseteq A$ asks about a collection of objects.\n\n### Try it before asking\n\nLet $A=\\{1,3,5\\}$. Are $3 \\in A$ and $\\{3,5\\} \\subseteq A$ both true?\nExplain what each statement is checking.\n",
      "prompts": [
        "Why do repeated entries not change a set?",
        "What is the difference between membership and subset?"
      ]
    },
    {
      "id": "relations",
      "title": "When the connection has a direction",
      "minutes": 3,
      "body": "An **ordered pair** records two objects in distinct positions. Usually,\n$(a,b)$ and $(b,a)$ mean different things. A flight from Oslo to Lima is not a flight\nfrom Lima to Oslo, even though the same cities appear.\n\nFor sets $A$ and $B$, their **Cartesian product** $A \\times B$ contains every ordered\npair $(a,b)$ with $a \\in A$ and $b \\in B$.\n\nTake $A=\\{1,2\\}$ and $B=\\{x,y\\}$. Then\n$A \\times B=\\{(1,x),(1,y),(2,x),(2,y)\\}$. Each choice from the first set is\npaired with each choice from the second.\n\n### Selecting the connections\n\nA **relation** from $A$ to $B$ is a subset of $A \\times B$. It selects the pairs\nthat satisfy some connection. For example, a relation between people and courses\nmight contain $(\\text{Mira},\\text{Logic})$ when Mira attends Logic.\n\nA person can attend several courses. Several people can attend the same course.\nA relation allows both patterns; it does not impose a one-output rule.\n\n### Try it before asking\n\nFor $A=\\{1,2,3\\}$, consider the relation containing $(a,b)$ whenever $a<b$.\nList its ordered pairs. Does $(2,1)$ belong? Does $(2,2)$ belong?\n",
      "prompts": [
        "Why does the order of a pair matter?",
        "Can you help me list the pairs for the less-than relation?"
      ]
    },
    {
      "id": "functions",
      "title": "Every input gets one answer",
      "minutes": 4,
      "body": "A **function** from $A$ to $B$ assigns exactly one member of $B$ to every\nmember of $A$. The set $A$ is its **domain**. The set $B$ is its **codomain**.\n\nThe rule $f(n)=2n$ defines a function from the integers to the integers. For every\ninteger input there is one specified output: $f(3)=6$ and $f(-2)=-4$.\n\nA function is a special kind of relation. It must satisfy two conditions:\n\n- Every input in the domain has an output.\n- No input has two different outputs.\n\n### Same output, different inputs\n\nDifferent inputs may share an output. For $g(n)=n^2$, both $g(2)$ and $g(-2)$ equal\n$4$. That does not break the function rule: each input still gets exactly one answer.\nA function is **one-to-one** only when different inputs always produce different outputs.\n\nThe **range** is the set of outputs actually reached. For $g$ from the integers to the\nintegers, the codomain contains $-1$, but the range does not: no integer squared equals\n$-1$. Domain, codomain and range serve different jobs.\n\n### Try it before asking\n\nLet $A=\\{1,2,3\\}$ and $B=\\{a,b\\}$. Does the relation\n$\\{(1,a),(2,a),(3,b)\\}$ define a function from $A$ to $B$? What changes if we\nadd $(2,b)$? What changes if we remove $(3,b)$ instead?\n",
      "prompts": [
        "Why can two inputs share an output in a function?",
        "Can you explain domain, codomain and range with another example?"
      ]
    }
  ]
}
