0

I want to prove the following lemma

lemma assumes "f (w+n) - f w / n ≤ g (w+n)" 
shows "∀n. (f (w+n) - f w) / n ≤ g (w+n)"

I assumed this would be very simple however it is proving trickier than I first thought. From my thoughts, the inequality in the assumption is valid for all w and n, therefore the result I am trying to prove should also be valid.

I've searched the documentation and ran sledgehammer however I haven't been successful.

Can this be solved or am I trying to prove completely different statements? If so, please could someone explain why.

creator22
  • 9
  • 1

2 Answers2

1

As the previous answer already stated, your proposition does not hold. Type classes, however, do not have anything to do with it; it is a very fundamental logical problem.

First of all, it should be noted that your assumption was probably supposed to be

(f (w+n) - f w) / n ≤ g (w+n)

The way you wrote it down, it means

f (w+n) - (f w / n) ≤ g (w+n)

But even when you fix that, it still does not hold, and the reason for that lies in what free variables mean. The convention in Isabelle is that free variables (that are not bound anywhere in the context) in a lemma are implicitly universally qualified. This is usually the convention in mathematics; we write a + b = b + a, not ∀a b. a + b = b + a.

Your lemma therefore means this to Isabelle:

∀f g w n. (f (w+n) - f w) / n ≤ g (w+n) ⟹ ∀n. (f (w+n) - f w) / n ≤ g (w+n)

Informally, what this says is that if the proposition holds for one n, it must hold for all n. This is obviously false. My guess is that you were confused by the fact that when you write down

lemma "(f (w+n) - f w) / n ≤ g (w+n)"

then that already means that it holds for all n (due to the same convention). But when you just take that and past it into the assumption of another lemma, the same convention leads to the opposite meaning: "for any n, if the assumption holds, then ...".

If you really want to state the assumption in such a way that it holds for all n, you have to write

lemma assumes "⋀n. (f (w+n) - f w) / n ≤ g (w+n)" 
      shows   "∀n. (f (w+n) - f w) / n ≤ g (w+n)"

Then the proof is just one application of the rule allI and can be done automatically with blast or auto. Note that ⋀ is Isabelle's universal qualifier in the meta logic. Its meaning is similar to when, in mathematics, you say "Fix some n." or "Let n be a fixed, but arbitrary number".

Manuel Eberl
  • 7,858
  • 15
  • 24
  • Thanks Manuel, your answer is very informative. More specifically, if I have the function "f (w+n) - (f w / n) ≤ g (w+n)", how can I transform it into the form "λn. f (w+n) - (f w / n) ≤ g (w+n)" in order to apply certain lemmas to it? (e.g. eventually_def). I am struggling to do this. – creator22 Jan 29 '15 at 10:47
  • I'm not sure what you mean by ‘transform’. If you mean ‘applying lemmas to it’, then higher-order unification should do that automatically when you try to apply the lemma. But I'm not sure this is what you mean. I would have to see a concrete example of what you're trying to do. – Manuel Eberl Feb 12 '15 at 08:00
0

(The HOL formulas for that other answer on limits are wrong. I don't have access to that user account. I submitted an edited answer, but I don't know if it'll show up. I have y x instead of x y. I didn't fix it, because I don't know how. I just made a few extra comments at the top.)

(Don't accept this as an answer. You should wait to see if one of the experts will show up. The Europeans aren't up yet.)

When I plug in your lemma, Nitpick tells me it found a counter example:

Auto Nitpick found a counterexample for
card "'a∷{inverse,minus,plus,ord}" = 2:

That's because I have "Auto Nitpick" enabled. You go to the options page, then the "Isabelle / General" settings. I usually have enabled "Auto Nitpick", "Auto Quickcheck", and "Auto Solve Direct".

I just now noticed I don't have "Auto Methods" enabled. It must have been sucking up too much CPU for some reason, but it's generally good to enable it, too.

If your CPU is running full bore, and you don't think it should be, then you disable "Auto Methods" to see if that's the problem. I don't use "Auto Sledgehammer". It's pretty demanding on the CPU, and I run it directly.

Auto Nitpick saves me a lot of trouble sometimes. It just pops up when I don't expect it. For some reason I never remember to run it directly anymore. You do that with nitpick. See the PDF for more details on the options.

As to why your lemma fails, I don't know. Maybe someone else will know.

What I'm looking at right now is the sort for your variables. Eventually, you have to get an understanding about type classes and sorts. There are different ways to get more information. I use declare, where sometimes I get too much info:

declare[[show_sorts=true, show_consts=true]]

In the output panel, I see what it showed in the counterexample. The sort of your type is this:

'a :: {inverse,minus,plus,ord}

Your variables, for example w, are w :: 'a :: {inverse,minus,plus,ord}. Those 4 sorts describe the algebraic properties that your variables have. You need to understand what limitations those sorts put on the use of your functions. You might need additional sorts to get what you want.