Skip to content

Commit 2deab08

Browse files
committed
chore: explicit postulate sweep for bodyless declarations (standards#158)
1 parent c0a762f commit 2deab08

42 files changed

Lines changed: 360 additions & 360 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Proven/SafeAPIKey/Proofs.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fullMaskStructure _ = Refl
105105
||| Discharge once a `DecEq KeyFormat` instance is exposed alongside a
106106
||| Bool-Prop reflection lemma for `==`, or once `mkAPIKeyWithFormat`
107107
||| is refactored to case-split on `decEq key.format expected`.
108-
0 formatMismatchRejected : (expected : KeyFormat) -> (s : String) ->
108+
postulate 0 formatMismatchRejected : (expected : KeyFormat) -> (s : String) ->
109109
(key : APIKey) ->
110110
mkAPIKey s = Just key ->
111111
Not (key.format = expected) ->

src/Proven/SafeArchive/Proofs.idr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ zeroCompressedNonZeroUncompressedIsZipBomb = Refl
147147
||| OWED: A reasonably-compressed entry (ratio 100, well under 1000)
148148
||| is NOT a zip bomb. Blocked on Nat-literal opacity (standards#128).
149149
public export
150-
0 modestRatioNotZipBomb :
150+
postulate 0 modestRatioNotZipBomb :
151151
isZipBomb (MkArchiveEntry "x" RegularFile 1 100 Nothing) = False
152152

153153
||| OWED: An entry with compression ratio > 1000 IS a zip bomb. Same
154154
||| blocker.
155155
public export
156-
0 extremeRatioIsZipBomb :
156+
postulate 0 extremeRatioIsZipBomb :
157157
isZipBomb (MkArchiveEntry "x" RegularFile 1 1001 Nothing) = True
158158

159159
--------------------------------------------------------------------------------
@@ -201,10 +201,10 @@ symlinkNoTargetNotDangerous = Refl
201201
||| OWED: A path with no special characters has no traversal. Blocked
202202
||| on the String FFI family (`isInfixOf` / `isPrefixOf`).
203203
public export
204-
0 plainPathHasNoTraversal :
204+
postulate 0 plainPathHasNoTraversal :
205205
hasPathTraversal "normal.txt" = False
206206

207207
||| OWED: A path with ".." has traversal. Same blocker.
208208
public export
209-
0 dotDotPathHasTraversal :
209+
postulate 0 dotDotPathHasTraversal :
210210
hasPathTraversal "../etc/passwd" = True

src/Proven/SafeArgs/Proofs.idr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import Data.String
2929
||| Predicate: Argument length is bounded
3030
public export
3131
data BoundedArg : Nat -> String -> Type where
32-
MkBoundedArg : (maxLen : Nat) -> (arg : String) ->
32+
postulate MkBoundedArg : (maxLen : Nat) -> (arg : String) ->
3333
{auto prf : length (unpack arg) <= maxLen = True} ->
3434
BoundedArg maxLen arg
3535

3636
||| Predicate: Argument count is bounded
3737
public export
3838
data BoundedArgCount : Nat -> List String -> Type where
39-
MkBoundedArgCount : (maxCount : Nat) -> (args : List String) ->
39+
postulate MkBoundedArgCount : (maxCount : Nat) -> (args : List String) ->
4040
{auto prf : length args <= maxCount = True} ->
4141
BoundedArgCount maxCount args
4242

@@ -65,7 +65,7 @@ argCountPreventsExhaustion opts count tooMany = ()
6565
||| Predicate: Option value is in allowed list
6666
public export
6767
data AllowedValue : List String -> String -> Type where
68-
MkAllowedValue : (allowed : List String) -> (value : String) ->
68+
postulate MkAllowedValue : (allowed : List String) -> (value : String) ->
6969
{auto prf : value `elem` allowed = True} ->
7070
AllowedValue allowed value
7171

@@ -98,7 +98,7 @@ nonEmptyAllowedRestricts allowed value notEmpty notIn = ()
9898
||| Predicate: All required arguments are present
9999
public export
100100
data RequiredPresent : List ArgSpec -> ParsedArgs -> Type where
101-
MkRequiredPresent : (specs : List ArgSpec) -> (parsed : ParsedArgs) ->
101+
postulate MkRequiredPresent : (specs : List ArgSpec) -> (parsed : ParsedArgs) ->
102102
RequiredPresent specs parsed
103103

104104
||| Theorem: Required check prevents missing arguments
@@ -150,7 +150,7 @@ parseBool' str =
150150
||| `Eq`-instance reduction lemma for `toLower` are available — or
151151
||| once the parser is refactored to case-split via `DecEq` on a
152152
||| `Recognised` ADT.
153-
0 boolParsingComplete : (s : String) ->
153+
postulate 0 boolParsingComplete : (s : String) ->
154154
toLower s `elem` ["true", "yes", "1", "on",
155155
"false", "no", "0", "off"] = True ->
156156
isJust (parseBool' s) = True
@@ -168,7 +168,7 @@ parseBool' str =
168168
||| String FFI primitives are exposed with reflective lemmas, or
169169
||| once the parser is rewritten to fold over a typed `List Digit`
170170
||| with explicit sign handling.
171-
0 intParsingHandlesNegative : (s : String) ->
171+
postulate 0 intParsingHandlesNegative : (s : String) ->
172172
isPrefixOf "-" s = True ->
173173
all Prelude.Types.isDigit (Data.List.drop 1 (unpack s)) = True ->
174174
isJust (parseInteger s) = True
@@ -191,7 +191,7 @@ parseNat' str = do
191191
||| a sign-tracking spec lemma, or once `parseNat'` is rewritten
192192
||| without going through `Integer` (e.g. directly folding `Digit`
193193
||| values into `Nat`).
194-
0 natRejectsNegative : (s : String) ->
194+
postulate 0 natRejectsNegative : (s : String) ->
195195
isPrefixOf "-" s = True ->
196196
parseNat' s = Nothing
197197

src/Proven/SafeBase64/Proofs.idr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ isValidOutputChar v c = isValidBase64Char v c || isPaddingChar c ||
3131
||| Predicate: Output contains only valid Base64 characters
3232
public export
3333
data ValidBase64Output : Base64Variant -> String -> Type where
34-
MkValidBase64Output : (variant : Base64Variant) -> (s : String) ->
34+
postulate MkValidBase64Output : (variant : Base64Variant) -> (s : String) ->
3535
{auto prf : all (isValidOutputChar variant) (unpack s) = True} ->
3636
ValidBase64Output variant s
3737

3838
||| Predicate: Encoded length is correct
3939
public export
4040
data CorrectEncodedLength : Base64Variant -> Nat -> Nat -> Type where
41-
MkCorrectEncodedLength : (variant : Base64Variant) ->
41+
postulate MkCorrectEncodedLength : (variant : Base64Variant) ->
4242
(inputLen : Nat) -> (outputLen : Nat) ->
4343
{auto prf : outputLen = encodedLength variant inputLen} ->
4444
CorrectEncodedLength variant inputLen outputLen
4545

4646
||| Predicate: Decoded length is correct
4747
public export
4848
data CorrectDecodedLength : Nat -> Nat -> Nat -> Type where
49-
MkCorrectDecodedLength : (encodedLen : Nat) -> (padding : Nat) -> (outputLen : Nat) ->
49+
postulate MkCorrectDecodedLength : (encodedLen : Nat) -> (padding : Nat) -> (outputLen : Nat) ->
5050
{auto prf : outputLen = exactDecodedLength encodedLen padding} ->
5151
CorrectDecodedLength encodedLen padding outputLen
5252

@@ -57,7 +57,7 @@ data CorrectDecodedLength : Nat -> Nat -> Nat -> Type where
5757
||| Predicate: Encoding is reversible
5858
public export
5959
data RoundtripSuccess : Base64Variant -> List Bits8 -> Type where
60-
MkRoundtripSuccess : (variant : Base64Variant) -> (bytes : List Bits8) ->
60+
postulate MkRoundtripSuccess : (variant : Base64Variant) -> (bytes : List Bits8) ->
6161
{auto prf : decode variant (encodeBytesToString variant bytes) = Ok bytes} ->
6262
RoundtripSuccess variant bytes
6363

@@ -83,7 +83,7 @@ data RoundtripSuccess : Base64Variant -> List Bits8 -> Type where
8383
||| reflective tactic for `unpack` is available, or by hand-rolling a
8484
||| 64-arm exhaustive case-split over the alphabet (one `Refl` per
8585
||| character).
86-
0 standardAlphabetValid : (c : Char) -> c `elem` unpack standardAlphabet = True ->
86+
postulate 0 standardAlphabetValid : (c : Char) -> c `elem` unpack standardAlphabet = True ->
8787
isValidBase64Char Standard c = True
8888

8989
||| OWED: every character in the URL-safe Base64 alphabet
@@ -95,7 +95,7 @@ data RoundtripSuccess : Base64Variant -> List Bits8 -> Type where
9595
||| `String` at the type level — same FFI-primitive blocker as
9696
||| `standardAlphabetValid` above. Discharge by the same mechanism
9797
||| (`Data.String` reflective tactic or 64-arm exhaustive case-split).
98-
0 urlSafeAlphabetValid : (c : Char) -> c `elem` unpack urlSafeAlphabet = True ->
98+
postulate 0 urlSafeAlphabetValid : (c : Char) -> c `elem` unpack urlSafeAlphabet = True ->
9999
isValidBase64Char URLSafe c = True
100100

101101
||| OWED: the encoder `encodeBytesToString variant bytes` emits only
@@ -115,7 +115,7 @@ data RoundtripSuccess : Base64Variant -> List Bits8 -> Type where
115115
||| a `Data.String` `pack`/`unpack` reflective tactic is available, or
116116
||| by lifting the proof to the underlying `List Char` produced before
117117
||| `pack` (which IS reducible by induction on the 6-bit chunking).
118-
0 encodeOutputValid : (variant : Base64Variant) -> (bytes : List Bits8) ->
118+
postulate 0 encodeOutputValid : (variant : Base64Variant) -> (bytes : List Bits8) ->
119119
ValidBase64Output variant (encodeBytesToString variant bytes)
120120

121121
--------------------------------------------------------------------------------
@@ -142,7 +142,7 @@ paddedLengthCorrect n = Refl
142142
||| product-by-divisor is available, or by direct induction on
143143
||| `(n + 2) `div` 3` using the `divides`/`Mod 0` lemmas from
144144
||| `Data.Nat.Division`.
145-
0 paddedLengthMultipleOf4 : (variant : Base64Variant) -> usesPadding variant = True ->
145+
postulate 0 paddedLengthMultipleOf4 : (variant : Base64Variant) -> usesPadding variant = True ->
146146
(n : Nat) -> (encodedLength variant n) `mod` 4 = 0
147147

148148
||| OWED: `decodedLength encodedLen <= (encodedLen * 3) `div` 4 + 1`
@@ -159,7 +159,7 @@ paddedLengthCorrect n = Refl
159159
||| `Bool`-reflective `lteSucc` is wired up, or by hand-writing
160160
||| `decideEq` over the underlying `Nat` to convert the `LTE` proof
161161
||| to its `Bool` form.
162-
0 decodedLengthBound : (encodedLen : Nat) ->
162+
postulate 0 decodedLengthBound : (encodedLen : Nat) ->
163163
decodedLength encodedLen <= (encodedLen * 3) `div` 4 + 1 = True
164164

165165
||| OWED: for non-empty input (`n > 0 = True`), `encodedLength variant
@@ -179,7 +179,7 @@ paddedLengthCorrect n = Refl
179179
||| available, or by chained applications of `lteMultRight`/
180180
||| `divLteRight` after refactoring `encodedLength` to expose a
181181
||| `total` divisor.
182-
0 encodingIncreasesLength : (variant : Base64Variant) -> (n : Nat) -> n > 0 = True ->
182+
postulate 0 encodingIncreasesLength : (variant : Base64Variant) -> (n : Nat) -> n > 0 = True ->
183183
encodedLength variant n >= n = True
184184

185185
--------------------------------------------------------------------------------
@@ -206,7 +206,7 @@ paddedLengthCorrect n = Refl
206206
||| `List Bits8 -> List (Fin 64) -> List Char -> List (Fin 64) ->
207207
||| List Bits8` decomposition where each leg IS reducible by
208208
||| structural induction.
209-
0 roundtripCorrect : (variant : Base64Variant) -> (bytes : List Bits8) ->
209+
postulate 0 roundtripCorrect : (variant : Base64Variant) -> (bytes : List Bits8) ->
210210
decode variant (encodeBytesToString variant bytes) = Ok bytes
211211

212212
||| OWED: round-trip on the empty input, `decode variant
@@ -224,7 +224,7 @@ paddedLengthCorrect n = Refl
224224
||| the same mechanism, or as a one-off `Refl` once the encoder's
225225
||| `pack`/`unpack` wrappers are reduced manually via a `Data.String`
226226
||| reflective tactic.
227-
0 roundtripEmpty : (variant : Base64Variant) ->
227+
postulate 0 roundtripEmpty : (variant : Base64Variant) ->
228228
decode variant (encodeBytesToString variant []) = Ok []
229229

230230
||| OWED: round-trip on a single byte, `decode variant
@@ -242,7 +242,7 @@ paddedLengthCorrect n = Refl
242242
||| as `roundtripCorrect`. Discharge once a `Data.Bits` reflective
243243
||| tactic for `shiftL`/`shiftR`/`.&.` is available alongside the
244244
||| `Data.String` `pack`/`unpack` tactic.
245-
0 roundtripSingleByte : (variant : Base64Variant) -> (b : Bits8) ->
245+
postulate 0 roundtripSingleByte : (variant : Base64Variant) -> (b : Bits8) ->
246246
decode variant (encodeBytesToString variant [b]) = Ok [b]
247247

248248
||| OWED: string-level round-trip, `decodeToString variant
@@ -258,7 +258,7 @@ paddedLengthCorrect n = Refl
258258
||| and `SafeHtml.escapePreservesNoLT`. Discharge once a
259259
||| `Data.String` reflective tactic exposes `pack (unpack s) = s` and
260260
||| `roundtripCorrect` is itself discharged.
261-
0 roundtripString : (variant : Base64Variant) -> (s : String) ->
261+
postulate 0 roundtripString : (variant : Base64Variant) -> (s : String) ->
262262
decodeToString variant (encodeStringToString variant s) = Ok s
263263

264264
--------------------------------------------------------------------------------
@@ -281,7 +281,7 @@ paddedLengthCorrect n = Refl
281281
||| `Data.String` reflective tactic exposes `length (unpack (pack
282282
||| xs)) = length xs` (i.e. `pack`/`unpack` preserve length), then
283283
||| `Refl` closes against the shared chunking step.
284-
0 variantsEqualLength : (bytes : List Bits8) ->
284+
postulate 0 variantsEqualLength : (bytes : List Bits8) ->
285285
length (unpack (encodeBytesToString Standard bytes)) =
286286
length (unpack (encodeBytesToString URLSafe bytes))
287287

@@ -298,7 +298,7 @@ paddedLengthCorrect n = Refl
298298
||| True`. Same blocker family as `decodedLengthBound`. Discharge by
299299
||| the same mechanism (`Data.String` `unpack` + `Data.Nat`/`Bool`
300300
||| `lte` reflective tactics).
301-
0 noPadShorter : (bytes : List Bits8) ->
301+
postulate 0 noPadShorter : (bytes : List Bits8) ->
302302
let standardLen = length (unpack (encodeBytesToString Standard bytes))
303303
noPadLen = length (unpack (encodeBytesToString URLSafeNoPad bytes))
304304
in noPadLen <= standardLen = True
@@ -326,7 +326,7 @@ paddedLengthCorrect n = Refl
326326
||| canonical Idris2 enhancement #2400-series), or by routing the
327327
||| scrutinee through a `decideEq`-style helper that returns the
328328
||| equation explicitly.
329-
0 decodeNeverCrashes : (variant : Base64Variant) -> (input : String) ->
329+
postulate 0 decodeNeverCrashes : (variant : Base64Variant) -> (input : String) ->
330330
Either (err : Base64Error ** decode variant input = Err err)
331331
(bytes : List Bits8 ** decode variant input = Ok bytes)
332332

@@ -346,7 +346,7 @@ paddedLengthCorrect n = Refl
346346
||| reflective tactic for `unpack`/`elem` is available, or by
347347
||| refactoring the decoder to return a `Dec`-style witness alongside
348348
||| each rejection.
349-
0 invalidCharDetected : (variant : Base64Variant) -> (input : String) ->
349+
postulate 0 invalidCharDetected : (variant : Base64Variant) -> (input : String) ->
350350
(c : Char) -> (pos : Nat) ->
351351
c `elem` unpack input = True ->
352352
not (isValidBase64Char variant c) = True ->
@@ -374,7 +374,7 @@ index' (S k) (_ :: xs) = index' k xs
374374
||| `invalidCharDetected`. Discharge once a `Data.String` reflective
375375
||| tactic for `unpack` / `index'` is available, or by refactoring
376376
||| `decode` to thread an explicit position-validation `Dec` witness.
377-
0 invalidPaddingDetected : (input : String) ->
377+
postulate 0 invalidPaddingDetected : (input : String) ->
378378
-- Padding not at end
379379
(pos : Nat) -> pos < (length (unpack input) `minus` 2) = True ->
380380
index' pos (unpack input) = Just '=' ->
@@ -399,7 +399,7 @@ index' (S k) (_ :: xs) = index' k xs
399399
||| `length . unpack . pack = length` and a `Data.List1` `split`
400400
||| reflective tactic is available, or by inductive proof over the
401401
||| encoder's line-wrap loop counter.
402-
0 mimeLineBreaksCorrect : (bytes : List Bits8) ->
402+
postulate 0 mimeLineBreaksCorrect : (bytes : List Bits8) ->
403403
let encoded = encodeBytesToString MIME bytes
404404
lines = forget (split (== '\n') encoded)
405405
in all (\l => length (unpack l) <= mimeLineLength + 1) lines = True
@@ -423,7 +423,7 @@ stripWhitespace s = pack (filter (not . isBase64Whitespace) (unpack s))
423423
||| tactic exposes `pack (filter p (unpack s))` as a `Refl`-able
424424
||| operation, or by refactoring `decode MIME` to take the already-
425425
||| stripped `String` as an explicit pre-condition.
426-
0 mimeIgnoresWhitespace : (encoded : String) -> (withWs : String) ->
426+
postulate 0 mimeIgnoresWhitespace : (encoded : String) -> (withWs : String) ->
427427
stripWhitespace withWs = encoded ->
428428
decode MIME withWs = decode MIME encoded
429429

@@ -446,7 +446,7 @@ stripWhitespace s = pack (filter (not . isBase64Whitespace) (unpack s))
446446
||| tactic for `pack`/`unpack` is available, or by lifting the proof
447447
||| to the underlying pre-`pack` `List Char` where the alphabet table
448448
||| lookup IS reducible (one `Refl` per Fin 64 index).
449-
0 urlSafeContainsNoUnsafe : (bytes : List Bits8) ->
449+
postulate 0 urlSafeContainsNoUnsafe : (bytes : List Bits8) ->
450450
let encoded = encodeBytesToString URLSafe bytes
451451
in all (\c => c /= '+' && c /= '/') (unpack encoded) = True
452452

@@ -467,7 +467,7 @@ stripWhitespace s = pack (filter (not . isBase64Whitespace) (unpack s))
467467
||| or by lifting to the pre-`pack` `List (Fin 64)` representation
468468
||| and case-splitting on whether `62 \`elem\` indices` or
469469
||| `63 \`elem\` indices`.
470-
0 standardMayContainUnsafe : (bytes : List Bits8) ->
470+
postulate 0 standardMayContainUnsafe : (bytes : List Bits8) ->
471471
Either ('+' `elem` unpack (encodeBytesToString Standard bytes) = True)
472472
(Either ('/' `elem` unpack (encodeBytesToString Standard bytes) = True)
473473
(all (\c => c /= '+' && c /= '/') (unpack (encodeBytesToString Standard bytes)) = True))
@@ -494,7 +494,7 @@ stripWhitespace s = pack (filter (not . isBase64Whitespace) (unpack s))
494494
||| `Data.Nat.Division` `divides`-elimination lemmas after
495495
||| introducing `(k : Nat) ** n = 3 * k` from the `n `mod` 3 = 0`
496496
||| hypothesis.
497-
0 threeToFourRatio : (n : Nat) -> (n `mod` 3 = 0) = True ->
497+
postulate 0 threeToFourRatio : (n : Nat) -> (n `mod` 3 = 0) = True ->
498498
encodedLength Standard n = (n `div` 3) * 4
499499

500500
||| Count padding characters in a string
@@ -520,7 +520,7 @@ countPadding s = length (filter (== '=') (unpack s))
520520
||| is available alongside a `Data.Nat` `mod`-elimination tactic, or
521521
||| by case-splitting on `n `mod` 3 ∈ {0,1,2}` and lifting to the
522522
||| pre-`pack` `List Char` where padding emission IS reducible.
523-
0 paddingMatchesRemainder : (variant : Base64Variant) -> usesPadding variant = True ->
523+
postulate 0 paddingMatchesRemainder : (variant : Base64Variant) -> usesPadding variant = True ->
524524
(n : Nat) ->
525525
let remainder = n `mod` 3
526526
encoded = encodeBytesToString variant (replicate n 0)
@@ -544,7 +544,7 @@ countPadding s = length (filter (== '=') (unpack s))
544544
||| `roundtripCorrect` is discharged: the proof body is then a pair
545545
||| of `roundtripCorrect variant bytes1` and `roundtripCorrect
546546
||| variant bytes2`.
547-
0 segmentedRoundtrip : (variant : Base64Variant) -> (bytes1 : List Bits8) -> (bytes2 : List Bits8) ->
547+
postulate 0 segmentedRoundtrip : (variant : Base64Variant) -> (bytes1 : List Bits8) -> (bytes2 : List Bits8) ->
548548
let enc1 = encodeBytesToString variant bytes1
549549
enc2 = encodeBytesToString variant bytes2
550550
in (decode variant enc1 = Ok bytes1,

src/Proven/SafeBloom/Proofs.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,6 @@ intersectionPreservesHashes a b c prf with (a.size /= b.size || a.numHashes /= b
169169
||| (`ord`, `unpack`) that Idris2 0.8.0 cannot type-level reduce; the
170170
||| claim therefore lives as an explicit, named assumption.
171171
public export
172-
0 noFalseNegatives :
172+
postulate 0 noFalseNegatives :
173173
(v : String) -> (bf : BloomFilter) -> LT 0 bf.size -> LT 0 bf.numHashes
174174
-> isInfixOf v (insert v bf) = True

0 commit comments

Comments
 (0)