From: Kevin Kappelmann <cl-isabelle-users@lists.cam.ac.uk>
Hi everyone,
Fabian Huch and I recently discovered some soundness-critical issues
(attached below) in thm.ML with the help of AI agents(*).
Makarius and the AFP editors are informed.
Best wishes,
Kevin
(*) We used GPT-6-Astra and Claude Opus 5.5 via PIDE MCP
https://github.com/kappelmann/isabelle-pide-mcp
theory Scratch
imports Main
begin
text ‹Problems in ‹thm.ML›. Tested on Isabelle dev, hg 410b271f3ac4
(committed 2026-10-08).
Line numbers refer to ‹src/Pure/thm.ML› in that revision.›
section ‹Soundness issues›
subsection ‹Case 1: ‹res› drops the rule's flex-flex pairs (L2620)›
lemma flex_rule1: "x True ⟹ x True" . ―‹Important: x here and below must
share the same name.›
lemma flex_rule2: "P True ⟹ ∀x::bool. P True" by simp
lemma "∀y::bool. False" ― ‹Important: name of y must not be equal to x›
apply (rule flex_rule1[THEN flex_rule2]) ― ‹new subgoal: ‹?y True›,
should be ‹False››
by (rule TrueI)
text ‹Possible cause: L2620 passes only ‹[BBi]› to ‹newAs›, not the
rule's flex-flex pairs ‹rtpairs›.
So ‹?x›, whose pair got solved, is not protected (L2432--2435) and is
renamed to ‹?y›
(L2439--2442). The binding for ‹?x› then misses ‹?y›.›
subsection ‹Case 2: ‹eres› drops the rule's flex-flex pairs (L2608)›
lemma eres_rule: "P True ⟹ (∀x::bool. ¬ P True) ⟹ False" by simp
lemma "∀y::bool. ¬ False ⟹ False"
apply (erule flex_rule1[THEN eres_rule, rotated]) ― ‹new subgoal: ‹?y
True›, should be ‹False››
by (rule TrueI)
text ‹Possible cause: like Case 1, but on the elim-resolution path:
L2608 passes only
‹[BBi, (concl', asm')]› to ‹newAs›.›
subsection ‹Case 3: ‹strip_apply› renames only part of a premise
(L2408--2414)›
definition X :: "prop" where "X ≡ (⋀w::bool. True ⟹ False)"
lemma split_rule: "(⋀z::bool. z = w ⟹ z ≠ w) ⟹ PROP X" ― ‹Important: w
here and in X must share the same name.›
unfolding X_def by auto
lemma split_aux: "z = True ⟹ z ≠ False" by simp
schematic_goal split_bad: "PROP ?G (λv::nat. v)" ― ‹Important: name of v
must not be equal to w›
apply (rule split_rule[unfolded X_def]) ― ‹new subgoal: ‹⋀z. z = ?w ⟹
z ≠ ?v››
apply (rule split_aux)
apply assumption
done
lemma False by (rule split_bad) (rule TrueI)
text ‹Possible cause: ‹strip_apply› (L2408--2414, used at L2584) strips
‹⋀›/‹⟹› as long as ‹B› has them,
not just the ‹nlift› lifted ones. With a rule conclusion ‹⋀w. …› it cuts
into the premise, so
‹?w› is renamed in ‹z ≠ ?w› but not in ‹z = ?w›.›
end
From: Makarius <makarius@sketis.net>
On 27/10/2026 09:38, Kevin Kappelmann (via cl-isabelle-users Mailing List) wrote:
Fabian Huch and I recently discovered some soundness-critical issues (attached
below) in thm.ML with the help of AI agents(*).
Thanks for the concrete example, to substantiate what I said on a realated
thread "MCP resources bounds" (Sep-2026):
On 08/09/2026 17:57, Makarius wrote:
There is indeed a fundamental problem here, because the MCP violates
longstanding assumptions about how the prover works, and is used by a human
user. So any "mitigation" can only be symbolic, not really a proper solution.At FLoC 2026 in Lisbon, I've had some discussions with users of AI + MCP. My
conclusion: we should gradually make the system more robust [...]
Makarius
From: Lawrence Paulson <lp15@cam.ac.uk>
Dear Qiyuan, many thanks for preparing this patch!
A number of us have looked at these issues using various LLMs and your patch seems to agree with the others. I've also seen some more elaborate patches, which I think are catching additional bugs. It isn't great that this code is so complicated that it's hard to be sure. These particular issues never come up in real proofs, which is how they have persisted for 40 years without detection.
Which also means if people would rather not bother with the patch, they will be fine. The real worry is that LLM-generated proofs might use them, which is yet another reason to check such proofs carefully.
Larry
On 4 Nov 2026, at 17:13, Qiyuan XU <cl-isabelle-users@lists.cam.ac.uk> wrote:
I’ve written a patch for this issue and uploaded it to my conda channel. If this issue affects you, you can install the patched version with:
From: Makarius <makarius@sketis.net>
On 04/11/2026 20:00, Lawrence Paulson wrote:
It isn't great that this code is so complicated that it's hard to be sure. These particular issues never come up in real proofs, which is how they have persisted for 40 years without detection.
As a boy more than 40 years ago, I always wanted to become an Archeologist.
Now I am a Software-Archeologist, because for any odd situation I am curious
to see when and how it happened in the past, and in which cultural context.
For this particular drop-out, we don't have recorded history, though: that
starts as late as Sep-1993.
The relevant change is somewhere in the transition from Isabelle90 to
Isabelle91, see also the bottom of
https://www.cl.cam.ac.uk/research/hvg/Isabelle/download_past.html
These ancient versions of Isabelle have an edits.txt in the top directory, to
provide some clues of what was going on recently. Later we replaced that by
NEWS for end-users and the repository history for developers (which is the key
to understand the sources).
Side-remark: there is no reason to believe that this will be the last historic
problem uncovered, until the next regular Isabelle release in approx. 8-10 months.
Makarius
From: Fabian Huch <huch@in.tum.de>
On 11/4/26 20:41, Makarius wrote:
Side-remark: there is no reason to believe that this will be the last
historic problem uncovered, until the next regular Isabelle release in
approx. 8-10 months.
Indeed, we should use a the verified proof checker [1] since
implementation errors can inadvertently occur. I have made a practical
tool out of it here [2].
The main problem is that our proofterms are stored in compressed form
and uncompressing some of the big smt-generated proofs is too slow;
there is a good chance that the zproof implementation [3] would work
much better here.
Anyway, with the tool I have stumbled on the next problem: Quickcheck
generates equations for datatypes that it axiomatizes with skip_proof.
Those are immediately rejected by the proof checker. Turns out rightly
so, because one can prove False with these equations (see below)!
The cheat_tac invocation was introduced in (8fdfa9c4e7ed)
for performance reasons; perhaps this is no longer required and we can
revert back to produce a proper proof?
Note that the problem here abuses the fact that deps are not tracked
with the skip proof construction, but fundamentally these equations do
need a termination argument to be sound, so a 'fix' for the former
doesn't solve the underlying problem.
Fabian
[1]: https://isa-afp.org/entries/Metalogic_ProofChecker.html
[2]: https://github.com/Dacit/isabelle-checker
[3]:
https://files.sketis.net/Isabelle_Workshop_2024/Isabelle_2024_paper_6.pdf
text ‹Simple helper›
definition flip_result ::
"(bool × Code_Evaluation.term list) option ⇒
(bool × Code_Evaluation.term list) option"
where "flip_result r = (if r = None then Some (True, []) else None)"
lemma flip_result_no_fixed_point: "r ≠ flip_result r"
by (cases r) (simp_all add: flip_result_def)
text ‹
Datatype definition yields theorem to generate terms of the datatype,
with skipped proof.
The theorem states that full_exhaustive of 'a container is built from
full_exhaustive of 'a.
However, the generator is actually defined as \<^const>‹undefined› and
the proof of the theorem is
skipped, so this dependency is not recorded.
›
datatype 'a container = Container 'a
declare [[show_types]]
thm container.full_exhaustive_container.simps
ML ‹Thm_Deps.all_oracles @{thms container.full_exhaustive_container.simps}›
text ‹Hence, we can instantiate full_exhaustive for 'a, calling
full_exhaustive for 'a container:›
datatype (plugins del: quickcheck_full_exhaustive) elem = Elem
instantiation elem :: full_exhaustive
begin
definition
"full_exhaustive_elem
(_ :: elem × (unit ⇒ Code_Evaluation.term) ⇒ (bool ×
Code_Evaluation.term list) option)
i =
flip_result
(Quickcheck_Exhaustive.full_exhaustive
(λ(_ :: elem container × (unit ⇒ Code_Evaluation.term)). None)
(i + 1))"
instance ..
end
text ‹This is a cycle and gives a contradiction due to flip_result:›
lemma generated_cycle:
"Quickcheck_Exhaustive.full_exhaustive
(λ(_ :: elem container × (unit ⇒ Code_Evaluation.term)). None) 1 =
flip_result (Quickcheck_Exhaustive.full_exhaustive
(λ(_ :: elem container × (unit ⇒ Code_Evaluation.term)). None) 1)"
by (subst container.full_exhaustive_container.simps)
(simp add: full_exhaustive_elem_def)
theorem missing_check_False: False
using generated_cycle flip_result_no_fixed_point by blast
Last updated: Nov 19 2026 at 01:46 UTC