Commit d73b801d authored by Felipe Cerqueira's avatar Felipe Cerqueira

Implement simple version of k-min

parent e0e0bc7e
...@@ -570,4 +570,34 @@ Section ExtraLemmas. ...@@ -570,4 +570,34 @@ Section ExtraLemmas.
} }
Qed. Qed.
End ExtraLemmas. End ExtraLemmas.
\ No newline at end of file
Section Kmin.
Context {T1 T2: eqType}.
Variable rel: T2 -> T2 -> bool.
Variable F: T1 -> T2.
Fixpoint seq_argmin_k (l: seq T1) (k: nat) :=
if k is S k' then
if (seq_argmin rel F l) is Some min_x then
let l_without_min := rem min_x l in
min_x :: seq_argmin_k l_without_min k'
else [::]
else [::].
Lemma seq_argmin_k_exists:
forall k l x,
k > 0 ->
x \in l ->
seq_argmin_k l k != [::].
induction k; first by done.
move => l x _ IN /=.
destruct (seq_argmin rel F l) as [|] eqn:MIN; first by done.
suff NOTNONE: seq_argmin rel F l != None by rewrite MIN in NOTNONE.
by apply seq_argmin_exists with (x0 := x).
End Kmin.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment