# Coded matmul admission

> Decide if a coded matrix request is computed, or which error it gets. The checks run in the order the LexLean Matmul protocol sets.

Inspired by afflom/lexlean-matmul (https://github.com/afflom/lexlean-matmul), live at https://afflom.github.io/lexlean-matmul/. A pure LexLean implementation of the UOR matrix multiplication method: decode the code, accumulate exactly, encode once. Pattern: Decision table, OMG DMN 1.5, hit policy FIRST. To write one of your own, follow How to build a decision table app (../../guides/decision-table/index.md). The prompt below is data, quoted from the example.

**Figure: What the Coded matmul admission app does.** A request goes in, the rules decide, and the Lean kernel has already proved what the rules promise.

| Step | What happens |
| --- | --- |
| 1. Request | version, m, k, n, shape, tier, code |
| 2. 10 rules | the first that matches wins |
| 3. Answer | ok, unsupported-version, invalid-dimension, shape-mismatch, unknown-tier, invalid-code |
| 4. Proved | 4 theorems, 71 tests |

Verified by prismpm verify in the pinned SDK. Fingerprint: b32ced10969d6575574d575c7874bc3c3dcf82049267ac4486c42fcc6c375b66. Acceptance vectors: 71. Claims: 7.

## The prompt

```json
{
  "schema": "prism/prompt/1",
  "goal": "Decide if a coded matrix request is computed, or which error it gets. The checks run in the order the LexLean Matmul protocol sets.",
  "pattern": "decisionTable",
  "repository": "afflom/lexlean-matmul",
  "app": {
    "name": "matmul-coded-admission",
    "title": "Coded matmul admission",
    "purpose": "Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first.",
    "fields": [
      {
        "name": "version",
        "kind": "number",
        "means": "the protocol version that leads the request"
      },
      {
        "name": "m",
        "kind": "number",
        "means": "rows of A and of the result"
      },
      {
        "name": "k",
        "kind": "number",
        "means": "columns of A and stored rows of B"
      },
      {
        "name": "n",
        "kind": "number",
        "means": "columns of B and of the result"
      },
      {
        "name": "shape",
        "kind": "choice",
        "values": [
          "conformant",
          "mismatched"
        ],
        "means": "whether A has m*k entries and B-codes has k*n codes"
      },
      {
        "name": "tier",
        "kind": "choice",
        "values": [
          "binary",
          "ternary",
          "signed8",
          "full8",
          "other"
        ],
        "means": "the scalar codec tier named after the operation"
      },
      {
        "name": "code",
        "kind": "number",
        "means": "the largest stored code in B-codes"
      }
    ],
    "outcomes": [
      "ok",
      "unsupported-version",
      "invalid-dimension",
      "shape-mismatch",
      "unknown-tier",
      "invalid-code"
    ],
    "meanings": {
      "ok": "the codes are decoded and the exact product is returned as 1 ok rows columns cells",
      "unsupported-version": "the request does not begin with version 1 and nothing is computed",
      "invalid-dimension": "a dimension is above the modeled maximum of 8 and nothing is allocated",
      "shape-mismatch": "A or B-codes does not have the entry count its dimensions declare",
      "unknown-tier": "the tier is not binary, ternary, signed8 or full8",
      "invalid-code": "a stored code is outside the range its tier decodes"
    },
    "rules": [
      {
        "when": [
          {
            "field": "version",
            "op": "!=",
            "value": 1
          }
        ],
        "then": "unsupported-version",
        "why": "PROTOCOL.md and src/Protocol.lex.tex: every request begins with 1; any other version is ProtocolError.UnsupportedVersion"
      },
      {
        "when": [
          {
            "field": "m",
            "op": ">",
            "value": 8
          }
        ],
        "then": "invalid-dimension",
        "why": "src/Model.lex.tex maximumDimension is 8; Protocol.lex.tex answers InvalidDimension before parsing matrices"
      },
      {
        "when": [
          {
            "field": "k",
            "op": ">",
            "value": 8
          }
        ],
        "then": "invalid-dimension",
        "why": "src/Model.lex.tex maximumDimension is 8 for k as for m and n"
      },
      {
        "when": [
          {
            "field": "n",
            "op": ">",
            "value": 8
          }
        ],
        "then": "invalid-dimension",
        "why": "src/Model.lex.tex maximumDimension is 8 for n as for m and k"
      },
      {
        "when": [
          {
            "field": "shape",
            "op": "is",
            "value": "mismatched"
          }
        ],
        "then": "shape-mismatch",
        "why": "src/Protocol.lex.tex compares a.length with m*k and b.length with k*n before the tier is read"
      },
      {
        "when": [
          {
            "field": "tier",
            "op": "is",
            "value": "other"
          }
        ],
        "then": "unknown-tier",
        "why": "src/Protocol.lex.tex validTier accepts exactly binary, ternary, signed8 and full8"
      },
      {
        "when": [
          {
            "field": "tier",
            "op": "is",
            "value": "binary"
          },
          {
            "field": "code",
            "op": ">",
            "value": 1
          }
        ],
        "then": "invalid-code",
        "why": "src/Core.lex.tex validCode: binary codes 0,1 decode to -1,+1"
      },
      {
        "when": [
          {
            "field": "tier",
            "op": "is",
            "value": "ternary"
          },
          {
            "field": "code",
            "op": ">",
            "value": 2
          }
        ],
        "then": "invalid-code",
        "why": "src/Core.lex.tex validCode: ternary codes 0,1,2 decode to -1,0,+1"
      },
      {
        "when": [
          {
            "field": "tier",
            "op": "is",
            "value": "signed8"
          },
          {
            "field": "code",
            "op": ">",
            "value": 255
          }
        ],
        "then": "invalid-code",
        "why": "src/Core.lex.tex validCode: signed8 codes are bytes 0..255 read as two complement"
      },
      {
        "when": [
          {
            "field": "tier",
            "op": "is",
            "value": "full8"
          },
          {
            "field": "code",
            "op": ">",
            "value": 255
          }
        ],
        "then": "invalid-code",
        "why": "src/Core.lex.tex validCode: full8 codes are bytes 0..255"
      }
    ],
    "otherwise": "ok",
    "otherwiseWhy": "version 1, every dimension at most 8, conformant shapes, a known tier and in-range codes: decode the code, accumulate exactly, encode once",
    "properties": [
      {
        "kind": "never",
        "when": [
          {
            "field": "m",
            "op": ">",
            "value": 8
          }
        ],
        "then": "ok",
        "why": "ERRORS.md: InvalidDimension has seven negative vectors; no product is computed above the dimension bound"
      },
      {
        "kind": "never",
        "when": [
          {
            "field": "tier",
            "op": "is",
            "value": "binary"
          },
          {
            "field": "code",
            "op": ">",
            "value": 1
          }
        ],
        "then": "ok",
        "why": "src/Core.lex.tex: a binary code above 1 is never decoded"
      },
      {
        "kind": "always",
        "when": [
          {
            "field": "version",
            "op": "!=",
            "value": 1
          }
        ],
        "then": "unsupported-version",
        "why": "the version is checked before any other field"
      },
      {
        "kind": "always",
        "when": [
          {
            "field": "version",
            "op": "=",
            "value": 1
          },
          {
            "field": "m",
            "op": "<=",
            "value": 8
          },
          {
            "field": "k",
            "op": "<=",
            "value": 8
          },
          {
            "field": "n",
            "op": "<=",
            "value": 8
          },
          {
            "field": "shape",
            "op": "is",
            "value": "conformant"
          },
          {
            "field": "tier",
            "op": "is",
            "value": "other"
          }
        ],
        "then": "unknown-tier",
        "why": "an unknown tier is reported as such, never as an invalid code"
      }
    ],
    "examples": [
      {
        "request": "1 1 3 1 conformant ternary 2",
        "response": "ok"
      },
      {
        "request": "1 2 2 2 conformant full8 255",
        "response": "ok"
      },
      {
        "request": "2 2 2 2 conformant binary 0",
        "response": "unsupported-version"
      },
      {
        "request": "1 9 2 2 conformant binary 1",
        "response": "invalid-dimension"
      },
      {
        "request": "1 2 2 2 mismatched binary 0",
        "response": "shape-mismatch"
      },
      {
        "request": "1 2 2 2 conformant other 0",
        "response": "unknown-tier"
      },
      {
        "request": "1 1 1 1 conformant binary 2",
        "response": "invalid-code"
      }
    ]
  },
  "stakeholders": [
    {
      "name": "Numerical researcher",
      "text": "Runs coded and quantized products in the workbench and needs every rejected request to name the error the source declares.",
      "concerns": [
        "Correct answers",
        "Proved guarantees"
      ]
    },
    {
      "name": "Integrator",
      "text": "Calls the generated native library or Core-Wasm guest and needs out-of-range dimensions and codes refused before any allocation.",
      "concerns": [
        "Refused malformed requests",
        "Bounded allocation"
      ]
    }
  ],
  "concerns": [
    {
      "name": "Bounded allocation",
      "text": "No request with a dimension above 8 or an undecodable code reaches matrix allocation or decoding.",
      "model": "security"
    }
  ],
  "components": [
    {
      "name": "LexLean Matmul workbench",
      "text": "The research workbench on GitHub Pages that sends version 1 protocol requests from a browser worker.",
      "kind": "staticSite"
    },
    {
      "name": "Independent arithmetic oracles",
      "text": "The reference UOR matmul oracles the just vv gate replays native and Wasm results against.",
      "kind": "externalSystem"
    }
  ],
  "threats": [
    {
      "name": "Oversized dimension",
      "text": "A request declares a dimension above 8 to force a large allocation in the guest.",
      "stride": "denialOfService",
      "asset": "request",
      "likelihood": "medium",
      "impact": "major",
      "control": {
        "name": "Dimension bound first",
        "text": "Dimensions are checked against maximumDimension before matrices are parsed or allocated.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "MatmulCodedAdmissionProofs::inv001Holds"
          },
          {
            "kind": "gate",
            "reference": "just vv"
          }
        ]
      }
    },
    {
      "name": "Out-of-book code",
      "text": "A stored code outside its tier is decoded into a value the tier does not define, changing the product.",
      "stride": "tampering",
      "asset": "answer",
      "likelihood": "medium",
      "impact": "major",
      "control": {
        "name": "Tier code range",
        "text": "Each tier admits only the codes validCode accepts, and a binary code above 1 is never computed.",
        "evidence": [
          {
            "kind": "proof",
            "reference": "MatmulCodedAdmissionProofs::inv002Holds"
          },
          {
            "kind": "gate",
            "reference": "just vv"
          }
        ]
      }
    },
    {
      "name": "Misreported shape",
      "text": "A caller reports a conformant shape for matrices whose entry counts do not match.",
      "stride": "spoofing",
      "asset": "request",
      "likelihood": "low",
      "impact": "minor",
      "accepted": "The app decides from the shape it is given; counting entries belongs to the protocol parser in src/Protocol.lex.tex, whose ten shape-mismatch vectors cover it."
    }
  ],
  "quality": [
    {
      "characteristic": "Functional suitability",
      "subcharacteristic": "Functional completeness",
      "requirement": "Every modeled error is reachable",
      "text": "Each of the five protocol errors the coded operation can return is the answer to some request.",
      "measure": "Unreachable outcomes",
      "measureText": "Outcomes of the spec that no request answers.",
      "threshold": 0
    },
    {
      "characteristic": "Interaction capability",
      "subcharacteristic": "User error protection",
      "requirement": "No silent acceptance",
      "text": "A request with an out-of-range dimension or code is never computed.",
      "measure": "Accepted invalid requests",
      "measureText": "Requests above the dimension bound or out of code range that answer ok.",
      "threshold": 0
    }
  ],
  "journeys": [
    {
      "stakeholder": "Numerical researcher",
      "steps": [
        "REQ-005",
        "REQ-006",
        "REQ-008",
        "INV-002",
        "otherwise"
      ]
    },
    {
      "stakeholder": "Integrator",
      "steps": [
        "refuse",
        "REQ-001",
        "REQ-002",
        "INV-001",
        "INV-003"
      ]
    }
  ],
  "axioms": {
    "inv002Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ],
    "inv003Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ],
    "inv004Holds": [
      "Classical.choice",
      "Quot.sound",
      "propext"
    ]
  },
  "license": "MIT OR Apache-2.0"
}
```

## Claims

- MC-01: The app never answers ok when m is above 8
- MC-02: The app never answers ok when tier is binary and code is above 1
- MC-03: The app always answers unsupported-version when version differs from 1
- MC-04: The app always answers unknown-tier when version equals 1 and m is at most 8 and k is at most 8 and n is at most 8 and shape is conformant and tier is other
- MC-05: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
- MC-06: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
- MC-07: Every compliance obligation is numbered in order and names its evidence

## Pattern

Decision table: OMG DMN 1.5, hit policy FIRST. The rules are tried in order, and the first one that matches gives the answer. If none matches, the default answer applies. This is a DMN decision table with the FIRST hit policy.

| Pattern | Standard | Answers |
| --- | --- | --- |
| Decision table | OMG DMN 1.5, hit policy FIRST | ok, unsupported-version, invalid-dimension, shape-mismatch, unknown-tier, invalid-code |

**Figure: Rules for each answer.** Each bar counts the rules that give one answer. When no rule matches, the answer is ok.

|  | rules |
| --- | --- |
| ok | 0 |
| unsupported-version | 1 |
| invalid-dimension | 3 |
| shape-mismatch | 1 |
| unknown-tier | 1 |
| invalid-code | 4 |

## Behavior

A request is version, m, k, n, shape, tier, code, separated by spaces. The first rule that matches decides. If none matches, the answer is ok. A request over 184 bytes, or in any other form, is answered invalid.

| Rule | When | Answer | Why |
| --- | --- | --- | --- |
| REQ-001 | version differs from 1 | unsupported-version | PROTOCOL.md and src/Protocol.lex.tex: every request begins with 1; any other version is ProtocolError.UnsupportedVersion |
| REQ-002 | m is above 8 | invalid-dimension | src/Model.lex.tex maximumDimension is 8; Protocol.lex.tex answers InvalidDimension before parsing matrices |
| REQ-003 | k is above 8 | invalid-dimension | src/Model.lex.tex maximumDimension is 8 for k as for m and n |
| REQ-004 | n is above 8 | invalid-dimension | src/Model.lex.tex maximumDimension is 8 for n as for m and k |
| REQ-005 | shape is mismatched | shape-mismatch | src/Protocol.lex.tex compares a.length with m\*k and b.length with k\*n before the tier is read |
| REQ-006 | tier is other | unknown-tier | src/Protocol.lex.tex validTier accepts exactly binary, ternary, signed8 and full8 |
| REQ-007 | tier is binary and code is above 1 | invalid-code | src/Core.lex.tex validCode: binary codes 0,1 decode to -1,+1 |
| REQ-008 | tier is ternary and code is above 2 | invalid-code | src/Core.lex.tex validCode: ternary codes 0,1,2 decode to -1,0,+1 |
| REQ-009 | tier is signed8 and code is above 255 | invalid-code | src/Core.lex.tex validCode: signed8 codes are bytes 0..255 read as two complement |
| REQ-010 | tier is full8 and code is above 255 | invalid-code | src/Core.lex.tex validCode: full8 codes are bytes 0..255 |
| otherwise | no rule matches | ok | version 1, every dimension at most 8, conformant shapes, a known tier and in-range codes: decode the code, accumulate exactly, encode once |

## Properties Lean proves

Each property is a theorem about the same definitions the app is built from. It is proved for every request, not only the tested ones.

| Property | Statement | Theorem | Why |
| --- | --- | --- | --- |
| INV-001 | It never answers ok when m is above 8. | MatmulCodedAdmissionProofs::inv001Holds | ERRORS.md: InvalidDimension has seven negative vectors; no product is computed above the dimension bound |
| INV-002 | It never answers ok when tier is binary and code is above 1. | MatmulCodedAdmissionProofs::inv002Holds | src/Core.lex.tex: a binary code above 1 is never decoded |
| INV-003 | It always answers unsupported-version when version differs from 1. | MatmulCodedAdmissionProofs::inv003Holds | the version is checked before any other field |
| INV-004 | It always answers unknown-tier when version equals 1 and m is at most 8 and k is at most 8 and n is at most 8 and shape is conformant and tier is other. | MatmulCodedAdmissionProofs::inv004Holds | an unknown tier is reported as such, never as an invalid code |

## Architecture

Stakeholders and the concerns each one views the app through (ISO/IEC/IEEE 42010).

| Stakeholder | Who they are | Concerns |
| --- | --- | --- |
| Integrator | Calls the generated native library or Core-Wasm guest and needs out-of-range dimensions and codes refused before any allocation. | Refused malformed requests, Bounded allocation |
| Numerical researcher | Runs coded and quantized products in the workbench and needs every rejected request to name the error the source declares. | Correct answers, Proved guarantees |
| Verifier | Anyone who loads the holo, checks its fingerprint and replays its acceptance vectors before trusting an answer. | Integrity of the published app, Refused malformed requests, Proved guarantees |

## Concerns

What the stakeholders care about, and the model each is viewed in.

| Concern | What it means | Model |
| --- | --- | --- |
| Bounded allocation | No request with a dimension above 8 or an undecodable code reaches matrix allocation or decoding. | security |
| Correct answers | Every well-formed request is answered by the first rule that matches it, or ok when none does, as the spec states. | quality |
| Integrity of the published app | What a visitor runs is the holo the build verified, with its fingerprint and signed provenance beside it. | security |
| Proved guarantees | Each of the 4 properties of the spec holds for every request, proved by the Lean kernel. | quality |
| Refused malformed requests | A request that is not the 7 fields in order, or is longer than 184 bytes, is answered invalid and never guessed. | security |

## Components

8 components and 11 edges between them.

| Component | Kind | What it is |
| --- | --- | --- |
| Browser | externalSystem | The visitor's web browser, which loads the page and runs the Coded matmul admission guest. |
| Coded matmul admission guest | service | The Core-Wasm guest built from the model: it answers one request of at most 184 bytes with one answer of at most 64. |
| Coded matmul admission page | staticSite | The page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors. |
| GitHub Pages | externalSystem | Serves the page and the holo from the repository Pages workflow. |
| Independent arithmetic oracles | externalSystem | The reference UOR matmul oracles the just vv gate replays native and Wasm results against. |
| LexLean Matmul workbench | staticSite | The research workbench on GitHub Pages that sends version 1 protocol requests from a browser worker. |
| Prism build | cliAdapter | prismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector. |
| Source repository | externalSystem | The repository that holds the prompt, the model and its gate. |

## Design views

The SDK checks each view against the system model and draws it as OPL and PlantUML.

| View | Diagram | Viewpoint |
| --- | --- | --- |
| Deciding a Coded matmul admission request | opmObjectProcess | Numerical researcher: Correct answers |
| Components of Coded matmul admission | umlComponent | Verifier: Integrity of the published app |
| Answering a Coded matmul admission request | umlSequence | Numerical researcher: Correct answers |
| States of the Coded matmul admission guest | umlStateMachine | Integrator: Refused malformed requests |

## Features and journeys

16 features. Each names the definitions that do the work and the tests that accept it. Each stakeholder has one journey.

| Feature | Calls | Accepted by |
| --- | --- | --- |
| When version differs from 1, the answer is unsupported-version. | MatmulCodedAdmission::rule1, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When m is above 8, the answer is invalid-dimension. | MatmulCodedAdmission::rule2, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When k is above 8, the answer is invalid-dimension. | MatmulCodedAdmission::rule3, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When n is above 8, the answer is invalid-dimension. | MatmulCodedAdmission::rule4, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When shape is mismatched, the answer is shape-mismatch. | MatmulCodedAdmission::rule5, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When tier is other, the answer is unknown-tier. | MatmulCodedAdmission::rule6, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When tier is binary and code is above 1, the answer is invalid-code. | MatmulCodedAdmission::rule7, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When tier is ternary and code is above 2, the answer is invalid-code. | MatmulCodedAdmission::rule8, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When tier is signed8 and code is above 255, the answer is invalid-code. | MatmulCodedAdmission::rule9, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When tier is full8 and code is above 255, the answer is invalid-code. | MatmulCodedAdmission::rule10, MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| When no rule matches, the answer is ok. | MatmulCodedAdmission::judge | MatmulCodedAdmission::application |
| A request that is not version, m, k, n, shape, tier, code in order, separated by single spaces, or is over 184 bytes, is answered invalid. | MatmulCodedAdmission::dispatch, MatmulCodedAdmission::decodeField1 | MatmulCodedAdmission::application |
| It never answers ok when m is above 8. | MatmulCodedAdmission::judge | MatmulCodedAdmissionProofs::inv001Holds |
| It never answers ok when tier is binary and code is above 1. | MatmulCodedAdmission::judge | MatmulCodedAdmissionProofs::inv002Holds |
| It always answers unsupported-version when version differs from 1. | MatmulCodedAdmission::judge | MatmulCodedAdmissionProofs::inv003Holds |
| It always answers unknown-tier when version equals 1 and m is at most 8 and k is at most 8 and n is at most 8 and shape is conformant and tier is other. | MatmulCodedAdmission::judge | MatmulCodedAdmissionProofs::inv004Holds |

## Journeys

The ordered features each stakeholder takes.

| Stakeholder | Steps |
| --- | --- |
| Integrator | refuse → REQ-001 → REQ-002 → INV-001 → INV-003 |
| Numerical researcher | REQ-005 → REQ-006 → REQ-008 → INV-002 → otherwise |
| Verifier | refuse → INV-001 → INV-002 → INV-003 → INV-004 |

## Security and threat model

13 threats against 4 assets. Each has a STRIDE category, and either a control with evidence or a risk that is accepted on purpose.

| Threat | STRIDE | Asset | Risk | Answered by |
| --- | --- | --- | --- | --- |
| Answer that breaks INV-001 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-001: proof MatmulCodedAdmissionProofs::inv001Holds |
| Answer that breaks INV-002 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-002: proof MatmulCodedAdmissionProofs::inv002Holds |
| Answer that breaks INV-003 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-003: proof MatmulCodedAdmissionProofs::inv003Holds |
| Answer that breaks INV-004 | repudiation | Answer | medium likelihood, critical impact | Proof of INV-004: proof MatmulCodedAdmissionProofs::inv004Holds |
| Granted capability | informationDisclosure | Answer | low likelihood, major impact | No capability granted: gate prism-code check refuses an ungranted guest import |
| Malformed request | tampering | Request bytes | high likelihood, major impact | Strict decoder: gate malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify |
| Misreported shape | spoofing | Request bytes | low likelihood, minor impact | accepted: The app decides from the shape it is given; counting entries belongs to the protocol parser in src/Protocol.lex.tex, whose ten shape-mismatch vectors cover it. |
| Out-of-book code | tampering | Answer | medium likelihood, major impact | Tier code range: proof MatmulCodedAdmissionProofs::inv002Holds; gate just vv |
| Oversized dimension | denialOfService | Request bytes | medium likelihood, major impact | Dimension bound first: proof MatmulCodedAdmissionProofs::inv001Holds; gate just vv |
| Oversized request | denialOfService | Request bytes | medium likelihood, minor impact | Bounded request: gate acceptance vectors at the request bound, one byte over it, and at the guest allocation bound, replayed by prismpm verify |
| Substituted holo | spoofing | Published holo | low likelihood, critical impact | Fingerprint and provenance: gate actions/attest-build-provenance in the pages workflow; gate prism-code check of the holo identities in the page |
| Substituted host | spoofing | Published holo | low likelihood, critical impact | accepted: A page cannot defend against its own host. The holo carries signed build provenance a visitor can check, and the app can be rebuilt from its prompt. |
| Tampered model | tampering | Model source | low likelihood, major impact | Regenerated from the prompt: gate prismpm verify in the SDK image prismpm.lock pins; review app/prompt.json |

## Quality

ISO/IEC 25010:2023 requirements. Each has a measure and a threshold that a theorem pins.

| Requirement | Characteristic | Measure | Threshold |
| --- | --- | --- | --- |
| Bounded allocation: The guest allocates at most 368 bytes for one request. | Performance efficiency: Resource utilization | Guest allocation bytes | 368 |
| Bounded request: A request over 184 bytes is refused before any field is read. | Performance efficiency: Time behaviour | Request bytes read | 184 |
| Every modeled error is reachable: Each of the five protocol errors the coded operation can return is the answer to some request. | Functional suitability: Functional completeness | Unreachable outcomes | 0 |
| Every property proved: All 4 properties are theorems the Lean kernel checks. | Security: Integrity | Unproved properties | 0 |
| Every request answered: Every request gets an answer: a rule, ok otherwise, or invalid. | Functional suitability: Functional completeness | Unanswered requests | 0 |
| Every vector replays: All 71 acceptance vectors replay in the compiled guest, the shortest 0 bytes long. | Reliability: Faultlessness | Failed vectors | 0 |
| Examples answered as stated: Every one of the 7 examples of the spec is answered as it states. | Functional suitability: Functional correctness | Example mismatches | 0 |
| No silent acceptance: A request with an out-of-range dimension or code is never computed. | Interaction capability: User error protection | Accepted invalid requests | 0 |

## Compliance

One obligation per standard, each naming its evidence.

| Standard | Subject | Evidence |
| --- | --- | --- |
| ISO/IEC/IEEE 42010:2022 | Architecture description | Architecture::architectureDescriptionHolds |
| ISO/PAS 19450:2015 and OMG UML 2.5.1 | Design views | Design::viewOpmDecide, Design::viewUmlComponents, Design::viewUmlRequest, Design::viewUmlStates |
| ISO/IEC 25010:2023 | Product quality | Quality::qualityModelHolds |
| ISO/IEC 27034-1:2011 and ISO/IEC 27005:2022 | Application security and risk | Security::controlSet |
| OMG DMN 1.5, hit policy FIRST | Decision table | MatmulCodedAdmission::judge |
| OpenSpec | Requirements | MatmulCodedAdmission::application |
| SPDX MIT OR Apache-2.0 | Licensing | MatmulCodedAdmission::application |

## Rendered design views

Written by the SDK from the design records when it verified the app.

### design/Design.viewOpmDecide.opl

```
View: Design::viewOpmDecide
Title: Deciding a Coded matmul admission request
Viewpoint: Architecture::viewpointNumericalResearcherCorrectAnswers
Notation: ISO/PAS 19450:2015 OPM, Prism OPL profile

componentBrowser is an object.
componentCodedMatmulAdmissionGuest is an object.
componentCodedMatmulAdmissionGuest can be stateDeciding or stateIdle.
processDecide is a process.
processEncodeAnswer is a process.
processJudge is a process.
processParseRequest is a process.
componentCodedMatmulAdmissionGuest handles processDecide.
processParseRequest requires componentBrowser.
processEncodeAnswer affects componentBrowser.
processJudge invokes processEncodeAnswer.
processParseRequest invokes processJudge.
processDecide zooms into processParseRequest, processJudge, and processEncodeAnswer, in that sequence.

```

### design/Design.viewUmlComponents.puml

```
@startuml
' UML 2.5.1 component diagram
' view: Design::viewUmlComponents
' viewpoint: Architecture::viewpointVerifierIntegrityOfThePublishedApp
title Components of Coded matmul admission
component "componentBrowser" as c0
component "componentCodedMatmulAdmissionGuest" as c1
component "componentCodedMatmulAdmissionPage" as c2
component "componentGitHubPages" as c3
component "componentIndependentArithmeticOracles" as c4
component "componentLexLeanMatmulWorkbench" as c5
component "componentPrismBuild" as c6
component "componentSourceRepository" as c7
c0 --> c1 : edgeBrowserToCodedMatmulAdmissionGuest
c1 --> c0 : edgeCodedMatmulAdmissionGuestToBrowser
c1 --> c4 : edgeCodedMatmulAdmissionGuestToIndependentArithmeticOracles
c1 --> c5 : edgeCodedMatmulAdmissionGuestToLexLeanMatmulWorkbench
c2 --> c3 : edgeCodedMatmulAdmissionPageToGitHubPages
c3 --> c0 : edgeGitHubPagesToBrowser
c4 --> c1 : edgeIndependentArithmeticOraclesToCodedMatmulAdmissionGuest
c5 --> c1 : edgeLexLeanMatmulWorkbenchToCodedMatmulAdmissionGuest
c6 --> c1 : edgePrismBuildToCodedMatmulAdmissionGuest
c6 --> c2 : edgePrismBuildToCodedMatmulAdmissionPage
c7 --> c6 : edgeSourceRepositoryToPrismBuild
@enduml

```

### design/Design.viewUmlRequest.puml

```
@startuml
' UML 2.5.1 sequence diagram
' view: Design::viewUmlRequest
' viewpoint: Architecture::viewpointNumericalResearcherCorrectAnswers
title Answering a Coded matmul admission request
participant "componentBrowser" as p0
participant "componentCodedMatmulAdmissionGuest" as p1
p0 -> p1 : processDecide
p1 --> p0 : processDecide
@enduml

```

### design/Design.viewUmlStates.puml

```
@startuml
' UML 2.5.1 state machine diagram
' view: Design::viewUmlStates
' viewpoint: Architecture::viewpointIntegratorRefusedMalformedRequests
title States of the Coded matmul admission guest
state "stateAnsweredInvalidCode" as s0
state "stateAnsweredInvalidDimension" as s1
state "stateAnsweredOk" as s2
state "stateAnsweredShapeMismatch" as s3
state "stateAnsweredUnknownTier" as s4
state "stateAnsweredUnsupportedVersion" as s5
state "stateDeciding" as s6
state "stateIdle" as s7
state "stateRefused" as s8
[*] --> s7
s7 --> s6 : processParseRequest
s7 --> s8 : processParseRequest
s6 --> s5 : processRule1
s6 --> s1 : processRule2
s6 --> s1 : processRule3
s6 --> s1 : processRule4
s6 --> s3 : processRule5
s6 --> s4 : processRule6
s6 --> s0 : processRule7
s6 --> s0 : processRule8
s6 --> s0 : processRule9
s6 --> s0 : processRule10
s6 --> s2 : processOtherwise
s2 --> s7 : processEncodeAnswer
s5 --> s7 : processEncodeAnswer
s1 --> s7 : processEncodeAnswer
s3 --> s7 : processEncodeAnswer
s4 --> s7 : processEncodeAnswer
s0 --> s7 : processEncodeAnswer
s8 --> s7 : processEncodeAnswer
@enduml

```

## Prism source

Every file the builder wrote, laid out as a repository created from UOR-Foundation/template; the download prism-matmul-coded-admission.zip has them all.

- app/src/Architecture.lex.tex (413 lines)
- app/src/Compliance.lex.tex (56 lines)
- app/src/Design.lex.tex (696 lines)
- app/src/Features.lex.tex (172 lines)
- app/src/Quality.lex.tex (382 lines)
- app/src/Security.lex.tex (593 lines)
- app/src/MatmulCodedAdmission.lex.tex (299 lines)
- app/src/MatmulCodedAdmissionProofs.lex.tex (181 lines)
- app/lexlean.toml (43 lines)
- app/prompt.json (472 lines)
- model/ids.toml (65 lines)
- features/suites/matmul\_coded\_admission.feature (44 lines)
- crates/conformance/tests/matmul\_coded\_admission.rs (132 lines)
- site/app.json (116 lines)
- openspec/specs/matmul-coded-admission/spec.md (244 lines)
