Isabelle 如何为BNF生成代码?
我正在尝试定义自定义集类型:Isabelle 如何为BNF生成代码?,isabelle,Isabelle,我正在尝试定义自定义集类型: notation bot ("⊥") typedef 'a myset = "UNIV :: 'a fset option set" .. definition myset :: "'a fset ⇒ 'a myset" where "myset b = Abs_myset (Some b)" instantiation myset :: (type) bot begin definition "⊥ = Abs_myset None" instance .
notation bot ("⊥")
typedef 'a myset = "UNIV :: 'a fset option set" ..
definition myset :: "'a fset ⇒ 'a myset" where
"myset b = Abs_myset (Some b)"
instantiation myset :: (type) bot
begin
definition "⊥ = Abs_myset None"
instance ..
end
free_constructors case_myset for
myset
| "⊥ :: 'a myset"
apply (simp_all add: bot_myset_def myset_def)
apply (metis Rep_myset_inverse option.collapse)
apply (metis Abs_myset_inverse iso_tuple_UNIV_I option.inject)
apply (metis Abs_myset_inverse iso_tuple_UNIV_I option.distinct(1))
done
copy_bnf 'a myset
value "map_myset (λx. x + 1) (myset {|1::int,2|})"
似乎没有为map\u myset
函数生成代码。因此,value
无法简化最后一行中的表达式
我试图为map\u myset
定义代码等式:
lemma map_myset_code [code]:
"map_myset f xs = (case xs
of myset fxs ⇒ myset (f |`| fxs)
| ⊥ ⇒ ⊥)"
apply (simp add: map_myset_def)
apply (cases xs)
apply (auto simp add: myset_def Abs_myset_inverse)
但我无法证明它的正确性,因为map\u myset
是使用MySetTest.myset.option.map\u option
定义的:
map_myset ≡ λf. Abs_myset ∘ MySetTest.myset.option.map_option f ∘ Rep_myset
如何找到此函数的定义?是否可以为BNF自动生成代码?如果您对代码感兴趣,我建议使用提升/转移包,而不是直接使用Abs/Rep等。在许多情况下,您可以免费获得代码
notation bot ("⊥")
typedef 'a myset = "UNIV :: 'a fset option set" ..
setup_lifting type_definition_myset
lift_definition myset :: "'a fset ⇒ 'a myset" is Some .
instantiation myset :: (type) bot
begin
lift_definition bot_myset :: "'a myset" is None .
instance ..
end
lift_definition map_myset :: "('a ⇒ 'b) ⇒ 'a myset ⇒ 'b myset"
is "map_option o fimage" .
lift_definition of_fset :: "'a fset ⇒ 'a myset" is Some .
value "map_myset (λx. x + 1) (of_fset {|1::int,2|})"
我希望这有帮助,
勒内