2
votes

I'm using Isabelle/HOL, trying to prove a statement Q. On the way to proving Q, I have proven the existence of a natural number that satisfies P::"nat=>bool". How can I create an instance x::nat that satisfies P, so that I can reference it in subsequent lemmas?

Inside any given lemma, I can do it using the obtains command. I want to reference the same witness instance in a number of different lemmas, however, so I need a way to do it outside of any lemma. I tried to use fix/assume inside a new locale, as shown below:

locale outerlocale
  fixes a b c ...
begin

definition Q::bool where ...

lemma existence: "EX x. P x"
proof -
  ...
qed

locale innerlocale = outerlocale +
  fixes x::nat
  assumes "P x"
begin


(*lots of lemmas that reference x*)
lemma innerlemma0
  ...
lemma innerlemma7
proof -
  ...
qed

lemma finalinnerlemma: "Q"
proof -
  ...
  ...
qed


end (*innerlocale*)

lemma outerlemma: "Q"
proof -
  (*I don't know what goes here*)
qed

end (*outerlocale)

Unfortunately this just kicks the can down the road. I need a way to use the existence lemma to extract the final inner lemma into the outer locale. If I try to interpret the inner locale, I'm once again up against the problem of supplying a witness. I can't interpret locales inside lemmas (unless I'm misunderstanding the error I get), and I can't use obtain outside of lemmas, so I'm stuck.

So it looks I need to figure out either

  • how to specify a witness instance outside a lemma or
  • how to extract a lemma from a locale by proving that locale's assumptions

Or is there a better way to do what I'm trying to do? Thanks!

1

1 Answers

3
votes

You can just use SOME x. P x, e.g., in a definition:

definition my_witness :: nat where
   "my_witness = (SOME x. P x)"

and then use thm someI_ex to show P my_witness.