From: David Kretzmer <david.k@posteo.de>
Dear all,
it seems that the special code generation setup for List.member in
theory "HOL-Library.Predicate_Compile_Alternative_Defs" overwrites SML's
List structure, which means you cannot access any of the standard List
functions after including the generated code.
Minimal code:
theory Scratch
imports Main "HOL-Library.Predicate_Compile_Alternative_Defs"
begin
inductive is_member :: "'a list ⇒ 'a ⇒ bool" where
"List.member xs x ⟹ is_member xs x"
code_pred is_member .
export_code is_member in SML
end
My current fix is to assign the original List structure to another
structure before importing the generated SML code.
Best regards,
David Kretzmer
From: David Kretzmer <david.k@posteo.de>
Hi Florian,
ah, you are right. I was a bit confused because the theory
"HOL-Library.Predicate_Compile_Alternative_Defs" already contains the
following code_identifier:
code_identifier constant member_i_i
⇀ (SML) "List.member_i_i"
and (OCaml) "List.member_i_i"
and (Haskell) "List.member_i_i"
and (Scala) "List.member_i_i"
Here, "List.member_i_i" for SML was the problem. But you are right, one
can simply add another code_identifier later, which then overwrites the
previous one.
However, this feels more like a hack. Other List functions (fold etc)
are put into a "Lista" structure so as to not collide with the standard
"List" structure of SML. Why is this different for member_i_i?
Anyway, thank you for this fix!
Best regards,
David
From: Florian Haftmann <florian.haftmann@informatik.tu-muenchen.de>
Hi David,
this seems to be a historic accident:
String.thy contains a
code_reserved SML string String Char List
since the notoriously difficult conversions need List.map.
This situation is not easily resolved. But I will think further about it.
Cheers,
Florian
signature.asc
From: Florian Haftmann <florian.haftmann@informatik.tu-muenchen.de>
For the record,
this issue is now addressed in rev. 1b812435a632
Cheers,
Florian
OpenPGP_signature
Last updated: Jan 04 2025 at 20:18 UTC