expect to use the subgoal to run the list which defined by let? aa = [1,2] and run rev_app on this aa and show the value as [2,1]
f.input :invoice_file_date, as: :datepicker,
:input_html => { :disabled => !current_admin_user.role?(:admin) } if f.object.invoice_file.present?
(1 st trial)
theory Scratch2
imports Datatype
begin
datatype 'a list = Nil ("[]")
| Cons 'a "'a list" (infixr "#" 65)
(* This is the append function: *)
primrec app :: "'a list => 'a list => 'a list" (infixr "@" 65)
where
"[] @ ys = ys" |
"(x # xs) @ ys = x # (xs @ ys)"
primrec rev :: "'a list => 'a list" where
"rev [] = []" |
"rev (x # xs) = (rev xs) @ (x # [])"
primrec itrev :: "'a list => 'a list => 'a list" where
"itrev [] ys = ys" |
"itrev (x#xs) ys = itrev xs (x#ys)"
value "rev (True # False # [])"
lemma app_Nil2 [simp]: "xs @ [] = xs"
apply(induct_tac xs)
apply(auto)
done
lemma app_assoc [simp]: "(xs @ ys) @ zs = xs @ (ys @ zs)"
apply(induct_tac xs)
apply(auto)
done
(2nd trial)
lemma rev_app [simp]: "rev(xs @ ys) = (rev ys) @ (rev xs)"
apply(induct_tac xs)
thus ?aa by rev_app
show "rev_app [1; 2]"
(3 rd trial)
value "rev_app [1,2]"
答案 0 :(得分:0)
首先,您需要list枚举的语法(我只是在src / HOL / List.thy文件中选择它):
syntax
-- {* list Enumeration *}
"_list" :: "args => 'a list" ("[(_)]")
translations
"[x, xs]" == "x#[xs]"
"[x]" == "x#[]"
然后,您正在寻找以下其中一项?
命题1:
lemma example1: "rev [a, b] = [b, a]"
by simp
这个引理通过应用rev
的定义规则来证明,该方法simp用于重写左手术语并证明等式的两个边是相等的。这是我更喜欢的解决方案,因为即使没有使用Isabelle进行评估,您也可以看到示例得到满足。
命题2:
value "rev [a, b]" (* return "[b, a]" *)
在这里和命题3中,我们只使用命令value
来评估rev
。
命题3:
value "rev [a, b] = [b, a]" (* returns "True" *)
以前的命题没有使用这个引理:
lemma rev_app [simp]: "rev(xs @ ys) = (rev ys) @ (rev xs)"
apply (induct_tac xs)
by simp_all
注意: