full_name
stringlengths 7
25
| prop_defn
stringlengths 39
240
| prop_loc
stringlengths 29
35
| score
int64 1
5
| deps
stringlengths 14
4.98k
| proof_state
stringlengths 17
160
| file_locs
stringlengths 29
73
|
---|---|---|---|---|---|---|
prop_01 | theorem prop_01 (n: Nat) (xs: List α) :
List.take n xs ++ List.drop n xs = xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:19 | 5 | import Mathlib | α : Type u_1
n : ℕ
xs : List α
⊢ List.take n xs ++ List.drop n xs = xs | LeanSrc/LeanSrc/Properties.lean:20 |
prop_02 | theorem prop_02 (n: Nat) (xs: List Nat) (ys: List Nat) :
List.count n xs + List.count n ys = List.count n (xs ++ ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:23 | 5 | import Mathlib | n : ℕ
xs ys : List ℕ
⊢ List.count n xs + List.count n ys = List.count n (xs ++ ys) | LeanSrc/LeanSrc/Properties.lean:24 |
prop_03 | theorem prop_03 (n: Nat) (xs: List Nat) (ys: List Nat) :
List.count n xs <= List.count n (xs ++ ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:27 | 4 | import Mathlib | n : ℕ
xs ys : List ℕ
⊢ List.count n xs ≤ List.count n (xs ++ ys) | LeanSrc/LeanSrc/Properties.lean:28 |
prop_04 | theorem prop_04 (n: Nat) (xs: List Nat) :
(List.count n xs).succ = List.count n (n :: xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:31 | 3 | import Mathlib | n : ℕ
xs : List ℕ
⊢ (List.count n xs).succ = List.count n (n :: xs) | LeanSrc/LeanSrc/Properties.lean:32 |
prop_05 | theorem prop_05 (n: Nat) (x: Nat) (xs: List Nat) :
(n = x) → (List.count n xs).succ = List.count n (x :: xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:35 | 4 | import Mathlib | n x : ℕ
xs : List ℕ
⊢ n = x → (List.count n xs).succ = List.count n (x :: xs) | LeanSrc/LeanSrc/Properties.lean:36 |
prop_06 | theorem prop_06 (n: Nat) (m: Nat) :
(n - (n + m) = 0):= by sorry | LeanSrc/LeanSrc/Properties.lean:39 | 2 | import Mathlib | n m : ℕ
⊢ n - (n + m) = 0 | LeanSrc/LeanSrc/Properties.lean:40 |
prop_07 | theorem prop_07 (n: Nat) (m: Nat) :
((n + m) - n = m):= by sorry | LeanSrc/LeanSrc/Properties.lean:43 | 1 | import Mathlib | n m : ℕ
⊢ n + m - n = m | LeanSrc/LeanSrc/Properties.lean:44 |
prop_08 | theorem prop_08 (k:Nat) (m: Nat) (n: Nat) :
((k + m) - (k + n) = m - n):= by sorry | LeanSrc/LeanSrc/Properties.lean:47 | 3 | import Mathlib | k m n : ℕ
⊢ k + m - (k + n) = m - n | LeanSrc/LeanSrc/Properties.lean:48 |
prop_09 | theorem prop_09 (i: Nat) (j: Nat) (k: Nat) :
((i - j) - k = i - (j + k)):= by sorry | LeanSrc/LeanSrc/Properties.lean:51 | 2 | import Mathlib | i j k : ℕ
⊢ i - j - k = i - (j + k) | LeanSrc/LeanSrc/Properties.lean:52 |
prop_10 | theorem prop_10 (m: Nat) :
(m - m = 0):= by sorry | LeanSrc/LeanSrc/Properties.lean:55 | 1 | import Mathlib | m : ℕ
⊢ m - m = 0 | LeanSrc/LeanSrc/Properties.lean:56 |
prop_11 | theorem prop_11 (xs: List α) :
(List.drop 0 xs = xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:59 | 3 | import Mathlib | α : Type u_1
xs : List α
⊢ List.drop 0 xs = xs | LeanSrc/LeanSrc/Properties.lean:60 |
prop_12 | theorem prop_12 (n: Nat) (f: α → α) (xs: List α) :
(List.drop n (List.map f xs) = List.map f (List.drop n xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:63 | 5 | import Mathlib | α : Type u_1
n : ℕ
f : α → α
xs : List α
⊢ List.drop n (List.map f xs) = List.map f (List.drop n xs) | LeanSrc/LeanSrc/Properties.lean:64 |
prop_13 | theorem prop_13 (n: Nat) (x: α) (xs: List α) :
(List.drop n.succ (x :: xs) = List.drop n xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:67 | 5 | import Mathlib | α : Type u_1
n : ℕ
x : α
xs : List α
⊢ List.drop n.succ (x :: xs) = List.drop n xs | LeanSrc/LeanSrc/Properties.lean:68 |
prop_14 | theorem prop_14 (p: α → Bool) (xs: List α) (ys: List α) :
(List.filter p (xs ++ ys) = (List.filter p xs) ++ (List.filter p ys)):= by sorry | LeanSrc/LeanSrc/Properties.lean:71 | 5 | import Mathlib | α : Type u_1
p : α → Bool
xs ys : List α
⊢ List.filter p (xs ++ ys) = List.filter p xs ++ List.filter p ys | LeanSrc/LeanSrc/Properties.lean:72 |
prop_15 | theorem prop_15 (x: Nat) (xs: List Nat) :
(List.length (ins x xs)) = (List.length xs).succ:= by sorry | LeanSrc/LeanSrc/Properties.lean:75 | 5 | import Mathlib
def ins: Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if (n < x) then n :: x :: xs else x :: (ins n xs)
| x : ℕ
xs : List ℕ
⊢ (ins x xs).length = xs.length.succ | LeanSrc/LeanSrc/Definitions.lean:202&&LeanSrc/LeanSrc/Properties.lean:76 |
prop_16 | theorem prop_16 (x: Nat) (xs: List Nat) :
xs = [] → last (x::xs) = x:= by sorry | LeanSrc/LeanSrc/Properties.lean:79 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
| x : ℕ
xs : List ℕ
⊢ xs = [] → last (x :: xs) = x | LeanSrc/LeanSrc/Definitions.lean:207&&LeanSrc/LeanSrc/Properties.lean:80 |
prop_17 | theorem prop_17 (n: Nat) :
n <= 0 ↔ n = 0:= by sorry | LeanSrc/LeanSrc/Properties.lean:83 | 1 | import Mathlib | n : ℕ
⊢ n ≤ 0 ↔ n = 0 | LeanSrc/LeanSrc/Properties.lean:84 |
prop_18 | theorem prop_18 i (m: Nat) :
i < (i + m).succ:= by sorry | LeanSrc/LeanSrc/Properties.lean:87 | 2 | import Mathlib | i m : ℕ
⊢ i < (i + m).succ | LeanSrc/LeanSrc/Properties.lean:88 |
prop_19 | theorem prop_19 (n: Nat) (xs: List Nat) :
(List.length (List.drop n xs) = List.length xs - n):= by sorry | LeanSrc/LeanSrc/Properties.lean:91 | 5 | import Mathlib | n : ℕ
xs : List ℕ
⊢ (List.drop n xs).length = xs.length - n | LeanSrc/LeanSrc/Properties.lean:92 |
prop_20 | theorem prop_20 (xs: List Nat) :
(List.length (sort xs) = List.length xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:96 | 5 | import Mathlib
def insort : Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if n <= x then n::x::xs else x::(insort n xs)
def sort : List Nat → List Nat
| [] => []
| x::xs => insort x (sort xs)
| xs : List ℕ
⊢ (sort xs).length = xs.length | LeanSrc/LeanSrc/Definitions.lean:215&&LeanSrc/LeanSrc/Properties.lean:97 |
prop_21 | theorem prop_21 (n: Nat) (m: Nat) :
n <= (n + m):= by sorry | LeanSrc/LeanSrc/Properties.lean:100 | 1 | import Mathlib | n m : ℕ
⊢ n ≤ n + m | LeanSrc/LeanSrc/Properties.lean:101 |
prop_22 | theorem prop_22 (a: Nat) (b: Nat) (c: Nat) :
(max (max a b) c = max a (max b c)):= by sorry | LeanSrc/LeanSrc/Properties.lean:104 | 2 | import Mathlib | a b c : ℕ
⊢ max (max a b) c = max a (max b c) | LeanSrc/LeanSrc/Properties.lean:105 |
prop_23 | theorem prop_23 (a: Nat) (b: Nat) :
(max a b = max b a):= by sorry | LeanSrc/LeanSrc/Properties.lean:108 | 1 | import Mathlib | a b : ℕ
⊢ max a b = max b a | LeanSrc/LeanSrc/Properties.lean:109 |
prop_24 | theorem prop_24 (a: Nat) (b: Nat) :
(((max a b) = a) ↔ b <= a):= by sorry | LeanSrc/LeanSrc/Properties.lean:112 | 2 | import Mathlib | a b : ℕ
⊢ max a b = a ↔ b ≤ a | LeanSrc/LeanSrc/Properties.lean:113 |
prop_25 | theorem prop_25 (a: Nat) (b: Nat) :
(((max a b) = b) ↔ a <= b):= by sorry | LeanSrc/LeanSrc/Properties.lean:116 | 2 | import Mathlib | a b : ℕ
⊢ max a b = b ↔ a ≤ b | LeanSrc/LeanSrc/Properties.lean:117 |
prop_26 | theorem prop_26 (x: α) (xs: List α) (ys: List α) :
x ∈ xs → x ∈ (xs ++ ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:120 | 4 | import Mathlib | α : Type u_1
x : α
xs ys : List α
⊢ x ∈ xs → x ∈ xs ++ ys | LeanSrc/LeanSrc/Properties.lean:121 |
prop_27 | theorem prop_27 (x: α) (xs: List α) (ys: List α) :
x ∈ ys → x ∈ (xs ++ ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:124 | 4 | import Mathlib | α : Type u_1
x : α
xs ys : List α
⊢ x ∈ ys → x ∈ xs ++ ys | LeanSrc/LeanSrc/Properties.lean:125 |
prop_28 | theorem prop_28 (x: α) (xs: List α) :
x ∈ (xs ++ [x]):= by sorry | LeanSrc/LeanSrc/Properties.lean:128 | 4 | import Mathlib | α : Type u_1
x : α
xs : List α
⊢ x ∈ xs ++ [x] | LeanSrc/LeanSrc/Properties.lean:129 |
prop_29 | theorem prop_29 (x: Nat) (xs: List Nat) :
x ∈ ins1 x xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:132 | 5 | import Mathlib
def ins1 : Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if n == x then x::xs else x::(ins1 n xs)
| x : ℕ
xs : List ℕ
⊢ x ∈ ins1 x xs | LeanSrc/LeanSrc/Definitions.lean:224&&LeanSrc/LeanSrc/Properties.lean:133 |
prop_30 | theorem prop_30 (x: Nat) (xs: List Nat) :
x ∈ ins x xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:136 | 5 | import Mathlib
def ins: Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if (n < x) then n :: x :: xs else x :: (ins n xs)
| x : ℕ
xs : List ℕ
⊢ x ∈ ins x xs | LeanSrc/LeanSrc/Definitions.lean:202&&LeanSrc/LeanSrc/Properties.lean:137 |
prop_31 | theorem prop_31 (a: Nat) (b: Nat) (c: Nat) :
min (min a b) c = min a (min b c):= by sorry | LeanSrc/LeanSrc/Properties.lean:140 | 2 | import Mathlib | a b c : ℕ
⊢ min (min a b) c = min a (min b c) | LeanSrc/LeanSrc/Properties.lean:141 |
prop_32 | theorem prop_32 (a: Nat) (b: Nat) :
min a b = min b a:= by sorry | LeanSrc/LeanSrc/Properties.lean:144 | 1 | import Mathlib | a b : ℕ
⊢ min a b = min b a | LeanSrc/LeanSrc/Properties.lean:145 |
prop_33 | theorem prop_33 (a: Nat) (b: Nat) :
min a b = a ↔ a <= b:= by sorry | LeanSrc/LeanSrc/Properties.lean:148 | 2 | import Mathlib | a b : ℕ
⊢ min a b = a ↔ a ≤ b | LeanSrc/LeanSrc/Properties.lean:149 |
prop_34 | theorem prop_34 (a: Nat) (b: Nat) :
min a b = b ↔ b <= a:= by sorry | LeanSrc/LeanSrc/Properties.lean:152 | 2 | import Mathlib | a b : ℕ
⊢ min a b = b ↔ b ≤ a | LeanSrc/LeanSrc/Properties.lean:153 |
prop_35 | theorem prop_35 (xs: List α) :
dropWhile (fun _ => False) xs = xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:156 | 5 | import Mathlib
def dropWhile : (α → Bool) → List α → List α
| _, [] => []
| p, x::xs => if p x then dropWhile p xs else x::xs
| α : Type u_1
xs : List α
⊢ dropWhile (fun x => decide False) xs = xs | LeanSrc/LeanSrc/Definitions.lean:228&&LeanSrc/LeanSrc/Properties.lean:157 |
prop_36 | theorem prop_36 (xs: List α) :
takeWhile (fun _ => True) xs = xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:160 | 5 | import Mathlib
def takeWhile : (α → Bool) → List α → List α
| _, [] => []
| p, x::xs => if p x then x ::(takeWhile p xs) else []
| α : Type u_1
xs : List α
⊢ takeWhile (fun x => decide True) xs = xs | LeanSrc/LeanSrc/Definitions.lean:232&&LeanSrc/LeanSrc/Properties.lean:161 |
prop_37 | theorem prop_37 (x: Nat) (xs: List Nat) :
not (x ∈ delete x xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:164 | 5 | import Mathlib
def delete : Nat → List Nat → List Nat
| _, [] => []
| n, x::xs => if n == x then (delete n xs) else x::(delete n xs)
| x : ℕ
xs : List ℕ
⊢ (!decide (x ∈ delete x xs)) = true | LeanSrc/LeanSrc/Definitions.lean:236&&LeanSrc/LeanSrc/Properties.lean:165 |
prop_38 | theorem prop_38 (n: Nat) (xs: List Nat) :
List.count n (xs ++ [n]) = (List.count n xs).succ:= by sorry | LeanSrc/LeanSrc/Properties.lean:168 | 4 | import Mathlib | n : ℕ
xs : List ℕ
⊢ List.count n (xs ++ [n]) = (List.count n xs).succ | LeanSrc/LeanSrc/Properties.lean:169 |
prop_39 | theorem prop_39 (n: Nat) (x: Nat) (xs: List Nat) :
List.count n [x] + List.count n xs = List.count n (x::xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:172 | 4 | import Mathlib | n x : ℕ
xs : List ℕ
⊢ List.count n [x] + List.count n xs = List.count n (x :: xs) | LeanSrc/LeanSrc/Properties.lean:173 |
prop_40 | theorem prop_40 (xs: List α) :
(List.take 0 xs = []):= by sorry | LeanSrc/LeanSrc/Properties.lean:176 | 3 | import Mathlib | α : Type u_1
xs : List α
⊢ List.take 0 xs = [] | LeanSrc/LeanSrc/Properties.lean:177 |
prop_41 | theorem prop_41 (n: Nat) (f: α → α) (xs: List α) :
(List.take n (List.map f xs) = List.map f (List.take n xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:180 | 5 | import Mathlib | α : Type u_1
n : ℕ
f : α → α
xs : List α
⊢ List.take n (List.map f xs) = List.map f (List.take n xs) | LeanSrc/LeanSrc/Properties.lean:181 |
prop_42 | theorem prop_42 (n: Nat) (x: α) (xs: List α) :
(List.take n.succ (x::xs) = x :: (List.take n xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:184 | 4 | import Mathlib | α : Type u_1
n : ℕ
x : α
xs : List α
⊢ List.take n.succ (x :: xs) = x :: List.take n xs | LeanSrc/LeanSrc/Properties.lean:185 |
prop_43 | theorem prop_43 (p: Nat → Bool) (xs: List Nat) :
(takeWhile p xs ++ dropWhile p xs = xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:188 | 5 | import Mathlib
def dropWhile : (α → Bool) → List α → List α
| _, [] => []
| p, x::xs => if p x then dropWhile p xs else x::xs
def takeWhile : (α → Bool) → List α → List α
| _, [] => []
| p, x::xs => if p x then x ::(takeWhile p xs) else []
| p : ℕ → Bool
xs : List ℕ
⊢ takeWhile p xs ++ dropWhile p xs = xs | LeanSrc/LeanSrc/Definitions.lean:232&&LeanSrc/LeanSrc/Properties.lean:189 |
prop_44 | theorem prop_44 (x: α) (xs: List α) (ys: List β) :
zip' (x::xs) ys = zipConcat x xs ys:= by sorry | LeanSrc/LeanSrc/Properties.lean:192 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
def zipConcat : α → List α → List β → List (α × β)
| _, _, [] => []
| x, xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
x : α
xs : List α
ys : List β
⊢ zip' (x :: xs) ys = zipConcat x xs ys | LeanSrc/LeanSrc/Definitions.lean:245&&LeanSrc/LeanSrc/Properties.lean:193 |
prop_45 | theorem prop_45 (x: α) (y: β) (xs: List α) (ys: List β) :
zip' (x::xs) (y::ys) = (x, y) :: zip' xs ys:= by sorry | LeanSrc/LeanSrc/Properties.lean:196 | 4 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
x : α
y : β
xs : List α
ys : List β
⊢ zip' (x :: xs) (y :: ys) = (x, y) :: zip' xs ys | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:197 |
prop_46 | theorem prop_46 {α β: Type} (xs: List β) :
zip' ([]: List α) xs = []:= by sorry | LeanSrc/LeanSrc/Properties.lean:200 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α β : Type
xs : List β
⊢ zip' [] xs = [] | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:201 |
prop_47 | theorem prop_47 (a: MyTree α) :
(height' (mirror a) = height' a):= by sorry | LeanSrc/LeanSrc/Properties.lean:204 | 5 | import Mathlib
inductive MyTree (α: Type) where
| leaf : MyTree α
| node : MyTree α → α → MyTree α → MyTree α
def height' : MyTree α → ℕ
| .leaf => 0
| .node l _x r => (max (height' l) (height' r)).succ
def mirror : MyTree α → MyTree α
| MyTree.leaf => MyTree.leaf
| MyTree.node l x r => MyTree.node r x l
| α : Type
a : MyTree α
⊢ height' (mirror a) = height' a | LeanSrc/LeanSrc/Definitions.lean:270&&LeanSrc/LeanSrc/Properties.lean:205 |
prop_48 | theorem prop_48 (xs: List Nat) :
not (null xs) → butlast xs ++ [last xs] = xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:208 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
def null : List α → Bool
| [] => True
| _ => False
def butlast : List α → List α
| [] => []
| [_x] => []
| x::xs => x::(butlast xs)
| xs : List ℕ
⊢ (!null xs) = true → butlast xs ++ [last xs] = xs | LeanSrc/LeanSrc/Definitions.lean:254&&LeanSrc/LeanSrc/Properties.lean:209 |
prop_49 | theorem prop_49 (xs: List Nat) (ys: List Nat) :
(butlast (xs ++ ys) = butlastConcat xs ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:212 | 4 | import Mathlib
def butlast : List α → List α
| [] => []
| [_x] => []
| x::xs => x::(butlast xs)
def butlastConcat : List α → List α → List α
| xs, [] => butlast xs
| xs, ys => xs ++ butlast ys
| xs ys : List ℕ
⊢ butlast (xs ++ ys) = butlastConcat xs ys | LeanSrc/LeanSrc/Definitions.lean:258&&LeanSrc/LeanSrc/Properties.lean:213 |
prop_50 | theorem prop_50 (xs: List α) :
(butlast xs = List.take (List.length xs - 1) xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:216 | 5 | import Mathlib
def butlast : List α → List α
| [] => []
| [_x] => []
| x::xs => x::(butlast xs)
| α : Type u_1
xs : List α
⊢ butlast xs = List.take (xs.length - 1) xs | LeanSrc/LeanSrc/Definitions.lean:254&&LeanSrc/LeanSrc/Properties.lean:217 |
prop_51 | theorem prop_51 (xs: List α) (x: α) :
(butlast (xs ++ [x]) = xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:220 | 5 | import Mathlib
def butlast : List α → List α
| [] => []
| [_x] => []
| x::xs => x::(butlast xs)
| α : Type u_1
xs : List α
x : α
⊢ butlast (xs ++ [x]) = xs | LeanSrc/LeanSrc/Definitions.lean:254&&LeanSrc/LeanSrc/Properties.lean:221 |
prop_52 | theorem prop_52 (n: Nat) xs :
(List.count n xs = List.count n (List.reverse xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:224 | 5 | import Mathlib | n : ℕ
xs : List ℕ
⊢ List.count n xs = List.count n xs.reverse | LeanSrc/LeanSrc/Properties.lean:225 |
prop_53 | theorem prop_53 (n: Nat) xs :
(List.count n xs = List.count n (sort xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:229 | 5 | import Mathlib
def insort : Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if n <= x then n::x::xs else x::(insort n xs)
def sort : List Nat → List Nat
| [] => []
| x::xs => insort x (sort xs)
| n : ℕ
xs : List ℕ
⊢ List.count n xs = List.count n (sort xs) | LeanSrc/LeanSrc/Definitions.lean:215&&LeanSrc/LeanSrc/Properties.lean:230 |
prop_54 | theorem prop_54 (n: Nat) (m: Nat) :
((m + n) - n = m):= by sorry | LeanSrc/LeanSrc/Properties.lean:233 | 2 | import Mathlib | n m : ℕ
⊢ m + n - n = m | LeanSrc/LeanSrc/Properties.lean:234 |
prop_55 | theorem prop_55 (n: Nat) (xs: List α) (ys: List α) :
(List.drop n (xs ++ ys) = List.drop n xs ++ List.drop (n - List.length xs) ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:237 | 5 | import Mathlib | α : Type u_1
n : ℕ
xs ys : List α
⊢ List.drop n (xs ++ ys) = List.drop n xs ++ List.drop (n - xs.length) ys | LeanSrc/LeanSrc/Properties.lean:238 |
prop_56 | theorem prop_56 (n: Nat) (m: Nat) (xs: List α) :
(List.drop n (List.drop m xs) = List.drop (n + m) xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:241 | 5 | import Mathlib | α : Type u_1
n m : ℕ
xs : List α
⊢ List.drop n (List.drop m xs) = List.drop (n + m) xs | LeanSrc/LeanSrc/Properties.lean:242 |
prop_57 | theorem prop_57 (n: Nat) (m: Nat) (xs: List α) :
(List.drop n (List.take m xs) = List.take (m - n) (List.drop n xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:245 | 5 | import Mathlib | α : Type u_1
n m : ℕ
xs : List α
⊢ List.drop n (List.take m xs) = List.take (m - n) (List.drop n xs) | LeanSrc/LeanSrc/Properties.lean:246 |
prop_58 | theorem prop_58 (n: Nat) (xs: List α) (ys: List β) :
(List.drop n (zip' xs ys) = zip' (List.drop n xs) (List.drop n ys)):= by sorry | LeanSrc/LeanSrc/Properties.lean:249 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
n : ℕ
xs : List α
ys : List β
⊢ List.drop n (zip' xs ys) = zip' (List.drop n xs) (List.drop n ys) | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:250 |
prop_59 | theorem prop_59 (xs: List Nat) (ys: List Nat) :
ys = [] → last (xs ++ ys) = last xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:253 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
| xs ys : List ℕ
⊢ ys = [] → last (xs ++ ys) = last xs | LeanSrc/LeanSrc/Definitions.lean:207&&LeanSrc/LeanSrc/Properties.lean:254 |
prop_60 | theorem prop_60 (xs: List Nat) (ys: List Nat) :
not (null ys) → last (xs ++ ys) = last ys:= by sorry | LeanSrc/LeanSrc/Properties.lean:257 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
def null : List α → Bool
| [] => True
| _ => False
| xs ys : List ℕ
⊢ (!null ys) = true → last (xs ++ ys) = last ys | LeanSrc/LeanSrc/Definitions.lean:249&&LeanSrc/LeanSrc/Properties.lean:258 |
prop_61 | theorem prop_61 (xs: List Nat) (ys: List Nat) :
(last (xs ++ ys) = lastOfTwo xs ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:261 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
def lastOfTwo : List ℕ → List ℕ → ℕ
| xs, [] => last xs
| _, ys => last ys
| xs ys : List ℕ
⊢ last (xs ++ ys) = lastOfTwo xs ys | LeanSrc/LeanSrc/Definitions.lean:262&&LeanSrc/LeanSrc/Properties.lean:262 |
prop_62 | theorem prop_62 (xs: List Nat) (x: Nat) :
not (null xs) → last (x::xs) = last xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:265 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
def null : List α → Bool
| [] => True
| _ => False
| xs : List ℕ
x : ℕ
⊢ (!null xs) = true → last (x :: xs) = last xs | LeanSrc/LeanSrc/Definitions.lean:249&&LeanSrc/LeanSrc/Properties.lean:266 |
prop_63 | theorem prop_63 (n: Nat) (xs: List Nat) :
n < List.length xs → last (List.drop n xs) = last xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:269 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
| n : ℕ
xs : List ℕ
⊢ n < xs.length → last (List.drop n xs) = last xs | LeanSrc/LeanSrc/Definitions.lean:207&&LeanSrc/LeanSrc/Properties.lean:270 |
prop_64 | theorem prop_64 x xs :
(last (xs ++ [x]) = x):= by sorry | LeanSrc/LeanSrc/Properties.lean:273 | 5 | import Mathlib
def last: List Nat → Nat
| [] => 0
| [x] => x
| _x::xs => (last xs)
| x : ℕ
xs : List ℕ
⊢ last (xs ++ [x]) = x | LeanSrc/LeanSrc/Definitions.lean:207&&LeanSrc/LeanSrc/Properties.lean:274 |
prop_65 | theorem prop_65 (i: Nat) (m: Nat) :
i < (m + i).succ:= by sorry | LeanSrc/LeanSrc/Properties.lean:277 | 2 | import Mathlib | i m : ℕ
⊢ i < (m + i).succ | LeanSrc/LeanSrc/Properties.lean:278 |
prop_66 | theorem prop_66 (p: α → Bool) (xs: List α) :
List.length (List.filter p xs) <= List.length xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:281 | 4 | import Mathlib | α : Type u_1
p : α → Bool
xs : List α
⊢ (List.filter p xs).length ≤ xs.length | LeanSrc/LeanSrc/Properties.lean:282 |
prop_67 | theorem prop_67 (xs: List Nat) :
List.length (butlast xs) = List.length xs - 1:= by sorry | LeanSrc/LeanSrc/Properties.lean:285 | 5 | import Mathlib
def butlast : List α → List α
| [] => []
| [_x] => []
| x::xs => x::(butlast xs)
| xs : List ℕ
⊢ (butlast xs).length = xs.length - 1 | LeanSrc/LeanSrc/Definitions.lean:254&&LeanSrc/LeanSrc/Properties.lean:286 |
prop_68 | theorem prop_68 (n: Nat) (xs: List Nat) :
List.length (delete n xs) <= List.length xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:289 | 5 | import Mathlib
def delete : Nat → List Nat → List Nat
| _, [] => []
| n, x::xs => if n == x then (delete n xs) else x::(delete n xs)
| n : ℕ
xs : List ℕ
⊢ (delete n xs).length ≤ xs.length | LeanSrc/LeanSrc/Definitions.lean:236&&LeanSrc/LeanSrc/Properties.lean:290 |
prop_69 | theorem prop_69 (n: Nat) (m: Nat) :
n <= (m + n):= by sorry | LeanSrc/LeanSrc/Properties.lean:293 | 1 | import Mathlib | n m : ℕ
⊢ n ≤ m + n | LeanSrc/LeanSrc/Properties.lean:294 |
prop_70 | theorem prop_70 m (n: Nat) :
m <= n → m <= n.succ:= by sorry | LeanSrc/LeanSrc/Properties.lean:297 | 1 | import Mathlib | m n : ℕ
⊢ m ≤ n → m ≤ n.succ | LeanSrc/LeanSrc/Properties.lean:298 |
prop_71 | theorem prop_71 (x:Nat) (y :Nat) (xs: List Nat) :
(x == y) = False → ((x ∈ (ins y xs)) == (x ∈ xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:301 | 5 | import Mathlib
def ins: Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if (n < x) then n :: x :: xs else x :: (ins n xs)
| x y : ℕ
xs : List ℕ
⊢ ((x == y) = true) = False → (decide (x ∈ ins y xs) == decide (x ∈ xs)) = true | LeanSrc/LeanSrc/Definitions.lean:202&&LeanSrc/LeanSrc/Properties.lean:302 |
prop_72 | theorem prop_72 (i: Nat) (xs: List α) :
(List.reverse (List.drop i xs) = List.take (List.length xs - i) (List.reverse xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:305 | 5 | import Mathlib | α : Type u_1
i : ℕ
xs : List α
⊢ (List.drop i xs).reverse = List.take (xs.length - i) xs.reverse | LeanSrc/LeanSrc/Properties.lean:306 |
prop_73 | theorem prop_73 (p: α → Bool) (xs: List α) :
(List.reverse (List.filter p xs) = List.filter p (List.reverse xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:309 | 5 | import Mathlib | α : Type u_1
p : α → Bool
xs : List α
⊢ (List.filter p xs).reverse = List.filter p xs.reverse | LeanSrc/LeanSrc/Properties.lean:310 |
prop_74 | theorem prop_74 (i: Nat) (xs: List α) :
(List.reverse (List.take i xs) = List.drop (List.length xs - i) (List.reverse xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:313 | 5 | import Mathlib | α : Type u_1
i : ℕ
xs : List α
⊢ (List.take i xs).reverse = List.drop (xs.length - i) xs.reverse | LeanSrc/LeanSrc/Properties.lean:314 |
prop_75 | theorem prop_75 (n: Nat) (m: Nat ) (xs: List Nat) :
(List.count n xs + List.count n [m] = List.count n (m :: xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:317 | 5 | import Mathlib | n m : ℕ
xs : List ℕ
⊢ List.count n xs + List.count n [m] = List.count n (m :: xs) | LeanSrc/LeanSrc/Properties.lean:318 |
prop_76 | theorem prop_76 (n: Nat) (m: Nat) (xs: List Nat) :
(n == m) = False → List.count n (xs ++ [m]) = List.count n xs:= by sorry | LeanSrc/LeanSrc/Properties.lean:321 | 5 | import Mathlib | n m : ℕ
xs : List ℕ
⊢ ((n == m) = true) = False → List.count n (xs ++ [m]) = List.count n xs | LeanSrc/LeanSrc/Properties.lean:322 |
prop_77 | theorem prop_77 (x: Nat) (xs: List Nat) :
sorted xs → sorted (insort x xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:325 | 5 | import Mathlib
def insort : Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if n <= x then n::x::xs else x::(insort n xs)
def sorted : List Nat → Bool
| [] => True
| [_x] => True
| x::y::xs => and (x <= y) (sorted (y::xs))
| x : ℕ
xs : List ℕ
⊢ sorted xs = true → sorted (insort x xs) = true | LeanSrc/LeanSrc/Definitions.lean:220&&LeanSrc/LeanSrc/Properties.lean:326 |
prop_78 | theorem prop_78 (xs: List Nat) :
sorted (sort xs):= by sorry | LeanSrc/LeanSrc/Properties.lean:330 | 5 | import Mathlib
def insort : Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if n <= x then n::x::xs else x::(insort n xs)
def sort : List Nat → List Nat
| [] => []
| x::xs => insort x (sort xs)
def sorted : List Nat → Bool
| [] => True
| [_x] => True
| x::y::xs => and (x <= y) (sorted (y::xs))
| xs : List ℕ
⊢ sorted (sort xs) = true | LeanSrc/LeanSrc/Definitions.lean:220&&LeanSrc/LeanSrc/Properties.lean:331 |
prop_79 | theorem prop_79 (m: Nat) (n: Nat) (k: Nat) :
((m.succ - n) - k.succ = (m - n) - k):= by sorry | LeanSrc/LeanSrc/Properties.lean:334 | 2 | import Mathlib | m n k : ℕ
⊢ m.succ - n - k.succ = m - n - k | LeanSrc/LeanSrc/Properties.lean:335 |
prop_80 | theorem prop_80 (n: Nat) (xs: List α) (ys: List α) :
(List.take n (xs ++ ys) = List.take n xs ++ List.take (n - List.length xs) ys):= by sorry | LeanSrc/LeanSrc/Properties.lean:338 | 5 | import Mathlib | α : Type u_1
n : ℕ
xs ys : List α
⊢ List.take n (xs ++ ys) = List.take n xs ++ List.take (n - xs.length) ys | LeanSrc/LeanSrc/Properties.lean:339 |
prop_81 | theorem prop_81 (n: Nat) (m: Nat) (xs: List α) :
(List.take n (List.drop m xs) = List.drop m (List.take (n + m) xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:343 | 5 | import Mathlib | α : Type u_1
n m : ℕ
xs : List α
⊢ List.take n (List.drop m xs) = List.drop m (List.take (n + m) xs) | LeanSrc/LeanSrc/Properties.lean:344 |
prop_82 | theorem prop_82 (n: Nat) (xs: List α) (ys: List β) :
(List.take n (zip' xs ys) = zip' (List.take n xs) (List.take n ys)):= by sorry | LeanSrc/LeanSrc/Properties.lean:347 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
n : ℕ
xs : List α
ys : List β
⊢ List.take n (zip' xs ys) = zip' (List.take n xs) (List.take n ys) | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:348 |
prop_83 | theorem prop_83 (xs: List α) (ys: List α) (zs: List β) :
(zip' (xs ++ ys) zs =
zip' xs (List.take (List.length xs) zs) ++ zip' ys (List.drop (List.length xs) zs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:351 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
xs ys : List α
zs : List β
⊢ zip' (xs ++ ys) zs = zip' xs (List.take xs.length zs) ++ zip' ys (List.drop xs.length zs) | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:353 |
prop_84 | theorem prop_84 (xs: List α) (ys: List β) (zs: List β) :
(zip' xs (ys ++ zs) =
zip' (List.take (List.length ys) xs) ys ++ zip' (List.drop (List.length ys) xs) zs):= by sorry | LeanSrc/LeanSrc/Properties.lean:356 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
xs : List α
ys zs : List β
⊢ zip' xs (ys ++ zs) = zip' (List.take ys.length xs) ys ++ zip' (List.drop ys.length xs) zs | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:358 |
prop_85 | theorem prop_85 (xs: List α) (ys: List β) :
(List.length xs = List.length ys) →
(zip' (List.reverse xs) (List.reverse ys) = List.reverse (zip' xs ys)):= by sorry | LeanSrc/LeanSrc/Properties.lean:363 | 5 | import Mathlib
def zip' : List α → List β → List (α × β)
| [], _ => []
| _, [] => []
| x::xs, y::ys => ⟨x, y⟩ :: zip' xs ys
| α : Type u_1
β : Type u_2
xs : List α
ys : List β
⊢ xs.length = ys.length → zip' xs.reverse ys.reverse = (zip' xs ys).reverse | LeanSrc/LeanSrc/Definitions.lean:241&&LeanSrc/LeanSrc/Properties.lean:365 |
prop_86 | theorem prop_86 (x: Nat) (y: Nat) (xs: List Nat) :
x < y → ((x ∈ (ins y xs)) == (x ∈ xs)):= by sorry | LeanSrc/LeanSrc/Properties.lean:368 | 5 | import Mathlib
def ins: Nat → List Nat → List Nat
| n, [] => [n]
| n, x::xs => if (n < x) then n :: x :: xs else x :: (ins n xs)
| x y : ℕ
xs : List ℕ
⊢ x < y → (decide (x ∈ ins y xs) == decide (x ∈ xs)) = true | LeanSrc/LeanSrc/Definitions.lean:202&&LeanSrc/LeanSrc/Properties.lean:369 |
prop_ISortSorts | theorem prop_ISortSorts (xs: List Nat) : ordered (isort xs) == True:= by sorry | LeanSrc/LeanSrc/Sorts.lean:54 | 5 | import Mathlib
def ordered : List Nat -> Bool
| [] => True
| [_x] => True
| x::y::xs => x <= y && ordered (y::xs)
def insert' : Nat → List Nat → List Nat
| x, [] => [x]
| x, y::xs => if x <= y then x::y::xs else y::(insert x xs)
def isort: List Nat → List Nat
| [] => []
| x::xs => insert' x (isort xs)
| xs : List ℕ
⊢ (ordered (isort xs) == decide True) = true | LeanSrc/LeanSrc/Sorts.lean:54 |
prop_ISortCount | theorem prop_ISortCount (x: Nat) (xs: List Nat) : count x (isort xs) == count x xs:= by sorry | LeanSrc/LeanSrc/Sorts.lean:55 | 5 | import Mathlib
def count [DecidableEq α] : α → List α → Nat
| _x, [] => 0
| x, y::ys => if x == y then 1 + (count x ys) else count x ys
def insert' : Nat → List Nat → List Nat
| x, [] => [x]
| x, y::xs => if x <= y then x::y::xs else y::(insert x xs)
def isort: List Nat → List Nat
| [] => []
| x::xs => insert' x (isort xs)
| x : ℕ
xs : List ℕ
⊢ (count x (isort xs) == count x xs) = true | LeanSrc/LeanSrc/Sorts.lean:55 |
prop_ISortPermutes | theorem prop_ISortPermutes (xs: List Nat) : isPermutation (isort xs) xs == True:= by sorry | LeanSrc/LeanSrc/Sorts.lean:56 | 5 | import Mathlib
def deleteFirst [DecidableEq α]: α → List α → List α
| _, [] => []
| n, x::xs => if n == x then xs else x::(deleteFirst n xs)
def isPermutation [DecidableEq α] : List α → List α → Bool
| [], ys => (ys == [])
| x::xs, ys => x ∈ ys && (isPermutation xs (deleteFirst x ys))
def insert' : Nat → List Nat → List Nat
| x, [] => [x]
| x, y::xs => if x <= y then x::y::xs else y::(insert x xs)
def isort: List Nat → List Nat
| [] => []
| x::xs => insert' x (isort xs)
| xs : List ℕ
⊢ (isPermutation (isort xs) xs == decide True) = true | LeanSrc/LeanSrc/Sorts.lean:56 |
prop_BubSortSorts | theorem prop_BubSortSorts (xs: List Nat) : ordered (bubsort xs) == true:= by sorry | LeanSrc/LeanSrc/Sorts.lean:89 | 5 | import Mathlib
def ordered : List Nat -> Bool
| [] => True
| [_x] => True
| x::y::xs => x <= y && ordered (y::xs)
def bubsort (xs : List Nat) : {l' : List Nat // xs.length = l'.length} :=
match xs with
| [] => ⟨[], rfl⟩
| x :: xs =>
match bubsort xs with
| ⟨[], h⟩ => ⟨[x], by simp[h]⟩
| ⟨y :: ys, h⟩ =>
if y < x then
have : Nat.succ (List.length ys) < Nat.succ (List.length xs) := by rw [h, List.length_cons]; apply Nat.lt_succ_self
let ⟨zs, he⟩ := bubsort (x :: ys)
⟨y :: zs, by simp[h, ← he]⟩
else
⟨x :: y :: ys, by simp[h]⟩
termination_by xs.length
| xs : List ℕ
⊢ (ordered ↑(bubsort xs) == true) = true | LeanSrc/LeanSrc/Sorts.lean:89 |
prop_BubSortCount | theorem prop_BubSortCount (x: Nat) (xs: List Nat) : count x (bubsort xs) == count x xs:= by sorry | LeanSrc/LeanSrc/Sorts.lean:90 | 5 | import Mathlib
def count [DecidableEq α] : α → List α → Nat
| _x, [] => 0
| x, y::ys => if x == y then 1 + (count x ys) else count x ys
def bubsort (xs : List Nat) : {l' : List Nat // xs.length = l'.length} :=
match xs with
| [] => ⟨[], rfl⟩
| x :: xs =>
match bubsort xs with
| ⟨[], h⟩ => ⟨[x], by simp[h]⟩
| ⟨y :: ys, h⟩ =>
if y < x then
have : Nat.succ (List.length ys) < Nat.succ (List.length xs) := by rw [h, List.length_cons]; apply Nat.lt_succ_self
let ⟨zs, he⟩ := bubsort (x :: ys)
⟨y :: zs, by simp[h, ← he]⟩
else
⟨x :: y :: ys, by simp[h]⟩
termination_by xs.length
| x : ℕ
xs : List ℕ
⊢ (count x ↑(bubsort xs) == count x xs) = true | LeanSrc/LeanSrc/Sorts.lean:90 |
prop_BubSortPermutes | theorem prop_BubSortPermutes (xs: List Nat) : isPermutation (bubsort xs) xs == true:= by sorry | LeanSrc/LeanSrc/Sorts.lean:91 | 5 | import Mathlib
def deleteFirst [DecidableEq α]: α → List α → List α
| _, [] => []
| n, x::xs => if n == x then xs else x::(deleteFirst n xs)
def isPermutation [DecidableEq α] : List α → List α → Bool
| [], ys => (ys == [])
| x::xs, ys => x ∈ ys && (isPermutation xs (deleteFirst x ys))
def bubsort (xs : List Nat) : {l' : List Nat // xs.length = l'.length} :=
match xs with
| [] => ⟨[], rfl⟩
| x :: xs =>
match bubsort xs with
| ⟨[], h⟩ => ⟨[x], by simp[h]⟩
| ⟨y :: ys, h⟩ =>
if y < x then
have : Nat.succ (List.length ys) < Nat.succ (List.length xs) := by rw [h, List.length_cons]; apply Nat.lt_succ_self
let ⟨zs, he⟩ := bubsort (x :: ys)
⟨y :: zs, by simp[h, ← he]⟩
else
⟨x :: y :: ys, by simp[h]⟩
termination_by xs.length
| xs : List ℕ
⊢ (isPermutation (↑(bubsort xs)) xs == true) = true | LeanSrc/LeanSrc/Sorts.lean:91 |
prop_BubSortIsSort | theorem prop_BubSortIsSort (xs: List Nat) : bubblesort xs == isort xs:= by sorry | LeanSrc/LeanSrc/Sorts.lean:92 | 5 | import Mathlib
def insert' : Nat → List Nat → List Nat
| x, [] => [x]
| x, y::xs => if x <= y then x::y::xs else y::(insert x xs)
def isort: List Nat → List Nat
| [] => []
| x::xs => insert' x (isort xs)
def bubsort (xs : List Nat) : {l' : List Nat // xs.length = l'.length} :=
match xs with
| [] => ⟨[], rfl⟩
| x :: xs =>
match bubsort xs with
| ⟨[], h⟩ => ⟨[x], by simp[h]⟩
| ⟨y :: ys, h⟩ =>
if y < x then
have : Nat.succ (List.length ys) < Nat.succ (List.length xs) := by rw [h, List.length_cons]; apply Nat.lt_succ_self
let ⟨zs, he⟩ := bubsort (x :: ys)
⟨y :: zs, by simp[h, ← he]⟩
else
⟨x :: y :: ys, by simp[h]⟩
termination_by xs.length
def bubblesort (xs: List Nat) : List Nat :=
bubsort xs
| xs : List ℕ
⊢ (bubblesort xs == isort xs) = true | LeanSrc/LeanSrc/Sorts.lean:92 |
prop_HSortSorts | theorem prop_HSortSorts (xs: List Nat) : ordered (hsort xs) == True:= by sorry | LeanSrc/LeanSrc/Sorts.lean:195 | 5 | import Mathlib
def ordered : List Nat -> Bool
| [] => True
| [_x] => True
| x::y::xs => x <= y && ordered (y::xs)
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def hpairwise : List MyHeap → List MyHeap
| p::q::qs => (hmerge p q)::hpairwise qs
| ps => ps
lemma hpairwise_desc (ps: List MyHeap): List.length (hpairwise ps) ≤ List.length ps := by
generalize hl: ps.length = len
induction len using Nat.strong_induction_on generalizing ps with
| h len2 ih =>
match ps with
| [] => unfold hpairwise; simp
| q1::qs1 => match qs1 with
| [] => unfold hpairwise; rw [←hl]
| q2::qs2 => unfold hpairwise; rw [← hl, List.length_cons, List.length_cons, List.length_cons,Nat.succ_le_succ_iff]
rw [List.length_cons, List.length_cons] at hl
have hl3 := Nat.lt_of_succ_lt (Nat.lt_of_succ_le (Nat.le_of_eq hl))
exact Nat.le.step (ih (qs2.length) hl3 qs2 rfl)
def hmerging : List MyHeap → MyHeap
| [] => MyHeap.nil
| [p] => p
| p::q::ps =>
have : List.length (hpairwise (p :: q :: ps)) < Nat.succ (Nat.succ (List.length ps)) := by
unfold hpairwise
rw [List.length_cons, Nat.succ_lt_succ_iff, Nat.lt_succ]
exact hpairwise_desc _
hmerging (hpairwise (p::q::ps))
termination_by ps => ps.length
def toHeap : List Nat → MyHeap
| xs => hmerging (xs.map (fun x => MyHeap.node MyHeap.nil x MyHeap.nil))
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hsort : List Nat → List Nat
| xs => toList (toHeap xs)
| xs : List ℕ
⊢ (ordered (hsort xs) == decide True) = true | LeanSrc/LeanSrc/Sorts.lean:195 |
prop_HSortCount | theorem prop_HSortCount (x: Nat) (xs: List Nat) : count x (hsort xs) == count x xs:= by sorry | LeanSrc/LeanSrc/Sorts.lean:196 | 5 | import Mathlib
def count [DecidableEq α] : α → List α → Nat
| _x, [] => 0
| x, y::ys => if x == y then 1 + (count x ys) else count x ys
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def hpairwise : List MyHeap → List MyHeap
| p::q::qs => (hmerge p q)::hpairwise qs
| ps => ps
lemma hpairwise_desc (ps: List MyHeap): List.length (hpairwise ps) ≤ List.length ps := by
generalize hl: ps.length = len
induction len using Nat.strong_induction_on generalizing ps with
| h len2 ih =>
match ps with
| [] => unfold hpairwise; simp
| q1::qs1 => match qs1 with
| [] => unfold hpairwise; rw [←hl]
| q2::qs2 => unfold hpairwise; rw [← hl, List.length_cons, List.length_cons, List.length_cons,Nat.succ_le_succ_iff]
rw [List.length_cons, List.length_cons] at hl
have hl3 := Nat.lt_of_succ_lt (Nat.lt_of_succ_le (Nat.le_of_eq hl))
exact Nat.le.step (ih (qs2.length) hl3 qs2 rfl)
def hmerging : List MyHeap → MyHeap
| [] => MyHeap.nil
| [p] => p
| p::q::ps =>
have : List.length (hpairwise (p :: q :: ps)) < Nat.succ (Nat.succ (List.length ps)) := by
unfold hpairwise
rw [List.length_cons, Nat.succ_lt_succ_iff, Nat.lt_succ]
exact hpairwise_desc _
hmerging (hpairwise (p::q::ps))
termination_by ps => ps.length
def toHeap : List Nat → MyHeap
| xs => hmerging (xs.map (fun x => MyHeap.node MyHeap.nil x MyHeap.nil))
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hsort : List Nat → List Nat
| xs => toList (toHeap xs)
| x : ℕ
xs : List ℕ
⊢ (count x (hsort xs) == count x xs) = true | LeanSrc/LeanSrc/Sorts.lean:196 |
prop_HSortPermutes | theorem prop_HSortPermutes (xs: List Nat) : isPermutation (hsort xs) xs == True:= by sorry | LeanSrc/LeanSrc/Sorts.lean:197 | 5 | import Mathlib
def deleteFirst [DecidableEq α]: α → List α → List α
| _, [] => []
| n, x::xs => if n == x then xs else x::(deleteFirst n xs)
def isPermutation [DecidableEq α] : List α → List α → Bool
| [], ys => (ys == [])
| x::xs, ys => x ∈ ys && (isPermutation xs (deleteFirst x ys))
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def hpairwise : List MyHeap → List MyHeap
| p::q::qs => (hmerge p q)::hpairwise qs
| ps => ps
lemma hpairwise_desc (ps: List MyHeap): List.length (hpairwise ps) ≤ List.length ps := by
generalize hl: ps.length = len
induction len using Nat.strong_induction_on generalizing ps with
| h len2 ih =>
match ps with
| [] => unfold hpairwise; simp
| q1::qs1 => match qs1 with
| [] => unfold hpairwise; rw [←hl]
| q2::qs2 => unfold hpairwise; rw [← hl, List.length_cons, List.length_cons, List.length_cons,Nat.succ_le_succ_iff]
rw [List.length_cons, List.length_cons] at hl
have hl3 := Nat.lt_of_succ_lt (Nat.lt_of_succ_le (Nat.le_of_eq hl))
exact Nat.le.step (ih (qs2.length) hl3 qs2 rfl)
def hmerging : List MyHeap → MyHeap
| [] => MyHeap.nil
| [p] => p
| p::q::ps =>
have : List.length (hpairwise (p :: q :: ps)) < Nat.succ (Nat.succ (List.length ps)) := by
unfold hpairwise
rw [List.length_cons, Nat.succ_lt_succ_iff, Nat.lt_succ]
exact hpairwise_desc _
hmerging (hpairwise (p::q::ps))
termination_by ps => ps.length
def toHeap : List Nat → MyHeap
| xs => hmerging (xs.map (fun x => MyHeap.node MyHeap.nil x MyHeap.nil))
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hsort : List Nat → List Nat
| xs => toList (toHeap xs)
| xs : List ℕ
⊢ (isPermutation (hsort xs) xs == decide True) = true | LeanSrc/LeanSrc/Sorts.lean:197 |
prop_HSortIsSort | theorem prop_HSortIsSort (xs: List Nat) : hsort xs == isort xs:= by sorry | LeanSrc/LeanSrc/Sorts.lean:198 | 5 | import Mathlib
def insert' : Nat → List Nat → List Nat
| x, [] => [x]
| x, y::xs => if x <= y then x::y::xs else y::(insert x xs)
def isort: List Nat → List Nat
| [] => []
| x::xs => insert' x (isort xs)
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def hpairwise : List MyHeap → List MyHeap
| p::q::qs => (hmerge p q)::hpairwise qs
| ps => ps
lemma hpairwise_desc (ps: List MyHeap): List.length (hpairwise ps) ≤ List.length ps := by
generalize hl: ps.length = len
induction len using Nat.strong_induction_on generalizing ps with
| h len2 ih =>
match ps with
| [] => unfold hpairwise; simp
| q1::qs1 => match qs1 with
| [] => unfold hpairwise; rw [←hl]
| q2::qs2 => unfold hpairwise; rw [← hl, List.length_cons, List.length_cons, List.length_cons,Nat.succ_le_succ_iff]
rw [List.length_cons, List.length_cons] at hl
have hl3 := Nat.lt_of_succ_lt (Nat.lt_of_succ_le (Nat.le_of_eq hl))
exact Nat.le.step (ih (qs2.length) hl3 qs2 rfl)
def hmerging : List MyHeap → MyHeap
| [] => MyHeap.nil
| [p] => p
| p::q::ps =>
have : List.length (hpairwise (p :: q :: ps)) < Nat.succ (Nat.succ (List.length ps)) := by
unfold hpairwise
rw [List.length_cons, Nat.succ_lt_succ_iff, Nat.lt_succ]
exact hpairwise_desc _
hmerging (hpairwise (p::q::ps))
termination_by ps => ps.length
def toHeap : List Nat → MyHeap
| xs => hmerging (xs.map (fun x => MyHeap.node MyHeap.nil x MyHeap.nil))
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hsort : List Nat → List Nat
| xs => toList (toHeap xs)
| xs : List ℕ
⊢ (hsort xs == isort xs) = true | LeanSrc/LeanSrc/Sorts.lean:198 |
prop_HSort2Sorts | theorem prop_HSort2Sorts (xs: List Nat) : ordered (hsort2 xs) == True:= by sorry | LeanSrc/LeanSrc/Sorts.lean:211 | 5 | import Mathlib
def ordered : List Nat -> Bool
| [] => True
| [_x] => True
| x::y::xs => x <= y && ordered (y::xs)
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hinsert : Nat → MyHeap → MyHeap
| x, h => hmerge (MyHeap.node MyHeap.nil x MyHeap.nil) h
def toHeap2 : List Nat → MyHeap
| [] => MyHeap.nil
| x::xs => hinsert x (toHeap2 xs)
def hsort2 : List Nat → List Nat
| xs => toList (toHeap2 xs)
| xs : List ℕ
⊢ (ordered (hsort2 xs) == decide True) = true | LeanSrc/LeanSrc/Sorts.lean:211 |
prop_HSort2Count | theorem prop_HSort2Count (x: Nat) (xs: List Nat) : count x (hsort2 xs) == count x xs:= by sorry | LeanSrc/LeanSrc/Sorts.lean:212 | 5 | import Mathlib
def count [DecidableEq α] : α → List α → Nat
| _x, [] => 0
| x, y::ys => if x == y then 1 + (count x ys) else count x ys
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hinsert : Nat → MyHeap → MyHeap
| x, h => hmerge (MyHeap.node MyHeap.nil x MyHeap.nil) h
def toHeap2 : List Nat → MyHeap
| [] => MyHeap.nil
| x::xs => hinsert x (toHeap2 xs)
def hsort2 : List Nat → List Nat
| xs => toList (toHeap2 xs)
| x : ℕ
xs : List ℕ
⊢ (count x (hsort2 xs) == count x xs) = true | LeanSrc/LeanSrc/Sorts.lean:212 |
prop_HSort2Permutes | theorem prop_HSort2Permutes (xs: List Nat) : isPermutation (hsort2 xs) xs == True:= by sorry | LeanSrc/LeanSrc/Sorts.lean:213 | 5 | import Mathlib
def deleteFirst [DecidableEq α]: α → List α → List α
| _, [] => []
| n, x::xs => if n == x then xs else x::(deleteFirst n xs)
def isPermutation [DecidableEq α] : List α → List α → Bool
| [], ys => (ys == [])
| x::xs, ys => x ∈ ys && (isPermutation xs (deleteFirst x ys))
inductive MyHeap where
| nil : MyHeap
| node : MyHeap → Nat → MyHeap → MyHeap
def hmerge : MyHeap → MyHeap → MyHeap
| MyHeap.nil, q => q
| p, MyHeap.nil => p
| MyHeap.node p x q, MyHeap.node r y s =>
if x <= y then MyHeap.node (hmerge q (MyHeap.node r y s)) x p
else MyHeap.node (hmerge (MyHeap.node p x q) s) y r
def numElem : MyHeap → Nat
| MyHeap.nil => 0
| MyHeap.node p _x q => 1 + numElem p + numElem q
lemma numElem_lt_subHeaps (q r: MyHeap) {x: Nat}: numElem q < numElem (MyHeap.node q x r) ∧ numElem r < numElem (MyHeap.node q x r) := by
have h': numElem (MyHeap.node q x r) = 1 + numElem q + numElem r; rfl
rw [h'];
exact ⟨by linarith, by linarith⟩;
lemma merge_elems (p q: MyHeap): numElem p + numElem q = numElem (hmerge p q) := by
generalize hsp: numElem p = sp
generalize hsq: numElem q = sq
generalize hspq: numElem (hmerge p q) = spq
induction sp using Nat.strong_induction_on generalizing p q sq spq with
| h sp2 ih => induction sq using Nat.strong_induction_on generalizing p q sp2 spq with
| h sq2 ih2 =>
rw [←hsp, ← hsq, ← hspq];
unfold hmerge;
split;
case h_1 _ _;
unfold numElem; rw [Nat.add_comm, Nat.add_zero];
case h_2 _ _;
unfold numElem; rw [Nat.add_zero];
case h_3 _ _ pl x pr ql y qr;
split;
unfold numElem;
suffices h': numElem (hmerge pr (MyHeap.node ql y qr)) = numElem pr + (1 + numElem ql + numElem qr);
rw[h']; linarith;
rw [←hsp] at ih;
exact Eq.symm (ih (numElem pr) (numElem_lt_subHeaps _ _).2 pr (MyHeap.node ql y qr) rfl
(numElem (MyHeap.node ql y qr)) rfl (numElem (hmerge pr (MyHeap.node ql y qr))) rfl);
unfold numElem;
suffices h': numElem (hmerge (MyHeap.node pl x pr) qr) = numElem qr + (1 + numElem pl + numElem pr);
rw[h']; linarith;
rw [←hsq] at ih2;
have h':= ih2 (numElem qr) (numElem_lt_subHeaps _ _).2 sp2 ih (MyHeap.node pl x pr) qr hsp rfl
(numElem (hmerge (MyHeap.node pl x pr) qr)) rfl;
rw [←hsp] at h';
suffices h'': 1 + numElem pl + numElem pr = numElem (MyHeap.node pl x pr);
rw [h'']; linarith;
rfl;
lemma numElem_merge_branches_lt (p q: MyHeap) (x: Nat): numElem (hmerge p q) < numElem (MyHeap.node p x q) := by
rw [←merge_elems _ _];
have h': numElem (MyHeap.node p x q) = 1 + numElem p + numElem q; rfl
rw [h']
linarith;
def toList : MyHeap → List Nat
| MyHeap.nil => []
| MyHeap.node p x q =>
have _h := numElem_merge_branches_lt p q x
x :: toList (hmerge p q)
termination_by hp => numElem hp
def hinsert : Nat → MyHeap → MyHeap
| x, h => hmerge (MyHeap.node MyHeap.nil x MyHeap.nil) h
def toHeap2 : List Nat → MyHeap
| [] => MyHeap.nil
| x::xs => hinsert x (toHeap2 xs)
def hsort2 : List Nat → List Nat
| xs => toList (toHeap2 xs)
| xs : List ℕ
⊢ (isPermutation (hsort2 xs) xs == decide True) = true | LeanSrc/LeanSrc/Sorts.lean:213 |
Getting Started
First install Lean 4. Then clone this repo:
git clone --recurse-submodules https://huggingface.co/datasets/elohn/miniCodeProps
The outer LeanSrc folder is a Lean Project. You can open that folder directly in VSCode and check that the proofs in LeanSrc/Sorts.lean
type check after following the instructions for working on an existing lean project in the Lean 4 documentation.
The main miniCodeProps folder handles extracting the benchmark and calculating baselines. If anything fails when building Lean or running lake exe cache get
from LeanSrc, the Zulip Chat is the best resource for troubleshooting.
After cloning the repo, you will need to install Lean REPL. By default, our scripts expect the repl
folder to be directly inside the miniCodeProps folder. run lake build
from within the repl
folder.
The extract.py
script is used only to create the json-formatted benchmark.
The baseline.py
script contains the code we used to get our baseline results. It shows how to interact with Lean Repl programmatically, although some interactions are still somewhat buggy in that the repl will send i.e. an extra newline or weirdly formatted message that requires our script to restart the repl.
Regardless, if you would like to use our setup, We ran our baselines using LLMStep. However, our code also includes a natural place to write your own function to generate tactics given the goal and file context (see get_tactics_llmstep
in baseline.py
). We modified the LLMStep server to return average suggestion log-probabilities per suggestion to implement best-first search.
Reproducing Baselines
First, ensure that you have installed Lean and Lean REPL as detailed above. Before running baseline.py
with any arguments, check that your OS has been set at the top of utils.py
. At the moment we support interacting with Lean in MacOS and Ubuntu (20.04).
Next-Step Baselines
Our experiments were run on an A100 GPU. Smaller GPUs may not be able to run Llemma7B, but will likely work with Pythia and ntp-context.
Clone our fork of LLMStep. After following the LLMStep setup instructions,
- For Pythia2.8B, run
python3 python/server_vllm.py
(or, if CPU-bound, runpython3 python/server.py
) - For Llemma7B, run
python3 python/server_llemma.py
- For ntp-context-1.3B, run
python3 python/server_context.py
In another terminal, run python baseline.py --bench_type nextstep
Full-Proof Baseline
run export OPENAI_API_KEY=<your key here>
.
Then, simply run
python3 baseline.py
You can also specify which openai LLM to use for proof generation via
python3 baseline.py --gpt_model <your model name>
although our tests only used gpt-4-turbo.
- Downloads last month
- 9