COQ-将表达式分配给变量
首先,我还不熟悉Coq Lingo,因此我将宽松地使用EG'expression'和``变量''之类的术语,但是它们可能不是正确的COQ术语。
我正在尝试证明定理的以下子缘。
1 goal
b : bag
v, b' : nat
b'' : natlist
B : b = b' :: b''
IHb'' : b = b'' -> count v (add v b'') = count v b'' + 1
______________________________________(1/1)
S match v =? b' with
| true => S (count v b'')
| false => count v b''
end = match v =? b' with
| true => S (count v b'')
| false => count v b''
end + 1
您可以忽略s
和+ 1
,我基本上正在寻找一种分配
match v =? b' with
| true => S (count v b'')
| false => count v b''
end
给类型nat
的 方法方程式的侧面。 我该怎么做?或者我需要进行销毁v
和b'
并分别证明所有情况吗?
First and foremost, I'm not yet very familiar with Coq lingo, so I will use terms like e.g. 'expression' and 'variable' loosely, but they are probably not the correct Coq terms.
I'm trying to prove the following subgoal of a Theorem.
1 goal
b : bag
v, b' : nat
b'' : natlist
B : b = b' :: b''
IHb'' : b = b'' -> count v (add v b'') = count v b'' + 1
______________________________________(1/1)
S match v =? b' with
| true => S (count v b'')
| false => count v b''
end = match v =? b' with
| true => S (count v b'')
| false => count v b''
end + 1
You can ignore S
and + 1
, I'm basically looking for a way to assign
match v =? b' with
| true => S (count v b'')
| false => count v b''
end
to a variable of type nat
because it occurs on both sides of the equation.
How can I do this? Or do I need to go through destroying v
and b'
and proving all cases separately?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是两种可能性。可能会有更好的。
您可以使用 为一个术语命名。该术语的所有出现都被变量所取代。
有时,您需要隐藏变量的定义,并且只能记住它是根据需要调用的平等。为此,使用
记住 。
您可以使用
上下文
匹配目标 ,并为该模式中的任何内容命名。如果这是您的真正目标,而不是简化的例子,那么这是一个简单的算术语句#COQ:tacn.lia“ rel =” nofollow noreferrer“>
lia
,让Coq弄清楚。Here are two possibilities. There may well be better ones.
You can use
set
to give a name to a term. All the occurrences of that term are replaced by the variable.Sometimes you need to hide the definition of the variable, and only remember it as an equality that you invoke on demand. For that, use
remember
.You can match the goal against a pattern using the
context
form ofmatch goal
and give a name to whatever's inside that pattern.If this is your real goal and not a simplified example, it's a simple arithmetic statement and you can just call
lia
and let Coq figure it out.除了吉尔斯的建议外,您还可以使用代码> 为了实现这一目标,至少以两种方式说明了此处:
后者也可以与常规
set
,但需要括号:Besides Gilles's suggestions you can use the ssreflect
set
to achieve this, in at least two ways illustrated here:The latter one also works with the regular
set
but it needs brackets: