Isabelle - exI and refl behavior explanation needed

血红的双手。 提交于 2019-12-08 00:27:30

问题


I am trying to understand the lemma below.

  • Why is the ?y2 schematic variable introduced in exI?
  • And why it is not considered in refl (so: x = x)?
lemma "∀x. ∃y. x = y"   
  apply(rule allI)     (*  ⋀x.      ∃y. x = y *)
  thm exI              (*  ?P ?x ⟹ ∃x. ?P x  *)
  apply(rule exI)      (*  ⋀x. x = ?y2 x      *)
  thm refl             (*  ?t = ?t            *)   
  apply(rule refl)   
done

UPDATE (because I can't format code in comments):

This is the same lemma with a different proof, using simp.

lemma "∀x. ∃y. x = y"
  using [[simp_trace, simp_trace_depth_limit = 20]]
  apply (rule allI)  (*So that we start from the same problem state. *)   
  apply (simp only:exI) 
done

The trace shows:

[0]Adding rewrite rule "HOL.exI":
?P1 ?x1 ⟹ ∃x. ?P1 x ≡ True 
[1]SIMPLIFIER INVOKED ON THE FOLLOWING TERM:
⋀x. ∃y. x = y 
[1]Applying instance of rewrite rule "HOL.exI":
?P1 ?x1 ⟹ ∃x. ?P1 x ≡ True    
[1]Trying to rewrite:
x = ?x1 ⟹ ∃xa. x = xa ≡ True   <-- NOTE: not ?y2 xa or similar!
[2]SIMPLIFIER INVOKED ON THE FOLLOWING TERM:
x = ?x1 
[1]SUCCEEDED
∃xa. x = xa ≡ True

So apparently simp and rule handles exI differently. And the remaining question is: what is the mechanical (programmatical) reasoning behind rule's behavior.


回答1:


When you use rule thm for some fact thm, Isabelle performs higher-order unification of the conclusion of thm with the current goal. If there is a unifier, it is used to instantiate both the goal and the conclusion of the theorem, and then resolution is performed (i.e. the goal is replaced with the assumptions of thm).

This means that:

  1. Schematic variables in the goal can be instantiated by rule through unification

  2. Variables that appear only in the assumptions of thm will not be instantiated by the unification and will therefore remain schematic. That way, you end up with schematic variables in your new goals. Such variables can be seen as existential in some sense, because the conclusion of thm holds if you can prove the assumptions for just one arbitrary value.

In the case of exI, you have ?P ?x ⟹ ∃x. ?P x. When you apply rule exI, the variable ?P is instantiated to λy. x = y, but the variable ?x appears only in the assumptions of exI, so it remains schematic. This means that you can pick any value you want for ?x later on in your proof.

To be more precise, you end up with ⋀x. x = ?y2 x as your goal. You might ask ‘Why not just ⋀x. x = ?y2?’ That would mean that you have to show that x equals some fixed value y2 for all possible values of x. That is obviously not true in general. ⋀x. x = ?y2 x means you have to show that every x equals some y2 that may depend on x – or, equivalently, that there is a function y2 that, when given x, outputs x.

Of course, there is such a function and it is simply the identity function λx. x. That is precisely what ?y2 gets instantiated to when you apply rule refl: the goal x = ?y2 x is unified with the conclusion of refl ?t = ?t and you end up with ?t = x and ?y2 = λx. x, and since refl has no assumptions, this resolution finishes the proof.

I am not entirely sure what you mean with ‘And why it is not considered in refl?’, but I hope that I have answered your questions.




回答2:


Get a more complete answer from an expert, but I give a short, brief answer to your second part.

The great thing about Isabelle is that it provides many different ways to prove a problem.

Your new question is similar to L.Paulson's comment on FOM: you moved the goal post by switching the question to rule vs. simp:

http://www.cs.nyu.edu/pipermail/fom/2015-October/019312.html

Getting a basic understanding of simp is actually a much easier goal to pursue, or I wouldn't be adding my reponse here.

rule and natural deduction

The use of rule is the use of natural deduction (ND), where most people aren't up to speed on ND. The use of ND requires understanding ND, so questions like your first question can lead to a non-simple answer, because anything informative can't be a one-liner answer, especially due to things like schematic variables (which you asked about), resolution, unification, rewriting, etc.

Do a search on natural deduction and you'll find the standard wiki page about it. There are numerous books on natural deduction, though they get swamped in searches on "logic" due to first-order logic books. A popular book is Logic in Computer Science, 2nd, by Huth and Ryan.

If you study ND, you'll see that exI matches one of the ND rules.

I have yet to take the time to come up to speed on ND, because I keep making progress without having more than a basic understanding of ND.

Sledgehammer, and auto-methods auto, simp, blast, induct, cases, etc., and Sledgehammer's use of some of those, keep me from finding the time to become good with natural decution.

Answer's like M.Eberl's, though not simple explanations, help me absorb a little here and a little there.

Simp, I think of it as simple substitution (rewriting)

The mechanics behind simp is really simple, compared to natural deduction. You define a formula and prove it:

lemma foo [simp]: "left_hand_side = right_hand_side"

In the proof of another theorem, when simp is invoked in one way or another, or foo is unfolded, where there is left_hand_side, it's replaced with right_hand_side. It's just classic mathematical substitution.

I suppose it could also be "rewriting", but I don't know anything about rewriting, other than they talk about it.

There are lots of details about how and whether one should set things up automatically (to prevent looping), like with [simp] or declare foo_def [simp add], but that's just details along the line of normal programming.



来源:https://stackoverflow.com/questions/33425599/isabelle-exi-and-refl-behavior-explanation-needed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!