[英]Flexible/Fuzzy rule application in Isabelle/HOL
Assume I have the following predicate P
and rule R
:假设我有以下谓词P
和规则R
:
locale example =
fixes P :: "int ⇒ int ⇒ bool"
assumes R: "⋀a b c. a ≥ 2 ⟹ P (a*b) (a*c)"
I now want to apply the rule to R
to prove P 8 4
, but of course a direct rule application fails:我现在想将规则应用于R
以证明P 8 4
,但是直接规则应用当然会失败:
lemma (in example) "P 8 4"
proof (rule R) (* FAILS *)
Instead I have to instantiate the equalities manually before using the rule:相反,我必须在使用规则之前手动实例化等式:
lemma (in example) "P 8 4"
proof -
have "P (4*2) (4*1)"
by (rule R, simp)
thus "P 8 4"
by simp
qed
lemma (in example) "P 8 4"
using R[where a=2 and b=4 and c=2] by simp
The following example is a bit nicer.下面的例子更好一点。 It only requires a specialized lemma for predicates with 2 arguments and it requires manually specifying the toplevel predicate name:对于具有 2 个 arguments 的谓词,它只需要一个专门的引理,并且需要手动指定顶级谓词名称:
lemma back_subst2: "⟦P x' y'; x' = x; y' = y⟧ ⟹ P x y"
by force
lemma (in example) "P 8 4"
proof (rule back_subst2[where P=P], rule R)
show "2 ≤ (2 :: int)" by simp
show "2*4 = (8::int)" by simp
show "2*2 = (4::int)" by simp
qed
My question: Is there a better way to apply rules, when arguments do not have the exactly required form?我的问题:当 arguments 没有完全需要的表格时,是否有更好的方法来应用规则? Can the last example be improved somehow?最后一个例子可以以某种方式改进吗?
I have now written my own method named fuzzy_rule
to do this:我现在已经编写了自己的名为fuzzy_rule
的方法来执行此操作:
lemma (in example) "P 8 4"
proof (fuzzy_rule R)
show "2 ≤ (2 :: int)" by simp
show "2*4 = (8::int)" by simp
show "2*2 = (4::int)" by simp
qed
Source is available at https://github.com/peterzeller/isabelle_fuzzy_rule源代码可在https://github.com/peterzeller/isabelle_fuzzy_rule获得
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.