Types 尝试将类型类和子类型视为集合和子集
这个问题与我之前的SO问题有关 . 我问这个问题是为了建立一个关于地区的未来问题。我不认为类型类对我正在尝试做的事情有效,但是类型类的工作方式让我了解了我想要从语言环境中得到什么 下面,当我使用大括号表示法Types 尝试将类型类和子类型视为集合和子集,types,typeclass,set,isabelle,Types,Typeclass,Set,Isabelle,这个问题与我之前的SO问题有关 . 我问这个问题是为了建立一个关于地区的未来问题。我不认为类型类对我正在尝试做的事情有效,但是类型类的工作方式让我了解了我想要从语言环境中得到什么 下面,当我使用大括号表示法{0,0}时,它并不表示普通的大括号,0表示空集 如果你需要的话,可以给我一些文件 -友好的 -非ASCII友好 -显示行号的PDF -与此相关的主要项目 和文件夹 提问前谈话 我描述了我在THY中所做的事情(我在底部包括了它),然后我基本上会问,“我可以在这里做些什么来修复这个问题,以便
{0,0}
时,它并不表示普通的大括号,0
表示空集
如果你需要的话,可以给我一些文件
- -友好的
- -非ASCII友好
- -显示行号的PDF
- -与此相关的主要项目
- 和文件夹
半群\u add
。我所做的是使用typedef
创建我的类型sT
的子类型,然后尝试将一些基本函数常量和运算符提升到新类型中,例如我的联合运算符geU
、我的空集emS
、我的无序对集paS
、我的成员谓词inP
这不起作用,因为我试图将新类型视为一个子集。特别是,我的新类型应该表示集合{{0,0}}
,它是平凡半群的一部分,一个只有一个元素的半群
问题在于,无序对公理表示,如果setx
存在,则set(paS x)
存在,而union公理表示,如果setx
存在,则set(geU x)
存在。因此,当我尝试将我的并集运算符提升到新类型中时,证明器神奇地知道我需要证明(geU{0,0}={0,0})
,这不是真的,但在我的新类型中只有一个元素{0,0}
,所以必须这样
问题:
我能修好这个吗?在我看来,我将集合和子集与类型和子类型进行比较,我知道它们不一样。调用我的主类型sT
和我的子类型subT
。我需要的是,当subT
被视为typesT
时,使用typesT
定义的所有运算符,例如sT=>sT
,都可以用于typesubT
。使用类型subT
定义的新运算符和常量,例如类型subT=>subT
的函数,以某种方式会像事物一样工作,神奇地被认为与这些事物一起工作
提问后谈话
在这里,我以行号的形式指出发生了什么。行号将显示在PDF和GitHub网站上
在第21到71行中有四个部分,我结合了相关常数、符号和公理
sT
、成员谓词inP/PIn
、等式公理(21到33)emS/SEm
和空集公理(37到45)paS/SPa
和无序对公理(49到58)geU/UGe
和并集公理(62到71)typedef
创建一个新类型,然后将其实例化为type classsemigroup\u add
在我尝试提升无序对函数{.x,y.}
第108行和联合函数(geU x)
第114行之前,没有问题
在Isar命令下面,我显示了一个输出,它告诉我需要证明某些集合等于{0,0}
,这是一个无法证明的事实
这是一个ASCII友好的源代码,我从上面的链接中删除了一些注释和行:
theory A_i130424a
imports Complex_Main
begin
--"AXIOM (sT type, inP predicate, and the equality axiom)"
typedecl sT ("sT")
consts PIn :: "sT => sT => bool"
notation
PIn ("in'_P") and
PIn (infix "inP" 51) and
PIn (infix "inP" 51)
axiomatization where
Ax_x: "(! x. x inP r <-> x inP s) <-> (r = s)"
--"[END]"
--"AXIOM (emS and the empty set axiom)"
consts SEm :: "sT" ("emS")
notation (input)
SEm ("emS")
axiomatization where
Ax_em [simp]: "(x niP emS)"
--"[END]"
--"AXIOM (paS and the axiom of unordered pairs)"
consts SPa :: "sT => sT => sT"
notation
SPa ("paS") and
SPa ("({.(_),(_).})")
axiomatization where
Ax_pa [simp]: "(x inP {.r,s.}) <-> (x = r | x = s)"
--"[END]"
--"AXIOM (geU and the axiom of unions)"
consts UGe :: "sT => sT"
notation
UGe ("geU") and
UGe ("geU")
axiomatization where
Ax_un: "x inP geU r = (? u. x inP u & u inP r)"
--"[END]"
--"EXAMPLE (A typedef type cannot be treated as a set of type sT)"
typedef tdLift = "{x::sT. x = {.emS,emS.}}"
by(simp)
setup_lifting type_definition_tdLift
instantiation tdLift :: semigroup_add
begin
lift_definition plus_tdLift:: "tdLift => tdLift => tdLift"
is "% x y. {.emS,emS.}" by(simp)
instance
proof
fix n m q :: tdLift
show "(n + m) + q = n + (m + q)"
by(transfer,simp)
qed
end
theorem
"((n::tdLift) + m) + q = n + (m + q)"
by(transfer,simp)
class tdClass =
fixes emSc :: "'a" ("emSk")
fixes inPc :: "'a => 'a => bool" (infix "∈k" 51)
fixes paSc :: "'a => 'a => 'a" ("({.(_),(_).}k)")
fixes geUc :: "'a => 'a" ("⋃k")
instantiation tdLift :: tdClass
begin
lift_definition inPc_tdLift:: "tdLift => tdLift => bool"
is "% x y. x inP y"
by(simp)
lift_definition paSc_tdLift:: "tdLift => tdLift => tdLift"
is "% x y. {.x,y.}"
--"OUTPUT: 1. (!! (sT1 sT2). ([|(sT1 = emS); (sT2 = emS)|] ==> ({.sT1,sT2.} = emS)))"
apply(auto)
--"OUTPUT: 1. ({.emS.} = emS)"
oops
lift_definition geUc_tdLift:: "tdLift => tdLift"
is "% x. geU x"
--"OUTPUT: 1. (!! sT. ((sT = {.emS,emS.}) ==> ((geU sT) = {.emS,emS.})))"
apply(auto)
--"OUTPUT: 1. ((geU {.emS,emS.}) = {.emS,emS.})"
oops
lift_definition emSc_tdLift:: "tdLift"
is "emS"
--"OUTPUT:
exception THM 1 raised (line 333 of drule.ML):
RSN: no unifiers
(?t = ?t) [name HOL.refl]
((emS = {.emS,emS.}) ==> (Lifting.invariant (% x. (x = {.emS,emS.})) emS emS))"
oops
instance ..
end
--"[END]"
end
理论A_i130424a
输入复杂的主
开始
--公理(sT类型、inP谓词和等式公理)
类型DECL sT(“sT”)
常量PIn::“sT=>sT=>bool”
符号
PIn(“in”U P)和
引脚(中缀“inP”51)和
引脚(中缀“inP”51)
公理化
Ax_x:(!x.x inP r x inP s)(r=s)
--“[完]”
--“公理(emS和空集公理)”
结构方程组::“sT”(“emS”)
符号(输入)
扫描电镜(“emS”)
公理化
Ax_em[simp]:(x niP emS)
--“[完]”
--“公理(paS和无序对公理)”
consts SPa::“sT=>sT=>sT”
符号
SPa(“paS”)和
SPa(({(}),(})。)
公理化
Ax|pa[simp]:(x inP{.r,s})(x=r|x=s)
--“[完]”
--“公理(geU和联合公理)”
常数::“sT=>sT”
符号
UGe(“geU”)和
UGe(“geU”)
公理化
Ax_un:“x inP geU r=(?u.x inP u&u inP r)”
--“[完]”
--“示例(typedef类型不能视为一组sT类型)”
typedef tdLift=“{x::sT.x={.emS,emS.}”
由(simp)
设置\u提升类型\u定义\u t提升
实例化tdLift::半群添加
开始
提升定义加上提升::“tdLift=>tdLift=>tdLift”
是“%x y.{.emS,emS.}”by(simp)
实例
证明
固定n m q::tdLift
显示“(n+m)+q=n+(m+q)”
由(传输,simp)
量化宽松
结束
定理
“((n::tdLift)+m)+q=n+(m+q)”
由(传输,simp)
类tdClass=
修正emSc::“'a”(“emSk”)
修正inPc::“'a=>'a=>bool”(中缀)∈k“51)
修正了paSc::“'a=>'a=>'a”(“({(}),(}.}k)”)
修正geUc::“'a=>'a”(“⋃k“)
实例化tdLift::tdClass
开始
提升定义inPc\u tdLift::“tdLift=>tdLift=>bool”
是“%x y.x inP y”
由(simp)
电梯定义paSc\U tdLift::“tdLift=>tdLift=>tdLift”
是“%x y.{.x,y.}”
--输出:1.(!!(sT1 sT2)。([|(sT1=emS);(sT2=emS)|]==>({.sT1,sT2.}=emS)))
应用(自动)
--“输出:1。({.emS.}=emS)”
哎呀
电梯定义geUc\U tdLift::“tdLift=>tdLift”
是“%x.geU x”
--输出:1。(!!sT.((sT={.emS,
locale semigroup =
fixes f :: "'a => 'a => 'a" (infixl "*" 70)
assumes assoc [ac_simps]: "a * b * c = a * (b * c)"
locale sgA =
fixes G :: sT
fixes f :: "sT => sT => sT" (infixl "*" 70)
assumes closed:
"(a inP G) & (b inP G) --> (a * b) inP G"
assumes assoc:
"(a inP G) & (b inP G) & (c inP G) --> (a * b) * c = a * (b * c)"
theory A_iSemigroup_xp
imports MFZ
begin
--"[END]"
--"EXAMPLE (Possible subtype for a trivial semigroup)"
typedef tsA = "{x::sT. x = emS}"
by(simp)
theorem "(Rep_tsA x) inP {.Rep_tsA x.}"
by(metis
SSi_exists)
theorem "! x::tsA. x = (Abs_tsA emS)"
by(metis (lifting, full_types)
Abs_tsA_cases
mem_Collect_eq)
theorem "! x. x inP {.emS.} --> x = emS"
by(simp)
theorem "! x. x inP {.z inP {.emS.} ¦ z = emS.} --> x = emS"
by(simp)
--"[END]"
--"ISAR (Theory end)"
end