coq - COQ中子序列的传递性
问题描述
我一直在努力打通逻辑基础,并且非常坚持子序列练习的传递性。
(** **** 练习:2 星,高级(子序列)
A list is a _subsequence_ of another list if all of the elements
in the first list occur in the same order in the second list,
possibly with some extra elements in between. For example,
- (Optional, harder) Prove [subseq_trans] that subsequence is
transitive -- that is, if [l1] is a subsequence of [l2] and [l2]
is a subsequence of [l3], then [l1] is a subsequence of [l3].
Hint: choose your induction carefully! *)
Inductive subseq : list nat -> list nat -> Prop :=
| sseq_e (l2 : list nat) : subseq ([]) (l2)
| sseq_m (l1 l2 : list nat) (n : nat) (H: subseq l1 l2) : subseq (n::l1) (n::l2)
| sseq_nm (l1 l2 : list nat) (n : nat) (H: subseq l1 l2) : subseq (l1) (n::l2)
.
Theorem subseq_trans : forall (l1 l2 l3 : list nat),
subseq l1 l2 ->
subseq l2 l3 ->
subseq l1 l3.
Proof.
intros l1 l2 l3 H H0.
induction H.
- apply sseq_e.
- induction l3.
-- inversion H0.
-- inversion H0.
--- apply sseq_m.
在尝试了几种不同的方法后,我无法获得正确的归纳假设。我尝试了多种方法,最终遇到这样一种情况,在我的假设中,我有类似 subseq l2 x::l3 的东西,但是我需要证明 subseq l2 l3 这似乎是一个死胡同。任何指向正确方向的指针都将不胜感激。
解决方案
我有类似 subseq l2 x::l3 的东西,但是我需要证明 subseq l2 l3 这似乎是一个死胡同。
该经验建议将归纳假设推广到l3
.
(* near the beginning of the proof *)
generalize dependent l3.
induction H.
推荐阅读
- python - 保留重复值 - python 字典
- vue.js - 如何在单击按钮vue js上反转消息
- scala - Spark Scala - 将带有毫秒的时间戳转换为没有毫秒的时间戳
- r - R中数据表中的缺失值
- streaming - Vega Vega-lite 流媒体
- dax - 用于保存按日期分组的最大值的 Dax 计算列
- java - 没有可用的“javax.sql.DataSource”类型的合格 bean:在候选中找到多个“主要”bean:
- heroku - Heroku 应用程序错误 - 代码=H10 desc="应用程序崩溃"
- javascript - 如果元素被溢出完全隐藏,设置可见性是否多余?
- vhdl - 高密度脂蛋白; 如何在受约束的数组中约束不受约束的 std_logic_vector