Skip to content

Commit f8085eb

Browse files
committed
Update batteries theorems
1 parent 7faf093 commit f8085eb

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

HumanEvalLean/HumanEval155.lean

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
1-
section Batteries
1+
section Batteries -- https://github.com/leanprover-community/batteries/pull/1267
22

3-
-- https://github.com/leanprover-community/batteries/pull/1267
4-
@[simp] theorem Nat.isDigit_digitChar : n.digitChar.isDigit = decide (n < 10) := sorry
5-
theorem Nat.mem_toDigits_base_10_isDigit (h : c ∈ toDigits 10 n) : c.isDigit := sorry
6-
theorem Nat.toDigits_10_of_lt_10 (h : n < 10) : toDigits 10 n = [n.digitChar] := sorry
3+
@[simp]
4+
theorem Nat.isDigit_digitChar : n.digitChar.isDigit = decide (n < 10) :=
5+
sorry
6+
7+
theorem Nat.isDigit_of_mem_toDigits (hb₁ : 0 < b) (hb₂ : b ≤ 10) (hc : c ∈ toDigits b n) :
8+
c.isDigit :=
9+
sorry
710

8-
theorem Nat.toDigits_10_decompose (h : d < 10) (n : Nat) :
9-
toDigits 10 (10 * n + d) = (toDigits 10 n) ++ (toDigits 10 d) :=
11+
theorem Nat.toDigits_of_lt_base (h : n < b) : toDigits b n = [n.digitChar] :=
12+
sorry
13+
14+
theorem Nat.toDigits_append_toDigits (hb₁ : 1 < b) (hb₂ : b ≤ 10) (hn : 0 < n) (hd : d < b) :
15+
(toDigits b n) ++ (toDigits b d) = toDigits b (b * n + d) := by
1016
sorry
1117

1218
end Batteries
1319

20+
-- TODO: If you want to use induction or recursion here, you probably have to state a lemma for
21+
-- `Nat.toDigitsCore`, too.
22+
theorem Nat.toDigits_decompose (hb₁ : 1 < b) (hb₂ : b ≤ 10) (hd : d < b) (n : Nat) :
23+
toDigits b (b * n + d) = (toDigits b n) ++ (toDigits b d) := by
24+
rw [toDigits, toDigitsCore]
25+
split
26+
· sorry
27+
· sorry
28+
1429
abbrev Digit := { c : Char // c.isDigit }
1530

1631
namespace Nat
1732

1833
def digits (n : Nat) : List Digit :=
1934
n.toDigits (base := 10)
2035
|>.attach
21-
|>.map fun ⟨j, h⟩ => ⟨j, Nat.mem_toDigits_base_10_isDigit h⟩
36+
|>.map fun ⟨j, h⟩ => ⟨j, Nat.isDigit_of_mem_toDigits (by decide) (by decide) h⟩
2237

2338
theorem digits_of_lt_10 (h : n < 10) : n.digits = [⟨n.digitChar, by simp_all⟩] := by
2439
simp only [digits, List.map_eq_singleton_iff, Subtype.mk.injEq, Subtype.exists, exists_and_right,
2540
exists_eq_right]
26-
rw [toDigits_10_of_lt_10 h]
41+
rw [toDigits_of_lt_base h]
2742
exists List.mem_singleton_self _
2843

2944
theorem digits_decompose (h : d < 10) (n : Nat) : (10 * n + d).digits = n.digits ++ d.digits := by

0 commit comments

Comments
 (0)