codegenのドキュメント セクション「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 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
:
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