Isabelle 如何定义映射的映射?
理论上有两种值-Isabelle 如何定义映射的映射?,isabelle,Isabelle,理论上有两种值-val1和val2: type_synonym bool3 = "bool option" datatype val1 = BVal1 bool3 | IVal1 int | SVal1 string datatype val2 = BVal2 bool | IVal2 int 我可以使用以下归纳谓词映射它们: inductive map_val_ind :: "val1 ⇒ val2 ⇒ bool" where "map_val_ind (BVal1 (Some v))
val1
和val2
:
type_synonym bool3 = "bool option"
datatype val1 = BVal1 bool3 | IVal1 int | SVal1 string
datatype val2 = BVal2 bool | IVal2 int
我可以使用以下归纳谓词映射它们:
inductive map_val_ind :: "val1 ⇒ val2 ⇒ bool" where
"map_val_ind (BVal1 (Some v)) (BVal2 v)"
| "map_val_ind (IVal1 v) (IVal2 v)"
code_pred [show_modes] map_val_ind .
values "{t. map_val_ind (BVal1 (Some True)) t}"
或以下功能:
fun map_val :: "val1 ⇒ val2 option" where
"map_val (BVal1 (Some v)) = Some (BVal2 v)"
| "map_val (IVal1 v) = Some (IVal2 v)"
| "map_val _ = None"
value "map_val (BVal1 (Some True))"
我更喜欢归纳谓词,因为它是双向的
我还需要映射变量的环境:
type_synonym vname = "string"
type_synonym 'a env = "vname ⇒ 'a option"
1) 以下是首次尝试定义映射:
definition map_env :: "val1 env ⇒ val2 env ⇒ bool" where
"map_env env1 env2 ≡ ∀x. ∃y z.
env1 x = Some y ∧
env2 x = Some z ∧
map_val_ind y z"
问题是它不是建设性的,我不明白如何使用这个定义来映射环境
2) 以下是功能定义:
definition map_env_fun :: "val1 env ⇒ (val2 env) option" where
"map_env_fun env = (if ∀x. ∃y z. env x = Some y ∧ map_val y = Some z
then Some (λx. map_val (the (env x)))
else None)"
value "map_env_fun [''x'' ↦ BVal1 (Some True)]"
但我得到了以下错误:
Wellsortedness error
(in code equation map_env_fun ?env ≡
if ∀x. ∃y z. equal_option_inst.equal_option (?env x) (Some y) ∧
equal_option_inst.equal_option (map_val y) (Some z)
then Some (λx. map_val (the (?env x))) else None,
with dependency "Pure.dummy_pattern" -> "map_env_fun"):
Type char list not of sort enum
No type arity list :: enum
3) 这是一个归纳的版本:
inductive map_env_ind :: "val1 env ⇒ val2 env ⇒ bool" where
"env1 x = Some y ⟹
env2 x = Some z ⟹
map_val_ind y z ⟹
map_env_ind env1 env2"
code_pred [show_modes] map_env_ind .
问题是code\u pred
无法推断任何执行模式
如何定义这样的环境映射?我更喜欢归纳版本,因为它是双向的,并且更容易证明归纳谓词的引理