我可以证明没有其他电感类型的引理
我有以下类型:
Inductive instr : Set :=
| Select : nat -> instr
| Backspace : instr.
Definition prog := list instr.
以及“执行”程序的功能:
Fixpoint execProg (p:prog) (head: list nat) (input: list nat)
: option (list nat) :=
match p with
| nil => match input with
| nil => Some head
| _::_ => None
end
| m::rest =>
match m with
| Select n =>
match input with
| nil => None
| x::r => if (beq_nat n x ) then
match (execProg rest (head++[x]) r) with
| None => None
| Some l => Some l
end
else None
end
| Backspace =>
match input with
| nil => None
| x::r => match (execProg rest (removelast head) r) with
| None => None
| Some l => Some l
end
end
end
end.
我可以在各种输入上尝试:
Eval compute in
execProg (Backspace::Select 1::Select 4::Backspace::nil)
nil (1::1::4::5::nil).
现在我想证明以下引理:
Lemma app_denoteSB :
forall (a b:nat) (p:prog) (input output:list nat) ,
execProg p [] input = Some output ->
execProg (p++[Select a; Backspace]) [] (input ++ [a;b])
= Some output.
但是我看不到该怎么做。 通常,乐器堆栈的大小应与数据的大小相同(输入列表),我可以更改结构并创建对(仪器,NAT)的列表,并在此新列表上运行归纳。
但是出于好奇,我想知道是否有一种方法可以证明没有新结构的引理。
是否可以 ?
谢谢 !!
I have the following types :
Inductive instr : Set :=
| Select : nat -> instr
| Backspace : instr.
Definition prog := list instr.
and a function to 'execute' the program :
Fixpoint execProg (p:prog) (head: list nat) (input: list nat)
: option (list nat) :=
match p with
| nil => match input with
| nil => Some head
| _::_ => None
end
| m::rest =>
match m with
| Select n =>
match input with
| nil => None
| x::r => if (beq_nat n x ) then
match (execProg rest (head++[x]) r) with
| None => None
| Some l => Some l
end
else None
end
| Backspace =>
match input with
| nil => None
| x::r => match (execProg rest (removelast head) r) with
| None => None
| Some l => Some l
end
end
end
end.
I can try it on various inputs :
Eval compute in
execProg (Backspace::Select 1::Select 4::Backspace::nil)
nil (1::1::4::5::nil).
Now I'd like to prove the following lemma:
Lemma app_denoteSB :
forall (a b:nat) (p:prog) (input output:list nat) ,
execProg p [] input = Some output ->
execProg (p++[Select a; Backspace]) [] (input ++ [a;b])
= Some output.
But I don't see how to do that.
As normally, the size of the instr stack should be the same as the size of the data (input list), I can change the structures and create a list of pairs (instr,nat), and run the induction on this new list.
But out of curiosity, I was wondering if there was a way to prove the lemma without the new structure.
Is it possible ?
Thanks !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您的语句不够笼统,无法通过归纳进行,因为归纳步骤需要处理
head
[] 以外的head
。修复很容易:The issue is that your statement is not general enough to go through by induction, because the inductive step needs to handle values of
head
other than[]
. The fix is easy: