You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
("u8_add_mod", "val u8_add_mod: a:UInt8.t -> b:UInt8.t -> Lemma (UInt8.v (UInt8.add_mod a b) == (UInt8.v a + UInt8.v b) % 256)", "let u8_add_mod a b = ()"),
259
+
("u32_shift_left", "val u32_shift_left: a:UInt32.t -> s:UInt32.t{UInt32.v s < 32} -> Lemma (UInt32.v (UInt32.shift_left a s) == (UInt32.v a * pow2 (UInt32.v s)) % pow2 32)", ""),
260
+
("u64_logand_comm", "val u64_logand_comm: a:UInt64.t -> b:UInt64.t -> Lemma (UInt64.logand a b == UInt64.logand b a)", "let u64_logand_comm a b = UInt64.logand_commutative a b"),
261
+
("i32_add_overflow", "val i32_add_overflow: a:Int32.t -> b:Int32.t -> Lemma (requires Int32.v a + Int32.v b < pow2 31 /\\ Int32.v a + Int32.v b >= -(pow2 31)) (ensures Int32.v (Int32.add a b) == Int32.v a + Int32.v b)", ""),
("u16_max_bound", "val u16_max_bound: a:UInt16.t -> Lemma (UInt16.v a < 65536)", "let u16_max_bound a = ()"),
266
+
]
267
+
268
+
parser_combinators = [
269
+
("parser_ret", "val parser_ret: #a:Type -> v:a -> parser a", "let parser_ret #a v = fun input -> Some (v, input)"),
270
+
("parser_bind", "val parser_bind: #a:Type -> #b:Type -> p:parser a -> f:(a -> parser b) -> parser b", "let parser_bind #a #b p f = fun input -> match p input with | None -> None | Some (v, rest) -> f v rest"),
271
+
("parser_map", "val parser_map: #a:Type -> #b:Type -> f:(a -> b) -> p:parser a -> parser b", "let parser_map #a #b f p = parser_bind p (fun v -> parser_ret (f v))"),
272
+
("parser_alt", "val parser_alt: #a:Type -> p1:parser a -> p2:parser a -> parser a", "let parser_alt #a p1 p2 = fun input -> match p1 input with | Some r -> Some r | None -> p2 input"),
273
+
("parser_many", "val parser_many: #a:Type -> p:parser a -> parser (list a)", "let rec parser_many #a p = parser_alt (parser_bind p (fun v -> parser_bind (parser_many p) (fun vs -> parser_ret (v :: vs)))) (parser_ret [])"),
274
+
("parser_char", "val parser_char: c:char -> parser char", "let parser_char c = fun input -> if Seq.length input > 0 && Seq.index input 0 = c then Some (c, Seq.slice input 1 (Seq.length input)) else None"),
("replay_protection", "val replay_protection: n:nonce -> log:list nonce -> Lemma (requires mem n log) (ensures reject n log)", "let replay_protection n log = ()"),
294
+
("forward_secrecy", "val forward_secrecy: sk:key -> pk:key -> Lemma (requires ephemeral sk) (ensures not (recoverable sk pk))", ""),
295
+
]
296
+
297
+
arrays_matrices = [
298
+
("array_swap", "val array_swap: #a:Type -> b:buffer a -> i:nat -> j:nat -> ST unit (requires fun h -> live h b /\\ i < length b /\\ j < length b) (ensures fun h0 _ h1 -> modifies (loc_buffer b) h0 h1 /\\ get h1 b i == get h0 b j /\\ get h1 b j == get h0 b i)", ""),
299
+
("array_fill", "val array_fill: b:buffer UInt8.t -> v:UInt8.t -> ST unit (requires fun h -> live h b) (ensures fun h0 _ h1 -> modifies (loc_buffer b) h0 h1 /\\ (forall (i:nat). i < length b ==> get h1 b i == v))", ""),
300
+
("matrix_index", "val matrix_index: #n:nat -> #m:nat -> mx:matrix n m -> i:nat{i < n} -> j:nat{j < m} -> Tot elem", "let matrix_index #n #m mx i j = Seq.index (Seq.index mx i) j"),
301
+
("matrix_transpose", "val matrix_transpose: #n:nat -> #m:nat -> mx:matrix n m -> Tot (matrix m n)", ""),
302
+
("dot_product", "val dot_product: #n:nat -> v1:vector n -> v2:vector n -> Tot int", "let dot_product #n v1 v2 = fold_left (+) 0 (map2 ( * ) v1 v2)"),
303
+
("array_sum_nonneg", "val array_sum_nonneg: b:buffer nat -> Lemma (requires forall (i:nat). i < length b ==> get h b i >= 0) (ensures array_sum b >= 0)", ""),
304
+
]
305
+
306
+
monad_laws = [
307
+
("option_left_id", "val option_left_id: #a:Type -> #b:Type -> x:a -> f:(a -> option b) -> Lemma (bind (Some x) f == f x)", "let option_left_id #a #b x f = ()"),
308
+
("option_right_id", "val option_right_id: #a:Type -> x:option a -> Lemma (bind x Some == x)", "let option_right_id #a x = match x with | None -> () | Some _ -> ()"),
309
+
("option_assoc", "val option_assoc: #a:Type -> #b:Type -> #c:Type -> x:option a -> f:(a -> option b) -> g:(b -> option c) -> Lemma (bind (bind x f) g == bind x (fun y -> bind (f y) g))", "let option_assoc #a #b #c x f g = match x with | None -> () | Some _ -> ()"),
310
+
("either_left_id", "val either_left_id: #e:Type -> #a:Type -> #b:Type -> x:a -> f:(a -> either e b) -> Lemma (either_bind (Right x) f == f x)", "let either_left_id #e #a #b x f = ()"),
311
+
("either_right_id", "val either_right_id: #e:Type -> #a:Type -> x:either e a -> Lemma (either_bind x Right == x)", "let either_right_id #e #a x = match x with | Left _ -> () | Right _ -> ()"),
312
+
("state_left_id", "val state_left_id: #s:Type -> #a:Type -> #b:Type -> x:a -> f:(a -> state s b) -> Lemma (state_bind (state_return x) f == f x)", "let state_left_id #s #a #b x f = ()"),
Copy file name to clipboardExpand all lines: scripts/extract_idris2.jl
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -259,6 +259,61 @@ function generate_synthetic_idris2()::Vector{Dict{String,Any}}
259
259
("chunksOfLength", "chunksOfLength : (k : Nat) -> {auto ok : NonZero k} -> (xs : Vect n a) -> length (chunksOf k xs) = divCeilNZ n k ok", ""),
260
260
]
261
261
262
+
bool_proofs = [
263
+
("andCommutative", "andCommutative : (a, b : Bool) -> a && b = b && a", "andCommutative True True = Refl\nandCommutative True False = Refl\nandCommutative False True = Refl\nandCommutative False False = Refl"),
264
+
("orCommutative", "orCommutative : (a, b : Bool) -> a || b = b || a", "orCommutative True True = Refl\norCommutative True False = Refl\norCommutative False True = Refl\norCommutative False False = Refl"),
265
+
("andAssociative", "andAssociative : (a, b, c : Bool) -> (a && b) && c = a && (b && c)", "andAssociative True b c = Refl\nandAssociative False b c = Refl"),
266
+
("orAssociative", "orAssociative : (a, b, c : Bool) -> (a || b) || c = a || (b || c)", "orAssociative True b c = Refl\norAssociative False b c = Refl"),
267
+
("andTrueNeutral", "andTrueNeutral : (a : Bool) -> a && True = a", "andTrueNeutral True = Refl\nandTrueNeutral False = Refl"),
268
+
("orFalseNeutral", "orFalseNeutral : (a : Bool) -> a || False = a", "orFalseNeutral True = Refl\norFalseNeutral False = Refl"),
269
+
("notInvolutive", "notInvolutive : (a : Bool) -> not (not a) = a", "notInvolutive True = Refl\nnotInvolutive False = Refl"),
270
+
("deMorganAnd", "deMorganAnd : (a, b : Bool) -> not (a && b) = not a || not b", "deMorganAnd True True = Refl\ndeMorganAnd True False = Refl\ndeMorganAnd False True = Refl\ndeMorganAnd False False = Refl"),
("mapFstCompose", "mapFstCompose : (f : b -> c) -> (g : a -> b) -> (p : (a, d)) -> mapFst f (mapFst g p) = mapFst (f . g) p", "mapFstCompose f g (x, y) = Refl"),
("snocCast", "snocCast : (xs : List a) -> cast (cast xs : SnocList a) = xs", ""),
288
+
]
289
+
290
+
proof_search = [
291
+
("autoRefl", "autoRefl : {auto prf : x = x} -> x = x", "autoRefl {prf} = prf"),
292
+
("autoLTE", "autoLTE : {auto prf : LTE n m} -> LTE n m", "autoLTE {prf} = prf"),
293
+
("decideEq", "decideEq : DecEq a => (x, y : a) -> Either (x = y) (Not (x = y))", "decideEq x y = case decEq x y of { Yes prf => Left prf; No contra => Right contra }"),
("autoShow", "autoShow : Show a => a -> String", "autoShow x = show x"),
296
+
]
297
+
298
+
with_views = [
299
+
("filterView", "filterView : (p : a -> Bool) -> (xs : List a) -> List a", "filterView p [] = []\nfilterView p (x :: xs) with (p x)\n _ | True = x :: filterView p xs\n _ | False = filterView p xs"),
300
+
("lookupView", "lookupView : DecEq k => k -> List (k, v) -> Maybe v", "lookupView key [] = Nothing\nlookupView key ((k, v) :: xs) with (decEq key k)\n _ | Yes _ = Just v\n _ | No _ = lookupView key xs"),
301
+
("insertSorted", "insertSorted : Ord a => a -> List a -> List a", "insertSorted x [] = [x]\ninsertSorted x (y :: ys) with (compare x y)\n _ | LT = x :: y :: ys\n _ | EQ = x :: y :: ys\n _ | GT = y :: insertSorted x ys"),
302
+
("splitAt", "splitAt : (n : Nat) -> (xs : Vect (n + m) a) -> (Vect n a, Vect m a)", "splitAt Z xs = ([], xs)\nsplitAt (S k) (x :: xs) = let (ys, zs) = splitAt k xs in (x :: ys, zs)"),
303
+
("mergeView", "mergeView : Ord a => List a -> List a -> List a", "mergeView [] ys = ys\nmergeView xs [] = xs\nmergeView (x :: xs) (y :: ys) with (compare x y)\n _ | LT = x :: mergeView xs (y :: ys)\n _ | _ = y :: mergeView (x :: xs) ys"),
304
+
("groupByView", "groupByView : (a -> a -> Bool) -> List a -> List (List a)", ""),
305
+
]
306
+
307
+
cong_rewrite = [
308
+
("congSucc", "congSucc : n = m -> S n = S m", "congSucc Refl = Refl"),
309
+
("congPlus", "congPlus : a = b -> c = d -> a + c = b + d", "congPlus Refl Refl = Refl"),
310
+
("congMap", "congMap : (f : a -> b) -> x = y -> f x = f y", "congMap f Refl = Refl"),
311
+
("transEq", "transEq : a = b -> b = c -> a = c", "transEq Refl Refl = Refl"),
312
+
("symEq", "symEq : a = b -> b = a", "symEq Refl = Refl"),
313
+
("replaceEq", "replaceEq : (0 p : a -> Type) -> x = y -> p x -> p y", "replaceEq p Refl px = px"),
0 commit comments