bend-schema 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4527 @@
1
+ import Base
2
+ import ./LAWS.bend as Laws
3
+ import ./core.bend as C
4
+ import bend-mathlib@0.7.1.0/string.bend as MS
5
+ import bend-mathlib@0.7.1.0/nat.bend as MN
6
+
7
+ # The proofs of bend-schema's laws. The gate is `bend core/PROOF.bend` (through
8
+ # tools/bend-check). Each law's proof sits under its own
9
+ # "# ---- name ----" header, which core/check_mutants.ts relies on.
10
+
11
+ # ---- tools: what first, under and the rest do to "nothing found" ----
12
+ #
13
+ # Each lemma is stated {simple == complex}, so that a rewrite replaces the
14
+ # complex side.
15
+
16
+ def Tag(b: Bool) -> Type:
17
+ match b:
18
+ case False{}:
19
+ Unit
20
+ case True{}:
21
+ Empty
22
+
23
+ def to_empty(e: {False{} == True{} : Bool}) -> Empty:
24
+ %e : Tag(_)
25
+ Unit{}
26
+
27
+ def none_first(m: Maybe<&2, C.Err>, n: Maybe<&2, C.Err>) -> {Bool.and(Maybe.is_none(&2, C.Err, m), Maybe.is_none(&2, C.Err, n)) == Maybe.is_none(&2, C.Err, C.first(m, n)) : Bool}:
28
+ match m:
29
+ case None{}:
30
+ {==}
31
+ case Some{e}:
32
+ {==}
33
+
34
+ # is_none(in_err(b, w)) is b: a failing test becomes an error, and the error
35
+ # was made only where the test failed. A rule's bound and a constructor's are
36
+ # the same test, so both readings use this.
37
+ def in_err_none(b: Bool, +w: C.Why) -> {Maybe.is_none(&2, C.Err, C.in_err(b, w)) == b : Bool}:
38
+ match b:
39
+ case True{}:
40
+ {==}
41
+ case False{}:
42
+ {==}
43
+
44
+ # is_none(len_err(lo, hi, r)) is len_ok(lo, hi, r), for every value: at an
45
+ # SStrLen the bound is the same test read two ways, and a value that is not a
46
+ # string is not in bounds (it is refused as NotString, and len_ok is False).
47
+ def len_err_none(+lo: Nat, +hi: Nat, r: C.Raw) -> {Maybe.is_none(&2, C.Err, C.len_err(lo, hi, r)) == C.len_ok(lo, hi, r) : Bool}:
48
+ match r:
49
+ case C.RNum{n_}:
50
+ {==}
51
+ case C.RBool{b_}:
52
+ {==}
53
+ case C.RNull{}:
54
+ {==}
55
+ case C.RStr{+x}:
56
+ in_err_none(C.str_len_ok(lo, hi, x), C.LengthNotIn{lo, hi})
57
+ case C.RBad{}:
58
+ {==}
59
+ case C.RTooBig{}:
60
+ {==}
61
+ case C.RMissing{}:
62
+ {==}
63
+ case C.RNil{}:
64
+ {==}
65
+ case C.RCons{h_, t_}:
66
+ {==}
67
+ case C.REnd{}:
68
+ {==}
69
+ case C.RKey{k_, v_, o_}:
70
+ {==}
71
+
72
+ # is_none(count_err(lo, hi, r)) is list_len_ok(lo, hi, r), for every value: at
73
+ # an SListLen the count is the same test read two ways. A list out of bounds is
74
+ # CountNotIn at the list's own path, and a value that is not a list is refused
75
+ # by count_err (NotList, Missing, TooLarge) exactly where list_len_ok is False.
76
+ def count_err_none(+lo: Nat, +hi: Nat, r: C.Raw) -> {Maybe.is_none(&2, C.Err, C.count_err(lo, hi, r)) == C.list_len_ok(lo, hi, r) : Bool}:
77
+ match r:
78
+ case C.RNil{}:
79
+ in_err_none(C.list_len_ok(lo, hi, r), C.CountNotIn{lo, hi})
80
+ case C.RCons{+h, +t}:
81
+ in_err_none(C.list_len_ok(lo, hi, r), C.CountNotIn{lo, hi})
82
+ case C.RNum{n_}:
83
+ {==}
84
+ case C.RBool{b_}:
85
+ {==}
86
+ case C.RNull{}:
87
+ {==}
88
+ case C.RStr{s_}:
89
+ {==}
90
+ case C.RBad{}:
91
+ {==}
92
+ case C.RTooBig{}:
93
+ {==}
94
+ case C.RMissing{}:
95
+ {==}
96
+ case C.REnd{}:
97
+ {==}
98
+ case C.RKey{k_, v_, o_}:
99
+ {==}
100
+
101
+ def none_under(+st: C.Step, m: Maybe<&2, C.Err>) -> {Maybe.is_none(&2, C.Err, m) == Maybe.is_none(&2, C.Err, C.under(st, m)) : Bool}:
102
+ match m:
103
+ case None{}:
104
+ {==}
105
+ case Some{C.Err{p, w}}:
106
+ {==}
107
+
108
+ def none_later_i(m: Maybe<&2, C.Err>) -> {Maybe.is_none(&2, C.Err, m) == Maybe.is_none(&2, C.Err, C.later_i(m)) : Bool}:
109
+ match m:
110
+ case None{}:
111
+ {==}
112
+ case Some{C.Err{p, w}}:
113
+ {==}
114
+
115
+ def none_later_l(m: Maybe<&2, C.Err>) -> {Maybe.is_none(&2, C.Err, m) == Maybe.is_none(&2, C.Err, C.later_l(m)) : Bool}:
116
+ match m:
117
+ case None{}:
118
+ {==}
119
+ case Some{C.Err{p, w}}:
120
+ {==}
121
+
122
+ def none_later_f(m: Maybe<&2, C.Err>) -> {Maybe.is_none(&2, C.Err, m) == Maybe.is_none(&2, C.Err, C.later_f(m)) : Bool}:
123
+ match m:
124
+ case None{}:
125
+ {==}
126
+ case Some{C.Err{p, w}}:
127
+ {==}
128
+
129
+ def none_true(b: Bool) -> {Maybe.is_none(&2, C.Err, C.true_err(b)) == b : Bool}:
130
+ match b:
131
+ case True{}:
132
+ {==}
133
+ case False{}:
134
+ {==}
135
+
136
+ def none_enum(b: Bool) -> {Maybe.is_none(&2, C.Err, C.enum_err(b)) == b : Bool}:
137
+ match b:
138
+ case True{}:
139
+ {==}
140
+ case False{}:
141
+ {==}
142
+
143
+ # b is is_none(key_err(b, name)): the repeated-key test becomes an error
144
+ # exactly where key_once says the key is not read once. Stated simple first so
145
+ # that a rewrite replaces the error back with the test.
146
+ def none_key_err(b: Bool, +name: String) -> {b == Maybe.is_none(&2, C.Err, C.key_err(b, name)) : Bool}:
147
+ match b:
148
+ case True{}:
149
+ {==}
150
+ case False{}:
151
+ {==}
152
+
153
+ def none_dup_step(b: Bool, +n: String, +rr: C.Schema, +r: C.Raw, ih: {Maybe.is_none(&2, C.Err, C.dup_err(rr, r)) == C.none_present(rr, r) : Bool}) -> {Maybe.is_none(&2, C.Err, C.pick_err(b, C.later_f(C.dup_err(rr, r)), Some{C.Err{C.AtField{0n, n} <> Nil{}, C.TwoVariants{}}})) == Bool.and(b, C.none_present(rr, r)) : Bool}:
154
+ match b:
155
+ case True{}:
156
+ %none_later_f(C.dup_err(rr, r)) : {_ == C.none_present(rr, r) : Bool}
157
+ ih
158
+ case False{}:
159
+ {==}
160
+
161
+ # dup_err finds nothing exactly when none of the keys is there.
162
+ # arms: s
163
+ # arms leaf: {==}
164
+ def none_dup(s: C.Schema, +r: C.Raw) -> {Maybe.is_none(&2, C.Err, C.dup_err(s, r)) == C.none_present(s, r) : Bool}:
165
+ match s:
166
+ case C.SNat{}:
167
+ {==}
168
+ case C.SNatIn{lo_, hi_}:
169
+ {==}
170
+ case C.SStr{}:
171
+ {==}
172
+ case C.SStrLen{lo_, hi_, s_}:
173
+ {==}
174
+ case C.SOpt{inner_}:
175
+ {==}
176
+ case C.SList{elem_}:
177
+ {==}
178
+ case C.SField{name_, s_, rest_}:
179
+ {==}
180
+ case C.SEnd{}:
181
+ {==}
182
+ case C.SRule{s_, tag_}:
183
+ {==}
184
+ case C.SStrict{s_}:
185
+ {==}
186
+ case C.STagged{key_, name_, s_, rest_}:
187
+ {==}
188
+ case C.STagEnd{key_}:
189
+ {==}
190
+ case C.SBool{}:
191
+ {==}
192
+ case C.STrue{}:
193
+ {==}
194
+ case C.SEnum{names_}:
195
+ {==}
196
+ case C.SVariant{+vn, vv, +vr}:
197
+ none_dup_step(C.is_missing(C.lookup(vn, r)), vn, vr, r, none_dup(vr, r))
198
+ case C.SVEnd{}:
199
+ {==}
200
+ case C.STuple{s_, rest_}:
201
+ {==}
202
+ case C.STEnd{}:
203
+ {==}
204
+ case C.SOptional{inner_}:
205
+ {==}
206
+ case C.SListLen{lo_, hi_, s_}:
207
+ {==}
208
+
209
+ # ---- tools: a tagged case, one side or the other ----
210
+
211
+ def tag_exact(b: Bool, +m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +c1: Bool, +c2: Bool, e1: {Maybe.is_none(&2, C.Err, m1) == c1 : Bool}, e2: {Maybe.is_none(&2, C.Err, m2) == c2 : Bool}) -> {Maybe.is_none(&2, C.Err, C.pick_err(b, m1, m2)) == C.pick_bool(b, c1, c2) : Bool}:
212
+ match b:
213
+ case True{}:
214
+ e1
215
+ case False{}:
216
+ e2
217
+
218
+ # The tag key's own repeated test stands in front of the case's check, exactly
219
+ # as a field key's does in front of a field's: the key's error first, then the
220
+ # case. So where the tag is the case's name the pick's answer is the key's test
221
+ # conjoined to the case's, and the pick's two answers are tag_exact's. kc is
222
+ # whether the tag key is read once, ek that test as a report -- what check asks
223
+ # key_err for.
224
+ def tag_exact_k(kc: Bool, b: Bool, +m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +c1: Bool, +c2: Bool, +name: String, ek: {kc == Maybe.is_none(&2, C.Err, C.key_err(kc, name)) : Bool}, et: {Maybe.is_none(&2, C.Err, C.pick_err(b, m1, m2)) == C.pick_bool(b, c1, c2) : Bool}) -> {Maybe.is_none(&2, C.Err, C.pick_err(b, C.first(C.key_err(kc, name), m1), m2)) == C.pick_bool(b, Bool.and(kc, c1), c2) : Bool}:
225
+ match b:
226
+ case True{}:
227
+ %none_first(C.key_err(kc, name), m1) : {_ == Bool.and(kc, c1) : Bool}
228
+ %ek : {Bool.and(_, Bool.not(Maybe.is_some(&2, C.Err, m1))) == Bool.and(kc, c1) : Bool}
229
+ %et : {Bool.and(kc, Bool.not(Maybe.is_some(&2, C.Err, m1))) == Bool.and(kc, _) : Bool}
230
+ {==}
231
+ case False{}:
232
+ et
233
+
234
+ def tag_acc(b: Bool, +m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +d1: Maybe<&2, C.Why>, +d2: Maybe<&2, C.Why>, +path: List<&2, C.Step>, +why: C.Why, h: {C.pick_err(b, m1, m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, i1: {m1 == Some{C.Err{path, why}} : Maybe<&2, C.Err>} -> {d1 == Some{why} : Maybe<&2, C.Why>}, i2: {m2 == Some{C.Err{path, why}} : Maybe<&2, C.Err>} -> {d2 == Some{why} : Maybe<&2, C.Why>}) -> {C.pick_why(b, d1, d2) == Some{why} : Maybe<&2, C.Why>}:
235
+ match b:
236
+ case True{}:
237
+ i1(h)
238
+ case False{}:
239
+ i2(h)
240
+
241
+ # ---- check finds nothing exactly when the value conforms ----
242
+ #
243
+ # The same walk as check and conforms, case by case. A leaf case computes on
244
+ # both sides; a step case turns "nothing found" in a first/under/later into an
245
+ # and of the parts (the tools), then rewrites each part with the recursive
246
+ # call, which is the induction hypothesis.
247
+
248
+ #
249
+ # extra_err finds nothing exactly when no_extra holds: the same walk, a
250
+ # pick_err where no_extra has a Bool.and.
251
+
252
+ def extra_exact_step(b: Bool, +x: Maybe<&2, C.Err>, +e: C.Err, +d: Bool, ih: {Maybe.is_none(&2, C.Err, x) == d : Bool}) -> {Maybe.is_none(&2, C.Err, C.pick_err(b, x, Some{e})) == Bool.and(b, d) : Bool}:
253
+ match b:
254
+ case True{}:
255
+ ih
256
+ case False{}:
257
+ {==}
258
+
259
+ def extra_exact(+ns: List<&2, String>, r: C.Raw) -> {Maybe.is_none(&2, C.Err, C.extra_err(ns, r)) == C.no_extra(ns, r) : Bool}:
260
+ match r:
261
+ case C.RKey{+k, v, +o}:
262
+ extra_exact_step(C.in_names(k, ns), C.extra_err(ns, o), C.Err{C.AtKey{k} <> Nil{}, C.UnknownKey{}}, C.no_extra(ns, o), extra_exact(ns, o))
263
+ case C.RNum{n_}:
264
+ {==}
265
+ case C.RBool{b_}:
266
+ {==}
267
+ case C.RNull{}:
268
+ {==}
269
+ case C.RStr{s_}:
270
+ {==}
271
+ case C.RBad{}:
272
+ {==}
273
+ case C.RTooBig{}:
274
+ {==}
275
+ case C.RMissing{}:
276
+ {==}
277
+ case C.RNil{}:
278
+ {==}
279
+ case C.RCons{h_, t_}:
280
+ {==}
281
+ case C.REnd{}:
282
+ {==}
283
+
284
+ # A variant: the key absent, go on with the rest; present, its value must
285
+ # conform and no later key may be there.
286
+ def var_exact(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, +vn: String, +vv: C.Schema, +vr: C.Schema, +r: C.Raw, ih1: {Maybe.is_none(&2, C.Err, C.check(~rule, vr, r, None{})) == C.conforms(~rule, vr, r, None{}) : Bool}, ih2: {Maybe.is_none(&2, C.Err, C.check(~rule, vv, C.lookup(vn, r), None{})) == C.conforms(~rule, vv, C.lookup(vn, r), None{}) : Bool}, nd: {Maybe.is_none(&2, C.Err, C.dup_err(vr, r)) == C.none_present(vr, r) : Bool}) -> {Maybe.is_none(&2, C.Err, C.pick_err(b, C.later_f(C.check(~rule, vr, r, None{})), C.first(C.key_err(C.key_once_at(r, False{}, vn), vn), C.first(C.under(C.AtField{0n, vn}, C.check(~rule, vv, C.lookup(vn, r), None{})), C.later_f(C.dup_err(vr, r)))))) == C.pick_bool(b, C.conforms(~rule, vr, r, None{}), Bool.and(C.key_once_at(r, False{}, vn), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r)))) : Bool}:
287
+ match b:
288
+ case True{}:
289
+ %none_later_f(C.check(~rule, vr, r, None{})) : {_ == C.conforms(~rule, vr, r, None{}) : Bool}
290
+ ih1
291
+ case False{}:
292
+ %none_first(C.key_err(C.key_once_at(r, False{}, vn), vn), C.first(C.under(C.AtField{0n, vn}, C.check(~rule, vv, C.lookup(vn, r), None{})), C.later_f(C.dup_err(vr, r)))) : {_ == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r))) : Bool}
293
+ %none_key_err(C.key_once_at(r, False{}, vn), vn) : {Bool.and(_, Maybe.is_none(&2, C.Err, C.first(C.under(C.AtField{0n, vn}, C.check(~rule, vv, C.lookup(vn, r), None{})), C.later_f(C.dup_err(vr, r))))) == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r))) : Bool}
294
+ %none_first(C.under(C.AtField{0n, vn}, C.check(~rule, vv, C.lookup(vn, r), None{})), C.later_f(C.dup_err(vr, r))) : {Bool.and(C.key_once_at(r, False{}, vn), _) == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r))) : Bool}
295
+ %none_under(C.AtField{0n, vn}, C.check(~rule, vv, C.lookup(vn, r), None{})) : {Bool.and(C.key_once_at(r, False{}, vn), Bool.and(_, Maybe.is_none(&2, C.Err, C.later_f(C.dup_err(vr, r))))) == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r))) : Bool}
296
+ %none_later_f(C.dup_err(vr, r)) : {Bool.and(C.key_once_at(r, False{}, vn), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, vv, C.lookup(vn, r), None{})), _)) == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r))) : Bool}
297
+ %ih2 : {Bool.and(C.key_once_at(r, False{}, vn), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, vv, C.lookup(vn, r), None{})), Maybe.is_none(&2, C.Err, C.dup_err(vr, r)))) == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(_, C.none_present(vr, r))) : Bool}
298
+ %nd : {Bool.and(C.key_once_at(r, False{}, vn), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, vv, C.lookup(vn, r), None{})), Maybe.is_none(&2, C.Err, C.dup_err(vr, r)))) == Bool.and(C.key_once_at(r, False{}, vn), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, vv, C.lookup(vn, r), None{})), _)) : Bool}
299
+ {==}
300
+
301
+ # arms: s r
302
+ # arms leaf: {==}
303
+ def exact(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, s: C.Schema, r: C.Raw, +prev: Maybe<&2, Nat>) -> {Maybe.is_none(&2, C.Err, C.check(~rule, s, r, prev)) == C.conforms(~rule, s, r, prev) : Bool}:
304
+ match s r:
305
+ case C.SNat{} C.RNum{n}:
306
+ {==}
307
+ case C.SNat{} C.RBool{bb}:
308
+ {==}
309
+ case C.SNat{} C.RNull{}:
310
+ {==}
311
+ case C.SNat{} C.RStr{x}:
312
+ {==}
313
+ case C.SNat{} C.RBad{}:
314
+ {==}
315
+ case C.SNat{} C.RTooBig{}:
316
+ {==}
317
+ case C.SNat{} C.RMissing{}:
318
+ {==}
319
+ case C.SNat{} C.RNil{}:
320
+ {==}
321
+ case C.SNat{} C.RCons{h, t}:
322
+ {==}
323
+ case C.SNat{} C.REnd{}:
324
+ {==}
325
+ case C.SNat{} C.RKey{k, v, o}:
326
+ {==}
327
+ case C.SNatIn{+lo, +hi} C.RNum{+n}:
328
+ in_err_none(C.num_ok(lo, hi, n), C.NotIn{lo, hi})
329
+ case C.SNatIn{+lo, +hi} C.RBool{bb}:
330
+ {==}
331
+ case C.SNatIn{+lo, +hi} C.RNull{}:
332
+ {==}
333
+ case C.SNatIn{+lo, +hi} C.RStr{x}:
334
+ {==}
335
+ case C.SNatIn{+lo, +hi} C.RBad{}:
336
+ {==}
337
+ case C.SNatIn{+lo, +hi} C.RTooBig{}:
338
+ {==}
339
+ case C.SNatIn{+lo, +hi} C.RMissing{}:
340
+ {==}
341
+ case C.SNatIn{+lo, +hi} C.RNil{}:
342
+ {==}
343
+ case C.SNatIn{+lo, +hi} C.RCons{h, t}:
344
+ {==}
345
+ case C.SNatIn{+lo, +hi} C.REnd{}:
346
+ {==}
347
+ case C.SNatIn{+lo, +hi} C.RKey{k, v, o}:
348
+ {==}
349
+ case C.SStr{} C.RNum{n}:
350
+ {==}
351
+ case C.SStr{} C.RBool{bb}:
352
+ {==}
353
+ case C.SStr{} C.RNull{}:
354
+ {==}
355
+ case C.SStr{} C.RStr{x}:
356
+ {==}
357
+ case C.SStr{} C.RBad{}:
358
+ {==}
359
+ case C.SStr{} C.RTooBig{}:
360
+ {==}
361
+ case C.SStr{} C.RMissing{}:
362
+ {==}
363
+ case C.SStr{} C.RNil{}:
364
+ {==}
365
+ case C.SStr{} C.RCons{h, t}:
366
+ {==}
367
+ case C.SStr{} C.REnd{}:
368
+ {==}
369
+ case C.SStr{} C.RKey{k, v, o}:
370
+ {==}
371
+ case C.SStrLen{+lo, +hi, +s2} +x:
372
+ %none_first(C.check(~rule, s2, x, prev), C.len_err(lo, hi, x)) : {_ == Bool.and(C.conforms(~rule, s2, x, prev), C.len_ok(lo, hi, x)) : Bool}
373
+ %exact(~rule, s2, x, prev) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), Maybe.is_none(&2, C.Err, C.len_err(lo, hi, x))) == Bool.and(_, C.len_ok(lo, hi, x)) : Bool}
374
+ %len_err_none(lo, hi, x) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), Maybe.is_none(&2, C.Err, C.len_err(lo, hi, x))) == Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), _) : Bool}
375
+ {==}
376
+ case C.SOpt{inner} C.RNum{n}:
377
+ exact(~rule, inner, C.RNum{n}, None{})
378
+ case C.SOpt{inner} C.RBool{bb}:
379
+ exact(~rule, inner, C.RBool{bb}, None{})
380
+ case C.SOpt{inner} C.RNull{}:
381
+ {==}
382
+ case C.SOpt{inner} C.RStr{x}:
383
+ exact(~rule, inner, C.RStr{x}, None{})
384
+ case C.SOpt{inner} C.RBad{}:
385
+ exact(~rule, inner, C.RBad{}, None{})
386
+ case C.SOpt{inner} C.RTooBig{}:
387
+ exact(~rule, inner, C.RTooBig{}, None{})
388
+ case C.SOpt{inner} C.RMissing{}:
389
+ exact(~rule, inner, C.RMissing{}, None{})
390
+ case C.SOpt{inner} C.RNil{}:
391
+ exact(~rule, inner, C.RNil{}, None{})
392
+ case C.SOpt{inner} C.RCons{h, t}:
393
+ exact(~rule, inner, C.RCons{h, t}, None{})
394
+ case C.SOpt{inner} C.REnd{}:
395
+ exact(~rule, inner, C.REnd{}, None{})
396
+ case C.SOpt{inner} C.RKey{k, v, o}:
397
+ exact(~rule, inner, C.RKey{k, v, o}, None{})
398
+ case C.SList{+e} C.RNum{n}:
399
+ {==}
400
+ case C.SList{+e} C.RBool{bb}:
401
+ {==}
402
+ case C.SList{+e} C.RNull{}:
403
+ {==}
404
+ case C.SList{+e} C.RStr{x}:
405
+ {==}
406
+ case C.SList{+e} C.RBad{}:
407
+ {==}
408
+ case C.SList{+e} C.RTooBig{}:
409
+ {==}
410
+ case C.SList{+e} C.RMissing{}:
411
+ {==}
412
+ case C.SList{+e} C.RNil{}:
413
+ {==}
414
+ case C.SList{+e} C.RCons{+h, +t}:
415
+ %none_first(C.under(C.AtIndex{0n}, C.check(~rule, e, h, None{})), C.later_l(C.check(~rule, C.SList{e}, t, None{}))) : {_ == Bool.and(C.conforms(~rule, e, h, None{}), C.conforms(~rule, C.SList{e}, t, None{})) : Bool}
416
+ %none_under(C.AtIndex{0n}, C.check(~rule, e, h, None{})) : {Bool.and(_, Maybe.is_none(&2, C.Err, C.later_l(C.check(~rule, C.SList{e}, t, None{})))) == Bool.and(C.conforms(~rule, e, h, None{}), C.conforms(~rule, C.SList{e}, t, None{})) : Bool}
417
+ %none_later_l(C.check(~rule, C.SList{e}, t, None{})) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, e, h, None{})), _) == Bool.and(C.conforms(~rule, e, h, None{}), C.conforms(~rule, C.SList{e}, t, None{})) : Bool}
418
+ %exact(~rule, e, h, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, e, h, None{})), Maybe.is_none(&2, C.Err, C.check(~rule, C.SList{e}, t, None{}))) == Bool.and(_, C.conforms(~rule, C.SList{e}, t, None{})) : Bool}
419
+ %exact(~rule, C.SList{e}, t, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, e, h, None{})), Maybe.is_none(&2, C.Err, C.check(~rule, C.SList{e}, t, None{}))) == Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, e, h, None{})), _) : Bool}
420
+ {==}
421
+ case C.SList{+e} C.REnd{}:
422
+ {==}
423
+ case C.SList{+e} C.RKey{k, v, o}:
424
+ {==}
425
+ case C.SField{+name, +fs, +rest} C.RNum{n}:
426
+ {==}
427
+ case C.SField{+name, +fs, +rest} C.RBool{bb}:
428
+ {==}
429
+ case C.SField{+name, +fs, +rest} C.RNull{}:
430
+ {==}
431
+ case C.SField{+name, +fs, +rest} C.RStr{x}:
432
+ {==}
433
+ case C.SField{+name, +fs, +rest} C.RBad{}:
434
+ {==}
435
+ case C.SField{+name, +fs, +rest} C.RTooBig{}:
436
+ {==}
437
+ case C.SField{+name, +fs, +rest} C.RMissing{}:
438
+ {==}
439
+ case C.SField{+name, +fs, +rest} C.RNil{}:
440
+ {==}
441
+ case C.SField{+name, +fs, +rest} C.RCons{h, t}:
442
+ {==}
443
+ case C.SField{+name, +fs, +rest} C.REnd{}:
444
+ %none_first(C.under(C.AtField{0n, name}, C.check(~rule, fs, C.RMissing{}, None{})), C.later_f(C.check(~rule, rest, C.REnd{}, None{}))) : {_ == Bool.and(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{})) : Bool}
445
+ %none_under(C.AtField{0n, name}, C.check(~rule, fs, C.RMissing{}, None{})) : {Bool.and(_, Maybe.is_none(&2, C.Err, C.later_f(C.check(~rule, rest, C.REnd{}, None{})))) == Bool.and(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{})) : Bool}
446
+ %none_later_f(C.check(~rule, rest, C.REnd{}, None{})) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.RMissing{}, None{})), _) == Bool.and(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{})) : Bool}
447
+ %exact(~rule, fs, C.RMissing{}, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.RMissing{}, None{})), Maybe.is_none(&2, C.Err, C.check(~rule, rest, C.REnd{}, None{}))) == Bool.and(_, C.conforms(~rule, rest, C.REnd{}, None{})) : Bool}
448
+ %exact(~rule, rest, C.REnd{}, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.RMissing{}, None{})), Maybe.is_none(&2, C.Err, C.check(~rule, rest, C.REnd{}, None{}))) == Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.RMissing{}, None{})), _) : Bool}
449
+ {==}
450
+ case C.SField{+name, +fs, +rest} C.RKey{+k, +v, +o}:
451
+ %none_first(C.key_err(C.key_once_at(o, String.eq(k, name), name), name), C.first(C.under(C.AtField{0n, name}, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), C.later_f(C.check(~rule, rest, C.RKey{k, v, o}, None{})))) : {_ == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}))) : Bool}
452
+ %none_key_err(C.key_once_at(o, String.eq(k, name), name), name) : {Bool.and(_, Maybe.is_none(&2, C.Err, C.first(C.under(C.AtField{0n, name}, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), C.later_f(C.check(~rule, rest, C.RKey{k, v, o}, None{}))))) == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}))) : Bool}
453
+ %none_first(C.under(C.AtField{0n, name}, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), C.later_f(C.check(~rule, rest, C.RKey{k, v, o}, None{}))) : {Bool.and(C.key_once_at(o, String.eq(k, name), name), _) == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}))) : Bool}
454
+ %none_under(C.AtField{0n, name}, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})) : {Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(_, Maybe.is_none(&2, C.Err, C.later_f(C.check(~rule, rest, C.RKey{k, v, o}, None{}))))) == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}))) : Bool}
455
+ %none_later_f(C.check(~rule, rest, C.RKey{k, v, o}, None{})) : {Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), _)) == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}))) : Bool}
456
+ %exact(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}) : {Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), Maybe.is_none(&2, C.Err, C.check(~rule, rest, C.RKey{k, v, o}, None{})))) == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(_, C.conforms(~rule, rest, C.RKey{k, v, o}, None{}))) : Bool}
457
+ %exact(~rule, rest, C.RKey{k, v, o}, None{}) : {Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), Maybe.is_none(&2, C.Err, C.check(~rule, rest, C.RKey{k, v, o}, None{})))) == Bool.and(C.key_once_at(o, String.eq(k, name), name), Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{})), _)) : Bool}
458
+ {==}
459
+ case C.SEnd{} C.RNum{n}:
460
+ {==}
461
+ case C.SEnd{} C.RBool{bb}:
462
+ {==}
463
+ case C.SEnd{} C.RNull{}:
464
+ {==}
465
+ case C.SEnd{} C.RStr{x}:
466
+ {==}
467
+ case C.SEnd{} C.RBad{}:
468
+ {==}
469
+ case C.SEnd{} C.RTooBig{}:
470
+ {==}
471
+ case C.SEnd{} C.RMissing{}:
472
+ {==}
473
+ case C.SEnd{} C.RNil{}:
474
+ {==}
475
+ case C.SEnd{} C.RCons{h, t}:
476
+ {==}
477
+ case C.SEnd{} C.REnd{}:
478
+ {==}
479
+ case C.SEnd{} C.RKey{k, v, o}:
480
+ {==}
481
+ case C.SRule{+s2, +tag} +x:
482
+ %none_first(C.check(~rule, s2, x, prev), rule(tag, x)) : {_ == Bool.and(C.conforms(~rule, s2, x, prev), Maybe.is_none(&2, C.Err, rule(tag, x))) : Bool}
483
+ %exact(~rule, s2, x, prev) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), Maybe.is_none(&2, C.Err, rule(tag, x))) == Bool.and(_, Maybe.is_none(&2, C.Err, rule(tag, x))) : Bool}
484
+ {==}
485
+ case C.SStrict{+s2} +x:
486
+ %none_first(C.check(~rule, s2, x, prev), C.extra_err(C.key_names(s2), x)) : {_ == Bool.and(C.conforms(~rule, s2, x, prev), C.no_extra(C.key_names(s2), x)) : Bool}
487
+ %exact(~rule, s2, x, prev) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), Maybe.is_none(&2, C.Err, C.extra_err(C.key_names(s2), x))) == Bool.and(_, C.no_extra(C.key_names(s2), x)) : Bool}
488
+ %extra_exact(C.key_names(s2), x) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), Maybe.is_none(&2, C.Err, C.extra_err(C.key_names(s2), x))) == Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, s2, x, prev)), _) : Bool}
489
+ {==}
490
+ case C.STagged{+k, +n, +cs, +rest} +x:
491
+ tag_exact_k(C.key_once(k, x), C.is_tag(k, n, x), C.check(~rule, cs, C.drop_key(k, x), None{}), C.check(~rule, rest, x, None{}), C.conforms(~rule, cs, C.drop_key(k, x), None{}), C.conforms(~rule, rest, x, None{}), k, none_key_err(C.key_once(k, x), k), tag_exact(C.is_tag(k, n, x), C.check(~rule, cs, C.drop_key(k, x), None{}), C.check(~rule, rest, x, None{}), C.conforms(~rule, cs, C.drop_key(k, x), None{}), C.conforms(~rule, rest, x, None{}), exact(~rule, cs, C.drop_key(k, x), None{}), exact(~rule, rest, x, None{})))
492
+ case C.STagEnd{key_} C.RNum{n}:
493
+ {==}
494
+ case C.STagEnd{key_} C.RBool{bb}:
495
+ {==}
496
+ case C.STagEnd{key_} C.RNull{}:
497
+ {==}
498
+ case C.STagEnd{key_} C.RStr{x}:
499
+ {==}
500
+ case C.STagEnd{key_} C.RBad{}:
501
+ {==}
502
+ case C.STagEnd{key_} C.RTooBig{}:
503
+ {==}
504
+ case C.STagEnd{key_} C.RMissing{}:
505
+ {==}
506
+ case C.STagEnd{key_} C.RNil{}:
507
+ {==}
508
+ case C.STagEnd{key_} C.RCons{h, t}:
509
+ {==}
510
+ case C.STagEnd{key_} C.REnd{}:
511
+ {==}
512
+ case C.STagEnd{key_} C.RKey{k, v, o}:
513
+ {==}
514
+ case C.SBool{} C.RNum{n}:
515
+ {==}
516
+ case C.SBool{} C.RBool{bb}:
517
+ {==}
518
+ case C.SBool{} C.RNull{}:
519
+ {==}
520
+ case C.SBool{} C.RStr{x}:
521
+ {==}
522
+ case C.SBool{} C.RBad{}:
523
+ {==}
524
+ case C.SBool{} C.RTooBig{}:
525
+ {==}
526
+ case C.SBool{} C.RMissing{}:
527
+ {==}
528
+ case C.SBool{} C.RNil{}:
529
+ {==}
530
+ case C.SBool{} C.RCons{h, t}:
531
+ {==}
532
+ case C.SBool{} C.REnd{}:
533
+ {==}
534
+ case C.SBool{} C.RKey{k, v, o}:
535
+ {==}
536
+ case C.STrue{} C.RNum{n}:
537
+ {==}
538
+ case C.STrue{} C.RBool{bb}:
539
+ none_true(bb)
540
+ case C.STrue{} C.RNull{}:
541
+ {==}
542
+ case C.STrue{} C.RStr{x}:
543
+ {==}
544
+ case C.STrue{} C.RBad{}:
545
+ {==}
546
+ case C.STrue{} C.RTooBig{}:
547
+ {==}
548
+ case C.STrue{} C.RMissing{}:
549
+ {==}
550
+ case C.STrue{} C.RNil{}:
551
+ {==}
552
+ case C.STrue{} C.RCons{h, t}:
553
+ {==}
554
+ case C.STrue{} C.REnd{}:
555
+ {==}
556
+ case C.STrue{} C.RKey{k, v, o}:
557
+ {==}
558
+ case C.SEnum{+ns} C.RNum{n}:
559
+ {==}
560
+ case C.SEnum{+ns} C.RBool{bb}:
561
+ {==}
562
+ case C.SEnum{+ns} C.RNull{}:
563
+ {==}
564
+ case C.SEnum{+ns} C.RStr{+x}:
565
+ none_enum(C.in_names(x, ns))
566
+ case C.SEnum{+ns} C.RBad{}:
567
+ {==}
568
+ case C.SEnum{+ns} C.RTooBig{}:
569
+ {==}
570
+ case C.SEnum{+ns} C.RMissing{}:
571
+ {==}
572
+ case C.SEnum{+ns} C.RNil{}:
573
+ {==}
574
+ case C.SEnum{+ns} C.RCons{h, t}:
575
+ {==}
576
+ case C.SEnum{+ns} C.REnd{}:
577
+ {==}
578
+ case C.SEnum{+ns} C.RKey{k, v, o}:
579
+ {==}
580
+ case C.SVariant{+vn, +vv, +vr} C.RNum{n}:
581
+ {==}
582
+ case C.SVariant{+vn, +vv, +vr} C.RBool{bb}:
583
+ {==}
584
+ case C.SVariant{+vn, +vv, +vr} C.RNull{}:
585
+ {==}
586
+ case C.SVariant{+vn, +vv, +vr} C.RStr{x}:
587
+ {==}
588
+ case C.SVariant{+vn, +vv, +vr} C.RBad{}:
589
+ {==}
590
+ case C.SVariant{+vn, +vv, +vr} C.RTooBig{}:
591
+ {==}
592
+ case C.SVariant{+vn, +vv, +vr} C.RMissing{}:
593
+ {==}
594
+ case C.SVariant{+vn, +vv, +vr} C.RNil{}:
595
+ {==}
596
+ case C.SVariant{+vn, +vv, +vr} C.RCons{h, t}:
597
+ {==}
598
+ case C.SVariant{+vn, +vv, +vr} C.REnd{}:
599
+ %none_later_f(C.check(~rule, vr, C.REnd{}, None{})) : {_ == C.conforms(~rule, vr, C.REnd{}, None{}) : Bool}
600
+ exact(~rule, vr, C.REnd{}, None{})
601
+ case C.SVariant{+vn, +vv, +vr} C.RKey{+k, +v, +o}:
602
+ var_exact(~rule, C.is_missing(C.lookup(vn, C.RKey{k, v, o})), vn, vv, vr, C.RKey{k, v, o}, exact(~rule, vr, C.RKey{k, v, o}, None{}), exact(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}), none_dup(vr, C.RKey{k, v, o}))
603
+ case C.SVEnd{} C.RNum{n}:
604
+ {==}
605
+ case C.SVEnd{} C.RBool{bb}:
606
+ {==}
607
+ case C.SVEnd{} C.RNull{}:
608
+ {==}
609
+ case C.SVEnd{} C.RStr{x}:
610
+ {==}
611
+ case C.SVEnd{} C.RBad{}:
612
+ {==}
613
+ case C.SVEnd{} C.RTooBig{}:
614
+ {==}
615
+ case C.SVEnd{} C.RMissing{}:
616
+ {==}
617
+ case C.SVEnd{} C.RNil{}:
618
+ {==}
619
+ case C.SVEnd{} C.RCons{h, t}:
620
+ {==}
621
+ case C.SVEnd{} C.REnd{}:
622
+ {==}
623
+ case C.SVEnd{} C.RKey{k, v, o}:
624
+ {==}
625
+ case C.STuple{+tt, +tr} C.RNum{n}:
626
+ {==}
627
+ case C.STuple{+tt, +tr} C.RBool{bb}:
628
+ {==}
629
+ case C.STuple{+tt, +tr} C.RNull{}:
630
+ {==}
631
+ case C.STuple{+tt, +tr} C.RStr{x}:
632
+ {==}
633
+ case C.STuple{+tt, +tr} C.RBad{}:
634
+ {==}
635
+ case C.STuple{+tt, +tr} C.RTooBig{}:
636
+ {==}
637
+ case C.STuple{+tt, +tr} C.RMissing{}:
638
+ {==}
639
+ case C.STuple{+tt, +tr} C.RNil{}:
640
+ {==}
641
+ case C.STuple{+tt, +tr} C.RCons{+h, +t}:
642
+ %none_first(C.under(C.AtIndex{0n}, C.check(~rule, tt, h, None{})), C.later_l(C.check(~rule, tr, t, None{}))) : {_ == Bool.and(C.conforms(~rule, tt, h, None{}), C.conforms(~rule, tr, t, None{})) : Bool}
643
+ %none_under(C.AtIndex{0n}, C.check(~rule, tt, h, None{})) : {Bool.and(_, Maybe.is_none(&2, C.Err, C.later_l(C.check(~rule, tr, t, None{})))) == Bool.and(C.conforms(~rule, tt, h, None{}), C.conforms(~rule, tr, t, None{})) : Bool}
644
+ %none_later_l(C.check(~rule, tr, t, None{})) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, tt, h, None{})), _) == Bool.and(C.conforms(~rule, tt, h, None{}), C.conforms(~rule, tr, t, None{})) : Bool}
645
+ %exact(~rule, tt, h, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, tt, h, None{})), Maybe.is_none(&2, C.Err, C.check(~rule, tr, t, None{}))) == Bool.and(_, C.conforms(~rule, tr, t, None{})) : Bool}
646
+ %exact(~rule, tr, t, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, tt, h, None{})), Maybe.is_none(&2, C.Err, C.check(~rule, tr, t, None{}))) == Bool.and(Maybe.is_none(&2, C.Err, C.check(~rule, tt, h, None{})), _) : Bool}
647
+ {==}
648
+ case C.STuple{+tt, +tr} C.REnd{}:
649
+ {==}
650
+ case C.STuple{+tt, +tr} C.RKey{k, v, o}:
651
+ {==}
652
+ case C.STEnd{} C.RNum{n}:
653
+ {==}
654
+ case C.STEnd{} C.RBool{bb}:
655
+ {==}
656
+ case C.STEnd{} C.RNull{}:
657
+ {==}
658
+ case C.STEnd{} C.RStr{x}:
659
+ {==}
660
+ case C.STEnd{} C.RBad{}:
661
+ {==}
662
+ case C.STEnd{} C.RTooBig{}:
663
+ {==}
664
+ case C.STEnd{} C.RMissing{}:
665
+ {==}
666
+ case C.STEnd{} C.RNil{}:
667
+ {==}
668
+ case C.STEnd{} C.RCons{h, t}:
669
+ {==}
670
+ case C.STEnd{} C.REnd{}:
671
+ {==}
672
+ case C.STEnd{} C.RKey{k, v, o}:
673
+ {==}
674
+ case C.SOptional{inner} C.RNum{n}:
675
+ exact(~rule, inner, C.RNum{n}, None{})
676
+ case C.SOptional{inner} C.RBool{bb}:
677
+ exact(~rule, inner, C.RBool{bb}, None{})
678
+ case C.SOptional{inner} C.RNull{}:
679
+ exact(~rule, inner, C.RNull{}, None{})
680
+ case C.SOptional{inner} C.RStr{x}:
681
+ exact(~rule, inner, C.RStr{x}, None{})
682
+ case C.SOptional{inner} C.RBad{}:
683
+ exact(~rule, inner, C.RBad{}, None{})
684
+ case C.SOptional{inner} C.RTooBig{}:
685
+ exact(~rule, inner, C.RTooBig{}, None{})
686
+ case C.SOptional{inner} C.RMissing{}:
687
+ {==}
688
+ case C.SOptional{inner} C.RNil{}:
689
+ exact(~rule, inner, C.RNil{}, None{})
690
+ case C.SOptional{inner} C.RCons{h, t}:
691
+ exact(~rule, inner, C.RCons{h, t}, None{})
692
+ case C.SOptional{inner} C.REnd{}:
693
+ exact(~rule, inner, C.REnd{}, None{})
694
+ case C.SOptional{inner} C.RKey{k, v, o}:
695
+ exact(~rule, inner, C.RKey{k, v, o}, None{})
696
+ case C.SListLen{+lo, +hi, +s2} +r:
697
+ %none_first(C.count_err(lo, hi, r), C.check(~rule, s2, r, None{})) : {_ == Bool.and(C.list_len_ok(lo, hi, r), C.conforms(~rule, s2, r, None{})) : Bool}
698
+ %count_err_none(lo, hi, r) : {Bool.and(Maybe.is_none(&2, C.Err, C.count_err(lo, hi, r)), Maybe.is_none(&2, C.Err, C.check(~rule, s2, r, None{}))) == Bool.and(_, C.conforms(~rule, s2, r, None{})) : Bool}
699
+ %exact(~rule, s2, r, None{}) : {Bool.and(Maybe.is_none(&2, C.Err, C.count_err(lo, hi, r)), Maybe.is_none(&2, C.Err, C.check(~rule, s2, r, None{}))) == Bool.and(Maybe.is_none(&2, C.Err, C.count_err(lo, hi, r)), _) : Bool}
700
+ {==}
701
+
702
+ def Laws.check_exact(rule, s, r, prev):
703
+ exact(~rule, s, r, prev)
704
+
705
+ # ---- tools: a rule's replay ----
706
+ #
707
+ # A path is equal to itself one step at a time; rule_defect compares the
708
+ # rule's reported path with the reported one. At an SRule the first of shape
709
+ # and rule reported the error: the shape did (its replay is the IH), or the
710
+ # shape found nothing and the rule did (first_why of Nothing is the rule's
711
+ # verdict, whose path is this path).
712
+
713
+ def nat_eq_refl_r(a: Nat) -> {Nat.is_eq(a, a) == True{} : Bool}:
714
+ Equal.sym(Bool, True{}, Nat.is_eq(a, a), MN.is_eq_refl_sym(a))
715
+
716
+ def string_eq_refl_r(s: String) -> {String.eq(s, s) == True{} : Bool}:
717
+ Equal.sym(Bool, True{}, String.eq(s, s), MS.eq_refl_sym(s))
718
+
719
+ def and_true2(x: Bool, +y: Bool, hx: {x == True{} : Bool}, hy: {y == True{} : Bool}) -> {Bool.and(x, y) == True{} : Bool}:
720
+ match x:
721
+ case True{}:
722
+ hy
723
+ case False{}:
724
+ Empty.absurd({Bool.and(x, y) == True{} : Bool}, to_empty(hx))
725
+
726
+ def step_refl(x: C.Step) -> {C.step_eq(x, x) == True{} : Bool}:
727
+ match x:
728
+ case C.AtIndex{+i}:
729
+ nat_eq_refl_r(i)
730
+ case C.AtField{+a, +n}:
731
+ and_true2(Nat.is_eq(a, a), String.eq(n, n), nat_eq_refl_r(a), string_eq_refl_r(n))
732
+ case C.BoundAt{+i, +k}:
733
+ and_true2(Nat.is_eq(i, i), String.eq(k, k), nat_eq_refl_r(i), string_eq_refl_r(k))
734
+ case C.AtKey{+k}:
735
+ string_eq_refl_r(k)
736
+
737
+ def path_refl(p: List<&2, C.Step>) -> {C.path_eq(p, p) == True{} : Bool}:
738
+ match p:
739
+ case Nil{}:
740
+ {==}
741
+ case +st <> +q:
742
+ and_true2(C.step_eq(st, st), C.path_eq(q, q), step_refl(st), path_refl(q))
743
+
744
+ def path_or(m: Maybe<&2, C.Err>) -> List<&2, C.Step>:
745
+ match m:
746
+ case None{}:
747
+ Nil{}
748
+ case Some{C.Err{p, w}}:
749
+ p
750
+
751
+ def why_or(m: Maybe<&2, C.Err>) -> C.Why:
752
+ match m:
753
+ case None{}:
754
+ C.Missing{}
755
+ case Some{C.Err{p, w}}:
756
+ w
757
+
758
+ def same_path(-p1: List<&2, C.Step>, -w1: C.Why, -p2: List<&2, C.Step>, -w2: C.Why, h: {Some{C.Err{p1, w1}} == Some{C.Err{p2, w2}} : Maybe<&2, C.Err>}) -> {p1 == p2 : List<&2, C.Step>}:
759
+ Equal.cong(Maybe<&2, C.Err>, List<&2, C.Step>, m => path_or(m), Some{C.Err{p1, w1}}, Some{C.Err{p2, w2}}, h)
760
+
761
+ def same_why(-p1: List<&2, C.Step>, -w1: C.Why, -p2: List<&2, C.Step>, -w2: C.Why, h: {Some{C.Err{p1, w1}} == Some{C.Err{p2, w2}} : Maybe<&2, C.Err>}) -> {w1 == w2 : C.Why}:
762
+ Equal.cong(Maybe<&2, C.Err>, C.Why, m => why_or(m), Some{C.Err{p1, w1}}, Some{C.Err{p2, w2}}, h)
763
+
764
+
765
+ # The reason of an error, kept inside its Maybe: same_why's fact lifted to the
766
+ # report a defect is written as, where what is compared is Some{why} and not
767
+ # why. A rewrite at a Some's inside is not one the checker makes, so this one
768
+ # is a term to hand to the goal rather than a rewrite.
769
+ def maybe_why(m: Maybe<&2, C.Err>) -> Maybe<&2, C.Why>:
770
+ match m:
771
+ case None{}:
772
+ None{}
773
+ case Some{C.Err{p, w}}:
774
+ Some{w}
775
+
776
+ def same_why_m(-p1: List<&2, C.Step>, -w1: C.Why, -p2: List<&2, C.Step>, -w2: C.Why, h: {Some{C.Err{p1, w1}} == Some{C.Err{p2, w2}} : Maybe<&2, C.Err>}) -> {Some{w1} == Some{w2} : Maybe<&2, C.Why>}:
777
+ Equal.cong(Maybe<&2, C.Err>, Maybe<&2, C.Why>, m => maybe_why(m), Some{C.Err{p1, w1}}, Some{C.Err{p2, w2}}, h)
778
+
779
+ # The repeated tag key, in front of the case's own check: the key's error is
780
+ # the report whenever the key is not read once, and otherwise the case's own
781
+ # walk answers it. kc is whether the key is read once, so the key's report is
782
+ # there exactly when it is not.
783
+ def tag_acc_in(kc: Bool, +m1: Maybe<&2, C.Err>, +d1: Maybe<&2, C.Why>, +k: String, +path: List<&2, C.Step>, +why: C.Why, +h: {C.first(C.key_err(kc, k), m1) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, i1: {m1 == Some{C.Err{path, why}} : Maybe<&2, C.Err>} -> {d1 == Some{why} : Maybe<&2, C.Why>}) -> {C.first_why(C.tag_key_defect(Bool.not(kc), k, path), d1) == Some{why} : Maybe<&2, C.Why>}:
784
+ match kc:
785
+ case True{}:
786
+ i1(h)
787
+ case False{}:
788
+ %same_path(C.AtField{0n, k} <> Nil{}, C.RepeatedKey{k}, path, why, h) : {C.first_why(C.tag_key_defect(True{}, k, _), d1) == Some{why} : Maybe<&2, C.Why>}
789
+ %MS.eq_refl_sym(k) : {C.first_why(C.pick_why(_, Some{C.RepeatedKey{k}}, None{}), d1) == Some{why} : Maybe<&2, C.Why>}
790
+ same_why_m(C.AtField{0n, k} <> Nil{}, C.RepeatedKey{k}, path, why, h)
791
+
792
+ # The pick behind check's tag key test, as defect replays it: with the key read
793
+ # once the pick is tag_acc's, and with it read twice defect answers the key's
794
+ # own report before it looks at the case.
795
+ def tag_acc_k(kc: Bool, b: Bool, +m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +d1: Maybe<&2, C.Why>, +d2: Maybe<&2, C.Why>, +k: String, +path: List<&2, C.Step>, +why: C.Why, +h: {C.pick_err(b, C.first(C.key_err(kc, k), m1), m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, i1: {m1 == Some{C.Err{path, why}} : Maybe<&2, C.Err>} -> {d1 == Some{why} : Maybe<&2, C.Why>}, i2: {m2 == Some{C.Err{path, why}} : Maybe<&2, C.Err>} -> {d2 == Some{why} : Maybe<&2, C.Why>}) -> {C.pick_why(b, C.first_why(C.tag_key_defect(Bool.not(kc), k, path), d1), d2) == Some{why} : Maybe<&2, C.Why>}:
796
+ match b:
797
+ case True{}:
798
+ tag_acc_in(kc, m1, d1, k, path, why, h, i1)
799
+ case False{}:
800
+ i2(h)
801
+ def guard_true(b: Bool, m: Maybe<&2, C.Why>, hb: {b == True{} : Bool}) -> {C.guard(b, m) == m : Maybe<&2, C.Why>}:
802
+ match b:
803
+ case True{}:
804
+ {==}
805
+ case False{}:
806
+ Empty.absurd({C.guard(b, m) == m : Maybe<&2, C.Why>}, to_empty(hb))
807
+
808
+ def rule_defect_refl(m: Maybe<&2, C.Err>, +path: List<&2, C.Step>, +why: C.Why, h: {m == Some{C.Err{path, why}} : Maybe<&2, C.Err>}) -> {C.rule_defect(m, path) == Some{why} : Maybe<&2, C.Why>}:
809
+ %Equal.sym(Maybe<&2, C.Err>, m, Some{C.Err{path, why}}, h) : {C.rule_defect(_, path) == Some{why} : Maybe<&2, C.Why>}
810
+ guard_true(C.path_eq(path, path), Some{why}, path_refl(path))
811
+
812
+ def rule_acc_step(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +s2: C.Schema, +x: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.first(m1, m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, s2, x, prev) : Bool}, ih_acc: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, s2, x, prev, p) == Some{w} : Maybe<&2, C.Why>}, ih_rd: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.rule_defect(m2, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.pick_why(C.conforms(~rule, s2, x, prev), C.rule_defect(m2, path), C.defect(~rule, s2, x, prev, path)) == Some{why} : Maybe<&2, C.Why>}:
813
+ match m1:
814
+ case Some{C.Err{+p1, +w1}}:
815
+ %ex : {C.pick_why(_, C.rule_defect(m2, path), C.defect(~rule, s2, x, prev, path)) == Some{why} : Maybe<&2, C.Why>}
816
+ %same_path(p1, w1, path, why, h) : {C.defect(~rule, s2, x, prev, _) == Some{why} : Maybe<&2, C.Why>}
817
+ %same_why(p1, w1, path, why, h) : {C.defect(~rule, s2, x, prev, p1) == Some{_} : Maybe<&2, C.Why>}
818
+ ih_acc(p1, w1, {==})
819
+ case None{}:
820
+ %ex : {C.pick_why(_, C.rule_defect(m2, path), C.defect(~rule, s2, x, prev, path)) == Some{why} : Maybe<&2, C.Why>}
821
+ ih_rd(path, why, h)
822
+
823
+ # At a strict object, what extra_err reports is there: its path is one key,
824
+ # the object has that key, and the key is not a name. A key found further
825
+ # along is still a key of the whole object (extra_lift).
826
+
827
+ def none_some_w(-w: C.Why, h: {None{} == Some{w} : Maybe<&2, C.Why>}) -> Empty:
828
+ to_empty(Equal.sym(Bool, True{}, False{}, Equal.cong(Maybe<&2, C.Why>, Bool, m => Maybe.is_none(&2, C.Why, m), None{}, Some{w}, h)))
829
+
830
+ def none_some_e(-x: C.Err, h: {None{} == Some{x} : Maybe<&2, C.Err>}) -> Empty:
831
+ to_empty(Equal.sym(Bool, True{}, False{}, Equal.cong(Maybe<&2, C.Err>, Bool, m => Maybe.is_none(&2, C.Err, m), None{}, Some{x}, h)))
832
+
833
+ def or_true_x(x: Bool) -> {True{} == Bool.or(x, True{}) : Bool}:
834
+ match x:
835
+ case True{}:
836
+ {==}
837
+ case False{}:
838
+ {==}
839
+
840
+ def guard_or(c: Bool, +d: Bool, +e: Bool, +m: Maybe<&2, C.Why>, +w: C.Why, h: {C.guard(Bool.and(c, d), m) == Some{w} : Maybe<&2, C.Why>}) -> {C.guard(Bool.and(Bool.or(e, c), d), m) == Some{w} : Maybe<&2, C.Why>}:
841
+ match c:
842
+ case True{}:
843
+ %or_true_x(e) : {C.guard(Bool.and(_, d), m) == Some{w} : Maybe<&2, C.Why>}
844
+ h
845
+ case False{}:
846
+ Empty.absurd({C.guard(Bool.and(Bool.or(e, False{}), d), m) == Some{w} : Maybe<&2, C.Why>}, none_some_w(w, h))
847
+
848
+ def extra_lift(+ns: List<&2, String>, +k: String, +v: C.Raw, +o: C.Raw, p: List<&2, C.Step>, +w: C.Why, ih: {C.extra_defect(ns, o, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.extra_defect(ns, C.RKey{k, v, o}, p) == Some{w} : Maybe<&2, C.Why>}:
849
+ match p:
850
+ case C.AtKey{+j} <> Nil{}:
851
+ guard_or(C.has_key(j, o), Bool.not(C.in_names(j, ns)), String.eq(j, k), Some{C.UnknownKey{}}, w, ih)
852
+ case Nil{}:
853
+ Empty.absurd({C.extra_defect(ns, C.RKey{k, v, o}, Nil{}) == Some{w} : Maybe<&2, C.Why>}, none_some_w(w, ih))
854
+ case C.AtIndex{i_} <> q:
855
+ Empty.absurd({C.extra_defect(ns, C.RKey{k, v, o}, C.AtIndex{i_} <> q) == Some{w} : Maybe<&2, C.Why>}, none_some_w(w, ih))
856
+ case C.AtField{a_, n_} <> q:
857
+ Empty.absurd({C.extra_defect(ns, C.RKey{k, v, o}, C.AtField{a_, n_} <> q) == Some{w} : Maybe<&2, C.Why>}, none_some_w(w, ih))
858
+ case C.BoundAt{i_, b_} <> q:
859
+ Empty.absurd({C.extra_defect(ns, C.RKey{k, v, o}, C.BoundAt{i_, b_} <> q) == Some{w} : Maybe<&2, C.Why>}, none_some_w(w, ih))
860
+ case C.AtKey{j} <> st <> q:
861
+ Empty.absurd({C.extra_defect(ns, C.RKey{k, v, o}, C.AtKey{j} <> st <> q) == Some{w} : Maybe<&2, C.Why>}, none_some_w(w, ih))
862
+
863
+ def extra_acc_step(b: Bool, +ns: List<&2, String>, +k: String, +v: C.Raw, +o: C.Raw, +p: List<&2, C.Step>, +w: C.Why, eb: {b == C.in_names(k, ns) : Bool}, +h: {C.pick_err(b, C.extra_err(ns, o), Some{C.Err{C.AtKey{k} <> Nil{}, C.UnknownKey{}}}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}, ih: @pp:List<&2, C.Step> -> @ww:C.Why -> {C.extra_err(ns, o) == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {C.extra_defect(ns, o, pp) == Some{ww} : Maybe<&2, C.Why>}) -> {C.extra_defect(ns, C.RKey{k, v, o}, p) == Some{w} : Maybe<&2, C.Why>}:
864
+ match b:
865
+ case True{}:
866
+ extra_lift(ns, k, v, o, p, w, ih(p, w, h))
867
+ case False{}:
868
+ %same_path(C.AtKey{k} <> Nil{}, C.UnknownKey{}, p, w, h) : {C.extra_defect(ns, C.RKey{k, v, o}, _) == Some{w} : Maybe<&2, C.Why>}
869
+ %same_why(C.AtKey{k} <> Nil{}, C.UnknownKey{}, p, w, h) : {C.extra_defect(ns, C.RKey{k, v, o}, C.AtKey{k} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
870
+ %MS.eq_refl_sym(k) : {C.guard(Bool.and(Bool.or(_, C.has_key(k, o)), Bool.not(C.in_names(k, ns))), Some{C.UnknownKey{}}) == Some{C.UnknownKey{}} : Maybe<&2, C.Why>}
871
+ %eb : {C.guard(Bool.not(_), Some{C.UnknownKey{}}) == Some{C.UnknownKey{}} : Maybe<&2, C.Why>}
872
+ {==}
873
+
874
+ def extra_acc(+ns: List<&2, String>, r: C.Raw, +p: List<&2, C.Step>, +w: C.Why, +h: {C.extra_err(ns, r) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}) -> {C.extra_defect(ns, r, p) == Some{w} : Maybe<&2, C.Why>}:
875
+ match r:
876
+ case C.RKey{+k, +v, +o}:
877
+ extra_acc_step(C.in_names(k, ns), ns, k, v, o, p, w, {==}, h, pp => ww => hh => extra_acc(ns, o, pp, ww, hh))
878
+ case C.RNum{n_}:
879
+ Empty.absurd({C.extra_defect(ns, C.RNum{n_}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
880
+ case C.RBool{b_}:
881
+ Empty.absurd({C.extra_defect(ns, C.RBool{b_}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
882
+ case C.RNull{}:
883
+ Empty.absurd({C.extra_defect(ns, C.RNull{}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
884
+ case C.RStr{s_}:
885
+ Empty.absurd({C.extra_defect(ns, C.RStr{s_}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
886
+ case C.RBad{}:
887
+ Empty.absurd({C.extra_defect(ns, C.RBad{}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
888
+ case C.RTooBig{}:
889
+ Empty.absurd({C.extra_defect(ns, C.RTooBig{}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
890
+ case C.RMissing{}:
891
+ Empty.absurd({C.extra_defect(ns, C.RMissing{}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
892
+ case C.RNil{}:
893
+ Empty.absurd({C.extra_defect(ns, C.RNil{}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
894
+ case C.RCons{h_, t_}:
895
+ Empty.absurd({C.extra_defect(ns, C.RCons{h_, t_}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
896
+ case C.REnd{}:
897
+ Empty.absurd({C.extra_defect(ns, C.REnd{}, p) == Some{w} : Maybe<&2, C.Why>}, none_some_e(C.Err{p, w}, h))
898
+
899
+ def strict_acc_step(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +ns: List<&2, String>, +s2: C.Schema, +x: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.first(m1, C.extra_err(ns, x)) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, s2, x, prev) : Bool}, ih_acc: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, s2, x, prev, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.pick_why(C.conforms(~rule, s2, x, prev), C.extra_defect(ns, x, path), C.defect(~rule, s2, x, prev, path)) == Some{why} : Maybe<&2, C.Why>}:
900
+ match m1:
901
+ case Some{C.Err{+p1, +w1}}:
902
+ %ex : {C.pick_why(_, C.extra_defect(ns, x, path), C.defect(~rule, s2, x, prev, path)) == Some{why} : Maybe<&2, C.Why>}
903
+ %same_path(p1, w1, path, why, h) : {C.defect(~rule, s2, x, prev, _) == Some{why} : Maybe<&2, C.Why>}
904
+ %same_why(p1, w1, path, why, h) : {C.defect(~rule, s2, x, prev, p1) == Some{_} : Maybe<&2, C.Why>}
905
+ ih_acc(p1, w1, {==})
906
+ case None{}:
907
+ %ex : {C.pick_why(_, C.extra_defect(ns, x, path), C.defect(~rule, s2, x, prev, path)) == Some{why} : Maybe<&2, C.Why>}
908
+ extra_acc(ns, x, path, why, h)
909
+
910
+ # ---- repeated_key_refused ----
911
+ #
912
+ # Both halves compute, at the explicit constructors the law names: key_once_at
913
+ # sees the second "a" (the first has set its flag), conforms is False there,
914
+ # and check reports the key at its own name before it looks at the value under
915
+ # it. Nothing here rewrites; the law is decided by evaluation, which is the
916
+ # point of stating it at literals.
917
+ def Laws.repeated_key_refused():
918
+ (({==}, {==}), ({==}, {==}))
919
+
920
+ # ---- repeated_tag_refused ----
921
+ #
922
+ # The same reading one constructor along: the tag names the case (the first
923
+ # "t" holds the case's name), the key is there twice (the second "t" is read
924
+ # with the flag the first one set, so key_once is False), conforms is False
925
+ # there, and check reports the key at its own name before it looks at the
926
+ # case's schema. The case's own schema is SEnd{}, which reads no key and
927
+ # accepts any object, so what is decided here is the tag key's own test and
928
+ # nothing else -- the same reading as repeated_key_refused, one constructor
929
+ # along.
930
+ def Laws.repeated_tag_refused():
931
+ ({==}, {==})
932
+
933
+ # ---- unnamed_key_ignored ----
934
+ #
935
+ # Every reading computes, at the explicit constructors the law names: a first
936
+ # key that is not the field's is not looked at, the unnamed key is never looked
937
+ # up wherever it stands, and at the variant the same two values go through
938
+ # pick_bool and none_present over the concrete chain. Nothing here rewrites;
939
+ # the law is decided by evaluation, which is the point of stating it at
940
+ # literals.
941
+ def Laws.unnamed_key_ignored():
942
+ ({==}, ({==}, {==}))
943
+
944
+ # ---- what check reports is there ----
945
+ #
946
+ # The same walk again. Where check reports here, the path is empty and the
947
+ # reason is the one defect computes at that node. Where it reports what a
948
+ # part reported, the path has one more step in front (under), or counts one
949
+ # more place along (later_l, later_i, later_f); defect takes the step off, or
950
+ # counts back, and passes the parts before, which conform because check found
951
+ # nothing in them (exact). The induction hypotheses are passed in as functions.
952
+
953
+ def none_some(-x: C.Err, h: {None{} == Some{x} : Maybe<&2, C.Err>}) -> Empty:
954
+ to_empty(Equal.sym(Bool, True{}, False{}, Equal.cong(Maybe<&2, C.Err>, Bool, m => Maybe.is_none(&2, C.Err, m), None{}, Some{x}, h)))
955
+
956
+
957
+ # An SNatIn whose check reported an error: the test failed (a passing test
958
+ # reports nothing), so the reason is NotIn at the value's own path.
959
+ def acc_num_in(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, +lo: Nat, +hi: Nat, +n: Nat, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, eb: {b == C.num_ok(lo, hi, n) : Bool}, +h: {C.in_err(b, C.NotIn{lo, hi}) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}) -> {C.nat_in_defect(lo, hi, C.RNum{n}, path) == Some{why} : Maybe<&2, C.Why>}:
960
+ match b:
961
+ case True{}:
962
+ Empty.absurd({C.nat_in_defect(lo, hi, C.RNum{n}, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
963
+ case False{}:
964
+ %same_path(Nil{}, C.NotIn{lo, hi}, path, why, h) : {C.nat_in_defect(lo, hi, C.RNum{n}, _) == Some{why} : Maybe<&2, C.Why>}
965
+ %same_why(Nil{}, C.NotIn{lo, hi}, path, why, h) : {C.nat_in_defect(lo, hi, C.RNum{n}, Nil{}) == Some{_} : Maybe<&2, C.Why>}
966
+ %eb : {C.guard(Bool.not(_), Some{C.NotIn{lo, hi}}) == Some{C.NotIn{lo, hi}} : Maybe<&2, C.Why>}
967
+ {==}
968
+
969
+ def list_path(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p2: List<&2, C.Step>, +w2: C.Why, +e: C.Schema, +h1: C.Raw, +t: C.Raw, +prev: Maybe<&2, Nat>, +ex1: {True{} == C.conforms(~rule, e, h1, None{}) : Bool}, ih: {C.defect(~rule, C.SList{e}, t, None{}, p2) == Some{w2} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, C.later_l_path(p2)) == Some{w2} : Maybe<&2, C.Why>}:
970
+ match p2:
971
+ case Nil{}:
972
+ %ex1 : {C.guard(_, C.defect(~rule, C.SList{e}, t, None{}, Nil{})) == Some{w2} : Maybe<&2, C.Why>}
973
+ ih
974
+ case C.AtIndex{+j} <> +q:
975
+ %ex1 : {C.guard(_, C.defect(~rule, C.SList{e}, t, None{}, C.AtIndex{j} <> q)) == Some{w2} : Maybe<&2, C.Why>}
976
+ ih
977
+ case C.AtField{+k, +n} <> +q:
978
+ %ex1 : {C.guard(_, C.defect(~rule, C.SList{e}, t, None{}, C.AtField{k, n} <> q)) == Some{w2} : Maybe<&2, C.Why>}
979
+ ih
980
+ case C.BoundAt{+j, +k} <> +q:
981
+ %ex1 : {C.guard(_, C.defect(~rule, C.SList{e}, t, None{}, C.BoundAt{j, k} <> q)) == Some{w2} : Maybe<&2, C.Why>}
982
+ ih
983
+ case C.AtKey{+k} <> +q:
984
+ %ex1 : {C.guard(_, C.defect(~rule, C.SList{e}, t, None{}, C.AtKey{k} <> q)) == Some{w2} : Maybe<&2, C.Why>}
985
+ ih
986
+
987
+ def list_tail(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m2: Maybe<&2, C.Err>, +e: C.Schema, +h1: C.Raw, +t: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.later_l(m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, +ex1: {True{} == C.conforms(~rule, e, h1, None{}) : Bool}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, C.SList{e}, t, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
988
+ match m2:
989
+ case None{}:
990
+ Empty.absurd({C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
991
+ case Some{C.Err{+p2, +w2}}:
992
+ %same_path(C.later_l_path(p2), w2, path, why, h) : {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, _) == Some{why} : Maybe<&2, C.Why>}
993
+ %same_why(C.later_l_path(p2), w2, path, why, h) : {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, C.later_l_path(p2)) == Some{_} : Maybe<&2, C.Why>}
994
+ list_path(~rule, p2, w2, e, h1, t, prev, ex1, ih2(p2, w2, {==}))
995
+
996
+ def list_step(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +e: C.Schema, +h1: C.Raw, +t: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.first(C.under(C.AtIndex{0n}, m1), C.later_l(m2)) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex1: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, e, h1, None{}) : Bool}, ih1: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, e, h1, None{}, p) == Some{w} : Maybe<&2, C.Why>}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, C.SList{e}, t, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
997
+ match m1:
998
+ case Some{C.Err{+p1, +w1}}:
999
+ %same_path(C.AtIndex{0n} <> p1, w1, path, why, h) : {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1000
+ %same_why(C.AtIndex{0n} <> p1, w1, path, why, h) : {C.defect(~rule, C.SList{e}, C.RCons{h1, t}, prev, C.AtIndex{0n} <> p1) == Some{_} : Maybe<&2, C.Why>}
1001
+ ih1(p1, w1, {==})
1002
+ case None{}:
1003
+ list_tail(~rule, m2, e, h1, t, prev, path, why, h, ex1, ih2)
1004
+
1005
+ def tup_path(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p2: List<&2, C.Step>, +w2: C.Why, +e: C.Schema, +tr: C.Schema, +h1: C.Raw, +t: C.Raw, +prev: Maybe<&2, Nat>, +ex1: {True{} == C.conforms(~rule, e, h1, None{}) : Bool}, ih: {C.defect(~rule, tr, t, None{}, p2) == Some{w2} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, C.later_l_path(p2)) == Some{w2} : Maybe<&2, C.Why>}:
1006
+ match p2:
1007
+ case Nil{}:
1008
+ %ex1 : {C.guard(_, C.defect(~rule, tr, t, None{}, Nil{})) == Some{w2} : Maybe<&2, C.Why>}
1009
+ ih
1010
+ case C.AtIndex{+j} <> +q:
1011
+ %ex1 : {C.guard(_, C.defect(~rule, tr, t, None{}, C.AtIndex{j} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1012
+ ih
1013
+ case C.AtField{+k, +n} <> +q:
1014
+ %ex1 : {C.guard(_, C.defect(~rule, tr, t, None{}, C.AtField{k, n} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1015
+ ih
1016
+ case C.BoundAt{+j, +k} <> +q:
1017
+ %ex1 : {C.guard(_, C.defect(~rule, tr, t, None{}, C.BoundAt{j, k} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1018
+ ih
1019
+ case C.AtKey{+k} <> +q:
1020
+ %ex1 : {C.guard(_, C.defect(~rule, tr, t, None{}, C.AtKey{k} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1021
+ ih
1022
+
1023
+ def tup_tail(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m2: Maybe<&2, C.Err>, +e: C.Schema, +tr: C.Schema, +h1: C.Raw, +t: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.later_l(m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, +ex1: {True{} == C.conforms(~rule, e, h1, None{}) : Bool}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, tr, t, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1024
+ match m2:
1025
+ case None{}:
1026
+ Empty.absurd({C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1027
+ case Some{C.Err{+p2, +w2}}:
1028
+ %same_path(C.later_l_path(p2), w2, path, why, h) : {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1029
+ %same_why(C.later_l_path(p2), w2, path, why, h) : {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, C.later_l_path(p2)) == Some{_} : Maybe<&2, C.Why>}
1030
+ tup_path(~rule, p2, w2, e, tr, h1, t, prev, ex1, ih2(p2, w2, {==}))
1031
+
1032
+ def tup_step(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +e: C.Schema, +tr: C.Schema, +h1: C.Raw, +t: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.first(C.under(C.AtIndex{0n}, m1), C.later_l(m2)) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex1: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, e, h1, None{}) : Bool}, ih1: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, e, h1, None{}, p) == Some{w} : Maybe<&2, C.Why>}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, tr, t, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1033
+ match m1:
1034
+ case Some{C.Err{+p1, +w1}}:
1035
+ %same_path(C.AtIndex{0n} <> p1, w1, path, why, h) : {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1036
+ %same_why(C.AtIndex{0n} <> p1, w1, path, why, h) : {C.defect(~rule, C.STuple{e, tr}, C.RCons{h1, t}, prev, C.AtIndex{0n} <> p1) == Some{_} : Maybe<&2, C.Why>}
1037
+ ih1(p1, w1, {==})
1038
+ case None{}:
1039
+ tup_tail(~rule, m2, e, tr, h1, t, prev, path, why, h, ex1, ih2)
1040
+
1041
+ def field_path_end(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p2: List<&2, C.Step>, +w2: C.Why, +name: String, +fs: C.Schema, +rest: C.Schema, +prev: Maybe<&2, Nat>, +ex1: {True{} == C.conforms(~rule, fs, C.RMissing{}, None{}) : Bool}, ih: {C.defect(~rule, rest, C.REnd{}, None{}, p2) == Some{w2} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, C.later_f_path(p2)) == Some{w2} : Maybe<&2, C.Why>}:
1042
+ match p2:
1043
+ case Nil{}:
1044
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.REnd{}, None{}, Nil{})) == Some{w2} : Maybe<&2, C.Why>}
1045
+ ih
1046
+ case C.AtField{+j, +n} <> +q:
1047
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.REnd{}, None{}, C.AtField{j, n} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1048
+ ih
1049
+ case C.AtIndex{+j} <> +q:
1050
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.REnd{}, None{}, C.AtIndex{j} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1051
+ ih
1052
+ case C.BoundAt{+j, +kk} <> +q:
1053
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.REnd{}, None{}, C.BoundAt{j, kk} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1054
+ ih
1055
+ case C.AtKey{+kk} <> +q:
1056
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.REnd{}, None{}, C.AtKey{kk} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1057
+ ih
1058
+
1059
+ def field_tail_end(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m2: Maybe<&2, C.Err>, +name: String, +fs: C.Schema, +rest: C.Schema, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.later_f(m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, +ex1: {True{} == C.conforms(~rule, fs, C.RMissing{}, None{}) : Bool}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, rest, C.REnd{}, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1060
+ match m2:
1061
+ case None{}:
1062
+ Empty.absurd({C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1063
+ case Some{C.Err{+p2, +w2}}:
1064
+ %same_path(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1065
+ %same_why(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, C.later_f_path(p2)) == Some{_} : Maybe<&2, C.Why>}
1066
+ field_path_end(~rule, p2, w2, name, fs, rest, prev, ex1, ih2(p2, w2, {==}))
1067
+
1068
+ def field_step_end(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +name: String, +fs: C.Schema, +rest: C.Schema, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.first(C.under(C.AtField{0n, name}, m1), C.later_f(m2)) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex1: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, fs, C.RMissing{}, None{}) : Bool}, ih1: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, fs, C.RMissing{}, None{}, p) == Some{w} : Maybe<&2, C.Why>}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, rest, C.REnd{}, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1069
+ match m1:
1070
+ case Some{C.Err{+p1, +w1}}:
1071
+ %same_path(C.AtField{0n, name} <> p1, w1, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1072
+ %same_why(C.AtField{0n, name} <> p1, w1, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.REnd{}, prev, C.AtField{0n, name} <> p1) == Some{_} : Maybe<&2, C.Why>}
1073
+ %MS.eq_refl_sym(name) : {C.guard(_, C.defect(~rule, fs, C.RMissing{}, None{}, p1)) == Some{w1} : Maybe<&2, C.Why>}
1074
+ ih1(p1, w1, {==})
1075
+ case None{}:
1076
+ field_tail_end(~rule, m2, name, fs, rest, prev, path, why, h, ex1, ih2)
1077
+
1078
+ def field_path_key(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p2: List<&2, C.Step>, +w2: C.Why, +name: String, +fs: C.Schema, +rest: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +ex1: {True{} == C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}) : Bool}, ih: {C.defect(~rule, rest, C.RKey{k, v, o}, None{}, p2) == Some{w2} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, C.later_f_path(p2)) == Some{w2} : Maybe<&2, C.Why>}:
1079
+ match p2:
1080
+ case Nil{}:
1081
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.RKey{k, v, o}, None{}, Nil{})) == Some{w2} : Maybe<&2, C.Why>}
1082
+ ih
1083
+ case C.AtField{+j, +n} <> +q:
1084
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.RKey{k, v, o}, None{}, C.AtField{j, n} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1085
+ ih
1086
+ case C.AtIndex{+j} <> +q:
1087
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.RKey{k, v, o}, None{}, C.AtIndex{j} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1088
+ ih
1089
+ case C.BoundAt{+j, +kk} <> +q:
1090
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.RKey{k, v, o}, None{}, C.BoundAt{j, kk} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1091
+ ih
1092
+ case C.AtKey{+kk} <> +q:
1093
+ %ex1 : {C.guard(_, C.defect(~rule, rest, C.RKey{k, v, o}, None{}, C.AtKey{kk} <> q)) == Some{w2} : Maybe<&2, C.Why>}
1094
+ ih
1095
+
1096
+ def field_tail_key(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m2: Maybe<&2, C.Err>, +name: String, +fs: C.Schema, +rest: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.later_f(m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, +ex1: {True{} == C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}) : Bool}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, rest, C.RKey{k, v, o}, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1097
+ match m2:
1098
+ case None{}:
1099
+ Empty.absurd({C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1100
+ case Some{C.Err{+p2, +w2}}:
1101
+ %same_path(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1102
+ %same_why(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, C.later_f_path(p2)) == Some{_} : Maybe<&2, C.Why>}
1103
+ field_path_key(~rule, p2, w2, name, fs, rest, k, v, o, prev, ex1, ih2(p2, w2, {==}))
1104
+
1105
+ def field_step_key(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +m2: Maybe<&2, C.Err>, +name: String, +fs: C.Schema, +rest: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, k0: Bool, +kc: {k0 == C.key_once_at(o, String.eq(k, name), name) : Bool}, +h: {C.first(C.key_err(k0, name), C.first(C.under(C.AtField{0n, name}, m1), C.later_f(m2))) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex1: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}) : Bool}, ih1: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}, p) == Some{w} : Maybe<&2, C.Why>}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, rest, C.RKey{k, v, o}, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1106
+ match m1:
1107
+ case Some{C.Err{+p1, +w1}}:
1108
+ match k0:
1109
+ case True{}:
1110
+ %same_path(C.AtField{0n, name} <> p1, w1, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1111
+ %same_why(C.AtField{0n, name} <> p1, w1, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, C.AtField{0n, name} <> p1) == Some{_} : Maybe<&2, C.Why>}
1112
+ %kc : {C.pick_why(Bool.not(_), C.at_end(C.RepeatedKey{name}, p1), C.guard(String.eq(name, name), C.defect(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}, p1))) == Some{w1} : Maybe<&2, C.Why>}
1113
+ %MS.eq_refl_sym(name) : {C.guard(_, C.defect(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}, p1)) == Some{w1} : Maybe<&2, C.Why>}
1114
+ ih1(p1, w1, {==})
1115
+ case False{}:
1116
+ %same_path(C.AtField{0n, name} <> Nil{}, C.RepeatedKey{name}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1117
+ %same_why(C.AtField{0n, name} <> Nil{}, C.RepeatedKey{name}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, C.AtField{0n, name} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
1118
+ %kc : {C.pick_why(Bool.not(_), C.at_end(C.RepeatedKey{name}, Nil{}), C.guard(String.eq(name, name), C.defect(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}, Nil{}))) == Some{C.RepeatedKey{name}} : Maybe<&2, C.Why>}
1119
+ {==}
1120
+ case None{}:
1121
+ match k0:
1122
+ case True{}:
1123
+ field_tail_key(~rule, m2, name, fs, rest, k, v, o, prev, path, why, h, ex1, ih2)
1124
+ case False{}:
1125
+ %same_path(C.AtField{0n, name} <> Nil{}, C.RepeatedKey{name}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1126
+ %same_why(C.AtField{0n, name} <> Nil{}, C.RepeatedKey{name}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RKey{k, v, o}, prev, C.AtField{0n, name} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
1127
+ %kc : {C.pick_why(Bool.not(_), C.at_end(C.RepeatedKey{name}, Nil{}), C.guard(String.eq(name, name), C.defect(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}, Nil{}))) == Some{C.RepeatedKey{name}} : Maybe<&2, C.Why>}
1128
+ {==}
1129
+
1130
+ def acc_true(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, bb: Bool, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.true_err(bb) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}) -> {C.defect(~rule, C.STrue{}, C.RBool{bb}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1131
+ match bb:
1132
+ case True{}:
1133
+ Empty.absurd({C.defect(~rule, C.STrue{}, C.RBool{True{}}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1134
+ case False{}:
1135
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RBool{False{}}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1136
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RBool{False{}}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1137
+ {==}
1138
+
1139
+ def acc_enum(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, +x: String, +ns: List<&2, String>, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, eb: {b == C.in_names(x, ns) : Bool}, +h: {C.enum_err(b) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}) -> {C.defect(~rule, C.SEnum{ns}, C.RStr{x}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1140
+ match b:
1141
+ case True{}:
1142
+ Empty.absurd({C.defect(~rule, C.SEnum{ns}, C.RStr{x}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1143
+ case False{}:
1144
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1145
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1146
+ %eb : {C.guard(Bool.not(_), Some{C.NotOneOf{}}) == Some{C.NotOneOf{}} : Maybe<&2, C.Why>}
1147
+ {==}
1148
+
1149
+ # A variant on an empty object: every key is absent, go on with the rest.
1150
+ def var_end_path(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p2: List<&2, C.Step>, +w2: C.Why, +vn: String, +vv: C.Schema, +vr: C.Schema, +prev: Maybe<&2, Nat>, ih: {C.defect(~rule, vr, C.REnd{}, None{}, p2) == Some{w2} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.REnd{}, prev, C.later_f_path(p2)) == Some{w2} : Maybe<&2, C.Why>}:
1151
+ match p2:
1152
+ case Nil{}:
1153
+ ih
1154
+ case C.AtField{+j, +n} <> +q:
1155
+ ih
1156
+ case C.AtIndex{+j} <> +q:
1157
+ ih
1158
+ case C.BoundAt{+j, +kk} <> +q:
1159
+ ih
1160
+ case C.AtKey{+kk} <> +q:
1161
+ ih
1162
+
1163
+ def var_end_tail(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m2: Maybe<&2, C.Err>, +vn: String, +vv: C.Schema, +vr: C.Schema, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.later_f(m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, vr, C.REnd{}, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.REnd{}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1164
+ match m2:
1165
+ case None{}:
1166
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.REnd{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1167
+ case Some{C.Err{+p2, +w2}}:
1168
+ %same_path(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1169
+ %same_why(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.REnd{}, prev, C.later_f_path(p2)) == Some{_} : Maybe<&2, C.Why>}
1170
+ var_end_path(~rule, p2, w2, vn, vv, vr, prev, ih2(p2, w2, {==}))
1171
+
1172
+ # A key absent from the object: the error is the rest's, one field along.
1173
+ def var_absent_path(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p2: List<&2, C.Step>, +w2: C.Why, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +eb: {True{} == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, ih: {C.defect(~rule, vr, C.RKey{k, v, o}, None{}, p2) == Some{w2} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.later_f_path(p2)) == Some{w2} : Maybe<&2, C.Why>}:
1174
+ match p2:
1175
+ case Nil{}:
1176
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, Nil{}), None{}) == Some{w2} : Maybe<&2, C.Why>}
1177
+ ih
1178
+ case C.AtField{+j, +n} <> +q:
1179
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.AtField{j, n} <> q), C.guard(C.conforms(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}), C.dup_defect(vr, C.RKey{k, v, o}, C.AtField{j, n} <> q))) == Some{w2} : Maybe<&2, C.Why>}
1180
+ ih
1181
+ case C.AtIndex{+j} <> +q:
1182
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.AtIndex{j} <> q), None{}) == Some{w2} : Maybe<&2, C.Why>}
1183
+ ih
1184
+ case C.BoundAt{+j, +kk} <> +q:
1185
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.BoundAt{j, kk} <> q), None{}) == Some{w2} : Maybe<&2, C.Why>}
1186
+ ih
1187
+ case C.AtKey{+kk} <> +q:
1188
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.AtKey{kk} <> q), None{}) == Some{w2} : Maybe<&2, C.Why>}
1189
+ ih
1190
+
1191
+ def var_absent(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m2: Maybe<&2, C.Err>, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +eb: {True{} == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, +h: {C.later_f(m2) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ih1: @p:List<&2, C.Step> -> @w:C.Why -> {m2 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, vr, C.RKey{k, v, o}, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1192
+ match m2:
1193
+ case None{}:
1194
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1195
+ case Some{C.Err{+p2, +w2}}:
1196
+ %same_path(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1197
+ %same_why(C.later_f_path(p2), w2, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.later_f_path(p2)) == Some{_} : Maybe<&2, C.Why>}
1198
+ var_absent_path(~rule, p2, w2, vn, vv, vr, k, v, o, prev, eb, ih1(p2, w2, {==}))
1199
+
1200
+ # The shape of a second-key error: its path starts with a field step.
1201
+ def head_is_field(p: List<&2, C.Step>) -> Bool:
1202
+ match p:
1203
+ case C.AtField{k, n} <> q:
1204
+ True{}
1205
+ case _:
1206
+ False{}
1207
+
1208
+ def shape_path(pp: List<&2, C.Step>, sh: {head_is_field(pp) == True{} : Bool}) -> {head_is_field(C.later_f_path(pp)) == True{} : Bool}:
1209
+ match pp:
1210
+ case Nil{}:
1211
+ Empty.absurd({False{} == True{} : Bool}, to_empty(sh))
1212
+ case C.AtField{j, n} <> q:
1213
+ {==}
1214
+ case C.AtIndex{j} <> q:
1215
+ Empty.absurd({False{} == True{} : Bool}, to_empty(sh))
1216
+ case C.BoundAt{j, kk} <> q:
1217
+ Empty.absurd({False{} == True{} : Bool}, to_empty(sh))
1218
+ case C.AtKey{kk} <> q:
1219
+ Empty.absurd({False{} == True{} : Bool}, to_empty(sh))
1220
+
1221
+ def shape_tail(m: Maybe<&2, C.Err>, +p: List<&2, C.Step>, +w: C.Why, +h: {C.later_f(m) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}, ih: @pp:List<&2, C.Step> -> @ww:C.Why -> {m == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {head_is_field(pp) == True{} : Bool}) -> {head_is_field(p) == True{} : Bool}:
1222
+ match m:
1223
+ case None{}:
1224
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1225
+ case Some{C.Err{+p1, +w1}}:
1226
+ %same_path(C.later_f_path(p1), w1, p, w, h) : {head_is_field(_) == True{} : Bool}
1227
+ shape_path(p1, ih(p1, w1, {==}))
1228
+
1229
+ def shape_step(b: Bool, +n: String, +rr: C.Schema, +r: C.Raw, +p: List<&2, C.Step>, +w: C.Why, +h: {C.pick_err(b, C.later_f(C.dup_err(rr, r)), Some{C.Err{C.AtField{0n, n} <> Nil{}, C.TwoVariants{}}}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}, ih: @pp:List<&2, C.Step> -> @ww:C.Why -> {C.dup_err(rr, r) == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {head_is_field(pp) == True{} : Bool}) -> {head_is_field(p) == True{} : Bool}:
1230
+ match b:
1231
+ case True{}:
1232
+ shape_tail(C.dup_err(rr, r), p, w, h, ih)
1233
+ case False{}:
1234
+ %same_path(C.AtField{0n, n} <> Nil{}, C.TwoVariants{}, p, w, h) : {head_is_field(_) == True{} : Bool}
1235
+ {==}
1236
+
1237
+ # arms: s
1238
+ # arms leaf: Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1239
+ def dup_shape(s: C.Schema, +r: C.Raw, +p: List<&2, C.Step>, +w: C.Why, +h: {C.dup_err(s, r) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}) -> {head_is_field(p) == True{} : Bool}:
1240
+ match s:
1241
+ case C.SNat{}:
1242
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1243
+ case C.SNatIn{lo_, hi_}:
1244
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1245
+ case C.SStr{}:
1246
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1247
+ case C.SStrLen{lo_, hi_, s_}:
1248
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1249
+ case C.SOpt{inner_}:
1250
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1251
+ case C.SList{elem_}:
1252
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1253
+ case C.SField{name_, s_, rest_}:
1254
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1255
+ case C.SEnd{}:
1256
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1257
+ case C.SRule{s_, tag_}:
1258
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1259
+ case C.SStrict{s_}:
1260
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1261
+ case C.STagged{key_, name_, s_, rest_}:
1262
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1263
+ case C.STagEnd{key_}:
1264
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1265
+ case C.SBool{}:
1266
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1267
+ case C.STrue{}:
1268
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1269
+ case C.SEnum{names_}:
1270
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1271
+ case C.SVariant{+vn, vv, +vr}:
1272
+ shape_step(C.is_missing(C.lookup(vn, r)), vn, vr, r, p, w, h, pp => ww => hh => dup_shape(vr, r, pp, ww, hh))
1273
+ case C.SVEnd{}:
1274
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1275
+ case C.STuple{s_, rest_}:
1276
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1277
+ case C.STEnd{}:
1278
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1279
+ case C.SOptional{inner_}:
1280
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1281
+ case C.SListLen{lo_, hi_, s_}:
1282
+ Empty.absurd({head_is_field(p) == True{} : Bool}, none_some(C.Err{p, w}, h))
1283
+
1284
+ # What dup_err reports, dup_defect replays.
1285
+ def dup_path(pp: List<&2, C.Step>, +ww: C.Why, +n: String, +vs: C.Schema, +rr: C.Schema, +r: C.Raw, +eb: {True{} == C.is_missing(C.lookup(n, r)) : Bool}, d: {C.dup_defect(rr, r, pp) == Some{ww} : Maybe<&2, C.Why>}, sh: {head_is_field(pp) == True{} : Bool}) -> {C.dup_defect(C.SVariant{n, vs, rr}, r, C.later_f_path(pp)) == Some{ww} : Maybe<&2, C.Why>}:
1286
+ match pp:
1287
+ case Nil{}:
1288
+ Empty.absurd({C.dup_defect(C.SVariant{n, vs, rr}, r, Nil{}) == Some{ww} : Maybe<&2, C.Why>}, to_empty(sh))
1289
+ case C.AtField{+j, +m} <> +q:
1290
+ %eb : {C.guard(_, C.dup_defect(rr, r, C.AtField{j, m} <> q)) == Some{ww} : Maybe<&2, C.Why>}
1291
+ d
1292
+ case C.AtIndex{j} <> q:
1293
+ Empty.absurd({C.dup_defect(C.SVariant{n, vs, rr}, r, C.AtIndex{j} <> q) == Some{ww} : Maybe<&2, C.Why>}, to_empty(sh))
1294
+ case C.BoundAt{j, kk} <> q:
1295
+ Empty.absurd({C.dup_defect(C.SVariant{n, vs, rr}, r, C.BoundAt{j, kk} <> q) == Some{ww} : Maybe<&2, C.Why>}, to_empty(sh))
1296
+ case C.AtKey{kk} <> q:
1297
+ Empty.absurd({C.dup_defect(C.SVariant{n, vs, rr}, r, C.AtKey{kk} <> q) == Some{ww} : Maybe<&2, C.Why>}, to_empty(sh))
1298
+
1299
+ def dup_tail(m: Maybe<&2, C.Err>, +n: String, +vs: C.Schema, +rr: C.Schema, +r: C.Raw, +p: List<&2, C.Step>, +w: C.Why, +eb: {True{} == C.is_missing(C.lookup(n, r)) : Bool}, +h: {C.later_f(m) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}, ih: @pp:List<&2, C.Step> -> @ww:C.Why -> {m == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {C.dup_defect(rr, r, pp) == Some{ww} : Maybe<&2, C.Why>}, sh: @pp:List<&2, C.Step> -> @ww:C.Why -> {m == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {head_is_field(pp) == True{} : Bool}) -> {C.dup_defect(C.SVariant{n, vs, rr}, r, p) == Some{w} : Maybe<&2, C.Why>}:
1300
+ match m:
1301
+ case None{}:
1302
+ Empty.absurd({C.dup_defect(C.SVariant{n, vs, rr}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1303
+ case Some{C.Err{+p1, +w1}}:
1304
+ %same_path(C.later_f_path(p1), w1, p, w, h) : {C.dup_defect(C.SVariant{n, vs, rr}, r, _) == Some{w} : Maybe<&2, C.Why>}
1305
+ %same_why(C.later_f_path(p1), w1, p, w, h) : {C.dup_defect(C.SVariant{n, vs, rr}, r, C.later_f_path(p1)) == Some{_} : Maybe<&2, C.Why>}
1306
+ dup_path(p1, w1, n, vs, rr, r, eb, ih(p1, w1, {==}), sh(p1, w1, {==}))
1307
+
1308
+ def dup_step(b: Bool, +n: String, +vs: C.Schema, +rr: C.Schema, +r: C.Raw, eb: {b == C.is_missing(C.lookup(n, r)) : Bool}, +p: List<&2, C.Step>, +w: C.Why, +h: {C.pick_err(b, C.later_f(C.dup_err(rr, r)), Some{C.Err{C.AtField{0n, n} <> Nil{}, C.TwoVariants{}}}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}, ih: @pp:List<&2, C.Step> -> @ww:C.Why -> {C.dup_err(rr, r) == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {C.dup_defect(rr, r, pp) == Some{ww} : Maybe<&2, C.Why>}, sh: @pp:List<&2, C.Step> -> @ww:C.Why -> {C.dup_err(rr, r) == Some{C.Err{pp, ww}} : Maybe<&2, C.Err>} -> {head_is_field(pp) == True{} : Bool}) -> {C.dup_defect(C.SVariant{n, vs, rr}, r, p) == Some{w} : Maybe<&2, C.Why>}:
1309
+ match b:
1310
+ case True{}:
1311
+ dup_tail(C.dup_err(rr, r), n, vs, rr, r, p, w, eb, h, ih, sh)
1312
+ case False{}:
1313
+ %same_path(C.AtField{0n, n} <> Nil{}, C.TwoVariants{}, p, w, h) : {C.dup_defect(C.SVariant{n, vs, rr}, r, _) == Some{w} : Maybe<&2, C.Why>}
1314
+ %same_why(C.AtField{0n, n} <> Nil{}, C.TwoVariants{}, p, w, h) : {C.dup_defect(C.SVariant{n, vs, rr}, r, C.AtField{0n, n} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
1315
+ %MS.eq_refl_sym(n) : {C.guard(Bool.and(_, Bool.not(C.is_missing(C.lookup(n, r)))), Some{C.TwoVariants{}}) == Some{C.TwoVariants{}} : Maybe<&2, C.Why>}
1316
+ %eb : {C.guard(Bool.and(True{}, Bool.not(_)), Some{C.TwoVariants{}}) == Some{C.TwoVariants{}} : Maybe<&2, C.Why>}
1317
+ {==}
1318
+
1319
+ # arms: s
1320
+ # arms leaf: Empty.absurd({C.dup_defect($S, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1321
+ def dup_acc(s: C.Schema, +r: C.Raw, +p: List<&2, C.Step>, +w: C.Why, +h: {C.dup_err(s, r) == Some{C.Err{p, w}} : Maybe<&2, C.Err>}) -> {C.dup_defect(s, r, p) == Some{w} : Maybe<&2, C.Why>}:
1322
+ match s:
1323
+ case C.SNat{}:
1324
+ Empty.absurd({C.dup_defect(C.SNat{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1325
+ case C.SNatIn{lo_, hi_}:
1326
+ Empty.absurd({C.dup_defect(C.SNatIn{lo_, hi_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1327
+ case C.SStr{}:
1328
+ Empty.absurd({C.dup_defect(C.SStr{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1329
+ case C.SStrLen{lo_, hi_, s_}:
1330
+ Empty.absurd({C.dup_defect(C.SStrLen{lo_, hi_, s_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1331
+ case C.SOpt{inner_}:
1332
+ Empty.absurd({C.dup_defect(C.SOpt{inner_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1333
+ case C.SList{elem_}:
1334
+ Empty.absurd({C.dup_defect(C.SList{elem_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1335
+ case C.SField{name_, s_, rest_}:
1336
+ Empty.absurd({C.dup_defect(C.SField{name_, s_, rest_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1337
+ case C.SEnd{}:
1338
+ Empty.absurd({C.dup_defect(C.SEnd{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1339
+ case C.SRule{s_, tag_}:
1340
+ Empty.absurd({C.dup_defect(C.SRule{s_, tag_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1341
+ case C.SStrict{s_}:
1342
+ Empty.absurd({C.dup_defect(C.SStrict{s_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1343
+ case C.STagged{key_, name_, s_, rest_}:
1344
+ Empty.absurd({C.dup_defect(C.STagged{key_, name_, s_, rest_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1345
+ case C.STagEnd{key_}:
1346
+ Empty.absurd({C.dup_defect(C.STagEnd{key_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1347
+ case C.SBool{}:
1348
+ Empty.absurd({C.dup_defect(C.SBool{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1349
+ case C.STrue{}:
1350
+ Empty.absurd({C.dup_defect(C.STrue{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1351
+ case C.SEnum{names_}:
1352
+ Empty.absurd({C.dup_defect(C.SEnum{names_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1353
+ case C.SVariant{+vn, +vv, +vr}:
1354
+ dup_step(C.is_missing(C.lookup(vn, r)), vn, vv, vr, r, {==}, p, w, h, pp => ww => hh => dup_acc(vr, r, pp, ww, hh), pp => ww => hh => dup_shape(vr, r, pp, ww, hh))
1355
+ case C.SVEnd{}:
1356
+ Empty.absurd({C.dup_defect(C.SVEnd{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1357
+ case C.STuple{s_, rest_}:
1358
+ Empty.absurd({C.dup_defect(C.STuple{s_, rest_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1359
+ case C.STEnd{}:
1360
+ Empty.absurd({C.dup_defect(C.STEnd{}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1361
+ case C.SOptional{inner_}:
1362
+ Empty.absurd({C.dup_defect(C.SOptional{inner_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1363
+ case C.SListLen{lo_, hi_, s_}:
1364
+ Empty.absurd({C.dup_defect(C.SListLen{lo_, hi_, s_}, r, p) == Some{w} : Maybe<&2, C.Why>}, none_some(C.Err{p, w}, h))
1365
+
1366
+ # A key present: an error in its value is under its field; else a second key
1367
+ # is one field along, found by dup_err.
1368
+ def var_dup_path(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, p3: List<&2, C.Step>, +w3: C.Why, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +eb: {False{} == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, +ex1: {True{} == C.conforms(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}) : Bool}, d: {C.dup_defect(vr, C.RKey{k, v, o}, p3) == Some{w3} : Maybe<&2, C.Why>}, sh: {head_is_field(p3) == True{} : Bool}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.later_f_path(p3)) == Some{w3} : Maybe<&2, C.Why>}:
1369
+ match p3:
1370
+ case C.AtField{+j, +n} <> +q:
1371
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.AtField{j, n} <> q), C.guard(C.conforms(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}), C.dup_defect(vr, C.RKey{k, v, o}, C.AtField{j, n} <> q))) == Some{w3} : Maybe<&2, C.Why>}
1372
+ %ex1 : {C.guard(_, C.dup_defect(vr, C.RKey{k, v, o}, C.AtField{j, n} <> q)) == Some{w3} : Maybe<&2, C.Why>}
1373
+ d
1374
+ case Nil{}:
1375
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, Nil{}) == Some{w3} : Maybe<&2, C.Why>}, to_empty(sh))
1376
+ case C.AtIndex{j} <> q:
1377
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.AtIndex{j} <> q) == Some{w3} : Maybe<&2, C.Why>}, to_empty(sh))
1378
+ case C.BoundAt{j, kk} <> q:
1379
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.BoundAt{j, kk} <> q) == Some{w3} : Maybe<&2, C.Why>}, to_empty(sh))
1380
+ case C.AtKey{kk} <> q:
1381
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.AtKey{kk} <> q) == Some{w3} : Maybe<&2, C.Why>}, to_empty(sh))
1382
+
1383
+ def var_dup(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m3: Maybe<&2, C.Err>, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +eb: {False{} == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, +h: {C.later_f(m3) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, +ex1: {True{} == C.conforms(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}) : Bool}, hd: @p:List<&2, C.Step> -> @w:C.Why -> {m3 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.dup_defect(vr, C.RKey{k, v, o}, p) == Some{w} : Maybe<&2, C.Why>}, hs: @p:List<&2, C.Step> -> @w:C.Why -> {m3 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {head_is_field(p) == True{} : Bool}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1384
+ match m3:
1385
+ case None{}:
1386
+ Empty.absurd({C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1387
+ case Some{C.Err{+p3, +w3}}:
1388
+ %same_path(C.later_f_path(p3), w3, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1389
+ %same_why(C.later_f_path(p3), w3, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.later_f_path(p3)) == Some{_} : Maybe<&2, C.Why>}
1390
+ var_dup_path(~rule, p3, w3, vn, vv, vr, k, v, o, prev, eb, ex1, hd(p3, w3, {==}), hs(p3, w3, {==}))
1391
+
1392
+ # The second occurrence of a variant key: check reports it before it looks at
1393
+ # the value under the key, so defect carries nothing but the report -- at the
1394
+ # key's own name, with no step after it. hk is the test at the value it was
1395
+ # false on, which is what the walk above has left of kc.
1396
+ def var_key_repeat(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +eb: {False{} == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, hk: {False{} == C.key_once_at(o, String.eq(k, vn), vn) : Bool}, +h: {Some{C.Err{C.AtField{0n, vn} <> Nil{}, C.RepeatedKey{vn}}} == Some{C.Err{path, why}} : Maybe<&2, C.Err>}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1397
+ %same_path(C.AtField{0n, vn} <> Nil{}, C.RepeatedKey{vn}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1398
+ %same_why(C.AtField{0n, vn} <> Nil{}, C.RepeatedKey{vn}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.AtField{0n, vn} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
1399
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.AtField{0n, vn} <> Nil{}), C.pick_why(Bool.not(C.key_once(vn, C.RKey{k, v, o})), C.at_end(C.RepeatedKey{vn}, Nil{}), C.guard(String.eq(vn, vn), C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, Nil{})))) == Some{C.RepeatedKey{vn}} : Maybe<&2, C.Why>}
1400
+ %hk : {C.pick_why(Bool.not(_), C.at_end(C.RepeatedKey{vn}, Nil{}), C.guard(String.eq(vn, vn), C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, Nil{}))) == Some{C.RepeatedKey{vn}} : Maybe<&2, C.Why>}
1401
+ {==}
1402
+
1403
+ def var_present(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +m3: Maybe<&2, C.Err>, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, k0: Bool, +kc: {k0 == C.key_once_at(o, String.eq(k, vn), vn) : Bool}, +eb: {False{} == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, +h: {C.first(C.key_err(k0, vn), C.first(C.under(C.AtField{0n, vn}, m1), C.later_f(m3))) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex1: {Maybe.is_none(&2, C.Err, m1) == C.conforms(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}) : Bool}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {m1 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, p) == Some{w} : Maybe<&2, C.Why>}, hd: @p:List<&2, C.Step> -> @w:C.Why -> {m3 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.dup_defect(vr, C.RKey{k, v, o}, p) == Some{w} : Maybe<&2, C.Why>}, hs: @p:List<&2, C.Step> -> @w:C.Why -> {m3 == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {head_is_field(p) == True{} : Bool}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1404
+ match m1:
1405
+ case Some{C.Err{+p1, +w1}}:
1406
+ match k0:
1407
+ case True{}:
1408
+ %same_path(C.AtField{0n, vn} <> p1, w1, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1409
+ %same_why(C.AtField{0n, vn} <> p1, w1, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, C.AtField{0n, vn} <> p1) == Some{_} : Maybe<&2, C.Why>}
1410
+ %eb : {C.pick_why(_, C.defect(~rule, vr, C.RKey{k, v, o}, None{}, C.AtField{0n, vn} <> p1), C.pick_why(Bool.not(C.key_once(vn, C.RKey{k, v, o})), C.at_end(C.RepeatedKey{vn}, p1), C.guard(String.eq(vn, vn), C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, p1)))) == Some{w1} : Maybe<&2, C.Why>}
1411
+ %kc : {C.pick_why(Bool.not(_), C.at_end(C.RepeatedKey{vn}, p1), C.guard(String.eq(vn, vn), C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, p1))) == Some{w1} : Maybe<&2, C.Why>}
1412
+ %MS.eq_refl_sym(vn) : {C.guard(_, C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, p1)) == Some{w1} : Maybe<&2, C.Why>}
1413
+ ih2(p1, w1, {==})
1414
+ case False{}:
1415
+ var_key_repeat(~rule, vn, vv, vr, k, v, o, prev, path, why, eb, kc, h)
1416
+ case None{}:
1417
+ match k0:
1418
+ case True{}:
1419
+ var_dup(~rule, m3, vn, vv, vr, k, v, o, prev, path, why, eb, h, ex1, hd, hs)
1420
+ case False{}:
1421
+ var_key_repeat(~rule, vn, vv, vr, k, v, o, prev, path, why, eb, kc, h)
1422
+
1423
+ def var_acc(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, +vn: String, +vv: C.Schema, +vr: C.Schema, +k: String, +v: C.Raw, +o: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, k0: Bool, +kc: {k0 == C.key_once_at(o, String.eq(k, vn), vn) : Bool}, eb: {b == C.is_missing(C.lookup(vn, C.RKey{k, v, o})) : Bool}, +h: {C.pick_err(b, C.later_f(C.check(~rule, vr, C.RKey{k, v, o}, None{})), C.first(C.key_err(k0, vn), C.first(C.under(C.AtField{0n, vn}, C.check(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{})), C.later_f(C.dup_err(vr, C.RKey{k, v, o}))))) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ex2: {Maybe.is_none(&2, C.Err, C.check(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{})) == C.conforms(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}) : Bool}, ih1: @p:List<&2, C.Step> -> @w:C.Why -> {C.check(~rule, vr, C.RKey{k, v, o}, None{}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, vr, C.RKey{k, v, o}, None{}, p) == Some{w} : Maybe<&2, C.Why>}, ih2: @p:List<&2, C.Step> -> @w:C.Why -> {C.check(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, p) == Some{w} : Maybe<&2, C.Why>}, hd: @p:List<&2, C.Step> -> @w:C.Why -> {C.dup_err(vr, C.RKey{k, v, o}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.dup_defect(vr, C.RKey{k, v, o}, p) == Some{w} : Maybe<&2, C.Why>}, hs: @p:List<&2, C.Step> -> @w:C.Why -> {C.dup_err(vr, C.RKey{k, v, o}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {head_is_field(p) == True{} : Bool}) -> {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1424
+ match b:
1425
+ case True{}:
1426
+ var_absent(~rule, C.check(~rule, vr, C.RKey{k, v, o}, None{}), vn, vv, vr, k, v, o, prev, path, why, eb, h, ih1)
1427
+ case False{}:
1428
+ var_present(~rule, C.check(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}), C.dup_err(vr, C.RKey{k, v, o}), vn, vv, vr, k, v, o, prev, path, why, k0, kc, eb, h, ex2, ih2, hd, hs)
1429
+
1430
+ # An SListLen whose check reported an error. The count is read before any
1431
+ # element, so the error is the count's own exactly when count_err reported one
1432
+ # (count_err_none turns the guard, which is written on the conforms side, into
1433
+ # that question; its reason is CountNotIn at the list's own path, or the reason
1434
+ # a list schema gives a value that is not a list). Otherwise the count found
1435
+ # nothing and the error is the inner schema's, replayed by the IH.
1436
+ def sll_acc_step(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, m1: Maybe<&2, C.Err>, +lo: Nat, +hi: Nat, +s2: C.Schema, +r: C.Raw, +path: List<&2, C.Step>, +why: C.Why, em: {m1 == C.count_err(lo, hi, r) : Maybe<&2, C.Err>}, +h: {C.first(m1, C.check(~rule, s2, r, None{})) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}, ih_acc: @p:List<&2, C.Step> -> @w:C.Why -> {C.check(~rule, s2, r, None{}) == Some{C.Err{p, w}} : Maybe<&2, C.Err>} -> {C.defect(~rule, s2, r, None{}, p) == Some{w} : Maybe<&2, C.Why>}) -> {C.pick_why(Bool.not(C.list_len_ok(lo, hi, r)), C.rule_defect(C.count_err(lo, hi, r), path), C.defect(~rule, s2, r, None{}, path)) == Some{why} : Maybe<&2, C.Why>}:
1437
+ match m1:
1438
+ case Some{C.Err{+p1, +w1}}:
1439
+ %count_err_none(lo, hi, r) : {C.pick_why(Bool.not(_), C.rule_defect(C.count_err(lo, hi, r), path), C.defect(~rule, s2, r, None{}, path)) == Some{why} : Maybe<&2, C.Why>}
1440
+ %em : {C.pick_why(Bool.not(Maybe.is_none(&2, C.Err, _)), C.rule_defect(_, path), C.defect(~rule, s2, r, None{}, path)) == Some{why} : Maybe<&2, C.Why>}
1441
+ %same_path(p1, w1, path, why, h) : {C.rule_defect(Some{C.Err{p1, w1}}, _) == Some{why} : Maybe<&2, C.Why>}
1442
+ %same_why(p1, w1, path, why, h) : {C.guard(C.path_eq(p1, p1), Some{w1}) == Some{_} : Maybe<&2, C.Why>}
1443
+ guard_true(C.path_eq(p1, p1), Some{w1}, path_refl(p1))
1444
+ case None{}:
1445
+ %count_err_none(lo, hi, r) : {C.pick_why(Bool.not(_), C.rule_defect(C.count_err(lo, hi, r), path), C.defect(~rule, s2, r, None{}, path)) == Some{why} : Maybe<&2, C.Why>}
1446
+ %em : {C.pick_why(Bool.not(Maybe.is_none(&2, C.Err, _)), C.rule_defect(_, path), C.defect(~rule, s2, r, None{}, path)) == Some{why} : Maybe<&2, C.Why>}
1447
+ ih_acc(path, why, h)
1448
+
1449
+
1450
+ # arms: s r
1451
+ # arms leaf: %same_path(Nil{}, $W, path, why, h) : {C.defect(~rule, $S, $R, prev, _) == Some{why} : Maybe<&2, C.Why>}
1452
+ # arms leaf: %same_why(Nil{}, $W, path, why, h) : {C.defect(~rule, $S, $R, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1453
+ # arms leaf: {==}
1454
+ # arms why: SBool=C.NotBool{} SNatIn=C.NotNat{} SStrLen=C.NotString{} RTooBig=C.TooLarge{} SNat=C.NotNat{} SStr=C.NotString{} SList=C.NotList{} SField=C.NotObject{} SEnd=C.NotObject{} STrue=C.NotTrue{} SEnum=C.NotOneOf{} SVariant=C.NotObject{} SVEnd=C.NotObject{} STuple=C.NotList{} STEnd=C.NotList{} STagEnd=C.NotObject{} RMissing=C.Missing{} SVEnd.REnd=C.NoVariant{} SVEnd.RKey=C.NoVariant{} STuple.RNil=C.TooShort{} STEnd.RCons=C.TooLong{}
1455
+ # arms accept: SNat.RNum SStr.RStr SOpt.RNull SList.RNil SEnd.REnd SEnd.RKey STEnd.RNil
1456
+ # arms accept leaf: Empty.absurd({C.defect(~rule, $S, $R, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1457
+ def acc(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, s: C.Schema, r: C.Raw, +prev: Maybe<&2, Nat>, +path: List<&2, C.Step>, +why: C.Why, +h: {C.check(~rule, s, r, prev) == Some{C.Err{path, why}} : Maybe<&2, C.Err>}) -> {C.defect(~rule, s, r, prev, path) == Some{why} : Maybe<&2, C.Why>}:
1458
+ match s r:
1459
+ case C.SNat{} C.RNum{n}:
1460
+ Empty.absurd({C.defect(~rule, C.SNat{}, C.RNum{n}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1461
+ case C.SNat{} C.RBool{bb}:
1462
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1463
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1464
+ {==}
1465
+ case C.SNat{} C.RNull{}:
1466
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1467
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1468
+ {==}
1469
+ case C.SNat{} C.RStr{x}:
1470
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1471
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1472
+ {==}
1473
+ case C.SNat{} C.RBad{}:
1474
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1475
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1476
+ {==}
1477
+ case C.SNat{} C.RTooBig{}:
1478
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1479
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1480
+ {==}
1481
+ case C.SNat{} C.RMissing{}:
1482
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1483
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1484
+ {==}
1485
+ case C.SNat{} C.RNil{}:
1486
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1487
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1488
+ {==}
1489
+ case C.SNat{} C.RCons{hd, tl}:
1490
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1491
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1492
+ {==}
1493
+ case C.SNat{} C.REnd{}:
1494
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1495
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1496
+ {==}
1497
+ case C.SNat{} C.RKey{k, v, o}:
1498
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1499
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNat{}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1500
+ {==}
1501
+ case C.SNatIn{+lo, +hi} C.RNum{+n}:
1502
+ acc_num_in(~rule, C.num_ok(lo, hi, n), lo, hi, n, prev, path, why, {==}, h)
1503
+ case C.SNatIn{+lo, +hi} C.RBool{bb}:
1504
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1505
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1506
+ {==}
1507
+ case C.SNatIn{+lo, +hi} C.RNull{}:
1508
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1509
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1510
+ {==}
1511
+ case C.SNatIn{+lo, +hi} C.RStr{x}:
1512
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1513
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1514
+ {==}
1515
+ case C.SNatIn{+lo, +hi} C.RBad{}:
1516
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1517
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1518
+ {==}
1519
+ case C.SNatIn{+lo, +hi} C.RTooBig{}:
1520
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1521
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1522
+ {==}
1523
+ case C.SNatIn{+lo, +hi} C.RMissing{}:
1524
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1525
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1526
+ {==}
1527
+ case C.SNatIn{+lo, +hi} C.RNil{}:
1528
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1529
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1530
+ {==}
1531
+ case C.SNatIn{+lo, +hi} C.RCons{hd, tl}:
1532
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1533
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1534
+ {==}
1535
+ case C.SNatIn{+lo, +hi} C.REnd{}:
1536
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1537
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1538
+ {==}
1539
+ case C.SNatIn{+lo, +hi} C.RKey{k, v, o}:
1540
+ %same_path(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1541
+ %same_why(Nil{}, C.NotNat{}, path, why, h) : {C.defect(~rule, C.SNatIn{lo, hi}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1542
+ {==}
1543
+ case C.SStr{} C.RNum{n}:
1544
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1545
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1546
+ {==}
1547
+ case C.SStr{} C.RBool{bb}:
1548
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1549
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1550
+ {==}
1551
+ case C.SStr{} C.RNull{}:
1552
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1553
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1554
+ {==}
1555
+ case C.SStr{} C.RStr{x}:
1556
+ Empty.absurd({C.defect(~rule, C.SStr{}, C.RStr{x}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1557
+ case C.SStr{} C.RBad{}:
1558
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1559
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1560
+ {==}
1561
+ case C.SStr{} C.RTooBig{}:
1562
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1563
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1564
+ {==}
1565
+ case C.SStr{} C.RMissing{}:
1566
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1567
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1568
+ {==}
1569
+ case C.SStr{} C.RNil{}:
1570
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1571
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1572
+ {==}
1573
+ case C.SStr{} C.RCons{hd, tl}:
1574
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1575
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1576
+ {==}
1577
+ case C.SStr{} C.REnd{}:
1578
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1579
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1580
+ {==}
1581
+ case C.SStr{} C.RKey{k, v, o}:
1582
+ %same_path(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1583
+ %same_why(Nil{}, C.NotString{}, path, why, h) : {C.defect(~rule, C.SStr{}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1584
+ {==}
1585
+ case C.SStrLen{+lo, +hi, +s2} +x:
1586
+ rule_acc_step(~rule, C.check(~rule, s2, x, prev), C.len_err(lo, hi, x), s2, x, prev, path, why, h, exact(~rule, s2, x, prev), p => w => hh => acc(~rule, s2, x, prev, p, w, hh), p => w => hh => rule_defect_refl(C.len_err(lo, hi, x), p, w, hh))
1587
+ case C.SOpt{+inner} C.RNum{n}:
1588
+ acc(~rule, inner, C.RNum{n}, None{}, path, why, h)
1589
+ case C.SOpt{+inner} C.RBool{bb}:
1590
+ acc(~rule, inner, C.RBool{bb}, None{}, path, why, h)
1591
+ case C.SOpt{+inner} C.RNull{}:
1592
+ Empty.absurd({C.defect(~rule, C.SOpt{inner}, C.RNull{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1593
+ case C.SOpt{+inner} C.RStr{x}:
1594
+ acc(~rule, inner, C.RStr{x}, None{}, path, why, h)
1595
+ case C.SOpt{+inner} C.RBad{}:
1596
+ acc(~rule, inner, C.RBad{}, None{}, path, why, h)
1597
+ case C.SOpt{+inner} C.RTooBig{}:
1598
+ acc(~rule, inner, C.RTooBig{}, None{}, path, why, h)
1599
+ case C.SOpt{+inner} C.RMissing{}:
1600
+ acc(~rule, inner, C.RMissing{}, None{}, path, why, h)
1601
+ case C.SOpt{+inner} C.RNil{}:
1602
+ acc(~rule, inner, C.RNil{}, None{}, path, why, h)
1603
+ case C.SOpt{+inner} C.RCons{hd, tl}:
1604
+ acc(~rule, inner, C.RCons{hd, tl}, None{}, path, why, h)
1605
+ case C.SOpt{+inner} C.REnd{}:
1606
+ acc(~rule, inner, C.REnd{}, None{}, path, why, h)
1607
+ case C.SOpt{+inner} C.RKey{k, v, o}:
1608
+ acc(~rule, inner, C.RKey{k, v, o}, None{}, path, why, h)
1609
+ case C.SList{+e} C.RNum{n}:
1610
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1611
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1612
+ {==}
1613
+ case C.SList{+e} C.RBool{bb}:
1614
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1615
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1616
+ {==}
1617
+ case C.SList{+e} C.RNull{}:
1618
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1619
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1620
+ {==}
1621
+ case C.SList{+e} C.RStr{x}:
1622
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1623
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1624
+ {==}
1625
+ case C.SList{+e} C.RBad{}:
1626
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1627
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1628
+ {==}
1629
+ case C.SList{+e} C.RTooBig{}:
1630
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1631
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1632
+ {==}
1633
+ case C.SList{+e} C.RMissing{}:
1634
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1635
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1636
+ {==}
1637
+ case C.SList{+e} C.RNil{}:
1638
+ Empty.absurd({C.defect(~rule, C.SList{e}, C.RNil{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1639
+ case C.SList{+e} C.RCons{+h1, +t}:
1640
+ list_step(~rule, C.check(~rule, e, h1, None{}), C.check(~rule, C.SList{e}, t, None{}), e, h1, t, prev, path, why, h, exact(~rule, e, h1, None{}), p => w => hh => acc(~rule, e, h1, None{}, p, w, hh), p => w => hh => acc(~rule, C.SList{e}, t, None{}, p, w, hh))
1641
+ case C.SList{+e} C.REnd{}:
1642
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1643
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1644
+ {==}
1645
+ case C.SList{+e} C.RKey{k, v, o}:
1646
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1647
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.SList{e}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1648
+ {==}
1649
+ case C.SField{+name, +fs, +rest} C.RNum{n}:
1650
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1651
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1652
+ {==}
1653
+ case C.SField{+name, +fs, +rest} C.RBool{bb}:
1654
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1655
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1656
+ {==}
1657
+ case C.SField{+name, +fs, +rest} C.RNull{}:
1658
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1659
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1660
+ {==}
1661
+ case C.SField{+name, +fs, +rest} C.RStr{x}:
1662
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1663
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1664
+ {==}
1665
+ case C.SField{+name, +fs, +rest} C.RBad{}:
1666
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1667
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1668
+ {==}
1669
+ case C.SField{+name, +fs, +rest} C.RTooBig{}:
1670
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1671
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1672
+ {==}
1673
+ case C.SField{+name, +fs, +rest} C.RMissing{}:
1674
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1675
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1676
+ {==}
1677
+ case C.SField{+name, +fs, +rest} C.RNil{}:
1678
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1679
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1680
+ {==}
1681
+ case C.SField{+name, +fs, +rest} C.RCons{hd, tl}:
1682
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1683
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SField{name, fs, rest}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1684
+ {==}
1685
+ case C.SField{+name, +fs, +rest} C.REnd{}:
1686
+ field_step_end(~rule, C.check(~rule, fs, C.RMissing{}, None{}), C.check(~rule, rest, C.REnd{}, None{}), name, fs, rest, prev, path, why, h, exact(~rule, fs, C.RMissing{}, None{}), p => w => hh => acc(~rule, fs, C.RMissing{}, None{}, p, w, hh), p => w => hh => acc(~rule, rest, C.REnd{}, None{}, p, w, hh))
1687
+ case C.SField{+name, +fs, +rest} C.RKey{+k, +v, +o}:
1688
+ field_step_key(~rule, C.check(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), C.check(~rule, rest, C.RKey{k, v, o}, None{}), name, fs, rest, k, v, o, prev, path, why, C.key_once(name, C.RKey{k, v, o}), {==}, h, exact(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}), p => w => hh => acc(~rule, fs, C.lookup(name, C.RKey{k, v, o}), None{}, p, w, hh), p => w => hh => acc(~rule, rest, C.RKey{k, v, o}, None{}, p, w, hh))
1689
+ case C.SEnd{} C.RNum{n}:
1690
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1691
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1692
+ {==}
1693
+ case C.SEnd{} C.RBool{bb}:
1694
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1695
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1696
+ {==}
1697
+ case C.SEnd{} C.RNull{}:
1698
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1699
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1700
+ {==}
1701
+ case C.SEnd{} C.RStr{x}:
1702
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1703
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1704
+ {==}
1705
+ case C.SEnd{} C.RBad{}:
1706
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1707
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1708
+ {==}
1709
+ case C.SEnd{} C.RTooBig{}:
1710
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1711
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1712
+ {==}
1713
+ case C.SEnd{} C.RMissing{}:
1714
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1715
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1716
+ {==}
1717
+ case C.SEnd{} C.RNil{}:
1718
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1719
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1720
+ {==}
1721
+ case C.SEnd{} C.RCons{hd, tl}:
1722
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1723
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SEnd{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1724
+ {==}
1725
+ case C.SEnd{} C.REnd{}:
1726
+ Empty.absurd({C.defect(~rule, C.SEnd{}, C.REnd{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1727
+ case C.SEnd{} C.RKey{k, v, o}:
1728
+ Empty.absurd({C.defect(~rule, C.SEnd{}, C.RKey{k, v, o}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1729
+ case C.SRule{+s2, +tag} +x:
1730
+ rule_acc_step(~rule, C.check(~rule, s2, x, prev), rule(tag, x), s2, x, prev, path, why, h, exact(~rule, s2, x, prev), p => w => hh => acc(~rule, s2, x, prev, p, w, hh), p => w => hh => rule_defect_refl(rule(tag, x), p, w, hh))
1731
+ case C.SStrict{+s2} +x:
1732
+ strict_acc_step(~rule, C.check(~rule, s2, x, prev), C.key_names(s2), s2, x, prev, path, why, h, exact(~rule, s2, x, prev), p => w => hh => acc(~rule, s2, x, prev, p, w, hh))
1733
+ case C.STagged{+k, +n, +cs, +rest} +x:
1734
+ tag_acc_k(C.key_once(k, x), C.is_tag(k, n, x), C.check(~rule, cs, C.drop_key(k, x), None{}), C.check(~rule, rest, x, None{}), C.defect(~rule, cs, C.drop_key(k, x), None{}, path), C.defect(~rule, rest, x, None{}, path), k, path, why, h, hh => acc(~rule, cs, C.drop_key(k, x), None{}, path, why, hh), hh => acc(~rule, rest, x, None{}, path, why, hh))
1735
+ case C.STagEnd{+k} C.RNum{n}:
1736
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1737
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1738
+ {==}
1739
+ case C.STagEnd{+k} C.RBool{bb}:
1740
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1741
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1742
+ {==}
1743
+ case C.STagEnd{+k} C.RNull{}:
1744
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1745
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1746
+ {==}
1747
+ case C.STagEnd{+k} C.RStr{x}:
1748
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1749
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1750
+ {==}
1751
+ case C.STagEnd{+k} C.RBad{}:
1752
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1753
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1754
+ {==}
1755
+ case C.STagEnd{+k} C.RTooBig{}:
1756
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1757
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1758
+ {==}
1759
+ case C.STagEnd{+k} C.RMissing{}:
1760
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1761
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1762
+ {==}
1763
+ case C.STagEnd{+k} C.RNil{}:
1764
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1765
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1766
+ {==}
1767
+ case C.STagEnd{+k} C.RCons{hd, tl}:
1768
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1769
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1770
+ {==}
1771
+ case C.STagEnd{+k} C.REnd{}:
1772
+ %same_path(C.AtKey{k} <> Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1773
+ %same_why(C.AtKey{k} <> Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.REnd{}, prev, C.AtKey{k} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
1774
+ %MS.eq_refl_sym(k) : {C.guard(_, Some{C.Missing{}}) == Some{C.Missing{}} : Maybe<&2, C.Why>}
1775
+ {==}
1776
+ case C.STagEnd{+k} C.RKey{+j, +v, +o}:
1777
+ %same_path(C.AtKey{k} <> Nil{}, C.missing_or(C.lookup(k, C.RKey{j, v, o}), C.NotOneOf{}), path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RKey{j, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1778
+ %same_why(C.AtKey{k} <> Nil{}, C.missing_or(C.lookup(k, C.RKey{j, v, o}), C.NotOneOf{}), path, why, h) : {C.defect(~rule, C.STagEnd{k}, C.RKey{j, v, o}, prev, C.AtKey{k} <> Nil{}) == Some{_} : Maybe<&2, C.Why>}
1779
+ %MS.eq_refl_sym(k) : {C.guard(_, Some{C.missing_or(C.lookup(k, C.RKey{j, v, o}), C.NotOneOf{})}) == Some{C.missing_or(C.lookup(k, C.RKey{j, v, o}), C.NotOneOf{})} : Maybe<&2, C.Why>}
1780
+ {==}
1781
+ case C.SBool{} C.RNum{n}:
1782
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1783
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1784
+ {==}
1785
+ case C.SBool{} C.RBool{bb}:
1786
+ Empty.absurd({C.defect(~rule, C.SBool{}, C.RBool{bb}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
1787
+ case C.SBool{} C.RNull{}:
1788
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1789
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1790
+ {==}
1791
+ case C.SBool{} C.RStr{x}:
1792
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1793
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1794
+ {==}
1795
+ case C.SBool{} C.RBad{}:
1796
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1797
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1798
+ {==}
1799
+ case C.SBool{} C.RTooBig{}:
1800
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1801
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1802
+ {==}
1803
+ case C.SBool{} C.RMissing{}:
1804
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1805
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1806
+ {==}
1807
+ case C.SBool{} C.RNil{}:
1808
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1809
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1810
+ {==}
1811
+ case C.SBool{} C.RCons{hd, tl}:
1812
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1813
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1814
+ {==}
1815
+ case C.SBool{} C.REnd{}:
1816
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1817
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1818
+ {==}
1819
+ case C.SBool{} C.RKey{k, v, o}:
1820
+ %same_path(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1821
+ %same_why(Nil{}, C.NotBool{}, path, why, h) : {C.defect(~rule, C.SBool{}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1822
+ {==}
1823
+ case C.STrue{} C.RNum{n}:
1824
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1825
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1826
+ {==}
1827
+ case C.STrue{} C.RBool{bb}:
1828
+ acc_true(~rule, bb, prev, path, why, h)
1829
+ case C.STrue{} C.RNull{}:
1830
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1831
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1832
+ {==}
1833
+ case C.STrue{} C.RStr{x}:
1834
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1835
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1836
+ {==}
1837
+ case C.STrue{} C.RBad{}:
1838
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1839
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1840
+ {==}
1841
+ case C.STrue{} C.RTooBig{}:
1842
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1843
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1844
+ {==}
1845
+ case C.STrue{} C.RMissing{}:
1846
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1847
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1848
+ {==}
1849
+ case C.STrue{} C.RNil{}:
1850
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1851
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1852
+ {==}
1853
+ case C.STrue{} C.RCons{hd, tl}:
1854
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1855
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1856
+ {==}
1857
+ case C.STrue{} C.REnd{}:
1858
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1859
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1860
+ {==}
1861
+ case C.STrue{} C.RKey{k, v, o}:
1862
+ %same_path(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1863
+ %same_why(Nil{}, C.NotTrue{}, path, why, h) : {C.defect(~rule, C.STrue{}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1864
+ {==}
1865
+ case C.SEnum{+ns} C.RNum{n}:
1866
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1867
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1868
+ {==}
1869
+ case C.SEnum{+ns} C.RBool{bb}:
1870
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1871
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1872
+ {==}
1873
+ case C.SEnum{+ns} C.RNull{}:
1874
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1875
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1876
+ {==}
1877
+ case C.SEnum{+ns} C.RStr{+x}:
1878
+ acc_enum(~rule, C.in_names(x, ns), x, ns, prev, path, why, {==}, h)
1879
+ case C.SEnum{+ns} C.RBad{}:
1880
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1881
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1882
+ {==}
1883
+ case C.SEnum{+ns} C.RTooBig{}:
1884
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1885
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1886
+ {==}
1887
+ case C.SEnum{+ns} C.RMissing{}:
1888
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1889
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1890
+ {==}
1891
+ case C.SEnum{+ns} C.RNil{}:
1892
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1893
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1894
+ {==}
1895
+ case C.SEnum{+ns} C.RCons{hd, tl}:
1896
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1897
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1898
+ {==}
1899
+ case C.SEnum{+ns} C.REnd{}:
1900
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1901
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1902
+ {==}
1903
+ case C.SEnum{+ns} C.RKey{k, v, o}:
1904
+ %same_path(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1905
+ %same_why(Nil{}, C.NotOneOf{}, path, why, h) : {C.defect(~rule, C.SEnum{ns}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1906
+ {==}
1907
+ case C.SVariant{+vn, +vv, +vr} C.RNum{n}:
1908
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1909
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1910
+ {==}
1911
+ case C.SVariant{+vn, +vv, +vr} C.RBool{bb}:
1912
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1913
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1914
+ {==}
1915
+ case C.SVariant{+vn, +vv, +vr} C.RNull{}:
1916
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1917
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1918
+ {==}
1919
+ case C.SVariant{+vn, +vv, +vr} C.RStr{x}:
1920
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1921
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1922
+ {==}
1923
+ case C.SVariant{+vn, +vv, +vr} C.RBad{}:
1924
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1925
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1926
+ {==}
1927
+ case C.SVariant{+vn, +vv, +vr} C.RTooBig{}:
1928
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1929
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1930
+ {==}
1931
+ case C.SVariant{+vn, +vv, +vr} C.RMissing{}:
1932
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1933
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1934
+ {==}
1935
+ case C.SVariant{+vn, +vv, +vr} C.RNil{}:
1936
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1937
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1938
+ {==}
1939
+ case C.SVariant{+vn, +vv, +vr} C.RCons{hd, tl}:
1940
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1941
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVariant{vn, vv, vr}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1942
+ {==}
1943
+ case C.SVariant{+vn, +vv, +vr} C.REnd{}:
1944
+ var_end_tail(~rule, C.check(~rule, vr, C.REnd{}, None{}), vn, vv, vr, prev, path, why, h, p => w => hh => acc(~rule, vr, C.REnd{}, None{}, p, w, hh))
1945
+ case C.SVariant{+vn, +vv, +vr} C.RKey{+k, +v, +o}:
1946
+ var_acc(~rule, C.is_missing(C.lookup(vn, C.RKey{k, v, o})), vn, vv, vr, k, v, o, prev, path, why, C.key_once(vn, C.RKey{k, v, o}), {==}, {==}, h, exact(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}), p => w => hh => acc(~rule, vr, C.RKey{k, v, o}, None{}, p, w, hh), p => w => hh => acc(~rule, vv, C.lookup(vn, C.RKey{k, v, o}), None{}, p, w, hh), p => w => hh => dup_acc(vr, C.RKey{k, v, o}, p, w, hh), p => w => hh => dup_shape(vr, C.RKey{k, v, o}, p, w, hh))
1947
+ case C.SVEnd{} C.RNum{n}:
1948
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1949
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1950
+ {==}
1951
+ case C.SVEnd{} C.RBool{bb}:
1952
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1953
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1954
+ {==}
1955
+ case C.SVEnd{} C.RNull{}:
1956
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1957
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1958
+ {==}
1959
+ case C.SVEnd{} C.RStr{x}:
1960
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1961
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1962
+ {==}
1963
+ case C.SVEnd{} C.RBad{}:
1964
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1965
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1966
+ {==}
1967
+ case C.SVEnd{} C.RTooBig{}:
1968
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1969
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1970
+ {==}
1971
+ case C.SVEnd{} C.RMissing{}:
1972
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1973
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1974
+ {==}
1975
+ case C.SVEnd{} C.RNil{}:
1976
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1977
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1978
+ {==}
1979
+ case C.SVEnd{} C.RCons{hd, tl}:
1980
+ %same_path(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1981
+ %same_why(Nil{}, C.NotObject{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1982
+ {==}
1983
+ case C.SVEnd{} C.REnd{}:
1984
+ %same_path(Nil{}, C.NoVariant{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1985
+ %same_why(Nil{}, C.NoVariant{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1986
+ {==}
1987
+ case C.SVEnd{} C.RKey{k, v, o}:
1988
+ %same_path(Nil{}, C.NoVariant{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1989
+ %same_why(Nil{}, C.NoVariant{}, path, why, h) : {C.defect(~rule, C.SVEnd{}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1990
+ {==}
1991
+ case C.STuple{+tt, +tr} C.RNum{n}:
1992
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1993
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1994
+ {==}
1995
+ case C.STuple{+tt, +tr} C.RBool{bb}:
1996
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
1997
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
1998
+ {==}
1999
+ case C.STuple{+tt, +tr} C.RNull{}:
2000
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2001
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2002
+ {==}
2003
+ case C.STuple{+tt, +tr} C.RStr{x}:
2004
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2005
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2006
+ {==}
2007
+ case C.STuple{+tt, +tr} C.RBad{}:
2008
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2009
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2010
+ {==}
2011
+ case C.STuple{+tt, +tr} C.RTooBig{}:
2012
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2013
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2014
+ {==}
2015
+ case C.STuple{+tt, +tr} C.RMissing{}:
2016
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2017
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2018
+ {==}
2019
+ case C.STuple{+tt, +tr} C.RNil{}:
2020
+ %same_path(Nil{}, C.TooShort{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RNil{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2021
+ %same_why(Nil{}, C.TooShort{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RNil{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2022
+ {==}
2023
+ case C.STuple{+tt, +tr} C.RCons{+h1, +t}:
2024
+ tup_step(~rule, C.check(~rule, tt, h1, None{}), C.check(~rule, tr, t, None{}), tt, tr, h1, t, prev, path, why, h, exact(~rule, tt, h1, None{}), p => w => hh => acc(~rule, tt, h1, None{}, p, w, hh), p => w => hh => acc(~rule, tr, t, None{}, p, w, hh))
2025
+ case C.STuple{+tt, +tr} C.REnd{}:
2026
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2027
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2028
+ {==}
2029
+ case C.STuple{+tt, +tr} C.RKey{k, v, o}:
2030
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2031
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STuple{tt, tr}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2032
+ {==}
2033
+ case C.STEnd{} C.RNum{n}:
2034
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RNum{n}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2035
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RNum{n}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2036
+ {==}
2037
+ case C.STEnd{} C.RBool{bb}:
2038
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RBool{bb}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2039
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RBool{bb}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2040
+ {==}
2041
+ case C.STEnd{} C.RNull{}:
2042
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RNull{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2043
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RNull{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2044
+ {==}
2045
+ case C.STEnd{} C.RStr{x}:
2046
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RStr{x}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2047
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RStr{x}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2048
+ {==}
2049
+ case C.STEnd{} C.RBad{}:
2050
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RBad{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2051
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RBad{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2052
+ {==}
2053
+ case C.STEnd{} C.RTooBig{}:
2054
+ %same_path(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RTooBig{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2055
+ %same_why(Nil{}, C.TooLarge{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RTooBig{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2056
+ {==}
2057
+ case C.STEnd{} C.RMissing{}:
2058
+ %same_path(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RMissing{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2059
+ %same_why(Nil{}, C.Missing{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RMissing{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2060
+ {==}
2061
+ case C.STEnd{} C.RNil{}:
2062
+ Empty.absurd({C.defect(~rule, C.STEnd{}, C.RNil{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
2063
+ case C.STEnd{} C.RCons{hd, tl}:
2064
+ %same_path(Nil{}, C.TooLong{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RCons{hd, tl}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2065
+ %same_why(Nil{}, C.TooLong{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RCons{hd, tl}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2066
+ {==}
2067
+ case C.STEnd{} C.REnd{}:
2068
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.REnd{}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2069
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.REnd{}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2070
+ {==}
2071
+ case C.STEnd{} C.RKey{k, v, o}:
2072
+ %same_path(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RKey{k, v, o}, prev, _) == Some{why} : Maybe<&2, C.Why>}
2073
+ %same_why(Nil{}, C.NotList{}, path, why, h) : {C.defect(~rule, C.STEnd{}, C.RKey{k, v, o}, prev, Nil{}) == Some{_} : Maybe<&2, C.Why>}
2074
+ {==}
2075
+ case C.SOptional{+inner} C.RNum{n}:
2076
+ acc(~rule, inner, C.RNum{n}, None{}, path, why, h)
2077
+ case C.SOptional{+inner} C.RBool{bb}:
2078
+ acc(~rule, inner, C.RBool{bb}, None{}, path, why, h)
2079
+ case C.SOptional{+inner} C.RNull{}:
2080
+ acc(~rule, inner, C.RNull{}, None{}, path, why, h)
2081
+ case C.SOptional{+inner} C.RStr{x}:
2082
+ acc(~rule, inner, C.RStr{x}, None{}, path, why, h)
2083
+ case C.SOptional{+inner} C.RBad{}:
2084
+ acc(~rule, inner, C.RBad{}, None{}, path, why, h)
2085
+ case C.SOptional{+inner} C.RTooBig{}:
2086
+ acc(~rule, inner, C.RTooBig{}, None{}, path, why, h)
2087
+ case C.SOptional{+inner} C.RMissing{}:
2088
+ Empty.absurd({C.defect(~rule, C.SOptional{inner}, C.RMissing{}, prev, path) == Some{why} : Maybe<&2, C.Why>}, none_some(C.Err{path, why}, h))
2089
+ case C.SOptional{+inner} C.RNil{}:
2090
+ acc(~rule, inner, C.RNil{}, None{}, path, why, h)
2091
+ case C.SOptional{+inner} C.RCons{hd, tl}:
2092
+ acc(~rule, inner, C.RCons{hd, tl}, None{}, path, why, h)
2093
+ case C.SOptional{+inner} C.REnd{}:
2094
+ acc(~rule, inner, C.REnd{}, None{}, path, why, h)
2095
+ case C.SOptional{+inner} C.RKey{k, v, o}:
2096
+ acc(~rule, inner, C.RKey{k, v, o}, None{}, path, why, h)
2097
+ case C.SListLen{+lo, +hi, +s2} +r:
2098
+ sll_acc_step(~rule, C.count_err(lo, hi, r), lo, hi, s2, r, path, why, {==}, h, p => w => hh => acc(~rule, s2, r, None{}, p, w, hh))
2099
+
2100
+ def Laws.check_accurate(rule, s, r, prev, path, why, h):
2101
+ acc(~rule, s, r, prev, path, why, h)
2102
+
2103
+ # ---- a too big value is reported where it stands ----
2104
+ #
2105
+ # The same walk as check, one arm per schema kind: a value the codec refused to
2106
+ # build is not the shape any kind wants, so every kind reaches the arm that
2107
+ # answers with missing_or, and that arm is where TooLarge comes from. The kinds
2108
+ # that look further into the value (an optional, a rule, a strict object, a
2109
+ # tag) reach their own arm first, and each of those either recurses or takes
2110
+ # the reason straight from the sub-walk.
2111
+
2112
+ # arms: s
2113
+ # arms leaf: {==}
2114
+ def too_large_go(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, s: C.Schema, +prev: Maybe<&2, Nat>) -> {C.check(~rule, s, C.RTooBig{}, prev) == Some{C.Err{Nil{}, C.TooLarge{}}} : Maybe<&2, C.Err>}:
2115
+ match s:
2116
+ case C.SNat{}:
2117
+ {==}
2118
+ case C.SNatIn{lo_, hi_}:
2119
+ {==}
2120
+ case C.SStr{}:
2121
+ {==}
2122
+ case C.SStrLen{lo, hi, s2}:
2123
+ %Equal.sym(Maybe<&2, C.Err>, C.check(~rule, s2, C.RTooBig{}, prev), Some{C.Err{Nil{}, C.TooLarge{}}}, too_large_go(~rule, s2, prev)) : {C.first(_, C.len_err(lo, hi, C.RTooBig{})) == Some{C.Err{Nil{}, C.TooLarge{}}} : Maybe<&2, C.Err>}
2124
+ {==}
2125
+ case C.SOpt{inner}:
2126
+ too_large_go(~rule, inner, None{})
2127
+ case C.SList{elem_}:
2128
+ {==}
2129
+ case C.SField{name_, s_, rest_}:
2130
+ {==}
2131
+ case C.SEnd{}:
2132
+ {==}
2133
+ case C.SRule{s2, tag}:
2134
+ %Equal.sym(Maybe<&2, C.Err>, C.check(~rule, s2, C.RTooBig{}, prev), Some{C.Err{Nil{}, C.TooLarge{}}}, too_large_go(~rule, s2, prev)) : {C.first(_, rule(tag, C.RTooBig{})) == Some{C.Err{Nil{}, C.TooLarge{}}} : Maybe<&2, C.Err>}
2135
+ {==}
2136
+ case C.SStrict{s2}:
2137
+ %Equal.sym(Maybe<&2, C.Err>, C.check(~rule, s2, C.RTooBig{}, prev), Some{C.Err{Nil{}, C.TooLarge{}}}, too_large_go(~rule, s2, prev)) : {C.first(_, C.extra_err(C.key_names(s2), C.RTooBig{})) == Some{C.Err{Nil{}, C.TooLarge{}}} : Maybe<&2, C.Err>}
2138
+ {==}
2139
+ case C.STagged{k, n, cs, rest}:
2140
+ too_large_go(~rule, rest, None{})
2141
+ case C.STagEnd{key_}:
2142
+ {==}
2143
+ case C.SBool{}:
2144
+ {==}
2145
+ case C.STrue{}:
2146
+ {==}
2147
+ case C.SEnum{names_}:
2148
+ {==}
2149
+ case C.SVariant{name_, s_, rest_}:
2150
+ {==}
2151
+ case C.SVEnd{}:
2152
+ {==}
2153
+ case C.STuple{s_, rest_}:
2154
+ {==}
2155
+ case C.STEnd{}:
2156
+ {==}
2157
+ case C.SOptional{inner}:
2158
+ too_large_go(~rule, inner, None{})
2159
+ case C.SListLen{lo_, hi_, s2_}:
2160
+ {==}
2161
+
2162
+ def Laws.too_large_reported(rule, s, prev):
2163
+ too_large_go(~rule, s, prev)
2164
+
2165
+ # ---- every listed name is accepted ----
2166
+ #
2167
+ # in_names looks for n through pre, then finds it: String.eq(n, n) is True
2168
+ # (MS.eq_refl_sym), and an or with True is True whatever came first.
2169
+
2170
+ def or_true_r(x: Bool) -> {True{} == Bool.or(x, True{}) : Bool}:
2171
+ match x:
2172
+ case True{}:
2173
+ {==}
2174
+ case False{}:
2175
+ {==}
2176
+
2177
+ def names_has(pre: List<&2, String>, +n: String, +post: List<&2, String>) -> {C.in_names(n, List.append(&2, String, pre, n <> post)) == True{} : Bool}:
2178
+ match pre:
2179
+ case Nil{}:
2180
+ %MS.eq_refl_sym(n) : {Bool.or(_, C.in_names(n, post)) == True{} : Bool}
2181
+ {==}
2182
+ case +m <> +t:
2183
+ %Equal.sym(Bool, C.in_names(n, List.append(&2, String, t, n <> post)), True{}, names_has(t, n, post)) : {Bool.or(String.eq(n, m), _) == True{} : Bool}
2184
+ Equal.sym(Bool, True{}, Bool.or(String.eq(n, m), True{}), or_true_r(String.eq(n, m)))
2185
+
2186
+ def Laws.enum_accepts(rule, pre, n, post):
2187
+ names_has(pre, n, post)
2188
+
2189
+ # ---- an accepted string is one of the names ----
2190
+ #
2191
+ # By induction on the names: the first one matches (the witness has an empty
2192
+ # pre), or the rest holds it, and the witness moves one name along.
2193
+
2194
+ def one_of_cons(+m: String, +t: List<&2, String>, +x: String, w: Laws.OneOf(t, x)) -> Laws.OneOf(m <> t, x):
2195
+ match w:
2196
+ case (+pre, +n, +post, eq, hx):
2197
+ (m <> pre, n, post, Equal.cong(List<&2, String>, List<&2, String>, l => m <> l, t, List.append(&2, String, pre, n <> post), eq), hx)
2198
+
2199
+ def one_of_step(b: Bool, +m: String, +t: List<&2, String>, +x: String, eb: {b == String.eq(x, m) : Bool}, h: {Bool.or(b, C.in_names(x, t)) == True{} : Bool}, ih: {C.in_names(x, t) == True{} : Bool} -> Laws.OneOf(t, x)) -> Laws.OneOf(m <> t, x):
2200
+ match b:
2201
+ case True{}:
2202
+ (Nil{}, m, t, {==}, Equal.sym(Bool, True{}, String.eq(x, m), eb))
2203
+ case False{}:
2204
+ one_of_cons(m, t, x, ih(h))
2205
+
2206
+ def one_of(ns: List<&2, String>, +x: String, h: {C.in_names(x, ns) == True{} : Bool}) -> Laws.OneOf(ns, x):
2207
+ match ns:
2208
+ case Nil{}:
2209
+ Empty.absurd(Laws.OneOf(Nil{}, x), to_empty(h))
2210
+ case +m <> +t:
2211
+ one_of_step(String.eq(x, m), m, t, x, {==}, h, hh => one_of(t, x, hh))
2212
+
2213
+ def Laws.enum_admits(rule, ns, x, h):
2214
+ one_of(ns, x, h)
2215
+
2216
+ # ---- a variant chain, read by counting ----
2217
+ #
2218
+ # One key along at a time: an absent key adds 0 to the count and says
2219
+ # nothing of the value; a present one adds 1, so no later key may be there
2220
+ # (count_zero), and then every later key is absent (np_pc).
2221
+
2222
+ def and_false_l(x: Bool) -> {Bool.and(x, False{}) == False{} : Bool}:
2223
+ match x:
2224
+ case True{}:
2225
+ {==}
2226
+ case False{}:
2227
+ {==}
2228
+
2229
+ def count_step(b: Bool, +rr: C.Schema, +r: C.Raw, ih: {Nat.is_eq(C.count_present(rr, r), 0n) == C.none_present(rr, r) : Bool}) -> {Nat.is_eq(Nat.add(C.one_if_there(b), C.count_present(rr, r)), 0n) == Bool.and(b, C.none_present(rr, r)) : Bool}:
2230
+ match b:
2231
+ case True{}:
2232
+ ih
2233
+ case False{}:
2234
+ {==}
2235
+
2236
+ # arms: s
2237
+ # arms leaf: {==}
2238
+ def count_zero(s: C.Schema, +r: C.Raw) -> {Nat.is_eq(C.count_present(s, r), 0n) == C.none_present(s, r) : Bool}:
2239
+ match s:
2240
+ case C.SNat{}:
2241
+ {==}
2242
+ case C.SNatIn{lo_, hi_}:
2243
+ {==}
2244
+ case C.SStr{}:
2245
+ {==}
2246
+ case C.SStrLen{lo_, hi_, s_}:
2247
+ {==}
2248
+ case C.SOpt{inner_}:
2249
+ {==}
2250
+ case C.SList{elem_}:
2251
+ {==}
2252
+ case C.SField{name_, s_, rest_}:
2253
+ {==}
2254
+ case C.SEnd{}:
2255
+ {==}
2256
+ case C.SRule{s_, tag_}:
2257
+ {==}
2258
+ case C.SStrict{s_}:
2259
+ {==}
2260
+ case C.STagged{key_, name_, s_, rest_}:
2261
+ {==}
2262
+ case C.STagEnd{key_}:
2263
+ {==}
2264
+ case C.SBool{}:
2265
+ {==}
2266
+ case C.STrue{}:
2267
+ {==}
2268
+ case C.SEnum{names_}:
2269
+ {==}
2270
+ case C.SVariant{+vn, vv, +vr}:
2271
+ count_step(C.is_missing(C.lookup(vn, r)), vr, r, count_zero(vr, r))
2272
+ case C.SVEnd{}:
2273
+ {==}
2274
+ case C.STuple{s_, rest_}:
2275
+ {==}
2276
+ case C.STEnd{}:
2277
+ {==}
2278
+ case C.SOptional{inner_}:
2279
+ {==}
2280
+ case C.SListLen{lo_, hi_, s_}:
2281
+ {==}
2282
+
2283
+ def np_pc_step(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, +cv: Bool, +vn: String, +vv: C.Schema, +rr: C.Schema, +r: C.Raw, ih: {Bool.and(cv, C.none_present(rr, r)) == Bool.and(C.none_present(rr, r), Bool.and(cv, C.present_conform(~rule, rr, r))) : Bool}) -> {Bool.and(cv, Bool.and(b, C.none_present(rr, r))) == Bool.and(Bool.and(b, C.none_present(rr, r)), Bool.and(cv, C.pick_bool(b, C.present_conform(~rule, rr, r), Bool.and(C.key_once(vn, r), Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.present_conform(~rule, rr, r)))))) : Bool}:
2284
+ match b:
2285
+ case True{}:
2286
+ ih
2287
+ case False{}:
2288
+ and_false_l(cv)
2289
+
2290
+ # cv and "no key" is "no key", cv and every present value conforming.
2291
+ # arms: s
2292
+ # arms leaf: {==}
2293
+ def np_pc(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, s: C.Schema, +r: C.Raw, +cv: Bool) -> {Bool.and(cv, C.none_present(s, r)) == Bool.and(C.none_present(s, r), Bool.and(cv, C.present_conform(~rule, s, r))) : Bool}:
2294
+ match s:
2295
+ case C.SNat{}:
2296
+ {==}
2297
+ case C.SNatIn{lo_, hi_}:
2298
+ {==}
2299
+ case C.SStr{}:
2300
+ {==}
2301
+ case C.SStrLen{lo_, hi_, s_}:
2302
+ {==}
2303
+ case C.SOpt{inner_}:
2304
+ {==}
2305
+ case C.SList{elem_}:
2306
+ {==}
2307
+ case C.SField{name_, s_, rest_}:
2308
+ {==}
2309
+ case C.SEnd{}:
2310
+ {==}
2311
+ case C.SRule{s_, tag_}:
2312
+ {==}
2313
+ case C.SStrict{s_}:
2314
+ {==}
2315
+ case C.STagged{key_, name_, s_, rest_}:
2316
+ {==}
2317
+ case C.STagEnd{key_}:
2318
+ {==}
2319
+ case C.SBool{}:
2320
+ {==}
2321
+ case C.STrue{}:
2322
+ {==}
2323
+ case C.SEnum{names_}:
2324
+ {==}
2325
+ case C.SVariant{+vn, +vv, +vr}:
2326
+ np_pc_step(~rule, C.is_missing(C.lookup(vn, r)), cv, vn, vv, vr, r, np_pc(~rule, vr, r, cv))
2327
+ case C.SVEnd{}:
2328
+ {==}
2329
+ case C.STuple{s_, rest_}:
2330
+ {==}
2331
+ case C.STEnd{}:
2332
+ {==}
2333
+ case C.SOptional{inner_}:
2334
+ {==}
2335
+ case C.SListLen{lo_, hi_, s_}:
2336
+ {==}
2337
+
2338
+ # The key's own case, in two splits. b is whether the chain's key is in the
2339
+ # value: an absent key adds nothing to the count and says nothing of the
2340
+ # value, which is the IH untouched. A key that is there adds 1, so the rest
2341
+ # must hold none (count_zero turned round) and the value under the key must
2342
+ # conform (np_pc) -- and it must be read once (k0), which is what conforms
2343
+ # asks at the same place; a key taken twice leaves false on both sides.
2344
+ def var_key(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, k0: Bool, +vn: String, +vv: C.Schema, +vr: C.Schema, +r: C.Raw, +kc: {k0 == C.key_once(vn, r) : Bool}, ih: {C.conforms(~rule, vr, r, None{}) == Bool.and(True{}, Bool.and(Nat.is_eq(C.count_present(vr, r), 1n), C.present_conform(~rule, vr, r))) : Bool}) -> {C.pick_bool(b, C.conforms(~rule, vr, r, None{}), Bool.and(k0, Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r)))) == Bool.and(Nat.is_eq(Nat.add(C.one_if_there(b), C.count_present(vr, r)), 1n), C.pick_bool(b, C.present_conform(~rule, vr, r), Bool.and(k0, Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.present_conform(~rule, vr, r))))) : Bool}:
2345
+ match b:
2346
+ case True{}:
2347
+ ih
2348
+ case False{}:
2349
+ match k0:
2350
+ case True{}:
2351
+ %Equal.sym(Bool, Nat.is_eq(C.count_present(vr, r), 0n), C.none_present(vr, r), count_zero(vr, r)) : {Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.none_present(vr, r)) == Bool.and(_, Bool.and(C.conforms(~rule, vv, C.lookup(vn, r), None{}), C.present_conform(~rule, vr, r))) : Bool}
2352
+ np_pc(~rule, vr, r, C.conforms(~rule, vv, C.lookup(vn, r), None{}))
2353
+ case False{}:
2354
+ Equal.sym(Bool, Bool.and(Nat.is_eq(Nat.add(C.one_if_there(b), C.count_present(vr, r)), 1n), False{}), False{}, and_false_l(Nat.is_eq(Nat.add(C.one_if_there(b), C.count_present(vr, r)), 1n)))
2355
+
2356
+ def vm_raw(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, r: C.Raw, +vn: String, +vv: C.Schema, +vr: C.Schema, hc: {C.is_chain(vr) == True{} : Bool}, ih: @rr:C.Raw -> {C.conforms(~rule, vr, rr, None{}) == Bool.and(C.is_object(rr), Bool.and(Nat.is_eq(C.count_present(vr, rr), 1n), C.present_conform(~rule, vr, rr))) : Bool}) -> {C.conforms(~rule, C.SVariant{vn, vv, vr}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SVariant{vn, vv, vr}, r), 1n), C.present_conform(~rule, C.SVariant{vn, vv, vr}, r))) : Bool}:
2357
+ match r:
2358
+ case C.RNum{n}:
2359
+ {==}
2360
+ case C.RBool{bb}:
2361
+ {==}
2362
+ case C.RNull{}:
2363
+ {==}
2364
+ case C.RStr{x}:
2365
+ {==}
2366
+ case C.RBad{}:
2367
+ {==}
2368
+ case C.RTooBig{}:
2369
+ {==}
2370
+ case C.RMissing{}:
2371
+ {==}
2372
+ case C.RNil{}:
2373
+ {==}
2374
+ case C.RCons{hd, tl}:
2375
+ {==}
2376
+ case C.REnd{}:
2377
+ ih(C.REnd{})
2378
+ case C.RKey{+k, +v, +o}:
2379
+ var_key(~rule, C.is_missing(C.lookup(vn, C.RKey{k, v, o})), C.key_once(vn, C.RKey{k, v, o}), vn, vv, vr, C.RKey{k, v, o}, {==}, ih(C.RKey{k, v, o}))
2380
+
2381
+ # arms: s
2382
+ # arms leaf: Empty.absurd({C.conforms(~rule, $S, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present($S, r), 1n), C.present_conform(~rule, $S, r))) : Bool}, to_empty(hc))
2383
+ def vm(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, s: C.Schema, r: C.Raw, +hc: {C.is_chain(s) == True{} : Bool}) -> {C.conforms(~rule, s, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(s, r), 1n), C.present_conform(~rule, s, r))) : Bool}:
2384
+ match s:
2385
+ case C.SNat{}:
2386
+ Empty.absurd({C.conforms(~rule, C.SNat{}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SNat{}, r), 1n), C.present_conform(~rule, C.SNat{}, r))) : Bool}, to_empty(hc))
2387
+ case C.SNatIn{lo_, hi_}:
2388
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SNatIn{lo_, hi_}, r), 1n), C.present_conform(~rule, C.SNatIn{lo_, hi_}, r))) : Bool}, to_empty(hc))
2389
+ case C.SStr{}:
2390
+ Empty.absurd({C.conforms(~rule, C.SStr{}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SStr{}, r), 1n), C.present_conform(~rule, C.SStr{}, r))) : Bool}, to_empty(hc))
2391
+ case C.SStrLen{lo_, hi_, s_}:
2392
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SStrLen{lo_, hi_, s_}, r), 1n), C.present_conform(~rule, C.SStrLen{lo_, hi_, s_}, r))) : Bool}, to_empty(hc))
2393
+ case C.SOpt{inner_}:
2394
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SOpt{inner_}, r), 1n), C.present_conform(~rule, C.SOpt{inner_}, r))) : Bool}, to_empty(hc))
2395
+ case C.SList{elem_}:
2396
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SList{elem_}, r), 1n), C.present_conform(~rule, C.SList{elem_}, r))) : Bool}, to_empty(hc))
2397
+ case C.SField{name_, s_, rest_}:
2398
+ Empty.absurd({C.conforms(~rule, C.SField{name_, s_, rest_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SField{name_, s_, rest_}, r), 1n), C.present_conform(~rule, C.SField{name_, s_, rest_}, r))) : Bool}, to_empty(hc))
2399
+ case C.SEnd{}:
2400
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SEnd{}, r), 1n), C.present_conform(~rule, C.SEnd{}, r))) : Bool}, to_empty(hc))
2401
+ case C.SRule{s_, tag_}:
2402
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SRule{s_, tag_}, r), 1n), C.present_conform(~rule, C.SRule{s_, tag_}, r))) : Bool}, to_empty(hc))
2403
+ case C.SStrict{s_}:
2404
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SStrict{s_}, r), 1n), C.present_conform(~rule, C.SStrict{s_}, r))) : Bool}, to_empty(hc))
2405
+ case C.STagged{key_, name_, s_, rest_}:
2406
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.STagged{key_, name_, s_, rest_}, r), 1n), C.present_conform(~rule, C.STagged{key_, name_, s_, rest_}, r))) : Bool}, to_empty(hc))
2407
+ case C.STagEnd{key_}:
2408
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.STagEnd{key_}, r), 1n), C.present_conform(~rule, C.STagEnd{key_}, r))) : Bool}, to_empty(hc))
2409
+ case C.SBool{}:
2410
+ Empty.absurd({C.conforms(~rule, C.SBool{}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SBool{}, r), 1n), C.present_conform(~rule, C.SBool{}, r))) : Bool}, to_empty(hc))
2411
+ case C.STrue{}:
2412
+ Empty.absurd({C.conforms(~rule, C.STrue{}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.STrue{}, r), 1n), C.present_conform(~rule, C.STrue{}, r))) : Bool}, to_empty(hc))
2413
+ case C.SEnum{names_}:
2414
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SEnum{names_}, r), 1n), C.present_conform(~rule, C.SEnum{names_}, r))) : Bool}, to_empty(hc))
2415
+ case C.SVariant{+vn, +vv, +vr}:
2416
+ vm_raw(~rule, r, vn, vv, vr, hc, rr => vm(~rule, vr, rr, hc))
2417
+ case C.SVEnd{}:
2418
+ Equal.sym(Bool, Bool.and(C.is_object(r), False{}), False{}, and_false_l(C.is_object(r)))
2419
+ case C.STuple{s_, rest_}:
2420
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.STuple{s_, rest_}, r), 1n), C.present_conform(~rule, C.STuple{s_, rest_}, r))) : Bool}, to_empty(hc))
2421
+ case C.STEnd{}:
2422
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.STEnd{}, r), 1n), C.present_conform(~rule, C.STEnd{}, r))) : Bool}, to_empty(hc))
2423
+ case C.SOptional{inner_}:
2424
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SOptional{inner_}, r), 1n), C.present_conform(~rule, C.SOptional{inner_}, r))) : Bool}, to_empty(hc))
2425
+ case C.SListLen{lo_, hi_, s_}:
2426
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, r, None{}) == Bool.and(C.is_object(r), Bool.and(Nat.is_eq(C.count_present(C.SListLen{lo_, hi_, s_}, r), 1n), C.present_conform(~rule, C.SListLen{lo_, hi_, s_}, r))) : Bool}, to_empty(hc))
2427
+
2428
+ def Laws.variant_meaning(rule, s, r, hc):
2429
+ vm(~rule, s, r, hc)
2430
+
2431
+ # ---- a tuple means its positions ----
2432
+ #
2433
+ # By induction on the list of schemas, generalized over the raw value. The
2434
+ # step reads position i of RCons{h, t} as position i-1 of t (each_shift), so
2435
+ # the tail's claim is the tail's own, from position 0.
2436
+
2437
+ def each_shift(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, ss: List<&2, C.Schema>, +h: C.Raw, +t: C.Raw, +i: Nat) -> {C.each_pos(~rule, ss, C.RCons{h, t}, 1n+i) == C.each_pos(~rule, ss, t, i) : Bool}:
2438
+ match ss:
2439
+ case Nil{}:
2440
+ {==}
2441
+ case x <> xs:
2442
+ Equal.cong(Bool, Bool, v => Bool.and(C.conforms(~rule, x, C.at_raw(t, i), None{}), v), C.each_pos(~rule, xs, C.RCons{h, t}, 2n+i), C.each_pos(~rule, xs, t, 1n+i), each_shift(~rule, xs, h, t, 1n+i))
2443
+
2444
+ def zero3(l: Bool, e: Bool) -> {Bool.and(l, Bool.and(e, False{})) == False{} : Bool}:
2445
+ match l e:
2446
+ case True{} True{}:
2447
+ {==}
2448
+ case True{} False{}:
2449
+ {==}
2450
+ case False{} _:
2451
+ {==}
2452
+
2453
+ def and3_swap(a: Bool, +l: Bool, +e: Bool, +c: Bool) -> {Bool.and(a, Bool.and(l, Bool.and(e, c))) == Bool.and(l, Bool.and(e, Bool.and(a, c))) : Bool}:
2454
+ match a:
2455
+ case True{}:
2456
+ Equal.sym(Bool, Bool.and(l, Bool.and(e, c)), Bool.and(l, Bool.and(e, Bool.and(True{}, c))), {==})
2457
+ case False{}:
2458
+ Equal.sym(Bool, Bool.and(l, Bool.and(e, False{})), False{}, zero3(l, e))
2459
+
2460
+ def tm(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, ss: List<&2, C.Schema>, r: C.Raw) -> {C.conforms(~rule, C.tuple_of(ss), r, None{}) == Bool.and(C.raw_list(r), Bool.and(Nat.is_eq(C.raw_len(r), List.length(&2, C.Schema, ss)), C.each_pos(~rule, ss, r, 0n))) : Bool}:
2461
+ match ss r:
2462
+ case Nil{} C.RNil{}:
2463
+ {==}
2464
+ case Nil{} C.RCons{h, t}:
2465
+ Equal.sym(Bool, Bool.and(C.raw_list(t), False{}), False{}, and_false_l(C.raw_list(t)))
2466
+ case Nil{} C.RNum{n}:
2467
+ {==}
2468
+ case Nil{} C.RBool{b}:
2469
+ {==}
2470
+ case Nil{} C.RNull{}:
2471
+ {==}
2472
+ case Nil{} C.RStr{x}:
2473
+ {==}
2474
+ case Nil{} C.RBad{}:
2475
+ {==}
2476
+ case Nil{} C.RTooBig{}:
2477
+ {==}
2478
+ case Nil{} C.RMissing{}:
2479
+ {==}
2480
+ case Nil{} C.REnd{}:
2481
+ {==}
2482
+ case Nil{} C.RKey{k, v, o}:
2483
+ {==}
2484
+ case +x <> +xs C.RCons{+h, +t}:
2485
+ %Equal.sym(Bool, C.conforms(~rule, C.tuple_of(xs), t, None{}), Bool.and(C.raw_list(t), Bool.and(Nat.is_eq(C.raw_len(t), List.length(&2, C.Schema, xs)), C.each_pos(~rule, xs, t, 0n))), tm(~rule, xs, t)) : {Bool.and(C.conforms(~rule, x, h, None{}), _) == Bool.and(C.raw_list(t), Bool.and(Nat.is_eq(C.raw_len(t), List.length(&2, C.Schema, xs)), Bool.and(C.conforms(~rule, x, h, None{}), C.each_pos(~rule, xs, C.RCons{h, t}, 1n)))) : Bool}
2486
+ %Equal.sym(Bool, C.each_pos(~rule, xs, C.RCons{h, t}, 1n), C.each_pos(~rule, xs, t, 0n), each_shift(~rule, xs, h, t, 0n)) : {Bool.and(C.conforms(~rule, x, h, None{}), Bool.and(C.raw_list(t), Bool.and(Nat.is_eq(C.raw_len(t), List.length(&2, C.Schema, xs)), C.each_pos(~rule, xs, t, 0n)))) == Bool.and(C.raw_list(t), Bool.and(Nat.is_eq(C.raw_len(t), List.length(&2, C.Schema, xs)), Bool.and(C.conforms(~rule, x, h, None{}), _))) : Bool}
2487
+ and3_swap(C.conforms(~rule, x, h, None{}), C.raw_list(t), Nat.is_eq(C.raw_len(t), List.length(&2, C.Schema, xs)), C.each_pos(~rule, xs, t, 0n))
2488
+ case +x <> +xs C.RNil{}:
2489
+ {==}
2490
+ case x <> xs C.RNum{n}:
2491
+ {==}
2492
+ case x <> xs C.RBool{b}:
2493
+ {==}
2494
+ case x <> xs C.RNull{}:
2495
+ {==}
2496
+ case x <> xs C.RStr{s}:
2497
+ {==}
2498
+ case x <> xs C.RBad{}:
2499
+ {==}
2500
+ case x <> xs C.RTooBig{}:
2501
+ {==}
2502
+ case x <> xs C.RMissing{}:
2503
+ {==}
2504
+ case x <> xs C.REnd{}:
2505
+ {==}
2506
+ case x <> xs C.RKey{k, v, o}:
2507
+ {==}
2508
+
2509
+ def Laws.tuple_meaning(rule, ss, r):
2510
+ tm(~rule, ss, r)
2511
+
2512
+ # ---- tools: what enc writes, for the decoder's laws ----
2513
+ #
2514
+ # Facts about the value enc writes and the keys a well-formed chain holds.
2515
+ # Each fact is stated {simple == complex}, so a rewrite replaces the complex
2516
+ # side (as above).
2517
+
2518
+ def and_l(a: Bool, +b: Bool, h: {Bool.and(a, b) == True{} : Bool}) -> {a == True{} : Bool}:
2519
+ match a:
2520
+ case True{}:
2521
+ {==}
2522
+ case False{}:
2523
+ Empty.absurd({False{} == True{} : Bool}, to_empty(h))
2524
+
2525
+ def and_r(a: Bool, +b: Bool, h: {Bool.and(a, b) == True{} : Bool}) -> {b == True{} : Bool}:
2526
+ match a:
2527
+ case True{}:
2528
+ h
2529
+ case False{}:
2530
+ Empty.absurd({b == True{} : Bool}, to_empty(h))
2531
+
2532
+ # The two conjuncts behind the key test. A key a schema reads that is in the
2533
+ # value carries key_once first, and what conforms asks at that key and after
2534
+ # it come behind it; a premise that says the whole conjunction holds is read
2535
+ # as either of the two, for the value under the key (l) or for the rest (r).
2536
+ def and_key_l(a: Bool, +b: Bool, +c: Bool, h: {Bool.and(a, Bool.and(b, c)) == True{} : Bool}) -> {b == True{} : Bool}:
2537
+ match a:
2538
+ case True{}:
2539
+ and_l(b, c, h)
2540
+ case False{}:
2541
+ Empty.absurd({b == True{} : Bool}, to_empty(h))
2542
+
2543
+ def and_key_r(a: Bool, +b: Bool, +c: Bool, h: {Bool.and(a, Bool.and(b, c)) == True{} : Bool}) -> {c == True{} : Bool}:
2544
+ match a:
2545
+ case True{}:
2546
+ and_r(b, c, h)
2547
+ case False{}:
2548
+ Empty.absurd({c == True{} : Bool}, to_empty(h))
2549
+
2550
+ def not_true(b: Bool, h: {Bool.not(b) == True{} : Bool}) -> {False{} == b : Bool}:
2551
+ match b:
2552
+ case True{}:
2553
+ Empty.absurd({False{} == True{} : Bool}, to_empty(h))
2554
+ case False{}:
2555
+ {==}
2556
+
2557
+ # enc never writes a missing value, as long as no absent value can reach the
2558
+ # top of what it writes (opt_at): the schemas that would are an SOptional
2559
+ # itself, and the ones that hand their value straight to one.
2560
+ def not_missing(s: C.Schema, x: C.Meaning(s), +hn: {False{} == C.opt_at(s) : Bool}) -> {False{} == C.is_missing(C.enc(s, x)) : Bool}:
2561
+ match s x:
2562
+ case C.SNat{} n:
2563
+ {==}
2564
+ case C.SNatIn{lo_, hi_} n:
2565
+ {==}
2566
+ case C.SBool{} b:
2567
+ {==}
2568
+ case C.SStr{} n:
2569
+ {==}
2570
+ case C.SStrLen{lo_, hi_, s2} v:
2571
+ not_missing(s2, v, hn)
2572
+ case C.SListLen{lo_, hi_, s2} v:
2573
+ not_missing(s2, v, hn)
2574
+ case C.SOpt{i} None{}:
2575
+ {==}
2576
+ case C.SOpt{i} Some{v}:
2577
+ not_missing(i, v, hn)
2578
+ case C.SList{e} Nil{}:
2579
+ {==}
2580
+ case C.SList{e} h <> t:
2581
+ {==}
2582
+ case C.SField{n, fs, rest} C.Both{a, b}:
2583
+ {==}
2584
+ case C.SEnd{} Unit{}:
2585
+ {==}
2586
+ case C.SRule{s2, tag} v:
2587
+ not_missing(s2, v, hn)
2588
+ case C.SStrict{s2} v:
2589
+ not_missing(s2, v, hn)
2590
+ case C.STagged{k, n, cs, rest} Inl{a}:
2591
+ {==}
2592
+ case C.STagged{k, n, cs, rest} Inr{b}:
2593
+ not_missing(rest, b, hn)
2594
+ case C.STagEnd{k_} e:
2595
+ Empty.absurd({False{} == C.is_missing(C.enc(C.STagEnd{k_}, e)) : Bool}, e)
2596
+ case C.STrue{} Unit{}:
2597
+ {==}
2598
+ case C.SEnum{names} v:
2599
+ {==}
2600
+ case C.SVariant{+n, vs, +rest} Inl{a}:
2601
+ {==}
2602
+ case C.SVariant{n, vs, rest} Inr{b}:
2603
+ not_missing(rest, b, hn)
2604
+ case C.SVEnd{} e:
2605
+ Empty.absurd({False{} == C.is_missing(C.enc(C.SVEnd{}, e)) : Bool}, e)
2606
+ case C.STuple{ts, rest} C.Both{a, b}:
2607
+ {==}
2608
+ case C.STEnd{} Unit{}:
2609
+ {==}
2610
+ case C.SOptional{i} None{}:
2611
+ Empty.absurd({False{} == C.is_missing(C.enc(C.SOptional{i}, None{})) : Bool}, to_empty(hn))
2612
+ case C.SOptional{i} Some{v}:
2613
+ Empty.absurd({False{} == C.is_missing(C.enc(C.SOptional{i}, Some{v})) : Bool}, to_empty(hn))
2614
+
2615
+ # Reading a key from the object that starts with it.
2616
+ def lk_self(+n: String, +v: C.Raw, +o: C.Raw) -> {v == C.lookup(n, C.RKey{n, v, o}) : C.Raw}:
2617
+ %MS.eq_refl_sym(n) : {v == C.pick_raw(_, v, C.lookup(n, o)) : C.Raw}
2618
+ {==}
2619
+
2620
+ # Reading past a key of another name.
2621
+ def lk_skip(+n: String, +m: String, +v: C.Raw, +o: C.Raw, ne: {False{} == String.eq(n, m) : Bool}) -> {C.lookup(m, o) == C.lookup(m, C.RKey{n, v, o}) : C.Raw}:
2622
+ %ne : {C.lookup(m, o) == C.pick_raw(_, v, C.lookup(m, o)) : C.Raw}
2623
+ {==}
2624
+
2625
+ # The same for the key test: a key of another name is compared to m and never
2626
+ # matches, so it can be neither the first read of m nor a second one, and the
2627
+ # test reads the same past it as without it.
2628
+ def kc_skip(+n: String, +m: String, +v: C.Raw, +o: C.Raw, ne: {False{} == String.eq(n, m) : Bool}) -> {C.key_once(m, o) == C.key_once(m, C.RKey{n, v, o}) : Bool}:
2629
+ %ne : {C.key_once(m, o) == C.key_once_at(o, _, m) : Bool}
2630
+ {==}
2631
+
2632
+ # A key no variant of a well-formed chain names is absent from what enc
2633
+ # writes for the chain.
2634
+ def absent(+n: String, s: C.Schema, x: C.Meaning(s), +hf: {C.fresh_v(n, s) == True{} : Bool}) -> {True{} == C.is_missing(C.lookup(n, C.enc(s, x))) : Bool}:
2635
+ match s x:
2636
+ case C.SVariant{+m, vs, rest} Inl{a}:
2637
+ %not_true(String.eq(m, n), and_l(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_v(n, rest)), hf)) : {True{} == C.is_missing(C.pick_raw(_, C.enc(vs, a), C.lookup(n, C.REnd{}))) : Bool}
2638
+ {==}
2639
+ case C.SVariant{+m, vs, +rest} Inr{b}:
2640
+ absent(n, rest, b, and_r(Bool.not(String.eq(n, m)), C.fresh_v(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_v(n, rest)), hf)))
2641
+ case C.SVEnd{} e:
2642
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SVEnd{}, e))) : Bool}, e)
2643
+ case C.SBool{} v:
2644
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SBool{}, v))) : Bool}, to_empty(hf))
2645
+ case C.SNatIn{lo_, hi_} v:
2646
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SNatIn{lo_, hi_}, v))) : Bool}, to_empty(hf))
2647
+ case C.SStrLen{lo_, hi_, s2} v:
2648
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SStrLen{lo_, hi_, s2}, v))) : Bool}, to_empty(hf))
2649
+ case C.SNat{} v:
2650
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SNat{}, v))) : Bool}, to_empty(hf))
2651
+ case C.SStr{} v:
2652
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SStr{}, v))) : Bool}, to_empty(hf))
2653
+ case C.SOpt{i} v:
2654
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SOpt{i}, v))) : Bool}, to_empty(hf))
2655
+ case C.SList{e} v:
2656
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SList{e}, v))) : Bool}, to_empty(hf))
2657
+ case C.SField{k, fs, rest} v:
2658
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SField{k, fs, rest}, v))) : Bool}, to_empty(hf))
2659
+ case C.SEnd{} v:
2660
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SEnd{}, v))) : Bool}, to_empty(hf))
2661
+ case C.SRule{s2, tag} v:
2662
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SRule{s2, tag}, v))) : Bool}, to_empty(hf))
2663
+ case C.SStrict{s2} v:
2664
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SStrict{s2}, v))) : Bool}, to_empty(hf))
2665
+ case C.STagged{k_, n_, cs_, rest_} v:
2666
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.STagged{k_, n_, cs_, rest_}, v))) : Bool}, to_empty(hf))
2667
+ case C.STagEnd{k_} v:
2668
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.STagEnd{k_}, v))) : Bool}, to_empty(hf))
2669
+ case C.STrue{} v:
2670
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.STrue{}, v))) : Bool}, to_empty(hf))
2671
+ case C.SEnum{names} v:
2672
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SEnum{names}, v))) : Bool}, to_empty(hf))
2673
+ case C.STuple{ts, rest} v:
2674
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.STuple{ts, rest}, v))) : Bool}, to_empty(hf))
2675
+ case C.STEnd{} v:
2676
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.STEnd{}, v))) : Bool}, to_empty(hf))
2677
+ case C.SOptional{i_} v:
2678
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SOptional{i_}, v))) : Bool}, to_empty(hf))
2679
+ case C.SListLen{lo_, hi_, s2_} v:
2680
+ Empty.absurd({True{} == C.is_missing(C.lookup(n, C.enc(C.SListLen{lo_, hi_, s2_}, v))) : Bool}, to_empty(hf))
2681
+
2682
+ # A schema that is not nullable does not write null.
2683
+ def not_nullish(s: C.Schema, x: C.Meaning(s), +hn: {False{} == C.nullable(s) : Bool}) -> {False{} == C.nullish(C.enc(s, x)) : Bool}:
2684
+ match s x:
2685
+ case C.SNat{} n:
2686
+ {==}
2687
+ case C.SNatIn{lo_, hi_} n:
2688
+ {==}
2689
+ case C.SBool{} b:
2690
+ {==}
2691
+ case C.SStr{} n:
2692
+ {==}
2693
+ case C.SStrLen{lo_, hi_, s2} v:
2694
+ not_nullish(s2, v, hn)
2695
+ case C.SOpt{i} v:
2696
+ Empty.absurd({False{} == C.nullish(C.enc(C.SOpt{i}, v)) : Bool}, to_empty(hn))
2697
+ case C.SList{e} Nil{}:
2698
+ {==}
2699
+ case C.SList{e} h <> t:
2700
+ {==}
2701
+ case C.SField{n, fs, rest} C.Both{a, b}:
2702
+ {==}
2703
+ case C.SEnd{} Unit{}:
2704
+ {==}
2705
+ case C.SRule{s2, tag} v:
2706
+ not_nullish(s2, v, hn)
2707
+ case C.SStrict{s2} v:
2708
+ not_nullish(s2, v, hn)
2709
+ case C.STagged{k, n, cs, rest} Inl{a}:
2710
+ {==}
2711
+ case C.STagged{k, n, cs, rest} Inr{b}:
2712
+ not_nullish(rest, b, hn)
2713
+ case C.STagEnd{k_} e:
2714
+ Empty.absurd({False{} == C.nullish(C.enc(C.STagEnd{k_}, e)) : Bool}, e)
2715
+ case C.STrue{} Unit{}:
2716
+ {==}
2717
+ case C.SEnum{names} v:
2718
+ {==}
2719
+ case C.SVariant{n, vs, rest} Inl{a}:
2720
+ {==}
2721
+ case C.SVariant{n, vs, rest} Inr{b}:
2722
+ not_nullish(rest, b, hn)
2723
+ case C.SVEnd{} e:
2724
+ Empty.absurd({False{} == C.nullish(C.enc(C.SVEnd{}, e)) : Bool}, e)
2725
+ case C.STuple{ts, rest} C.Both{a, b}:
2726
+ {==}
2727
+ case C.STEnd{} Unit{}:
2728
+ {==}
2729
+ case C.SOptional{i} v:
2730
+ Empty.absurd({False{} == C.nullish(C.enc(C.SOptional{i}, v)) : Bool}, to_empty(hn))
2731
+ case C.SListLen{lo_, hi_, s2} v:
2732
+ not_nullish(s2, v, hn)
2733
+
2734
+ # A tagged case: the tag enc writes reads back as this case's, drop_key
2735
+ # takes it out again, and no later case of a well-formed chain claims it.
2736
+
2737
+ def tag_self(+k: String, +n: String, e: C.Raw) -> {True{} == C.is_tag(k, n, C.RKey{k, C.RStr{n}, e}) : Bool}:
2738
+ %MS.eq_refl_sym(k) : {True{} == C.is_str(n, C.pick_raw(_, C.RStr{n}, C.lookup(k, e))) : Bool}
2739
+ %MS.eq_refl_sym(n) : {True{} == _ : Bool}
2740
+ {==}
2741
+
2742
+ def drop_self(+k: String, +v: C.Raw, +e: C.Raw) -> {e == C.drop_key(k, C.RKey{k, v, e}) : C.Raw}:
2743
+ %MS.eq_refl_sym(k) : {e == C.pick_raw(_, e, C.RKey{k, v, C.drop_key(k, e)}) : C.Raw}
2744
+ {==}
2745
+
2746
+ def tag_other(+k: String, +n: String, s: C.Schema, x: C.Meaning(s), +hf: {C.fresh_t(k, n, s) == True{} : Bool}) -> {False{} == C.is_tag(k, n, C.enc(s, x)) : Bool}:
2747
+ match s x:
2748
+ case C.STagged{+k2, +m, +cs, +rest} Inl{+a}:
2749
+ %Equal.sym(Bool, String.eq(k2, k), True{}, and_l(String.eq(k2, k), Bool.and(Bool.not(String.eq(m, n)), C.fresh_t(k, n, rest)), hf)) : {False{} == C.is_str(n, C.pick_raw(_, C.RStr{m}, C.lookup(k, C.enc(cs, a)))) : Bool}
2750
+ %not_true(String.eq(m, n), and_l(Bool.not(String.eq(m, n)), C.fresh_t(k, n, rest), and_r(String.eq(k2, k), Bool.and(Bool.not(String.eq(m, n)), C.fresh_t(k, n, rest)), hf))) : {False{} == _ : Bool}
2751
+ {==}
2752
+ case C.STagged{+k2, +m, cs, +rest} Inr{b}:
2753
+ tag_other(k, n, rest, b, and_r(Bool.not(String.eq(m, n)), C.fresh_t(k, n, rest), and_r(String.eq(k2, k), Bool.and(Bool.not(String.eq(m, n)), C.fresh_t(k, n, rest)), hf)))
2754
+ case C.STagEnd{k2} e:
2755
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.STagEnd{k2}, e)) : Bool}, e)
2756
+ case C.SBool{} x_:
2757
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SBool{}, x_)) : Bool}, to_empty(hf))
2758
+ case C.SNatIn{lo_, hi_} x_:
2759
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SNatIn{lo_, hi_}, x_)) : Bool}, to_empty(hf))
2760
+ case C.SStrLen{lo_, hi_, s2} x_:
2761
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SStrLen{lo_, hi_, s2}, x_)) : Bool}, to_empty(hf))
2762
+ case C.SNat{} x_:
2763
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SNat{}, x_)) : Bool}, to_empty(hf))
2764
+ case C.SStr{} x_:
2765
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SStr{}, x_)) : Bool}, to_empty(hf))
2766
+ case C.SOpt{i_} x_:
2767
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SOpt{i_}, x_)) : Bool}, to_empty(hf))
2768
+ case C.SOptional{i_} x_:
2769
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SOptional{i_}, x_)) : Bool}, to_empty(hf))
2770
+ case C.SListLen{lo_, hi_, s2_} x_:
2771
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SListLen{lo_, hi_, s2_}, x_)) : Bool}, to_empty(hf))
2772
+ case C.SList{e_} x_:
2773
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SList{e_}, x_)) : Bool}, to_empty(hf))
2774
+ case C.SField{f_, fs_, r_} x_:
2775
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SField{f_, fs_, r_}, x_)) : Bool}, to_empty(hf))
2776
+ case C.SEnd{} x_:
2777
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SEnd{}, x_)) : Bool}, to_empty(hf))
2778
+ case C.SRule{s_, t_} x_:
2779
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SRule{s_, t_}, x_)) : Bool}, to_empty(hf))
2780
+ case C.SStrict{s_} x_:
2781
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SStrict{s_}, x_)) : Bool}, to_empty(hf))
2782
+ case C.STrue{} x_:
2783
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.STrue{}, x_)) : Bool}, to_empty(hf))
2784
+ case C.SEnum{ns_} x_:
2785
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SEnum{ns_}, x_)) : Bool}, to_empty(hf))
2786
+ case C.SVariant{v_, vs_, r_} x_:
2787
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SVariant{v_, vs_, r_}, x_)) : Bool}, to_empty(hf))
2788
+ case C.SVEnd{} x_:
2789
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.SVEnd{}, x_)) : Bool}, to_empty(hf))
2790
+ case C.STuple{ts_, rs_} x_:
2791
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.STuple{ts_, rs_}, x_)) : Bool}, to_empty(hf))
2792
+ case C.STEnd{} x_:
2793
+ Empty.absurd({False{} == C.is_tag(k, n, C.enc(C.STEnd{}, x_)) : Bool}, to_empty(hf))
2794
+
2795
+ # ---- what was written reads back as itself ----
2796
+
2797
+ # A record chain reads past a key it does not name.
2798
+ def skip_f(+n: String, s: C.Schema, +v: C.Raw, +o: C.Raw, +hf: {C.fresh_f(n, s) == True{} : Bool}) -> {C.dec(s, o) == C.dec(s, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(s)>}:
2799
+ match s:
2800
+ case C.SField{+m, +fs, +rest}:
2801
+ %not_true(String.eq(n, m), and_l(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf))) : {C.dec(C.SField{m, fs, rest}, o) == C.both(C.Meaning(fs), C.Meaning(rest), C.dec(fs, C.pick_raw(_, v, C.lookup(m, o))), C.dec(rest, C.RKey{n, v, o})) : Maybe<&2, C.Both<C.Meaning(fs), C.Meaning(rest)>>}
2802
+ %skip_f(n, rest, v, o, and_r(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf))) : {C.dec(C.SField{m, fs, rest}, o) == C.both(C.Meaning(fs), C.Meaning(rest), C.dec(fs, C.lookup(m, o)), _) : Maybe<&2, C.Both<C.Meaning(fs), C.Meaning(rest)>>}
2803
+ {==}
2804
+ case C.SEnd{}:
2805
+ {==}
2806
+ case C.SBool{}:
2807
+ Empty.absurd({C.dec(C.SBool{}, o) == C.dec(C.SBool{}, C.RKey{n, v, o}) : Maybe<&2, Bool>}, to_empty(hf))
2808
+ case C.SNatIn{lo_, hi_}:
2809
+ Empty.absurd({C.dec(C.SNatIn{lo_, hi_}, o) == C.dec(C.SNatIn{lo_, hi_}, C.RKey{n, v, o}) : Maybe<&2, Nat>}, to_empty(hf))
2810
+ case C.SStrLen{lo_, hi_, s2}:
2811
+ Empty.absurd({C.dec(C.SStrLen{lo_, hi_, s2}, o) == C.dec(C.SStrLen{lo_, hi_, s2}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(s2)>}, to_empty(hf))
2812
+ case C.SNat{}:
2813
+ Empty.absurd({C.dec(C.SNat{}, o) == C.dec(C.SNat{}, C.RKey{n, v, o}) : Maybe<&2, Nat>}, to_empty(hf))
2814
+ case C.SStr{}:
2815
+ Empty.absurd({C.dec(C.SStr{}, o) == C.dec(C.SStr{}, C.RKey{n, v, o}) : Maybe<&2, String>}, to_empty(hf))
2816
+ case C.SOpt{i}:
2817
+ Empty.absurd({C.dec(C.SOpt{i}, o) == C.dec(C.SOpt{i}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.SOpt{i})>}, to_empty(hf))
2818
+ case C.SList{e}:
2819
+ Empty.absurd({C.dec(C.SList{e}, o) == C.dec(C.SList{e}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.SList{e})>}, to_empty(hf))
2820
+ case C.SRule{s2, tag}:
2821
+ Empty.absurd({C.dec(C.SRule{s2, tag}, o) == C.dec(C.SRule{s2, tag}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(s2)>}, to_empty(hf))
2822
+ case C.SStrict{s2}:
2823
+ Empty.absurd({C.dec(C.SStrict{s2}, o) == C.dec(C.SStrict{s2}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(s2)>}, to_empty(hf))
2824
+ case C.STagged{k_, n_, cs_, rest_}:
2825
+ Empty.absurd({C.dec(C.STagged{k_, n_, cs_, rest_}, o) == C.dec(C.STagged{k_, n_, cs_, rest_}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.STagged{k_, n_, cs_, rest_})>}, to_empty(hf))
2826
+ case C.STagEnd{k_}:
2827
+ Empty.absurd({C.dec(C.STagEnd{k_}, o) == C.dec(C.STagEnd{k_}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.STagEnd{k_})>}, to_empty(hf))
2828
+ case C.STrue{}:
2829
+ Empty.absurd({C.dec(C.STrue{}, o) == C.dec(C.STrue{}, C.RKey{n, v, o}) : Maybe<&2, Unit>}, to_empty(hf))
2830
+ case C.SEnum{names}:
2831
+ Empty.absurd({C.dec(C.SEnum{names}, o) == C.dec(C.SEnum{names}, C.RKey{n, v, o}) : Maybe<&2, String>}, to_empty(hf))
2832
+ case C.SVariant{k, vs, rest}:
2833
+ Empty.absurd({C.dec(C.SVariant{k, vs, rest}, o) == C.dec(C.SVariant{k, vs, rest}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.SVariant{k, vs, rest})>}, to_empty(hf))
2834
+ case C.SVEnd{}:
2835
+ Empty.absurd({C.dec(C.SVEnd{}, o) == C.dec(C.SVEnd{}, C.RKey{n, v, o}) : Maybe<&2, Empty>}, to_empty(hf))
2836
+ case C.STuple{ts, rest}:
2837
+ Empty.absurd({C.dec(C.STuple{ts, rest}, o) == C.dec(C.STuple{ts, rest}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.STuple{ts, rest})>}, to_empty(hf))
2838
+ case C.STEnd{}:
2839
+ Empty.absurd({C.dec(C.STEnd{}, o) == C.dec(C.STEnd{}, C.RKey{n, v, o}) : Maybe<&2, Unit>}, to_empty(hf))
2840
+ case C.SOptional{i_}:
2841
+ Empty.absurd({C.dec(C.SOptional{i_}, o) == C.dec(C.SOptional{i_}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.SOptional{i_})>}, to_empty(hf))
2842
+ case C.SListLen{lo_, hi_, s2_}:
2843
+ Empty.absurd({C.dec(C.SListLen{lo_, hi_, s2_}, o) == C.dec(C.SListLen{lo_, hi_, s2_}, C.RKey{n, v, o}) : Maybe<&2, C.Meaning(C.SListLen{lo_, hi_, s2_})>}, to_empty(hf))
2844
+
2845
+ def de(s: C.Schema, x: C.Meaning(s), +hw: {C.wf(s) == True{} : Bool}) -> {Some{x} == C.dec(s, C.enc(s, x)) : Maybe<&2, C.Meaning(s)>}:
2846
+ match s x:
2847
+ case C.SNat{} n:
2848
+ {==}
2849
+ case C.SNatIn{lo_, hi_} n:
2850
+ {==}
2851
+ case C.SBool{} b:
2852
+ {==}
2853
+ case C.SStr{} n:
2854
+ {==}
2855
+ case C.SOpt{i} None{}:
2856
+ {==}
2857
+ case C.SOpt{+i} Some{+v}:
2858
+ %not_nullish(i, v, not_true(C.nullable(i), and_l(Bool.not(C.nullable(i)), C.wf(i), hw))) : {Some{Some{v}} == C.pick_m(Maybe<&2, Maybe<&2, C.Meaning(i)>>, _, Some{None{}}, C.opt_some(C.Meaning(i), C.dec(i, C.enc(i, v)))) : Maybe<&2, Maybe<&2, C.Meaning(i)>>}
2859
+ %de(i, v, and_r(Bool.not(C.nullable(i)), C.wf(i), hw)) : {Some{Some{v}} == C.opt_some(C.Meaning(i), _) : Maybe<&2, Maybe<&2, C.Meaning(i)>>}
2860
+ {==}
2861
+ case C.SList{e} Nil{}:
2862
+ {==}
2863
+ case C.SList{+e} +h <> +t:
2864
+ %de(e, h, and_r(Bool.not(C.opt_at(e)), C.wf(e), hw)) : {Some{h <> t} == C.lcons(C.Meaning(e), _, C.dec(C.SList{e}, C.enc(C.SList{e}, t))) : Maybe<&2, List<&2, C.Meaning(e)>>}
2865
+ %de(C.SList{e}, t, hw) : {Some{h <> t} == C.lcons(C.Meaning(e), Some{h}, _) : Maybe<&2, List<&2, C.Meaning(e)>>}
2866
+ {==}
2867
+ case C.SListLen{lo_, hi_, +s2} v:
2868
+ de(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), hw))
2869
+ case C.SOptional{+i} None{}:
2870
+ {==}
2871
+ case C.SOptional{+i} Some{+v}:
2872
+ %not_missing(i, v, not_true(C.opt_at(i), and_l(Bool.not(C.opt_at(i)), C.wf(i), hw))) : {Some{Some{v}} == C.pick_m(Maybe<&2, Maybe<&2, C.Meaning(i)>>, _, Some{None{}}, C.opt_some(C.Meaning(i), C.dec(i, C.enc(i, v)))) : Maybe<&2, Maybe<&2, C.Meaning(i)>>}
2873
+ %de(i, v, and_r(Bool.not(C.opt_at(i)), C.wf(i), hw)) : {Some{Some{v}} == C.opt_some(C.Meaning(i), _) : Maybe<&2, Maybe<&2, C.Meaning(i)>>}
2874
+ {==}
2875
+ case C.SField{+n, +fs, +rest} C.Both{+a, +b}:
2876
+ %lk_self(n, C.enc(fs, a), C.enc(rest, b)) : {Some{C.Both{a, b}} == C.both(C.Meaning(fs), C.Meaning(rest), C.dec(fs, _), C.dec(rest, C.RKey{n, C.enc(fs, a), C.enc(rest, b)})) : Maybe<&2, C.Both<C.Meaning(fs), C.Meaning(rest)>>}
2877
+ %skip_f(n, rest, C.enc(fs, a), C.enc(rest, b), and_l(C.fresh_f(n, rest), C.wf(rest), and_r(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw))) : {Some{C.Both{a, b}} == C.both(C.Meaning(fs), C.Meaning(rest), C.dec(fs, C.enc(fs, a)), _) : Maybe<&2, C.Both<C.Meaning(fs), C.Meaning(rest)>>}
2878
+ %de(fs, a, and_l(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw)) : {Some{C.Both{a, b}} == C.both(C.Meaning(fs), C.Meaning(rest), _, C.dec(rest, C.enc(rest, b))) : Maybe<&2, C.Both<C.Meaning(fs), C.Meaning(rest)>>}
2879
+ %de(rest, b, and_r(C.fresh_f(n, rest), C.wf(rest), and_r(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw))) : {Some{C.Both{a, b}} == C.both(C.Meaning(fs), C.Meaning(rest), Some{a}, _) : Maybe<&2, C.Both<C.Meaning(fs), C.Meaning(rest)>>}
2880
+ {==}
2881
+ case C.SEnd{} Unit{}:
2882
+ {==}
2883
+ case C.SStrLen{lo_, hi_, +s2} v:
2884
+ de(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), hw))
2885
+ case C.SRule{+s2, tag} v:
2886
+ de(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), hw))
2887
+ case C.SStrict{+s2} v:
2888
+ de(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), and_r(C.is_keyed(s2), Bool.and(Bool.not(C.opt_at(s2)), C.wf(s2)), hw)))
2889
+ case C.STagged{+k, +n, +cs, +rest} Inl{+a}:
2890
+ %tag_self(k, n, C.enc(cs, a)) : {Some{Inl{a}} == C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>, _, C.map_inl(C.Meaning(cs), C.Meaning(rest), C.dec(cs, C.drop_key(k, C.RKey{k, C.RStr{n}, C.enc(cs, a)}))), C.map_inr(C.Meaning(cs), C.Meaning(rest), C.dec(rest, C.RKey{k, C.RStr{n}, C.enc(cs, a)}))) : Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>}
2891
+ %drop_self(k, C.RStr{n}, C.enc(cs, a)) : {Some{Inl{a}} == C.map_inl(C.Meaning(cs), C.Meaning(rest), C.dec(cs, _)) : Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>}
2892
+ %de(cs, a, and_l(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw))) : {Some{Inl{a}} == C.map_inl(C.Meaning(cs), C.Meaning(rest), _) : Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>}
2893
+ {==}
2894
+ case C.STagged{+k, +n, +cs, +rest} Inr{+b}:
2895
+ %tag_other(k, n, rest, b, and_l(C.fresh_t(k, n, rest), C.wf(rest), and_r(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)), and_r(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw))))) : {Some{Inr{b}} == C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>, _, C.map_inl(C.Meaning(cs), C.Meaning(rest), C.dec(cs, C.drop_key(k, C.enc(rest, b)))), C.map_inr(C.Meaning(cs), C.Meaning(rest), C.dec(rest, C.enc(rest, b)))) : Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>}
2896
+ %de(rest, b, and_r(C.fresh_t(k, n, rest), C.wf(rest), and_r(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)), and_r(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw))))) : {Some{Inr{b}} == C.map_inr(C.Meaning(cs), C.Meaning(rest), _) : Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>}
2897
+ {==}
2898
+ case C.STagEnd{k_} e:
2899
+ Empty.absurd({Some{e} == C.dec(C.STagEnd{k_}, C.enc(C.STagEnd{k_}, e)) : Maybe<&2, Empty>}, e)
2900
+ case C.STrue{} Unit{}:
2901
+ {==}
2902
+ case C.SEnum{names} v:
2903
+ {==}
2904
+ case C.SVariant{+n, +vs, +rest} Inl{+a}:
2905
+ %lk_self(n, C.enc(vs, a), C.REnd{}) : {Some{Inl{a}} == C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>, C.is_missing(_), C.map_inr(C.Meaning(vs), C.Meaning(rest), C.dec(rest, C.RKey{n, C.enc(vs, a), C.REnd{}})), C.map_inl(C.Meaning(vs), C.Meaning(rest), C.dec(vs, _))) : Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>}
2906
+ %not_missing(vs, a, not_true(C.opt_at(vs), and_l(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw))) : {Some{Inl{a}} == C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>, _, C.map_inr(C.Meaning(vs), C.Meaning(rest), C.dec(rest, C.RKey{n, C.enc(vs, a), C.REnd{}})), C.map_inl(C.Meaning(vs), C.Meaning(rest), C.dec(vs, C.enc(vs, a)))) : Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>}
2907
+ %de(vs, a, and_l(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw))) : {Some{Inl{a}} == C.map_inl(C.Meaning(vs), C.Meaning(rest), _) : Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>}
2908
+ {==}
2909
+ case C.SVariant{+n, +vs, +rest} Inr{+b}:
2910
+ %absent(n, rest, b, and_l(C.fresh_v(n, rest), C.wf(rest), and_r(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw)))) : {Some{Inr{b}} == C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>, _, C.map_inr(C.Meaning(vs), C.Meaning(rest), C.dec(rest, C.enc(rest, b))), C.map_inl(C.Meaning(vs), C.Meaning(rest), C.dec(vs, C.lookup(n, C.enc(rest, b))))) : Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>}
2911
+ %de(rest, b, and_r(C.fresh_v(n, rest), C.wf(rest), and_r(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw)))) : {Some{Inr{b}} == C.map_inr(C.Meaning(vs), C.Meaning(rest), _) : Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>}
2912
+ {==}
2913
+ case C.SVEnd{} e:
2914
+ Empty.absurd({Some{e} == C.dec(C.SVEnd{}, C.enc(C.SVEnd{}, e)) : Maybe<&2, Empty>}, e)
2915
+ case C.STuple{+ts, +rest} C.Both{+a, +b}:
2916
+ %de(ts, a, and_l(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest)), and_r(Bool.not(C.opt_at(ts)), Bool.and(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest))), hw))) : {Some{C.Both{a, b}} == C.both(C.Meaning(ts), C.Meaning(rest), _, C.dec(rest, C.enc(rest, b))) : Maybe<&2, C.Both<C.Meaning(ts), C.Meaning(rest)>>}
2917
+ %de(rest, b, and_r(Bool.not(C.opt_at(rest)), C.wf(rest), and_r(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest)), and_r(Bool.not(C.opt_at(ts)), Bool.and(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest))), hw)))) : {Some{C.Both{a, b}} == C.both(C.Meaning(ts), C.Meaning(rest), Some{a}, _) : Maybe<&2, C.Both<C.Meaning(ts), C.Meaning(rest)>>}
2918
+ {==}
2919
+ case C.STEnd{} Unit{}:
2920
+ {==}
2921
+
2922
+ def Laws.decode_encode(s, x, hw):
2923
+ Equal.sym(Maybe<&2, C.Meaning(s)>, Some{x}, C.dec(s, C.enc(s, x)), de(s, x, hw))
2924
+
2925
+
2926
+
2927
+
2928
+ # ---- a value check accepts can be read ----
2929
+
2930
+ def is_some_m(-A: Data, m: Maybe<&2, A>) -> Bool:
2931
+ Maybe.is_some(&2, A, m)
2932
+
2933
+ def some_opt(-A: Data, m: Maybe<&2, A>, h: {Maybe.is_some(&2, A, m) == True{} : Bool}) -> {Maybe.is_some(&2, Maybe<&2, A>, C.opt_some(A, m)) == True{} : Bool}:
2934
+ match m:
2935
+ case Some{v}:
2936
+ {==}
2937
+ case None{}:
2938
+ Empty.absurd({Maybe.is_some(&2, Maybe<&2, A>, C.opt_some(A, None{})) == True{} : Bool}, to_empty(h))
2939
+
2940
+ def some_cons(-A: Data, m: Maybe<&2, A>, +n: Maybe<&2, List<&2, A>>, h1: {Maybe.is_some(&2, A, m) == True{} : Bool}, h2: {Maybe.is_some(&2, List<&2, A>, n) == True{} : Bool}) -> {Maybe.is_some(&2, List<&2, A>, C.lcons(A, m, n)) == True{} : Bool}:
2941
+ match m n:
2942
+ case Some{x} Some{xs}:
2943
+ {==}
2944
+ case None{} n2:
2945
+ Empty.absurd({Maybe.is_some(&2, List<&2, A>, C.lcons(A, None{}, n2)) == True{} : Bool}, to_empty(h1))
2946
+ case Some{x} None{}:
2947
+ Empty.absurd({Maybe.is_some(&2, List<&2, A>, C.lcons(A, Some{x}, None{})) == True{} : Bool}, to_empty(h2))
2948
+
2949
+ def some_both(-A: Data, -B: Data, m: Maybe<&2, A>, +n: Maybe<&2, B>, h1: {Maybe.is_some(&2, A, m) == True{} : Bool}, h2: {Maybe.is_some(&2, B, n) == True{} : Bool}) -> {Maybe.is_some(&2, C.Both<A, B>, C.both(A, B, m, n)) == True{} : Bool}:
2950
+ match m n:
2951
+ case Some{x} Some{y}:
2952
+ {==}
2953
+ case None{} n2:
2954
+ Empty.absurd({Maybe.is_some(&2, C.Both<A, B>, C.both(A, B, None{}, n2)) == True{} : Bool}, to_empty(h1))
2955
+ case Some{x} None{}:
2956
+ Empty.absurd({Maybe.is_some(&2, C.Both<A, B>, C.both(A, B, Some{x}, None{})) == True{} : Bool}, to_empty(h2))
2957
+
2958
+ def some_inl(-A: Data, -B: Data, m: Maybe<&2, A>, h: {Maybe.is_some(&2, A, m) == True{} : Bool}) -> {Maybe.is_some(&2, Either<&2, &2, A, B>, C.map_inl(A, B, m)) == True{} : Bool}:
2959
+ match m:
2960
+ case Some{v}:
2961
+ {==}
2962
+ case None{}:
2963
+ Empty.absurd({Maybe.is_some(&2, Either<&2, &2, A, B>, C.map_inl(A, B, None{})) == True{} : Bool}, to_empty(h))
2964
+
2965
+ def some_inr(-A: Data, -B: Data, m: Maybe<&2, B>, h: {Maybe.is_some(&2, B, m) == True{} : Bool}) -> {Maybe.is_some(&2, Either<&2, &2, A, B>, C.map_inr(A, B, m)) == True{} : Bool}:
2966
+ match m:
2967
+ case Some{v}:
2968
+ {==}
2969
+ case None{}:
2970
+ Empty.absurd({Maybe.is_some(&2, Either<&2, &2, A, B>, C.map_inr(A, B, None{})) == True{} : Bool}, to_empty(h))
2971
+
2972
+ # The variant case: by whether the key is there.
2973
+ def cd_var(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, b: Bool, +vs: C.Schema, +rest: C.Schema, +n: String, +x: C.Raw, ihr: {C.conforms(~rule, rest, x, None{}) == True{} : Bool} -> {Maybe.is_some(&2, C.Meaning(rest), C.dec(rest, x)) == True{} : Bool}, ihv: {C.conforms(~rule, vs, C.lookup(n, x), None{}) == True{} : Bool} -> {Maybe.is_some(&2, C.Meaning(vs), C.dec(vs, C.lookup(n, x))) == True{} : Bool}, hc: {C.pick_bool(b, C.conforms(~rule, rest, x, None{}), Bool.and(C.key_once(n, x), Bool.and(C.conforms(~rule, vs, C.lookup(n, x), None{}), C.none_present(rest, x)))) == True{} : Bool}) -> {Maybe.is_some(&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>, C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(vs), C.Meaning(rest)>>, b, C.map_inr(C.Meaning(vs), C.Meaning(rest), C.dec(rest, x)), C.map_inl(C.Meaning(vs), C.Meaning(rest), C.dec(vs, C.lookup(n, x))))) == True{} : Bool}:
2974
+ match b:
2975
+ case True{}:
2976
+ some_inr(C.Meaning(vs), C.Meaning(rest), C.dec(rest, x), ihr(hc))
2977
+ case False{}:
2978
+ some_inl(C.Meaning(vs), C.Meaning(rest), C.dec(vs, C.lookup(n, x)), ihv(and_key_l(C.key_once(n, x), C.conforms(~rule, vs, C.lookup(n, x), None{}), C.none_present(rest, x), hc)))
2979
+
2980
+ def cd_tag(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, kc: Bool, b: Bool, +cs: C.Schema, +rest: C.Schema, +xd: C.Raw, +x: C.Raw, ihc: {C.conforms(~rule, cs, xd, None{}) == True{} : Bool} -> {Maybe.is_some(&2, C.Meaning(cs), C.dec(cs, xd)) == True{} : Bool}, ihr: {C.conforms(~rule, rest, x, None{}) == True{} : Bool} -> {Maybe.is_some(&2, C.Meaning(rest), C.dec(rest, x)) == True{} : Bool}, hc: {C.pick_bool(b, Bool.and(kc, C.conforms(~rule, cs, xd, None{})), C.conforms(~rule, rest, x, None{})) == True{} : Bool}) -> {Maybe.is_some(&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>, C.pick_m(Maybe<&2, Either<&2, &2, C.Meaning(cs), C.Meaning(rest)>>, b, C.map_inl(C.Meaning(cs), C.Meaning(rest), C.dec(cs, xd)), C.map_inr(C.Meaning(cs), C.Meaning(rest), C.dec(rest, x)))) == True{} : Bool}:
2981
+ match b:
2982
+ case True{}:
2983
+ some_inl(C.Meaning(cs), C.Meaning(rest), C.dec(cs, xd), ihc(and_r(kc, C.conforms(~rule, cs, xd, None{}), hc)))
2984
+ case False{}:
2985
+ some_inr(C.Meaning(cs), C.Meaning(rest), C.dec(rest, x), ihr(hc))
2986
+
2987
+ def tu(b: Bool, h: {b == True{} : Bool}) -> {Maybe.is_some(&2, Unit, C.true_unit(b)) == True{} : Bool}:
2988
+ match b:
2989
+ case True{}:
2990
+ {==}
2991
+ case False{}:
2992
+ Empty.absurd({Maybe.is_some(&2, Unit, C.true_unit(False{})) == True{} : Bool}, to_empty(h))
2993
+
2994
+ # arms: s r
2995
+ # arms leaf: Empty.absurd({Maybe.is_some(&2, C.Meaning($S), C.dec($S, $R)) == True{} : Bool}, to_empty(hc))
2996
+ def cd(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, s: C.Schema, r: C.Raw, +hc: {C.conforms(~rule, s, r, None{}) == True{} : Bool}) -> {Maybe.is_some(&2, C.Meaning(s), C.dec(s, r)) == True{} : Bool}:
2997
+ match s r:
2998
+ case C.SNat{} C.RNum{n}:
2999
+ {==}
3000
+ case C.SNat{} C.RBool{+bb}:
3001
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3002
+ case C.SNat{} C.RNull{}:
3003
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3004
+ case C.SNat{} C.RStr{+x}:
3005
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3006
+ case C.SNat{} C.RBad{}:
3007
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3008
+ case C.SNat{} C.RTooBig{}:
3009
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3010
+ case C.SNat{} C.RMissing{}:
3011
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3012
+ case C.SNat{} C.RNil{}:
3013
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3014
+ case C.SNat{} C.RCons{+h, +t}:
3015
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3016
+ case C.SNat{} C.REnd{}:
3017
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3018
+ case C.SNat{} C.RKey{+k, +v, +o}:
3019
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNat{}), C.dec(C.SNat{}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3020
+ case C.SNatIn{+lo, +hi} C.RNum{+n}:
3021
+ {==}
3022
+ case C.SNatIn{+lo, +hi} C.RBool{+bb}:
3023
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3024
+ case C.SNatIn{+lo, +hi} C.RNull{}:
3025
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3026
+ case C.SNatIn{+lo, +hi} C.RStr{+x}:
3027
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3028
+ case C.SNatIn{+lo, +hi} C.RBad{}:
3029
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3030
+ case C.SNatIn{+lo, +hi} C.RTooBig{}:
3031
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3032
+ case C.SNatIn{+lo, +hi} C.RMissing{}:
3033
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3034
+ case C.SNatIn{+lo, +hi} C.RNil{}:
3035
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3036
+ case C.SNatIn{+lo, +hi} C.RCons{+h, +t}:
3037
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3038
+ case C.SNatIn{+lo, +hi} C.REnd{}:
3039
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3040
+ case C.SNatIn{+lo, +hi} C.RKey{+k, +v, +o}:
3041
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SNatIn{lo, hi}), C.dec(C.SNatIn{lo, hi}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3042
+ case C.SStr{} C.RNum{n}:
3043
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3044
+ case C.SStr{} C.RBool{+bb}:
3045
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3046
+ case C.SStr{} C.RNull{}:
3047
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3048
+ case C.SStr{} C.RStr{+x}:
3049
+ {==}
3050
+ case C.SStr{} C.RBad{}:
3051
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3052
+ case C.SStr{} C.RTooBig{}:
3053
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3054
+ case C.SStr{} C.RMissing{}:
3055
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3056
+ case C.SStr{} C.RNil{}:
3057
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3058
+ case C.SStr{} C.RCons{+h, +t}:
3059
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3060
+ case C.SStr{} C.REnd{}:
3061
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3062
+ case C.SStr{} C.RKey{+k, +v, +o}:
3063
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SStr{}), C.dec(C.SStr{}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3064
+ case C.SStrLen{+lo, +hi, +s2} +x:
3065
+ cd(~rule, s2, x, and_l(C.conforms(~rule, s2, x, None{}), C.len_ok(lo, hi, x), hc))
3066
+ case C.SOpt{+i} C.RNum{+n}:
3067
+ some_opt(C.Meaning(i), C.dec(i, C.RNum{n}), cd(~rule, i, C.RNum{n}, hc))
3068
+ case C.SOpt{+i} C.RBool{+bb}:
3069
+ some_opt(C.Meaning(i), C.dec(i, C.RBool{bb}), cd(~rule, i, C.RBool{bb}, hc))
3070
+ case C.SOpt{+i} C.RNull{}:
3071
+ {==}
3072
+ case C.SOpt{+i} C.RStr{+x}:
3073
+ some_opt(C.Meaning(i), C.dec(i, C.RStr{x}), cd(~rule, i, C.RStr{x}, hc))
3074
+ case C.SOpt{+i} C.RBad{}:
3075
+ some_opt(C.Meaning(i), C.dec(i, C.RBad{}), cd(~rule, i, C.RBad{}, hc))
3076
+ case C.SOpt{+i} C.RTooBig{}:
3077
+ some_opt(C.Meaning(i), C.dec(i, C.RTooBig{}), cd(~rule, i, C.RTooBig{}, hc))
3078
+ case C.SOpt{+i} C.RMissing{}:
3079
+ {==}
3080
+ case C.SOpt{+i} C.RNil{}:
3081
+ some_opt(C.Meaning(i), C.dec(i, C.RNil{}), cd(~rule, i, C.RNil{}, hc))
3082
+ case C.SOpt{+i} C.RCons{+h, +t}:
3083
+ some_opt(C.Meaning(i), C.dec(i, C.RCons{h, t}), cd(~rule, i, C.RCons{h, t}, hc))
3084
+ case C.SOpt{+i} C.REnd{}:
3085
+ some_opt(C.Meaning(i), C.dec(i, C.REnd{}), cd(~rule, i, C.REnd{}, hc))
3086
+ case C.SOpt{+i} C.RKey{+k, +v, +o}:
3087
+ some_opt(C.Meaning(i), C.dec(i, C.RKey{k, v, o}), cd(~rule, i, C.RKey{k, v, o}, hc))
3088
+ case C.SList{+e} C.RNum{n}:
3089
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3090
+ case C.SList{+e} C.RBool{+bb}:
3091
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3092
+ case C.SList{+e} C.RNull{}:
3093
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3094
+ case C.SList{+e} C.RStr{+x}:
3095
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3096
+ case C.SList{+e} C.RBad{}:
3097
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3098
+ case C.SList{+e} C.RTooBig{}:
3099
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3100
+ case C.SList{+e} C.RMissing{}:
3101
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3102
+ case C.SList{+e} C.RNil{}:
3103
+ {==}
3104
+ case C.SList{+e} C.RCons{+h, +t}:
3105
+ some_cons(C.Meaning(e), C.dec(e, h), C.dec(C.SList{e}, t), cd(~rule, e, h, and_l(C.conforms(~rule, e, h, None{}), C.conforms(~rule, C.SList{e}, t, None{}), hc)), cd(~rule, C.SList{e}, t, and_r(C.conforms(~rule, e, h, None{}), C.conforms(~rule, C.SList{e}, t, None{}), hc)))
3106
+ case C.SList{+e} C.REnd{}:
3107
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3108
+ case C.SList{+e} C.RKey{+k, +v, +o}:
3109
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SList{e}), C.dec(C.SList{e}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3110
+ case C.SField{+fn, +fs, +rest} C.RNum{n}:
3111
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3112
+ case C.SField{+fn, +fs, +rest} C.RBool{+bb}:
3113
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3114
+ case C.SField{+fn, +fs, +rest} C.RNull{}:
3115
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3116
+ case C.SField{+fn, +fs, +rest} C.RStr{+x}:
3117
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3118
+ case C.SField{+fn, +fs, +rest} C.RBad{}:
3119
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3120
+ case C.SField{+fn, +fs, +rest} C.RTooBig{}:
3121
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3122
+ case C.SField{+fn, +fs, +rest} C.RMissing{}:
3123
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3124
+ case C.SField{+fn, +fs, +rest} C.RNil{}:
3125
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3126
+ case C.SField{+fn, +fs, +rest} C.RCons{+h, +t}:
3127
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SField{fn, fs, rest}), C.dec(C.SField{fn, fs, rest}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3128
+ case C.SField{+fn, +fs, +rest} C.REnd{}:
3129
+ some_both(C.Meaning(fs), C.Meaning(rest), C.dec(fs, C.RMissing{}), C.dec(rest, C.REnd{}), cd(~rule, fs, C.RMissing{}, and_l(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{}), hc)), cd(~rule, rest, C.REnd{}, and_r(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{}), hc)))
3130
+ case C.SField{+fn, +fs, +rest} C.RKey{+k, +v, +o}:
3131
+ some_both(C.Meaning(fs), C.Meaning(rest), C.dec(fs, C.lookup(fn, C.RKey{k, v, o})), C.dec(rest, C.RKey{k, v, o}), cd(~rule, fs, C.lookup(fn, C.RKey{k, v, o}), and_key_l(C.key_once(fn, C.RKey{k, v, o}), C.conforms(~rule, fs, C.lookup(fn, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}), hc)), cd(~rule, rest, C.RKey{k, v, o}, and_key_r(C.key_once(fn, C.RKey{k, v, o}), C.conforms(~rule, fs, C.lookup(fn, C.RKey{k, v, o}), None{}), C.conforms(~rule, rest, C.RKey{k, v, o}, None{}), hc)))
3132
+ case C.SEnd{} C.RNum{n}:
3133
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3134
+ case C.SEnd{} C.RBool{+bb}:
3135
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3136
+ case C.SEnd{} C.RNull{}:
3137
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3138
+ case C.SEnd{} C.RStr{+x}:
3139
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3140
+ case C.SEnd{} C.RBad{}:
3141
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3142
+ case C.SEnd{} C.RTooBig{}:
3143
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3144
+ case C.SEnd{} C.RMissing{}:
3145
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3146
+ case C.SEnd{} C.RNil{}:
3147
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3148
+ case C.SEnd{} C.RCons{+h, +t}:
3149
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnd{}), C.dec(C.SEnd{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3150
+ case C.SEnd{} C.REnd{}:
3151
+ {==}
3152
+ case C.SEnd{} C.RKey{k, v, o}:
3153
+ {==}
3154
+ case C.SRule{+s2, +tag} +x:
3155
+ cd(~rule, s2, x, and_l(C.conforms(~rule, s2, x, None{}), Maybe.is_none(&2, C.Err, rule(tag, x)), hc))
3156
+ case C.SStrict{+s2} +x:
3157
+ cd(~rule, s2, x, and_l(C.conforms(~rule, s2, x, None{}), C.no_extra(C.key_names(s2), x), hc))
3158
+ case C.STagged{+k, +n, +cs, +rest} +x:
3159
+ cd_tag(~rule, C.key_once(k, x), C.is_tag(k, n, x), cs, rest, C.drop_key(k, x), x, hh => cd(~rule, cs, C.drop_key(k, x), hh), hh => cd(~rule, rest, x, hh), hc)
3160
+ case C.STagEnd{key_} C.RNum{n}:
3161
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3162
+ case C.STagEnd{key_} C.RBool{+bb}:
3163
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3164
+ case C.STagEnd{key_} C.RNull{}:
3165
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3166
+ case C.STagEnd{key_} C.RStr{+x}:
3167
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3168
+ case C.STagEnd{key_} C.RBad{}:
3169
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3170
+ case C.STagEnd{key_} C.RTooBig{}:
3171
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3172
+ case C.STagEnd{key_} C.RMissing{}:
3173
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3174
+ case C.STagEnd{key_} C.RNil{}:
3175
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3176
+ case C.STagEnd{key_} C.RCons{+h, +t}:
3177
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3178
+ case C.STagEnd{key_} C.REnd{}:
3179
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3180
+ case C.STagEnd{key_} C.RKey{+k, +v, +o}:
3181
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STagEnd{key_}), C.dec(C.STagEnd{key_}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3182
+ case C.SBool{} C.RNum{n}:
3183
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3184
+ case C.SBool{} C.RBool{bb}:
3185
+ {==}
3186
+ case C.SBool{} C.RNull{}:
3187
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3188
+ case C.SBool{} C.RStr{+x}:
3189
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3190
+ case C.SBool{} C.RBad{}:
3191
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3192
+ case C.SBool{} C.RTooBig{}:
3193
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3194
+ case C.SBool{} C.RMissing{}:
3195
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3196
+ case C.SBool{} C.RNil{}:
3197
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3198
+ case C.SBool{} C.RCons{+h, +t}:
3199
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3200
+ case C.SBool{} C.REnd{}:
3201
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3202
+ case C.SBool{} C.RKey{+k, +v, +o}:
3203
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SBool{}), C.dec(C.SBool{}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3204
+ case C.STrue{} C.RNum{n}:
3205
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3206
+ case C.STrue{} C.RBool{bb}:
3207
+ tu(bb, hc)
3208
+ case C.STrue{} C.RNull{}:
3209
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3210
+ case C.STrue{} C.RStr{+x}:
3211
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3212
+ case C.STrue{} C.RBad{}:
3213
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3214
+ case C.STrue{} C.RTooBig{}:
3215
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3216
+ case C.STrue{} C.RMissing{}:
3217
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3218
+ case C.STrue{} C.RNil{}:
3219
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3220
+ case C.STrue{} C.RCons{+h, +t}:
3221
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3222
+ case C.STrue{} C.REnd{}:
3223
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3224
+ case C.STrue{} C.RKey{+k, +v, +o}:
3225
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STrue{}), C.dec(C.STrue{}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3226
+ case C.SEnum{names} C.RNum{n}:
3227
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3228
+ case C.SEnum{names} C.RBool{+bb}:
3229
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3230
+ case C.SEnum{names} C.RNull{}:
3231
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3232
+ case C.SEnum{names} C.RStr{x}:
3233
+ {==}
3234
+ case C.SEnum{names} C.RBad{}:
3235
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3236
+ case C.SEnum{names} C.RTooBig{}:
3237
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3238
+ case C.SEnum{names} C.RMissing{}:
3239
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3240
+ case C.SEnum{names} C.RNil{}:
3241
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3242
+ case C.SEnum{names} C.RCons{+h, +t}:
3243
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3244
+ case C.SEnum{names} C.REnd{}:
3245
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3246
+ case C.SEnum{names} C.RKey{+k, +v, +o}:
3247
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SEnum{names}), C.dec(C.SEnum{names}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3248
+ case C.SVariant{+vn, +vs, +rest} C.RNum{n}:
3249
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3250
+ case C.SVariant{+vn, +vs, +rest} C.RBool{+bb}:
3251
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3252
+ case C.SVariant{+vn, +vs, +rest} C.RNull{}:
3253
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3254
+ case C.SVariant{+vn, +vs, +rest} C.RStr{+x}:
3255
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3256
+ case C.SVariant{+vn, +vs, +rest} C.RBad{}:
3257
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3258
+ case C.SVariant{+vn, +vs, +rest} C.RTooBig{}:
3259
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3260
+ case C.SVariant{+vn, +vs, +rest} C.RMissing{}:
3261
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3262
+ case C.SVariant{+vn, +vs, +rest} C.RNil{}:
3263
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3264
+ case C.SVariant{+vn, +vs, +rest} C.RCons{+h, +t}:
3265
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVariant{vn, vs, rest}), C.dec(C.SVariant{vn, vs, rest}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3266
+ case C.SVariant{+vn, +vs, +rest} C.REnd{}:
3267
+ some_inr(C.Meaning(vs), C.Meaning(rest), C.dec(rest, C.REnd{}), cd(~rule, rest, C.REnd{}, hc))
3268
+ case C.SVariant{+vn, +vs, +rest} C.RKey{+k, +v, +o}:
3269
+ cd_var(~rule, C.is_missing(C.lookup(vn, C.RKey{k, v, o})), vs, rest, vn, C.RKey{k, v, o}, h => cd(~rule, rest, C.RKey{k, v, o}, h), h => cd(~rule, vs, C.lookup(vn, C.RKey{k, v, o}), h), hc)
3270
+ case C.SVEnd{} C.RNum{n}:
3271
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3272
+ case C.SVEnd{} C.RBool{+bb}:
3273
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3274
+ case C.SVEnd{} C.RNull{}:
3275
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3276
+ case C.SVEnd{} C.RStr{+x}:
3277
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3278
+ case C.SVEnd{} C.RBad{}:
3279
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3280
+ case C.SVEnd{} C.RTooBig{}:
3281
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3282
+ case C.SVEnd{} C.RMissing{}:
3283
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3284
+ case C.SVEnd{} C.RNil{}:
3285
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3286
+ case C.SVEnd{} C.RCons{+h, +t}:
3287
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3288
+ case C.SVEnd{} C.REnd{}:
3289
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3290
+ case C.SVEnd{} C.RKey{+k, +v, +o}:
3291
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.SVEnd{}), C.dec(C.SVEnd{}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3292
+ case C.STuple{+ts, +rest} C.RNum{n}:
3293
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3294
+ case C.STuple{+ts, +rest} C.RBool{+bb}:
3295
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3296
+ case C.STuple{+ts, +rest} C.RNull{}:
3297
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3298
+ case C.STuple{+ts, +rest} C.RStr{+x}:
3299
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3300
+ case C.STuple{+ts, +rest} C.RBad{}:
3301
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3302
+ case C.STuple{+ts, +rest} C.RTooBig{}:
3303
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3304
+ case C.STuple{+ts, +rest} C.RMissing{}:
3305
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3306
+ case C.STuple{+ts, +rest} C.RNil{}:
3307
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RNil{})) == True{} : Bool}, to_empty(hc))
3308
+ case C.STuple{+ts, +rest} C.RCons{+h, +t}:
3309
+ some_both(C.Meaning(ts), C.Meaning(rest), C.dec(ts, h), C.dec(rest, t), cd(~rule, ts, h, and_l(C.conforms(~rule, ts, h, None{}), C.conforms(~rule, rest, t, None{}), hc)), cd(~rule, rest, t, and_r(C.conforms(~rule, ts, h, None{}), C.conforms(~rule, rest, t, None{}), hc)))
3310
+ case C.STuple{+ts, +rest} C.REnd{}:
3311
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3312
+ case C.STuple{+ts, +rest} C.RKey{+k, +v, +o}:
3313
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STuple{ts, rest}), C.dec(C.STuple{ts, rest}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3314
+ case C.STEnd{} C.RNum{n}:
3315
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RNum{n})) == True{} : Bool}, to_empty(hc))
3316
+ case C.STEnd{} C.RBool{+bb}:
3317
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RBool{bb})) == True{} : Bool}, to_empty(hc))
3318
+ case C.STEnd{} C.RNull{}:
3319
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RNull{})) == True{} : Bool}, to_empty(hc))
3320
+ case C.STEnd{} C.RStr{+x}:
3321
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RStr{x})) == True{} : Bool}, to_empty(hc))
3322
+ case C.STEnd{} C.RBad{}:
3323
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RBad{})) == True{} : Bool}, to_empty(hc))
3324
+ case C.STEnd{} C.RTooBig{}:
3325
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RTooBig{})) == True{} : Bool}, to_empty(hc))
3326
+ case C.STEnd{} C.RMissing{}:
3327
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RMissing{})) == True{} : Bool}, to_empty(hc))
3328
+ case C.STEnd{} C.RNil{}:
3329
+ {==}
3330
+ case C.STEnd{} C.RCons{+h, +t}:
3331
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RCons{h, t})) == True{} : Bool}, to_empty(hc))
3332
+ case C.STEnd{} C.REnd{}:
3333
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.REnd{})) == True{} : Bool}, to_empty(hc))
3334
+ case C.STEnd{} C.RKey{+k, +v, +o}:
3335
+ Empty.absurd({Maybe.is_some(&2, C.Meaning(C.STEnd{}), C.dec(C.STEnd{}, C.RKey{k, v, o})) == True{} : Bool}, to_empty(hc))
3336
+ case C.SOptional{+i} C.RNum{+n}:
3337
+ some_opt(C.Meaning(i), C.dec(i, C.RNum{n}), cd(~rule, i, C.RNum{n}, hc))
3338
+ case C.SOptional{+i} C.RBool{+bb}:
3339
+ some_opt(C.Meaning(i), C.dec(i, C.RBool{bb}), cd(~rule, i, C.RBool{bb}, hc))
3340
+ case C.SOptional{+i} C.RNull{}:
3341
+ some_opt(C.Meaning(i), C.dec(i, C.RNull{}), cd(~rule, i, C.RNull{}, hc))
3342
+ case C.SOptional{+i} C.RStr{+x}:
3343
+ some_opt(C.Meaning(i), C.dec(i, C.RStr{x}), cd(~rule, i, C.RStr{x}, hc))
3344
+ case C.SOptional{+i} C.RBad{}:
3345
+ some_opt(C.Meaning(i), C.dec(i, C.RBad{}), cd(~rule, i, C.RBad{}, hc))
3346
+ case C.SOptional{+i} C.RTooBig{}:
3347
+ some_opt(C.Meaning(i), C.dec(i, C.RTooBig{}), cd(~rule, i, C.RTooBig{}, hc))
3348
+ case C.SOptional{+i} C.RMissing{}:
3349
+ {==}
3350
+ case C.SOptional{+i} C.RNil{}:
3351
+ some_opt(C.Meaning(i), C.dec(i, C.RNil{}), cd(~rule, i, C.RNil{}, hc))
3352
+ case C.SOptional{+i} C.RCons{+h, +t}:
3353
+ some_opt(C.Meaning(i), C.dec(i, C.RCons{h, t}), cd(~rule, i, C.RCons{h, t}, hc))
3354
+ case C.SOptional{+i} C.REnd{}:
3355
+ some_opt(C.Meaning(i), C.dec(i, C.REnd{}), cd(~rule, i, C.REnd{}, hc))
3356
+ case C.SOptional{+i} C.RKey{+k, +v, +o}:
3357
+ some_opt(C.Meaning(i), C.dec(i, C.RKey{k, v, o}), cd(~rule, i, C.RKey{k, v, o}, hc))
3358
+ case C.SListLen{+lo, +hi, +s2} +r:
3359
+ cd(~rule, s2, r, and_r(C.list_len_ok(lo, hi, r), C.conforms(~rule, s2, r, None{}), hc))
3360
+
3361
+ def Laws.checked_decodes(rule, s, r, hc):
3362
+ cd(~rule, s, r, hc)
3363
+
3364
+
3365
+ # ---- tools: what wf's tag rule buys, the key is nowhere in what enc wrote ----
3366
+ #
3367
+ # no_key(k, s) says the object enc builds for s holds no key k. That is what
3368
+ # key_once_at needs of the value a tag key was already written into: the walk
3369
+ # reads every key of the object, so a key that is not there is never the
3370
+ # second one -- whatever flag the walk arrived with. The flag is a parameter
3371
+ # because the walk's own step at a key j turns it into Bool.or(b, eq(j, k)),
3372
+ # and with eq(j, k) false (which is what no_key's own arms say of j) that is
3373
+ # the flag it already had.
3374
+
3375
+ def key_step(b: Bool, +j: String, +k: String, +s2: C.Schema, x2: C.Meaning(s2), +hf: {False{} == String.eq(j, k) : Bool}, ih1: {C.key_once_at(C.enc(s2, x2), True{}, k) == True{} : Bool}, ih0: {C.key_once_at(C.enc(s2, x2), False{}, k) == True{} : Bool}) -> {Bool.and(Bool.not(Bool.and(b, String.eq(j, k))), C.key_once_at(C.enc(s2, x2), Bool.or(b, String.eq(j, k)), k)) == True{} : Bool}:
3376
+ match b:
3377
+ case True{}:
3378
+ %hf : {Bool.and(Bool.not(_), C.key_once_at(C.enc(s2, x2), True{}, k)) == True{} : Bool}
3379
+ ih1
3380
+ case False{}:
3381
+ %hf : {C.key_once_at(C.enc(s2, x2), _, k) == True{} : Bool}
3382
+ ih0
3383
+
3384
+ def no_key_once(+k: String, s: C.Schema, x: C.Meaning(s), b: Bool, +h: {C.no_key(k, s) == True{} : Bool}) -> {C.key_once_at(C.enc(s, x), b, k) == True{} : Bool}:
3385
+ match s x:
3386
+ case C.SNat{} n:
3387
+ {==}
3388
+ case C.SNatIn{lo_, hi_} n:
3389
+ {==}
3390
+ case C.SStr{} n:
3391
+ {==}
3392
+ case C.SBool{} bb:
3393
+ {==}
3394
+ case C.STrue{} Unit{}:
3395
+ {==}
3396
+ case C.SEnum{ns} e:
3397
+ {==}
3398
+ case C.SEnd{} Unit{}:
3399
+ {==}
3400
+ case C.STEnd{} Unit{}:
3401
+ {==}
3402
+ case C.SVEnd{} e:
3403
+ Empty.absurd({C.key_once_at(C.enc(C.SVEnd{}, e), b, k) == True{} : Bool}, e)
3404
+ case C.STagEnd{k2} e:
3405
+ Empty.absurd({C.key_once_at(C.enc(C.STagEnd{k2}, e), b, k) == True{} : Bool}, e)
3406
+ case C.SList{e} Nil{}:
3407
+ {==}
3408
+ case C.SList{e} +hh <> +tt:
3409
+ {==}
3410
+ case C.STuple{ts, rs} C.Both{aa, bb}:
3411
+ {==}
3412
+ case C.SStrLen{lo_, hi_, s2} v:
3413
+ no_key_once(k, s2, v, b, h)
3414
+ case C.SListLen{lo_, hi_, s2} v:
3415
+ no_key_once(k, s2, v, b, h)
3416
+ case C.SRule{s2, tag} v:
3417
+ no_key_once(k, s2, v, b, h)
3418
+ case C.SStrict{s2} v:
3419
+ no_key_once(k, s2, v, b, h)
3420
+ case C.SOpt{i} None{}:
3421
+ {==}
3422
+ case C.SOpt{i} Some{v}:
3423
+ no_key_once(k, i, v, b, h)
3424
+ case C.SOptional{i} None{}:
3425
+ {==}
3426
+ case C.SOptional{i} Some{v}:
3427
+ no_key_once(k, i, v, b, h)
3428
+ case C.SField{+n, fs, +rest} C.Both{a, +b2}:
3429
+ key_step(b, n, k, rest, b2, not_true(String.eq(n, k), and_l(Bool.not(String.eq(n, k)), Bool.and(Bool.not(String.eq(k, n)), C.no_key(k, rest)), h)), no_key_once(k, rest, b2, True{}, and_r(Bool.not(String.eq(k, n)), C.no_key(k, rest), and_r(Bool.not(String.eq(n, k)), Bool.and(Bool.not(String.eq(k, n)), C.no_key(k, rest)), h))), no_key_once(k, rest, b2, False{}, and_r(Bool.not(String.eq(k, n)), C.no_key(k, rest), and_r(Bool.not(String.eq(n, k)), Bool.and(Bool.not(String.eq(k, n)), C.no_key(k, rest)), h))))
3430
+ case C.SVariant{n, vs, rest} Inl{a}:
3431
+ key_step(b, n, k, C.SEnd{}, Unit{}, not_true(String.eq(n, k), and_l(Bool.not(String.eq(n, k)), Bool.and(Bool.not(String.eq(k, n)), C.no_key(k, rest)), h)), {==}, {==})
3432
+ case C.SVariant{+n, vs, +rest} Inr{b2}:
3433
+ no_key_once(k, rest, b2, b, and_r(Bool.not(String.eq(k, n)), C.no_key(k, rest), and_r(Bool.not(String.eq(n, k)), Bool.and(Bool.not(String.eq(k, n)), C.no_key(k, rest)), h)))
3434
+ case C.STagged{+k2, n2, +cs2, +rest2} Inl{+a}:
3435
+ key_step(b, k2, k, cs2, a, not_true(String.eq(k2, k), and_l(Bool.not(String.eq(k2, k)), Bool.and(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2))), h)), no_key_once(k, cs2, a, True{}, and_l(C.no_key(k, cs2), C.no_key(k, rest2), and_r(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2)), and_r(Bool.not(String.eq(k2, k)), Bool.and(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2))), h)))), no_key_once(k, cs2, a, False{}, and_l(C.no_key(k, cs2), C.no_key(k, rest2), and_r(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2)), and_r(Bool.not(String.eq(k2, k)), Bool.and(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2))), h)))))
3436
+ case C.STagged{+k2, n2, +cs2, +rest2} Inr{b2}:
3437
+ no_key_once(k, rest2, b2, b, and_r(C.no_key(k, cs2), C.no_key(k, rest2), and_r(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2)), and_r(Bool.not(String.eq(k2, k)), Bool.and(Bool.not(String.eq(k, k2)), Bool.and(C.no_key(k, cs2), C.no_key(k, rest2))), h))))
3438
+
3439
+ # ---- what is written is accepted ----
3440
+
3441
+ # enc writes an object for a record chain and for a variant chain.
3442
+ def obj_f(+n: String, s: C.Schema, x: C.Meaning(s), +hf: {C.fresh_f(n, s) == True{} : Bool}) -> {C.is_object(C.enc(s, x)) == True{} : Bool}:
3443
+ match s x:
3444
+ case C.SBool{} v:
3445
+ Empty.absurd({C.is_object(C.enc(C.SBool{}, v)) == True{} : Bool}, to_empty(hf))
3446
+ case C.SNatIn{lo_, hi_} v:
3447
+ Empty.absurd({C.is_object(C.enc(C.SNatIn{lo_, hi_}, v)) == True{} : Bool}, to_empty(hf))
3448
+ case C.SStrLen{lo_, hi_, s2} v:
3449
+ Empty.absurd({C.is_object(C.enc(C.SStrLen{lo_, hi_, s2}, v)) == True{} : Bool}, to_empty(hf))
3450
+ case C.SNat{} v:
3451
+ Empty.absurd({C.is_object(C.enc(C.SNat{}, v)) == True{} : Bool}, to_empty(hf))
3452
+ case C.SStr{} v:
3453
+ Empty.absurd({C.is_object(C.enc(C.SStr{}, v)) == True{} : Bool}, to_empty(hf))
3454
+ case C.SOpt{i_} v:
3455
+ Empty.absurd({C.is_object(C.enc(C.SOpt{i_}, v)) == True{} : Bool}, to_empty(hf))
3456
+ case C.SList{e_} v:
3457
+ Empty.absurd({C.is_object(C.enc(C.SList{e_}, v)) == True{} : Bool}, to_empty(hf))
3458
+ case C.SField{k, fs, rest} C.Both{a, b}:
3459
+ {==}
3460
+ case C.SEnd{} Unit{}:
3461
+ {==}
3462
+ case C.SRule{s2_, tag_} v:
3463
+ Empty.absurd({C.is_object(C.enc(C.SRule{s2_, tag_}, v)) == True{} : Bool}, to_empty(hf))
3464
+ case C.SStrict{s2_} v:
3465
+ Empty.absurd({C.is_object(C.enc(C.SStrict{s2_}, v)) == True{} : Bool}, to_empty(hf))
3466
+ case C.STagged{k_, n_, cs_, rest_} v:
3467
+ Empty.absurd({C.is_object(C.enc(C.STagged{k_, n_, cs_, rest_}, v)) == True{} : Bool}, to_empty(hf))
3468
+ case C.STagEnd{k_} v:
3469
+ Empty.absurd({C.is_object(C.enc(C.STagEnd{k_}, v)) == True{} : Bool}, to_empty(hf))
3470
+ case C.STrue{} v:
3471
+ Empty.absurd({C.is_object(C.enc(C.STrue{}, v)) == True{} : Bool}, to_empty(hf))
3472
+ case C.SEnum{names_} v:
3473
+ Empty.absurd({C.is_object(C.enc(C.SEnum{names_}, v)) == True{} : Bool}, to_empty(hf))
3474
+ case C.SVariant{k_, vs_, rest_} v:
3475
+ Empty.absurd({C.is_object(C.enc(C.SVariant{k_, vs_, rest_}, v)) == True{} : Bool}, to_empty(hf))
3476
+ case C.SVEnd{} e:
3477
+ Empty.absurd({C.is_object(C.enc(C.SVEnd{}, e)) == True{} : Bool}, e)
3478
+ case C.STuple{ts_, rest_} v:
3479
+ Empty.absurd({C.is_object(C.enc(C.STuple{ts_, rest_}, v)) == True{} : Bool}, to_empty(hf))
3480
+ case C.STEnd{} v:
3481
+ Empty.absurd({C.is_object(C.enc(C.STEnd{}, v)) == True{} : Bool}, to_empty(hf))
3482
+ case C.SOptional{i_} v:
3483
+ Empty.absurd({C.is_object(C.enc(C.SOptional{i_}, v)) == True{} : Bool}, to_empty(hf))
3484
+ case C.SListLen{lo_, hi_, s2_} v:
3485
+ Empty.absurd({C.is_object(C.enc(C.SListLen{lo_, hi_, s2_}, v)) == True{} : Bool}, to_empty(hf))
3486
+
3487
+ def obj_v(+n: String, s: C.Schema, x: C.Meaning(s), +hf: {C.fresh_v(n, s) == True{} : Bool}) -> {C.is_object(C.enc(s, x)) == True{} : Bool}:
3488
+ match s x:
3489
+ case C.SBool{} v:
3490
+ Empty.absurd({C.is_object(C.enc(C.SBool{}, v)) == True{} : Bool}, to_empty(hf))
3491
+ case C.SNatIn{lo_, hi_} v:
3492
+ Empty.absurd({C.is_object(C.enc(C.SNatIn{lo_, hi_}, v)) == True{} : Bool}, to_empty(hf))
3493
+ case C.SStrLen{lo_, hi_, s2} v:
3494
+ Empty.absurd({C.is_object(C.enc(C.SStrLen{lo_, hi_, s2}, v)) == True{} : Bool}, to_empty(hf))
3495
+ case C.SNat{} v:
3496
+ Empty.absurd({C.is_object(C.enc(C.SNat{}, v)) == True{} : Bool}, to_empty(hf))
3497
+ case C.SStr{} v:
3498
+ Empty.absurd({C.is_object(C.enc(C.SStr{}, v)) == True{} : Bool}, to_empty(hf))
3499
+ case C.SOpt{i_} v:
3500
+ Empty.absurd({C.is_object(C.enc(C.SOpt{i_}, v)) == True{} : Bool}, to_empty(hf))
3501
+ case C.SList{e_} v:
3502
+ Empty.absurd({C.is_object(C.enc(C.SList{e_}, v)) == True{} : Bool}, to_empty(hf))
3503
+ case C.SField{k_, fs_, rest_} v:
3504
+ Empty.absurd({C.is_object(C.enc(C.SField{k_, fs_, rest_}, v)) == True{} : Bool}, to_empty(hf))
3505
+ case C.SEnd{} v:
3506
+ Empty.absurd({C.is_object(C.enc(C.SEnd{}, v)) == True{} : Bool}, to_empty(hf))
3507
+ case C.SRule{s2_, tag_} v:
3508
+ Empty.absurd({C.is_object(C.enc(C.SRule{s2_, tag_}, v)) == True{} : Bool}, to_empty(hf))
3509
+ case C.SStrict{s2_} v:
3510
+ Empty.absurd({C.is_object(C.enc(C.SStrict{s2_}, v)) == True{} : Bool}, to_empty(hf))
3511
+ case C.STagged{k_, n_, cs_, rest_} v:
3512
+ Empty.absurd({C.is_object(C.enc(C.STagged{k_, n_, cs_, rest_}, v)) == True{} : Bool}, to_empty(hf))
3513
+ case C.STagEnd{k_} v:
3514
+ Empty.absurd({C.is_object(C.enc(C.STagEnd{k_}, v)) == True{} : Bool}, to_empty(hf))
3515
+ case C.STrue{} v:
3516
+ Empty.absurd({C.is_object(C.enc(C.STrue{}, v)) == True{} : Bool}, to_empty(hf))
3517
+ case C.SEnum{names_} v:
3518
+ Empty.absurd({C.is_object(C.enc(C.SEnum{names_}, v)) == True{} : Bool}, to_empty(hf))
3519
+ case C.SVariant{k, vs, rest} Inl{a}:
3520
+ {==}
3521
+ case C.SVariant{+k, vs, +rest} Inr{b}:
3522
+ obj_v(n, rest, b, and_r(Bool.not(String.eq(n, k)), C.fresh_v(n, rest), and_r(Bool.not(String.eq(k, n)), Bool.and(Bool.not(String.eq(n, k)), C.fresh_v(n, rest)), hf)))
3523
+ case C.SVEnd{} e:
3524
+ Empty.absurd({C.is_object(C.enc(C.SVEnd{}, e)) == True{} : Bool}, e)
3525
+ case C.STuple{ts_, rest_} v:
3526
+ Empty.absurd({C.is_object(C.enc(C.STuple{ts_, rest_}, v)) == True{} : Bool}, to_empty(hf))
3527
+ case C.STEnd{} v:
3528
+ Empty.absurd({C.is_object(C.enc(C.STEnd{}, v)) == True{} : Bool}, to_empty(hf))
3529
+ case C.SOptional{i_} v:
3530
+ Empty.absurd({C.is_object(C.enc(C.SOptional{i_}, v)) == True{} : Bool}, to_empty(hf))
3531
+ case C.SListLen{lo_, hi_, s2_} v:
3532
+ Empty.absurd({C.is_object(C.enc(C.SListLen{lo_, hi_, s2_}, v)) == True{} : Bool}, to_empty(hf))
3533
+
3534
+ # No variant of a well-formed chain is in an object holding one other key.
3535
+ def np(+n: String, s: C.Schema, +v: C.Raw, +hf: {C.fresh_v(n, s) == True{} : Bool}) -> {C.none_present(s, C.RKey{n, v, C.REnd{}}) == True{} : Bool}:
3536
+ match s:
3537
+ case C.SVariant{+m, vs, +rest}:
3538
+ %not_true(String.eq(n, m), and_l(Bool.not(String.eq(n, m)), C.fresh_v(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_v(n, rest)), hf))) : {Bool.and(C.is_missing(C.pick_raw(_, v, C.lookup(m, C.REnd{}))), C.none_present(rest, C.RKey{n, v, C.REnd{}})) == True{} : Bool}
3539
+ np(n, rest, v, and_r(Bool.not(String.eq(n, m)), C.fresh_v(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_v(n, rest)), hf)))
3540
+ case C.SNat{}:
3541
+ {==}
3542
+ case C.SNatIn{lo_, hi_}:
3543
+ {==}
3544
+ case C.SBool{}:
3545
+ {==}
3546
+ case C.SStrLen{lo_, hi_, s2_}:
3547
+ {==}
3548
+ case C.SStr{}:
3549
+ {==}
3550
+ case C.SOpt{i_}:
3551
+ {==}
3552
+ case C.SList{e_}:
3553
+ {==}
3554
+ case C.SField{k_, fs_, rest_}:
3555
+ {==}
3556
+ case C.SEnd{}:
3557
+ {==}
3558
+ case C.SRule{s2_, tag_}:
3559
+ {==}
3560
+ case C.SStrict{s2_}:
3561
+ {==}
3562
+ case C.STagged{k_, n_, cs_, rest_}:
3563
+ {==}
3564
+ case C.STagEnd{k_}:
3565
+ {==}
3566
+ case C.STrue{}:
3567
+ {==}
3568
+ case C.SEnum{names_}:
3569
+ {==}
3570
+ case C.SVEnd{}:
3571
+ {==}
3572
+ case C.SOptional{i_}:
3573
+ {==}
3574
+ case C.SListLen{lo_, hi_, s2_}:
3575
+ {==}
3576
+ case C.STuple{ts_, rest_}:
3577
+ {==}
3578
+ case C.STEnd{}:
3579
+ {==}
3580
+
3581
+ # n is not a key of what enc writes for the record chain s: enc writes the
3582
+ # chain's own keys and nothing else, and the chain names none of them n. The
3583
+ # key test is read with its flag already set -- the read that set it is the
3584
+ # schema's own first key, and this says the walk past it never reads n again.
3585
+ def key_once_enc(+n: String, s: C.Schema, x: C.Meaning(s), +hf: {C.fresh_f(n, s) == True{} : Bool}) -> {True{} == C.key_once_at(C.enc(s, x), True{}, n) : Bool}:
3586
+ match s x:
3587
+ case C.SBool{} v:
3588
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SBool{}, v), True{}, n) : Bool}, to_empty(hf))
3589
+ case C.SNatIn{lo_, hi_} v:
3590
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SNatIn{lo_, hi_}, v), True{}, n) : Bool}, to_empty(hf))
3591
+ case C.SStrLen{lo_, hi_, s2} v:
3592
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SStrLen{lo_, hi_, s2}, v), True{}, n) : Bool}, to_empty(hf))
3593
+ case C.SNat{} v:
3594
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SNat{}, v), True{}, n) : Bool}, to_empty(hf))
3595
+ case C.SStr{} v:
3596
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SStr{}, v), True{}, n) : Bool}, to_empty(hf))
3597
+ case C.SOpt{i_} v:
3598
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SOpt{i_}, v), True{}, n) : Bool}, to_empty(hf))
3599
+ case C.SList{e_} v:
3600
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SList{e_}, v), True{}, n) : Bool}, to_empty(hf))
3601
+ case C.SField{+m, +fs, +rest} C.Both{+a, +b}:
3602
+ %not_true(String.eq(m, n), and_l(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)) : {True{} == Bool.and(Bool.not(_), C.key_once_at(C.enc(rest, b), True{}, n)) : Bool}
3603
+ key_once_enc(n, rest, b, and_r(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)))
3604
+ case C.SEnd{} Unit{}:
3605
+ {==}
3606
+ case C.SRule{s2_, tag_} v:
3607
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SRule{s2_, tag_}, v), True{}, n) : Bool}, to_empty(hf))
3608
+ case C.SStrict{s2_} v:
3609
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SStrict{s2_}, v), True{}, n) : Bool}, to_empty(hf))
3610
+ case C.STagged{k_, n_, cs_, rest_} v:
3611
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.STagged{k_, n_, cs_, rest_}, v), True{}, n) : Bool}, to_empty(hf))
3612
+ case C.STagEnd{k_} v:
3613
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.STagEnd{k_}, v), True{}, n) : Bool}, to_empty(hf))
3614
+ case C.STrue{} v:
3615
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.STrue{}, v), True{}, n) : Bool}, to_empty(hf))
3616
+ case C.SEnum{names_} v:
3617
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SEnum{names_}, v), True{}, n) : Bool}, to_empty(hf))
3618
+ case C.SVariant{k_, vs_, rest_} v:
3619
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SVariant{k_, vs_, rest_}, v), True{}, n) : Bool}, to_empty(hf))
3620
+ case C.SVEnd{} e:
3621
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SVEnd{}, e), True{}, n) : Bool}, e)
3622
+ case C.STuple{ts_, rest_} v:
3623
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.STuple{ts_, rest_}, v), True{}, n) : Bool}, to_empty(hf))
3624
+ case C.STEnd{} v:
3625
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.STEnd{}, v), True{}, n) : Bool}, to_empty(hf))
3626
+ case C.SOptional{i_} v:
3627
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SOptional{i_}, v), True{}, n) : Bool}, to_empty(hf))
3628
+ case C.SListLen{lo_, hi_, s2_} v:
3629
+ Empty.absurd({True{} == C.key_once_at(C.enc(C.SListLen{lo_, hi_, s2_}, v), True{}, n) : Bool}, to_empty(hf))
3630
+
3631
+ # A present value of an optional schema conforms as its inner schema does.
3632
+ def opt_conf(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, i: C.Schema, r: C.Raw, +hn: {False{} == C.nullish(r) : Bool}) -> {C.conforms(~rule, i, r, None{}) == C.conforms(~rule, C.SOpt{i}, r, None{}) : Bool}:
3633
+ match r:
3634
+ case C.RNull{}:
3635
+ Empty.absurd({C.conforms(~rule, i, C.RNull{}, None{}) == C.conforms(~rule, C.SOpt{i}, C.RNull{}, None{}) : Bool}, to_empty(hn))
3636
+ case C.RMissing{}:
3637
+ Empty.absurd({C.conforms(~rule, i, C.RMissing{}, None{}) == C.conforms(~rule, C.SOpt{i}, C.RMissing{}, None{}) : Bool}, to_empty(hn))
3638
+ case C.RNum{n}:
3639
+ {==}
3640
+ case C.RBool{b}:
3641
+ {==}
3642
+ case C.RStr{s}:
3643
+ {==}
3644
+ case C.RBad{}:
3645
+ {==}
3646
+ case C.RTooBig{}:
3647
+ {==}
3648
+ case C.RNil{}:
3649
+ {==}
3650
+ case C.RCons{h, t}:
3651
+ {==}
3652
+ case C.REnd{}:
3653
+ {==}
3654
+ case C.RKey{k, w, o}:
3655
+ {==}
3656
+
3657
+ # A variant chain reads past its first variant when that key is absent.
3658
+ def var_skip(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, +n: String, +vs: C.Schema, +rest: C.Schema, r: C.Raw, +ho: {C.is_object(r) == True{} : Bool}, +hm: {True{} == C.is_missing(C.lookup(n, r)) : Bool}) -> {C.conforms(~rule, rest, r, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, r, None{}) : Bool}:
3659
+ match r:
3660
+ case C.REnd{}:
3661
+ {==}
3662
+ case C.RKey{+k, +w, +o}:
3663
+ %hm : {C.conforms(~rule, rest, C.RKey{k, w, o}, None{}) == C.pick_bool(_, C.conforms(~rule, rest, C.RKey{k, w, o}, None{}), Bool.and(C.key_once(n, C.RKey{k, w, o}), Bool.and(C.conforms(~rule, vs, C.lookup(n, C.RKey{k, w, o}), None{}), C.none_present(rest, C.RKey{k, w, o})))) : Bool}
3664
+ {==}
3665
+ case C.RNum{n_}:
3666
+ Empty.absurd({C.conforms(~rule, rest, C.RNum{n_}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RNum{n_}, None{}) : Bool}, to_empty(ho))
3667
+ case C.RBool{b_}:
3668
+ Empty.absurd({C.conforms(~rule, rest, C.RBool{b_}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RBool{b_}, None{}) : Bool}, to_empty(ho))
3669
+ case C.RNull{}:
3670
+ Empty.absurd({C.conforms(~rule, rest, C.RNull{}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RNull{}, None{}) : Bool}, to_empty(ho))
3671
+ case C.RStr{s_}:
3672
+ Empty.absurd({C.conforms(~rule, rest, C.RStr{s_}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RStr{s_}, None{}) : Bool}, to_empty(ho))
3673
+ case C.RBad{}:
3674
+ Empty.absurd({C.conforms(~rule, rest, C.RBad{}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RBad{}, None{}) : Bool}, to_empty(ho))
3675
+ case C.RTooBig{}:
3676
+ Empty.absurd({C.conforms(~rule, rest, C.RTooBig{}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RTooBig{}, None{}) : Bool}, to_empty(ho))
3677
+ case C.RMissing{}:
3678
+ Empty.absurd({C.conforms(~rule, rest, C.RMissing{}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RMissing{}, None{}) : Bool}, to_empty(ho))
3679
+ case C.RNil{}:
3680
+ Empty.absurd({C.conforms(~rule, rest, C.RNil{}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RNil{}, None{}) : Bool}, to_empty(ho))
3681
+ case C.RCons{h_, t_}:
3682
+ Empty.absurd({C.conforms(~rule, rest, C.RCons{h_, t_}, None{}) == C.conforms(~rule, C.SVariant{n, vs, rest}, C.RCons{h_, t_}, None{}) : Bool}, to_empty(ho))
3683
+
3684
+ # A record chain ignores a key it does not name.
3685
+ # arms: s o
3686
+ # arms leaf: Empty.absurd({C.conforms(~rule, $S, $R, None{}) == C.conforms(~rule, $S, C.RKey{n, v, $R}, None{}) : Bool}, to_empty($W))
3687
+ # arms why: RNum=ho RBool=ho RNull=ho RStr=ho RBad=ho RTooBig=ho RMissing=ho RNil=ho RCons=ho SNat=hf SStr=hf SOpt=hf SList=hf SRule=hf SStrict=hf SBool=hf SNatIn=hf SStrLen=hf STagged=hf STagEnd=hf STrue=hf SEnum=hf SVariant=hf SVEnd=hf STuple=hf STEnd=hf SOptional=hf SListLen=hf
3688
+ def skip_c(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, +n: String, s: C.Schema, +v: C.Raw, o: C.Raw, +hf: {C.fresh_f(n, s) == True{} : Bool}, +ho: {C.is_object(o) == True{} : Bool}) -> {C.conforms(~rule, s, o, None{}) == C.conforms(~rule, s, C.RKey{n, v, o}, None{}) : Bool}:
3689
+ match s o:
3690
+ case C.SNat{} C.RNum{n__}:
3691
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3692
+ case C.SNat{} C.RBool{b__}:
3693
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3694
+ case C.SNat{} C.RNull{}:
3695
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RNull{}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3696
+ case C.SNat{} C.RStr{s__}:
3697
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3698
+ case C.SNat{} C.RBad{}:
3699
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RBad{}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3700
+ case C.SNat{} C.RTooBig{}:
3701
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3702
+ case C.SNat{} C.RMissing{}:
3703
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RMissing{}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3704
+ case C.SNat{} C.RNil{}:
3705
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RNil{}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3706
+ case C.SNat{} C.RCons{head__, tail__}:
3707
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3708
+ case C.SNat{} C.REnd{}:
3709
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.REnd{}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3710
+ case C.SNat{} C.RKey{+k, +w, +o2}:
3711
+ Empty.absurd({C.conforms(~rule, C.SNat{}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SNat{}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3712
+ case C.SNatIn{lo_, hi_} C.RNum{n__}:
3713
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3714
+ case C.SNatIn{lo_, hi_} C.RBool{b__}:
3715
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3716
+ case C.SNatIn{lo_, hi_} C.RNull{}:
3717
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RNull{}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3718
+ case C.SNatIn{lo_, hi_} C.RStr{s__}:
3719
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3720
+ case C.SNatIn{lo_, hi_} C.RBad{}:
3721
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RBad{}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3722
+ case C.SNatIn{lo_, hi_} C.RTooBig{}:
3723
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3724
+ case C.SNatIn{lo_, hi_} C.RMissing{}:
3725
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3726
+ case C.SNatIn{lo_, hi_} C.RNil{}:
3727
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RNil{}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3728
+ case C.SNatIn{lo_, hi_} C.RCons{head__, tail__}:
3729
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3730
+ case C.SNatIn{lo_, hi_} C.REnd{}:
3731
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.REnd{}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3732
+ case C.SNatIn{lo_, hi_} C.RKey{+k, +w, +o2}:
3733
+ Empty.absurd({C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SNatIn{lo_, hi_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3734
+ case C.SStr{} C.RNum{n__}:
3735
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3736
+ case C.SStr{} C.RBool{b__}:
3737
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3738
+ case C.SStr{} C.RNull{}:
3739
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RNull{}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3740
+ case C.SStr{} C.RStr{s__}:
3741
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3742
+ case C.SStr{} C.RBad{}:
3743
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RBad{}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3744
+ case C.SStr{} C.RTooBig{}:
3745
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3746
+ case C.SStr{} C.RMissing{}:
3747
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RMissing{}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3748
+ case C.SStr{} C.RNil{}:
3749
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RNil{}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3750
+ case C.SStr{} C.RCons{head__, tail__}:
3751
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3752
+ case C.SStr{} C.REnd{}:
3753
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.REnd{}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3754
+ case C.SStr{} C.RKey{+k, +w, +o2}:
3755
+ Empty.absurd({C.conforms(~rule, C.SStr{}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SStr{}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3756
+ case C.SStrLen{lo_, hi_, s_} C.RNum{n__}:
3757
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3758
+ case C.SStrLen{lo_, hi_, s_} C.RBool{b__}:
3759
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3760
+ case C.SStrLen{lo_, hi_, s_} C.RNull{}:
3761
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RNull{}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3762
+ case C.SStrLen{lo_, hi_, s_} C.RStr{s__}:
3763
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3764
+ case C.SStrLen{lo_, hi_, s_} C.RBad{}:
3765
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RBad{}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3766
+ case C.SStrLen{lo_, hi_, s_} C.RTooBig{}:
3767
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3768
+ case C.SStrLen{lo_, hi_, s_} C.RMissing{}:
3769
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3770
+ case C.SStrLen{lo_, hi_, s_} C.RNil{}:
3771
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RNil{}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3772
+ case C.SStrLen{lo_, hi_, s_} C.RCons{head__, tail__}:
3773
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3774
+ case C.SStrLen{lo_, hi_, s_} C.REnd{}:
3775
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.REnd{}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3776
+ case C.SStrLen{lo_, hi_, s_} C.RKey{+k, +w, +o2}:
3777
+ Empty.absurd({C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SStrLen{lo_, hi_, s_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3778
+ case C.SOpt{inner_} C.RNum{n__}:
3779
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3780
+ case C.SOpt{inner_} C.RBool{b__}:
3781
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3782
+ case C.SOpt{inner_} C.RNull{}:
3783
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RNull{}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3784
+ case C.SOpt{inner_} C.RStr{s__}:
3785
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3786
+ case C.SOpt{inner_} C.RBad{}:
3787
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RBad{}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3788
+ case C.SOpt{inner_} C.RTooBig{}:
3789
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3790
+ case C.SOpt{inner_} C.RMissing{}:
3791
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3792
+ case C.SOpt{inner_} C.RNil{}:
3793
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RNil{}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3794
+ case C.SOpt{inner_} C.RCons{head__, tail__}:
3795
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3796
+ case C.SOpt{inner_} C.REnd{}:
3797
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.REnd{}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3798
+ case C.SOpt{inner_} C.RKey{+k, +w, +o2}:
3799
+ Empty.absurd({C.conforms(~rule, C.SOpt{inner_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SOpt{inner_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3800
+ case C.SList{elem_} C.RNum{n__}:
3801
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3802
+ case C.SList{elem_} C.RBool{b__}:
3803
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3804
+ case C.SList{elem_} C.RNull{}:
3805
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RNull{}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3806
+ case C.SList{elem_} C.RStr{s__}:
3807
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3808
+ case C.SList{elem_} C.RBad{}:
3809
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RBad{}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3810
+ case C.SList{elem_} C.RTooBig{}:
3811
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3812
+ case C.SList{elem_} C.RMissing{}:
3813
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3814
+ case C.SList{elem_} C.RNil{}:
3815
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RNil{}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3816
+ case C.SList{elem_} C.RCons{head__, tail__}:
3817
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3818
+ case C.SList{elem_} C.REnd{}:
3819
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.REnd{}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3820
+ case C.SList{elem_} C.RKey{+k, +w, +o2}:
3821
+ Empty.absurd({C.conforms(~rule, C.SList{elem_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SList{elem_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3822
+ case C.SField{+m, +fs, +rest} C.RNum{n__}:
3823
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3824
+ case C.SField{+m, +fs, +rest} C.RBool{b__}:
3825
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3826
+ case C.SField{+m, +fs, +rest} C.RNull{}:
3827
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RNull{}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3828
+ case C.SField{+m, +fs, +rest} C.RStr{s__}:
3829
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3830
+ case C.SField{+m, +fs, +rest} C.RBad{}:
3831
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RBad{}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3832
+ case C.SField{+m, +fs, +rest} C.RTooBig{}:
3833
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3834
+ case C.SField{+m, +fs, +rest} C.RMissing{}:
3835
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RMissing{}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3836
+ case C.SField{+m, +fs, +rest} C.RNil{}:
3837
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RNil{}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3838
+ case C.SField{+m, +fs, +rest} C.RCons{head__, tail__}:
3839
+ Empty.absurd({C.conforms(~rule, C.SField{m, fs, rest}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SField{m, fs, rest}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3840
+ case C.SField{+m, +fs, +rest} C.REnd{}:
3841
+ %lk_skip(n, m, v, C.REnd{}, not_true(String.eq(n, m), and_l(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)))) : {Bool.and(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{})) == Bool.and(C.conforms(~rule, fs, _, None{}), C.conforms(~rule, rest, C.RKey{n, v, C.REnd{}}, None{})) : Bool}
3842
+ %skip_c(~rule, n, rest, v, C.REnd{}, and_r(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)), {==}) : {Bool.and(C.conforms(~rule, fs, C.RMissing{}, None{}), C.conforms(~rule, rest, C.REnd{}, None{})) == Bool.and(C.conforms(~rule, fs, C.RMissing{}, None{}), _) : Bool}
3843
+ {==}
3844
+ case C.SField{+m, +fs, +rest} C.RKey{+k, +w, +o2}:
3845
+ %kc_skip(n, m, v, C.RKey{k, w, o2}, not_true(String.eq(n, m), and_l(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)))) : {Bool.and(C.key_once(m, C.RKey{k, w, o2}), Bool.and(C.conforms(~rule, fs, C.lookup(m, C.RKey{k, w, o2}), None{}), C.conforms(~rule, rest, C.RKey{k, w, o2}, None{}))) == Bool.and(_, Bool.and(C.conforms(~rule, fs, C.lookup(m, C.RKey{n, v, C.RKey{k, w, o2}}), None{}), C.conforms(~rule, rest, C.RKey{n, v, C.RKey{k, w, o2}}, None{}))) : Bool}
3846
+ %lk_skip(n, m, v, C.RKey{k, w, o2}, not_true(String.eq(n, m), and_l(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)))) : {Bool.and(C.key_once(m, C.RKey{k, w, o2}), Bool.and(C.conforms(~rule, fs, C.lookup(m, C.RKey{k, w, o2}), None{}), C.conforms(~rule, rest, C.RKey{k, w, o2}, None{}))) == Bool.and(C.key_once(m, C.RKey{k, w, o2}), Bool.and(C.conforms(~rule, fs, _, None{}), C.conforms(~rule, rest, C.RKey{n, v, C.RKey{k, w, o2}}, None{}))) : Bool}
3847
+ %skip_c(~rule, n, rest, v, C.RKey{k, w, o2}, and_r(Bool.not(String.eq(n, m)), C.fresh_f(n, rest), and_r(Bool.not(String.eq(m, n)), Bool.and(Bool.not(String.eq(n, m)), C.fresh_f(n, rest)), hf)), {==}) : {Bool.and(C.key_once(m, C.RKey{k, w, o2}), Bool.and(C.conforms(~rule, fs, C.lookup(m, C.RKey{k, w, o2}), None{}), C.conforms(~rule, rest, C.RKey{k, w, o2}, None{}))) == Bool.and(C.key_once(m, C.RKey{k, w, o2}), Bool.and(C.conforms(~rule, fs, C.lookup(m, C.RKey{k, w, o2}), None{}), _)) : Bool}
3848
+ {==}
3849
+ case C.SEnd{} C.RNum{n__}:
3850
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3851
+ case C.SEnd{} C.RBool{b__}:
3852
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3853
+ case C.SEnd{} C.RNull{}:
3854
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RNull{}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3855
+ case C.SEnd{} C.RStr{s__}:
3856
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3857
+ case C.SEnd{} C.RBad{}:
3858
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RBad{}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3859
+ case C.SEnd{} C.RTooBig{}:
3860
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3861
+ case C.SEnd{} C.RMissing{}:
3862
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RMissing{}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3863
+ case C.SEnd{} C.RNil{}:
3864
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RNil{}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3865
+ case C.SEnd{} C.RCons{head__, tail__}:
3866
+ Empty.absurd({C.conforms(~rule, C.SEnd{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SEnd{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3867
+ case C.SEnd{} C.REnd{}:
3868
+ {==}
3869
+ case C.SEnd{} C.RKey{+k, +w, +o2}:
3870
+ {==}
3871
+ case C.SRule{s_, tag_} C.RNum{n__}:
3872
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3873
+ case C.SRule{s_, tag_} C.RBool{b__}:
3874
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3875
+ case C.SRule{s_, tag_} C.RNull{}:
3876
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RNull{}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3877
+ case C.SRule{s_, tag_} C.RStr{s__}:
3878
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3879
+ case C.SRule{s_, tag_} C.RBad{}:
3880
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RBad{}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3881
+ case C.SRule{s_, tag_} C.RTooBig{}:
3882
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3883
+ case C.SRule{s_, tag_} C.RMissing{}:
3884
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3885
+ case C.SRule{s_, tag_} C.RNil{}:
3886
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RNil{}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3887
+ case C.SRule{s_, tag_} C.RCons{head__, tail__}:
3888
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3889
+ case C.SRule{s_, tag_} C.REnd{}:
3890
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.REnd{}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3891
+ case C.SRule{s_, tag_} C.RKey{+k, +w, +o2}:
3892
+ Empty.absurd({C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SRule{s_, tag_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3893
+ case C.SStrict{s_} C.RNum{n__}:
3894
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3895
+ case C.SStrict{s_} C.RBool{b__}:
3896
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3897
+ case C.SStrict{s_} C.RNull{}:
3898
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RNull{}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3899
+ case C.SStrict{s_} C.RStr{s__}:
3900
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3901
+ case C.SStrict{s_} C.RBad{}:
3902
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RBad{}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3903
+ case C.SStrict{s_} C.RTooBig{}:
3904
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3905
+ case C.SStrict{s_} C.RMissing{}:
3906
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3907
+ case C.SStrict{s_} C.RNil{}:
3908
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RNil{}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3909
+ case C.SStrict{s_} C.RCons{head__, tail__}:
3910
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3911
+ case C.SStrict{s_} C.REnd{}:
3912
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.REnd{}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3913
+ case C.SStrict{s_} C.RKey{+k, +w, +o2}:
3914
+ Empty.absurd({C.conforms(~rule, C.SStrict{s_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SStrict{s_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3915
+ case C.STagged{key_, name_, s_, rest_} C.RNum{n__}:
3916
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3917
+ case C.STagged{key_, name_, s_, rest_} C.RBool{b__}:
3918
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3919
+ case C.STagged{key_, name_, s_, rest_} C.RNull{}:
3920
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RNull{}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3921
+ case C.STagged{key_, name_, s_, rest_} C.RStr{s__}:
3922
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3923
+ case C.STagged{key_, name_, s_, rest_} C.RBad{}:
3924
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RBad{}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3925
+ case C.STagged{key_, name_, s_, rest_} C.RTooBig{}:
3926
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3927
+ case C.STagged{key_, name_, s_, rest_} C.RMissing{}:
3928
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RMissing{}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3929
+ case C.STagged{key_, name_, s_, rest_} C.RNil{}:
3930
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RNil{}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3931
+ case C.STagged{key_, name_, s_, rest_} C.RCons{head__, tail__}:
3932
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3933
+ case C.STagged{key_, name_, s_, rest_} C.REnd{}:
3934
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.REnd{}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3935
+ case C.STagged{key_, name_, s_, rest_} C.RKey{+k, +w, +o2}:
3936
+ Empty.absurd({C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.STagged{key_, name_, s_, rest_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3937
+ case C.STagEnd{key_} C.RNum{n__}:
3938
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3939
+ case C.STagEnd{key_} C.RBool{b__}:
3940
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3941
+ case C.STagEnd{key_} C.RNull{}:
3942
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RNull{}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3943
+ case C.STagEnd{key_} C.RStr{s__}:
3944
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3945
+ case C.STagEnd{key_} C.RBad{}:
3946
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RBad{}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3947
+ case C.STagEnd{key_} C.RTooBig{}:
3948
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3949
+ case C.STagEnd{key_} C.RMissing{}:
3950
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RMissing{}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3951
+ case C.STagEnd{key_} C.RNil{}:
3952
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RNil{}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3953
+ case C.STagEnd{key_} C.RCons{head__, tail__}:
3954
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3955
+ case C.STagEnd{key_} C.REnd{}:
3956
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.REnd{}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3957
+ case C.STagEnd{key_} C.RKey{+k, +w, +o2}:
3958
+ Empty.absurd({C.conforms(~rule, C.STagEnd{key_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.STagEnd{key_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3959
+ case C.SBool{} C.RNum{n__}:
3960
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3961
+ case C.SBool{} C.RBool{b__}:
3962
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3963
+ case C.SBool{} C.RNull{}:
3964
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RNull{}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3965
+ case C.SBool{} C.RStr{s__}:
3966
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3967
+ case C.SBool{} C.RBad{}:
3968
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RBad{}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3969
+ case C.SBool{} C.RTooBig{}:
3970
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3971
+ case C.SBool{} C.RMissing{}:
3972
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RMissing{}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3973
+ case C.SBool{} C.RNil{}:
3974
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RNil{}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3975
+ case C.SBool{} C.RCons{head__, tail__}:
3976
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3977
+ case C.SBool{} C.REnd{}:
3978
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.REnd{}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
3979
+ case C.SBool{} C.RKey{+k, +w, +o2}:
3980
+ Empty.absurd({C.conforms(~rule, C.SBool{}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SBool{}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
3981
+ case C.STrue{} C.RNum{n__}:
3982
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
3983
+ case C.STrue{} C.RBool{b__}:
3984
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
3985
+ case C.STrue{} C.RNull{}:
3986
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RNull{}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
3987
+ case C.STrue{} C.RStr{s__}:
3988
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
3989
+ case C.STrue{} C.RBad{}:
3990
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RBad{}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
3991
+ case C.STrue{} C.RTooBig{}:
3992
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
3993
+ case C.STrue{} C.RMissing{}:
3994
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RMissing{}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
3995
+ case C.STrue{} C.RNil{}:
3996
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RNil{}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
3997
+ case C.STrue{} C.RCons{head__, tail__}:
3998
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
3999
+ case C.STrue{} C.REnd{}:
4000
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.REnd{}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4001
+ case C.STrue{} C.RKey{+k, +w, +o2}:
4002
+ Empty.absurd({C.conforms(~rule, C.STrue{}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.STrue{}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4003
+ case C.SEnum{names_} C.RNum{n__}:
4004
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4005
+ case C.SEnum{names_} C.RBool{b__}:
4006
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4007
+ case C.SEnum{names_} C.RNull{}:
4008
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RNull{}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4009
+ case C.SEnum{names_} C.RStr{s__}:
4010
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4011
+ case C.SEnum{names_} C.RBad{}:
4012
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RBad{}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4013
+ case C.SEnum{names_} C.RTooBig{}:
4014
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4015
+ case C.SEnum{names_} C.RMissing{}:
4016
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4017
+ case C.SEnum{names_} C.RNil{}:
4018
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RNil{}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4019
+ case C.SEnum{names_} C.RCons{head__, tail__}:
4020
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4021
+ case C.SEnum{names_} C.REnd{}:
4022
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.REnd{}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4023
+ case C.SEnum{names_} C.RKey{+k, +w, +o2}:
4024
+ Empty.absurd({C.conforms(~rule, C.SEnum{names_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SEnum{names_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4025
+ case C.SVariant{name_, s_, rest_} C.RNum{n__}:
4026
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4027
+ case C.SVariant{name_, s_, rest_} C.RBool{b__}:
4028
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4029
+ case C.SVariant{name_, s_, rest_} C.RNull{}:
4030
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RNull{}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4031
+ case C.SVariant{name_, s_, rest_} C.RStr{s__}:
4032
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4033
+ case C.SVariant{name_, s_, rest_} C.RBad{}:
4034
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RBad{}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4035
+ case C.SVariant{name_, s_, rest_} C.RTooBig{}:
4036
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4037
+ case C.SVariant{name_, s_, rest_} C.RMissing{}:
4038
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4039
+ case C.SVariant{name_, s_, rest_} C.RNil{}:
4040
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RNil{}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4041
+ case C.SVariant{name_, s_, rest_} C.RCons{head__, tail__}:
4042
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4043
+ case C.SVariant{name_, s_, rest_} C.REnd{}:
4044
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.REnd{}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4045
+ case C.SVariant{name_, s_, rest_} C.RKey{+k, +w, +o2}:
4046
+ Empty.absurd({C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SVariant{name_, s_, rest_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4047
+ case C.SVEnd{} C.RNum{n__}:
4048
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4049
+ case C.SVEnd{} C.RBool{b__}:
4050
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4051
+ case C.SVEnd{} C.RNull{}:
4052
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RNull{}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4053
+ case C.SVEnd{} C.RStr{s__}:
4054
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4055
+ case C.SVEnd{} C.RBad{}:
4056
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RBad{}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4057
+ case C.SVEnd{} C.RTooBig{}:
4058
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4059
+ case C.SVEnd{} C.RMissing{}:
4060
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RMissing{}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4061
+ case C.SVEnd{} C.RNil{}:
4062
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RNil{}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4063
+ case C.SVEnd{} C.RCons{head__, tail__}:
4064
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4065
+ case C.SVEnd{} C.REnd{}:
4066
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.REnd{}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4067
+ case C.SVEnd{} C.RKey{+k, +w, +o2}:
4068
+ Empty.absurd({C.conforms(~rule, C.SVEnd{}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SVEnd{}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4069
+ case C.STuple{s_, rest_} C.RNum{n__}:
4070
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4071
+ case C.STuple{s_, rest_} C.RBool{b__}:
4072
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4073
+ case C.STuple{s_, rest_} C.RNull{}:
4074
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RNull{}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4075
+ case C.STuple{s_, rest_} C.RStr{s__}:
4076
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4077
+ case C.STuple{s_, rest_} C.RBad{}:
4078
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RBad{}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4079
+ case C.STuple{s_, rest_} C.RTooBig{}:
4080
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4081
+ case C.STuple{s_, rest_} C.RMissing{}:
4082
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RMissing{}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4083
+ case C.STuple{s_, rest_} C.RNil{}:
4084
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RNil{}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4085
+ case C.STuple{s_, rest_} C.RCons{head__, tail__}:
4086
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4087
+ case C.STuple{s_, rest_} C.REnd{}:
4088
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.REnd{}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4089
+ case C.STuple{s_, rest_} C.RKey{+k, +w, +o2}:
4090
+ Empty.absurd({C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.STuple{s_, rest_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4091
+ case C.STEnd{} C.RNum{n__}:
4092
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RNum{n__}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4093
+ case C.STEnd{} C.RBool{b__}:
4094
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RBool{b__}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4095
+ case C.STEnd{} C.RNull{}:
4096
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RNull{}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4097
+ case C.STEnd{} C.RStr{s__}:
4098
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RStr{s__}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4099
+ case C.STEnd{} C.RBad{}:
4100
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RBad{}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4101
+ case C.STEnd{} C.RTooBig{}:
4102
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RTooBig{}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4103
+ case C.STEnd{} C.RMissing{}:
4104
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RMissing{}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4105
+ case C.STEnd{} C.RNil{}:
4106
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RNil{}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4107
+ case C.STEnd{} C.RCons{head__, tail__}:
4108
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4109
+ case C.STEnd{} C.REnd{}:
4110
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.REnd{}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4111
+ case C.STEnd{} C.RKey{+k, +w, +o2}:
4112
+ Empty.absurd({C.conforms(~rule, C.STEnd{}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.STEnd{}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4113
+ case C.SOptional{inner_} C.RNum{n__}:
4114
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4115
+ case C.SOptional{inner_} C.RBool{b__}:
4116
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4117
+ case C.SOptional{inner_} C.RNull{}:
4118
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RNull{}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4119
+ case C.SOptional{inner_} C.RStr{s__}:
4120
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4121
+ case C.SOptional{inner_} C.RBad{}:
4122
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RBad{}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4123
+ case C.SOptional{inner_} C.RTooBig{}:
4124
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4125
+ case C.SOptional{inner_} C.RMissing{}:
4126
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4127
+ case C.SOptional{inner_} C.RNil{}:
4128
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RNil{}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4129
+ case C.SOptional{inner_} C.RCons{head__, tail__}:
4130
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4131
+ case C.SOptional{inner_} C.REnd{}:
4132
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.REnd{}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4133
+ case C.SOptional{inner_} C.RKey{+k, +w, +o2}:
4134
+ Empty.absurd({C.conforms(~rule, C.SOptional{inner_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SOptional{inner_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4135
+ case C.SListLen{lo_, hi_, s_} C.RNum{n__}:
4136
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RNum{n__}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RNum{n__}}, None{}) : Bool}, to_empty(ho))
4137
+ case C.SListLen{lo_, hi_, s_} C.RBool{b__}:
4138
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RBool{b__}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RBool{b__}}, None{}) : Bool}, to_empty(ho))
4139
+ case C.SListLen{lo_, hi_, s_} C.RNull{}:
4140
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RNull{}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RNull{}}, None{}) : Bool}, to_empty(ho))
4141
+ case C.SListLen{lo_, hi_, s_} C.RStr{s__}:
4142
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RStr{s__}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RStr{s__}}, None{}) : Bool}, to_empty(ho))
4143
+ case C.SListLen{lo_, hi_, s_} C.RBad{}:
4144
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RBad{}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RBad{}}, None{}) : Bool}, to_empty(ho))
4145
+ case C.SListLen{lo_, hi_, s_} C.RTooBig{}:
4146
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RTooBig{}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RTooBig{}}, None{}) : Bool}, to_empty(ho))
4147
+ case C.SListLen{lo_, hi_, s_} C.RMissing{}:
4148
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RMissing{}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RMissing{}}, None{}) : Bool}, to_empty(ho))
4149
+ case C.SListLen{lo_, hi_, s_} C.RNil{}:
4150
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RNil{}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RNil{}}, None{}) : Bool}, to_empty(ho))
4151
+ case C.SListLen{lo_, hi_, s_} C.RCons{head__, tail__}:
4152
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RCons{head__, tail__}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RCons{head__, tail__}}, None{}) : Bool}, to_empty(ho))
4153
+ case C.SListLen{lo_, hi_, s_} C.REnd{}:
4154
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.REnd{}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.REnd{}}, None{}) : Bool}, to_empty(hf))
4155
+ case C.SListLen{lo_, hi_, s_} C.RKey{+k, +w, +o2}:
4156
+ Empty.absurd({C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{k, w, o2}, None{}) == C.conforms(~rule, C.SListLen{lo_, hi_, s_}, C.RKey{n, v, C.RKey{k, w, o2}}, None{}) : Bool}, to_empty(hf))
4157
+
4158
+ # A strict object's encoding: every key enc writes for a chain of keys is
4159
+ # one of the chain's names; a longer list of names allows at least as much.
4160
+
4161
+ def or_r_true(a: Bool, +b: Bool, hb: {b == True{} : Bool}) -> {Bool.or(a, b) == True{} : Bool}:
4162
+ match a:
4163
+ case True{}:
4164
+ {==}
4165
+ case False{}:
4166
+ hb
4167
+
4168
+ def extra_mono(+m: String, +ns: List<&2, String>, r: C.Raw, +h: {C.no_extra(ns, r) == True{} : Bool}) -> {C.no_extra(m <> ns, r) == True{} : Bool}:
4169
+ match r:
4170
+ case C.RKey{+k, v, +o}:
4171
+ and_true2(Bool.or(String.eq(k, m), C.in_names(k, ns)), C.no_extra(m <> ns, o), or_r_true(String.eq(k, m), C.in_names(k, ns), and_l(C.in_names(k, ns), C.no_extra(ns, o), h)), extra_mono(m, ns, o, and_r(C.in_names(k, ns), C.no_extra(ns, o), h)))
4172
+ case C.RNum{n_}:
4173
+ {==}
4174
+ case C.RBool{b_}:
4175
+ {==}
4176
+ case C.RNull{}:
4177
+ {==}
4178
+ case C.RStr{s_}:
4179
+ {==}
4180
+ case C.RBad{}:
4181
+ {==}
4182
+ case C.RTooBig{}:
4183
+ {==}
4184
+ case C.RMissing{}:
4185
+ {==}
4186
+ case C.RNil{}:
4187
+ {==}
4188
+ case C.RCons{h_, t_}:
4189
+ {==}
4190
+ case C.REnd{}:
4191
+ {==}
4192
+
4193
+ def keyed_enc(s: C.Schema, x: C.Meaning(s), +hk: {C.is_keyed(s) == True{} : Bool}) -> {C.no_extra(C.key_names(s), C.enc(s, x)) == True{} : Bool}:
4194
+ match s x:
4195
+ case C.SField{+n, fs, +rest} C.Both{a, +b}:
4196
+ and_true2(C.in_names(n, n <> C.key_names(rest)), C.no_extra(n <> C.key_names(rest), C.enc(rest, b)), names_has(Nil{}, n, C.key_names(rest)), extra_mono(n, C.key_names(rest), C.enc(rest, b), keyed_enc(rest, b, hk)))
4197
+ case C.SEnd{} Unit{}:
4198
+ {==}
4199
+ case C.SVariant{+n, vs, +rest} Inl{a}:
4200
+ and_true2(C.in_names(n, n <> C.key_names(rest)), C.no_extra(n <> C.key_names(rest), C.REnd{}), names_has(Nil{}, n, C.key_names(rest)), {==})
4201
+ case C.SVariant{+n, vs, +rest} Inr{+b}:
4202
+ extra_mono(n, C.key_names(rest), C.enc(rest, b), keyed_enc(rest, b, hk))
4203
+ case C.SVEnd{} e:
4204
+ Empty.absurd({C.no_extra(C.key_names(C.SVEnd{}), C.enc(C.SVEnd{}, e)) == True{} : Bool}, e)
4205
+ case C.SBool{} v:
4206
+ Empty.absurd({C.no_extra(C.key_names(C.SBool{}), C.enc(C.SBool{}, v)) == True{} : Bool}, to_empty(hk))
4207
+ case C.SNatIn{lo_, hi_} v:
4208
+ Empty.absurd({C.no_extra(C.key_names(C.SNatIn{lo_, hi_}), C.enc(C.SNatIn{lo_, hi_}, v)) == True{} : Bool}, to_empty(hk))
4209
+ case C.SStrLen{lo_, hi_, s2} v:
4210
+ Empty.absurd({C.no_extra(C.key_names(C.SStrLen{lo_, hi_, s2}), C.enc(C.SStrLen{lo_, hi_, s2}, v)) == True{} : Bool}, to_empty(hk))
4211
+ case C.SNat{} v:
4212
+ Empty.absurd({C.no_extra(C.key_names(C.SNat{}), C.enc(C.SNat{}, v)) == True{} : Bool}, to_empty(hk))
4213
+ case C.SStr{} v:
4214
+ Empty.absurd({C.no_extra(C.key_names(C.SStr{}), C.enc(C.SStr{}, v)) == True{} : Bool}, to_empty(hk))
4215
+ case C.SOpt{i_} v:
4216
+ Empty.absurd({C.no_extra(C.key_names(C.SOpt{i_}), C.enc(C.SOpt{i_}, v)) == True{} : Bool}, to_empty(hk))
4217
+ case C.SList{e_} v:
4218
+ Empty.absurd({C.no_extra(C.key_names(C.SList{e_}), C.enc(C.SList{e_}, v)) == True{} : Bool}, to_empty(hk))
4219
+ case C.SRule{s_, t_} v:
4220
+ Empty.absurd({C.no_extra(C.key_names(C.SRule{s_, t_}), C.enc(C.SRule{s_, t_}, v)) == True{} : Bool}, to_empty(hk))
4221
+ case C.SStrict{s_} v:
4222
+ Empty.absurd({C.no_extra(C.key_names(C.SStrict{s_}), C.enc(C.SStrict{s_}, v)) == True{} : Bool}, to_empty(hk))
4223
+ case C.STagged{k_, n_, cs_, rest_} v:
4224
+ Empty.absurd({C.no_extra(C.key_names(C.STagged{k_, n_, cs_, rest_}), C.enc(C.STagged{k_, n_, cs_, rest_}, v)) == True{} : Bool}, to_empty(hk))
4225
+ case C.STagEnd{k_} v:
4226
+ Empty.absurd({C.no_extra(C.key_names(C.STagEnd{k_}), C.enc(C.STagEnd{k_}, v)) == True{} : Bool}, to_empty(hk))
4227
+ case C.STrue{} v:
4228
+ Empty.absurd({C.no_extra(C.key_names(C.STrue{}), C.enc(C.STrue{}, v)) == True{} : Bool}, to_empty(hk))
4229
+ case C.SEnum{ns_} v:
4230
+ Empty.absurd({C.no_extra(C.key_names(C.SEnum{ns_}), C.enc(C.SEnum{ns_}, v)) == True{} : Bool}, to_empty(hk))
4231
+ case C.STuple{ts_, rs_} v:
4232
+ Empty.absurd({C.no_extra(C.key_names(C.STuple{ts_, rs_}), C.enc(C.STuple{ts_, rs_}, v)) == True{} : Bool}, to_empty(hk))
4233
+ case C.STEnd{} v:
4234
+ Empty.absurd({C.no_extra(C.key_names(C.STEnd{}), C.enc(C.STEnd{}, v)) == True{} : Bool}, to_empty(hk))
4235
+ case C.SOptional{i_} v:
4236
+ Empty.absurd({C.no_extra(C.key_names(C.SOptional{i_}), C.enc(C.SOptional{i_}, v)) == True{} : Bool}, to_empty(hk))
4237
+ case C.SListLen{lo_, hi_, s2_} v:
4238
+ Empty.absurd({C.no_extra(C.key_names(C.SListLen{lo_, hi_, s2_}), C.enc(C.SListLen{lo_, hi_, s2_}, v)) == True{} : Bool}, to_empty(hk))
4239
+
4240
+ def ec(s: C.Schema, x: C.Meaning(s), +hw: {C.wf(s) == True{} : Bool}, +hn: {C.names_ok(s, x) == True{} : Bool}, +hb: {C.bounds_ok(s, x) == True{} : Bool}) -> {C.conforms(~C.no_rule, s, C.enc(s, x), None{}) == True{} : Bool}:
4241
+ match s x:
4242
+ case C.SNat{} n:
4243
+ {==}
4244
+ case C.SNatIn{+lo, +hi} n:
4245
+ hb
4246
+ case C.SStr{} n:
4247
+ {==}
4248
+ case C.SStrLen{+lo, +hi, +s2} +v:
4249
+ and_true2(C.conforms(~C.no_rule, s2, C.enc(s2, v), None{}), C.len_ok(lo, hi, C.enc(s2, v)), ec(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), hw), hn, and_l(C.bounds_ok(s2, v), C.len_ok(lo, hi, C.enc(s2, v)), hb)), and_r(C.bounds_ok(s2, v), C.len_ok(lo, hi, C.enc(s2, v)), hb))
4250
+ case C.SListLen{+lo, +hi, +s2} +v:
4251
+ and_true2(C.list_len_ok(lo, hi, C.enc(s2, v)), C.conforms(~C.no_rule, s2, C.enc(s2, v), None{}), and_r(C.bounds_ok(s2, v), C.list_len_ok(lo, hi, C.enc(s2, v)), hb), ec(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), hw), hn, and_l(C.bounds_ok(s2, v), C.list_len_ok(lo, hi, C.enc(s2, v)), hb)))
4252
+ case C.SOpt{i} None{}:
4253
+ {==}
4254
+ case C.SOpt{+i} Some{+v}:
4255
+ %opt_conf(~C.no_rule, i, C.enc(i, v), not_nullish(i, v, not_true(C.nullable(i), and_l(Bool.not(C.nullable(i)), C.wf(i), hw)))) : {_ == True{} : Bool}
4256
+ ec(i, v, and_r(Bool.not(C.nullable(i)), C.wf(i), hw), hn, hb)
4257
+ case C.SOptional{+i} None{}:
4258
+ {==}
4259
+ case C.SOptional{+i} Some{+v}:
4260
+ %not_missing(i, v, not_true(C.opt_at(i), and_l(Bool.not(C.opt_at(i)), C.wf(i), hw))) : {Bool.or(_, C.conforms(~C.no_rule, i, C.enc(i, v), None{})) == True{} : Bool}
4261
+ ec(i, v, and_r(Bool.not(C.opt_at(i)), C.wf(i), hw), hn, hb)
4262
+ case C.SList{e} Nil{}:
4263
+ {==}
4264
+ case C.SList{+e} +h <> +t:
4265
+ and_true2(C.conforms(~C.no_rule, e, C.enc(e, h), None{}), C.conforms(~C.no_rule, C.SList{e}, C.enc(C.SList{e}, t), None{}), ec(e, h, and_r(Bool.not(C.opt_at(e)), C.wf(e), hw), and_l(C.names_ok(e, h), C.names_ok(C.SList{e}, t), hn), and_l(C.bounds_ok(e, h), C.bounds_ok(C.SList{e}, t), hb)), ec(C.SList{e}, t, hw, and_r(C.names_ok(e, h), C.names_ok(C.SList{e}, t), hn), and_r(C.bounds_ok(e, h), C.bounds_ok(C.SList{e}, t), hb)))
4266
+ case C.SField{+n, +fs, +rest} C.Both{+a, +b}:
4267
+ %lk_self(n, C.enc(fs, a), C.enc(rest, b)) : {Bool.and(C.key_once_at(C.enc(rest, b), String.eq(n, n), n), Bool.and(C.conforms(~C.no_rule, fs, _, None{}), C.conforms(~C.no_rule, rest, C.RKey{n, C.enc(fs, a), C.enc(rest, b)}, None{}))) == True{} : Bool}
4268
+ %MS.eq_refl_sym(n) : {Bool.and(C.key_once_at(C.enc(rest, b), _, n), Bool.and(C.conforms(~C.no_rule, fs, C.enc(fs, a), None{}), C.conforms(~C.no_rule, rest, C.RKey{n, C.enc(fs, a), C.enc(rest, b)}, None{}))) == True{} : Bool}
4269
+ %key_once_enc(n, rest, b, and_l(C.fresh_f(n, rest), C.wf(rest), and_r(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw))) : {Bool.and(_, Bool.and(C.conforms(~C.no_rule, fs, C.enc(fs, a), None{}), C.conforms(~C.no_rule, rest, C.RKey{n, C.enc(fs, a), C.enc(rest, b)}, None{}))) == True{} : Bool}
4270
+ %skip_c(~C.no_rule, n, rest, C.enc(fs, a), C.enc(rest, b), and_l(C.fresh_f(n, rest), C.wf(rest), and_r(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw)), obj_f(n, rest, b, and_l(C.fresh_f(n, rest), C.wf(rest), and_r(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw)))) : {Bool.and(C.conforms(~C.no_rule, fs, C.enc(fs, a), None{}), _) == True{} : Bool}
4271
+ and_true2(C.conforms(~C.no_rule, fs, C.enc(fs, a), None{}), C.conforms(~C.no_rule, rest, C.enc(rest, b), None{}), ec(fs, a, and_l(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw), and_l(C.names_ok(fs, a), C.names_ok(rest, b), hn), and_l(C.bounds_ok(fs, a), C.bounds_ok(rest, b), hb)), ec(rest, b, and_r(C.fresh_f(n, rest), C.wf(rest), and_r(C.wf(fs), Bool.and(C.fresh_f(n, rest), C.wf(rest)), hw)), and_r(C.names_ok(fs, a), C.names_ok(rest, b), hn), and_r(C.bounds_ok(fs, a), C.bounds_ok(rest, b), hb)))
4272
+ case C.SEnd{} Unit{}:
4273
+ {==}
4274
+ case C.SRule{+s2, +tag} +v:
4275
+ and_true2(C.conforms(~C.no_rule, s2, C.enc(s2, v), None{}), Maybe.is_none(&2, C.Err, C.no_rule(tag, C.enc(s2, v))), ec(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), hw), hn, hb), {==})
4276
+ case C.SStrict{+s2} +v:
4277
+ and_true2(C.conforms(~C.no_rule, s2, C.enc(s2, v), None{}), C.no_extra(C.key_names(s2), C.enc(s2, v)), ec(s2, v, and_r(Bool.not(C.opt_at(s2)), C.wf(s2), and_r(C.is_keyed(s2), Bool.and(Bool.not(C.opt_at(s2)), C.wf(s2)), hw)), hn, hb), keyed_enc(s2, v, and_l(C.is_keyed(s2), Bool.and(Bool.not(C.opt_at(s2)), C.wf(s2)), hw)))
4278
+ case C.STagged{+k, +n, +cs, +rest} Inl{+a}:
4279
+ %tag_self(k, n, C.enc(cs, a)) : {C.pick_bool(_, Bool.and(C.key_once(k, C.RKey{k, C.RStr{n}, C.enc(cs, a)}), C.conforms(~C.no_rule, cs, C.drop_key(k, C.RKey{k, C.RStr{n}, C.enc(cs, a)}), None{})), C.conforms(~C.no_rule, rest, C.RKey{k, C.RStr{n}, C.enc(cs, a)}, None{})) == True{} : Bool}
4280
+ %drop_self(k, C.RStr{n}, C.enc(cs, a)) : {Bool.and(C.key_once(k, C.RKey{k, C.RStr{n}, C.enc(cs, a)}), C.conforms(~C.no_rule, cs, _, None{})) == True{} : Bool}
4281
+ and_true2(C.key_once(k, C.RKey{k, C.RStr{n}, C.enc(cs, a)}), C.conforms(~C.no_rule, cs, C.enc(cs, a), None{}), no_key_once(k, cs, a, String.eq(k, k), and_l(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)), and_r(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw)))), ec(cs, a, and_l(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw)), hn, hb))
4282
+ case C.STagged{+k, +n, +cs, +rest} Inr{+b}:
4283
+ %tag_other(k, n, rest, b, and_l(C.fresh_t(k, n, rest), C.wf(rest), and_r(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)), and_r(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw))))) : {C.pick_bool(_, Bool.and(C.key_once(k, C.enc(rest, b)), C.conforms(~C.no_rule, cs, C.drop_key(k, C.enc(rest, b)), None{})), C.conforms(~C.no_rule, rest, C.enc(rest, b), None{})) == True{} : Bool}
4284
+ ec(rest, b, and_r(C.fresh_t(k, n, rest), C.wf(rest), and_r(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)), and_r(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest))), and_r(Bool.not(C.opt_at(cs)), Bool.and(C.wf(cs), Bool.and(C.no_key(k, cs), Bool.and(C.fresh_t(k, n, rest), C.wf(rest)))), hw)))), hn, hb)
4285
+ case C.STagEnd{k_} e:
4286
+ Empty.absurd({C.conforms(~C.no_rule, C.STagEnd{k_}, C.enc(C.STagEnd{k_}, e), None{}) == True{} : Bool}, e)
4287
+ case C.STrue{} Unit{}:
4288
+ {==}
4289
+ case C.SBool{} b:
4290
+ {==}
4291
+ case C.SEnum{names} v:
4292
+ hn
4293
+ case C.SVariant{+n, +vs, +rest} Inl{+a}:
4294
+ %lk_self(n, C.enc(vs, a), C.REnd{}) : {C.pick_bool(C.is_missing(_), C.conforms(~C.no_rule, rest, C.RKey{n, C.enc(vs, a), C.REnd{}}, None{}), Bool.and(C.conforms(~C.no_rule, vs, _, None{}), C.none_present(rest, C.RKey{n, C.enc(vs, a), C.REnd{}}))) == True{} : Bool}
4295
+ %not_missing(vs, a, not_true(C.opt_at(vs), and_l(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw))) : {C.pick_bool(_, C.conforms(~C.no_rule, rest, C.RKey{n, C.enc(vs, a), C.REnd{}}, None{}), Bool.and(C.conforms(~C.no_rule, vs, C.enc(vs, a), None{}), C.none_present(rest, C.RKey{n, C.enc(vs, a), C.REnd{}}))) == True{} : Bool}
4296
+ and_true2(C.conforms(~C.no_rule, vs, C.enc(vs, a), None{}), C.none_present(rest, C.RKey{n, C.enc(vs, a), C.REnd{}}), ec(vs, a, and_l(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw)), hn, hb), np(n, rest, C.enc(vs, a), and_l(C.fresh_v(n, rest), C.wf(rest), and_r(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw)))))
4297
+ case C.SVariant{+n, +vs, +rest} Inr{+b}:
4298
+ %var_skip(~C.no_rule, n, vs, rest, C.enc(rest, b), obj_v(n, rest, b, and_l(C.fresh_v(n, rest), C.wf(rest), and_r(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw)))), absent(n, rest, b, and_l(C.fresh_v(n, rest), C.wf(rest), and_r(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw))))) : {_ == True{} : Bool}
4299
+ ec(rest, b, and_r(C.fresh_v(n, rest), C.wf(rest), and_r(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest)), and_r(Bool.not(C.opt_at(vs)), Bool.and(C.wf(vs), Bool.and(C.fresh_v(n, rest), C.wf(rest))), hw))), hn, hb)
4300
+ case C.SVEnd{} e:
4301
+ Empty.absurd({C.conforms(~C.no_rule, C.SVEnd{}, C.enc(C.SVEnd{}, e), None{}) == True{} : Bool}, e)
4302
+ case C.STuple{+ts, +rest} C.Both{+a, +b}:
4303
+ and_true2(C.conforms(~C.no_rule, ts, C.enc(ts, a), None{}), C.conforms(~C.no_rule, rest, C.enc(rest, b), None{}), ec(ts, a, and_l(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest)), and_r(Bool.not(C.opt_at(ts)), Bool.and(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest))), hw)), and_l(C.names_ok(ts, a), C.names_ok(rest, b), hn), and_l(C.bounds_ok(ts, a), C.bounds_ok(rest, b), hb)), ec(rest, b, and_r(Bool.not(C.opt_at(rest)), C.wf(rest), and_r(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest)), and_r(Bool.not(C.opt_at(ts)), Bool.and(C.wf(ts), Bool.and(Bool.not(C.opt_at(rest)), C.wf(rest))), hw))), and_r(C.names_ok(ts, a), C.names_ok(rest, b), hn), and_r(C.bounds_ok(ts, a), C.bounds_ok(rest, b), hb)))
4304
+ case C.STEnd{} Unit{}:
4305
+ {==}
4306
+
4307
+ def Laws.encode_conforms(s, x, hw, hn, hb):
4308
+ ec(s, x, hw, hn, hb)
4309
+
4310
+ # ---- a string's length is in its bounds ----
4311
+
4312
+ def Laws.str_len_in_meaning(lo, hi, x):
4313
+ in_err_none(Bool.and(Nat.is_le(lo, String.length(x)), Nat.is_le(String.length(x), hi)), C.LengthNotIn{lo, hi})
4314
+
4315
+ # ---- a number is in its bounds ----
4316
+
4317
+ def Laws.nat_in_meaning(lo, hi, n):
4318
+ in_err_none(Bool.and(Nat.is_le(lo, n), Nat.is_le(n, hi)), C.NotIn{lo, hi})
4319
+
4320
+ # ---- a boolean, and nothing else ----
4321
+ #
4322
+ # A second reading of SBool, by a walk of its own over the value: conforms
4323
+ # accepts exactly the booleans. A host that writes "a boolean" gets a check
4324
+ # that agrees with it for every value, not only for the ones it thought of.
4325
+
4326
+ # arms: r
4327
+ # arms leaf: {==}
4328
+ def sbool_go(~rule: Nat -> C.Raw -> Maybe<&2, C.Err>, r: C.Raw) -> {C.conforms(~rule, C.SBool{}, r, None{}) == C.is_bool(r) : Bool}:
4329
+ match r:
4330
+ case C.RNum{n_}:
4331
+ {==}
4332
+ case C.RBool{b_}:
4333
+ {==}
4334
+ case C.RNull{}:
4335
+ {==}
4336
+ case C.RStr{s_}:
4337
+ {==}
4338
+ case C.RBad{}:
4339
+ {==}
4340
+ case C.RTooBig{}:
4341
+ {==}
4342
+ case C.RMissing{}:
4343
+ {==}
4344
+ case C.RNil{}:
4345
+ {==}
4346
+ case C.RCons{h_, t_}:
4347
+ {==}
4348
+ case C.REnd{}:
4349
+ {==}
4350
+ case C.RKey{k_, v_, o_}:
4351
+ {==}
4352
+
4353
+ def Laws.sbool_meaning(rule, r):
4354
+ sbool_go(~rule, r)
4355
+
4356
+ # ---- a string's length, as a constructor ----
4357
+ #
4358
+ # str_len_in_meaning, restated for SStrLen: what the rule tested, the
4359
+ # constructor means -- the same str_len_ok, and the shape s the value must also
4360
+ # satisfy. The rule read no other kind; here the other kinds are not in bounds.
4361
+
4362
+ def Laws.sstr_len_meaning(rule, lo, hi, s, x):
4363
+ {==}
4364
+
4365
+ # ---- a number's bounds, as a constructor ----
4366
+ #
4367
+ # nat_in_meaning, restated for SNatIn: the same num_ok, both ends included.
4368
+
4369
+ def Laws.snat_in_meaning(rule, lo, hi, n):
4370
+ {==}
4371
+
4372
+ # ---- a strict object has no other key ----
4373
+
4374
+ def unk_step(b: Bool, +c: Nat, +d: Bool, ih: {Nat.is_eq(c, 0n) == d : Bool}) -> {Nat.is_eq(Nat.add(C.one_if_there(b), c), 0n) == Bool.and(b, d) : Bool}:
4375
+ match b:
4376
+ case True{}:
4377
+ ih
4378
+ case False{}:
4379
+ {==}
4380
+
4381
+ def strict_count(+ns: List<&2, String>, r: C.Raw) -> {Nat.is_eq(C.count_unknown(ns, r), 0n) == C.no_extra(ns, r) : Bool}:
4382
+ match r:
4383
+ case C.RKey{+k, v, +o}:
4384
+ unk_step(C.in_names(k, ns), C.count_unknown(ns, o), C.no_extra(ns, o), strict_count(ns, o))
4385
+ case C.RNum{n_}:
4386
+ {==}
4387
+ case C.RBool{b_}:
4388
+ {==}
4389
+ case C.RNull{}:
4390
+ {==}
4391
+ case C.RStr{s_}:
4392
+ {==}
4393
+ case C.RBad{}:
4394
+ {==}
4395
+ case C.RTooBig{}:
4396
+ {==}
4397
+ case C.RMissing{}:
4398
+ {==}
4399
+ case C.RNil{}:
4400
+ {==}
4401
+ case C.RCons{h_, t_}:
4402
+ {==}
4403
+ case C.REnd{}:
4404
+ {==}
4405
+
4406
+ def Laws.strict_meaning(rule, s, r):
4407
+ %strict_count(C.key_names(s), r) : {Bool.and(C.conforms(~rule, s, r, None{}), _) == Bool.and(C.conforms(~rule, s, r, None{}), Nat.is_eq(C.count_unknown(C.key_names(s), r), 0n)) : Bool}
4408
+ {==}
4409
+
4410
+ # ---- a tagged case reads the object without its tag ----
4411
+
4412
+ def Laws.tagged_meaning(rule, k, n, cs, rest, r):
4413
+ {==}
4414
+
4415
+ # ---- the end of a tagged chain accepts nothing ----
4416
+
4417
+ def Laws.tag_end_refuses(rule, k, r):
4418
+ match r:
4419
+ case C.RNum{n_}:
4420
+ {==}
4421
+ case C.RBool{b_}:
4422
+ {==}
4423
+ case C.RNull{}:
4424
+ {==}
4425
+ case C.RStr{s_}:
4426
+ {==}
4427
+ case C.RBad{}:
4428
+ {==}
4429
+ case C.RTooBig{}:
4430
+ {==}
4431
+ case C.RMissing{}:
4432
+ {==}
4433
+ case C.RNil{}:
4434
+ {==}
4435
+ case C.RCons{h_, t_}:
4436
+ {==}
4437
+ case C.REnd{}:
4438
+ {==}
4439
+ case C.RKey{j_, v_, o_}:
4440
+ {==}
4441
+
4442
+ # ---- drop_key takes out the first key it names ----
4443
+
4444
+ def Laws.drop_first(k, v, o):
4445
+ Equal.sym(C.Raw, o, C.drop_key(k, C.RKey{k, v, o}), drop_self(k, v, o))
4446
+
4447
+ # ---- drop_key leaves every other key as it was ----
4448
+
4449
+ def drop_step(b: Bool, +i: String, +k: String, +j: String, +v: C.Raw, +o: C.Raw, eb: {b == String.eq(i, k) : Bool}, +h: {False{} == String.eq(k, j) : Bool}, ih: {C.lookup(j, C.drop_key(k, o)) == C.lookup(j, o) : C.Raw}) -> {C.lookup(j, C.pick_raw(b, o, C.RKey{i, v, C.drop_key(k, o)})) == C.lookup(j, C.RKey{i, v, o}) : C.Raw}:
4450
+ match b:
4451
+ case True{}:
4452
+ %Equal.sym(String, i, k, MS.eq_of_eq_true(i, k, Equal.sym(Bool, True{}, String.eq(i, k), eb))) : {C.lookup(j, o) == C.pick_raw(String.eq(_, j), v, C.lookup(j, o)) : C.Raw}
4453
+ %h : {C.lookup(j, o) == C.pick_raw(_, v, C.lookup(j, o)) : C.Raw}
4454
+ {==}
4455
+ case False{}:
4456
+ %ih : {C.pick_raw(String.eq(i, j), v, C.lookup(j, C.drop_key(k, o))) == C.pick_raw(String.eq(i, j), v, _) : C.Raw}
4457
+ {==}
4458
+
4459
+ def drop_other_go(+k: String, +j: String, r: C.Raw, +h: {False{} == String.eq(k, j) : Bool}) -> {C.lookup(j, C.drop_key(k, r)) == C.lookup(j, r) : C.Raw}:
4460
+ match r:
4461
+ case C.RKey{+i, +v, +o}:
4462
+ drop_step(String.eq(i, k), i, k, j, v, o, {==}, h, drop_other_go(k, j, o, h))
4463
+ case C.RNum{n_}:
4464
+ {==}
4465
+ case C.RBool{b_}:
4466
+ {==}
4467
+ case C.RNull{}:
4468
+ {==}
4469
+ case C.RStr{s_}:
4470
+ {==}
4471
+ case C.RBad{}:
4472
+ {==}
4473
+ case C.RTooBig{}:
4474
+ {==}
4475
+ case C.RMissing{}:
4476
+ {==}
4477
+ case C.RNil{}:
4478
+ {==}
4479
+ case C.RCons{h_, t_}:
4480
+ {==}
4481
+ case C.REnd{}:
4482
+ {==}
4483
+
4484
+ def Laws.drop_other(k, j, r, h):
4485
+ drop_other_go(k, j, r, h)
4486
+
4487
+
4488
+ # ---- a list's element count, as a constructor ----
4489
+
4490
+ # conforms(SListLen{lo, hi, s}, r) unfolds to the count (list_len_ok: is it a
4491
+ # list at all, and are its elements in the bounds) beside conforms(s, r) --
4492
+ # which is the law's right side, with the helper the core reads written out.
4493
+ # The two sides are the same term, so nothing is left to prove.
4494
+ def Laws.slist_len_meaning(rule, lo, hi, s, r):
4495
+ {==}
4496
+
4497
+
4498
+ # ---- an optional field, as a constructor ----
4499
+
4500
+ # Every value but the absent one is the inner schema's to decide, and the
4501
+ # absent one is accepted. Bool.or reduces on the first argument, which is the
4502
+ # value's own kind, so each arm is the same equation with the constructor
4503
+ # fixed: no rule is read at an SOptional's own node.
4504
+ def Laws.soptional_meaning(rule, i, r):
4505
+ match r:
4506
+ case C.RMissing{}:
4507
+ {==}
4508
+ case C.RNum{n_}:
4509
+ {==}
4510
+ case C.RBool{b_}:
4511
+ {==}
4512
+ case C.RNull{}:
4513
+ {==}
4514
+ case C.RStr{s_}:
4515
+ {==}
4516
+ case C.RBad{}:
4517
+ {==}
4518
+ case C.RTooBig{}:
4519
+ {==}
4520
+ case C.RNil{}:
4521
+ {==}
4522
+ case C.RCons{h_, t_}:
4523
+ {==}
4524
+ case C.REnd{}:
4525
+ {==}
4526
+ case C.RKey{k_, v_, o_}:
4527
+ {==}