Skip to content

Commit a0d8984

Browse files
authored
solve problem 13 (#222)
This PR trivially solves problem 13.
1 parent e897e0f commit a0d8984

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

HumanEvalLean/HumanEval13.lean

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1-
def greatest_common_divisor : Unit :=
2-
()
1+
/-!
2+
## Implementation
3+
4+
There is nothing to implement: The standard library provides `Int.gcd` out of the box.
5+
6+
## Tests
7+
-/
8+
9+
example : Int.gcd 3 7 = 1 := by native_decide
10+
example : Int.gcd 10 15 = 5 := by native_decide
11+
example : Int.gcd 49 14 = 7 := by native_decide
12+
example : Int.gcd 144 60 = 12 := by native_decide
13+
14+
/-!
15+
## Verification
16+
-/
17+
18+
/-- info: Int.dvd_gcd_iff {a b : Int} {c : Nat} : c ∣ a.gcd b ↔ ↑c ∣ a ∧ ↑c ∣ b -/
19+
#guard_msgs in
20+
#check Int.dvd_gcd_iff
21+
22+
/-- info: Int.dvd_coe_gcd_iff {a b c : Int} : c ∣ ↑(a.gcd b) ↔ c ∣ a ∧ c ∣ b -/
23+
#guard_msgs in
24+
#check Int.dvd_coe_gcd_iff
25+
26+
theorem Int.gcd_le_of_dvd {a b : Int} {c : Nat}
27+
(h : (c : Int) ∣ a ∧ (c : Int) ∣ b) (hpos : 0 < a ∨ 0 < b) :
28+
c ≤ a.gcd b := by
29+
apply Nat.le_of_dvd <;> grind [Int.dvd_gcd_iff]
330

431
/-!
532
## Prompt
@@ -41,4 +68,4 @@ def check(candidate):
4168
assert candidate(49, 14) == 7
4269
assert candidate(144, 60) == 12
4370
```
44-
-/
71+
-/

0 commit comments

Comments
 (0)