{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://capacityatlas.org/api/problem.schema.json",
  "title": "Capacity Atlas problem",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "title",
    "status",
    "category",
    "updated",
    "summary",
    "model",
    "quantity",
    "capacity",
    "bounds",
    "formalization",
    "references"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "title": { "type": "string", "minLength": 3 },
    "abbreviation": { "type": "string", "minLength": 1 },
    "status": {
      "enum": ["solved", "open", "partially-solved"]
    },
    "category": { "type": "string", "minLength": 1 },
    "featured": { "type": "boolean" },
    "updated": {
      "type": "string",
      "format": "date"
    },
    "summary": { "type": "string", "minLength": 20 },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
      },
      "uniqueItems": true
    },
    "parameters": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["symbol", "description"],
        "properties": {
          "symbol": { "type": "string" },
          "description": { "type": "string" },
          "range": { "type": "string" }
        }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": ["input", "output", "law", "assumptions"],
      "properties": {
        "input": { "type": "string" },
        "output": { "type": "string" },
        "law": { "type": "string", "minLength": 3 },
        "assumptions": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "quantity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "symbol", "units"],
      "properties": {
        "name": { "type": "string" },
        "symbol": { "type": "string" },
        "units": { "type": "string" },
        "criterion": { "type": "string" }
      }
    },
    "capacity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "display"],
      "properties": {
        "kind": {
          "enum": ["exact", "characterization", "bounds", "region"]
        },
        "display": { "type": "string", "minLength": 1 },
        "conditions": { "type": "string" },
        "lower": { "type": "string" },
        "upper": { "type": "string" },
        "conjectured": { "type": "string" },
        "notes": { "type": "string" }
      }
    },
    "bounds": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "direction",
          "relation",
          "method",
          "year",
          "references"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "direction": {
            "enum": [
              "lower",
              "upper",
              "exact",
              "inner-region",
              "outer-region",
              "linear-exact"
            ]
          },
          "relation": { "type": "string" },
          "method": { "type": "string" },
          "year": { "type": "integer", "minimum": 1900, "maximum": 2100 },
          "conditions": { "type": "string" },
          "notes": { "type": "string" },
          "references": {
            "type": "array",
            "items": { "type": "string" },
            "minItems": 1,
            "uniqueItems": true
          }
        }
      }
    },
    "timeline": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["year", "event", "references"],
        "properties": {
          "year": { "type": "integer", "minimum": 1900, "maximum": 2100 },
          "event": { "type": "string" },
          "references": {
            "type": "array",
            "items": { "type": "string" },
            "uniqueItems": true
          }
        }
      }
    },
    "frontier": {
      "type": "object",
      "additionalProperties": false,
      "required": ["question", "bottleneck", "progress"],
      "properties": {
        "question": { "type": "string" },
        "bottleneck": { "type": "string" },
        "progress": {
          "type": "array",
          "items": { "type": "string" },
          "minItems": 1
        },
        "subproblems": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["title", "status"],
            "properties": {
              "title": { "type": "string" },
              "status": { "enum": ["open", "in-progress", "done"] },
              "url": { "type": "string", "format": "uri" }
            }
          }
        }
      }
    },
    "formalization": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status"],
      "properties": {
        "status": {
          "enum": ["none", "definitions", "statement", "partial", "complete"]
        },
        "language": { "const": "Lean" },
        "notes": { "type": "string" },
        "files": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["path", "declaration", "description"],
            "properties": {
              "path": { "type": "string", "pattern": "^lean/.+\\.lean$" },
              "declaration": { "type": "string", "minLength": 1 },
              "description": { "type": "string", "minLength": 3 }
            }
          }
        }
      }
    },
    "discussion": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "url": { "type": "string", "format": "uri" }
      }
    },
    "references": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 1,
      "uniqueItems": true
    }
  }
}
