Skip to content

Commit 418be3b

Browse files
committed
Prove digits_of_lt_10
1 parent 2a80c53 commit 418be3b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

HumanEvalLean/HumanEval155.lean

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
section Batteries
22

33
-- https://github.com/leanprover-community/batteries/pull/1267
4-
@[simp] theorem isDigit_digitChar : n.digitChar.isDigit = decide (n < 10) := sorry
4+
@[simp] theorem Nat.isDigit_digitChar : n.digitChar.isDigit = decide (n < 10) := sorry
55
theorem Nat.mem_toDigits_base_10_isDigit (h : c ∈ toDigits 10 n) : c.isDigit := sorry
6-
7-
theorem Nat.toDigits_10_of_lt_10 (h : n < 10) : toDigits 10 n = [n.digitChar] := by
8-
sorry
6+
theorem Nat.toDigits_10_of_lt_10 (h : n < 10) : toDigits 10 n = [n.digitChar] := sorry
7+
@[simp] theorem Nat.toDigits_10_natAbs_ofNat (n : Nat) : toDigits 10 (n : Int).natAbs = toDigits 10 n := sorry
98

109
theorem Nat.toDigits_10_decompose (h : d < 10) (n : Nat) :
1110
toDigits 10 (10 * n + d) = (toDigits 10 n) ++ (toDigits 10 d) :=
1211
sorry
1312

14-
@[simp]
15-
theorem Nat.toDigits_10_natAbs_cast (n : Nat) : toDigits 10 (n : Int).natAbs = toDigits 10 n :=
16-
sorry
17-
1813
end Batteries
1914

2015
abbrev Digit := { c : Char // c.isDigit }
@@ -27,7 +22,10 @@ def digits (n : Nat) : List Digit :=
2722
|>.map fun ⟨j, h⟩ => ⟨j, Nat.mem_toDigits_base_10_isDigit h⟩
2823

2924
theorem digits_of_lt_10 (h : n < 10) : n.digits = [⟨n.digitChar, by simp_all⟩] := by
30-
sorry
25+
simp only [digits, List.map_eq_singleton_iff, Subtype.mk.injEq, Subtype.exists, exists_and_right,
26+
exists_eq_right]
27+
rw [toDigits_10_of_lt_10 h]
28+
exists List.mem_singleton_self _
3129

3230
theorem digits_decompose (h : d < 10) (n : Nat) : (10 * n + d).digits = n.digits ++ d.digits := by
3331
simp [digits]

0 commit comments

Comments
 (0)