Zulip Chat Archive

Stream: new members

Topic: max + 1 not in finset


Patrick Thomas (Jun 19 2022 at 04:58):

I was wondering if someone might be able to give me a hint in proving the admit here?

import data.finset

-- a computable function to find an element not in a finset.
def variant :   finset   
| x vars :=
if h : x  vars
then vars.max' (exists.intro x h) + 1
else x

-- a proof that the function returns an element not in the finset.
lemma variant_not_mem (x : ) (s : finset ) : variant x s  s :=
begin
  unfold variant, split_ifs,
  admit,
  assumption
end

Patrick Thomas (Jun 19 2022 at 04:59):

Or a proof of something equivalent.

Patrick Thomas (Jun 19 2022 at 05:01):

I think this may be called generating a fresh variable in substitution.

Ruben Van de Velde (Jun 19 2022 at 05:37):

I would start with contrapose! h

Patrick Thomas (Jun 19 2022 at 05:56):

I get:

failed to infer type, unexpected bound variable occurrence
state:
2 goals
x : ,
s : finset 
  (h : x  s), s.max' _ + 1  s

x : ,
s : finset ,
h : x  s
 x  s

Ruben Van de Velde (Jun 19 2022 at 06:09):

Hmm. And intros h con?

Patrick Thomas (Jun 19 2022 at 06:16):

Sorry, no, different error.

Ruben Van de Velde (Jun 19 2022 at 06:38):

That's all I have while I'm not at lean, maybe something with generalize_proofs will work?

Ruben Van de Velde (Jun 19 2022 at 07:09):

This seems to work here:

lemma variant_not_mem (x : ) (s : finset ) : variant x s  s :=
begin
  unfold variant, split_ifs,
  { intro con,
    exact (s.le_max' _ con).not_lt (nat.lt_succ_self _) },
  { assumption }
end

Last updated: Dec 20 2023 at 11:08 UTC