为什么我不能像Isabelle中的定义那样应用函数的单个步骤?

为什么我不能像Isabelle中的定义那样应用函数的单个步骤?,isabelle,theorem-proving,Isabelle,Theorem Proving,我正在努力做到: datatype my_bool = true | false value "true" (* it has value true with type my_bool *) fun conj :: "my_bool ⇒ my_bool ⇒ my_bool" where "conj true true = true" | "conj _ _ = false" lemma "conj true true = true" apply (simp only: conj_def

我正在努力做到:

datatype my_bool = true | false
value "true" (* it has value true with type my_bool *)

fun conj :: "my_bool ⇒ my_bool ⇒ my_bool" where 
"conj true true = true" |
"conj _ _ = false"

lemma "conj true true = true"
  apply (simp only: conj_def)
但我得到了一个错误:

Undefined fact: "conj_def"⌂

我理解错误,但不理解为什么我不能像处理定义那样应用单个simp。函数可以这样做吗?

当您使用命令定义定义一个新常数时,会自动提供一个类似conj_def的定理。实际上,可以控制该定理的名称。命令fun不会自动提供定理名称,其中name是常量的名称。然而,它提供了各种其他定理。您可以使用命令fun在指定常量后键入print_定理来查看这些定理。比如说,

datatype my_bool = true | false

fun conj :: "my_bool ⇒ my_bool ⇒ my_bool" 
  where 
  "conj true true = true" 
| "conj _ _ = false"

print_theorems
例如,在上面的代码列表中,fun命令提供了事实conj.simps,这很可能是您正在寻找的:

lemma "conj true true = true"
  by (simp only: conj.simps)
从技术上讲,可以恢复Isabelle/ML中任何常数的原始定义公理,包括conj。可以从[1]中获得有关定义原则的一些见解,但可能有更多专门的参考:

theory Scratch
  imports Main
  keywords "get_da" :: diag
begin

ML‹

fun apdupr f x = (x, f x);

fun axioms_of_const ctxt (c, T) =
  let 
    val thy = Proof_Context.theory_of ctxt
    val defs = Theory.defs_of thy
  in
    (c, T)
    |> Theory.const_dep thy
    |> #1
    |> Defs.specifications_of defs
    |> map #def
    |> filter is_some
    |> map (the #> try (Thm.axiom thy))
    |> filter is_some
    |> map (the #> Local_Defs.abs_def_rule ctxt)
    |> map (apdupr (Thm.cprop_of #> Thm.dest_equals_lhs #> Thm.typ_of_cterm))
    |> filter (#2 #> curry (swap #> Type.could_match) T)
    |> map #1
  end;

fun process_da t st =
  let 
    val ctxt = Toplevel.context_of st
    val const = t
      |> Proof_Context.read_term_pattern ctxt 
      |> dest_Const
    val _ = const
      |> axioms_of_const ctxt 
      |> map (Thm.string_of_thm ctxt)
      |> map writeln
  in () end


val tts_find_sbts = Outer_Syntax.command
  \<^command_keyword>‹get_da›
  "print definitional axioms"
  (Parse.const >> (process_da #> Toplevel.keep));

›


datatype my_bool = true | false

fun conj :: "my_bool ⇒ my_bool ⇒ my_bool" 
  where 
  "conj true true = true" 
| "conj _ _ = false"

print_theorems

lemma "conj true true = true"
  by (simp only: conj.simps)

get_da conj_graph
get_da conj_sumC
get_da conj


text‹The type of the input to the command @{command get_da} is important:›

get_da ‹plus::nat⇒nat⇒nat›
get_da ‹plus::int⇒int⇒int›

end
然而,正如Manuel Eberl在评论中所指出的那样,对于终端用户来说,这些公理对于大多数实际目的并不特别有用

伊莎贝尔版本:伊莎贝尔2020

参考资料:

Haftmann F,Wenzel M.Isabelle/Isar中的局部理论规范。在:贝拉迪S,达米亚尼F,德利古罗U,编辑。校样和程序的类型。海德堡:斯普林格;2009P153–68.
当您使用命令定义定义一个新常量时,会自动提供一个类似conj_def的定理。实际上,可以控制该定理的名称。命令fun不会自动提供定理名称,其中name是常量的名称。然而,它提供了各种其他定理。您可以使用命令fun在指定常量后键入print_定理来查看这些定理。比如说,

datatype my_bool = true | false

fun conj :: "my_bool ⇒ my_bool ⇒ my_bool" 
  where 
  "conj true true = true" 
| "conj _ _ = false"

print_theorems
例如,在上面的代码列表中,fun命令提供了事实conj.simps,这很可能是您正在寻找的:

lemma "conj true true = true"
  by (simp only: conj.simps)
从技术上讲,可以恢复Isabelle/ML中任何常数的原始定义公理,包括conj。可以从[1]中获得有关定义原则的一些见解,但可能有更多专门的参考:

theory Scratch
  imports Main
  keywords "get_da" :: diag
begin

ML‹

fun apdupr f x = (x, f x);

fun axioms_of_const ctxt (c, T) =
  let 
    val thy = Proof_Context.theory_of ctxt
    val defs = Theory.defs_of thy
  in
    (c, T)
    |> Theory.const_dep thy
    |> #1
    |> Defs.specifications_of defs
    |> map #def
    |> filter is_some
    |> map (the #> try (Thm.axiom thy))
    |> filter is_some
    |> map (the #> Local_Defs.abs_def_rule ctxt)
    |> map (apdupr (Thm.cprop_of #> Thm.dest_equals_lhs #> Thm.typ_of_cterm))
    |> filter (#2 #> curry (swap #> Type.could_match) T)
    |> map #1
  end;

fun process_da t st =
  let 
    val ctxt = Toplevel.context_of st
    val const = t
      |> Proof_Context.read_term_pattern ctxt 
      |> dest_Const
    val _ = const
      |> axioms_of_const ctxt 
      |> map (Thm.string_of_thm ctxt)
      |> map writeln
  in () end


val tts_find_sbts = Outer_Syntax.command
  \<^command_keyword>‹get_da›
  "print definitional axioms"
  (Parse.const >> (process_da #> Toplevel.keep));

›


datatype my_bool = true | false

fun conj :: "my_bool ⇒ my_bool ⇒ my_bool" 
  where 
  "conj true true = true" 
| "conj _ _ = false"

print_theorems

lemma "conj true true = true"
  by (simp only: conj.simps)

get_da conj_graph
get_da conj_sumC
get_da conj


text‹The type of the input to the command @{command get_da} is important:›

get_da ‹plus::nat⇒nat⇒nat›
get_da ‹plus::int⇒int⇒int›

end
然而,正如Manuel Eberl在评论中所指出的那样,对于终端用户来说,这些公理对于大多数实际目的并不特别有用

伊莎贝尔版本:伊莎贝尔2020

参考资料:

Haftmann F,Wenzel M.Isabelle/Isar中的局部理论规范。在:贝拉迪S,达米亚尼F,德利古罗U,编辑。校样和程序的类型。海德堡:斯普林格;2009P153–68.
另外:为使用函数包定义的函数生成的定义引理相当难看,这就是为什么它会自动隐藏,这样用户就不会意外地使用它而感到困惑。simps方程是展开函数包定义的函数定义的标准方法。我在引理后打印了_定理,但没有显示任何内容。它什么时候显示东西?仅在定义之后?似乎也是一个有状态的命令…@Pinocchio根据文档:print_定理打印最后一个命令产生的背景理论的定理;。。。因此,它通常应该与其他命令一起工作。如果您提供一个失败的可复制示例,我可能能够提供进一步的帮助。此外:为使用函数包定义的函数生成的定义引理相当难看,这就是为什么它会自动隐藏,以便用户不会意外地使用它并感到困惑。simps方程是展开函数包定义的函数定义的标准方法。我在引理后打印了_定理,但没有显示任何内容。它什么时候显示东西?仅在定义之后?似乎也是一个有状态的命令…@Pinocchio根据文档:print_定理打印最后一个命令产生的背景理论的定理;。。。因此,它通常应该与其他命令一起工作。如果你提供一个失败的可复制的例子,我可能会提供进一步的帮助。