我特林與this one定義類推以下功能:如何查找數據類型的構造函數?
fun int_divide :: "int option ⇒ int option ⇒ real option" where
"int_divide _ (Some (int 0)) = None"
| "int_divide (Some a) (Some b) = Some (a/b)"
| "int_divide _ _ = None"
fun real_divide :: "real option ⇒ real option ⇒ real option" where
"real_divide _ (Some (real 0)) = None"
| "real_divide (Some a) (Some b) = Some (a/b)"
| "real_divide _ _ = None"
但這些類型沒有int
或real
構造。 int
和real
類型被定義爲quotient_type
。我找不到在理論上看起來像構造函數的東西。
下面的定義不工作:
definition int0 :: "int" where
"int0 = Abs_Integ (0,0)"
fun int_divide :: "int option ⇒ int option ⇒ real option" where
"int_divide _ (Some int0) = None"
| "int_divide (Some a) (Some b) = Some (a/b)"
| "int_divide _ _ = None"
如何找到一個類型的所有構造函數?或者至少對於quotient_type
?或者如何定義所需的構造函數?