Commit 094750c
proof(xml-7-44): discharge Xml744.Element proof debts (#81)
## Summary
Discharges four proof / totality debts in `Xml744.Element` that blocked
the toolkit build past step 4/6.
1. **`tagName`** — same `decEq` baseline-rot as `attrName`. Replaced
with `with (isValidName s) proof prf` so `MkTagName`'s auto-implicit
discharges in the matched branch.
2. **`unsafeTagName`** — same never-compiled `cast (MkTagName s)`
placeholder as `unsafeAttrName`. Bumped to `(s : String) -> {auto prf :
isValidName s = True} -> TagName`; `Refl` discharges for literals.
3. **`render`** — failed totality via `concatMap render children`
(higher-order call opaques the size-change recursion). Refactored into a
`mutual` block with a first-order `renderList : List XmlNode -> String`
helper:
```idris
mutual
render (Element tag attrs children) = "<" ++ ... ++ renderList children
++ ...
renderList [] = ""
renderList (n :: ns) = render n ++ renderList ns
```
Each `renderList (n :: ns)` peels one element; `render Element` calls
`renderList children` on a structural sub-term.
4. **`renderPretty.go`** — same shape (`unlines (map go children)`),
same fix: `mutual` block with `renderPrettyList : Nat -> List XmlNode ->
String`. The child-separator semantics (trailing newline after each
rendered child) match the previous `unlines` behaviour exactly.
## Knock-on signature changes (smart-constructor proof propagation)
To keep the API total without proof escapes, the validity proofs need to
flow through the smart constructors:
- `el`, `emptyEl` → `(tag : String) -> {auto prf : isValidName tag =
True} -> ...`
- `wEl`, `wEmptyEl` → `(tag : String) -> {auto prf : isValidName (\"w:\"
++ tag) = True} -> ...`
All existing call sites pass literals (`wEl \"r\"`, `wEl \"t\"`, `wEl
\"p\"`, `wEmptyEl \"commentReference\"`, etc.), so every proof
discharges by `Refl` at elaboration time. The probe (verified locally)
confirms `isValidName (\"w:\" ++ \"id\") = True` reduces.
## Verification
```
$ idris2 -p contrib Xml744/Element.idr
1/4: Building Xml744.Escape
2/4: Building Xml744.Text
3/4: Building Xml744.Attribute
4/4: Building Xml744.Element
Xml744.Element> :total Xml744.Element.tagName --> is total
Xml744.Element> :total Xml744.Element.unsafeTagName --> is total
Xml744.Element> :total Xml744.Element.render --> is total
Xml744.Element> :total Xml744.Element.renderList --> is total
Xml744.Element> :total Xml744.Element.renderPretty --> is total
Xml744.Element> :total Xml744.Element.renderPrettyList--> is total
Xml744.Element> :total Xml744.Element.el --> is total
Xml744.Element> :total Xml744.Element.emptyEl --> is total
Xml744.Element> :total Xml744.Element.wEl --> is total
Xml744.Element> :total Xml744.Element.wEmptyEl --> is total
Xml744.Element> :total Xml744.Element.wText --> is total
Xml744.Element> :total Xml744.Element.wPara --> is total
Xml744.Element> :total Xml744.Element.wCommentRef --> is total
Xml744.Element> :total Xml744.Element.wCommentStart --> is total
Xml744.Element> :total Xml744.Element.wCommentEnd --> is total
```
`grep -E
'assert_total|assert_smaller|believe_me|%unsafe|PROOF_TODO|idris_crash|partial
' src/Xml744/Element.idr` → no matches.
Toolkit build advances 4/6 → 5/6. `Xml744.Document` errors ("Expected
end of input" at `prefix : String` field — `prefix` likely reserved on
Idris2 0.8.0) are pre-existing baseline-rot, not caused by this branch.
Stacks on top of #80 (`proof-debt/xml744-attribute-discharge`) which
stacks on #79 (`proof-debt/xml744-escape-totality`). Base is `main` per
the orphan-trap guidance; cumulative diff until earlier PRs land, then
rebases to a single-file change.
## Test plan
- [ ] CI green
- [ ] `idris2 --build idris2-ecosystem/xml-toolkit/xml-7-44.ipkg` builds
modules 1–4 cleanly (verified locally)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 34dc2de commit 094750c
1 file changed
Lines changed: 88 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| |||
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
52 | | - | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | | - | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | 66 | | |
57 | | - | |
| 67 | + | |
58 | 68 | | |
59 | | - | |
| 69 | + | |
| 70 | + | |
60 | 71 | | |
61 | 72 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
96 | 128 | | |
97 | 129 | | |
98 | 130 | | |
99 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
100 | 134 | | |
101 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
102 | 138 | | |
103 | 139 | | |
104 | 140 | | |
105 | 141 | | |
106 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
107 | 145 | | |
108 | 146 | | |
109 | 147 | | |
| |||
0 commit comments