theory Test imports Main begin datatype tree = LeafA | LeafB | Node "tree" "tree" fun closure :: "tree \ tree set" where "closure (Node r s) = { z. \ r' s'. (r' \ closure r \ s' \ closure s \ z = Node r' s') }" | "closure LeafA = { LeafA }" | "closure LeafB = { LeafA, LeafB }" lemma "closure (Node r (Node s t)) \ closure (Node (Node r s) t)" unfolding closure.simps proof (rule subsetI, unfold mem_Collect_eq, elim exE conjE) fix x r' s' r'a s'a (** This works -- the difference to the failing version is that *** r'a was renamed to r'a' inside the existential quantification of *** the conclusion. assume "r' \ closure r" and "x = Node r' s'" and "r'a \ closure s" and "s'a \ closure t" and "s' = Node r'a s'a" thus "\r' s'. (\r'a' s'. r'a' \ closure r \ s' \ closure s \ r' = Node r'a' s') \ s' \ closure t \ x = Node r' s'" sorry **) (** while this fails: **) assume "r' \ closure r" and "x = Node r' s'" and "r'a \ closure s" and "s'a \ closure t" and "s' = Node r'a s'a" thus "\r' s'. (\r'a s'. r'a \ closure r \ s' \ closure s \ r' = Node r'a s') \ s' \ closure t \ x = Node r' s'" sorry (** *** Local statement will fail to refine any pending goal *** Failed attempt to solve goal by exported rule: *** \?r'2 \ closure r; ?x2 = Node ?r'2 ?s'2; ?r'a2 \ closure s; *** ?s'a2 \ closure t; ?s'2 = Node ?r'a2 ?s'a2\ *** \ \r' s'. *** (\r'a s'. r'a \ closure r \ s' \ closure s \ r' = Node r'a s') \ *** s' \ closure t \ ?x2 = Node r' s' *** At command "thus" (line 19 of ".../Bug.thy") **) end