Hi,
If I have a domain of functions where input is {1..n} and output is {1..m}, can I express this as type?
Can you express this as a type? Yes, this is similar to the setup for words in HOL-Library.Word
typedef (overloaded) 'a bound = "{n. n ≤ LENGTH('a::len0)}"
by auto
definition test :: ‹3 bound ⇒ 5 bound› where
‹test = undefined›
Should you do it? I do not think so. Typelifting and co is not really easy to use and very annoying. It will be a lot easier to have an precondition on the function.
Thanks, will recheck.
Mathias Fleury said:
Can you express this as a type? Yes, this is similar to the setup for words in HOL-Library.Word
typedef (overloaded) 'a bound = "{n. n ≤ LENGTH('a::len0)}" by auto definition test :: ‹3 bound ⇒ 5 bound› where ‹test = undefined›
Should you do it? I do not think so. Typelifting and co is not really easy to use and very annoying. It will be a lot easier to have an precondition on the function.
This is very interesting. I’ve never head of LENGTH
and len0
. Where is this introduced, and where is this documented? Is this about type-level natural numbers? Also, what is the difference between len0
and len
, which the Word
theory uses?
len0 is the same as len but non-zero
Mostly because words of length 0 are weird
I see. Is there any documentation of LENGTH
, len
, and len0
somewhere? At the moment, I’m not sure what these exactly are and how to use them.
I don't think that there is much besides the point where this is defined (https://www.isa-afp.org/browser_info/devel/HOL/HOL-Word/Type_Length.html)
Well, that’s certainly pretty illuminating.
Last updated: Dec 21 2024 at 16:20 UTC