{
  "familyId": "math.arithmetic",
  "version": 1,
  "status": "draft",
  "contentStatus": "draft_offline_checked",
  "name": "整數與有限小數四則",
  "scope": [
    "有號整數與有限小數四則及括號。",
    "AST 明確保留運算順序，結果允許精確分數如 1/3。"
  ],
  "exclusions": [
    "指數、根號、百分號及循環小數輸入記法。",
    "未知量及未確認 OCR 候選；零除數不可計算。"
  ],
  "parameterSchema": {
    "ast": {
      "type": "recursive_expression",
      "number": "整數或有限小數字串；不接受科學記號、浮點數或自由程式。",
      "operators": {
        "add": 2,
        "sub": 2,
        "mul": 2,
        "div": 2,
        "neg": 1
      },
      "constraint": "節點無環且運算元數量符合定義。",
      "limits": {
        "maxNodes": 500,
        "maxDepth": 100,
        "maxNumberCharacters": 64
      }
    },
    "confirmed": {
      "type": "boolean",
      "required": true,
      "falseOrMissing": "confirm"
    }
  },
  "methods": [
    {
      "methodId": "arithmetic.expression-tree",
      "version": 1,
      "applicability": [
        "來源與 AST 對應且 confirmed=true。",
        "節點與數值合法；每個除數子樹精確求值不為零。"
      ],
      "steps": [
        {
          "id": "read",
          "stage": 0,
          "title": "確認算式",
          "instruction": "逐一確認數字、負號及括號，不清楚先問。",
          "hint": "先指出括號範圍。",
          "check": "數字及運算都有已確認來源。"
        },
        {
          "id": "choose",
          "stage": 1,
          "title": "排好順序",
          "instruction": "括號優先，先乘除後加減，同級由左至右。",
          "hint": "樹上最深層先處理。",
          "check": "不改原 AST 的依賴或結合順序。"
        },
        {
          "id": "compute",
          "stage": 2,
          "title": "逐步計算",
          "instruction": "一次計算一個節點，再用等值結果替換。",
          "hint": "有限小數可轉成精確分數。",
          "check": "每一節點等值；除數求值後非零。"
        },
        {
          "id": "verify",
          "stage": 3,
          "title": "核對答案",
          "instruction": "由原 AST 重算，輸出最簡正分母答案。",
          "hint": "以逆運算核對局部步骤。",
          "check": "結果一致、正分母且互質；圖與 trace 同源。"
        }
      ],
      "validatorRefs": [
        "source.confirmed.v1",
        "expression.ast-domain.v1",
        "rational.exact-evaluation.v1",
        "arithmetic.divisor-nonzero.v1",
        "rational.canonical.v1",
        "diagram.same-binding.v1"
      ],
      "diagramRefs": [
        "arithmetic.expression-tree.v1",
        "arithmetic.number-line.v1"
      ]
    }
  ],
  "svgTemplateSpecs": [
    {
      "templateId": "arithmetic.expression-tree",
      "version": 1,
      "parameters": {
        "nodes": "合法 AST ID、運算、原值及計算 trace",
        "activeNode": "當前合法運算節點 ID",
        "revealedIds": "已到達步驟的節點 ID"
      },
      "domainGuards": [
        "只用五種合法節點，無循環且參數等於題目綁定。",
        "節點過多分局部子樹，不能刪除算式。",
        "文字安全轉義，不接受模型 SVG 原碼。"
      ],
      "primitives": [
        "roundedRect",
        "line",
        "circle",
        "text"
      ],
      "revealSequence": [
        "原算式",
        "當前子算式描亮",
        "當前等值替換",
        "完成後揭露最终結果"
      ],
      "fallback": "改為上下對齊的 SVG 算式卡，不更改運算或數值。"
    },
    {
      "templateId": "arithmetic.number-line",
      "version": 1,
      "parameters": {
        "start": "精確分數",
        "delta": "帶正負方向的精確分數",
        "end": "start+delta",
        "range": "共用原點及比例"
      },
      "domainGuards": [
        "只適用加減單步，乘除不用位移圖。",
        "位置與標籤共用精確值，縮放不改變關係。",
        "大跨度改標關鍵刻度並註明示意。"
      ],
      "primitives": [
        "line",
        "arrow",
        "circle",
        "text"
      ],
      "revealSequence": [
        "起點",
        "位移",
        "終點與算式"
      ],
      "fallback": "精確 SVG 算式卡。"
    }
  ],
  "review": {
    "humanTeacherReviewed": false,
    "source": "全部案例自製；未引用教材原題或學生個資。",
    "approval": "僅離線草稿核對，未正式教師審核或發布。"
  }
}
