【发布时间】:2020-11-11 18:21:46
【问题描述】:
我正在使用 softwarefoundations book 学习 Coq,但在 induction chapter 中的最后一个任务上卡住了 - 练习:5 星,高级 (binary_inverse) 部分 c。
鉴于下一个定义。
Inductive bin : Type :=
| Z
| B0 (n : bin)
| B1 (n : bin).
Fixpoint norm_bin (input :bin): bin :=
match input with
| Z => Z
| B0 Z => Z
| B1 restInput => B1 (norm_bin restInput)
| B0 restInput=> match norm_bin restInput with
| Z => Z
| _ => B0 (norm_bin restInput)
end
end.
我正在努力证明
Theorem norm_bin_B0_out :
forall b, norm_bin b <> Z -> norm_bin (B0 b) = B0 (norm_bin b).
我试过destruct b,但是不能解决b = Z的情况,根据条件norm_bin b <> Z,b不能是Z。我该如何证明?提前致谢!
感谢下面的回复,我设法证明了这一点:
Theorem norm_bin_B0_out :
forall b, norm_bin b <> Z -> norm_bin (B0 b) = B0 (norm_bin b).
Proof.
intros b H.
simpl.
destruct norm_bin eqn:f.
- simpl in H. tauto.
- simpl. destruct b.
{ discriminate. }
{ reflexivity. }
{ reflexivity. }
- destruct b.
{ discriminate. }
{ reflexivity. }
{ reflexivity. }
Qed.
我不知道 norm_bin 可以被破坏。那是个问题。
【问题讨论】:
标签: coq