0

When I have a lot of assumptions, sometimes I end up with a lot of temporary names that clutter the proof.

I'm talking about things like this:

lemma foo: ...
proof
  assume P: ... and Q: ... and R: ...
  then have ...
  then have ... using P ...
  then have ... using P R ...
  then show ...
  proof
   assume A: ... and B: ... and C: ...
   then have ...
   then have ... using B C ...
   ...

and can you imagine how that evolves. A lot of names for statements that, in the grand scheme of things, are not worthy of naming, but are named nonetheless because we need to reference them some lines later.

If we used all current assumptions on the other hand, the superfluous names wouldn't clutter the proof:

lemma foo: ...
proof
  assume ... and ... and ...
  then have ...
  then have ... using assumptions ...
  then have ... using assumptions ...
  then show ...
  proof
   assume ... and ... and ...
   then have ...
   then have ... using assumptions ...
   ...

Of course, using assumptions is not a valid statement in Isabelle. I know about assms, which references the assumes clause, but I don't know if there exists such a thing for assume.

Is there a way to reference the all current assumptions created by assume?

Luiz Martins
  • 1,644
  • 10
  • 24

1 Answers1

0

In case you really need it...

If all you want are the last assumptions that you made (and not all of them), you can simulate the effect presented by using a name convention (e.g. assumptions or assmps) and bundling the assumptions together (i.e using ""..." "..." "..."" instead of ""..." and "..." and "...""):

lemma foo: ...
proof
  assume assumptions: "..." "..." "..."
  then have ...
  then have ... using assumptions ...
  then have ... using assumptions ...
  then show ...
  proof
   assume assumptions: "..." "..." "..."
   then have ...
   then have ... using assumptions ...
   ...

In the example above, the second assume assumptions shadows the first one, so if you always name your assumptions "assumptions" (or whatever naming convention you prefer), then using assumptions will always refer to the last set of assumptions.

Notice that once you close a subproof with qed, any assume assumptions in the current scope is forgot, so as expected, you can continue using it the previous assumptions after you finish the subproof.

The downside of this method is that, since every new name shadows the rest, only your most recent assumptions in the scope are accessible, which may be a problem if you intend to use any assumptions made before the most recent ones.


... but you probably don't need it.

Although you can use that, Isabelle has other constructs that may solve the same problem in a better way, depending on the situation. Here's some useful tools to keep in mind:

  1. You can bundle assumptions together by using assume A: "..." "..." "...", without and
  2. You can accumulate statements with moreover ... ultimately ...
  3. You can derive multiple statements in one shot with have ... and ... and ... by ...
  4. If your assumptions are at lemma level, you can use lemma foo: assumes ... shows ... and they will be available to you as assms
  5. You can directly quote previous facts with ‹...›

Using 1. already vastly reduces the clutter:

lemma foo: ...
proof
  assume A: "..." "..." "..."
  then have ...
  then have ... using A ...
  then have ... using A ...
  then show ...
  proof
   assume B: "..." "..." "..."
   then have ...
   then have ... using B ...
   ...

Alternatively, using 2. and 3. you can format it as such:

lemma foo: ...
proof
  assume "..." "..." "..."
  moreover from calculation have ...
  moreover from calculation have ...
  ultimately have ...
  then show ...
  proof
   assume "..." "..." "..."
   moreover from this have ...
   ultimately have ... and ...
   ...

Or alternatively, using 4. and 5.:

lemma foo:
  assumes: "..." "..." "..."
  shows: ...
proof
  have ... using assms ...
  then have ... using assms ...
  then have ... using assms ...
  then show ...
  proof
    assume "..." "..." "..."
    then have ...
    then have ... using ‹...› ‹...› ...
Luiz Martins
  • 1,644
  • 10
  • 24
  • 1) If your assumptions are at lemma level (`assumes`), you can use `assms` in the proof. 2) It can make sense to declare your lemmas as `simp` to use them automatically. 3) You can use `goal_cases` and the label name `1`, `2`, ... 4) IMO the `assumptions` idea /feels/ wrong. Names are easier to track (Ctrl-Click) than `assumptions`. – Mathias Fleury May 07 '21 at 06:20
  • 1
    5) you can also use `have ... and ... using ...` to reduce duplications of assumptions. – Mathias Fleury May 07 '21 at 07:35
  • 1
    I believe that one feature of the language that has not been mentioned yet is that one can use literal facts to avoid giving names to explicit assumptions: `assume ‹a + b = c› from ‹a + b = c› show ‹a + b = c› by simp`. – user9716869 - supports Ukraine May 07 '21 at 11:35
  • @MathiasFleury Regarding *4)*, you're in luck, as you *can* Ctrl-Click my proposed solution using `assumptions`, and it'll lead to the currently used set of `assumptions` :) . In any case, I agree with you, I don't think it's a good solution and I've added an addendum addressing this. Also, feel free to criticize and provide a better alternative for my use of `moreover from calculations ...`, as I'm not sure if it is idiomatic. – Luiz Martins May 12 '21 at 21:30
  • @LuizMartins if your `assumptions` contains >10 assumptions and auto breaks during an Isabelle update, you are in huge trouble. If you have only 2 named assumptions you can click on, you have a chance to figure out the difference. – Mathias Fleury May 14 '21 at 05:48