What is the syntax to use Map.thy

邮差的信 提交于 2019-12-11 04:59:07

问题


So far I can define a map

map_of [(1, 2), (3, 4::int)]

of type

'a => int option

When I try to get the domain of the map:

dom (map_of [(1, 2), (3, 4::int)])

give the error

Wellsortedness error:
Type 'b not of sort enum
Cannot derive subsort relation {equal,numeral} < enum

The examples in Enum.thy only show finite cases, how do you prove the enum property for an infinite type like int or nat?

Update 1: Fixed the syntax and give the exact error message


回答1:


This looks like a problem that occurs when trying to evaluate the expression

dom (map_of [(1, 2), (3, 4::int)])

e.g. using the "value" command.

The reason why this doesn't work is that "map_of" essentially gives you a function and the domain of a function is not in general computable.

Still, you can use your map and carry out proofs:

lemma "dom (map_of [(1, 2), (3, 4::nat)]) = {1, 3}"
by simp

Or, if you'd rather have something computable, then you can just keep using lists of tuples. In Isabelle2016-1, there will be a dedicated "finite map" type too:

theory Scratch
  imports "~~/src/HOL/Library/Finite_Map"
begin

value "fmdom' (fmap_of_list [(1, 2), (3, 4::nat)])"
(* prints "{1, 1 + 1 + 1}" *)


来源:https://stackoverflow.com/questions/39399652/what-is-the-syntax-to-use-map-thy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!