我想在伊莎贝尔(Isabelle)中证明以下引理:
lemma "T (Open # xs) ⟹ ¬ S (Open # xs) ⟹ count xs Close ≤ count xs Open"
请找到以下定义:
datatype paren = Open | Close
inductive S where
S_empty: "S []" |
S_append: "S xs ⟹ S ys ⟹ S (xs @ ys)" |
S_paren: "S xs ⟹ S (Open # xs @ [Close])"
inductive T where
T_S: "T []" |
T_append: "T xs ⟹ T ys ⟹ T (xs @ ys)" |
T_paren: "T xs ⟹ T (Open # xs @ [Close])" |
T_left: "T xs ⟹ T (Open # xs)"
引理指出,不平衡的括号结构将在删除Open
括号时导致可能不平衡的结构。
我一直在尝试“高阶逻辑的证明助手”一书中描述的技术,但是到目前为止,它们都不起作用。特别是,我尝试使用规则反转和规则归纳,sledgehammer
等技术。
问题之一是我尚未了解Isar证明,这使证明变得复杂。如果您可以使用简单的Apply命令来定向我,我会更愿意。
答案 0 :(得分:1)
请在下面找到证明。改进的可能性不大:我尝试遵循最简单的证明方法,并依靠sledgehammer
来填写细节。
theory so_raoidii
imports Complex_Main
begin
datatype paren = Open | Close
inductive S where
S_empty: "S []" |
S_append: "S xs ⟹ S ys ⟹ S (xs @ ys)" |
S_paren: "S xs ⟹ S (Open # xs @ [Close])"
inductive T where
T_S: "T []" |
T_append: "T xs ⟹ T ys ⟹ T (xs @ ys)" |
T_paren: "T xs ⟹ T (Open # xs @ [Close])" |
T_left: "T xs ⟹ T (Open # xs)"
lemma count_list_lem:
"count_list xsa a = n ⟹
count_list ysa a = m ⟹
count_list (xsa @ ysa) a = n + m"
apply(induction xsa arbitrary: ysa n m)
apply auto
done
lemma T_to_count: "T xs ⟹ count_list xs Close ≤ count_list xs Open"
apply(induction rule: T.induct)
by (simp add: count_list_lem)+
lemma T_to_S_count: "T xs ⟹ count_list xs Close = count_list xs Open ⟹ S xs"
apply(induction rule: T.induct)
apply(auto)
apply(simp add: S_empty)
apply(metis S_append T_to_count add.commute add_le_cancel_right count_list_lem
dual_order.antisym)
apply(simp add: count_list_lem S_paren)
using T_to_count by fastforce
lemma "T (Open # xs) ⟹
¬ S (Open # xs) ⟹
count_list xs Close ≤ count_list xs Open"
apply(cases "T xs")
apply(simp add: T_to_count)
using T_to_S_count T_to_count by fastforce
end