Skip to content

Commit d47824a

Browse files
proof(SafeTOML): DISCHARGE isScalarCorrect via 10-arm case-split (proven#90, #107) (#113)
Mirror of [#112 SafeYAML](#112) — same case-split shape for TOMLValue's 10 constructors. \`\`\`idris public export isScalarCorrect : (val : TOMLValue) -> isScalar val = True -> not (isTable val || isArray val) = True isScalarCorrect (TString _) _ = Refl isScalarCorrect (TInt _) _ = Refl isScalarCorrect (TFloat _) _ = Refl isScalarCorrect (TBool _) _ = Refl isScalarCorrect (TDateTime _) _ = Refl isScalarCorrect (TDate _) _ = Refl isScalarCorrect (TTime _) _ = Refl isScalarCorrect (TArray _) Refl impossible isScalarCorrect (TInlineTable _) Refl impossible isScalarCorrect (TTable _) Refl impossible \`\`\` 7 scalar arms close by Refl (`not (False || False) = True`). 3 container arms have premise `False = True` (uninhabited). Refs #90 #107 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 031bcbb commit d47824a

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

src/Proven/SafeTOML/Proofs.idr

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,28 @@ parsedTypesCorrect (TArray _) = Refl
131131
parsedTypesCorrect (TInlineTable _) = Refl
132132
parsedTypesCorrect (TTable _) = Refl
133133

134-
||| OWED: `isScalar`, `isTable`, and `isArray` are pairwise disjoint on
135-
||| `TOMLValue` constructors. The seven scalar constructors (`TString`,
136-
||| `TInt`, `TFloat`, `TBool`, `TDateTime`, `TDate`, `TTime`) make
137-
||| `isScalar val = True`; the same constructors all make
138-
||| `isTable val = False` and `isArray val = False` (see
139-
||| `src/Proven/SafeTOML/Types.idr` L376-L393). The two propositions
140-
||| therefore agree by exhaustive case-split on `val`.
141-
|||
142-
||| Held back by Idris2 0.8.0 requiring an explicit ten-arm case-split
143-
||| on `val` to close the proof — for each scalar arm the
144-
||| `isScalar val = True` premise is already `Refl`, and the conclusion
145-
||| reduces to `not (False || False) = True` which is *also* `Refl`,
146-
||| but the three non-scalar arms (`TArray`, `TInlineTable`, `TTable`)
147-
||| make the premise `False = True`, requiring an `absurd`/`uninhabited`
148-
||| witness that the elaborator does not derive automatically from the
149-
||| `Bool` decision shape. Same shape as boj-server's class-J
150-
||| `Bool`-vs-`Prop` reflection gap (see SafetyLemmas `charEqSound`).
151-
||| Discharge once a reflective `Bool`-to-`Dec` lemma is wired up for
152-
||| derived enum-shaped predicates, or by hand-writing the ten-arm
153-
||| case-split with one `Refl` per arm and `absurd Refl` for the three
154-
||| `True = False` branches.
155-
0 isScalarCorrect : (val : TOMLValue) ->
156-
isScalar val = True ->
157-
not (isTable val || isArray val) = True
134+
||| DISCHARGED via 10-arm case-split: the 7 scalar arms (`TString`,
135+
||| `TInt`, `TFloat`, `TBool`, `TDateTime`, `TDate`, `TTime`) close by
136+
||| `Refl` since the goal `not (isTable val || isArray val) = True`
137+
||| reduces to `not (False || False) = True` = `Refl`. The 3 container
138+
||| arms (`TArray`, `TInlineTable`, `TTable`) have the premise
139+
||| `isScalar val = True` reduce to `False = True` which is uninhabited
140+
||| (`Refl impossible`). The OWED note correctly identified the
141+
||| ten-arm discharge shape — just hadn't executed.
142+
public export
143+
isScalarCorrect : (val : TOMLValue) ->
144+
isScalar val = True ->
145+
not (isTable val || isArray val) = True
146+
isScalarCorrect (TString _) _ = Refl
147+
isScalarCorrect (TInt _) _ = Refl
148+
isScalarCorrect (TFloat _) _ = Refl
149+
isScalarCorrect (TBool _) _ = Refl
150+
isScalarCorrect (TDateTime _) _ = Refl
151+
isScalarCorrect (TDate _) _ = Refl
152+
isScalarCorrect (TTime _) _ = Refl
153+
isScalarCorrect (TArray _) Refl impossible
154+
isScalarCorrect (TInlineTable _) Refl impossible
155+
isScalarCorrect (TTable _) Refl impossible
158156

159157
||| Theorem: Scalars cannot contain nested structures
160158
export

0 commit comments

Comments
 (0)