问题
I need to use nat_plus_commute.fold_set_fold_remdups
code equation instead of Finite_Set.fold_def
:
interpretation nat_plus_commute: comp_fun_commute "plus :: nat ⇒ nat ⇒ nat"
by standard auto
declare Finite_Set.fold_def [code del]
declare nat_plus_commute.fold_set_fold_remdups [code]
The problem is that the first equation is defined only for plus
operation and so I get the following warning:
Partially applied constant "Groups.plus_class.plus" on left hand side of equation, in theorem:
Finite_Set.fold op + ?y (set ?xs) ≡ fold op + (remdups ?xs) ?y
As result the following statement
value "Finite_Set.fold plus 0 (set [1::nat, 2])"
returns the exception:
exception Fail raised (line 29 of "generated code"): Finite_Set.fold
Is it possible to use a specialized code equation for specific operations (plus
) and types (nat
)?
回答1:
I am not quite sure want you want to achieve, but note that Finite_Set.fold is a low-level construct of which other operations with practically usable properties can only be derived with considerable effort, cf. theories src/HOL/Finite_Set.thy and src/HOL/Groups_Big.thy for a rough idea.
For summation on finite sets and lists, there are sum and sum_list which are already equipped with code equations.
来源:https://stackoverflow.com/questions/46784091/partially-applied-constant-on-left-hand-side-of-code-equation