Isabelle 从具有多个参数的区域设置导出代码
根据文档部分“7.3语言环境和解释”,从语言环境导出代码有点棘手,但可以实现。以下示例很好地工作:Isabelle 从具有多个参数的区域设置导出代码,isabelle,Isabelle,根据文档部分“7.3语言环境和解释”,从语言环境导出代码有点棘手,但可以实现。以下示例很好地工作: locale localTest = fixes A :: "string" begin fun concatA :: "string ⇒ string" where "concatA x = x@A" definition concatAA :: "string ⇒ string" where "concatAA x = x@A@A" end definition localtes
locale localTest =
fixes A :: "string"
begin
fun concatA :: "string ⇒ string" where "concatA x = x@A"
definition concatAA :: "string ⇒ string" where "concatAA x = x@A@A"
end
definition localtest_concatA :: "string ⇒ string " where
[code del]: "localtest_concatA = localTest.concatA ''a''"
definition localtest_concatAA :: "string ⇒ string " where
[code del]: "localtest_concatAA = localTest.concatAA ''a''"
interpretation localTest "''a''"
where "localTest.concatA ''a'' = localtest_concatA"
and "localTest.concatAA ''a'' = localtest_concatAA"
apply unfold_locales
apply(simp_all add: localtest_concatA_def localtest_concatAA_def)
done
export_code localtest_concatA localtest_concatAA in Scala file -
如何为具有多个参数的区域设置导出代码?给定以下区域设置
:
locale localTest =
fixes A :: "string"
fixes B :: "string"
begin
fun concatA :: "string ⇒ string" where "concatA x = x@A"
definition concatB :: "string ⇒ string" where "concatB x = x@B"
end
我能用英语解释它
interpretation localTest "''a''" "''b''" .
但我不能在定义中使用这种解释
definition localtest_concatA :: "string ⇒ string " where
[code del]: "localtest_concatA = localTest.concatA ''a'' ''b''"
它失败了
Type unification failed: Clash of types "_ list" and "_ ⇒ _"
Type error in application: incompatible operand type
Operator: op = localtest_concatA :: (char list ⇒ char list) ⇒ bool
Operand: localTest.concatA ''a'' ''b'' :: char list
查看引入的常量,例如,通过
术语
命令。我们有
term localTest.concatA
有输出
"localTest.concatA" :: "char list ⇒ char list ⇒ char list"
"localTest.concatA ''a''" :: "char list ⇒ char list"
您可以看到,除了在原始定义(在区域设置内部)中提供的单个参数外,还有一个额外的参数(但只有1个而不是2个,因为定义不依赖于B
)
现在,在您的解释之后(因为您没有明确提供名称,localTest
的常量将不带限定符地在范围内),我们已经
有输出
"localTest.concatA" :: "char list ⇒ char list ⇒ char list"
"localTest.concatA ''a''" :: "char list ⇒ char list"
也就是说,localTest.concatA“a”
的类型已经是string=>string
。您还添加了“b”
,并获得类型字符串
,但您的类型注释显示string=>string
。因此确实存在类型冲突,原因是您为localTest.concatA
提供了太多参数。试用
definition localtest_concatA :: "string ⇒ string " where
[code del]: "localtest_concatA = concatA
相反