1

Isabelle 是否可以访问数据类型的各个元素?假设我有以下数据类型:

datatype foo = mat int int int int 

和(例如在引理中)

fixes A :: foo

是否可以访问 A 的单个元素?或者,修复单个元素 ( fix a b c d :: int),然后定义Amat a b c d?

4

2 回答 2

1
于 2018-01-22T17:32:22.220 回答
1

Alternatively it is possible to define custom extractor functions when specifying a data type. In your case, for example

datatype foo = Mat (mat_a : int) (mat_b : int) (mat_c : int) (mat_d : int)

would work.

Then you can access the first element of a foo value x by mat_a x, the second by mat_b x, and so on.

Example:

 value "mat_a (Mat 1 2 3 4)"

"1" :: "int"

于 2018-03-14T11:54:11.603 回答