Isabelle 扩展标准类型和操作是一个好主意吗?

Isabelle 扩展标准类型和操作是一个好主意吗?,isabelle,Isabelle,我需要定义一个扩展bool类型(ebool=bool)∪ {⊥})和类型的一组操作(连词等) 理论是这样的: theory EboolTest imports Main "~~/src/HOL/Library/Adhoc_Overloading" begin notation bot ("⊥") declare [[coercion_enabled]] typedef ebool = "UNIV :: bool option set" .. definition ebool ::

我需要定义一个扩展bool类型(
ebool=bool)∪ {⊥})和类型的一组操作(连词等)

理论是这样的:

theory EboolTest
  imports Main "~~/src/HOL/Library/Adhoc_Overloading"
begin

notation
  bot ("⊥")

declare [[coercion_enabled]]

typedef ebool = "UNIV :: bool option set" ..

definition ebool :: "bool ⇒ ebool" where
  "ebool b = Abs_ebool (Some b)"

declare [[coercion "ebool :: bool ⇒ ebool"]]

instantiation ebool :: bot
begin
definition "⊥ ≡ Abs_ebool None"
instance ..
end

free_constructors case_ebool for
  ebool
| "⊥ :: ebool"
  apply (metis Rep_ebool_inverse bot_ebool_def ebool_def not_Some_eq)
  apply (smt Abs_ebool_inverse ebool_def iso_tuple_UNIV_I option.inject)
  by (simp add: Abs_ebool_inject bot_ebool_def ebool_def)

lemmas ebool2_cases = ebool.exhaust[case_product ebool.exhaust]
lemmas ebool3_cases = ebool.exhaust[case_product ebool.exhaust ebool.exhaust]

fun ebool_and :: "ebool ⇒ ebool ⇒ ebool" (infixr "∧" 35) where
  "ebool_and a b = ebool (HOL.conj a b)"
| "ebool_and False _ = False"
| "ebool_and _ False = False"
| "ebool_and ⊥ _ = ⊥"
| "ebool_and _ ⊥ = ⊥"

no_notation HOL.conj (infixr "∧" 35)
consts "(∧)" :: "'a ⇒ 'a ⇒ 'a"
adhoc_overloading "(∧)" HOL.conj
adhoc_overloading "(∧)" ebool_and

end
以下工作很好:

value "True ∧ (False::ebool)"
value "True ∧ ⊥"
但是下面返回的是
ebool
,但我希望看到
bool

value "True ∧ False"

看来我的方法不好。你能建议一个更好的方法吗?也许我认为标准操作过载根本不好?

首先,我有点惊讶于:

consts "(∧)" :: "'a ⇒ 'a ⇒ 'a"
这听起来像个bug,因为
(…)
符号是为系统保留的。(公平地说,它确实会打印一条警告,除非你确切知道自己在做什么,否则忽略它们是不明智的。)

但是,为了回到您的实际问题,我不认为您应该使用
adhoc\u重载
来重载
Main
提供的语法

还有其他选择。例如,您可以使用粗体版本。这在中使用

或者您可以使用另一个符号,如
&&

作为补充:我相信强制和临时重载之间可能存在奇怪的交互作用。这两种工具本身都很好,但请注意它们是否相互交互