如何使用默认或或子句之类的东西在COQ中使用COQ中的比赛?
如何在Coq中编写类似于此的开关状态(Rust)? 特别是我是Curios如何合并Coq中的分支以产生相同的输出,并通过一些默认实现来耗尽其余分支。
type Voltages = u32; // in coq is similar to Definition Voltages := R.
type Timestamp = u32; // in coq is similar to Definition Timestamp := R.
const TD: Timestamp = 2; // dummy value cuz rust, in coq would be Variable TD : Timestamp.
enum Pin {
Ground(bool),
VoltageIn(bool),
Threshold,
Discharge,
Output,
Trigger,
Reset,
CtrlVoltage
}
impl Pin {
fn evaluate() -> bool { // dummy for some other functions and predicates
true
}
}
fn is_high(p: Pin) -> bool {
match p {
Pin::Ground(value) | Pin::VoltageIn(value) => value, // how to grab 2 options in one match in coq?
_ => Pin.evaluate() // how to exhaust the options in coq?
}
}
How can i write a switch state similar to this one (in rust), in coq?
In particular I'm curios how to merge branches in coq to produce same output, and exhaust the remaining branches via some default implementation.
type Voltages = u32; // in coq is similar to Definition Voltages := R.
type Timestamp = u32; // in coq is similar to Definition Timestamp := R.
const TD: Timestamp = 2; // dummy value cuz rust, in coq would be Variable TD : Timestamp.
enum Pin {
Ground(bool),
VoltageIn(bool),
Threshold,
Discharge,
Output,
Trigger,
Reset,
CtrlVoltage
}
impl Pin {
fn evaluate() -> bool { // dummy for some other functions and predicates
true
}
}
fn is_high(p: Pin) -> bool {
match p {
Pin::Ground(value) | Pin::VoltageIn(value) => value, // how to grab 2 options in one match in coq?
_ => Pin.evaluate() // how to exhaust the options in coq?
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在COQ中,您可以分开几个通过管道绑定相同变量的分支,并且仅使用一个右侧值。
您也可以将下划线作为通配符来捕获所有剩余案例。
In coq you can separate several branches that bind the same variables by a pipe and use only one right-hand side value.
You can also use the underscore as a wildcard to catch all remaining cases.