Skip to content

Commit 99e0515

Browse files
committed
44
1 parent b5f637a commit 99e0515

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

HumanEvalLean/HumanEval44.lean

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
module
22

3-
def change_base : Unit :=
4-
()
3+
def changeBase (x : Nat) (base : Nat) : String :=
4+
String.ofList (Nat.toDigits base x)
5+
6+
example : changeBase 8 3 = "22" := by native_decide
7+
example : changeBase 9 3 = "100" := by native_decide
8+
example : changeBase 234 2 = "11101010" := by native_decide
9+
example : changeBase 16 2 = "10000" := by native_decide
10+
example : changeBase 8 2 = "1000" := by native_decide
11+
example : changeBase 7 2 = "111" := by native_decide
12+
13+
namespace Nat
14+
15+
theorem ofDigitChars_toDigits' {b n : Nat} (hb' : 1 < b) (hb : b ≤ 10) : ofDigitChars b (toDigits b n) 0 = n := by
16+
sorry -- https://github.com/leanprover/lean4/pull/13098
17+
18+
end Nat
19+
20+
theorem ofDigitChars_changeBase {x : Nat} {base : Nat} (hb' : 1 < base) (hb : base ≤ 10) :
21+
Nat.ofDigitChars base (changeBase x base).toList 0 = x := by
22+
simp [changeBase, Nat.ofDigitChars_toDigits' hb' hb]
523

624
/-!
725
## Prompt
@@ -51,4 +69,4 @@ def check(candidate):
5169
assert candidate(x, x + 1) == str(x)
5270
5371
```
54-
-/
72+
-/

0 commit comments

Comments
 (0)