Skip to content

Commit a56564a

Browse files
hyperpolymathclaude
andcommitted
proof(SafeJson): DISCHARGE appendLengthInc via lengthSnoc + plusCommutative
`append v (JsonArray arr) = JsonArray (arr ++ [v])` (SafeJson.idr L233-234), so the goal reduces to `Just (length (arr ++ [v])) = Just (length arr + 1)`. Two-step proof: 1. lengthSnoc arr v : length (arr ++ [v]) = S (length arr) 2. plusCommutative 1 (length arr) : 1 + length arr = length arr + 1 (where 1 + n = S n by Nat addition) Combined via `trans` inside `cong Just`: - appendLengthInc v arr = cong Just (trans (lengthSnoc arr v) (plusCommutative 1 (length arr))) Adds Data.List.Equalities (contrib, already used by #97 SafeUrl + #124 SafeBuffer) and Data.Nat for plusCommutative. Surfaced by the post-empirical re-audit (proven#119). Refs #90 #107 #119 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 52a8dd3 commit a56564a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/Proven/SafeJson/Proofs.idr

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ module Proven.SafeJson.Proofs
99
import Proven.Core
1010
import Proven.SafeJson
1111
import Data.List
12+
import Data.List.Equalities
1213
import Data.List.Quantifiers
14+
import Data.Nat
1315

1416
%default total
1517

@@ -193,10 +195,17 @@ prependLengthInc v arr = Refl
193195
||| `Data.List.lengthAppendSingleton` lemma. Discharge by composing
194196
||| `lengthAppend` + `plusZeroRightNeutral` + `S` congruence, or by
195197
||| adding a direct singleton-append lemma to base.
196-
public export
197-
0 appendLengthInc : (v : JsonValue) -> (arr : List JsonValue) ->
198-
arrayLength (append v (JsonArray arr)) =
199-
Just (length arr + 1)
198+
||| DISCHARGED: `append v (JsonArray arr) = JsonArray (arr ++ [v])`
199+
||| (SafeJson.idr L233-234), so the goal reduces to
200+
||| `Just (length (arr ++ [v])) = Just (length arr + 1)`. Apply
201+
||| `lengthSnoc arr v : length (arr ++ [v]) = S (length arr)`, then
202+
||| close the `S n` vs `n + 1` gap with `plusCommutative 1 n`.
203+
public export
204+
appendLengthInc : (v : JsonValue) -> (arr : List JsonValue) ->
205+
arrayLength (append v (JsonArray arr)) =
206+
Just (length arr + 1)
207+
appendLengthInc v arr =
208+
cong Just (trans (lengthSnoc arr v) (plusCommutative 1 (length arr)))
200209

201210
--------------------------------------------------------------------------------
202211
-- Path Access Properties

0 commit comments

Comments
 (0)