您能建议如何将归纳规则应用于以下引理吗?
datatype 'a expr =
Literal "'a literal_expr"
| Var "string"
and 'a literal_expr =
NullLiteral
| CollectionLiteral "'a collection_literal_part_expr list"
and 'a collection_literal_part_expr =
CollectionItem "'a expr"
datatype 'a type = OclVoid | Set "'a type"
inductive typing and collection_parts_typing where
"typing Γ (Literal NullLiteral) OclVoid"
| "collection_parts_typing Γ prts τ ⟹
typing Γ (Literal (CollectionLiteral prts)) (Set τ)"
| "collection_parts_typing Γ [] OclVoid"
| "⟦typing Γ a τ; collection_parts_typing Γ xs σ⟧ ⟹
collection_parts_typing Γ (CollectionItem a # xs) σ"
lemma
"typing Γ1 expr τ1 ⟹ typing Γ1 expr σ1 ⟹ τ1 = σ1" and
"collection_parts_typing Γ2 prts τ2 ⟹
collection_parts_typing Γ2 prts σ2 ⟹ τ2 = σ2"
apply (induct expr and prts)
apply (induct rule: typing_collection_parts_typing.inducts)
以下问题包含一个非常简单的示例:
但是我的例子更加复杂。而且我不明白我的数据类型,谓词或引理有什么问题。无需相互递归就可以重新构造这一精确的理论。但这只是我实际理论的一小部分。
答案 0 :(得分:1)
存在一个可行的解决方案,该解决方案与您先前的question的已接受答案中提供的解决方案相似。请注意,我更改了定义中某些元素的名称,并且我严重依赖sledgehammer
来得出结论。
datatype 'a expr =
Literal "'a literal_expr"
| Var "string"
and 'a literal_expr =
NL
| CL "'a clpe list"
and 'a clpe = CI "'a expr"
datatype 'a type = OclVoid | Set "'a type"
inductive typing and cpt where
"typing Γ (Literal NL) OclVoid"
| "cpt Γ prts τ ⟹ typing Γ (Literal (CL prts)) (Set τ)"
| "cpt Γ [] OclVoid"
| "⟦typing Γ a τ; cpt Γ xs σ⟧ ⟹ cpt Γ (CI a # xs) σ"
lemma
fixes Γ1 Γ2 :: 'a
and expr :: "'b expr"
and prts :: "'b clpe list"
and σ1 τ1 σ2 τ2 :: "'c type"
shows
"typing Γ1 expr τ1 ⟹ typing Γ1 expr σ1 ⟹ τ1 = σ1" and
"cpt Γ2 prts τ2 ⟹ cpt Γ2 prts σ2 ⟹ τ2 = σ2"
apply(
induction Γ1 expr τ1 and Γ2 prts τ2
arbitrary: σ1 and σ2
rule: typing_cpt.inducts
)
subgoal by (blast dest: typing.cases)
subgoal
by (metis
expr.inject(1)
literal_expr.distinct(1)
literal_expr.inject
typing.cases)
subgoal by (blast dest: cpt.cases)
subgoal by (metis cpt.cases list.discI list.sel(3))
done