File size: 2,437 Bytes
5316c4e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | -- SPDX-License-Identifier: AGPL-3.0-or-later
-- | @CONFORMANCE.md@, generated from the model and never edited (R1).
module MP.Gate.Render (renderConformance) where
import Data.List (intercalate, nub)
import MP.Gate.Model
renderConformance :: Model -> String
renderConformance (Model rows claims auths) =
unlines $
[ "<!-- Generated from model/*.toml by `mp-gate write`. Do not edit: R1. -->"
, ""
, "# Conformance"
, ""
, "Every claim this repository makes, by honesty level:"
, ""
, "| Level | Meaning |"
, "| --- | --- |"
, "| `some-true` | reproduced from an authority. **Not established here.** |"
, "| `build` | constructed here and checked against an oracle by a test. Evidence, not proof. |"
, "| `open` | measured and reported. **Never asserted.** |"
, "| `proved` | machine-checked by Agda under `--safe`, with no postulates. The evidence names the file and lemmas. Trusts Agda's kernel. |"
, "| `refined` | checked by Liquid Haskell. The evidence names a core source and the functions whose specs were checked. Trusts Liquid Haskell and Z3. |"
, ""
, "## Register"
, ""
, show (length rows) <> " IDs. Each is discharged by the tests tagged with it."
]
++ concatMap packageSection (nub (map rowPackage rows))
++ [ ""
, "## Ledger"
, ""
, "Claims with no ID, and so no test: reproduced facts and measured quantities."
, ""
, "| Key | Level | Statement | Evidence |"
, "| --- | --- | --- | --- |"
]
++ [ "| `" <> claimKey c <> "` | `" <> levelName (claimLevel c) <> "` | " <> cell (claimStatement c)
<> " | " <> cell (claimEvidence c) <> cites (claimAuthorities c) <> " |"
| c <- claims
]
++ ["", "## Authorities", ""]
++ ["- **" <> authKey a <> "**: " <> authCite a | a <- auths]
where
packageSection p =
[ ""
, "### " <> p
, ""
, "| ID | Level | Claim | Checked against |"
, "| --- | --- | --- | --- |"
]
++ [ "| `" <> rowId r <> "` | `" <> levelName (rowLevel r) <> "` | " <> cell (rowClaim r)
<> " | " <> cell (rowOracle r) <> cites (rowAuthorities r) <> " |"
| r <- rows
, rowPackage r == p
]
cites [] = ""
cites ks = " (" <> intercalate ", " ks <> ")"
cell = concatMap (\ch -> if ch == '|' then "\\|" else [ch])
|