{
  "artifactId": "artifact.library.mathlib.law-of-cosines.v001",
  "candidateOnly": false,
  "category": "Geometry",
  "claimBoundary": "This page indexes Mathlib's angle-at-point law of cosines for arbitrary points p₁, p₂, and p₃ in an affine metric space modeled on a real inner-product space. The selected identity places the angle at p₂ and the opposite distance between p₁ and p₃. It assumes neither distinctness nor non-collinearity, so degenerate triples are included. It is not restricted to the Euclidean plane and does not state the law of sines, recover an angle, or add a nondegenerate-triangle hypothesis.",
  "collectionSlug": "landmark-theorems-in-mathlib",
  "exactFormalStatement": "theorem EuclideanGeometry.dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] (p₁ p₂ p₃ : P) : dist p₁ p₃ * dist p₁ p₃ = dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂ - 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃)",
  "family": "Euclidean affine geometry",
  "id": "library.mathlib.law-of-cosines.v001",
  "links": {
    "collection": "/collections/landmark-theorems-in-mathlib/",
    "collectionData": "/data/collections/mathlib-landmarks.json",
    "entry": "/library-theorems/law-of-cosines/",
    "entryData": "/data/library-theorems/law-of-cosines.json",
    "evidence": "/proofs/artifact.library.mathlib.law-of-cosines.v001.html",
    "evidenceData": "/data/proofs/artifact.library.mathlib.law-of-cosines.v001.evidence.json",
    "source": "/sources/upstream/law-of-cosines/"
  },
  "landmark": {
    "completeFormalType": "theorem EuclideanGeometry.dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] (p₁ p₂ p₃ : P) : dist p₁ p₃ * dist p₁ p₃ = dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂ - 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃)",
    "concepts": [
      "law of cosines",
      "Euclidean affine geometry",
      "distance",
      "angle",
      "displacement vectors"
    ],
    "plainLanguage": "Choose any three points and focus on the angle at p₂. The distance from p₁ to p₃ satisfies the familiar cosine rule using the two distances from p₂—even when the three points form a degenerate triangle.",
    "poster": {
      "alt": "An ivory editorial poster places a gold angle at p₂ in a scalene p₁-p₂-p₃ triangle, highlights the opposite side p₁—p₃, states the exact Mathlib distance identity, and traces its displacement-vector proof route.",
      "byteSize": 2233724,
      "caption": "For any three points in a real inner-product affine space, the squared distance p₁—p₃ obeys the cosine rule for the angle at p₂.",
      "description": "The poster fixes the angle and opposite side in one labelled triangle, prints the source's distance-product identity, and follows the checked proof from distances to displacement norms, through the vector law of cosines, to cancellation of the shared affine base point. Its exact-scope footer keeps degenerate triples inside the declaration.",
      "derivatives": [
        {
          "byteSize": 83090,
          "height": 960,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/law-of-cosines/theorem-poster-v1-640.webp",
          "sha256": "sha256:a79c828e1ce525b94eadf6e65212b2a997f013c5e44aeeb7466e222aacaf33be",
          "width": 640
        },
        {
          "byteSize": 166998,
          "height": 1536,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/law-of-cosines/theorem-poster-v1-1024.webp",
          "sha256": "sha256:4dd92159255c7f9503fc9d19f3633a4e4cb4eb161cc65c2223d8b8bef32e5355",
          "width": 1024
        }
      ],
      "generatedAt": "2026-07-25T16:25:31-04:00",
      "height": 1536,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/law-of-cosines/theorem-poster-v1.png",
      "sha256": "sha256:ff77d134d15afbf2b2348f181ee8523c006e1383c9c5435d215a4d5bd48eb0ce",
      "title": "Law of Cosines at a glance",
      "width": 1024,
      "kind": "theorem_poster",
      "transcript": "EUCLIDEAN AFFINE GEOMETRY\nLAW OF COSINES\nANGLE AT p₂ · OPPOSITE SIDE p₁—p₃\ndist p₁ p₃ * dist p₁ p₃\n= dist p₁ p₂ * dist p₁ p₂ + dist p₃ p₂ * dist p₃ p₂\n− 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃)\nPROOF ROUTE\nDISTANCES → DISPLACEMENT NORMS\nVECTOR LAW OF COSINES\nCANCEL THE SHARED BASE POINT\nEXACT SCOPE\nAny three points, including degenerate triples, in a real inner-product affine space."
    },
    "visual": {
      "alt": "On a deep-green field, a scalene triangle labels p₁ above p₂ on the left and p₃ on the right; one gold arc marks the angle at p₂, two arrows share p₂ as their tail, and the gold double-stroked side from p₁ to p₃ is opposite that angle.",
      "byteSize": 2712750,
      "caption": "For the angle at p₂, the law of cosines relates the opposite distance p₁—p₃ to the two distances from p₂.",
      "description": "Exactly three point markers form an oblique scalene triangle. The two displacement arrows begin at p₂ and end at p₁ and p₃, matching the source's reduction to vectors. A single angle arc is centered at p₂, while a doubled antique-gold stroke emphasizes the opposite side joining p₁ directly to p₃.",
      "derivatives": [
        {
          "byteSize": 15742,
          "height": 427,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/law-of-cosines/theorem-schematic-v1-640.webp",
          "sha256": "sha256:937a4be7696964a8398eee49299f6a0a494f0f5ac9ede2cf85dea01a9a12e599",
          "width": 640
        },
        {
          "byteSize": 79448,
          "height": 800,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/law-of-cosines/theorem-schematic-v1-1200.webp",
          "sha256": "sha256:3a1e7dde000b6af0d938945dbdd75728ed21bf97c3a9bd734d61c9cb22bcd2b7",
          "width": 1200
        }
      ],
      "generatedAt": "2026-07-25T16:25:31-04:00",
      "height": 1024,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/law-of-cosines/theorem-schematic-v1.png",
      "sha256": "sha256:b729b8183c8ad9e7bb86152be3343c0272fe722d3031ed61e250d04ed12d0329",
      "title": "The angle and its opposite side",
      "width": 1536
    },
    "walkthrough": null,
    "whyLandmark": "The law of cosines is the basic metric identity connecting three side lengths with one angle. Mathlib states it without unnecessary nondegeneracy or planar hypotheses and derives it cleanly from the vector law of cosines through affine displacement vectors."
  },
  "nonClaims": [
    "ProofAtlas did not originate the law of cosines or Mathlib's declaration.",
    "The selected declaration does not assume that the three points are distinct or non-collinear.",
    "The selected declaration is not limited to a two-dimensional Euclidean plane.",
    "It does not state the law of sines or an inverse-cosine angle-recovery formula.",
    "The generated explanation and visuals are not proof evidence."
  ],
  "publicExportEligible": true,
  "relationship": "upstream_direct",
  "schemaVersion": "library-theorem-entry-data.v1",
  "statementId": "statement.library.mathlib.law-of-cosines.v001",
  "statusAxes": {
    "acceptedAtlasResult": "Not recorded for the preferred artifact",
    "locallyReproduced": "Exact upstream declaration replayed",
    "reviewedPage": "Current public presentation reviewed",
    "upstreamIndexed": "Pinned source bytes verified locally"
  },
  "summary": "For any three points in a real inner-product affine space, the squared distance opposite the angle at p₂ is determined by the two adjacent distances and the cosine of that angle.",
  "targetId": "target.library.mathlib.law-of-cosines.v001",
  "title": "Law of Cosines",
  "upstreamOrigin": {
    "declarationName": "EuclideanGeometry.dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle",
    "immutableSourceUrl": "https://github.com/leanprover-community/mathlib4/blob/5e932f97dd25535344f80f9dd8da3aab83df0fe6/Mathlib/Geometry/Euclidean/Triangle.lean#L242",
    "packageName": "mathlib",
    "repositoryUrl": "https://github.com/leanprover-community/mathlib4",
    "sourceArtifactHash": "sha256:d213d254e278b215ce8d206d4ea2290e3ef39cb4a84e2696c3c08e6639135ade",
    "sourceByteLength": 25183,
    "sourceCommit": "5e932f97dd25535344f80f9dd8da3aab83df0fe6",
    "sourceFile": "Mathlib/Geometry/Euclidean/Triangle.lean",
    "sourceLine": 242,
    "verificationKind": "git_worktree"
  },
  "publicPresentationReview": {
    "status": "reviewed"
  }
}
