# XIC Instruction Semantics v1.5 **Version**: 1.5 **Date**: 2026-05-21 **Status**: Formal Specification --- ## Overview XIC v1.5 is a symbolic and compressed execution virtual machine. It provides: 1. **Dual execution modes**: Compressed (via execute_gx) and symbolic (via symbolic pipeline) 2. **Explicit instruction set semantics**: Formal definitions of preconditions, postconditions, and side effects 3. **Glyph-aware symbolic processing**: Integration with LAIN 8-lane cognition and glyph metadata 4. **Context propagation**: Symbolic context flows through chains of operations ### Architecture ``` XICContext (model_path, mode, params, context, symbolic_mode, _state) ↓ XIC Instructions (9 ops in OP_TABLE) ↓ Dual paths: - Compressed: execute_gx() → decompresses .gx → execs Python - Symbolic: run_symbolic_pipeline() → LAIN 8 lanes → fused_symbol ``` --- ## XICContext Model ### Fields | Field | Type | Meaning | |-------|------|---------| | `model_path` | Optional[str] | Path to .gx model file. Set by LOAD_MODEL. | | `mode` | str | Execution mode: "chat", "eval", "benchmark", "symbolic". Default: "chat". | | `params` | Dict[str, Any] | Execution parameters (temperature, trace, profile, use_gpu, etc.). | | `context` | Dict[str, Any] | (In params["context"]) Symbolic/cognitive context metadata (domain, style, glyph_id, etc.). | | `symbolic_mode` | bool | True if mode == "symbolic". Controls routing in RUN_PROMPT/STREAM/CALL_GLYPH. | | `_state` | Dict[str, Any] | Internal state: last_result, last_symbolic_result, last_symbolic_pipeline, glyph_* keys. | ### Context Propagation - `SET_CONTEXT ` adds/updates keys in `ctx.params["context"]`. - Context is passed to `run_symbolic_pipeline(context=...)` in symbolic operations. - Glyph operations add `glyph_id` to context automatically. --- ## Instruction Semantics (12 Instructions) ### 1. LOAD_MODEL **Signature** ```json { "op": "LOAD_MODEL", "args": [""] } ``` **Preconditions** - Argument must be a valid string (path). **Postconditions** - `ctx.model_path = path` **Side effects** - Prints `[XIC] Model loaded: ` **Symbolic behavior** - No effect on `ctx.symbolic_mode`. **Compressed behavior** - `ctx.model_path` is used by RUN_PROMPT/STREAM to load the .gx file. --- ### 2. SET_MODE **Signature** ```json { "op": "SET_MODE", "args": [""] } ``` **Preconditions** - `mode` ∈ {"chat", "eval", "benchmark", "symbolic", ...} **Postconditions** - `ctx.mode = mode` - If `mode == "symbolic"`: `ctx.symbolic_mode = True` - If `mode != "symbolic"`: `ctx.symbolic_mode = False` **Side effects** - Prints `[XIC] Mode set to: ` **Remarks** - Setting mode to "symbolic" enables routing through symbolic pipeline (run_symbolic_pipeline). - All other modes use compressed execution (execute_gx). --- ### 3. SET_PARAM **Signature** ```json { "op": "SET_PARAM", "args": ["", ] } ``` **Preconditions** - Arguments: key (str), value (any). **Postconditions** - `ctx.params[key] = value` **Side effects** - Prints `[XIC] Parameter = ` **Remarks** - `use_gpu`, `trace`, `profile` are reserved parameter names. - Parameters are passed to execute_gx (if used). --- ### 4. SET_CONTEXT **Signature** ```json { "op": "SET_CONTEXT", "args": ["", ] } ``` **Preconditions** - Arguments: key (str), value (any). **Postconditions** - `ctx.params["context"][key] = value` - If `ctx.params["context"]` doesn't exist, it is created. **Side effects** - Prints `[XIC] Context = ` **Usage** - Build symbolic context metadata: `SET_CONTEXT "domain" "ai"`, `SET_CONTEXT "style" "analytic"`. - Context is passed to symbolic operations (RUN_PROMPT, STREAM, CALL_GLYPH). --- ### 5. RUN_PROMPT **Signature** ```json { "op": "RUN_PROMPT", "args": [""] } ``` **Preconditions** - Argument: prompt (str). **Postconditions** - If `ctx.symbolic_mode == True`: - `ctx._state["last_symbolic_result"] = output_text` - `ctx._state["last_symbolic_pipeline"] = SymbolicPipelineResult` - If `ctx.symbolic_mode == False`: - Requires `ctx.model_path` to be set (LOAD_MODEL must be called first). - `ctx._state["last_result"] = ExecutionContext` **Symbolic behavior** (ctx.symbolic_mode=True) - Calls `run_symbolic_pipeline(prompt, context=ctx.params.get("context"))`. - Routes through LAIN 8-lane cognition kernel. - Prints `[XIC-SYMBOLIC] ` - Stores full SymbolicPipelineResult for inspection (steps, fused_symbol). **Compressed behavior** (ctx.symbolic_mode=False) - Calls `execute_gx(ctx.model_path, trace=ctx.params.get("trace"), profile=ctx.params.get("profile"))`. - Decompresses .gx binary and executes Python code. - Prints `[XIC] Execution complete` and result. **Remarks** - The prompt argument is informational in compressed mode (not used). - In symbolic mode, the prompt is the primary input to LAIN cognition. --- ### 6. STREAM **Signature** ```json { "op": "STREAM", "args": [""] } ``` **Preconditions** - Argument: prompt (str). **Postconditions** - Same as RUN_PROMPT, but output is streamed line-by-line. **Symbolic behavior** - Calls `run_symbolic_pipeline(prompt, context=...)`. - Streams output_text line-by-line with `[XIC-STREAM]` prefix. - Stores pipeline result in `ctx._state["last_symbolic_pipeline"]`. **Compressed behavior** - Calls `execute_gx(...)`. - Streams result line-by-line with `[XIC-STREAM]` prefix. **Side effects** - Multiple print statements (one per line). --- ### 7. CHAIN **Signature** ```json { "op": "CHAIN", "args": ["