5 kyu
Multiples of some m, you say?
Description:
This is a marginally more difficult version of Multiples of 3, you say?
We say that a
divides b
if b
is a multiple of a
. An inductive definition of this relation could be as follows:
Inductive divides (m : nat) : nat -> Prop :=
| O_divides : divides m O
| add_divides n (H : divides m n) : divides m (m + n).
The Coq stdlib defines this notion as well for both natural numbers and integers, albeit in a non-inductive way.
Now we define a predicate P
on the natural numbers such that:
P 24
holdsP 40
holdsP 60
holdsP (n + m)
holds if bothP n
andP m
holdP l
holds if there existsn
,m
such thatl + n = m
and bothP n
,P m
hold
Show that P
describes exactly the multiples of some natural number m
.
Preloaded
Inductive divides (m : nat) : nat -> Prop :=
| O_divides : divides m O
| add_divides n (H : divides m n) : divides m (m + n).
Inductive P : nat -> Prop :=
| P_24 : P 24
| P_40 : P 40
| P_60 : P 60
| P_sum n m (Hn : P n) (Hm : P m) : P (n + m)
| P_diff l n m (Hl : l + n = m) (Hn : P n) (Hm : P m) : P l.
Theorem Proving
Fundamentals
Similar Kata:
Stats:
Created | Nov 6, 2021 |
Published | Nov 6, 2021 |
Warriors Trained | 37 |
Total Skips | 0 |
Total Code Submissions | 22 |
Total Times Completed | 19 |
Coq Completions | 19 |
Total Stars | 0 |
% of votes with a positive feedback rating | 100% of 5 |
Total "Very Satisfied" Votes | 5 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 3 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |