Examples: Coded matmul admission
Overview
Example appsDecision tables
Rule 30 cellStrike dieWise deferralCurrent supportHeader workPlant attunementCapability routePublish gateProposal admissionCompression admissionQuorum commitAddress admissionDataflow policyDraft admissionCoded matmul admissionUTQC row honestyCalculator protocolRequantization clampJCS NFC admissionTwo-seed barDocs sync// example · Decision tables
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 (live). 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.
The data in this figure
| 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 |
- Fingerprint
b32ced10969d6575574d575c7874bc3c3dcf82049267ac4486c42fcc6c375b66- Acceptance vectors
- 71
- Claims
- 7
Verified by prismpm verify in the pinned SDK when this site was built.
The prompt
This is the whole input. Raw JSON · Open it in the builder · Download the app (.zip)
The prompt 471 lines
{
"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"
}What the app claims
Each claim is a row in model/ids.toml, a scenario and a test, and a theorem the Lean kernel checks. The claims are quoted as the model states them.
MC-01The app never answers ok when m is above 8MC-02The app never answers ok when tier is binary and code is above 1MC-03The app always answers unsupported-version when version differs from 1MC-04The 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 otherMC-05The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it referencesMC-06The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declaredMC-07Every 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 |
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.
Behavior 11 rows
| 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.
Properties Lean proves 4 rows
| 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.
Features and journeys 16 rows
| 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.
Security and threat model 13 rows
| 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.
Quality 8 rows
| 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 language packages and Foundation modules every app shares are in the download.
app/src/Architecture.lex.tex 413 lines
\begin{lexlean}{Architecture}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Foundation.Arch}
\title{architectural component}
\begin{semanticmodule}
definition{
name: standardIso25010,
parameters: [],
result: Foundation.Arch::StandardReference,
body: (record Foundation.Arch::StandardReference {standardIndex := 0, editionIndex := 0, standardId := "ISO-25010-2023", edition := "2023"})
}
definition{
name: standardIso27005,
parameters: [],
result: Foundation.Arch::StandardReference,
body: (record Foundation.Arch::StandardReference {standardIndex := 1, editionIndex := 0, standardId := "ISO-27005-2022", edition := "2022"})
}
definition{
name: standardIso27034,
parameters: [],
result: Foundation.Arch::StandardReference,
body: (record Foundation.Arch::StandardReference {standardIndex := 2, editionIndex := 0, standardId := "ISO-27034-1-2011", edition := "2011"})
}
definition{
name: standardIso42010,
parameters: [],
result: Foundation.Arch::StandardReference,
body: (record Foundation.Arch::StandardReference {standardIndex := 4, editionIndex := 0, standardId := "ISO-42010-2022", edition := "2022"})
}
definition{
name: stakeholderIntegrator,
parameters: [],
result: Foundation.Arch::Stakeholder,
body: (record Foundation.Arch::Stakeholder {index := 0, name := "Integrator", text := "Calls the generated native library or Core-Wasm guest and needs out-of-range dimensions and codes refused before any allocation."})
}
definition{
name: stakeholderNumericalResearcher,
parameters: [],
result: Foundation.Arch::Stakeholder,
body: (record Foundation.Arch::Stakeholder {index := 1, name := "Numerical researcher", text := "Runs coded and quantized products in the workbench and needs every rejected request to name the error the source declares."})
}
definition{
name: stakeholderVerifier,
parameters: [],
result: Foundation.Arch::Stakeholder,
body: (record Foundation.Arch::Stakeholder {index := 2, name := "Verifier", text := "Anyone who loads the holo, checks its fingerprint and replays its acceptance vectors before trusting an answer."})
}
definition{
name: concernBoundedAllocation,
parameters: [],
result: Foundation.Arch::Concern,
body: (record Foundation.Arch::Concern {index := 0, name := "Bounded allocation", text := "No request with a dimension above 8 or an undecodable code reaches matrix allocation or decoding."})
}
definition{
name: concernCorrectAnswers,
parameters: [],
result: Foundation.Arch::Concern,
body: (record Foundation.Arch::Concern {index := 1, name := "Correct answers", text := "Every well-formed request is answered by the first rule that matches it, or ok when none does, as the spec states."})
}
definition{
name: concernIntegrityOfThePublishedApp,
parameters: [],
result: Foundation.Arch::Concern,
body: (record Foundation.Arch::Concern {index := 2, name := "Integrity of the published app", text := "What a visitor runs is the holo the build verified, with its fingerprint and signed provenance beside it."})
}
definition{
name: concernProvedGuarantees,
parameters: [],
result: Foundation.Arch::Concern,
body: (record Foundation.Arch::Concern {index := 3, name := "Proved guarantees", text := "Each of the 4 properties of the spec holds for every request, proved by the Lean kernel."})
}
definition{
name: concernRefusedMalformedRequests,
parameters: [],
result: Foundation.Arch::Concern,
body: (record Foundation.Arch::Concern {index := 4, name := "Refused malformed requests", text := "A request that is not the 7 fields in order, or is longer than 184 bytes, is answered invalid and never guessed."})
}
definition{
name: componentBrowser,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 0, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "Browser", text := "The visitor's web browser, which loads the page and runs the Coded matmul admission guest."})
}
definition{
name: componentCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 1, kind := (ctor Foundation.Arch::ComponentKind.service), name := "Coded matmul admission guest", text := "The Core-Wasm guest built from the model: it answers one request of at most 184 bytes with one answer of at most 64."})
}
definition{
name: componentCodedMatmulAdmissionPage,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 2, kind := (ctor Foundation.Arch::ComponentKind.staticSite), name := "Coded matmul admission page", text := "The page the template publishes: the holo, its fingerprint, its provenance and its acceptance vectors."})
}
definition{
name: componentGitHubPages,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 3, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "GitHub Pages", text := "Serves the page and the holo from the repository Pages workflow."})
}
definition{
name: componentIndependentArithmeticOracles,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 4, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "Independent arithmetic oracles", text := "The reference UOR matmul oracles the just vv gate replays native and Wasm results against."})
}
definition{
name: componentLexLeanMatmulWorkbench,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 5, kind := (ctor Foundation.Arch::ComponentKind.staticSite), name := "LexLean Matmul workbench", text := "The research workbench on GitHub Pages that sends version 1 protocol requests from a browser worker."})
}
definition{
name: componentPrismBuild,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 6, kind := (ctor Foundation.Arch::ComponentKind.cliAdapter), name := "Prism build", text := "prismpm verify in the SDK image prismpm.lock pins: it checks every theorem, builds the guest and replays every vector."})
}
definition{
name: componentSourceRepository,
parameters: [],
result: Foundation.Arch::Component,
body: (record Foundation.Arch::Component {index := 7, kind := (ctor Foundation.Arch::ComponentKind.externalSystem), name := "Source repository", text := "The repository that holds the prompt, the model and its gate."})
}
definition{
name: edgeBrowserToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 0, fromIndex := 0, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeCodedMatmulAdmissionGuestToBrowser,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 1, fromIndex := 1, toIndex := 0, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeCodedMatmulAdmissionGuestToIndependentArithmeticOracles,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 2, fromIndex := 1, toIndex := 4, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeCodedMatmulAdmissionGuestToLexLeanMatmulWorkbench,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 3, fromIndex := 1, toIndex := 5, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeCodedMatmulAdmissionPageToGitHubPages,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 4, fromIndex := 2, toIndex := 3, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeGitHubPagesToBrowser,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 5, fromIndex := 3, toIndex := 0, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeIndependentArithmeticOraclesToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 6, fromIndex := 4, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeLexLeanMatmulWorkbenchToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 7, fromIndex := 5, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgePrismBuildToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 8, fromIndex := 6, toIndex := 1, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgePrismBuildToCodedMatmulAdmissionPage,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 9, fromIndex := 6, toIndex := 2, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: edgeSourceRepositoryToPrismBuild,
parameters: [],
result: Foundation.Arch::Edge,
body: (record Foundation.Arch::Edge {index := 10, fromIndex := 7, toIndex := 6, kind := (ctor Foundation.Arch::EdgeKind.dataFlow)})
}
definition{
name: viewpointIntegratorBoundedAllocation,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 0, stakeholderIndex := 0, concernIndex := 0, modelKindIndex := 2})
}
definition{
name: viewpointIntegratorRefusedMalformedRequests,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 1, stakeholderIndex := 0, concernIndex := 4, modelKindIndex := 2})
}
definition{
name: viewpointNumericalResearcherCorrectAnswers,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 2, stakeholderIndex := 1, concernIndex := 1, modelKindIndex := 1})
}
definition{
name: viewpointNumericalResearcherProvedGuarantees,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 3, stakeholderIndex := 1, concernIndex := 3, modelKindIndex := 1})
}
definition{
name: viewpointVerifierIntegrityOfThePublishedApp,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 4, stakeholderIndex := 2, concernIndex := 2, modelKindIndex := 2})
}
definition{
name: viewpointVerifierProvedGuarantees,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 5, stakeholderIndex := 2, concernIndex := 3, modelKindIndex := 1})
}
definition{
name: viewpointVerifierRefusedMalformedRequests,
parameters: [],
result: Foundation.Arch::Viewpoint,
body: (record Foundation.Arch::Viewpoint {index := 6, stakeholderIndex := 2, concernIndex := 4, modelKindIndex := 2})
}
definition{
name: viewIntegratorBoundedAllocation,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 0, viewpointIndex := 0, modelKindIndex := 2})
}
definition{
name: viewIntegratorRefusedMalformedRequests,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 1, viewpointIndex := 1, modelKindIndex := 2})
}
definition{
name: viewNumericalResearcherCorrectAnswers,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 2, viewpointIndex := 2, modelKindIndex := 1})
}
definition{
name: viewNumericalResearcherProvedGuarantees,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 3, viewpointIndex := 3, modelKindIndex := 1})
}
definition{
name: viewVerifierIntegrityOfThePublishedApp,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 4, viewpointIndex := 4, modelKindIndex := 2})
}
definition{
name: viewVerifierProvedGuarantees,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 5, viewpointIndex := 5, modelKindIndex := 1})
}
definition{
name: viewVerifierRefusedMalformedRequests,
parameters: [],
result: Foundation.Arch::View,
body: (record Foundation.Arch::View {index := 6, viewpointIndex := 6, modelKindIndex := 2})
}
definition{
name: componentRecords,
parameters: [],
result: (List Foundation.Arch::Component),
body: (cons (componentBrowser) (cons (componentCodedMatmulAdmissionGuest) (cons (componentCodedMatmulAdmissionPage) (cons (componentGitHubPages) (cons (componentIndependentArithmeticOracles) (cons (componentLexLeanMatmulWorkbench) (cons (componentPrismBuild) (cons (componentSourceRepository) (nil Foundation.Arch::Component)))))))))
}
definition{
name: edgeRecords,
parameters: [],
result: (List Foundation.Arch::Edge),
body: (cons (edgeBrowserToCodedMatmulAdmissionGuest) (cons (edgeCodedMatmulAdmissionGuestToBrowser) (cons (edgeCodedMatmulAdmissionGuestToIndependentArithmeticOracles) (cons (edgeCodedMatmulAdmissionGuestToLexLeanMatmulWorkbench) (cons (edgeCodedMatmulAdmissionPageToGitHubPages) (cons (edgeGitHubPagesToBrowser) (cons (edgeIndependentArithmeticOraclesToCodedMatmulAdmissionGuest) (cons (edgeLexLeanMatmulWorkbenchToCodedMatmulAdmissionGuest) (cons (edgePrismBuildToCodedMatmulAdmissionGuest) (cons (edgePrismBuildToCodedMatmulAdmissionPage) (cons (edgeSourceRepositoryToPrismBuild) (nil Foundation.Arch::Edge))))))))))))
}
definition{
name: viewpointRecords,
parameters: [],
result: (List Foundation.Arch::Viewpoint),
body: (cons (viewpointIntegratorBoundedAllocation) (cons (viewpointIntegratorRefusedMalformedRequests) (cons (viewpointNumericalResearcherCorrectAnswers) (cons (viewpointNumericalResearcherProvedGuarantees) (cons (viewpointVerifierIntegrityOfThePublishedApp) (cons (viewpointVerifierProvedGuarantees) (cons (viewpointVerifierRefusedMalformedRequests) (nil Foundation.Arch::Viewpoint))))))))
}
definition{
name: viewRecords,
parameters: [],
result: (List Foundation.Arch::View),
body: (cons (viewIntegratorBoundedAllocation) (cons (viewIntegratorRefusedMalformedRequests) (cons (viewNumericalResearcherCorrectAnswers) (cons (viewNumericalResearcherProvedGuarantees) (cons (viewVerifierIntegrityOfThePublishedApp) (cons (viewVerifierProvedGuarantees) (cons (viewVerifierRefusedMalformedRequests) (nil Foundation.Arch::View))))))))
}
definition{
name: edgesKnown,
parameters: [count : Nat, records : (List Foundation.Arch::Edge)],
result: Bool,
body: (match records
| List.nil => true
| List.cons edge rest => (((project edge fromIndex) <? count) && (((project edge toIndex) <? count) && (edgesKnown count rest)))),
recursive_argument: records
}
definition{
name: viewpointsKnown,
parameters: [
stakeholderCount : Nat,
concernCount : Nat,
records : (List Foundation.Arch::Viewpoint)
],
result: Bool,
body: (match records
| List.nil => true
| List.cons viewpoint rest => (((project viewpoint stakeholderIndex) <? stakeholderCount) && (((project viewpoint concernIndex) <? concernCount) && (((project viewpoint modelKindIndex) <? 3) && (viewpointsKnown stakeholderCount concernCount rest))))),
recursive_argument: records
}
definition{
name: viewMatches,
parameters: [view : Foundation.Arch::View, viewpoints : (List Foundation.Arch::Viewpoint)],
result: Bool,
body: (match viewpoints
| List.nil => false
| List.cons viewpoint rest => ((((project viewpoint index) =? (project view viewpointIndex)) && ((project viewpoint modelKindIndex) =? (project view modelKindIndex))) || (viewMatches view rest))),
recursive_argument: viewpoints
}
definition{
name: viewsConform,
parameters: [
viewpoints : (List Foundation.Arch::Viewpoint),
records : (List Foundation.Arch::View)
],
result: Bool,
body: (match records
| List.nil => true
| List.cons view rest => ((viewMatches view viewpoints) && (viewsConform viewpoints rest))),
recursive_argument: records
}
definition{
name: architectureValid,
parameters: [],
result: Bool,
body: ((edgesKnown 8 (edgeRecords)) && ((viewpointsKnown 3 5 (viewpointRecords)) && (viewsConform (viewpointRecords) (viewRecords))))
}
theorem{
name: architectureDescriptionHolds,
parameters: [],
statement: ((architectureValid) = true),
proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Compliance.lex.tex 56 lines
\begin{lexlean}{Compliance}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Architecture}
\importmodule{Design}
\importmodule{Quality}
\importmodule{Security}
\importmodule{MatmulCodedAdmission}
\title{standards reference}
\begin{semanticmodule}
structure{
name: Obligation,
type_parameters: [],
parameters: [],
fields: [
{name: index, type: Nat},
{name: standard, type: String},
{name: subject, type: String},
{name: text, type: String},
{name: evidence, type: (List String)}
]
}
definition{
name: obligations,
parameters: [],
result: (List Obligation),
body: (cons (record Obligation {index := 0, standard := "ISO/IEC/IEEE 42010:2022", subject := "Architecture description", text := "Stakeholders, concerns, viewpoints and views are declared and their references resolve.", evidence := (cons "Architecture::architectureDescriptionHolds" (nil String))}) (cons (record Obligation {index := 1, standard := "ISO/PAS 19450:2015 and OMG UML 2.5.1", subject := "Design views", text := "Every design view is checked by the SDK against the system model before it is rendered.", evidence := (cons "Design::viewOpmDecide" (cons "Design::viewUmlComponents" (cons "Design::viewUmlRequest" (cons "Design::viewUmlStates" (nil String)))))}) (cons (record Obligation {index := 2, standard := "ISO/IEC 25010:2023", subject := "Product quality", text := "Characteristics, subcharacteristics, requirements and measures are numbered and their parents resolve.", evidence := (cons "Quality::qualityModelHolds" (nil String))}) (cons (record Obligation {index := 3, standard := "ISO/IEC 27034-1:2011 and ISO/IEC 27005:2022", subject := "Application security and risk", text := "Every threat has a STRIDE category and a mapped control with evidence, or an accepted risk with its rationale.", evidence := (cons "Security::controlSet" (nil String))}) (cons (record Obligation {index := 4, standard := "OMG DMN 1.5, hit policy FIRST", subject := "Decision table", text := "The 10 rules are tried in order and the first that matches gives the answer; otherwise ok.", evidence := (cons "MatmulCodedAdmission::judge" (nil String))}) (cons (record Obligation {index := 5, standard := "OpenSpec", subject := "Requirements", text := "Every rule and property of the spec is a requirement with a scenario in openspec/specs.", evidence := (cons "MatmulCodedAdmission::application" (nil String))}) (cons (record Obligation {index := 6, standard := "SPDX MIT OR Apache-2.0", subject := "Licensing", text := "The application and its model are offered under MIT OR Apache-2.0.", evidence := (cons "MatmulCodedAdmission::application" (nil String))}) (nil Obligation))))))))
}
definition{
name: obligationsEvidenced,
parameters: [position : Nat, items : (List Obligation)],
result: Bool,
body: (match items
| List.nil => true
| List.cons item rest => (((project item index) =? position) && (match{
branches: [
{body: false, binders: [], constructor: List.nil},
{body: true, binders: [first, others], constructor: List.cons}
],
scrutinee: (project item evidence)
} && (obligationsEvidenced (position + 1) rest)))),
recursive_argument: items
}
theorem{
name: everyObligationEvidenced,
parameters: [],
statement: ((obligationsEvidenced 0 (obligations)) = true),
proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Design.lex.tex 696 lines
\begin{lexlean}{Design}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Architecture}
\importmodule{Foundation.Arch}
\title{design view}
\begin{semanticmodule}
definition{
name: processSendRequest,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentBrowser"})
}
definition{
name: processDecide,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processParseRequest,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processJudge,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processEncodeAnswer,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processBuildAndVerify,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentPrismBuild"})
}
definition{
name: processRule1,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule2,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule3,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule4,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule5,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule6,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule7,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule8,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule9,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processRule10,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: processOtherwise,
parameters: [],
result: Foundation.Arch::SystemProcess,
body: (record Foundation.Arch::SystemProcess {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateIdle,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateDeciding,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateRefused,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateAnsweredOk,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateAnsweredUnsupportedVersion,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateAnsweredInvalidDimension,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateAnsweredShapeMismatch,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateAnsweredUnknownTier,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: stateAnsweredInvalidCode,
parameters: [],
result: Foundation.Arch::SystemState,
body: (record Foundation.Arch::SystemState {owner := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: viewOpmDecide,
parameters: [],
result: Foundation.Arch::DesignView,
body: (record Foundation.Arch::DesignView {title := "Deciding a Coded matmul admission request", viewpoint := "Architecture::viewpointNumericalResearcherCorrectAnswers", diagram := (ctor Foundation.Arch::DesignDiagram.opmObjectProcess)})
}
definition{
name: viewUmlComponents,
parameters: [],
result: Foundation.Arch::DesignView,
body: (record Foundation.Arch::DesignView {title := "Components of Coded matmul admission", viewpoint := "Architecture::viewpointVerifierIntegrityOfThePublishedApp", diagram := (ctor Foundation.Arch::DesignDiagram.umlComponent)})
}
definition{
name: viewUmlRequest,
parameters: [],
result: Foundation.Arch::DesignView,
body: (record Foundation.Arch::DesignView {title := "Answering a Coded matmul admission request", viewpoint := "Architecture::viewpointNumericalResearcherCorrectAnswers", diagram := (ctor Foundation.Arch::DesignDiagram.umlSequence)})
}
definition{
name: viewUmlStates,
parameters: [],
result: Foundation.Arch::DesignView,
body: (record Foundation.Arch::DesignView {title := "States of the Coded matmul admission guest", viewpoint := "Architecture::viewpointIntegratorRefusedMalformedRequests", diagram := (ctor Foundation.Arch::DesignDiagram.umlStateMachine)})
}
definition{
name: opmBrowser,
parameters: [],
result: Foundation.Arch::OpmThing,
body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.object), subject := "Architecture::componentBrowser"})
}
definition{
name: opmGuest,
parameters: [],
result: Foundation.Arch::OpmThing,
body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.object), subject := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: opmDecide,
parameters: [],
result: Foundation.Arch::OpmThing,
body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processDecide"})
}
definition{
name: opmParseRequest,
parameters: [],
result: Foundation.Arch::OpmThing,
body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processParseRequest"})
}
definition{
name: opmJudge,
parameters: [],
result: Foundation.Arch::OpmThing,
body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processJudge"})
}
definition{
name: opmEncodeAnswer,
parameters: [],
result: Foundation.Arch::OpmThing,
body: (record Foundation.Arch::OpmThing {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmThingKind.process), subject := "Design::processEncodeAnswer"})
}
definition{
name: opmGuestIdle,
parameters: [],
result: Foundation.Arch::OpmState,
body: (record Foundation.Arch::OpmState {view := "Design::viewOpmDecide", thing := "Architecture::componentCodedMatmulAdmissionGuest", state := "Design::stateIdle"})
}
definition{
name: opmGuestDeciding,
parameters: [],
result: Foundation.Arch::OpmState,
body: (record Foundation.Arch::OpmState {view := "Design::viewOpmDecide", thing := "Architecture::componentCodedMatmulAdmissionGuest", state := "Design::stateDeciding"})
}
definition{
name: opmGuestAgent,
parameters: [],
result: Foundation.Arch::OpmLink,
body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.agent), source := "Architecture::componentCodedMatmulAdmissionGuest", target := "Design::processDecide"})
}
definition{
name: opmBrowserInstrument,
parameters: [],
result: Foundation.Arch::OpmLink,
body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.instrument), source := "Architecture::componentBrowser", target := "Design::processParseRequest"})
}
definition{
name: opmParseInvokesJudge,
parameters: [],
result: Foundation.Arch::OpmLink,
body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.invocation), source := "Design::processParseRequest", target := "Design::processJudge"})
}
definition{
name: opmJudgeInvokesEncode,
parameters: [],
result: Foundation.Arch::OpmLink,
body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.invocation), source := "Design::processJudge", target := "Design::processEncodeAnswer"})
}
definition{
name: opmEncodeAffectsBrowser,
parameters: [],
result: Foundation.Arch::OpmLink,
body: (record Foundation.Arch::OpmLink {view := "Design::viewOpmDecide", kind := (ctor Foundation.Arch::OpmLinkKind.effect), source := "Architecture::componentBrowser", target := "Design::processEncodeAnswer"})
}
definition{
name: opmZoomParseRequest,
parameters: [],
result: Foundation.Arch::OpmZoom,
body: (record Foundation.Arch::OpmZoom {view := "Design::viewOpmDecide", process := "Design::processDecide", subprocess := "Design::processParseRequest", order := 0})
}
definition{
name: opmZoomJudge,
parameters: [],
result: Foundation.Arch::OpmZoom,
body: (record Foundation.Arch::OpmZoom {view := "Design::viewOpmDecide", process := "Design::processDecide", subprocess := "Design::processJudge", order := 1})
}
definition{
name: opmZoomEncodeAnswer,
parameters: [],
result: Foundation.Arch::OpmZoom,
body: (record Foundation.Arch::OpmZoom {view := "Design::viewOpmDecide", process := "Design::processDecide", subprocess := "Design::processEncodeAnswer", order := 2})
}
definition{
name: umlBrowser,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentBrowser"})
}
definition{
name: umlCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentCodedMatmulAdmissionGuest"})
}
definition{
name: umlCodedMatmulAdmissionPage,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentCodedMatmulAdmissionPage"})
}
definition{
name: umlGitHubPages,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentGitHubPages"})
}
definition{
name: umlIndependentArithmeticOracles,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentIndependentArithmeticOracles"})
}
definition{
name: umlLexLeanMatmulWorkbench,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentLexLeanMatmulWorkbench"})
}
definition{
name: umlPrismBuild,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentPrismBuild"})
}
definition{
name: umlSourceRepository,
parameters: [],
result: Foundation.Arch::UmlComponent,
body: (record Foundation.Arch::UmlComponent {view := "Design::viewUmlComponents", component := "Architecture::componentSourceRepository"})
}
definition{
name: umlBrowserToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeBrowserToCodedMatmulAdmissionGuest"})
}
definition{
name: umlCodedMatmulAdmissionGuestToBrowser,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeCodedMatmulAdmissionGuestToBrowser"})
}
definition{
name: umlCodedMatmulAdmissionGuestToIndependentArithmeticOracles,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeCodedMatmulAdmissionGuestToIndependentArithmeticOracles"})
}
definition{
name: umlCodedMatmulAdmissionGuestToLexLeanMatmulWorkbench,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeCodedMatmulAdmissionGuestToLexLeanMatmulWorkbench"})
}
definition{
name: umlCodedMatmulAdmissionPageToGitHubPages,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeCodedMatmulAdmissionPageToGitHubPages"})
}
definition{
name: umlGitHubPagesToBrowser,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeGitHubPagesToBrowser"})
}
definition{
name: umlIndependentArithmeticOraclesToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeIndependentArithmeticOraclesToCodedMatmulAdmissionGuest"})
}
definition{
name: umlLexLeanMatmulWorkbenchToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeLexLeanMatmulWorkbenchToCodedMatmulAdmissionGuest"})
}
definition{
name: umlPrismBuildToCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgePrismBuildToCodedMatmulAdmissionGuest"})
}
definition{
name: umlPrismBuildToCodedMatmulAdmissionPage,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgePrismBuildToCodedMatmulAdmissionPage"})
}
definition{
name: umlSourceRepositoryToPrismBuild,
parameters: [],
result: Foundation.Arch::UmlConnector,
body: (record Foundation.Arch::UmlConnector {view := "Design::viewUmlComponents", edge := "Architecture::edgeSourceRepositoryToPrismBuild"})
}
definition{
name: seqBrowser,
parameters: [],
result: Foundation.Arch::UmlLifeline,
body: (record Foundation.Arch::UmlLifeline {view := "Design::viewUmlRequest", component := "Architecture::componentBrowser", order := 0})
}
definition{
name: seqCodedMatmulAdmissionGuest,
parameters: [],
result: Foundation.Arch::UmlLifeline,
body: (record Foundation.Arch::UmlLifeline {view := "Design::viewUmlRequest", component := "Architecture::componentCodedMatmulAdmissionGuest", order := 1})
}
definition{
name: seqRequest,
parameters: [],
result: Foundation.Arch::UmlMessage,
body: (record Foundation.Arch::UmlMessage {view := "Design::viewUmlRequest", kind := (ctor Foundation.Arch::UmlMessageKind.synchronous), order := 0, source := "Architecture::componentBrowser", target := "Architecture::componentCodedMatmulAdmissionGuest", process := "Design::processDecide"})
}
definition{
name: seqReply,
parameters: [],
result: Foundation.Arch::UmlMessage,
body: (record Foundation.Arch::UmlMessage {view := "Design::viewUmlRequest", kind := (ctor Foundation.Arch::UmlMessageKind.reply), order := 1, source := "Architecture::componentCodedMatmulAdmissionGuest", target := "Architecture::componentBrowser", process := "Design::processDecide"})
}
definition{
name: stIdle,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateIdle", initial := true})
}
definition{
name: stDeciding,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateDeciding", initial := false})
}
definition{
name: stRefused,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateRefused", initial := false})
}
definition{
name: stAnsweredOk,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredOk", initial := false})
}
definition{
name: stAnsweredUnsupportedVersion,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredUnsupportedVersion", initial := false})
}
definition{
name: stAnsweredInvalidDimension,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredInvalidDimension", initial := false})
}
definition{
name: stAnsweredShapeMismatch,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredShapeMismatch", initial := false})
}
definition{
name: stAnsweredUnknownTier,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredUnknownTier", initial := false})
}
definition{
name: stAnsweredInvalidCode,
parameters: [],
result: Foundation.Arch::UmlState,
body: (record Foundation.Arch::UmlState {view := "Design::viewUmlStates", state := "Design::stateAnsweredInvalidCode", initial := false})
}
definition{
name: trAccept,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 0, source := "Design::stateIdle", target := "Design::stateDeciding", trigger := "Design::processParseRequest"})
}
definition{
name: trRefuse,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 1, source := "Design::stateIdle", target := "Design::stateRefused", trigger := "Design::processParseRequest"})
}
definition{
name: trRule1,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 2, source := "Design::stateDeciding", target := "Design::stateAnsweredUnsupportedVersion", trigger := "Design::processRule1"})
}
definition{
name: trRule2,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 3, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidDimension", trigger := "Design::processRule2"})
}
definition{
name: trRule3,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 4, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidDimension", trigger := "Design::processRule3"})
}
definition{
name: trRule4,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 5, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidDimension", trigger := "Design::processRule4"})
}
definition{
name: trRule5,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 6, source := "Design::stateDeciding", target := "Design::stateAnsweredShapeMismatch", trigger := "Design::processRule5"})
}
definition{
name: trRule6,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 7, source := "Design::stateDeciding", target := "Design::stateAnsweredUnknownTier", trigger := "Design::processRule6"})
}
definition{
name: trRule7,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 8, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidCode", trigger := "Design::processRule7"})
}
definition{
name: trRule8,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 9, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidCode", trigger := "Design::processRule8"})
}
definition{
name: trRule9,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 10, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidCode", trigger := "Design::processRule9"})
}
definition{
name: trRule10,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 11, source := "Design::stateDeciding", target := "Design::stateAnsweredInvalidCode", trigger := "Design::processRule10"})
}
definition{
name: trOtherwise,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 12, source := "Design::stateDeciding", target := "Design::stateAnsweredOk", trigger := "Design::processOtherwise"})
}
definition{
name: trResetOk,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 13, source := "Design::stateAnsweredOk", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
definition{
name: trResetUnsupportedVersion,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 14, source := "Design::stateAnsweredUnsupportedVersion", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
definition{
name: trResetInvalidDimension,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 15, source := "Design::stateAnsweredInvalidDimension", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
definition{
name: trResetShapeMismatch,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 16, source := "Design::stateAnsweredShapeMismatch", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
definition{
name: trResetUnknownTier,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 17, source := "Design::stateAnsweredUnknownTier", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
definition{
name: trResetInvalidCode,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 18, source := "Design::stateAnsweredInvalidCode", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
definition{
name: trResetRefused,
parameters: [],
result: Foundation.Arch::UmlTransition,
body: (record Foundation.Arch::UmlTransition {view := "Design::viewUmlStates", order := 19, source := "Design::stateRefused", target := "Design::stateIdle", trigger := "Design::processEncodeAnswer"})
}
\end{semanticmodule}
\end{lexlean}
app/src/Features.lex.tex 172 lines
\begin{lexlean}{Features}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{MatmulCodedAdmission}
\importmodule{Architecture}
\importmodule{Foundation.Arch}
\title{feature}
\begin{semanticmodule}
definition{
name: acceptINV001,
parameters: [],
result: String,
body: "MatmulCodedAdmissionProofs::inv001Holds"
}
definition{
name: acceptINV002,
parameters: [],
result: String,
body: "MatmulCodedAdmissionProofs::inv002Holds"
}
definition{
name: acceptINV003,
parameters: [],
result: String,
body: "MatmulCodedAdmissionProofs::inv003Holds"
}
definition{
name: acceptINV004,
parameters: [],
result: String,
body: "MatmulCodedAdmissionProofs::inv004Holds"
}
definition{
name: featureRule1,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When version differs from 1, the answer is unsupported-version.", calls := (cons "MatmulCodedAdmission::rule1" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule2,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When m is above 8, the answer is invalid-dimension.", calls := (cons "MatmulCodedAdmission::rule2" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule3,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When k is above 8, the answer is invalid-dimension.", calls := (cons "MatmulCodedAdmission::rule3" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule4,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When n is above 8, the answer is invalid-dimension.", calls := (cons "MatmulCodedAdmission::rule4" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule5,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When shape is mismatched, the answer is shape-mismatch.", calls := (cons "MatmulCodedAdmission::rule5" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule6,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When tier is other, the answer is unknown-tier.", calls := (cons "MatmulCodedAdmission::rule6" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule7,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When tier is binary and code is above 1, the answer is invalid-code.", calls := (cons "MatmulCodedAdmission::rule7" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule8,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When tier is ternary and code is above 2, the answer is invalid-code.", calls := (cons "MatmulCodedAdmission::rule8" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule9,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When tier is signed8 and code is above 255, the answer is invalid-code.", calls := (cons "MatmulCodedAdmission::rule9" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRule10,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When tier is full8 and code is above 255, the answer is invalid-code.", calls := (cons "MatmulCodedAdmission::rule10" (cons "MatmulCodedAdmission::judge" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureOtherwise,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "When no rule matches, the answer is ok.", calls := (cons "MatmulCodedAdmission::judge" (nil String)), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureRefuseMalformed,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "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.", calls := (cons "MatmulCodedAdmission::dispatch" (cons "MatmulCodedAdmission::decodeField1" (nil String))), acceptance := (cons "MatmulCodedAdmission::application" (nil String))})
}
definition{
name: featureINV001,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "It never answers ok when m is above 8.", calls := (cons "MatmulCodedAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV001" (nil String))})
}
definition{
name: featureINV002,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "It never answers ok when tier is binary and code is above 1.", calls := (cons "MatmulCodedAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV002" (nil String))})
}
definition{
name: featureINV003,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "It always answers unsupported-version when version differs from 1.", calls := (cons "MatmulCodedAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV003" (nil String))})
}
definition{
name: featureINV004,
parameters: [],
result: Foundation.Arch::Feature,
body: (record Foundation.Arch::Feature {statement := "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.", calls := (cons "MatmulCodedAdmission::judge" (nil String)), acceptance := (cons "Features::acceptINV004" (nil String))})
}
definition{
name: journeyIntegrator,
parameters: [],
result: Foundation.Arch::Journey,
body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderIntegrator", steps := (cons "Features::featureRefuseMalformed" (cons "Features::featureRule1" (cons "Features::featureRule2" (cons "Features::featureINV001" (cons "Features::featureINV003" (nil String))))))})
}
definition{
name: journeyNumericalResearcher,
parameters: [],
result: Foundation.Arch::Journey,
body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderNumericalResearcher", steps := (cons "Features::featureRule5" (cons "Features::featureRule6" (cons "Features::featureRule8" (cons "Features::featureINV002" (cons "Features::featureOtherwise" (nil String))))))})
}
definition{
name: journeyVerifier,
parameters: [],
result: Foundation.Arch::Journey,
body: (record Foundation.Arch::Journey {actor := "Architecture::stakeholderVerifier", steps := (cons "Features::featureRefuseMalformed" (cons "Features::featureINV001" (cons "Features::featureINV002" (cons "Features::featureINV003" (cons "Features::featureINV004" (nil String))))))})
}
\end{semanticmodule}
\end{lexlean}
app/src/Quality.lex.tex 382 lines
\begin{lexlean}{Quality}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\useglossary{prism.qual@1.0.0}
\importmodule{Foundation.Qual}
\title{quality measure}
\begin{semanticmodule}
structure{
name: Named,
type_parameters: [],
parameters: [],
fields: [{name: index, type: Nat}, {name: name, type: String}, {name: text, type: String}]
}
definition{
name: characteristicFunctionalSuitability,
parameters: [],
result: Foundation.Qual::ProductQualityCharacteristic,
body: (record Foundation.Qual::ProductQualityCharacteristic {index := 0})
}
definition{
name: characteristicInteractionCapability,
parameters: [],
result: Foundation.Qual::ProductQualityCharacteristic,
body: (record Foundation.Qual::ProductQualityCharacteristic {index := 1})
}
definition{
name: characteristicPerformanceEfficiency,
parameters: [],
result: Foundation.Qual::ProductQualityCharacteristic,
body: (record Foundation.Qual::ProductQualityCharacteristic {index := 2})
}
definition{
name: characteristicReliability,
parameters: [],
result: Foundation.Qual::ProductQualityCharacteristic,
body: (record Foundation.Qual::ProductQualityCharacteristic {index := 3})
}
definition{
name: characteristicSecurity,
parameters: [],
result: Foundation.Qual::ProductQualityCharacteristic,
body: (record Foundation.Qual::ProductQualityCharacteristic {index := 4})
}
definition{
name: subcharacteristicFaultlessness,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 0, characteristicIndex := 3})
}
definition{
name: subcharacteristicFunctionalCompleteness,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 1, characteristicIndex := 0})
}
definition{
name: subcharacteristicFunctionalCorrectness,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 2, characteristicIndex := 0})
}
definition{
name: subcharacteristicIntegrity,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 3, characteristicIndex := 4})
}
definition{
name: subcharacteristicResourceUtilization,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 4, characteristicIndex := 2})
}
definition{
name: subcharacteristicTimeBehaviour,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 5, characteristicIndex := 2})
}
definition{
name: subcharacteristicUserErrorProtection,
parameters: [],
result: Foundation.Qual::QualitySubcharacteristic,
body: (record Foundation.Qual::QualitySubcharacteristic {index := 6, characteristicIndex := 1})
}
definition{
name: requirementBoundedAllocation,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 0, subcharacteristicIndex := 4})
}
definition{
name: requirementBoundedRequest,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 1, subcharacteristicIndex := 5})
}
definition{
name: requirementEveryModeledErrorIsReachable,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 2, subcharacteristicIndex := 1})
}
definition{
name: requirementEveryPropertyProved,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 3, subcharacteristicIndex := 3})
}
definition{
name: requirementEveryRequestAnswered,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 4, subcharacteristicIndex := 1})
}
definition{
name: requirementEveryVectorReplays,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 5, subcharacteristicIndex := 0})
}
definition{
name: requirementExamplesAnsweredAsStated,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 6, subcharacteristicIndex := 2})
}
definition{
name: requirementNoSilentAcceptance,
parameters: [],
result: Foundation.Qual::QualityRequirement,
body: (record Foundation.Qual::QualityRequirement {index := 7, subcharacteristicIndex := 6})
}
definition{
name: measureAcceptedInvalidRequests,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 0, requirementIndex := 7, threshold := 0})
}
definition{
name: measureExampleMismatches,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 1, requirementIndex := 6, threshold := 0})
}
definition{
name: measureFailedVectors,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 2, requirementIndex := 5, threshold := 0})
}
definition{
name: measureGuestAllocationBytes,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 3, requirementIndex := 0, threshold := 368})
}
definition{
name: measureRequestBytesRead,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 4, requirementIndex := 1, threshold := 184})
}
definition{
name: measureUnansweredRequests,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 5, requirementIndex := 4, threshold := 0})
}
definition{
name: measureUnprovedProperties,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 6, requirementIndex := 3, threshold := 0})
}
definition{
name: measureUnreachableOutcomes,
parameters: [],
result: Foundation.Qual::QualityMeasure,
body: (record Foundation.Qual::QualityMeasure {index := 7, requirementIndex := 2, threshold := 0})
}
definition{
name: characteristicNames,
parameters: [],
result: (List Named),
body: (cons (record Named {index := 0, name := "Functional suitability", text := "Functional suitability, as ISO/IEC 25010:2023 defines it, for Coded matmul admission."}) (cons (record Named {index := 1, name := "Interaction capability", text := "Interaction capability, as ISO/IEC 25010:2023 defines it, for Coded matmul admission."}) (cons (record Named {index := 2, name := "Performance efficiency", text := "Performance efficiency, as ISO/IEC 25010:2023 defines it, for Coded matmul admission."}) (cons (record Named {index := 3, name := "Reliability", text := "Reliability, as ISO/IEC 25010:2023 defines it, for Coded matmul admission."}) (cons (record Named {index := 4, name := "Security", text := "Security, as ISO/IEC 25010:2023 defines it, for Coded matmul admission."}) (nil Named))))))
}
definition{
name: subcharacteristicNames,
parameters: [],
result: (List Named),
body: (cons (record Named {index := 0, name := "Faultlessness", text := "Reliability: Faultlessness."}) (cons (record Named {index := 1, name := "Functional completeness", text := "Functional suitability: Functional completeness."}) (cons (record Named {index := 2, name := "Functional correctness", text := "Functional suitability: Functional correctness."}) (cons (record Named {index := 3, name := "Integrity", text := "Security: Integrity."}) (cons (record Named {index := 4, name := "Resource utilization", text := "Performance efficiency: Resource utilization."}) (cons (record Named {index := 5, name := "Time behaviour", text := "Performance efficiency: Time behaviour."}) (cons (record Named {index := 6, name := "User error protection", text := "Interaction capability: User error protection."}) (nil Named))))))))
}
definition{
name: requirementNames,
parameters: [],
result: (List Named),
body: (cons (record Named {index := 0, name := "Bounded allocation", text := "The guest allocates at most 368 bytes for one request."}) (cons (record Named {index := 1, name := "Bounded request", text := "A request over 184 bytes is refused before any field is read."}) (cons (record Named {index := 2, name := "Every modeled error is reachable", text := "Each of the five protocol errors the coded operation can return is the answer to some request."}) (cons (record Named {index := 3, name := "Every property proved", text := "All 4 properties are theorems the Lean kernel checks."}) (cons (record Named {index := 4, name := "Every request answered", text := "Every request gets an answer: a rule, ok otherwise, or invalid."}) (cons (record Named {index := 5, name := "Every vector replays", text := "All 71 acceptance vectors replay in the compiled guest, the shortest 0 bytes long."}) (cons (record Named {index := 6, name := "Examples answered as stated", text := "Every one of the 7 examples of the spec is answered as it states."}) (cons (record Named {index := 7, name := "No silent acceptance", text := "A request with an out-of-range dimension or code is never computed."}) (nil Named)))))))))
}
definition{
name: measureNames,
parameters: [],
result: (List Named),
body: (cons (record Named {index := 0, name := "Accepted invalid requests", text := "Requests above the dimension bound or out of code range that answer ok."}) (cons (record Named {index := 1, name := "Example mismatches", text := "Examples the guest answers otherwise than they state."}) (cons (record Named {index := 2, name := "Failed vectors", text := "Acceptance vectors whose replay differs from the model."}) (cons (record Named {index := 3, name := "Guest allocation bytes", text := "Most bytes the guest allocates for one request."}) (cons (record Named {index := 4, name := "Request bytes read", text := "Longest request the guest decodes, in bytes."}) (cons (record Named {index := 5, name := "Unanswered requests", text := "Acceptance vectors the guest does not answer."}) (cons (record Named {index := 6, name := "Unproved properties", text := "Properties of the spec without a checked theorem."}) (cons (record Named {index := 7, name := "Unreachable outcomes", text := "Outcomes of the spec that no request answers."}) (nil Named)))))))))
}
definition{
name: subcharacteristicRecords,
parameters: [],
result: (List Foundation.Qual::QualitySubcharacteristic),
body: (cons (subcharacteristicFaultlessness) (cons (subcharacteristicFunctionalCompleteness) (cons (subcharacteristicFunctionalCorrectness) (cons (subcharacteristicIntegrity) (cons (subcharacteristicResourceUtilization) (cons (subcharacteristicTimeBehaviour) (cons (subcharacteristicUserErrorProtection) (nil Foundation.Qual::QualitySubcharacteristic))))))))
}
definition{
name: requirementRecords,
parameters: [],
result: (List Foundation.Qual::QualityRequirement),
body: (cons (requirementBoundedAllocation) (cons (requirementBoundedRequest) (cons (requirementEveryModeledErrorIsReachable) (cons (requirementEveryPropertyProved) (cons (requirementEveryRequestAnswered) (cons (requirementEveryVectorReplays) (cons (requirementExamplesAnsweredAsStated) (cons (requirementNoSilentAcceptance) (nil Foundation.Qual::QualityRequirement)))))))))
}
definition{
name: measureRecords,
parameters: [],
result: (List Foundation.Qual::QualityMeasure),
body: (cons (measureAcceptedInvalidRequests) (cons (measureExampleMismatches) (cons (measureFailedVectors) (cons (measureGuestAllocationBytes) (cons (measureRequestBytesRead) (cons (measureUnansweredRequests) (cons (measureUnprovedProperties) (cons (measureUnreachableOutcomes) (nil Foundation.Qual::QualityMeasure)))))))))
}
definition{
name: namesNumbered,
parameters: [position : Nat, names : (List Named)],
result: Bool,
body: (match names
| List.nil => true
| List.cons item rest => (((project item index) =? position) && (namesNumbered (position + 1) rest))),
recursive_argument: names
}
definition{
name: parentsKnown,
parameters: [count : Nat, records : (List Foundation.Qual::QualitySubcharacteristic)],
result: Bool,
body: (match records
| List.nil => true
| List.cons item rest => (((project item characteristicIndex) <? count) && (parentsKnown count rest))),
recursive_argument: records
}
definition{
name: requirementsKnown,
parameters: [count : Nat, records : (List Foundation.Qual::QualityRequirement)],
result: Bool,
body: (match records
| List.nil => true
| List.cons item rest => (((project item subcharacteristicIndex) <? count) && (requirementsKnown count rest))),
recursive_argument: records
}
definition{
name: measuresKnown,
parameters: [count : Nat, records : (List Foundation.Qual::QualityMeasure)],
result: Bool,
body: (match records
| List.nil => true
| List.cons item rest => (((project item requirementIndex) <? count) && (measuresKnown count rest))),
recursive_argument: records
}
definition{
name: thresholdOf,
parameters: [wanted : Nat, records : (List Foundation.Qual::QualityMeasure)],
result: Nat,
body: (match records
| List.nil => 0
| List.cons head rest => (if ((project head index) =? wanted) then (project head threshold) else (thresholdOf wanted rest))),
recursive_argument: records
}
definition{
name: qualityValid,
parameters: [],
result: Bool,
body: ((namesNumbered 0 (characteristicNames)) && ((namesNumbered 0 (subcharacteristicNames)) && ((namesNumbered 0 (requirementNames)) && ((namesNumbered 0 (measureNames)) && ((parentsKnown 5 (subcharacteristicRecords)) && ((requirementsKnown 7 (requirementRecords)) && (measuresKnown 8 (measureRecords))))))))
}
theorem{
name: qualityModelHolds,
parameters: [],
statement: ((qualityValid) = true),
proof: decide{}
}
theorem{
name: measureAcceptedInvalidRequestsThreshold,
parameters: [],
statement: ((thresholdOf 0 (measureRecords)) = 0),
proof: decide{}
}
theorem{
name: measureExampleMismatchesThreshold,
parameters: [],
statement: ((thresholdOf 1 (measureRecords)) = 0),
proof: decide{}
}
theorem{
name: measureFailedVectorsThreshold,
parameters: [],
statement: ((thresholdOf 2 (measureRecords)) = 0),
proof: decide{}
}
theorem{
name: measureGuestAllocationBytesThreshold,
parameters: [],
statement: ((thresholdOf 3 (measureRecords)) = 368),
proof: decide{}
}
theorem{
name: measureRequestBytesReadThreshold,
parameters: [],
statement: ((thresholdOf 4 (measureRecords)) = 184),
proof: decide{}
}
theorem{
name: measureUnansweredRequestsThreshold,
parameters: [],
statement: ((thresholdOf 5 (measureRecords)) = 0),
proof: decide{}
}
theorem{
name: measureUnprovedPropertiesThreshold,
parameters: [],
statement: ((thresholdOf 6 (measureRecords)) = 0),
proof: decide{}
}
theorem{
name: measureUnreachableOutcomesThreshold,
parameters: [],
statement: ((thresholdOf 7 (measureRecords)) = 0),
proof: decide{}
}
\end{semanticmodule}
\end{lexlean}
app/src/Security.lex.tex 593 lines
\begin{lexlean}{Security}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\useglossary{prism.sec@1.0.0}
\importmodule{Foundation.Sec}
\importmodule{Production.ThreatModel}
\importmodule{Architecture}
\title{security threat}
\begin{semanticmodule}
definition{
name: assetAnswer,
parameters: [],
result: Foundation.Sec::Asset,
body: (record Foundation.Sec::Asset {index := 0, componentIndex := 1})
}
definition{
name: assetModelSource,
parameters: [],
result: Foundation.Sec::Asset,
body: (record Foundation.Sec::Asset {index := 1, componentIndex := 7})
}
definition{
name: assetPublishedHolo,
parameters: [],
result: Foundation.Sec::Asset,
body: (record Foundation.Sec::Asset {index := 2, componentIndex := 2})
}
definition{
name: assetRequestBytes,
parameters: [],
result: Foundation.Sec::Asset,
body: (record Foundation.Sec::Asset {index := 3, componentIndex := 1})
}
definition{
name: threatAnswerThatBreaksINV001,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 0})
}
definition{
name: threatAnswerThatBreaksINV002,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 1})
}
definition{
name: threatAnswerThatBreaksINV003,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 2})
}
definition{
name: threatAnswerThatBreaksINV004,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 3})
}
definition{
name: threatGrantedCapability,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 4})
}
definition{
name: threatMalformedRequest,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 5})
}
definition{
name: threatMisreportedShape,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 6})
}
definition{
name: threatOutOfBookCode,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 7})
}
definition{
name: threatOversizedDimension,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 8})
}
definition{
name: threatOversizedRequest,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 9})
}
definition{
name: threatSubstitutedHolo,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 10})
}
definition{
name: threatSubstitutedHost,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 11})
}
definition{
name: threatTamperedModel,
parameters: [],
result: Foundation.Sec::Threat,
body: (record Foundation.Sec::Threat {index := 12})
}
definition{
name: riskAnswerThatBreaksINV001,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 0, assetIndex := 0, threatIndex := 0, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}
definition{
name: riskAnswerThatBreaksINV002,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 1, assetIndex := 0, threatIndex := 1, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}
definition{
name: riskAnswerThatBreaksINV003,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 2, assetIndex := 0, threatIndex := 2, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}
definition{
name: riskAnswerThatBreaksINV004,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 3, assetIndex := 0, threatIndex := 3, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.critical)})
}
definition{
name: riskGrantedCapability,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 4, assetIndex := 0, threatIndex := 4, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.major)})
}
definition{
name: riskMalformedRequest,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 5, assetIndex := 3, threatIndex := 5, likelihood := (ctor Foundation.Sec::Likelihood.high), impact := (ctor Foundation.Sec::Impact.major)})
}
definition{
name: riskMisreportedShape,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 6, assetIndex := 3, threatIndex := 6, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.minor)})
}
definition{
name: riskOutOfBookCode,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 7, assetIndex := 0, threatIndex := 7, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.major)})
}
definition{
name: riskOversizedDimension,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 8, assetIndex := 3, threatIndex := 8, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.major)})
}
definition{
name: riskOversizedRequest,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 9, assetIndex := 3, threatIndex := 9, likelihood := (ctor Foundation.Sec::Likelihood.medium), impact := (ctor Foundation.Sec::Impact.minor)})
}
definition{
name: riskSubstitutedHolo,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 10, assetIndex := 2, threatIndex := 10, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.critical)})
}
definition{
name: riskSubstitutedHost,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 11, assetIndex := 2, threatIndex := 11, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.critical)})
}
definition{
name: riskTamperedModel,
parameters: [],
result: Foundation.Sec::Risk,
body: (record Foundation.Sec::Risk {index := 12, assetIndex := 1, threatIndex := 12, likelihood := (ctor Foundation.Sec::Likelihood.low), impact := (ctor Foundation.Sec::Impact.major)})
}
definition{
name: controlBoundedRequest,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 0, riskIndex := 9})
}
definition{
name: controlDimensionBoundFirst,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 1, riskIndex := 8})
}
definition{
name: controlFingerprintAndProvenance,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 2, riskIndex := 10})
}
definition{
name: controlNoCapabilityGranted,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 3, riskIndex := 4})
}
definition{
name: controlProofOfINV001,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 4, riskIndex := 0})
}
definition{
name: controlProofOfINV002,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 5, riskIndex := 1})
}
definition{
name: controlProofOfINV003,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 6, riskIndex := 2})
}
definition{
name: controlProofOfINV004,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 7, riskIndex := 3})
}
definition{
name: controlRegeneratedFromThePrompt,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 8, riskIndex := 12})
}
definition{
name: controlStrictDecoder,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 9, riskIndex := 5})
}
definition{
name: controlTierCodeRange,
parameters: [],
result: Foundation.Sec::ApplicationSecurityControl,
body: (record Foundation.Sec::ApplicationSecurityControl {index := 10, riskIndex := 7})
}
definition{
name: controlSet,
parameters: [],
result: Production.ThreatModel::ControlSet,
body: (record Production.ThreatModel::ControlSet {title := "Coded matmul admission security controls", text := "Coded matmul admission answers one request with one answer in a Core-Wasm guest granted no capability. Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first.", version := "0.1.0", lastModified := "2026-11-12T18:44:38Z"})
}
definition{
name: modeledAssetAnswer,
parameters: [],
result: Production.ThreatModel::ModeledAsset,
body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetAnswer", name := "Answer", text := "The answer the guest returns: one of ok, unsupported-version, invalid-dimension, shape-mismatch, unknown-tier, invalid-code, or invalid."})
}
definition{
name: modeledAssetModelSource,
parameters: [],
result: Production.ThreatModel::ModeledAsset,
body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetModelSource", name := "Model source", text := "The prompt, the spec and the LexLean model in the repository, from which the holo is built."})
}
definition{
name: modeledAssetPublishedHolo,
parameters: [],
result: Production.ThreatModel::ModeledAsset,
body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetPublishedHolo", name := "Published holo", text := "The holo and page the Pages workflow publishes, with its fingerprint and signed provenance."})
}
definition{
name: modeledAssetRequestBytes,
parameters: [],
result: Production.ThreatModel::ModeledAsset,
body: (record Production.ThreatModel::ModeledAsset {asset := "Security::assetRequestBytes", name := "Request bytes", text := "The bytes a caller sends, at most 184 of them."})
}
definition{
name: modeledThreatAnswerThatBreaksINV001,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV001", name := "Answer that breaks INV-001", text := "The guest answers ok although m is above 8, which matters because ERRORS.md: InvalidDimension has seven negative vectors; no product is computed above the dimension bound.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}
definition{
name: modeledThreatAnswerThatBreaksINV002,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV002", name := "Answer that breaks INV-002", text := "The guest answers ok although tier is binary and code is above 1, which matters because src/Core.lex.tex: a binary code above 1 is never decoded.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}
definition{
name: modeledThreatAnswerThatBreaksINV003,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV003", name := "Answer that breaks INV-003", text := "The guest answers unsupported-version not when version differs from 1, which matters because the version is checked before any other field.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}
definition{
name: modeledThreatAnswerThatBreaksINV004,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatAnswerThatBreaksINV004", name := "Answer that breaks INV-004", text := "The guest answers unknown-tier not 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, which matters because an unknown tier is reported as such, never as an invalid code.", category := (ctor Production.ThreatModel::Stride.repudiation)})
}
definition{
name: modeledThreatGrantedCapability,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatGrantedCapability", name := "Granted capability", text := "The guest reads, stores or sends data beyond the request it answers.", category := (ctor Production.ThreatModel::Stride.informationDisclosure)})
}
definition{
name: modeledThreatMalformedRequest,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatMalformedRequest", name := "Malformed request", text := "A request with a missing, extra, unknown or badly written field is answered as if it were well formed.", category := (ctor Production.ThreatModel::Stride.tampering)})
}
definition{
name: modeledThreatMisreportedShape,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatMisreportedShape", name := "Misreported shape", text := "A caller reports a conformant shape for matrices whose entry counts do not match.", category := (ctor Production.ThreatModel::Stride.spoofing)})
}
definition{
name: modeledThreatOutOfBookCode,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatOutOfBookCode", 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.", category := (ctor Production.ThreatModel::Stride.tampering)})
}
definition{
name: modeledThreatOversizedDimension,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatOversizedDimension", name := "Oversized dimension", text := "A request declares a dimension above 8 to force a large allocation in the guest.", category := (ctor Production.ThreatModel::Stride.denialOfService)})
}
definition{
name: modeledThreatOversizedRequest,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatOversizedRequest", name := "Oversized request", text := "A request longer than 184 bytes makes the guest parse or allocate without bound.", category := (ctor Production.ThreatModel::Stride.denialOfService)})
}
definition{
name: modeledThreatSubstitutedHolo,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatSubstitutedHolo", name := "Substituted holo", text := "A holo other than the one the build verified is served under the app address.", category := (ctor Production.ThreatModel::Stride.spoofing)})
}
definition{
name: modeledThreatSubstitutedHost,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatSubstitutedHost", name := "Substituted host", text := "Something other than the repository Pages workflow serves pages under its address.", category := (ctor Production.ThreatModel::Stride.spoofing)})
}
definition{
name: modeledThreatTamperedModel,
parameters: [],
result: Production.ThreatModel::ModeledThreat,
body: (record Production.ThreatModel::ModeledThreat {threat := "Security::threatTamperedModel", name := "Tampered model", text := "The model the holo is built from differs from the reviewed prompt and spec.", category := (ctor Production.ThreatModel::Stride.tampering)})
}
definition{
name: modeledControlBoundedRequest,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlBoundedRequest", name := "Bounded request", text := "dispatch answers invalid for a request over 184 bytes before reading a field, and the guest allocates at most 368.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "acceptance vectors at the request bound, one byte over it, and at the guest allocation bound, replayed by prismpm verify"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlDimensionBoundFirst,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlDimensionBoundFirst", name := "Dimension bound first", text := "Dimensions are checked against maximumDimension before matrices are parsed or allocated.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "MatmulCodedAdmissionProofs::inv001Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "just vv"}) (nil Production.ThreatModel::Evidence)))})
}
definition{
name: modeledControlFingerprintAndProvenance,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlFingerprintAndProvenance", name := "Fingerprint and provenance", text := "The page verifies the holo digests before it runs, and the build signs its provenance as the repository workflow.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "actions/attest-build-provenance in the pages workflow"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "prism-code check of the holo identities in the page"}) (nil Production.ThreatModel::Evidence)))})
}
definition{
name: modeledControlNoCapabilityGranted,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlNoCapabilityGranted", name := "No capability granted", text := "prism.toml grants the holo nothing and the model declares capabilitiesEmpty, so a guest import of any host capability is refused.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "prism-code check refuses an ungranted guest import"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlProofOfINV001,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV001", name := "Proof of INV-001", text := "It never answers ok when m is above 8. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "MatmulCodedAdmissionProofs::inv001Holds"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlProofOfINV002,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV002", name := "Proof of INV-002", text := "It never answers ok when tier is binary and code is above 1. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "MatmulCodedAdmissionProofs::inv002Holds"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlProofOfINV003,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV003", name := "Proof of INV-003", text := "It always answers unsupported-version when version differs from 1. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "MatmulCodedAdmissionProofs::inv003Holds"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlProofOfINV004,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlProofOfINV004", name := "Proof of INV-004", text := "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. The Lean kernel proves it for every request.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "MatmulCodedAdmissionProofs::inv004Holds"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlRegeneratedFromThePrompt,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlRegeneratedFromThePrompt", name := "Regenerated from the prompt", text := "The model is written from the prompt by the builder, and the build checks every theorem and replays every vector in the pinned SDK.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "prismpm verify in the SDK image prismpm.lock pins"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.review), reference := "app/prompt.json"}) (nil Production.ThreatModel::Evidence)))})
}
definition{
name: modeledControlStrictDecoder,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlStrictDecoder", name := "Strict decoder", text := "Every field is decoded exactly: choices from their list, numbers as plain decimal digits within their bounds, single spaces between fields; anything else is invalid.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "malformed-request acceptance vectors, replayed in the compiled guest by prismpm verify"}) (nil Production.ThreatModel::Evidence))})
}
definition{
name: modeledControlTierCodeRange,
parameters: [],
result: Production.ThreatModel::ModeledControl,
body: (record Production.ThreatModel::ModeledControl {control := "Security::controlTierCodeRange", name := "Tier code range", text := "Each tier admits only the codes validCode accepts, and a binary code above 1 is never computed.", evidence := (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.proof), reference := "MatmulCodedAdmissionProofs::inv002Holds"}) (cons (record Production.ThreatModel::Evidence {kind := (ctor Production.ThreatModel::EvidenceKind.gate), reference := "just vv"}) (nil Production.ThreatModel::Evidence)))})
}
definition{
name: mappingOversizedRequest,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatOversizedRequest", controls := (cons "Security::controlBoundedRequest" (nil String))})
}
definition{
name: mappingOversizedDimension,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatOversizedDimension", controls := (cons "Security::controlDimensionBoundFirst" (nil String))})
}
definition{
name: mappingSubstitutedHolo,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatSubstitutedHolo", controls := (cons "Security::controlFingerprintAndProvenance" (nil String))})
}
definition{
name: mappingGrantedCapability,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatGrantedCapability", controls := (cons "Security::controlNoCapabilityGranted" (nil String))})
}
definition{
name: mappingAnswerThatBreaksINV001,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV001", controls := (cons "Security::controlProofOfINV001" (nil String))})
}
definition{
name: mappingAnswerThatBreaksINV002,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV002", controls := (cons "Security::controlProofOfINV002" (nil String))})
}
definition{
name: mappingAnswerThatBreaksINV003,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV003", controls := (cons "Security::controlProofOfINV003" (nil String))})
}
definition{
name: mappingAnswerThatBreaksINV004,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatAnswerThatBreaksINV004", controls := (cons "Security::controlProofOfINV004" (nil String))})
}
definition{
name: mappingTamperedModel,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatTamperedModel", controls := (cons "Security::controlRegeneratedFromThePrompt" (nil String))})
}
definition{
name: mappingMalformedRequest,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatMalformedRequest", controls := (cons "Security::controlStrictDecoder" (nil String))})
}
definition{
name: mappingOutOfBookCode,
parameters: [],
result: Production.ThreatModel::ThreatMapping,
body: (record Production.ThreatModel::ThreatMapping {threat := "Security::threatOutOfBookCode", controls := (cons "Security::controlTierCodeRange" (nil String))})
}
definition{
name: acceptedMisreportedShape,
parameters: [],
result: Production.ThreatModel::AcceptedRisk,
body: (record Production.ThreatModel::AcceptedRisk {threat := "Security::threatMisreportedShape", rationale := "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."})
}
definition{
name: acceptedSubstitutedHost,
parameters: [],
result: Production.ThreatModel::AcceptedRisk,
body: (record Production.ThreatModel::AcceptedRisk {threat := "Security::threatSubstitutedHost", rationale := "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."})
}
\end{semanticmodule}
\end{lexlean}
app/src/MatmulCodedAdmission.lex.tex 299 lines
\begin{lexlean}{MatmulCodedAdmission}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{Foundation.Bytes}
\importmodule{Foundation.View.Text.V1.Model}
\title{Text application model}
\begin{semanticmodule}
definition{name: shapeConformant, parameters: [], result: Nat, body: 0}
definition{name: shapeMismatched, parameters: [], result: Nat, body: 1}
definition{name: tierBinary, parameters: [], result: Nat, body: 0}
definition{name: tierTernary, parameters: [], result: Nat, body: 1}
definition{name: tierSigned8, parameters: [], result: Nat, body: 2}
definition{name: tierFull8, parameters: [], result: Nat, body: 3}
definition{name: tierOther, parameters: [], result: Nat, body: 4}
definition{name: answerOk, parameters: [], result: Nat, body: 0}
definition{name: answerUnsupportedVersion, parameters: [], result: Nat, body: 1}
definition{name: answerInvalidDimension, parameters: [], result: Nat, body: 2}
definition{name: answerShapeMismatch, parameters: [], result: Nat, body: 3}
definition{name: answerUnknownTier, parameters: [], result: Nat, body: 4}
definition{name: answerInvalidCode, parameters: [], result: Nat, body: 5}
structure{
name: Request,
type_parameters: [],
parameters: [],
fields: [
{name: version, type: Nat},
{name: m, type: Nat},
{name: k, type: Nat},
{name: n, type: Nat},
{name: shape, type: Nat},
{name: tier, type: Nat},
{name: code2, type: Nat}
]
}
definition{
name: byteAt,
parameters: [s : Bytes, i : Nat],
result: (Option Nat),
body: (match (prim index s i : (Option UInt8))
| Option.none => (ctor Option.none [Nat])
| Option.some b => (ctor Option.some [Nat] (prim to_nat b : Nat))),
axioms: [Quot.sound, propext]
}
definition{
name: digitsValue,
parameters: [s : Bytes, i : Nat, acc : Nat, fuel : Nat],
result: (Option Nat),
body: (match fuel
| Nat.zero => (ctor Option.some [Nat] acc)
| Nat.succ rest => (match (byteAt s i)
| Option.none => (ctor Option.none [Nat])
| Option.some d => (if ((d <? 48) || (57 <? d)) then (ctor Option.none [Nat]) else (digitsValue s (i + 1) ((prim multiply acc 10 : Nat) + (prim subtract d 48 : Nat)) rest)))),
axioms: [Quot.sound, propext],
recursive_argument: fuel
}
definition{
name: parseDigits,
parameters: [s : Bytes],
result: (Option Nat),
body: (if ((Foundation.Bytes::byteLength s) =? 0) then (ctor Option.none [Nat]) else (if (18 <? (Foundation.Bytes::byteLength s)) then (ctor Option.none [Nat]) else (match (byteAt s 0)
| Option.none => (ctor Option.none [Nat])
| Option.some lead => (if ((lead =? 48) && (1 <? (Foundation.Bytes::byteLength s))) then (ctor Option.none [Nat]) else (digitsValue s 0 0 (Foundation.Bytes::byteLength s)))))),
axioms: [Quot.sound, propext]
}
definition{
name: parseNumber,
parameters: [value : Bytes],
result: (Option Nat),
body: (parseDigits value),
axioms: [Quot.sound, propext]
}
definition{
name: parseShape,
parameters: [value : Bytes],
result: (Option Nat),
body: (if (prim equal value 0x636f6e666f726d616e74 : Bool) then (ctor Option.some [Nat] (shapeConformant)) else (if (prim equal value 0x6d69736d617463686564 : Bool) then (ctor Option.some [Nat] (shapeMismatched)) else (ctor Option.none [Nat])))
}
definition{
name: parseTier,
parameters: [value : Bytes],
result: (Option Nat),
body: (if (prim equal value 0x62696e617279 : Bool) then (ctor Option.some [Nat] (tierBinary)) else (if (prim equal value 0x7465726e617279 : Bool) then (ctor Option.some [Nat] (tierTernary)) else (if (prim equal value 0x7369676e656438 : Bool) then (ctor Option.some [Nat] (tierSigned8)) else (if (prim equal value 0x66756c6c38 : Bool) then (ctor Option.some [Nat] (tierFull8)) else (if (prim equal value 0x6f74686572 : Bool) then (ctor Option.some [Nat] (tierOther)) else (ctor Option.none [Nat]))))))
}
definition{
name: sliceOf,
parameters: [s : Bytes, start : Nat, count : Nat],
result: Bytes,
body: (match (prim slice s start count : (Option Bytes))
| Option.none => 0x
| Option.some part => part)
}
definition{
name: fieldEnd,
parameters: [s : Bytes, i : Nat, fuel : Nat],
result: Nat,
body: (match fuel
| Nat.zero => i
| Nat.succ rest => (match (byteAt s i)
| Option.none => i
| Option.some d => (if (d =? 32) then i else (fieldEnd s (i + 1) rest)))),
axioms: [Quot.sound, propext],
recursive_argument: fuel
}
definition{
name: decodeField7,
parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat, v3 : Nat, v4 : Nat, v5 : Nat, v6 : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseNumber (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v7 => (if (e =? (Foundation.Bytes::byteLength s)) then (ctor Option.some [Request] (record Request {version := v1, m := v2, k := v3, n := v4, shape := v5, tier := v6, code2 := v7})) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: decodeField6,
parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat, v3 : Nat, v4 : Nat, v5 : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseTier (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v6 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField7 s (e + 1) v1 v2 v3 v4 v5 v6) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: decodeField5,
parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat, v3 : Nat, v4 : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseShape (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v5 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField6 s (e + 1) v1 v2 v3 v4 v5) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: decodeField4,
parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat, v3 : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseNumber (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v4 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField5 s (e + 1) v1 v2 v3 v4) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: decodeField3,
parameters: [s : Bytes, start : Nat, v1 : Nat, v2 : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseNumber (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v3 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField4 s (e + 1) v1 v2 v3) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: decodeField2,
parameters: [s : Bytes, start : Nat, v1 : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseNumber (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v2 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField3 s (e + 1) v1 v2) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: decodeField1,
parameters: [s : Bytes, start : Nat],
result: (Option Request),
body: (let e : Nat := (fieldEnd s start (Foundation.Bytes::byteLength s)); (match (parseNumber (sliceOf s start (prim subtract e start : Nat)))
| Option.none => (ctor Option.none [Request])
| Option.some v1 => (if (e <? (Foundation.Bytes::byteLength s)) then (decodeField2 s (e + 1) v1) else (ctor Option.none [Request])))),
axioms: [Quot.sound, propext]
}
definition{
name: rule1,
parameters: [request : Request],
result: Bool,
body: (not ((project request version) =? 1))
}
definition{
name: rule2,
parameters: [request : Request],
result: Bool,
body: (8 <? (project request m))
}
definition{
name: rule3,
parameters: [request : Request],
result: Bool,
body: (8 <? (project request k))
}
definition{
name: rule4,
parameters: [request : Request],
result: Bool,
body: (8 <? (project request n))
}
definition{
name: rule5,
parameters: [request : Request],
result: Bool,
body: ((project request shape) =? (shapeMismatched))
}
definition{
name: rule6,
parameters: [request : Request],
result: Bool,
body: ((project request tier) =? (tierOther))
}
definition{
name: rule7,
parameters: [request : Request],
result: Bool,
body: (((project request tier) =? (tierBinary)) && (1 <? (project request code2)))
}
definition{
name: rule8,
parameters: [request : Request],
result: Bool,
body: (((project request tier) =? (tierTernary)) && (2 <? (project request code2)))
}
definition{
name: rule9,
parameters: [request : Request],
result: Bool,
body: (((project request tier) =? (tierSigned8)) && (255 <? (project request code2)))
}
definition{
name: rule10,
parameters: [request : Request],
result: Bool,
body: (((project request tier) =? (tierFull8)) && (255 <? (project request code2)))
}
definition{
name: judge,
parameters: [request : Request],
result: Nat,
body: (if (rule1 request) then (answerUnsupportedVersion) else (if (rule2 request) then (answerInvalidDimension) else (if (rule3 request) then (answerInvalidDimension) else (if (rule4 request) then (answerInvalidDimension) else (if (rule5 request) then (answerShapeMismatch) else (if (rule6 request) then (answerUnknownTier) else (if (rule7 request) then (answerInvalidCode) else (if (rule8 request) then (answerInvalidCode) else (if (rule9 request) then (answerInvalidCode) else (if (rule10 request) then (answerInvalidCode) else (answerOk)))))))))))
}
definition{
name: encodeAnswer,
parameters: [code : Nat],
result: Bytes,
body: (if (code =? (answerOk)) then 0x6f6b else (if (code =? (answerUnsupportedVersion)) then 0x756e737570706f727465642d76657273696f6e else (if (code =? (answerInvalidDimension)) then 0x696e76616c69642d64696d656e73696f6e else (if (code =? (answerShapeMismatch)) then 0x73686170652d6d69736d61746368 else (if (code =? (answerUnknownTier)) then 0x756e6b6e6f776e2d74696572 else (if (code =? (answerInvalidCode)) then 0x696e76616c69642d636f6465 else 0x696e76616c6964))))))
}
definition{
name: dispatch,
parameters: [value : Bytes],
result: Bytes,
body: (if (184 <? (Foundation.Bytes::byteLength value)) then 0x696e76616c6964 else (match (decodeField1 value 0)
| Option.none => 0x696e76616c6964
| Option.some request => (encodeAnswer (judge request)))),
axioms: [Quot.sound, propext]
}
definition{
name: application,
parameters: [],
result: Foundation.View.Text.V1.Model::TextApplication,
body: (record Foundation.View.Text.V1.Model::TextApplication {profile := "prismpm/text-application/1", name := "Coded matmul admission", cargoName := "prism-matmul-coded-admission", cargoVersion := "0.1.0", cargoDescription := "Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first.", cargoRepository := "https://github.com/UOR-Foundation/PrismPM", cargoHomepage := "https://github.com/UOR-Foundation/PrismPM", libraryRoots := (cons "PrismMatmulCodedAdmission.MatmulCodedAdmission.dispatch" (nil String)), acceptanceVectors := (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3120312033203120636f6e666f726d616e74207465726e6172792032, response := 0x6f6b}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3120322032203220636f6e666f726d616e742066756c6c3820323535, response := 0x6f6b}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3220322032203220636f6e666f726d616e742062696e6172792030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3120392032203220636f6e666f726d616e742062696e6172792031, response := 0x696e76616c69642d64696d656e73696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x31203220322032206d69736d6174636865642062696e6172792030, response := 0x73686170652d6d69736d61746368}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3120322032203220636f6e666f726d616e74206f746865722030, response := 0x756e6b6e6f776e2d74696572}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3120312031203120636f6e666f726d616e742062696e6172792032, response := 0x696e76616c69642d636f6465}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e6172792030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e6172792032, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e6172792033, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e61727920323536, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207465726e6172792030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207465726e6172792032, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207465726e6172792033, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207465726e61727920323536, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207369676e6564382030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207369676e6564382032, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207369676e6564382033, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74207369676e65643820323536, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742066756c6c382030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742066756c6c382032, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742066756c6c382033, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742066756c6c3820323536, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74206f746865722030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74206f746865722032, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74206f746865722033, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e74206f7468657220323536, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30203020302030206d69736d6174636865642062696e6172792030, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30203020302030206d69736d6174636865642062696e6172792032, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30203020302030206d69736d6174636865642062696e6172792033, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30203020302030206d69736d6174636865642062696e61727920323536, response := 0x756e737570706f727465642d76657273696f6e}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0xff, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e617279, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e61727920302030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302020302020302020302020636f6e666f726d616e74202062696e617279202030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x303720302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x2d3120302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x2b3120302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3130303030303030303030303030303030303020302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0xd9a120302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7820302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302030372030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30202d312030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30202b312030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020313030303030303030303030303030303030302030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020d9a12030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020782030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302030203037203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302030202d31203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302030202b31203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302031303030303030303030303030303030303030203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x30203020d9a1203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302078203020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302030203020303720636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030202d3120636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030202b3120636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203130303030303030303030303030303030303020636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x302030203020d9a120636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030207820636f6e666f726d616e742062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020756e6b6e6f776e2062696e6172792030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e7420756e6b6e6f776e2030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e617279203037, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e617279202d31, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e617279202b31, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e6172792031303030303030303030303030303030303030, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e61727920d9a1, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x3020302030203020636f6e666f726d616e742062696e6172792078, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x78787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (cons (record Foundation.View.Text.V1.Model::AcceptanceVector {request := 0x7878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878, response := 0x696e76616c6964}) (nil Foundation.View.Text.V1.Model::AcceptanceVector)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))), entryRoot := "PrismMatmulCodedAdmission.MatmulCodedAdmission.dispatch", coreContract := "hologram:guest/core-wasm@1", requestMaximum := (184 : UInt32), responseMaximum := (64 : UInt32), guestAllocationMaximum := (368 : UInt32), capabilitiesEmpty := true, fatArchive := true, primaryLayer := (0 : UInt8), viewLayer := (1 : UInt8), view := (record Foundation.View.Text.V1.Model::TextView {title := "Coded matmul admission", heading := "Coded matmul admission", inputLabel := "Request: version m k n shape tier code", submitLabel := "Decide", outputLabel := "Answer", inputError := "Invalid request", responseError := "Invalid response"})})
}
\end{semanticmodule}
\end{lexlean}
app/src/MatmulCodedAdmissionProofs.lex.tex 181 lines
\begin{lexlean}{MatmulCodedAdmissionProofs}
\useglossary{lexlean.std.bool@1.2.0}
\useglossary{lexlean.std.nat@1.2.0}
\useglossary{prism.arch@1.0.0}
\importmodule{MatmulCodedAdmission}
\title{Text application model}
\begin{semanticmodule}
definition{
name: breaksInv001,
parameters: [request : MatmulCodedAdmission::Request],
result: Bool,
body: (((((project request shape) <? 2) && ((project request tier) <? 5)) && (8 <? (project request m))) && ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerOk)))
}
theorem{
name: inv001Holds,
parameters: [request : MatmulCodedAdmission::Request],
statement: ((breaksInv001 request) = false),
proof: linear_arithmetic{
definitions: [
MatmulCodedAdmission::answerInvalidCode,
MatmulCodedAdmission::answerInvalidDimension,
MatmulCodedAdmission::answerOk,
MatmulCodedAdmission::answerShapeMismatch,
MatmulCodedAdmission::answerUnknownTier,
MatmulCodedAdmission::answerUnsupportedVersion,
MatmulCodedAdmission::judge,
MatmulCodedAdmission::rule1,
MatmulCodedAdmission::rule10,
MatmulCodedAdmission::rule2,
MatmulCodedAdmission::rule3,
MatmulCodedAdmission::rule4,
MatmulCodedAdmission::rule5,
MatmulCodedAdmission::rule6,
MatmulCodedAdmission::rule7,
MatmulCodedAdmission::rule8,
MatmulCodedAdmission::rule9,
MatmulCodedAdmission::shapeConformant,
MatmulCodedAdmission::shapeMismatched,
MatmulCodedAdmission::tierBinary,
MatmulCodedAdmission::tierFull8,
MatmulCodedAdmission::tierOther,
MatmulCodedAdmission::tierSigned8,
MatmulCodedAdmission::tierTernary,
breaksInv001
]
},
axioms: [Quot.sound, propext]
}
definition{
name: breaksInv002,
parameters: [request : MatmulCodedAdmission::Request],
result: Bool,
body: ((((((project request shape) <? 2) && ((project request tier) <? 5)) && ((project request tier) =? (MatmulCodedAdmission::tierBinary))) && (1 <? (project request code2))) && ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerOk)))
}
theorem{
name: inv002Holds,
parameters: [request : MatmulCodedAdmission::Request],
statement: ((breaksInv002 request) = false),
proof: linear_arithmetic{
definitions: [
MatmulCodedAdmission::answerInvalidCode,
MatmulCodedAdmission::answerInvalidDimension,
MatmulCodedAdmission::answerOk,
MatmulCodedAdmission::answerShapeMismatch,
MatmulCodedAdmission::answerUnknownTier,
MatmulCodedAdmission::answerUnsupportedVersion,
MatmulCodedAdmission::judge,
MatmulCodedAdmission::rule1,
MatmulCodedAdmission::rule10,
MatmulCodedAdmission::rule2,
MatmulCodedAdmission::rule3,
MatmulCodedAdmission::rule4,
MatmulCodedAdmission::rule5,
MatmulCodedAdmission::rule6,
MatmulCodedAdmission::rule7,
MatmulCodedAdmission::rule8,
MatmulCodedAdmission::rule9,
MatmulCodedAdmission::shapeConformant,
MatmulCodedAdmission::shapeMismatched,
MatmulCodedAdmission::tierBinary,
MatmulCodedAdmission::tierFull8,
MatmulCodedAdmission::tierOther,
MatmulCodedAdmission::tierSigned8,
MatmulCodedAdmission::tierTernary,
breaksInv002
]
},
axioms: [Classical.choice, Quot.sound, propext]
}
definition{
name: breaksInv003,
parameters: [request : MatmulCodedAdmission::Request],
result: Bool,
body: (((((project request shape) <? 2) && ((project request tier) <? 5)) && (not ((project request version) =? 1))) && (not ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerUnsupportedVersion))))
}
theorem{
name: inv003Holds,
parameters: [request : MatmulCodedAdmission::Request],
statement: ((breaksInv003 request) = false),
proof: linear_arithmetic{
definitions: [
MatmulCodedAdmission::answerInvalidCode,
MatmulCodedAdmission::answerInvalidDimension,
MatmulCodedAdmission::answerOk,
MatmulCodedAdmission::answerShapeMismatch,
MatmulCodedAdmission::answerUnknownTier,
MatmulCodedAdmission::answerUnsupportedVersion,
MatmulCodedAdmission::judge,
MatmulCodedAdmission::rule1,
MatmulCodedAdmission::rule10,
MatmulCodedAdmission::rule2,
MatmulCodedAdmission::rule3,
MatmulCodedAdmission::rule4,
MatmulCodedAdmission::rule5,
MatmulCodedAdmission::rule6,
MatmulCodedAdmission::rule7,
MatmulCodedAdmission::rule8,
MatmulCodedAdmission::rule9,
MatmulCodedAdmission::shapeConformant,
MatmulCodedAdmission::shapeMismatched,
MatmulCodedAdmission::tierBinary,
MatmulCodedAdmission::tierFull8,
MatmulCodedAdmission::tierOther,
MatmulCodedAdmission::tierSigned8,
MatmulCodedAdmission::tierTernary,
breaksInv003
]
},
axioms: [Classical.choice, Quot.sound, propext]
}
definition{
name: breaksInv004,
parameters: [request : MatmulCodedAdmission::Request],
result: Bool,
body: ((((((((((project request shape) <? 2) && ((project request tier) <? 5)) && ((project request version) =? 1)) && ((project request m) <=? 8)) && ((project request k) <=? 8)) && ((project request n) <=? 8)) && ((project request shape) =? (MatmulCodedAdmission::shapeConformant))) && ((project request tier) =? (MatmulCodedAdmission::tierOther))) && (not ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerUnknownTier))))
}
theorem{
name: inv004Holds,
parameters: [request : MatmulCodedAdmission::Request],
statement: ((breaksInv004 request) = false),
proof: linear_arithmetic{
definitions: [
MatmulCodedAdmission::answerInvalidCode,
MatmulCodedAdmission::answerInvalidDimension,
MatmulCodedAdmission::answerOk,
MatmulCodedAdmission::answerShapeMismatch,
MatmulCodedAdmission::answerUnknownTier,
MatmulCodedAdmission::answerUnsupportedVersion,
MatmulCodedAdmission::judge,
MatmulCodedAdmission::rule1,
MatmulCodedAdmission::rule10,
MatmulCodedAdmission::rule2,
MatmulCodedAdmission::rule3,
MatmulCodedAdmission::rule4,
MatmulCodedAdmission::rule5,
MatmulCodedAdmission::rule6,
MatmulCodedAdmission::rule7,
MatmulCodedAdmission::rule8,
MatmulCodedAdmission::rule9,
MatmulCodedAdmission::shapeConformant,
MatmulCodedAdmission::shapeMismatched,
MatmulCodedAdmission::tierBinary,
MatmulCodedAdmission::tierFull8,
MatmulCodedAdmission::tierOther,
MatmulCodedAdmission::tierSigned8,
MatmulCodedAdmission::tierTernary,
breaksInv004
]
},
axioms: [Classical.choice, Quot.sound, propext]
}
\end{semanticmodule}
\end{lexlean}
app/lexlean.toml 43 lines
spec = "lexlean/project/1"
name = "prism-matmul-coded-admission"
language = "1.2"
module_prefix = "PrismMatmulCodedAdmission"
source_roots = ["src"]
entrypoints = ["src/Architecture.lex.tex", "src/Compliance.lex.tex", "src/Design.lex.tex", "src/Features.lex.tex", "src/MatmulCodedAdmission.lex.tex", "src/MatmulCodedAdmissionProofs.lex.tex", "src/Quality.lex.tex", "src/Security.lex.tex"]
build_root = ".lexlean"
lockfile = "lexlean.lock"
lean_workspace = "."
lean_toolchain = "leanprover/lean4:v4.32.1"
[[lexicon_source]]
package = "lexlean.std.nat"
kind = "builtin"
[[lexicon_source]]
package = "prism.arch"
kind = "path"
path = "language/prism.arch"
[[lexicon_source]]
package = "prism.qual"
kind = "path"
path = "language/prism.qual"
[[lexicon_source]]
package = "prism.sec"
kind = "path"
path = "language/prism.sec"
[limits]
max_file_bytes = 4194304
max_total_source_bytes = 67108864
max_primitive_atoms = 2000000
max_token_lattice_edges = 4000000
max_parse_states = 4000000
max_ir_nodes = 2000000
max_scope_depth = 1024
max_import_depth = 128
max_diagnostics = 256
max_child_output_bytes = 16777216
child_timeout_ms = 300000
app/prompt.json 472 lines
{
"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"
}
model/ids.toml 65 lines
# model/ids.toml --- the conformance ID register.
#
# Every ID this repository claims, in one place, so that nothing is referenced
# without being defined. `CONFORMANCE.md` is generated from this file. A test
# whose name ends in an ID not listed here fails `check-model`, and an ID listed
# here with no scenario and no test fails it too (CM-02).
#
# `level` is the honesty level (R2):
# some-true a fact reproduced from an authority; not established here
# build constructed here and validated against its oracle
# open measured and reported, never asserted
#
# Every row here has a scenario in `features/suites/` and a test whose name ends
# in the ID, lowercased with underscores (R3, CM-02). There is no "pending"
# state: a capability that is not built does not get a row, and every row in this
# file is built.
#
# The first row is the template's own Prism application in `app/` (TC-01).
# A capability starts with a row here; `just new-capability` writes the row,
# its scenario and its failing test in the order `AGENTS.md` sets out.
spec = "template/1"
[[id]]
id = "MC-01"
level = "build"
suite = "matmul_coded_admission"
statement = "The app never answers ok when m is above 8"
[[id]]
id = "MC-02"
level = "build"
suite = "matmul_coded_admission"
statement = "The app never answers ok when tier is binary and code is above 1"
[[id]]
id = "MC-03"
level = "build"
suite = "matmul_coded_admission"
statement = "The app always answers unsupported-version when version differs from 1"
[[id]]
id = "MC-04"
level = "build"
suite = "matmul_coded_admission"
statement = "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"
[[id]]
id = "MC-05"
level = "build"
suite = "matmul_coded_admission"
statement = "The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references"
[[id]]
id = "MC-06"
level = "build"
suite = "matmul_coded_admission"
statement = "The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared"
[[id]]
id = "MC-07"
level = "build"
suite = "matmul_coded_admission"
statement = "Every compliance obligation is numbered in order and names its evidence"
features/suites/matmul_coded_admission.feature 44 lines
Feature: matmul_coded_admission
This repository's Prism application, in app/, generated by prism-code from its
spec: Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first.
@MC-01 @build
Scenario: The app never answers ok when m is above 8
Given the model in app/src/MatmulCodedAdmission.lex.tex
When the Lean kernel checks inv001Holds during prismpm verify
Then no request meets breaksInv001
@MC-02 @build
Scenario: The app never answers ok when tier is binary and code is above 1
Given the model in app/src/MatmulCodedAdmission.lex.tex
When the Lean kernel checks inv002Holds during prismpm verify
Then no request meets breaksInv002
@MC-03 @build
Scenario: The app always answers unsupported-version when version differs from 1
Given the model in app/src/MatmulCodedAdmission.lex.tex
When the Lean kernel checks inv003Holds during prismpm verify
Then no request meets breaksInv003
@MC-04 @build
Scenario: 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
Given the model in app/src/MatmulCodedAdmission.lex.tex
When the Lean kernel checks inv004Holds during prismpm verify
Then no request meets breaksInv004
@MC-05 @build
Scenario: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
Given the model in app/src/Architecture.lex.tex
When the Lean kernel checks architectureDescriptionHolds during prismpm verify
Then the architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
@MC-06 @build
Scenario: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
Given the model in app/src/Quality.lex.tex
When the Lean kernel checks qualityModelHolds during prismpm verify
Then the ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
@MC-07 @build
Scenario: Every compliance obligation is numbered in order and names its evidence
Given the model in app/src/Compliance.lex.tex
When the Lean kernel checks everyObligationEvidenced during prismpm verify
Then every compliance obligation is numbered in order and names its evidence
crates/conformance/tests/matmul_coded_admission.rs 132 lines
//! The `matmul_coded_admission` suite: one test per scenario in `features/suites/matmul_coded_admission.feature`.
//!
//! Written by the Prism-DevRel builder from the app's prompt. The theorems are
//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.
//! What these tests hold fixed is what each theorem is about, so a weakened
//! statement that still verifies fails the gate.
use std::path::PathBuf;
fn root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(2)
.expect("crates/conformance is two below the root")
.to_path_buf()
}
/// The body of the top-level declaration named `name`, up to its closing brace.
fn declaration<'a>(model: &'a str, name: &str) -> &'a str {
let start = model
.find(&format!("\n name: {name},\n"))
.unwrap_or_else(|| panic!("{name} is not declared"));
let end = model[start..]
.find("\n}\n")
.unwrap_or_else(|| panic!("{name} is not closed"));
&model[start..start + end]
}
fn module(path: &str) -> String {
std::fs::read_to_string(root().join(path)).expect("the module")
}
/// The condition no request may meet, and the theorem that says none does.
fn pinned(breaks: &str, condition: &str, theorem: &str) {
let model = module("app/src/MatmulCodedAdmissionProofs.lex.tex");
let found = declaration(&model, breaks);
assert!(
found.contains(condition),
"the condition of {breaks} changed:\n{found}"
);
let holds = declaration(&model, theorem);
let statement = format!("statement: (({breaks} request) = false),");
assert!(
holds.contains(&statement),
"{theorem} must state that no request meets {breaks}:\n{holds}"
);
}
/// A facet theorem: proved by `decide`, about exactly this predicate.
fn holds(path: &str, theorem: &str, statement: &str) {
let model = module(path);
let found = declaration(&model, theorem);
assert!(
found.contains(&format!("statement: {statement},")),
"{theorem} must state {statement}:\n{found}"
);
assert!(
found.contains("proof: decide{}"),
"{theorem} is proved by decide"
);
}
/// `MC-01`: The app never answers ok when m is above 8
#[test]
fn matmul_coded_admission_mc_01() {
pinned(
"breaksInv001",
"body: (((((project request shape) <? 2) && ((project request tier) <? 5)) && (8 <? (project request m))) && ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerOk)))",
"inv001Holds",
);
}
/// `MC-02`: The app never answers ok when tier is binary and code is above 1
#[test]
fn matmul_coded_admission_mc_02() {
pinned(
"breaksInv002",
"body: ((((((project request shape) <? 2) && ((project request tier) <? 5)) && ((project request tier) =? (MatmulCodedAdmission::tierBinary))) && (1 <? (project request code2))) && ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerOk)))",
"inv002Holds",
);
}
/// `MC-03`: The app always answers unsupported-version when version differs from 1
#[test]
fn matmul_coded_admission_mc_03() {
pinned(
"breaksInv003",
"body: (((((project request shape) <? 2) && ((project request tier) <? 5)) && (not ((project request version) =? 1))) && (not ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerUnsupportedVersion))))",
"inv003Holds",
);
}
/// `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
#[test]
fn matmul_coded_admission_mc_04() {
pinned(
"breaksInv004",
"body: ((((((((((project request shape) <? 2) && ((project request tier) <? 5)) && ((project request version) =? 1)) && ((project request m) <=? 8)) && ((project request k) <=? 8)) && ((project request n) <=? 8)) && ((project request shape) =? (MatmulCodedAdmission::shapeConformant))) && ((project request tier) =? (MatmulCodedAdmission::tierOther))) && (not ((MatmulCodedAdmission::judge request) =? (MatmulCodedAdmission::answerUnknownTier))))",
"inv004Holds",
);
}
/// `MC-05`: The architecture description declares every stakeholder, concern, component, edge, viewpoint and view it references
#[test]
fn matmul_coded_admission_mc_05() {
holds(
"app/src/Architecture.lex.tex",
"architectureDescriptionHolds",
"((architectureValid) = true)",
);
}
/// `MC-06`: The ISO/IEC 25010 quality model numbers every characteristic, subcharacteristic, requirement and measure, and every parent it names is declared
#[test]
fn matmul_coded_admission_mc_06() {
holds(
"app/src/Quality.lex.tex",
"qualityModelHolds",
"((qualityValid) = true)",
);
}
/// `MC-07`: Every compliance obligation is numbered in order and names its evidence
#[test]
fn matmul_coded_admission_mc_07() {
holds(
"app/src/Compliance.lex.tex",
"everyObligationEvidenced",
"((obligationsEvidenced 0 (obligations)) = true)",
);
}
site/app.json 116 lines
{
"name": "Coded matmul admission",
"shortName": "Coded",
"live": "https://afflom.github.io/lexlean-matmul/",
"purpose": "Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first. Send version, m, k, n, shape, tier or code, separated by spaces; it answers ok, unsupported-version, invalid-dimension, shape-mismatch, unknown-tier or invalid-code, and invalid request for anything else.",
"inputLabel": "Request: version m k n shape tier code",
"placeholder": "1 1 3 1 conformant ternary 2",
"submitLabel": "Decide",
"outputLabel": "Answer",
"answers": {
"positive": [
"ok"
],
"negative": [
"unsupported-version",
"invalid-dimension",
"shape-mismatch",
"unknown-tier",
"invalid-code"
],
"refusal": "invalid request"
},
"promise": {
"headline": "Says conformant exactly when every policy file matches its lock.",
"detail": "Each of the six universal policy files is compared with the digest the lock records, and any file that drifted is named."
},
"claim": "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.",
"proposition": {
"name": "judge",
"text": "judge request :=\n version differs from 1 → unsupported-version\n m is above 8 → invalid-dimension\n k is above 8 → invalid-dimension\n n is above 8 → invalid-dimension\n shape is mismatched → shape-mismatch\n tier is other → unknown-tier\n tier is binary and code is above 1 → invalid-code\n tier is ternary and code is above 2 → invalid-code\n tier is signed8 and code is above 255 → invalid-code\n tier is full8 and code is above 255 → invalid-code\n otherwise → ok",
"plain": "Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first."
},
"theorems": [
{
"name": "inv001Holds",
"statement": "no request meets breaksInv001: the app never answers ok when m is above 8",
"how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
"where": "app/src/MatmulCodedAdmissionProofs.lex.tex"
},
{
"name": "inv002Holds",
"statement": "no request meets breaksInv002: the app never answers ok when tier is binary and code is above 1",
"how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
"where": "app/src/MatmulCodedAdmissionProofs.lex.tex"
},
{
"name": "inv003Holds",
"statement": "no request meets breaksInv003: the app always answers unsupported-version when version differs from 1",
"how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
"where": "app/src/MatmulCodedAdmissionProofs.lex.tex"
},
{
"name": "inv004Holds",
"statement": "no request meets breaksInv004: 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",
"how": "Proved by linear arithmetic, checked by the Lean kernel on the UOR MCP server and again by prismpm verify in CI",
"where": "app/src/MatmulCodedAdmissionProofs.lex.tex"
}
],
"pinned": [
{
"name": "matmul_coded_admission_mc_01",
"what": "MC-01's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
"where": "crates/conformance/tests/matmul_coded_admission.rs"
},
{
"name": "matmul_coded_admission_mc_02",
"what": "MC-02's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
"where": "crates/conformance/tests/matmul_coded_admission.rs"
},
{
"name": "matmul_coded_admission_mc_03",
"what": "MC-03's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
"where": "crates/conformance/tests/matmul_coded_admission.rs"
},
{
"name": "matmul_coded_admission_mc_04",
"what": "MC-04's condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.",
"where": "crates/conformance/tests/matmul_coded_admission.rs"
}
],
"trusted": [
{
"name": "SDK image",
"value": "the digest prismpm.lock pins; see the bootstrap workflow's log"
},
{
"name": "Lean toolchain",
"value": "leanprover/lean4:v4.32.1"
},
{
"name": "LexLean compiler semantics",
"value": "5262e5b4c8b5668ae7066ad686757a6bb7f80c941d515fb9d586894fbc7de69a"
},
{
"name": "prism-code runtime, vendored",
"value": "0.2.0, see try/vendor/prism-code/VENDOR.md"
},
{
"name": "Your browser",
"value": "runs the WebAssembly guest and this page"
}
],
"attestations": {
"proof": {
"id": "not recorded: the proof ran in the SDK image, not on the UOR MCP server",
"url": "https://github.com/afflom/lexlean-matmul/actions/workflows/bootstrap.yml"
},
"build": {
"id": "printed by prismpm verify in every pages run",
"url": "https://github.com/afflom/lexlean-matmul/actions/workflows/pages.yml"
}
},
"repository": "https://github.com/afflom/lexlean-matmul",
"report": "https://github.com/afflom/lexlean-matmul/blob/main/TEMPLATE-VERIFICATION.md"
}
openspec/specs/matmul-coded-admission/spec.md 244 lines
# matmul-coded-admission Specification
<!-- Generated by Prism from prism/spec.json. Change the app through your agent with /prism, not by editing this file. -->
## Purpose
Coded matmul admission: Decide whether a coded matrix product request is computed, or answered with the protocol error the LexLean Matmul source returns first.
## Requirements
### Requirement: Never ok when m is above 8
The app SHALL NOT answer `ok` when m is above 8, because ERRORS.md: InvalidDimension has seven negative vectors; no product is computed above the dimension bound.
Verified: to be proved by Lean for every request (INV-001, theorem `inv001Holds`).
#### Scenario: INV-001 holds
- **WHEN** the request is `1 9 2 2 conformant binary 1` (an acceptance example)
- **THEN** the answer SHALL NOT be `ok`
- **AND** the app answers `invalid-dimension`, decided by REQ-002
### Requirement: Never ok when tier is binary and code is above 1
The app SHALL NOT answer `ok` when tier is binary and code is above 1, because src/Core.lex.tex: a binary code above 1 is never decoded.
Verified: to be proved by Lean for every request (INV-002, theorem `inv002Holds`).
#### Scenario: INV-002 holds
- **WHEN** the request is `1 1 1 1 conformant binary 2` (an acceptance example)
- **THEN** the answer SHALL NOT be `ok`
- **AND** the app answers `invalid-code`, decided by REQ-007
### Requirement: Always unsupported-version when version differs from 1
The app SHALL answer `unsupported-version` when version differs from 1, because the version is checked before any other field.
Verified: to be proved by Lean for every request (INV-003, theorem `inv003Holds`).
#### Scenario: INV-003 holds
- **WHEN** the request is `2 2 2 2 conformant binary 0` (an acceptance example)
- **THEN** the answer SHALL be `unsupported-version`
- **AND** the app answers `unsupported-version`, decided by REQ-001
### Requirement: Always 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
The app SHALL answer `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, because an unknown tier is reported as such, never as an invalid code.
Verified: to be proved by Lean for every request (INV-004, theorem `inv004Holds`).
#### Scenario: INV-004 holds
- **WHEN** the request is `1 2 2 2 conformant other 0` (an acceptance example)
- **THEN** the answer SHALL be `unknown-tier`
- **AND** the app answers `unknown-tier`, decided by REQ-006
### Requirement: REQ-001 unsupported-version when version differs from 1
The app SHALL answer `unsupported-version` when version differs from 1, because PROTOCOL.md and src/Protocol.lex.tex: every request begins with 1; any other version is ProtocolError.UnsupportedVersion.
Verified: tested by the acceptance vectors (`rule1`).
#### Scenario: REQ-001 decides
- **WHEN** the request is `2 2 2 2 conformant binary 0` (an acceptance example)
- **THEN** the answer SHALL be `unsupported-version`, decided by REQ-001
### Requirement: REQ-002 invalid-dimension when m is above 8
The app SHALL answer `invalid-dimension` when m is above 8 and no earlier rule matches, because src/Model.lex.tex maximumDimension is 8; Protocol.lex.tex answers InvalidDimension before parsing matrices.
Verified: tested by the acceptance vectors (`rule2`).
#### Scenario: REQ-002 decides
- **WHEN** the request is `1 9 2 2 conformant binary 1` (an acceptance example)
- **THEN** the answer SHALL be `invalid-dimension`, decided by REQ-002
### Requirement: REQ-003 invalid-dimension when k is above 8
The app SHALL answer `invalid-dimension` when k is above 8 and no earlier rule matches, because src/Model.lex.tex maximumDimension is 8 for k as for m and n.
Verified: tested by the acceptance vectors (`rule3`).
#### Scenario: REQ-003 decides
- **WHEN** a request meets the conditions above
- **THEN** the answer SHALL be `invalid-dimension`, decided by REQ-003
### Requirement: REQ-004 invalid-dimension when n is above 8
The app SHALL answer `invalid-dimension` when n is above 8 and no earlier rule matches, because src/Model.lex.tex maximumDimension is 8 for n as for m and k.
Verified: tested by the acceptance vectors (`rule4`).
#### Scenario: REQ-004 decides
- **WHEN** a request meets the conditions above
- **THEN** the answer SHALL be `invalid-dimension`, decided by REQ-004
### Requirement: REQ-005 shape-mismatch when shape is mismatched
The app SHALL answer `shape-mismatch` when shape is mismatched and no earlier rule matches, because src/Protocol.lex.tex compares a.length with m*k and b.length with k*n before the tier is read.
Verified: tested by the acceptance vectors (`rule5`).
#### Scenario: REQ-005 decides
- **WHEN** the request is `1 2 2 2 mismatched binary 0` (an acceptance example)
- **THEN** the answer SHALL be `shape-mismatch`, decided by REQ-005
### Requirement: REQ-006 unknown-tier when tier is other
The app SHALL answer `unknown-tier` when tier is other and no earlier rule matches, because src/Protocol.lex.tex validTier accepts exactly binary, ternary, signed8 and full8.
Verified: tested by the acceptance vectors (`rule6`).
#### Scenario: REQ-006 decides
- **WHEN** the request is `1 2 2 2 conformant other 0` (an acceptance example)
- **THEN** the answer SHALL be `unknown-tier`, decided by REQ-006
### Requirement: REQ-007 invalid-code when tier is binary and code is above 1
The app SHALL answer `invalid-code` when tier is binary and code is above 1 and no earlier rule matches, because src/Core.lex.tex validCode: binary codes 0,1 decode to -1,+1.
Verified: tested by the acceptance vectors (`rule7`).
#### Scenario: REQ-007 decides
- **WHEN** the request is `1 1 1 1 conformant binary 2` (an acceptance example)
- **THEN** the answer SHALL be `invalid-code`, decided by REQ-007
### Requirement: REQ-008 invalid-code when tier is ternary and code is above 2
The app SHALL answer `invalid-code` when tier is ternary and code is above 2 and no earlier rule matches, because src/Core.lex.tex validCode: ternary codes 0,1,2 decode to -1,0,+1.
Verified: tested by the acceptance vectors (`rule8`).
#### Scenario: REQ-008 decides
- **WHEN** a request meets the conditions above
- **THEN** the answer SHALL be `invalid-code`, decided by REQ-008
### Requirement: REQ-009 invalid-code when tier is signed8 and code is above 255
The app SHALL answer `invalid-code` when tier is signed8 and code is above 255 and no earlier rule matches, because src/Core.lex.tex validCode: signed8 codes are bytes 0..255 read as two complement.
Verified: tested by the acceptance vectors (`rule9`).
#### Scenario: REQ-009 decides
- **WHEN** a request meets the conditions above
- **THEN** the answer SHALL be `invalid-code`, decided by REQ-009
### Requirement: REQ-010 invalid-code when tier is full8 and code is above 255
The app SHALL answer `invalid-code` when tier is full8 and code is above 255 and no earlier rule matches, because src/Core.lex.tex validCode: full8 codes are bytes 0..255.
Verified: tested by the acceptance vectors (`rule10`).
#### Scenario: REQ-010 decides
- **WHEN** a request meets the conditions above
- **THEN** the answer SHALL be `invalid-code`, decided by REQ-010
### Requirement: Otherwise ok
The app SHALL answer `ok` when no rule matches, because version 1, every dimension at most 8, conformant shapes, a known tier and in-range codes: decode the code, accumulate exactly, encode once.
Verified: tested by the acceptance vectors.
#### Scenario: No rule matches
- **WHEN** the request is `1 1 3 1 conformant ternary 2` (an acceptance example)
- **THEN** the answer SHALL be `ok`
### Requirement: The first matching rule decides
The app SHALL try REQ-001, REQ-002, REQ-003, REQ-004, REQ-005, REQ-006, REQ-007, REQ-008, REQ-009, REQ-010 in that order, and the first rule that matches SHALL decide.
Verified: tested by the acceptance vectors.
#### Scenario: Two rules match
- **WHEN** the request is `0 0 0 0 conformant binary 2`
- **THEN** the answer SHALL be `unsupported-version`, decided by REQ-001, the earlier rule
### Requirement: Request and answers
The app SHALL read one request as one line of 7 fields separated by single spaces, in this order, and SHALL answer exactly one of `ok`, `unsupported-version`, `invalid-dimension`, `shape-mismatch`, `unknown-tier`, `invalid-code`, or `invalid` for anything else.
| Field | Accepts | Means |
| --- | --- | --- |
| `version` | whole number | the protocol version that leads the request |
| `m` | whole number | rows of A and of the result |
| `k` | whole number | columns of A and stored rows of B |
| `n` | whole number | columns of B and of the result |
| `shape` | `conformant`, `mismatched` | whether A has m*k entries and B-codes has k*n codes |
| `tier` | `binary`, `ternary`, `signed8`, `full8`, `other` | the scalar codec tier named after the operation |
| `code` | whole number | the largest stored code in B-codes |
| Answer | Means |
| --- | --- |
| `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 |
| `invalid` | the request is malformed |
Verified: reading a request is tested, not proved.
#### Scenario: A malformed request is invalid
- **WHEN** the request is not 7 fields in this order
- **THEN** the answer SHALL be `invalid`
## Examples
- `1 1 3 1 conformant ternary 2` gives `ok`
- `1 2 2 2 conformant full8 255` gives `ok`
- `2 2 2 2 conformant binary 0` gives `unsupported-version`
- `1 9 2 2 conformant binary 1` gives `invalid-dimension`
- `1 2 2 2 mismatched binary 0` gives `shape-mismatch`
- `1 2 2 2 conformant other 0` gives `unknown-tier`
- `1 1 1 1 conformant binary 2` gives `invalid-code`
## What is proved and what is tested
Lean proves each property marked proved above, for every request that decodes, with no exceptions and no sampling. The proof is about `judge`, the function the WebAssembly guest runs, because both come from the same model.
The parsing of requests is tested, not proved: the acceptance vectors in the app replay through the built guest, including malformed and oversized requests.
Nothing here says the rules are the right rules. That is the part only you can judge.
## Files
- `prism/spec.json` is this spec as data.
- `src/MatmulCodedAdmission.lex.tex` is the LexLean model generated from it. It is the single source of the app.
Words on this page 8
- record
- One entry in a facet: a component, a threat, a measure or a journey step, with the place in the source it came from.
- LexLean
- The language Prism models are written in. It reads like LaTeX and compiles to Lean 4.
- Lean kernel
- The small checker at the heart of the Lean prover. It accepts a proof only if every step follows the rules.
- theorem
- A statement about the model that the Lean kernel has checked, so it holds for every input, not only the ones tested.
- SDK
- Software development kit. Here, the PrismPM container image that builds, checks and verifies Prism models.
- stakeholder
- A person or group with an interest in the system, as ISO/IEC/IEEE 42010 defines it.
- UOR
- Universal Object Reference: the UOR Foundation's framework for naming any object by its content.
- decision table
- A table of rules, as in OMG DMN 1.5: each row says which inputs lead to which outcome.