Stream: Beginner Questions

Topic: proving an obvious statement


view this post on Zulip Craig Alan Feinstein (Nov 09 2025 at 00:23):

I'm trying to prove

have i0_in: "0 ∈ {0..<4}" sorry
have i1_in: "1 ∈ {0..<4}" sorry
have i2_in: "2 ∈ {0..<4}" sorry
have i3_in: "3 ∈ {0..<4}" sorry

I sledgehammered it, but no luck. Why?

view this post on Zulip Max Lang (Nov 09 2025 at 07:18):

Usually failing to prove this kind of "obvious" statement involving numerals is because the type of numerals (0, 1, 2, ...) is much more general than one expects. If you fix some type for those numerals, the propositions should become easy to prove, e.g.:

lemma
  "(0 :: nat) ∈ {0..<4}"
  "(1 :: nat) ∈ {0..<4}"
  "(2 :: int) ∈ {0..<4}"
  "(3 :: int) ∈ {0..<4}"
  "finite ({0..<4} :: nat set)"
  by simp_all

depending on what you're after. In general, whenever you find yourself stumped on some trivial lemma like this, it's always a good idea to check which types Isabelle has inferred and/or annotate them yourself.

In fact, we can find a type 'a :: numeral for which the propositions can be falsified. With a little help from a friendly chatbot and sledgehammer:

Counterexample

view this post on Zulip Craig Alan Feinstein (Nov 09 2025 at 20:09):

Thank you, that works fine.


Last updated: Nov 13 2025 at 04:27 UTC