Let\'s say I wrote a function for reversing a list. I want to test it out using the value
command, just to assure myself that I probably got it right. But the outpu
Note: I hope my answer here doesn't prevent Brian Huffman or Florian Haftmann from giving an answer. If it does, that would be a bad thing. Hopefully, I'm just doing some gofer work to set either of them up.
Short answer 1: The pertinent mailing list email is Re: [isabelle] value no longer pretty-prints numbers of type nat.
Short answer 2: A solution for nat
is to import "~~/src/HOL/Library/Code_Target_Nat"
. Because I'm not clear on the details of how numeral
and num
are completely tied into HOL at the low level, the solution I'm giving you is not necessarily a good and final solution.
A big part of my answer here is partly to say, before Brian Huffman or Florian Haftmann get here, who are the authors of Num.thy, "I'm interested in this too, because it's related to numeral
, which is a powerful part of HOL. The more info I have about the intricacies of using numeral
, the better".
Basically, they made a design choice change for Isabelle2013-1, which is to have the default for nat
and numeral
be represented in a successor form. That's what the mailing list email is about.
If you use declare[[show_sorts=true]]
, you will see that your value "reverse [1,8,3]"
is using type class numeral
. I mention that because I've been putting a lot of effort into trying to learn about numeral
, and even with concrete types, such as nat
and int
, the use of constants such as 44
and 5
involve numeral
, at least for the input. And even with a concrete type like nat
, numeral
can be involved in simp
rules that are being used.
Before saying more, one way to get nice nat
output for value "reverse [1::nat,8,3]"
is, again, to use the following import:
"~~/src/HOL/Library/Code_Target_Nat"
The reason I'm interested in your question is because that's just a plug-n-play solution I saw by Andreas Lochbihler in that email.
I can't get value "reverse [1,8,3]"
to not use sums of 1 by importing this:
"~~/src/HOL/Library/Code_Target_Numeral"
So, I want to know about how to get numeral
to be in that nice form we love to see.
Anyway, numeral
is at the core of using number constants. Consider this:
lemma "(3::nat) = z"
using[[simp_trace, simp_trace_depth_limit=100, linarith_trace, rule_trace]]
using[[blast_trace, blast_stats]]
apply simp
oops
Part of the simp trace is this:
[1]SIMPLIFIER INVOKED ON THE FOLLOWING TERM:
3 = z
[1]Procedure "Num.reorient_numeral" produced rewrite rule:
?a1 = ?b1 ≡ ?b1 = ?a1
[1]Applying instance of rewrite rule
?a1 = ?b1 ≡ ?b1 = ?a1
[1]Rewriting:
3 = z ≡ z = 3
If you look at simp traces involving number constants, you'll see that Num
rules show up a lot, which come from that most excellent of Num.thy.