简体   繁体   English

Isabelle / HOL中的通用定量

[英]Universal Quantification in Isabelle/HOL

It has come to my attention that there are several ways to deal with universal quantification when working with Isabelle/HOL Isar. 引起我注意的是,在使用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. 我试图以适合大学生理解和复制的方式写一些证明(这就是我使用Isar的原因!),并且我对如何以一种很好的方式表示通用量化感到困惑。

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. 例如,在Coq中,我可以写出全部forall x, P(x) ,然后我可以说“归纳x”,并且它将根据相应的归纳原理自动生成目标。 However, in Isabelle/HOL Isar, if I want to directly apply an induction principle I must state the theorem without any quantification, like this: 但是,在Isabelle / HOL Isar中,如果我想直接应用归纳原理,则必须陈述定理而不进行任何量化,例如:

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. 这很好用,因为x然后被当作一个示意图变量,就好像它已被普遍量化。 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> . 我拥有资金的另一种方式是使用\\<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? 什么是表达通用量化的很好的证明模式,不需要我在归纳之前明确确定变量?

You can use induct_tac , case_tac , etc. These are the legacy variant of the induct / induction and cases methods used in proper Isar. 您可以使用induct_taccase_tac等。这些是在适当的Isar中使用的induct / inductioncases方法的传统变体。 They can operate on bound meta-universally-quantified variables in the goal state, like the x in your second example: 它们可以在目标状态下对绑定的元通用量化变量进行运算,例如第二个示例中的x

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. induction相比, induct_tac一个缺点是它不提供案例,因此您不能只写case (Suc x) ,然后再from Suc.IH并在证明中show ?case 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. 另一个缺点是,寻址绑定变量通常比较脆弱,因为它们的名称通常是由Isabelle自动生成的,并且在Isabelle更改时可能会更改。 (not in the case you have shown above, of course) (当然,如果您已显示以上内容,则不会)

This is one of the reasons why Isar proofs are preferred these days. 这就是为什么如今偏爱Isar证明的原因之一。 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. 事实是这样的:Isabelle中的一个定理语句中的自由变量在逻辑上等同于通用量化的变量,并且Isabelle在您证明了它之后会自动将它们转换为原理图变量。 This convention is not unique to Isabelle; 此约定并非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 (ie have / show ; they still appear in assume ). 伊萨尔尤其是试图避免明确使用的在目标陈述运营商(即have / show ,他们仍然会出现在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. 当我从伊莎贝尔(Isabelle)作为理学学士学位的学生开始时,我当然没有。 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 实际上,我发现将定理表示为xs @ (ys @ zs) = (xs @ ys) @ zs而不是∀xs ys zs. xs @ (ys @ zs) = (xs @ ys) @ zs更自然∀xs ys zs. xs @ (ys @ zs) = (xs @ ys) @ zs ∀xs ys zs. xs @ (ys @ zs) = (xs @ ys) @ zs . ∀xs ys zs. xs @ (ys @ zs) = (xs @ ys) @ zs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM