So I have two custom datatypes:
datatype ('a, 't) action = ACTION (name: "'a") (args: "'t list") ("⌈_ _⌋")
and
datatype ('a, 't) multiaction = MULTIACTION "('a, 't) action multiset" ("⟨(_)⟩")
Both of them work with their given notations, however whenever I want to use these data structures in their pretty-printed format, it looks a little redundant. For example:
value "⟨{#⌈a b⌋, ⌈c d⌋#}⟩"
What I'd like to do is have the above typed without the multiset brackets, so that it looks like this:
value "⟨⌈a b⌋, ⌈c d⌋⟩"
What I've tried is using syntax:
syntax
"_maction" :: "args ⇒ ('a, 't) multiaction" ("⟨_⟩" [0] 60)
translations
"⟨x⟩" == "CONST MULTIACTION {#x#}"
But when I try it out with some datatypes:
value "⟨⌈''x'' [1,2,3::int]⌋⟩"
But I get a wellsortedness error, which I have no idea why it occurs. Can I please have some help with this?
Thanks in advance!
Perhaps, you are looking to lift the multiset
syntax to multiaction
? In this case, you may also wish to lift the relevant definitions for the multiset
(as noted in the comments, ideally, you will wish to use the datatype
/ lift_definition
infrastructure for this):
datatype ('a, 't) action = ACTION (name: "'a") (args: "'t list") ("⌈_ _⌋")
datatype ('a, 't) multiaction = MULTIACTION "('a, 't) action multiset"
(*this should not be lifted manually: use the integration of
the datatype and lifting infrastructure*)
fun add_multiaction ::
"('a, 'b) action ⇒ ('a, 'b) multiaction ⇒ ('a, 'b) multiaction"
where "add_multiaction x (MULTIACTION xs) = MULTIACTION (add_mset x xs)"
abbreviation MAempty :: "('a, 't) multiaction" ("⟨#⟩") where
"MAempty ≡ MULTIACTION {#}"
syntax
"_multiaction" :: "args ⇒ ('a, 't) multiaction" ("⟨(_)⟩")
translations
"⟨x, xs⟩" == "CONST add_multiaction x ⟨xs⟩"
"⟨x⟩" == "CONST add_multiaction x ⟨#⟩"
value "⟨⌈''x'' [1,2,3::int]⌋, ⌈''x'' [1,2,3::int]⌋⟩"
I have to admit I am not entirely certain if I fully understood what exactly you are trying to achieve: I am providing the first idea that came to my mind based on not-very-thorough understanding of the question.
Isabelle version: Isabelle2021-RC6
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.