gpt4 book ai didi

if-statement - ATS 证明 : Why does this static if need greater than or equal to?

转载 作者:行者123 更新时间:2023-12-04 10:57:53 24 4
gpt4 key购买 nike

我正在写一个 a*0=0 的证明,我偶然发现了一些奇怪的地方。为什么第 7 行的 sif a >= 0 需要是 >=,而当它只是 sif > 0 时不编译?

prfn mul_ax0_0 {a:int} () : MUL(a,0,0) =
let
prfun auxnat {a:nat} .<a>. () : MUL(a,0,0) =
sif a == 0 then MULbas()
else MULind(auxnat{a-1}())
in
sif a >= 0 then auxnat{a}() // line 7
else MULneg(auxnat{~a}())
end

implement main0 () = ()

从直觉上讲,a=0 应该可以被任何一条路径很好地处理,但只有第一条路径有效。为什么?

最佳答案

MULneg 声明如下:

  | {m:pos}{n:int}{p:int}
MULneg (~(m), n, ~(p)) of MUL_prop (m, n, p)

请注意,“m”必须为正数。在你的例子中,'m' 是 '~a'。如果你使用'>'而不是'>=',那么不能推断'~a > 0'成立当测试 'a > 0' 失败时。

关于if-statement - ATS 证明 : Why does this static if need greater than or equal to?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59063284/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com