When I use value
to find out some value of a function that returns natural numbers, I always obtain the answer in the form of iterated Successor functions of 0, i.e., Suc(Suc( ... 0 ))
which can be hard to read sometimes.
Is there a way to output directly the number that Isabelle returns?
相关问题
- How do I remove duplicate subgoals in Isabelle?
- Isabelle's document preparation
- What is the best way to search through general def
- How type casting is possible in isabelle
- Degree of polynomial smaller than a number
相关文章
- What is the difference between primrec and fun in
- Isabelle/HOL: What does the THE construct denote?
- What is an Isabelle/HOL subtype? What Isar command
- 在替换伊莎贝尔(Substitution in Isabelle)
- 装载在伊莎贝尔预编译堆图像(loading a precompiled heap image in
- 如何解除从要素列出了传递关系?(How to lift a transitive relation
- Function returns 0 when it should return 1, elimin
- Organizing constraints in isabelle in order to mod
This is something I wanted to fix some time ago but apparently I forgot. Carcigenate's guess is incorrect; this is indeed the fully evaluated result. The problem is just that natural numbers are printed in this unwieldy way.
You can do the following things:
The easiest way is to convert the number to an integer, i.e. instead of
value "foo x y z"
(wherefoo x y z
is the expression of typenat
that you want to eavluate) you writevalue "int (foo x y z)"
.You can add
~~/src/HOL/Library/Code_Target_Numeral
to your imports. This makes Isabelle's code generator use arbitrary-precision integers of the target language (in case ofvalue
, that's ML and its GMP-based integers) instead of the inefficient successor notation. As a side effect, this also prints natural numbers in a nicer way.You can add the following code to your theory, which changes the way the
value
command displays natural numbers:Code:
Note that the
value
command is a diagnostic command only. It is mainly used for quick plausibility tests and debugging of code generation setups, and getting it to work can sometimes be tricky.By default,
value
relies on the code generator, i.e. Isabelle needs to know how to generate executable code for the expression, and if it cannot do that,value
will probably fail. (It can sometimes also fall back to some other strategies, normalisation by evaluation or evaluation by simplification, but those usually don't provide useful output)I'm just telling you this so that you know what to expect from the
value
command and don't get the impression that this is some integral part of Isabelle that people use all the time.