gpt4 book ai didi

程序修复点的 Coq 简化

转载 作者:行者123 更新时间:2023-12-04 04:16:12 26 4
gpt4 key购买 nike

有什么类似的战术simplProgram Fixpoint ?

特别是,如何证明以下无关紧要的陈述?

Program Fixpoint bla (n:nat) {measure n} :=
match n with
| 0 => 0
| S n' => S (bla n')
end.

Lemma obvious: forall n, bla n = n.
induction n. reflexivity.
(* I'm stuck here. For a normal fixpoint, I could for instance use
simpl. rewrite IHn. reflexivity. But here, I couldn't find a tactic
transforming bla (S n) to S (bla n).*)

显然,没有 Program Fixpoint这个玩具示例是必需的,但我在更复杂的设置中面临同样的问题,我需要证明 Program Fixpoint 的终止手动。

最佳答案

我不习惯用Program所以可能有更好的解决方案,但这是我通过展开 bla 想到的,看到它是使用 Fix_sub 在内部定义的并使用 SearchAbout Fix_sub 查看有关该函数的定理.

Lemma obvious: forall n, bla n = n.
Proof.
intro n ; induction n.
reflexivity.
unfold bla ; rewrite fix_sub_eq ; simpl ; fold (bla n).
rewrite IHn ; reflexivity.

(* This can probably be automated using Ltac *)
intros x f g Heq.
destruct x.
reflexivity.
f_equal ; apply Heq.
Qed.

在您的实际示例中,您可能希望引入归约引理,以便您不必每次都做相同的工作。例如。:
Lemma blaS_red : forall n, bla (S n) = S (bla n).
Proof.
intro n.
unfold bla ; rewrite fix_sub_eq ; simpl ; fold (bla n).
reflexivity.

(* This can probably be automated using Ltac *)
intros x f g Heq.
destruct x.
reflexivity.
f_equal ; apply Heq.
Qed.

这样,下次你有 bla (S _) ,您可以简单地 rewrite blaS_red .

关于程序修复点的 Coq 简化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36329256/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com