Stream: Archive Mirror: Isabelle Users Mailing List

Topic: [isabelle] incompatible operand type


view this post on Zulip Email Gateway (Aug 19 2022 at 16:12):

From: Holger Blasum <hbl@sysgo.com>
Hello Martin,

On 10-28, M A wrote:

when design a new unknown function max, it return incompatible operand type error, I tried add bracket, still got error, where is wrong?
lemma max_app [simp]: "((max xs) @ (max ys)) @ (max zs) = (max xs) @ ((max ys) @ (max zs))"

Type unification failed: Clash of types "_ ⇒ _" and "_ list"
Type error in application: incompatible operand type
Operator: op @ :: ??'a list ⇒ ??'a list ⇒ ??'a list
Operand: max xs :: ??'b ⇒ ??'b

If you Ctrl-hover[*] over "max" you see it is already defined as
constant "Orderings.ord_class.max".
[*] Click button on right side "Documentation",
see section "Prover output" in "jedit: Isabelle/jEdit" entry
under "Reference Manuals" or search for jedit.pdf.

If you Ctrl-hover+click over "max" you see its definition as
definition (in ord) max :: "'a ⇒ 'a ⇒ 'a" where
"max a b = (if a ≤ b then b else a)"

The operator "@" expects both arguments to be of type 'a list,
whereas "max xs" is seen as function of "'a => 'a".
Hence the type unification error.

Change "max" to a term not yet defined,
e.g. "mymax" and the type unification error will disappear.
The proof script below will fail, but you could prove "by auto".

lemma max_app [simp]: "(max xs @ max ys) @ max zs = max xs @ (max ys @ max zs)"
apply(induct_tac xs)
apply(auto)
done


Last updated: Nov 21 2024 at 12:39 UTC