if a then b else c
이 match a with true => b | false => c end
을 나타내는 자습서를 읽었습니다. 그러나 전자는 a
의 형식을 매우 이상하게 검사하지 않지만 후자는 물론 a
이 부울임을 확인합니다. 예를 들어,Coq에서 "if then else"는 부울이 아닌 첫 번째 인수를 허용합니까?
Coq < Check if nil then 1 else 2.
if nil then 1 else 2
: nat
where
?A : [ |- Type]
Coq < Check match nil with true => 1 | false => 2 end.
Toplevel input, characters 33-38:
> Check match nil with true => 1 | false => 2 end.
> ^^^^^
Error: Found a constructor of inductive type bool while
a constructor of list is expected.
왜 if ... then ... else ...
는 첫 번째 인수는 부울이 아닌 이상 무엇을 할 수 있습니까? 어떤 과부하가 진행되고 있습니까? (Locate "if".
어떤 결과를 제공하지 않습니다.)