Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal Quantification in Isabelle/HOL

Tags:

proof

isabelle

It has come to my attention that there are several ways to deal with universal quantification when working with Isabelle/HOL Isar. I am trying to write some proofs in a style that is suitable for undergraduate students to understand and reproduce (that's why I'm using Isar!) and I am confused about how to express universal quantification in a nice way.

In Coq for example, I can write forall x, P(x) and then I may say "induction x" and that will automatically generate goals according to the corresponding induction principle. However, in Isabelle/HOL Isar, if I want to directly apply an induction principle I must state the theorem without any quantification, like this:

lemma foo: P(x)
proof (induct x)

And this works fine as x is then treated as a schematic variable, as if it was universally quantified. However, it lacks the universal quantification in the statement which is not very educational. Another way I have fund is by using \<And> and \<forall>. However, I can not directly apply the induction principle if I state the lemma in this way, I have to first fix the universally quantified variables... which again seems inconvenient from an educational point of view:

lemma foo: \<And>x. P(x)
proof -
fix x
show "P(x)"
proof (induct x)

What is a nice proof pattern for expressing universal quantification that does not require me to explicitly fix variables before induction?

like image 752
Martin Copes Avatar asked Dec 28 '15 01:12

Martin Copes


1 Answers

You can use induct_tac, case_tac, etc. These are the legacy variant of the induct/induction and cases methods used in proper Isar. They can operate on bound meta-universally-quantified variables in the goal state, like the x in your second example:

lemma foo: "⋀x. P(x :: nat)"
proof (induct_tac x)

One disadvantage of induct_tac over induction is that it does not provide cases, so you cannot just write case (Suc x) and then from Suc.IH and show ?case in your proof. Another disadvantage is that addressing bound variables is, in general, rather fragile, since their names are often generated automatically by Isabelle and may change when Isabelle changes. (not in the case you have shown above, of course)

This is one of the reasons why Isar proofs are preferred these days. I would strongly advise against showing your students ‘bad’ Isabelle with the intention that it is easier for them to understand.

The facts are these: free variables in a theorem statement in Isabelle are logically equivalent to universally-quantified variables and Isabelle automatically converts them to schematic variables after you have proven it. This convention is not unique to Isabelle; it is common in mathematics and logic, and it helps to reduce clutter. Isar in particular tries to avoid explicit use of the operator in goal statements (i.e. have/show; they still appear in assume).

Or, in short: free variables in theorems are universally quantified by default. I doubt that students will find this hard to understand; I certainly did not when I started with Isabelle as a BSc student. In fact, I found it much more natural to state a theorem as xs @ (ys @ zs) = (xs @ ys) @ zs instead of ∀xs ys zs. xs @ (ys @ zs) = (xs @ ys) @ zs.

like image 185
Manuel Eberl Avatar answered Sep 28 '22 05:09

Manuel Eberl