Skip to content
LAM
Read Home Blog
Make Projects HTML Tools Games
Touch grass Notes Resume Links
Home Blog HTML Projects
Tools Games Notes Resume Links
Back MAT 243 — Discrete Math Structures — The Complete Galaxy Guide Math
Download Open
Show description 2,329 chars · Math

MAT 243 — Discrete Math Structures — The Complete Galaxy Guide

MAT 243 — Discrete Math Structures — The Complete Galaxy Guide

↑

ASU · MAT 243 · Spring 2026

DISCRETE MATH STRUCTURES

The complete course — every concept, every formula, every proof technique — condensed into one galaxy-class reference.

✦ Navigation

01 Propositional Logic
02 Logical Equivalences
03 Predicates & Quantifiers
04 Rules of Inference
05 Proof Techniques
06 Sets
07 Functions
08 Sequences & Summation
09 Growth of Functions (Big-O)
10 Divisibility & Modular Arithmetic
11 Number Systems & Representations
12 Primes & GCD
13 Mathematical Induction
14 Structural Induction
15 Recurrence Relations
16 Combinatorics & Counting
17 Inclusion-Exclusion
18 Relations

01

Propositional Logic

Propositions

A proposition is a declarative sentence that is either true (T) or false (F), but not both. Questions, commands, and opinions are NOT propositions.

Examples

Proposition: "2 + 3 = 5" → T
Proposition: "The moon is made of cheese" → F
NOT a proposition: "What time is it?" / "Close the door."

Logical Operators (Connectives)

Name
Symbol
Read As
True When

Negation
¬p
"not p"
p is false

Conjunction
p ∧ q
"p and q"
both true

Disjunction
p ∨ q
"p or q"
at least one true

Exclusive Or
p ⊕ q
"p xor q"
exactly one true

Conditional
p → q
"if p then q"
¬p or q (false only when p=T, q=F)

Biconditional
p ↔ q
"p if and only if q"
both same truth value

The Conditional (p → q) — Most Tested!

p
q
p → q

T
T
T

T
F
F

F
T
T

F
F
T

Key Insight

p → q is only false when the hypothesis (p) is true and the conclusion (q) is false. A false hypothesis makes the whole conditional vacuously true.

Variations of Conditionals

Given the conditional p → q:

Name
Form
Equivalent To

Converse
q → p
NOT equivalent to p → q

Inverse
¬p → ¬q
equivalent to converse

Contrapositive
¬q → ¬p
equivalent to p → q

Remember

The contrapositive is always logically equivalent to the original. The converse and inverse are equivalent to each other but NOT to the original.

"Only If" Statements

"p only if q" means p → q (NOT q → p!).

Think of it as: p can be true ONLY IF q is also true. If q is false, p must be false.

Example

"You pass only if you study" = "If you pass, then you studied" = pass → studied

Tautologies, Contradictions & Contingencies

Definitions

Tautology: Always true for all truth value assignments.…

MAT 243 — Discrete Math Structures — The Complete Galaxy Guide

66,060 bytes · HTML source
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MAT 243 — Discrete Math Structures — The Complete Galaxy Guide</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Exo+2:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<style>
/* ═══════════════════════════════════════════════
   CSS RESET & VARIABLES
   ═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --space-void: #030014;
  --space-deep: #0a0525;
  --space-mid: #120a3a;
  --nebula-purple: #6b21a8;
  --nebula-blue: #1e40af;
  --nebula-pink: #db2777;
  --nebula-cyan: #06b6d4;
  --star-white: #f0f0ff;
  --star-gold: #fbbf24;
  --star-blue: #93c5fd;
  --comet-green: #34d399;
  --comet-orange: #fb923c;
  --text-bright: #e8e6f0;
  --text-dim: #a8a4c0;
  --text-faint: #6b6890;
  --glass-bg: rgba(15, 10, 40, 0.7);
  --glass-border: rgba(139, 92, 246, 0.25);
  --glass-glow: rgba(139, 92, 246, 0.1);
  --card-bg: rgba(20, 12, 50, 0.85);
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Exo 2', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--space-void);
  color: var(--text-bright);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   STARFIELD BACKGROUND
   ═══════════════════════════════════════════════ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(107, 33, 168, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(30, 64, 175, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(219, 39, 119, 0.08) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--dur) ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: var(--min-o); transform: scale(1); }
  100% { opacity: var(--max-o); transform: scale(1.3); }
}

@keyframes shootingStar {
  0% { transform: translateX(0) translateY(0); opacity: 1; }
  100% { transform: translateX(300px) translateY(300px); opacity: 0; }
}

/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */
.container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

/* ═══════════════════════════════════════════════
   HERO / HEADER
   ═══════════════════════════════════════════════ */
.hero {
  text-align: center;
  padding: 5rem 2rem 4rem;
  position: relative;
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--nebula-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.4rem 1.2rem;
  border-radius: 100px;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
  background: rgba(6, 182, 212, 0.05);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--star-white) 0%, var(--nebula-cyan) 40%, var(--nebula-purple) 70%, var(--nebula-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-dim);
  font-weight: 300;
  max-width: 600px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════
   TABLE OF CONTENTS
   ═══════════════════════════════════════════════ */
.toc {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  margin: 2rem 0 3rem;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.toc::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--nebula-cyan), var(--nebula-purple), var(--nebula-pink), transparent);
}

.toc h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--nebula-cyan);
  margin-bottom: 1.2rem;
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
}

.toc a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all 0.2s;
}

.toc a:hover {
  color: var(--star-white);
  background: rgba(139, 92, 246, 0.12);
}

.toc a .num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--nebula-purple);
  min-width: 24px;
}

/* ═══════════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════════ */
.section {
  margin-bottom: 3.5rem;
  scroll-margin-top: 2rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--glass-border);
}

.section-num {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--space-void);
  background: linear-gradient(135deg, var(--nebula-cyan), var(--nebula-purple));
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--star-white);
}

/* CARDS */
.card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 1.6rem 2rem;
  margin-bottom: 1.2rem;
  backdrop-filter: blur(15px);
  position: relative;
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--nebula-cyan), var(--nebula-purple));
  border-radius: 3px 0 0 3px;
}

.card h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--nebula-cyan);
  margin-bottom: 0.8rem;
}

.card h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--star-gold);
  margin: 1rem 0 0.4rem;
}

.card p, .card li {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.75;
}

.card ul, .card ol {
  padding-left: 1.2rem;
  margin: 0.5rem 0;
}

.card li { margin-bottom: 0.3rem; }

.card strong { color: var(--star-white); font-weight: 600; }

.card em { color: var(--nebula-cyan); font-style: normal; font-weight: 500; }

/* DEFINITION BOXES */
.def {
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 10px;
  padding: 1rem 1.3rem;
  margin: 0.8rem 0;
}

.def .label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--nebula-cyan);
  margin-bottom: 0.3rem;
}

/* EXAMPLE BOXES */
.ex {
  background: rgba(251, 191, 36, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 10px;
  padding: 1rem 1.3rem;
  margin: 0.8rem 0;
}

.ex .label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--star-gold);
  margin-bottom: 0.3rem;
}

/* WARNING / KEY IDEA BOXES */
.key {
  background: rgba(219, 39, 119, 0.06);
  border: 1px solid rgba(219, 39, 119, 0.2);
  border-radius: 10px;
  padding: 1rem 1.3rem;
  margin: 0.8rem 0;
}

.key .label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--nebula-pink);
  margin-bottom: 0.3rem;
}

/* FORMULA BLOCKS */
.formula {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 8px;
  padding: 0.8rem 1.2rem;
  margin: 0.6rem 0;
  color: var(--star-blue);
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.9;
}

/* TRUTH TABLES */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.88rem;
}

th {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--nebula-cyan);
  text-align: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 2px solid var(--glass-border);
  background: rgba(6, 182, 212, 0.06);
}

td {
  text-align: center;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.1);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

tr:hover td { background: rgba(139, 92, 246, 0.05); }

/* GRID LAYOUTS */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 700px) {
  .two-col { grid-template-columns: 1fr; }
  .toc-grid { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
  .card { padding: 1.2rem 1.4rem; }
}

/* INLINE CODE */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(139, 92, 246, 0.12);
  color: var(--star-blue);
  padding: 0.15em 0.45em;
  border-radius: 4px;
}

/* SEPARATOR */
.sep {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
  margin: 3rem 0;
}

/* BACK TO TOP */
.top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--nebula-purple), var(--nebula-cyan));
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 4px 20px rgba(107, 33, 168, 0.4);
}

.top-btn.show { opacity: 1; }

/* SEARCH */
.search-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.8rem 0;
  backdrop-filter: blur(20px);
  background: rgba(3, 0, 20, 0.6);
  margin-bottom: 1.5rem;
}

.search-wrap input {
  width: 100%;
  padding: 0.8rem 1.2rem 0.8rem 2.8rem;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:focus { border-color: var(--nebula-cyan); }

.search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 1.1rem;
  pointer-events: none;
}

/* PRINT */
@media print {
  body { background: white; color: #111; }
  body::before, #starfield, .search-wrap, .top-btn { display: none; }
  .card, .toc { border-color: #ccc; background: #fafafa; break-inside: avoid; }
  .card::after { background: #333; }
  .section-num { background: #333; color: white; }
  .card h3, .def .label, .key .label { color: #333; }
  .card h4 { color: #555; }
  .formula { background: #f0f0f0; color: #222; border-color: #ccc; }
  th { background: #eee; color: #222; }
  a { color: #333; }
  .hero h1 { background: none; -webkit-text-fill-color: #111; }
}
</style>
</head>
<body>

<!-- STARFIELD -->
<div id="starfield"></div>

<!-- BACK TO TOP -->
<button class="top-btn" id="topBtn" onclick="window.scrollTo({top:0})">↑</button>

<div class="container">

<!-- ═══════════════ HERO ═══════════════ -->
<header class="hero">
  <div class="hero-badge">ASU · MAT 243 · Spring 2026</div>
  <h1>DISCRETE MATH STRUCTURES</h1>
  <p class="subtitle">The complete course — every concept, every formula, every proof technique — condensed into one galaxy-class reference.</p>
</header>

<!-- ═══════════════ SEARCH ═══════════════ -->
<div class="search-wrap">
  <input type="text" id="search" placeholder="Search anything... (tautology, big-O, induction, sets...)" autocomplete="off">
</div>

<!-- ═══════════════ TABLE OF CONTENTS ═══════════════ -->
<nav class="toc" id="toc">
  <h2>✦ Navigation</h2>
  <div class="toc-grid">
    <a href="#s1"><span class="num">01</span> Propositional Logic</a>
    <a href="#s2"><span class="num">02</span> Logical Equivalences</a>
    <a href="#s3"><span class="num">03</span> Predicates & Quantifiers</a>
    <a href="#s4"><span class="num">04</span> Rules of Inference</a>
    <a href="#s5"><span class="num">05</span> Proof Techniques</a>
    <a href="#s6"><span class="num">06</span> Sets</a>
    <a href="#s7"><span class="num">07</span> Functions</a>
    <a href="#s8"><span class="num">08</span> Sequences & Summation</a>
    <a href="#s9"><span class="num">09</span> Growth of Functions (Big-O)</a>
    <a href="#s10"><span class="num">10</span> Divisibility & Modular Arithmetic</a>
    <a href="#s11"><span class="num">11</span> Number Systems & Representations</a>
    <a href="#s12"><span class="num">12</span> Primes & GCD</a>
    <a href="#s13"><span class="num">13</span> Mathematical Induction</a>
    <a href="#s14"><span class="num">14</span> Structural Induction</a>
    <a href="#s15"><span class="num">15</span> Recurrence Relations</a>
    <a href="#s16"><span class="num">16</span> Combinatorics & Counting</a>
    <a href="#s17"><span class="num">17</span> Inclusion-Exclusion</a>
    <a href="#s18"><span class="num">18</span> Relations</a>
  </div>
</nav>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 1: PROPOSITIONAL LOGIC
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s1">
  <div class="section-header">
    <div class="section-num">01</div>
    <h2>Propositional Logic</h2>
  </div>

  <div class="card">
    <h3>Propositions</h3>
    <p>A <strong>proposition</strong> is a declarative sentence that is either <em>true (T)</em> or <em>false (F)</em>, but not both. Questions, commands, and opinions are NOT propositions.</p>
    <div class="ex">
      <div class="label">Examples</div>
      <p><strong>Proposition:</strong> "2 + 3 = 5" → T<br>
      <strong>Proposition:</strong> "The moon is made of cheese" → F<br>
      <strong>NOT a proposition:</strong> "What time is it?" / "Close the door."</p>
    </div>
  </div>

  <div class="card">
    <h3>Logical Operators (Connectives)</h3>
    <table>
      <tr><th>Name</th><th>Symbol</th><th>Read As</th><th>True When</th></tr>
      <tr><td>Negation</td><td>¬p</td><td>"not p"</td><td>p is false</td></tr>
      <tr><td>Conjunction</td><td>p ∧ q</td><td>"p and q"</td><td>both true</td></tr>
      <tr><td>Disjunction</td><td>p ∨ q</td><td>"p or q"</td><td>at least one true</td></tr>
      <tr><td>Exclusive Or</td><td>p ⊕ q</td><td>"p xor q"</td><td>exactly one true</td></tr>
      <tr><td>Conditional</td><td>p → q</td><td>"if p then q"</td><td>¬p or q (false only when p=T, q=F)</td></tr>
      <tr><td>Biconditional</td><td>p ↔ q</td><td>"p if and only if q"</td><td>both same truth value</td></tr>
    </table>

    <h4>The Conditional (p → q) — Most Tested!</h4>
    <table>
      <tr><th>p</th><th>q</th><th>p → q</th></tr>
      <tr><td>T</td><td>T</td><td>T</td></tr>
      <tr><td>T</td><td>F</td><td><strong style="color:var(--nebula-pink)">F</strong></td></tr>
      <tr><td>F</td><td>T</td><td>T</td></tr>
      <tr><td>F</td><td>F</td><td>T</td></tr>
    </table>
    <div class="key">
      <div class="label">Key Insight</div>
      <p>p → q is only false when the hypothesis (p) is true and the conclusion (q) is false. A false hypothesis makes the whole conditional <strong>vacuously true</strong>.</p>
    </div>
  </div>

  <div class="card">
    <h3>Variations of Conditionals</h3>
    <p>Given the conditional <strong>p → q</strong>:</p>
    <table>
      <tr><th>Name</th><th>Form</th><th>Equivalent To</th></tr>
      <tr><td>Converse</td><td>q → p</td><td>NOT equivalent to p → q</td></tr>
      <tr><td>Inverse</td><td>¬p → ¬q</td><td>equivalent to converse</td></tr>
      <tr><td>Contrapositive</td><td>¬q → ¬p</td><td><strong>equivalent to p → q</strong></td></tr>
    </table>
    <div class="key">
      <div class="label">Remember</div>
      <p>The <strong>contrapositive</strong> is always logically equivalent to the original. The converse and inverse are equivalent to each other but NOT to the original.</p>
    </div>
  </div>

  <div class="card">
    <h3>"Only If" Statements</h3>
    <p><strong>"p only if q"</strong> means <em>p → q</em> (NOT q → p!).</p>
    <p>Think of it as: p can be true ONLY IF q is also true. If q is false, p must be false.</p>
    <div class="ex">
      <div class="label">Example</div>
      <p>"You pass only if you study" = "If you pass, then you studied" = pass → studied</p>
    </div>
  </div>

  <div class="card">
    <h3>Tautologies, Contradictions & Contingencies</h3>
    <div class="def">
      <div class="label">Definitions</div>
      <p><strong>Tautology:</strong> Always true for all truth value assignments. Example: p ∨ ¬p<br>
      <strong>Contradiction:</strong> Always false for all truth value assignments. Example: p ∧ ¬p<br>
      <strong>Contingency:</strong> Neither — sometimes true, sometimes false. Example: p ∨ q</p>
    </div>
    <div class="key">
      <div class="label">How to Check</div>
      <p>Build the full truth table. If the final column is ALL T → tautology. ALL F → contradiction. Mix → contingency.</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 2: LOGICAL EQUIVALENCES
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s2">
  <div class="section-header">
    <div class="section-num">02</div>
    <h2>Propositional Equivalences</h2>
  </div>

  <div class="card">
    <h3>Key Equivalence Laws</h3>
    <p>Two propositions are <strong>logically equivalent</strong> (p ≡ q) if they have the same truth table.</p>
    <table>
      <tr><th>Law</th><th>Equivalence</th></tr>
      <tr><td>Identity</td><td>p ∧ T ≡ p &nbsp;/&nbsp; p ∨ F ≡ p</td></tr>
      <tr><td>Domination</td><td>p ∨ T ≡ T &nbsp;/&nbsp; p ∧ F ≡ F</td></tr>
      <tr><td>Idempotent</td><td>p ∨ p ≡ p &nbsp;/&nbsp; p ∧ p ≡ p</td></tr>
      <tr><td>Double Negation</td><td>¬(¬p) ≡ p</td></tr>
      <tr><td>Commutative</td><td>p ∨ q ≡ q ∨ p &nbsp;/&nbsp; p ∧ q ≡ q ∧ p</td></tr>
      <tr><td>Associative</td><td>(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)</td></tr>
      <tr><td>Distributive</td><td>p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)</td></tr>
      <tr><td></td><td>p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)</td></tr>
      <tr><td>De Morgan's</td><td>¬(p ∧ q) ≡ ¬p ∨ ¬q</td></tr>
      <tr><td></td><td>¬(p ∨ q) ≡ ¬p ∧ ¬q</td></tr>
      <tr><td>Absorption</td><td>p ∨ (p ∧ q) ≡ p &nbsp;/&nbsp; p ∧ (p ∨ q) ≡ p</td></tr>
      <tr><td>Negation</td><td>p ∨ ¬p ≡ T &nbsp;/&nbsp; p ∧ ¬p ≡ F</td></tr>
    </table>
  </div>

  <div class="card">
    <h3>Conditional Equivalences</h3>
    <div class="formula">p → q  ≡  ¬p ∨ q
p → q  ≡  ¬q → ¬p          (contrapositive)
p ↔ q  ≡  (p → q) ∧ (q → p)
p ↔ q  ≡  (p ∧ q) ∨ (¬p ∧ ¬q)</div>
    <div class="key">
      <div class="label">Most Common Mistake</div>
      <p>Students confuse p → q with q → p (converse). The conditional is NOT symmetric! Use ¬p ∨ q as your go-to rewrite.</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 3: PREDICATES & QUANTIFIERS
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s3">
  <div class="section-header">
    <div class="section-num">03</div>
    <h2>Predicates & Quantifiers</h2>
  </div>

  <div class="card">
    <h3>Predicates</h3>
    <p>A <strong>predicate</strong> is a statement with variables that becomes a proposition when you plug in values.</p>
    <div class="ex">
      <div class="label">Example</div>
      <p>P(x) = "x > 5"<br>P(3) = "3 > 5" = F<br>P(7) = "7 > 5" = T</p>
    </div>
    <p>The <strong>domain</strong> (universe of discourse) is the set of all possible values the variable can take.</p>
  </div>

  <div class="card">
    <h3>Quantifiers</h3>
    <table>
      <tr><th>Symbol</th><th>Name</th><th>Meaning</th><th>True When</th></tr>
      <tr><td>∀x P(x)</td><td>Universal</td><td>"for all x, P(x)"</td><td>P(x) is true for EVERY x in domain</td></tr>
      <tr><td>∃x P(x)</td><td>Existential</td><td>"there exists x such that P(x)"</td><td>P(x) is true for AT LEAST ONE x</td></tr>
    </table>

    <h4>Negating Quantified Statements (De Morgan's for Quantifiers)</h4>
    <div class="formula">¬(∀x P(x))  ≡  ∃x ¬P(x)
¬(∃x P(x))  ≡  ∀x ¬P(x)</div>
    <div class="key">
      <div class="label">Flip & Negate Rule</div>
      <p>To negate: flip the quantifier (∀ ↔ ∃) and negate the predicate. Repeat for nested quantifiers from left to right.</p>
    </div>

    <h4>Nested Quantifiers — Order Matters!</h4>
    <div class="formula">∀x ∃y P(x,y)  means: for every x, there is SOME y (y can depend on x)
∃y ∀x P(x,y)  means: there is ONE y that works for ALL x (much stronger!)</div>
    <div class="ex">
      <div class="label">Example</div>
      <p>∀x ∃y (x + y = 0): "every number has an additive inverse" → TRUE<br>
      ∃y ∀x (x + y = 0): "there is one number that is the additive inverse of every number" → FALSE</p>
    </div>
  </div>

  <div class="card">
    <h3>Translating English to Logic</h3>
    <table>
      <tr><th>English</th><th>Logic</th></tr>
      <tr><td>"All dogs bark"</td><td>∀x (Dog(x) → Barks(x))</td></tr>
      <tr><td>"Some dogs bark"</td><td>∃x (Dog(x) ∧ Barks(x))</td></tr>
      <tr><td>"No dogs bark"</td><td>¬∃x (Dog(x) ∧ Barks(x)) ≡ ∀x (Dog(x) → ¬Barks(x))</td></tr>
    </table>
    <div class="key">
      <div class="label">Critical Pattern</div>
      <p>Universal (∀) pairs with → (conditional).<br>
      Existential (∃) pairs with ∧ (conjunction).<br>
      Mixing these up is one of the most common errors!</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 4: RULES OF INFERENCE
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s4">
  <div class="section-header">
    <div class="section-num">04</div>
    <h2>Rules of Inference</h2>
  </div>

  <div class="card">
    <h3>Propositional Rules of Inference</h3>
    <table>
      <tr><th>Rule</th><th>Form</th><th>In Words</th></tr>
      <tr><td>Modus Ponens</td><td>p → q, p ∴ q</td><td>If p then q; p is true; therefore q</td></tr>
      <tr><td>Modus Tollens</td><td>p → q, ¬q ∴ ¬p</td><td>If p then q; q is false; therefore ¬p</td></tr>
      <tr><td>Hypothetical Syllogism</td><td>p → q, q → r ∴ p → r</td><td>Chain two conditionals</td></tr>
      <tr><td>Disjunctive Syllogism</td><td>p ∨ q, ¬p ∴ q</td><td>One of two; not the first; therefore the second</td></tr>
      <tr><td>Addition</td><td>p ∴ p ∨ q</td><td>p is true so p OR anything is true</td></tr>
      <tr><td>Simplification</td><td>p ∧ q ∴ p</td><td>Both true means each is true</td></tr>
      <tr><td>Conjunction</td><td>p, q ∴ p ∧ q</td><td>Both true so the AND is true</td></tr>
      <tr><td>Resolution</td><td>p ∨ q, ¬p ∨ r ∴ q ∨ r</td><td>Resolve away complementary literals</td></tr>
    </table>
  </div>

  <div class="card">
    <h3>Quantified Rules of Inference</h3>
    <table>
      <tr><th>Rule</th><th>Form</th></tr>
      <tr><td>Universal Instantiation</td><td>∀x P(x) ∴ P(c) for any c</td></tr>
      <tr><td>Universal Generalization</td><td>P(c) for arbitrary c ∴ ∀x P(x)</td></tr>
      <tr><td>Existential Instantiation</td><td>∃x P(x) ∴ P(c) for some specific c</td></tr>
      <tr><td>Existential Generalization</td><td>P(c) ∴ ∃x P(x)</td></tr>
    </table>
    <div class="key">
      <div class="label">Watch Out</div>
      <p>For universal generalization, c must be truly <strong>arbitrary</strong> — no special assumptions about c! For existential instantiation, c is a <strong>specific</strong> (but unknown) element — you can't assume anything else about it.</p>
    </div>
  </div>

  <div class="card">
    <h3>Common Fallacies</h3>
    <table>
      <tr><th>Fallacy</th><th>Invalid Form</th><th>Why Wrong</th></tr>
      <tr><td>Affirming the Consequent</td><td>p → q, q ∴ p</td><td>q could be true for other reasons</td></tr>
      <tr><td>Denying the Antecedent</td><td>p → q, ¬p ∴ ¬q</td><td>q might still be true without p</td></tr>
    </table>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 5: PROOF TECHNIQUES
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s5">
  <div class="section-header">
    <div class="section-num">05</div>
    <h2>Proof Techniques</h2>
  </div>

  <div class="card">
    <h3>Proof Methods Overview</h3>

    <h4>1. Direct Proof (prove p → q)</h4>
    <p>Assume p is true. Use definitions, axioms, and known theorems to arrive at q.</p>
    <div class="ex">
      <div class="label">Example</div>
      <p><strong>Prove:</strong> If n is even, then n² is even.<br>
      <strong>Proof:</strong> Assume n is even, so n = 2k for some integer k.<br>
      Then n² = (2k)² = 4k² = 2(2k²).<br>
      Since 2k² is an integer, n² = 2(integer), so n² is even. ∎</p>
    </div>

    <h4>2. Proof by Contrapositive (prove ¬q → ¬p)</h4>
    <p>Instead of p → q, prove the equivalent contrapositive. Assume ¬q and show ¬p.</p>
    <div class="ex">
      <div class="label">Example</div>
      <p><strong>Prove:</strong> If n² is odd, then n is odd.<br>
      <strong>Contrapositive:</strong> If n is even, then n² is even. (Same as above!) ∎</p>
    </div>

    <h4>3. Proof by Contradiction</h4>
    <p>Assume the statement is FALSE (assume ¬S). Derive a contradiction (something impossible like p ∧ ¬p). Conclude S must be true.</p>
    <div class="ex">
      <div class="label">Example</div>
      <p><strong>Prove:</strong> √2 is irrational.<br>
      <strong>Proof:</strong> Assume √2 is rational, so √2 = a/b in lowest terms (gcd(a,b) = 1).<br>
      Then 2 = a²/b², so a² = 2b², meaning a² is even → a is even → a = 2k.<br>
      Then 4k² = 2b² → b² = 2k² → b is even.<br>
      Contradiction: both a and b are even, but we said gcd(a,b) = 1. ∎</p>
    </div>

    <h4>4. Proof by Cases (Exhaustive Proof)</h4>
    <p>Break into cases that cover all possibilities. Prove the result for each case.</p>

    <h4>5. Existence Proof</h4>
    <p><strong>Constructive:</strong> find/build a specific example.<br>
    <strong>Non-constructive:</strong> prove one must exist without finding it.</p>

    <h4>6. Counterexample (to disprove ∀x P(x))</h4>
    <p>Find ONE specific x where P(x) is false. That's it — done.</p>
  </div>

  <div class="card">
    <h3>Common Proof Writing Mistakes</h3>
    <ul>
      <li><strong>Assuming what you're trying to prove</strong> (circular reasoning)</li>
      <li><strong>Using specific examples</strong> instead of general/arbitrary elements for universal proofs</li>
      <li><strong>Confusing "for all" vs "there exists"</strong> — universal proofs need arbitrary elements; existence proofs need one witness</li>
      <li><strong>Not stating assumptions clearly</strong></li>
      <li><strong>Using ≡ when you mean =</strong> (≡ is logical equivalence, = is equality)</li>
      <li><strong>Skipping the "since __ is an integer"</strong> step when proving even/odd/divisibility</li>
    </ul>
  </div>

  <div class="card">
    <h3>Rational & Irrational Numbers</h3>
    <div class="def">
      <div class="label">Definition</div>
      <p><strong>Rational:</strong> a/b where a, b are integers and b ≠ 0.<br>
      <strong>Irrational:</strong> cannot be expressed as a/b (e.g., √2, π, e).</p>
    </div>
    <p><strong>Key facts:</strong> rational + rational = rational. irrational + rational = irrational. The product of a nonzero rational and an irrational is irrational. But irrational + irrational can be rational (e.g., √2 + (−√2) = 0).</p>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 6: SETS
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s6">
  <div class="section-header">
    <div class="section-num">06</div>
    <h2>Sets</h2>
  </div>

  <div class="card">
    <h3>Set Basics</h3>
    <div class="def">
      <div class="label">Definitions</div>
      <p>A <strong>set</strong> is an unordered collection of distinct objects (elements).<br>
      <strong>x ∈ A</strong> means x is in set A.<br>
      <strong>x ∉ A</strong> means x is not in A.<br>
      <strong>|A|</strong> = cardinality (number of elements in A).</p>
    </div>

    <h4>Important Sets</h4>
    <div class="formula">ℕ = {0, 1, 2, 3, ...}         Natural numbers (includes 0 in this course)
ℤ = {..., -2, -1, 0, 1, 2, ...}  Integers
ℤ⁺ = {1, 2, 3, ...}             Positive integers
ℚ = rationals                    a/b where a,b ∈ ℤ, b ≠ 0
ℝ = real numbers
∅ = {} = empty set               the set with no elements</div>

    <h4>Subsets</h4>
    <p><strong>A ⊆ B</strong> (A is a subset of B): every element of A is in B.<br>
    <strong>A ⊂ B</strong> (proper subset): A ⊆ B and A ≠ B.<br>
    Key facts: ∅ ⊆ A for any set A. A ⊆ A for any set A.</p>

    <h4>Power Set</h4>
    <p>P(A) = the set of ALL subsets of A, including ∅ and A itself.</p>
    <div class="formula">If |A| = n, then |P(A)| = 2ⁿ</div>
    <div class="ex">
      <div class="label">Example</div>
      <p>A = {1, 2}<br>P(A) = {∅, {1}, {2}, {1,2}}<br>|P(A)| = 2² = 4</p>
    </div>

    <h4>Cartesian Product</h4>
    <div class="formula">A × B = {(a, b) | a ∈ A and b ∈ B}
|A × B| = |A| · |B|</div>
  </div>

  <div class="card">
    <h3>Set Operations</h3>
    <table>
      <tr><th>Operation</th><th>Symbol</th><th>Definition</th></tr>
      <tr><td>Union</td><td>A ∪ B</td><td>{x | x ∈ A or x ∈ B}</td></tr>
      <tr><td>Intersection</td><td>A ∩ B</td><td>{x | x ∈ A and x ∈ B}</td></tr>
      <tr><td>Difference</td><td>A − B</td><td>{x | x ∈ A and x ∉ B}</td></tr>
      <tr><td>Complement</td><td>A̅ or Aᶜ</td><td>{x ∈ U | x ∉ A} (U = universal set)</td></tr>
      <tr><td>Symmetric Diff</td><td>A ⊕ B</td><td>(A − B) ∪ (B − A)</td></tr>
    </table>

    <h4>Set Identities (mirror logic laws!)</h4>
    <div class="formula">De Morgan's:  (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ     (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ
Distributive: A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
              A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)</div>

    <h4>The Empty Set — Tricky Behavior</h4>
    <div class="key">
      <div class="label">Watch Out</div>
      <p>∅ ∈ {∅} is TRUE (∅ is an element of the set containing ∅).<br>
      ∅ ⊆ {∅} is TRUE (∅ is a subset of everything).<br>
      {∅} ≠ ∅ — one has one element, the other has zero.</p>
    </div>
  </div>

  <div class="card">
    <h3>Intervals (Subsets of ℝ)</h3>
    <div class="formula">[a, b] = {x ∈ ℝ | a ≤ x ≤ b}     closed interval (includes endpoints)
(a, b) = {x ∈ ℝ | a < x < b}     open interval (excludes endpoints)
[a, b) = {x ∈ ℝ | a ≤ x < b}     half-open
(−∞, b] = {x ∈ ℝ | x ≤ b}        extends left forever
[a, ∞) = {x ∈ ℝ | x ≥ a}         extends right forever</div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 7: FUNCTIONS
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s7">
  <div class="section-header">
    <div class="section-num">07</div>
    <h2>Functions</h2>
  </div>

  <div class="card">
    <h3>Function Basics</h3>
    <div class="def">
      <div class="label">Definition</div>
      <p>A <strong>function</strong> f: A → B assigns to each element in A (domain) exactly one element in B (codomain).</p>
    </div>
    <p><strong>Range</strong> (image) = {f(a) | a ∈ A} ⊆ B — the actual outputs used.</p>

    <h4>Function Properties</h4>
    <table>
      <tr><th>Property</th><th>Definition</th><th>Intuition</th></tr>
      <tr><td><strong>Injective</strong> (one-to-one)</td><td>f(a) = f(b) → a = b</td><td>No two inputs share an output</td></tr>
      <tr><td><strong>Surjective</strong> (onto)</td><td>∀b ∈ B, ∃a ∈ A: f(a) = b</td><td>Every element in codomain is hit</td></tr>
      <tr><td><strong>Bijective</strong> (one-to-one AND onto)</td><td>Injective + Surjective</td><td>Perfect pairing; invertible</td></tr>
    </table>

    <h4>Function Composition</h4>
    <div class="formula">(f ∘ g)(x) = f(g(x))     Apply g first, then f!</div>

    <h4>Inverse Function</h4>
    <p>f⁻¹ exists only if f is bijective. Then f⁻¹(f(x)) = x and f(f⁻¹(y)) = y.</p>

    <h4>Floor & Ceiling</h4>
    <div class="formula">⌊x⌋ = floor(x) = greatest integer ≤ x     ⌊3.7⌋ = 3, ⌊−1.2⌋ = −2
⌈x⌉ = ceil(x) = smallest integer ≥ x      ⌈3.2⌉ = 4, ⌈−1.8⌉ = −1</div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 8: SEQUENCES & SUMMATION
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s8">
  <div class="section-header">
    <div class="section-num">08</div>
    <h2>Sequences & Summation</h2>
  </div>

  <div class="card">
    <h3>Sequences</h3>
    <p>A <strong>sequence</strong> is an ordered list of elements: a₁, a₂, a₃, ... Each aₙ is a <strong>term</strong>.</p>

    <h4>Common Sequences</h4>
    <div class="formula">Arithmetic: aₙ = a₁ + (n−1)d          (constant difference d)
Geometric:  aₙ = a₁ · rⁿ⁻¹            (constant ratio r)
Fibonacci:  f₁ = 1, f₂ = 1, fₙ = fₙ₋₁ + fₙ₋₂</div>
  </div>

  <div class="card">
    <h3>Summation Formulas</h3>
    <div class="formula">Sum of first n positive integers:
  1 + 2 + 3 + ... + n = n(n+1)/2

Sum of first n squares:
  1² + 2² + ... + n² = n(n+1)(2n+1)/6

Sum of first n cubes:
  1³ + 2³ + ... + n³ = [n(n+1)/2]²

Geometric series:
  a + ar + ar² + ... + arⁿ = a(rⁿ⁺¹ − 1)/(r − 1)    when r ≠ 1

Infinite geometric (|r| < 1):
  a + ar + ar² + ... = a/(1 − r)</div>

    <h4>Useful Summation Properties</h4>
    <div class="formula">Σ(aᵢ + bᵢ) = Σaᵢ + Σbᵢ
Σ(c · aᵢ) = c · Σaᵢ
Σ(i=1 to n) c = cn</div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 9: GROWTH OF FUNCTIONS (BIG-O)
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s9">
  <div class="section-header">
    <div class="section-num">09</div>
    <h2>Growth of Functions (Big-O)</h2>
  </div>

  <div class="card">
    <h3>Asymptotic Notation</h3>

    <div class="def">
      <div class="label">Big-O (Upper Bound)</div>
      <p>f(x) is O(g(x)) if there exist constants C > 0 and k such that |f(x)| ≤ C|g(x)| for all x > k.<br>
      Think: f grows <strong>no faster than</strong> g.</p>
    </div>

    <div class="def">
      <div class="label">Big-Ω (Lower Bound)</div>
      <p>f(x) is Ω(g(x)) if there exist constants C > 0 and k such that |f(x)| ≥ C|g(x)| for all x > k.<br>
      Think: f grows <strong>at least as fast as</strong> g.</p>
    </div>

    <div class="def">
      <div class="label">Big-Θ (Tight Bound)</div>
      <p>f(x) is Θ(g(x)) if f(x) is both O(g(x)) and Ω(g(x)).<br>
      Think: f grows <strong>at the same rate as</strong> g.</p>
    </div>

    <h4>Growth Rate Hierarchy (slowest to fastest)</h4>
    <div class="formula">1 ≺ log n ≺ √n ≺ n ≺ n log n ≺ n² ≺ n³ ≺ 2ⁿ ≺ n! ≺ nⁿ</div>

    <div class="key">
      <div class="label">Why Base Doesn't Matter for Log</div>
      <p>log_a(n) = log_b(n) / log_b(a), so any two log bases differ by a constant factor. Since Big-O ignores constants, <strong>all logarithmic bases are the same in Big-O</strong>.</p>
    </div>

    <h4>Quick Rules</h4>
    <ul>
      <li>Polynomial: aₙxⁿ + ... + a₁x + a₀ is O(xⁿ) — highest power dominates</li>
      <li>Sum rule: f₁ is O(g₁) and f₂ is O(g₂) → f₁ + f₂ is O(max(g₁, g₂))</li>
      <li>Product rule: f₁ is O(g₁) and f₂ is O(g₂) → f₁·f₂ is O(g₁·g₂)</li>
    </ul>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 10: DIVISIBILITY & MODULAR ARITHMETIC
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s10">
  <div class="section-header">
    <div class="section-num">10</div>
    <h2>Divisibility & Modular Arithmetic</h2>
  </div>

  <div class="card">
    <h3>Divisibility</h3>
    <div class="def">
      <div class="label">Definition</div>
      <p>a | b ("a divides b") means b = a·k for some integer k. Equivalently, b/a is an integer.</p>
    </div>

    <h4>Properties</h4>
    <div class="formula">If a | b and a | c, then a | (b + c) and a | (b − c)
If a | b, then a | (b·c) for any integer c
If a | b and b | c, then a | c (transitivity)</div>
  </div>

  <div class="card">
    <h3>Division Algorithm</h3>
    <div class="formula">For any integer a and positive integer d:
  a = d·q + r    where 0 ≤ r < d

  q = ⌊a/d⌋ (quotient)
  r = a mod d = a − d·⌊a/d⌋ (remainder)</div>
  </div>

  <div class="card">
    <h3>Modular Arithmetic</h3>
    <div class="def">
      <div class="label">Congruence</div>
      <p>a ≡ b (mod m) means m | (a − b), i.e., a and b have the same remainder when divided by m.</p>
    </div>
    <div class="formula">If a ≡ b (mod m) and c ≡ d (mod m), then:
  a + c ≡ b + d (mod m)
  a · c ≡ b · d (mod m)</div>
    <div class="ex">
      <div class="label">Example</div>
      <p>17 ≡ 5 (mod 6) because 17 − 5 = 12 and 6 | 12.<br>
      Or: 17 mod 6 = 5 and 5 mod 6 = 5. Same remainder!</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 11: NUMBER SYSTEMS
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s11">
  <div class="section-header">
    <div class="section-num">11</div>
    <h2>Number Systems & Integer Representations</h2>
  </div>

  <div class="card">
    <h3>Base Conversions</h3>

    <h4>Decimal to Binary</h4>
    <p>Repeatedly divide by 2 and collect remainders (read bottom to top).</p>
    <div class="ex">
      <div class="label">Example: 42 to Binary</div>
      <p>42 ÷ 2 = 21 r <strong>0</strong><br>
      21 ÷ 2 = 10 r <strong>1</strong><br>
      10 ÷ 2 = 5 r <strong>0</strong><br>
      5 ÷ 2 = 2 r <strong>1</strong><br>
      2 ÷ 2 = 1 r <strong>0</strong><br>
      1 ÷ 2 = 0 r <strong>1</strong><br>
      Read up: 42₁₀ = <strong>101010</strong>₂</p>
    </div>

    <h4>Binary to Decimal</h4>
    <div class="formula">101010₂ = 1·2⁵ + 0·2⁴ + 1·2³ + 0·2² + 1·2¹ + 0·2⁰
       = 32 + 0 + 8 + 0 + 2 + 0 = 42</div>

    <h4>Hexadecimal (Base 16)</h4>
    <div class="formula">Digits: 0-9, A=10, B=11, C=12, D=13, E=14, F=15
Hex ↔ Binary: each hex digit = 4 binary digits
  Example: 2A₁₆ = 0010 1010₂ = 42₁₀</div>

    <h4>Binary Arithmetic</h4>
    <div class="formula">Addition:  0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry the 1)
Subtraction: Borrow from next column (just like decimal)
Multiplication: Shift and add (same as long multiplication)</div>
  </div>

  <div class="card">
    <h3>Two's Complement (Signed Integers)</h3>
    <p>For n-bit numbers, the leftmost bit is the sign (0 = positive, 1 = negative).</p>
    <div class="formula">Range of n-bit two's complement: −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1
To negate: flip all bits and add 1
Example (8-bit): +5 = 00000101 → flip = 11111010 → +1 = 11111011 = −5</div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 12: PRIMES & GCD
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s12">
  <div class="section-header">
    <div class="section-num">12</div>
    <h2>Primes & GCD</h2>
  </div>

  <div class="card">
    <h3>Prime Numbers</h3>
    <div class="def">
      <div class="label">Definition</div>
      <p>An integer p > 1 is <strong>prime</strong> if its only positive divisors are 1 and p. Otherwise it's <strong>composite</strong>. Note: 1 is neither prime nor composite.</p>
    </div>

    <h4>Fundamental Theorem of Arithmetic</h4>
    <p>Every integer > 1 can be written as a product of primes in <strong>exactly one way</strong> (up to ordering).</p>
    <div class="ex">
      <div class="label">Example</div>
      <p>360 = 2³ · 3² · 5</p>
    </div>

    <h4>Testing Primality</h4>
    <p>To check if n is prime, test divisibility by all primes up to √n. If none divide n, it's prime.</p>
  </div>

  <div class="card">
    <h3>GCD & LCM</h3>
    <div class="formula">gcd(a, b) = greatest common divisor (largest integer dividing both)
lcm(a, b) = least common multiple (smallest positive multiple of both)

Key relationship: gcd(a, b) · lcm(a, b) = a · b</div>

    <h4>Euclidean Algorithm (Finding GCD)</h4>
    <p>Repeatedly apply: gcd(a, b) = gcd(b, a mod b) until remainder = 0.</p>
    <div class="ex">
      <div class="label">Example: gcd(252, 105)</div>
      <p>gcd(252, 105) = gcd(105, 252 mod 105) = gcd(105, 42)<br>
      gcd(105, 42) = gcd(42, 105 mod 42) = gcd(42, 21)<br>
      gcd(42, 21) = gcd(21, 42 mod 21) = gcd(21, 0)<br>
      <strong>gcd = 21</strong></p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 13: MATHEMATICAL INDUCTION
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s13">
  <div class="section-header">
    <div class="section-num">13</div>
    <h2>Mathematical Induction</h2>
  </div>

  <div class="card">
    <h3>The Principle of Induction</h3>
    <p>To prove P(n) is true for all integers n ≥ b:</p>

    <h4>Step 1: Base Case</h4>
    <p>Show P(b) is true (usually b = 0 or b = 1).</p>

    <h4>Step 2: Inductive Step</h4>
    <p>Assume P(k) is true for some arbitrary k ≥ b (<strong>inductive hypothesis</strong>). Then prove P(k+1) is true.</p>

    <div class="key">
      <div class="label">Why It Works</div>
      <p>Think dominoes: base case knocks over the first. Inductive step says "if any domino falls, the next one falls too." Together → all dominoes fall.</p>
    </div>

    <div class="ex">
      <div class="label">Example: Prove 1 + 2 + ... + n = n(n+1)/2</div>
      <p><strong>Base case (n=1):</strong> LHS = 1. RHS = 1(2)/2 = 1. ✓<br><br>
      <strong>Inductive step:</strong> Assume 1 + 2 + ... + k = k(k+1)/2 (inductive hypothesis).<br>
      Show: 1 + 2 + ... + k + (k+1) = (k+1)(k+2)/2.<br><br>
      LHS = [1 + 2 + ... + k] + (k+1)<br>
      &nbsp;&nbsp;&nbsp;&nbsp;= k(k+1)/2 + (k+1)  &nbsp;&nbsp;← used IH here!<br>
      &nbsp;&nbsp;&nbsp;&nbsp;= k(k+1)/2 + 2(k+1)/2<br>
      &nbsp;&nbsp;&nbsp;&nbsp;= (k+1)(k+2)/2 = RHS ✓ ∎</p>
    </div>
  </div>

  <div class="card">
    <h3>Strong Induction</h3>
    <p>Same as regular induction, but the inductive hypothesis assumes P(b), P(b+1), ..., P(k) are ALL true (not just P(k)). Then prove P(k+1).</p>
    <p>Use strong induction when P(k+1) depends on multiple previous cases (not just P(k)).</p>
  </div>

  <div class="card">
    <h3>Common Mistakes in Induction Proofs</h3>
    <ul>
      <li><strong>Forgetting the base case.</strong> The inductive step alone proves nothing!</li>
      <li><strong>Not clearly using the inductive hypothesis.</strong> You must identify WHERE you use the assumption.</li>
      <li><strong>Using P(k+1) in the proof of P(k+1).</strong> That's circular — you assume P(k), not P(k+1).</li>
      <li><strong>Wrong base case.</strong> Make sure n = b actually works.</li>
      <li><strong>Incorrect algebra.</strong> Check every step. The inductive step is where most errors hide.</li>
    </ul>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 14: STRUCTURAL INDUCTION
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s14">
  <div class="section-header">
    <div class="section-num">14</div>
    <h2>Structural Induction</h2>
  </div>

  <div class="card">
    <h3>Recursively Defined Structures</h3>
    <p>Some structures (strings, trees, formulas) are defined recursively with base elements and rules for building bigger structures from smaller ones.</p>

    <h4>How Structural Induction Works</h4>
    <p><strong>Base step:</strong> Prove the property for the base elements.<br>
    <strong>Recursive step:</strong> Assume the property holds for the smaller sub-structures, then prove it holds for the structure built from them.</p>

    <div class="ex">
      <div class="label">Example: Binary Trees</div>
      <p><strong>Recursive definition:</strong><br>
      Base: A single node is a binary tree.<br>
      Recursive: If T₁ and T₂ are binary trees, then connecting them to a new root gives a binary tree.<br><br>
      <strong>Prove: A binary tree with n internal nodes has n+1 leaves.</strong><br>
      Base: 0 internal nodes → 1 leaf (just the root). 0 + 1 = 1. ✓<br>
      Recursive step: Assume true for T₁ (k₁ internal, k₁+1 leaves) and T₂ (k₂ internal, k₂+1 leaves).<br>
      Combined tree: (k₁ + k₂ + 1) internal nodes and (k₁+1) + (k₂+1) = k₁ + k₂ + 2 = (k₁+k₂+1) + 1 leaves. ✓ ∎</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 15: RECURRENCE RELATIONS
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s15">
  <div class="section-header">
    <div class="section-num">15</div>
    <h2>Recurrence Relations</h2>
  </div>

  <div class="card">
    <h3>What's a Recurrence?</h3>
    <p>An equation defining aₙ in terms of previous terms. Plus initial conditions.</p>
    <div class="ex">
      <div class="label">Example</div>
      <p>aₙ = 2aₙ₋₁ + 1, with a₀ = 0<br>
      a₁ = 2(0)+1 = 1, a₂ = 2(1)+1 = 3, a₃ = 2(3)+1 = 7, ...</p>
    </div>
  </div>

  <div class="card">
    <h3>Solving Linear Recurrences</h3>
    <h4>Homogeneous (aₙ = c₁aₙ₋₁ + c₂aₙ₋₂)</h4>
    <p><strong>Step 1:</strong> Write the characteristic equation: r² − c₁r − c₂ = 0<br>
    <strong>Step 2:</strong> Find the roots r₁, r₂.<br>
    <strong>Step 3:</strong> General solution depends on the roots:</p>
    <div class="formula">Distinct roots r₁ ≠ r₂:    aₙ = A·r₁ⁿ + B·r₂ⁿ
Repeated root r₁ = r₂ = r:  aₙ = A·rⁿ + B·n·rⁿ</div>
    <p><strong>Step 4:</strong> Use initial conditions to solve for A and B.</p>

    <div class="ex">
      <div class="label">Example: Fibonacci</div>
      <p>fₙ = fₙ₋₁ + fₙ₋₂, f₀ = 0, f₁ = 1<br>
      Characteristic eq: r² − r − 1 = 0<br>
      Roots: r = (1 ± √5)/2 → φ = (1+√5)/2 and ψ = (1−√5)/2<br>
      Solution: fₙ = (φⁿ − ψⁿ)/√5</p>
    </div>

    <h4>Complex Roots</h4>
    <p>If the characteristic equation has complex roots a ± bi, convert to polar form r·e^(iθ) and the solution involves rⁿcos(nθ) and rⁿsin(nθ) terms.</p>

    <div class="key">
      <div class="label">Complex → Real Connection</div>
      <p>Complex numbers a + bi where i² = −1. A complex expression produces a real number when imaginary parts cancel. This happens with conjugate pairs (a+bi)(a−bi) = a² + b².</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 16: COMBINATORICS & COUNTING
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s16">
  <div class="section-header">
    <div class="section-num">16</div>
    <h2>Combinatorics & Counting</h2>
  </div>

  <div class="card">
    <h3>Fundamental Counting Principles</h3>

    <h4>Product Rule</h4>
    <p>If task 1 can be done m ways and task 2 can be done n ways, both tasks together can be done <strong>m × n</strong> ways.</p>

    <h4>Sum Rule</h4>
    <p>If task 1 can be done m ways OR task 2 can be done n ways (mutually exclusive), the total is <strong>m + n</strong> ways.</p>
  </div>

  <div class="card">
    <h3>Permutations & Combinations</h3>

    <h4>Permutations (order matters)</h4>
    <div class="formula">P(n, r) = n! / (n − r)!

Choosing r items from n items where ORDER MATTERS
Example: How many 3-letter "words" from {A,B,C,D,E}?
P(5, 3) = 5! / 2! = 60</div>

    <h4>Combinations (order doesn't matter)</h4>
    <div class="formula">C(n, r) = n! / (r! · (n − r)!)    also written as "n choose r"

Choosing r items from n where ORDER DOESN'T MATTER
Example: How many 3-person committees from 5 people?
C(5, 3) = 5! / (3! · 2!) = 10</div>

    <div class="key">
      <div class="label">When to Use Which</div>
      <p><strong>Permutation:</strong> "arrange", "order", "rank", "sequence", "password", "lineup"<br>
      <strong>Combination:</strong> "choose", "select", "committee", "group", "team", "hand"</p>
    </div>

    <h4>Key Identities</h4>
    <div class="formula">C(n, 0) = C(n, n) = 1
C(n, 1) = n
C(n, r) = C(n, n−r)          symmetry
C(n, r) = C(n−1, r−1) + C(n−1, r)    Pascal's identity</div>
  </div>

  <div class="card">
    <h3>Binomial Theorem</h3>
    <div class="formula">(x + y)ⁿ = Σ(k=0 to n) C(n,k) · xⁿ⁻ᵏ · yᵏ</div>
    <div class="ex">
      <div class="label">Example</div>
      <p>(x+y)³ = C(3,0)x³ + C(3,1)x²y + C(3,2)xy² + C(3,3)y³<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= x³ + 3x²y + 3xy² + y³</p>
    </div>
  </div>

  <div class="card">
    <h3>Counting Operations in Algorithms</h3>
    <p>Count operations (comparisons, additions, multiplications) by analyzing loops:</p>
    <div class="formula">Single loop (1 to n):         n operations → O(n)
Nested loops (1 to n, 1 to n): n² operations → O(n²)
Loop (1 to n, 1 to i):         n(n+1)/2 → O(n²)
Halving loop (while n > 1, n = n/2): log₂n → O(log n)</div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 17: INCLUSION-EXCLUSION
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s17">
  <div class="section-header">
    <div class="section-num">17</div>
    <h2>Inclusion-Exclusion Principle</h2>
  </div>

  <div class="card">
    <h3>The Principle</h3>
    <p>When counting elements in a union, you have to correct for over-counting the overlaps.</p>
    <div class="formula">|A ∪ B| = |A| + |B| − |A ∩ B|

|A ∪ B ∪ C| = |A| + |B| + |C|
               − |A ∩ B| − |A ∩ C| − |B ∩ C|
               + |A ∩ B ∩ C|</div>
    <div class="key">
      <div class="label">Pattern</div>
      <p>Add singles, subtract pairs, add triples, subtract quadruples, ... Alternating signs!</p>
    </div>

    <div class="ex">
      <div class="label">Example</div>
      <p>In a class of 40: 25 take math, 20 take CS, 10 take both.<br>
      How many take math OR CS?<br>
      |M ∪ C| = 25 + 20 − 10 = 35</p>
    </div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     SECTION 18: RELATIONS
     ═══════════════════════════════════════════════════════════════ -->
<section class="section" id="s18">
  <div class="section-header">
    <div class="section-num">18</div>
    <h2>Relations</h2>
  </div>

  <div class="card">
    <h3>What is a Relation?</h3>
    <div class="def">
      <div class="label">Definition</div>
      <p>A <strong>relation R</strong> from set A to set B is a subset of A × B. If (a, b) ∈ R, we write aRb. A relation on a set A means R ⊆ A × A.</p>
    </div>
  </div>

  <div class="card">
    <h3>Properties of Relations (on a set A)</h3>
    <table>
      <tr><th>Property</th><th>Definition</th><th>Matrix Check</th></tr>
      <tr><td><strong>Reflexive</strong></td><td>∀a ∈ A: aRa</td><td>All 1s on diagonal</td></tr>
      <tr><td><strong>Irreflexive</strong></td><td>∀a ∈ A: ¬(aRa)</td><td>All 0s on diagonal</td></tr>
      <tr><td><strong>Symmetric</strong></td><td>aRb → bRa</td><td>Matrix equals its transpose</td></tr>
      <tr><td><strong>Antisymmetric</strong></td><td>aRb ∧ bRa → a = b</td><td>If M[i][j]=1 and i≠j, then M[j][i]=0</td></tr>
      <tr><td><strong>Transitive</strong></td><td>aRb ∧ bRc → aRc</td><td>M² has no 1 where M has 0</td></tr>
    </table>

    <div class="key">
      <div class="label">Important Combinations</div>
      <p><strong>Equivalence relation:</strong> reflexive + symmetric + transitive (partitions a set into classes)<br>
      <strong>Partial order:</strong> reflexive + antisymmetric + transitive (like ≤ on numbers)</p>
    </div>

    <div class="ex">
      <div class="label">Examples</div>
      <p><strong>=</strong> on ℤ: reflexive ✓, symmetric ✓, transitive ✓ → equivalence relation<br>
      <strong>≤</strong> on ℤ: reflexive ✓, antisymmetric ✓, transitive ✓ → partial order<br>
      <strong>&lt;</strong> on ℤ: irreflexive, antisymmetric, transitive (strict partial order)</p>
    </div>
  </div>

  <div class="card">
    <h3>Composition of Relations</h3>
    <div class="def">
      <div class="label">Definition</div>
      <p>If R is from A to B and S is from B to C, then <strong>S ∘ R</strong> is from A to C where:<br>
      (a, c) ∈ S ∘ R if there exists b ∈ B such that (a, b) ∈ R and (b, c) ∈ S.</p>
    </div>
    <p>In matrix terms: multiply the relation matrices (using Boolean AND for multiplication and OR for addition).</p>

    <h4>Powers of Relations</h4>
    <div class="formula">R¹ = R
R² = R ∘ R     (apply R twice)
Rⁿ = R ∘ Rⁿ⁻¹</div>
    <p>A relation R is transitive if and only if Rⁿ ⊆ R for all n ≥ 1.</p>
  </div>

  <div class="card">
    <h3>Representing Relations</h3>
    <h4>As a Matrix</h4>
    <p>M[i][j] = 1 if (aᵢ, aⱼ) ∈ R, else 0.</p>

    <h4>As a Directed Graph (Digraph)</h4>
    <p>Nodes = elements, arrow from a to b if aRb. Self-loops for reflexive pairs.</p>

    <h4>Closures</h4>
    <div class="formula">Reflexive closure: add all (a,a) pairs (add self-loops)
Symmetric closure: if aRb, add bRa (add reverse arrows)
Transitive closure: add all paths — if aRb and bRc, add aRc
  Transitive closure = R ∪ R² ∪ R³ ∪ ... (Warshall's algorithm)</div>
  </div>
</section>

<!-- ═══════════════════════════════════════════════════════════════
     FINAL QUICK REFERENCE
     ═══════════════════════════════════════════════════════════════ -->
<div class="sep"></div>

<section class="section" id="quickref">
  <div class="section-header">
    <div class="section-num">★</div>
    <h2>Quick Reference — Must-Know Facts</h2>
  </div>

  <div class="card">
    <h3>Formulas to Memorize</h3>
    <div class="formula">Summation:       1+2+...+n = n(n+1)/2
Geometric sum:   1+r+r²+...+rⁿ = (rⁿ⁺¹−1)/(r−1)
Power set size:  |P(A)| = 2ⁿ
Cartesian:       |A×B| = |A|·|B|
Permutations:    P(n,r) = n!/(n−r)!
Combinations:    C(n,r) = n!/(r!(n−r)!)
Binomial:        (x+y)ⁿ = Σ C(n,k)·xⁿ⁻ᵏ·yᵏ
Inc-Exc (2 sets): |A∪B| = |A|+|B|−|A∩B|
GCD·LCM = a·b
Contrapositive:  p→q ≡ ¬q→¬p
Conditional:     p→q ≡ ¬p∨q
De Morgan's:     ¬(p∧q) ≡ ¬p∨¬q,  ¬(p∨q) ≡ ¬p∧¬q
Quantifier neg:  ¬∀x = ∃x¬,  ¬∃x = ∀x¬</div>
  </div>

  <div class="card">
    <h3>Proof Strategy Cheat Sheet</h3>
    <table>
      <tr><th>Proving...</th><th>Try This Method</th></tr>
      <tr><td>p → q</td><td>Direct proof, contrapositive, or contradiction</td></tr>
      <tr><td>p ↔ q</td><td>Prove p→q AND q→p separately</td></tr>
      <tr><td>∀n ≥ b, P(n)</td><td>Mathematical induction</td></tr>
      <tr><td>∃x P(x)</td><td>Find a specific example (constructive)</td></tr>
      <tr><td>¬∀x P(x)</td><td>Find one counterexample</td></tr>
      <tr><td>Something is irrational</td><td>Proof by contradiction</td></tr>
      <tr><td>A ⊆ B</td><td>Let x ∈ A, show x ∈ B</td></tr>
      <tr><td>A = B</td><td>Show A ⊆ B AND B ⊆ A</td></tr>
      <tr><td>f is injective</td><td>Assume f(a)=f(b), show a=b</td></tr>
      <tr><td>f is surjective</td><td>Let y ∈ codomain, find x where f(x)=y</td></tr>
    </table>
  </div>
</section>

<footer style="text-align:center; padding:3rem 0 2rem; color:var(--text-faint); font-size:0.8rem;">
  <p style="font-family:var(--font-display); letter-spacing:2px; margin-bottom:0.5rem;">MAT 243 · ASU · SPRING 2026</p>
  <p>Built for the grind. You got this. ∎</p>
</footer>

</div><!-- /container -->

<!-- ═══════════════════════════════════════════════════════════════
     JAVASCRIPT
     ═══════════════════════════════════════════════════════════════ -->
<script>
// STARFIELD
(function() {
  const sf = document.getElementById('starfield');
  const count = 200;
  for (let i = 0; i < count; i++) {
    const star = document.createElement('div');
    star.className = 'star';
    const size = Math.random() * 2.5 + 0.5;
    star.style.cssText = `
      width: ${size}px;
      height: ${size}px;
      left: ${Math.random() * 100}%;
      top: ${Math.random() * 100}%;
      --dur: ${Math.random() * 3 + 2}s;
      --min-o: ${Math.random() * 0.3 + 0.1};
      --max-o: ${Math.random() * 0.5 + 0.5};
      animation-delay: ${Math.random() * 5}s;
    `;
    if (size > 2) {
      star.style.boxShadow = `0 0 ${size * 2}px rgba(200,200,255,0.3)`;
    }
    sf.appendChild(star);
  }
})();

// BACK TO TOP BUTTON
const topBtn = document.getElementById('topBtn');
window.addEventListener('scroll', () => {
  topBtn.classList.toggle('show', window.scrollY > 600);
});

// SEARCH FILTER
const searchInput = document.getElementById('search');
searchInput.addEventListener('input', function() {
  const term = this.value.toLowerCase().trim();
  const sections = document.querySelectorAll('.section');
  const toc = document.getElementById('toc');

  if (!term) {
    sections.forEach(s => s.style.display = '');
    toc.style.display = '';
    return;
  }

  toc.style.display = 'none';
  sections.forEach(s => {
    const text = s.textContent.toLowerCase();
    s.style.display = text.includes(term) ? '' : 'none';
  });
});
</script>
</body>
</html>