{
  "id": "KL-FCS-017",
  "version": "1.0.0",
  "domain": "Programming-language semantics",
  "kind": "semantics",
  "title": "Signed integer reduction",
  "problem": "Replay left-to-right integer arithmetic with add and mul nodes.",
  "specification": {
    "term": [
      "add",
      [
        "mul",
        -2,
        3
      ],
      [
        "mul",
        4,
        5
      ]
    ],
    "rules": "Left non-literal operand first, then right; integer arithmetic without overflow."
  },
  "claim": {
    "normal_form": 14
  },
  "witness": {
    "trace": [
      [
        "add",
        [
          "mul",
          -2,
          3
        ],
        [
          "mul",
          4,
          5
        ]
      ],
      [
        "add",
        -6,
        [
          "mul",
          4,
          5
        ]
      ],
      [
        "add",
        -6,
        20
      ],
      14
    ]
  },
  "verification_scope": "Exact reduction replay · 3 steps",
  "explanation": "The trace records intermediate terms, so the result’s derivation and the evaluation order are both inspectable.",
  "limitations": "This language uses mathematical integers and no side effects; machine overflow requires different semantics.",
  "verification_status": "mechanically-checked",
  "review_status": "awaiting-independent-review",
  "provenance": {
    "origin": "Original Kenton Labs reference instance, authored with Codex assistance on 2026-10-11.",
    "external_dataset": null,
    "model_run": null
  },
  "references": [
    "https://softwarefoundations.cis.upenn.edu/plf-current/Smallstep.html"
  ],
  "license_status": "not-yet-selected",
  "dataset": {
    "family": "semantics",
    "task": "Replay left-to-right integer arithmetic with add and mul nodes.",
    "input_encoding": "Structured JSON; field meanings are stated in the specification.",
    "coverage": "Exact reduction replay · 3 steps",
    "acceptance": [
      "Check that the trace begins with the declared syntax tree.",
      "Reduce the left non-literal operand before the right operand.",
      "Apply arithmetic only when both operands are integer literals.",
      "Check each adjacent trace pair and require a terminal integer."
    ],
    "generation": "Deterministic finite fixture; full enumeration or witness replay as stated.",
    "split_policy": "Reference corpus for exposition and reproduction; no train/test evaluation split is claimed."
  },
  "lesson": {
    "motivation": "Turn an expression’s meaning into an inspectable sequence of rule applications. Evaluation order belongs to the specification.",
    "definitions": [
      {
        "term": "Term",
        "definition": "An integer literal or an add/mul syntax node."
      },
      {
        "term": "Small step",
        "definition": "One permitted local reduction, under an explicitly chosen evaluation context."
      },
      {
        "term": "Normal form",
        "definition": "A term with no further reduction; here it is an integer literal."
      }
    ],
    "reasoning": [
      "Check that the trace begins with the declared syntax tree.",
      "Reduce the left non-literal operand before the right operand.",
      "Apply arithmetic only when both operands are integer literals.",
      "Check each adjacent trace pair and require a terminal integer."
    ],
    "worked_example": "The trace records intermediate terms, so the result’s derivation and the evaluation order are both inspectable.",
    "complexity": "Replay costs one reduction per arithmetic node, plus traversal to find the next reducible node.",
    "common_error": "A final number alone does not certify the declared evaluation sequence.",
    "further_work": "Introduce variables, environments, conditionals, and explicit stuck-state outcomes."
  },
  "related_ids": [
    "KL-FCS-003",
    "KL-FCS-016"
  ]
}
