{
  "map_id": "tel.syntax_map",
  "version": "5.0-draft",
  "book": "book5_tel",
  "series": "AI Edition",
  "invariant": "INV-TEL-001",
  "operator_binding": "TEL-Σ (SyntaxCheck)",
  "description": "Defines the canonical TEL grammar. TEL is a formal notation system for encoding AI Edition structural configurations, transformations, constraints, and invariant assertions. All TEL expressions must conform to this grammar before evaluation.",
  "grammar": {
    "notation": "BNF-extended with operator-symbol shorthand",
    "entry_point": "<tel_expression>",
    "rules": [
      {
        "rule_id": "G-001",
        "lhs": "<tel_expression>",
        "rhs": "<atom> | <compound> | <transform_expr> | <constraint_expr> | <invariant_expr>",
        "note": "Top-level production. Every well-formed TEL expression reduces to one of these five forms."
      },
      {
        "rule_id": "G-002",
        "lhs": "<atom>",
        "rhs": "<identifier> | <literal> | <symbol_ref>",
        "note": "Irreducible terminal expression. Corresponds to a single AI Edition primitive (node, relation endpoint, or declared constant)."
      },
      {
        "rule_id": "G-003",
        "lhs": "<compound>",
        "rhs": "'(' <tel_expression> <compose_op> <tel_expression> ')'",
        "note": "Binary composition. Parentheses are mandatory and non-optional. Nesting depth is unbounded."
      },
      {
        "rule_id": "G-004",
        "lhs": "<compose_op>",
        "rhs": "'⊕' | '⊗' | '→' | '⊢' | '⊥'",
        "semantics": {
          "⊕": "Relational union — combines two structure sets under shared relational closure",
          "⊗": "Relational product — cross-product of two relation sets with shared constraint application",
          "→": "Directed structural dependency — left structure depends on right",
          "⊢": "Constraint assertion — left structure must satisfy right constraint expression",
          "⊥": "Structural disjointness — left and right share no relational elements"
        }
      },
      {
        "rule_id": "G-005",
        "lhs": "<transform_expr>",
        "rhs": "'T[' <identifier> ']:' <tel_expression> '→' <tel_expression>",
        "note": "Encodes a named transformation mapping an input structural expression to an output structural expression."
      },
      {
        "rule_id": "G-006",
        "lhs": "<constraint_expr>",
        "rhs": "'C[' <identifier> ']:' <tel_expression>",
        "note": "Declares a named constraint over a TEL expression. The constraint is evaluated by TEL-Α (Assert) in the assert phase."
      },
      {
        "rule_id": "G-007",
        "lhs": "<invariant_expr>",
        "rhs": "'INV[' <identifier> ']:' 'assert' <tel_expression>",
        "note": "Top-level invariant assertion. Must reference a declared invariant identifier. Evaluated strictly by TEL-Α."
      },
      {
        "rule_id": "G-008",
        "lhs": "<identifier>",
        "rhs": "[A-Z][A-Z0-9_-]*",
        "note": "Uppercase alphanumeric string with underscores/hyphens. Case-sensitive. Must match a declared entity in the active AI Edition module registry."
      },
      {
        "rule_id": "G-009",
        "lhs": "<literal>",
        "rhs": "<numeric_literal> | <boolean_literal> | <string_literal>",
        "note": "Primitive value literals. Numeric literals may be integer or real. Booleans are ⊤ (true) and ⊥ (false) — note ⊥ is overloaded: as compose_op it means disjointness; as boolean literal it means false. Context resolves the reading."
      },
      {
        "rule_id": "G-010",
        "lhs": "<symbol_ref>",
        "rhs": "'#' <identifier>",
        "note": "Reference to a declared symbol in the active TEL scope. Symbols are declared via prior INV or C expressions in the same evaluation session."
      }
    ]
  },
  "token_table": [
    { "token": "⊕", "class": "compose_op", "label": "relational_union" },
    { "token": "⊗", "class": "compose_op", "label": "relational_product" },
    { "token": "→", "class": "compose_op", "label": "directed_dependency" },
    { "token": "⊢", "class": "compose_op", "label": "constraint_assertion" },
    { "token": "⊥", "class": "compose_op | boolean_literal", "label": "disjointness / false" },
    { "token": "⊤", "class": "boolean_literal", "label": "true" },
    { "token": "T[…]", "class": "transform_prefix", "label": "transformation_block" },
    { "token": "C[…]", "class": "constraint_prefix", "label": "constraint_block" },
    { "token": "INV[…]", "class": "invariant_prefix", "label": "invariant_assertion_block" },
    { "token": "#", "class": "symbol_ref_sigil", "label": "symbol_reference" }
  ],
  "well_formedness_rules": [
    "WF-001: Parentheses must be balanced. Unmatched parentheses constitute a parse error.",
    "WF-002: All identifiers must resolve to declared entities in the active module registry. Unresolved identifiers constitute a syntax error, not a runtime error.",
    "WF-003: T[…] expressions must have exactly one '→' at the top level of the transform body.",
    "WF-004: INV[…] expressions must reference an invariant declared in the active book's invariants file.",
    "WF-005: Nesting of INV[…] inside T[…] or C[…] is not permitted at the grammar level.",
    "WF-006: The ⊥ token is resolved as compose_op when appearing between two <tel_expression> terminals inside parentheses; otherwise as boolean literal."
  ],
  "worked_examples": [
    {
      "example_id": "EX-SYN-001",
      "label": "Simple relational union",
      "expression": "(STRUCT_A ⊕ STRUCT_B)",
      "parse": "compound: atom ⊕ atom",
      "reading": "Relational union of structure A and structure B"
    },
    {
      "example_id": "EX-SYN-002",
      "label": "Directed dependency with constraint",
      "expression": "((STRUCT_A → STRUCT_B) ⊢ C[VALID_DEPEND])",
      "parse": "compound: compound ⊢ constraint_expr",
      "reading": "The directed dependency of A on B must satisfy constraint VALID_DEPEND"
    },
    {
      "example_id": "EX-SYN-003",
      "label": "Named transformation",
      "expression": "T[OPACITY_SHIFT]: (STRUCT_A) → (STRUCT_A ⊗ OR_OMEGA)",
      "parse": "transform_expr: identifier maps atom to compound",
      "reading": "Transformation OPACITY_SHIFT maps structure A to the relational product of A with the opacity gradient operator binding"
    },
    {
      "example_id": "EX-SYN-004",
      "label": "Invariant assertion",
      "expression": "INV[INV-TEL-002]: assert (EXPR_X ⊥ EXPR_Y)",
      "parse": "invariant_expr: references INV-TEL-002 and asserts disjointness",
      "reading": "Assert, under INV-TEL-002, that expressions X and Y are structurally disjoint"
    }
  ]
}
