T***@data61.csiro.au
2018-08-01 07:07:58 UTC
Hello Isabelle users,
I just found a strange behaviour in Isabelle/HOL using notes which allow to create to different free variables with different types but the same name. This is very confusing for a user which doesn't work with [[show_types]] (Which I think is mostly everyone). Here is a minimal example:
lemma
notes hyp = refl[where t=a]
shows "a = a"
apply (insert hyp)
subgoal by assumption
done
The notes introduces a free variable named "a" with schematic type "?'a1". Then shows introduces another free variable "a" with a fixed type " 'a ". If you do by (rule hyp) right after the shows, the schematic type will be unified with "'a" and from now on both variables will be the same (same name + same type ⟹ same variable). However if you add hyp to your premises and then use the subgoal command, all schematics (here only "?'a") are instantiated with fresh free variables (here " 'b "). Therefore, right after the subgoal command, your context is:
(a :: 'b) = (a :: 'b) ⟹ (a :: 'a) = (a :: 'a)
but without type annotations it looks like:
a = a ⟹ a = a
which one would expect to be solved by assumption. In practice, the variables are different and thus assumption fails.
If this is not considered as a bug, I think there should at least be either:
* a warning that two different variables with different types but same name have appeared in the context
* or an even simpler change: when two variables have the same name but different types, print the types in the pretty printer for those specific variables even when we are in a printing mode where types are hidden
In both cases the current type printing mode (when using [[show_types]]) assumes that such name conflicts cannot exist. The previous goal gets printed as
goal (1 subgoal):
1. a = a ⟹ a = a
variables:
a :: 'a
a :: 'b
which is not very informative about which "a" is which.
For extra information: This behaviour can also be obtained with the lemmas command:
lemmas hyp = refl[where t=a]
lemma
"a = a"
apply (insert hyp)
subgoal by assumption
done
it can also be obtained without subgoal by manually instantiating the type variable:
lemmas hyp = refl[where t=a]
lemma
"a = a"
apply (insert hyp[where 'a = int)
by assumption
Thank you for y
I just found a strange behaviour in Isabelle/HOL using notes which allow to create to different free variables with different types but the same name. This is very confusing for a user which doesn't work with [[show_types]] (Which I think is mostly everyone). Here is a minimal example:
lemma
notes hyp = refl[where t=a]
shows "a = a"
apply (insert hyp)
subgoal by assumption
done
The notes introduces a free variable named "a" with schematic type "?'a1". Then shows introduces another free variable "a" with a fixed type " 'a ". If you do by (rule hyp) right after the shows, the schematic type will be unified with "'a" and from now on both variables will be the same (same name + same type ⟹ same variable). However if you add hyp to your premises and then use the subgoal command, all schematics (here only "?'a") are instantiated with fresh free variables (here " 'b "). Therefore, right after the subgoal command, your context is:
(a :: 'b) = (a :: 'b) ⟹ (a :: 'a) = (a :: 'a)
but without type annotations it looks like:
a = a ⟹ a = a
which one would expect to be solved by assumption. In practice, the variables are different and thus assumption fails.
If this is not considered as a bug, I think there should at least be either:
* a warning that two different variables with different types but same name have appeared in the context
* or an even simpler change: when two variables have the same name but different types, print the types in the pretty printer for those specific variables even when we are in a printing mode where types are hidden
In both cases the current type printing mode (when using [[show_types]]) assumes that such name conflicts cannot exist. The previous goal gets printed as
goal (1 subgoal):
1. a = a ⟹ a = a
variables:
a :: 'a
a :: 'b
which is not very informative about which "a" is which.
For extra information: This behaviour can also be obtained with the lemmas command:
lemmas hyp = refl[where t=a]
lemma
"a = a"
apply (insert hyp)
subgoal by assumption
done
it can also be obtained without subgoal by manually instantiating the type variable:
lemmas hyp = refl[where t=a]
lemma
"a = a"
apply (insert hyp[where 'a = int)
by assumption
Thank you for y