Skip to content

fix: simplify Decidable instance neutralization - #93

Closed
zqy1018 wants to merge 2 commits into
mainfrom
fix/replacing-instances
Closed

zqy1018 wants to merge 2 commits into
mainfrom
fix/replacing-instances

Conversation

@zqy1018

@zqy1018 zqy1018 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Veil/Util/ReplacingInstances.lean had four simprocs (Depth0/General × actual/expected type). Depth0 differed from General only by leaving unapplied instances (∀ xs, Decidable (p xs)) alone, which nothing relies on, and Depth0WithExpectedType was unused. This PR reduces them to two and makes their proofs independent of unification.

  • Two simprocs. neutralizeDecidableInst reads the proposition off the type of the argument and is meant for tactics. neutralizeDecidableInstWithExpectedType reads it off the binder type of the surrounding application and is meant for generated artifacts (LocalRProp/LocalTheoryProp cores, wp_local_eq.pred). Both handle fully applied and unapplied instances, so __veil_neutralize_decidable_inst loses its ! variant.
  • Proofs. A replacement is justified by Subsingleton.elim applied directly to both endpoints, and the surrounding congruence uses mkCongrArg/mkCongrFun. Previously mkAppM (including mkFunExt via Simp.Result.addLambdas) re-inferred the endpoints by unification. That unification has to unfold a definition, e.g. a ghost, whenever the instance's type matches the binder type only after unfolding it. The simple private theorem neutralize_Decidable is removed.

Behavior change: tactics that used the old default (Depth0) now also neutralize unapplied instances. Unapplied instances typed as DecidableEq α, DecidablePred p or DecidableRel r, such as module parameters, are still left alone.

@zqy1018
zqy1018 added this pull request to stack #94 October 4, 2026 08:18
Base automatically changed from fix/local-optimization-fixes to main October 4, 2026 15:40
zqy1018 and others added 2 commits October 4, 2026 23:41
* fix: generate `LocalRProp`-like instances for ghost functions

* fix: allow generating `wp_local_eq` with picking subtypes
@zqy1018
zqy1018 force-pushed the fix/replacing-instances branch from def16e7 to acbc55d Compare October 4, 2026 15:41
@zqy1018

zqy1018 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Seems that something weird happened with stacked PR. Closing it for now.

@zqy1018 zqy1018 closed this Oct 4, 2026
@zqy1018
zqy1018 deleted the fix/replacing-instances branch October 4, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant