{
  "index": "1974-A-3",
  "type": "NT",
  "tag": [
    "NT",
    "ALG"
  ],
  "difficulty": "",
  "question": "A-3. A well-known theorem asserts that a prime \\( p>2 \\) can be written as the sum of two perfect squares ( \\( p=m^{2}+n^{2} \\), with \\( m \\) and \\( n \\) integers) if and only if \\( p \\equiv 1(\\bmod 4) \\). Assuming this result, find which primes \\( p>2 \\) can be written in each of the following forms, using (not necessarily positive) integers \\( \\boldsymbol{x} \\) and \\( y \\) :\n(a) \\( x^{2}+16 y^{2} \\);\n(b) \\( 4 x^{2}+4 x y+5 y^{2} \\).",
  "solution": "A-3.\nIf \\( p \\equiv 1(\\bmod 4) \\), either \\( (A): p \\equiv 1(\\bmod 8) \\) or \\( (B): p \\equiv 5(\\bmod 8) \\). We show that \\( (A) \\) and \\( (B) \\) are necessary and sufficient for (a) and (b), respectively. If \\( p=m^{2}+n^{2} \\) and \\( p \\) is odd, one can let \\( m \\) be odd and \\( n \\) be even. Then \\( p=m^{2}+4 v^{2} \\) with \\( m^{2} \\equiv 1(\\bmod 8) \\). With \\( (A), v \\) is even and \\( p=m^{2}+16 w^{2} \\). Conversely, \\( p=m^{2}+16 w^{2} \\) implies \\( p \\equiv m^{2} \\equiv 1(\\bmod 8) \\). With (B), \\( v \\) is odd, \\( m=2 u+v \\) for some integer \\( u \\), and \\( p=(2 u+v)^{2}+4 v^{2}=4 u^{2}+4 u v+5 v^{2} \\). Conversely, \\( p=4 u^{2}+4 u v+5 v^{2} \\) with \\( p \\) odd implies \\( p=(2 u+v)^{2}+4 v^{2} \\) with \\( v \\) odd and hence \\( p \\equiv 5(\\bmod 8) \\).",
  "vars": [
    "x",
    "y"
  ],
  "params": [
    "p",
    "m",
    "n",
    "v",
    "w",
    "u",
    "A",
    "B"
  ],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "x": "unknownx",
        "y": "variabley",
        "p": "primeval",
        "m": "integerm",
        "n": "integern",
        "v": "numberv",
        "w": "numberw",
        "u": "numberu",
        "A": "caseone",
        "B": "casetwo"
      },
      "question": "A-3. A well-known theorem asserts that a prime \\( primeval>2 \\) can be written as the sum of two perfect squares ( \\( primeval=integerm^{2}+integern^{2} \\), with \\( integerm \\) and \\( integern \\) integers) if and only if \\( primeval \\equiv 1(\\bmod 4) \\). Assuming this result, find which primes \\( primeval>2 \\) can be written in each of the following forms, using (not necessarily positive) integers \\( \\boldsymbol{unknownx} \\) and \\( variabley \\) :\n(a) \\( unknownx^{2}+16\\,variabley^{2} \\);\n(b) \\( 4\\,unknownx^{2}+4\\,unknownx\\,variabley+5\\,variabley^{2} \\).",
      "solution": "A-3.\nIf \\( primeval \\equiv 1(\\bmod 4) \\), either \\( (caseone): primeval \\equiv 1(\\bmod 8) \\) or \\( (casetwo): primeval \\equiv 5(\\bmod 8) \\). We show that \\( (caseone) \\) and \\( (casetwo) \\) are necessary and sufficient for (a) and (b), respectively. If \\( primeval=integerm^{2}+integern^{2} \\) and \\( primeval \\) is odd, one can let \\( integerm \\) be odd and \\( integern \\) be even. Then \\( primeval=integerm^{2}+4\\,numberv^{2} \\) with \\( integerm^{2} \\equiv 1(\\bmod 8) \\). With \\( (caseone), numberv \\) is even and \\( primeval=integerm^{2}+16\\,numberw^{2} \\). Conversely, \\( primeval=integerm^{2}+16\\,numberw^{2} \\) implies \\( primeval \\equiv integerm^{2} \\equiv 1(\\bmod 8) \\). With (casetwo), \\( numberv \\) is odd, \\( integerm=2\\,numberu+numberv \\) for some integer \\( numberu \\), and \\( primeval=(2\\,numberu+numberv)^{2}+4\\,numberv^{2}=4\\,numberu^{2}+4\\,numberu\\,numberv+5\\,numberv^{2} \\). Conversely, \\( primeval=4\\,numberu^{2}+4\\,numberu\\,numberv+5\\,numberv^{2} \\) with \\( primeval \\) odd implies \\( primeval=(2\\,numberu+numberv)^{2}+4\\,numberv^{2} \\) with \\( numberv \\) odd and hence \\( primeval \\equiv 5(\\bmod 8) \\)."
    },
    "descriptive_long_confusing": {
      "map": {
        "x": "lighthouse",
        "y": "umbrella",
        "p": "sandwich",
        "m": "carnation",
        "n": "pendulum",
        "v": "blueberry",
        "w": "salamander",
        "u": "marigold",
        "A": "tangerine",
        "B": "porcupine"
      },
      "question": "A-3. A well-known theorem asserts that a prime \\( sandwich>2 \\) can be written as the sum of two perfect squares ( \\( sandwich=carnation^{2}+pendulum^{2} \\), with \\( carnation \\) and \\( pendulum \\) integers) if and only if \\( sandwich \\equiv 1(\\bmod 4) \\). Assuming this result, find which primes \\( sandwich>2 \\) can be written in each of the following forms, using (not necessarily positive) integers \\( \\boldsymbol{lighthouse} \\) and \\( umbrella \\) :\n(a) \\( lighthouse^{2}+16\\, umbrella^{2} \\);\n(b) \\( 4\\, lighthouse^{2}+4\\, lighthouse\\, umbrella+5\\, umbrella^{2} \\).",
      "solution": "A-3.\nIf \\( sandwich \\equiv 1(\\bmod 4) \\), either \\( (tangerine): sandwich \\equiv 1(\\bmod 8) \\) or \\( (porcupine): sandwich \\equiv 5(\\bmod 8) \\). We show that \\( (tangerine) \\) and \\( (porcupine) \\) are necessary and sufficient for (a) and (b), respectively. If \\( sandwich=carnation^{2}+pendulum^{2} \\) and \\( sandwich \\) is odd, one can let \\( carnation \\) be odd and \\( pendulum \\) be even. Then \\( sandwich=carnation^{2}+4 blueberry^{2} \\) with \\( carnation^{2} \\equiv 1(\\bmod 8) \\). With \\( (tangerine), blueberry \\) is even and \\( sandwich=carnation^{2}+16 salamander^{2} \\). Conversely, \\( sandwich=carnation^{2}+16 salamander^{2} \\) implies \\( sandwich \\equiv carnation^{2} \\equiv 1(\\bmod 8) \\). With (porcupine), \\( blueberry \\) is odd, \\( carnation=2 marigold+blueberry \\) for some integer \\( marigold \\), and \\[ sandwich=(2 marigold+blueberry)^{2}+4 blueberry^{2}=4 marigold^{2}+4 marigold\\, blueberry+5 blueberry^{2}. \\] Conversely, \\( sandwich=4 marigold^{2}+4 marigold\\, blueberry+5 blueberry^{2} \\) with \\( sandwich \\) odd implies \\( sandwich=(2 marigold+blueberry)^{2}+4 blueberry^{2} \\) with \\( blueberry \\) odd and hence \\( sandwich \\equiv 5(\\bmod 8) \\)."
    },
    "descriptive_long_misleading": {
      "map": {
        "x": "knownvalue",
        "y": "fixedterm",
        "p": "composite",
        "m": "evenvalue",
        "n": "oddvalue",
        "v": "steadyvar",
        "w": "unevenval",
        "u": "fraction",
        "A": "nonalpha",
        "B": "nondelta"
      },
      "question": "A-3. A well-known theorem asserts that a prime \\( composite>2 \\) can be written as the sum of two perfect squares ( \\( composite=evenvalue^{2}+oddvalue^{2} \\), with \\( evenvalue \\) and \\( oddvalue \\) integers) if and only if \\( composite \\equiv 1(\\bmod 4) \\). Assuming this result, find which primes \\( composite>2 \\) can be written in each of the following forms, using (not necessarily positive) integers \\( \\boldsymbol{knownvalue} \\) and \\( fixedterm \\) :\n(a) \\( knownvalue^{2}+16 fixedterm^{2} \\);\n(b) \\( 4 knownvalue^{2}+4 knownvalue fixedterm+5 fixedterm^{2} \\).",
      "solution": "A-3.\nIf \\( composite \\equiv 1(\\bmod 4) \\), either \\( (nonalpha): composite \\equiv 1(\\bmod 8) \\) or \\( (nondelta): composite \\equiv 5(\\bmod 8) \\). We show that \\( (nonalpha) \\) and \\( (nondelta) \\) are necessary and sufficient for (a) and (b), respectively. If \\( composite=evenvalue^{2}+oddvalue^{2} \\) and \\( composite \\) is odd, one can let \\( evenvalue \\) be odd and \\( oddvalue \\) be even. Then \\( composite=evenvalue^{2}+4 steadyvar^{2} \\) with \\( evenvalue^{2} \\equiv 1(\\bmod 8) \\). With \\( (nonalpha), steadyvar \\) is even and \\( composite=evenvalue^{2}+16 unevenval^{2} \\). Conversely, \\( composite=evenvalue^{2}+16 unevenval^{2} \\) implies \\( composite \\equiv evenvalue^{2} \\equiv 1(\\bmod 8) \\). With (nondelta), \\( steadyvar \\) is odd, \\( evenvalue=2 fraction+steadyvar \\) for some integer \\( fraction \\), and \\( composite=(2 fraction+steadyvar)^{2}+4 steadyvar^{2}=4 fraction^{2}+4 fraction steadyvar+5 steadyvar^{2} \\). Conversely, \\( composite=4 fraction^{2}+4 fraction steadyvar+5 steadyvar^{2} \\) with \\( composite \\) odd implies \\( composite=(2 fraction+steadyvar)^{2}+4 steadyvar^{2} \\) with \\( steadyvar \\) odd and hence \\( composite \\equiv 5(\\bmod 8) \\)."
    },
    "garbled_string": {
      "map": {
        "x": "kdlwhsze",
        "y": "oamfrqtu",
        "p": "zngqvcrh",
        "m": "qjiyxdpo",
        "n": "gpxlceur",
        "v": "wpmnoita",
        "w": "ycbtrdle",
        "u": "hjakgsef",
        "A": "afbmnqpe",
        "B": "jqwrsylk"
      },
      "question": "A-3. A well-known theorem asserts that a prime \\( zngqvcrh>2 \\) can be written as the sum of two perfect squares ( \\( zngqvcrh=qjiyxdpo^{2}+gpxlceur^{2} \\), with \\( qjiyxdpo \\) and \\( gpxlceur \\) integers) if and only if \\( zngqvcrh \\equiv 1(\\bmod 4) \\). Assuming this result, find which primes \\( zngqvcrh>2 \\) can be written in each of the following forms, using (not necessarily positive) integers \\( \\boldsymbol{kdlwhsze} \\) and \\( oamfrqtu \\) :\n(a) \\( kdlwhsze^{2}+16 oamfrqtu^{2} \\);\n(b) \\( 4 kdlwhsze^{2}+4 kdlwhsze oamfrqtu+5 oamfrqtu^{2} \\).",
      "solution": "A-3.\nIf \\( zngqvcrh \\equiv 1(\\bmod 4) \\), either \\( (afbmnqpe): zngqvcrh \\equiv 1(\\bmod 8) \\) or \\( (jqwrsylk): zngqvcrh \\equiv 5(\\bmod 8) \\). We show that \\( (afbmnqpe) \\) and \\( (jqwrsylk) \\) are necessary and sufficient for (a) and (b), respectively. If \\( zngqvcrh=qjiyxdpo^{2}+gpxlceur^{2} \\) and \\( zngqvcrh \\) is odd, one can let \\( qjiyxdpo \\) be odd and \\( gpxlceur \\) be even. Then \\( zngqvcrh=qjiyxdpo^{2}+4 wpmnoita^{2} \\) with \\( qjiyxdpo^{2} \\equiv 1(\\bmod 8) \\). With \\( (afbmnqpe), wpmnoita \\) is even and \\( zngqvcrh=qjiyxdpo^{2}+16 ycbtrdle^{2} \\). Conversely, \\( zngqvcrh=qjiyxdpo^{2}+16 ycbtrdle^{2} \\) implies \\( zngqvcrh \\equiv qjiyxdpo^{2} \\equiv 1(\\bmod 8) \\). With (jqwrsylk), \\( wpmnoita \\) is odd, \\( qjiyxdpo=2 hjakgsef+wpmnoita \\) for some integer \\( hjakgsef \\), and \\( zngqvcrh=(2 hjakgsef+wpmnoita)^{2}+4 wpmnoita^{2}=4 hjakgsef^{2}+4 hjakgsef wpmnoita+5 wpmnoita^{2} \\). Conversely, \\( zngqvcrh=4 hjakgsef^{2}+4 hjakgsef wpmnoita+5 wpmnoita^{2} \\) with \\( zngqvcrh \\) odd implies \\( zngqvcrh=(2 hjakgsef+wpmnoita)^{2}+4 wpmnoita^{2} \\) with \\( wpmnoita \\) odd and hence \\( zngqvcrh \\equiv 5(\\bmod 8) \\)."
    },
    "kernel_variant": {
      "question": "Let q be an odd prime.\n(a) For which primes q does there exist a pair of integers (\\alpha,\\,\\beta) satisfying\n\\[q=\\alpha^{2}+16\\beta^{2}?\\]\n(b) For which primes q does there exist a pair of integers (\\gamma,\\,\\delta) satisfying\n\\[q=4\\gamma^{2}+4\\gamma\\delta+5\\delta^{2}?\\]",
      "solution": "Recall Fermat’s two–square theorem: an odd prime q can be expressed as the sum of two integer squares iff q≡1 (mod 4).  \n\nStep 1. (Two squares.)  Because both quadratic forms in (a) and (b) will be linked to such sums, begin by writing  \n   q = a² + b²,  \nwith a odd and b even.  (Exactly one of a,b must be even for an odd prime.)  \n\nStep 2. (Introduce v.)  Put b = 2v.  Then  \n   q = a² + 4v²,  \nwith a² ≡ 1 (mod 8) since a is odd.  \n\nStep 3. (Mod 8 analysis.)  Since 4v² ≡ 0 (v even) or 4 (v odd) mod 8, we obtain  \n   v even ⇒ q ≡ 1 (mod 8),  \n   v odd  ⇒ q ≡ 5 (mod 8).  \nThus every odd prime q ≡ 1 (mod 4) lies in exactly one of the two residue classes 1 or 5 mod 8.  \n\nStep 4a. (v even ⇒ form in part (a).)  If v is even, write v = 2w.  Then  \n   q = a² + 4(2w)² = a² + 16w²,  \nwhich is the shape required in (a) with (α,β) = (a,w).  \n\nStep 4b. (v odd ⇒ form in part (b).)  If v is odd, a is also odd, so set a = 2u + v.  Then  \n   q = (2u + v)² + 4v² = 4u² + 4uv + 5v²,  \nwhich is the expression in (b) with (γ,δ) = (u,v).  \n\nStep 5. (Converses.)  \n• If q = α² + 16β², then mod 8 gives q ≡ α² ≡ 1, so q ≡ 1 (mod 8).  Hence q ≡ 1 (mod 4), and in any representation q = a² + b² one finds b must be even and then v = b/2 must be even (else q ≡ 5 mod 8), recovering (a).  \n• If q = 4γ² + 4γδ + 5δ², rewrite q = (2γ + δ)² + 4δ².  If δ were even, both summands would be divisible by 4, forcing q divisible by 4, impossible for an odd prime.  Thus δ is odd, so q ≡ 1 + 4 = 5 (mod 8), recovering (b).  \n\nConclusion.  \n(a) The integers α,β exist ⇔ q ≡ 1 (mod 8).  \n(b) The integers γ,δ exist ⇔ q ≡ 5 (mod 8).  \nThese two disjoint residue classes together comprise all odd primes q ≡ 1 (mod 4).",
      "_meta": {
        "core_steps": [
          "Invoke Fermat’s two-square theorem: any prime p≡1 (mod 4) can be written p=m²+n².",
          "Fix parities (m odd, n even), write n=2v to obtain p=m²+4v² with m²≡1 (mod 8).",
          "Use mod-8 analysis: 4v²≡0 when v even ⇒ p≡1 (mod 8); 4v²≡4 when v odd ⇒ p≡5 (mod 8).",
          "v even ⇒ v=2w gives p=m²+16w² (first quadratic form).  v odd ⇒ m=2u+v gives p=4u²+4uv+5v² (second form).",
          "Converses: each quadratic form forces the same mod-8 class, completing the iff for the respective primes."
        ],
        "mutable_slots": {
          "slot1": {
            "description": "Lower bound on p chosen only to exclude the even prime; any wording that merely says ‘p is an odd prime’ suffices.",
            "original": "p>2"
          },
          "slot2": {
            "description": "Names/labels for the two residue classes or cases (currently ‘(A)’ and ‘(B)’) can be altered or omitted without affecting the logic.",
            "original": "(A) and (B)"
          },
          "slot3": {
            "description": "Choice of variable symbols for integers (m,n,u,v,w,x,y) is arbitrary; any distinct letters would work.",
            "original": "m, n, u, v, w, x, y"
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "proof"
}