Isabelle 确定记录类型属于给定类
我制作了一个名为Isabelle 确定记录类型属于给定类,isabelle,theorem-proving,Isabelle,Theorem Proving,我制作了一个名为图形的记录类型,并定义了一个合适的“is a subgraph of”关系。我想说明的是,这组图与子图关系构成了一个顺序,即是ord类的一个实例。但我不能让它工作。以下是我的最小工作示例: theory John imports Main begin typedecl node record graph = nodes :: "node set" edges :: "(node × node) set" definition subgraph :: "graph
图形的记录类型,并定义了一个合适的“is a subgraph of”关系。我想说明的是,这组图与子图关系构成了一个顺序,即是ord
类的一个实例。但我不能让它工作。以下是我的最小工作示例:
theory John imports
Main
begin
typedecl node
record graph =
nodes :: "node set"
edges :: "(node × node) set"
definition subgraph :: "graph ⇒ graph ⇒ bool"
(infix "⊑" 50)
where
"G ⊑ H ≡
nodes G ⊆ nodes H ∧ edges G ⊆ edges H"
lemma "(GREATEST H. H ⊑ G) = G"
oops
end
我得到一个错误:
类型统一失败:没有类型arity图\u ext::ord“
我试着键入诸如实例化图::ord
和实例化图_ext::ord
之类的东西,但似乎什么都不起作用。有什么想法吗?当定义了一个记录图
时,在幕后实际上创建了一个新的类型“一个图_ext
。这个类型与您的记录类型相同,但有一个额外的字段d,允许添加额外数据(即,记录定义中添加了一个类型为'a
的新字段,可用于以后向记录中添加额外数据)。类型图形
只是单位图_ext
的缩写
这意味着,当您想要将图形
实例化为类型类时,实际上需要实例化底层类型'a graph\u ext
。这可以按如下方式完成:
instantiation graph_ext :: (type) ord
begin
instance ..
end
instantiation graph_ext :: (type) ord
begin
definition "less_eq_graph_ext (G :: 'a graph_ext) (H :: 'a graph_ext) ≡
nodes G ⊆ nodes H ∧ edges G ⊆ edges H"
definition "less_graph_ext (G :: 'a graph_ext) (H :: 'a graph_ext)
≡ (nodes G ⊆ nodes H ∧ edges G ⊆ edges H) ∧
¬ (nodes H ⊆ nodes G ∧ edges H ⊆ edges G)"
instance ..
end
尽管您可能还想为ord
类型提供一些定义,可能如下所示:
instantiation graph_ext :: (type) ord
begin
instance ..
end
instantiation graph_ext :: (type) ord
begin
definition "less_eq_graph_ext (G :: 'a graph_ext) (H :: 'a graph_ext) ≡
nodes G ⊆ nodes H ∧ edges G ⊆ edges H"
definition "less_graph_ext (G :: 'a graph_ext) (H :: 'a graph_ext)
≡ (nodes G ⊆ nodes H ∧ edges G ⊆ edges H) ∧
¬ (nodes H ⊆ nodes G ∧ edges H ⊆ edges G)"
instance ..
end
一旦'一个图形外部
被实例化到类ord
中,您的最终引理类型检查(尽管要实际执行证明,您可能需要做更多的工作,例如将一个图形外部
实例化到预序
或顺序
类中。)