Isabelle 如何将可传递关系从元素提升到列表?

Isabelle 如何将可传递关系从元素提升到列表?,isabelle,theorem-proving,Isabelle,Theorem Proving,我试图证明列表元素上的传递关系等价于列表上的传递关系(在某些条件下) 这是第一个引理: lemma list_all2_rtrancl1: "(list_all2 P)⇧*⇧* xs ys ⟹ list_all2 P⇧*⇧* xs ys" apply (induct rule: rtranclp_induct) apply (simp add: list.rel_refl) by (smt list_all2_trans rtranclp.rtrancl_into_rtra

我试图证明列表元素上的传递关系等价于列表上的传递关系(在某些条件下)

这是第一个引理:

lemma list_all2_rtrancl1:
  "(list_all2 P)⇧*⇧* xs ys ⟹
   list_all2 P⇧*⇧* xs ys"
  apply (induct rule: rtranclp_induct)
  apply (simp add: list.rel_refl)
  by (smt list_all2_trans rtranclp.rtrancl_into_rtrancl)
这是一个对称引理:

lemma list_all2_rtrancl2:
  "(⋀x. P x x) ⟹
   list_all2 P⇧*⇧* xs ys ⟹
   (list_all2 P)⇧*⇧* xs ys"
  apply (erule list_all2_induct)
  apply simp
我想一个关系应该是反身的。但也许我应该用另一种假设。假设P是可传递的,但P不是可传递的,可以证明引理。我卡住了。你能建议选择什么样的假设以及如何证明这个引理吗

对于最后一个引理(
xs=[0]
ys=[2]
)的具体情况,Nitfick似乎给了我一个错误的反例:

我可以证明引理适用于这个例子:

lemma list_all2_rtrancl2_example_0_2:
  "list_all2 (λx y. x = y ∨ Suc x = y)⇧*⇧* [0] [2] ⟹
   (list_all2 (λx y. x = y ∨ Suc x = y))⇧*⇧* [0] [2]"
  apply (rule_tac ?b="[1]" in converse_rtranclp_into_rtranclp; simp)
  apply (rule_tac ?b="[2]" in converse_rtranclp_into_rtranclp; simp)
  done

使用
listrel
而不是
list\u all2
可能是可行的。实际上,如下所示,它们是等效的(请参见
set\u listrel\u eq\u list\u all2
)。然而,在标准库中有几个关于
listrel
的定理没有与
list\u all2
等价的定理



还提供了
列表所有2
的直接证据(遗留):

  • list\u all2\u induct
    应用于列表;基本情况并不重要。因此,它仍然显示
    (lp)*x#xs y#ys
    如果
    (lp*)xs ys
    (lp)*xs ys
    P*xy
  • 其思想是可以找到
    zs
    (例如
    xs
    ),从而
    (lp)xs zs
    (lp)+zs ys
  • 然后,假设
    P*x y
    px
    ,通过基于
    P*
    的传递性质的归纳,
    (lp)x#xs y#zs
    。因此,同样,
    (lp)*x#xs y#zs
  • 同样,假设
    (lp)+zsys
    pyy
    ,通过归纳,
    (lp)+y#zsy#ys
    。因此,同样,
    (lp)*y#zs y#ys
  • 从第3和第4节中,得出结论
    (lp)*x#xs y#ys


  • 作为旁注,在我看来(我对Nittick知之甚少),Nittick不应该在没有任何警告的情况下提供无效的反例。我相信,通常,当
    吹毛求疵
    怀疑某个反例可能无效时,它会通知用户该示例“可能是虚假的”。如果此问题未在其他地方记录,则提交错误报告可能很有用



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

    非常感谢您的帮助!我已经向邮件列表发送了关于挑剔的错误报告。谢谢!对我来说,校样里有很多新东西。我不懂感应装置和传输包。这是研究它们的一个很好的理由。@Denis我很惊讶你提到你不理解归纳集。从你的其他问题来看,你似乎理解归纳定义的谓词。在HOL:
    “px中,谓词和集合之间存在明显的对应关系⟷ x∈ {x.px}“
    。当然,有许多书籍/课堂讲稿为归纳集提供了理论背景,例如,见此。@Denis在《高阶逻辑的证明助手》(PA)一书的第7.1节中有一个很好的例子,演示了HOL中归纳定义集和归纳定义谓词之间的对应关系以及《Isabelle/HOL的具体语义》(CS)一书中的第4.5.1节。PA给出了使用“归纳集”构造偶数集的示例,CS给出了确定自然数是否使用“归纳集”的谓词构造示例。
    lemma list_all2_rtrancl2_example_0_2:
      "list_all2 (λx y. x = y ∨ Suc x = y)⇧*⇧* [0] [2] ⟹
       (list_all2 (λx y. x = y ∨ Suc x = y))⇧*⇧* [0] [2]"
      apply (rule_tac ?b="[1]" in converse_rtranclp_into_rtranclp; simp)
      apply (rule_tac ?b="[2]" in converse_rtranclp_into_rtranclp; simp)
      done
    
    lemma set_listrel_eq_list_all2: 
      "listrel {(x, y). r x y} = {(xs, ys). list_all2 r xs ys}"
      using list_all2_conv_all_nth listrel_iff_nth by fastforce
    
    lemma listrel_tclosure_1: "(listrel r)⇧* ⊆ listrel (r⇧*)"
      by 
        (
          simp add: 
            listrel_rtrancl_eq_rtrancl_listrel1 
            listrel_subset_rtrancl_listrel1 
            rtrancl_subset_rtrancl
        )
    
    lemma listrel_tclosure_2: "refl r ⟹ listrel (r⇧*) ⊆ (listrel r)⇧*"
      by 
        (
          simp add: 
            listrel1_subset_listrel 
            listrel_rtrancl_eq_rtrancl_listrel1 
            rtrancl_mono
        )
    
    context 
      includes lifting_syntax
    begin
    
    lemma listrel_list_all2_transfer[transfer_rule]:
      "((=) ===> (=) ===> (=) ===> (=)) 
      (λr xs ys. (xs, ys) ∈ listrel {(x, y). r x y}) list_all2"
      unfolding rel_fun_def using set_listrel_eq_list_all2 listrel_iff_nth by blast
    
    end
    
    lemma list_all2_rtrancl_1:
      "(list_all2 r)⇧*⇧* xs ys ⟹ list_all2 r⇧*⇧* xs ys"
    proof transfer
      fix r :: "'a ⇒ 'a ⇒ bool" and xs :: "'a list" and ys:: "'a list"
      assume "(λxs ys. (xs, ys) ∈ listrel {(x, y). r x y})⇧*⇧* xs ys"
      then have "(xs, ys) ∈ (listrel {(x, y). r x y})⇧*"
        unfolding rtranclp_def rtrancl_def by auto  
      then have "(xs, ys) ∈ listrel ({(x, y). r x y}⇧*)" 
        using listrel_tclosure_1 by auto
      then show "(xs, ys) ∈ listrel {(x, y). r⇧*⇧* x y}"
        unfolding rtranclp_def rtrancl_def by auto  
    qed
    
    lemma list_all2_rtrancl_2:
      "reflp r ⟹ list_all2 r⇧*⇧* xs ys ⟹ (list_all2 r)⇧*⇧* xs ys"
    proof transfer
      fix r :: "'a ⇒ 'a ⇒ bool" and xs :: "'a list" and ys :: "'a list"
      assume as_reflp: "reflp r" and p_in_lr: "(xs, ys) ∈ listrel {(x, y). r⇧*⇧* x y}"
      from as_reflp have refl: "refl {(x, y). r x y}" 
        using reflp_refl_eq by fastforce
      from p_in_lr have "(xs, ys) ∈ listrel ({(x, y). r x y}⇧*)"
        unfolding rtranclp_def rtrancl_def by auto
      with refl have "(xs, ys) ∈ (listrel {(x, y). r x y})⇧*"
        using listrel_tclosure_2 by auto
      then show "(λxs ys. (xs, ys) ∈ listrel {(x, y). r x y})⇧*⇧* xs ys" 
        unfolding rtranclp_def rtrancl_def by auto
    qed
    
    lemma list_all2_rtrancl2:
      assumes as_r: "(⋀x. P x x)" 
      shows "(list_all2 P⇧*⇧*) xs ys ⟹ (list_all2 P)⇧*⇧* xs ys"
    proof(induction rule: list_all2_induct)
      case Nil then show ?case by simp
    next
      case (Cons x xs y ys) show ?case
      proof -
        from as_r have lp_xs_xs: "list_all2 P xs xs" by (rule list_all2_refl)
        from Cons.hyps(1) have x_xs_y_zs: "(list_all2 P)⇧*⇧* (x#xs) (y#xs)"
        proof(induction rule: rtranclp_induct)
          case base then show ?case by simp
        next
          case (step y z) then show ?case 
          proof -
            have rt_step_2: "(list_all2 P)⇧*⇧* (y#xs) (z#xs)" 
              by (rule r_into_rtranclp, rule list_all2_Cons[THEN iffD2]) 
                (simp add: step.hyps(2) lp_xs_xs)
            from step.IH rt_step_2 show ?thesis by (rule rtranclp_trans) 
          qed      
        qed
        from Cons.IH have "(list_all2 P)⇧*⇧* (y#xs) (y#ys)"
        proof(induction rule: rtranclp_induct)
          case base then show ?case by simp
        next
          case (step ya za) show ?case
          proof -
            have rt_step_2: "(list_all2 P)⇧*⇧* (y#ya) (y#za)" 
              by (rule r_into_rtranclp, rule list_all2_Cons[THEN iffD2])     
                (simp add: step.hyps(2) as_r)
            from step.IH rt_step_2 show ?thesis by (rule rtranclp_trans)
          qed
        qed
        with x_xs_y_zs show ?thesis by simp
      qed
    qed