Rules available to the restricted support-certificate solver used by irw.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Rules available to the restricted support-certificate solver used by irw.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Rules available to the restricted support-certificate solver used by irw.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Rules available to the restricted support-certificate solver used by irw.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Isomorphism rewriting #
irw i transports a proposition along a supplied isomorphism i. Earlier typeclass closure
handled only a fixed family of proposition shapes. This tactic instead traverses the actual
proposition expression, so its logical recursion has no arity ceiling.
The tactic has transformation-system and domain registries plus system-indexed equivalence and naturality theorem databases.
@[irw_system]: a transformation/type constructor accepted as the argument toirw. Its final two parameters are respectively the source and target objects.@[irw_domain]: a primitive total or support-restricted domain action for that system.@[irw_support]: a theorem available only to the restricted support-certificate solver.@[irw_naturality]: a system-indexed equality or iff. Equalities normalize mechanically transported syntax; proposition-valued declarations also serve as primitive atomic transport. Both are oriented from mechanically transported source syntax to canonical target syntax.@[irw_equiv]: a theorem whose first explicit argument is the supplied isomorphism and whose result is anEquiv. These rules transport quantified binder types.
Except for @[irw_system], registrations accept the usual optional Lean priority (low, high,
or a numeral). Contributors should omit it. Exact matches always outrank definitional matches;
within one match class higher priority wins. Equal-priority naturality rules with overlapping left
sides must produce the same canonical form and are otherwise rejected at registration time.
For project-owned API, place a registration on the canonical declaration beside its definition. Separate registration modules are reserved for declarations owned by Mathlib. A naturality theorem should take the transformation as its first explicit argument and be oriented from mechanically transported source syntax to ordinary canonical target syntax.
Within the active system, exact instantiated source matches outrank merely definitionally equal matches. Conflicting exact matches are rejected rather than resolved by declaration order.
Logical connectives and quantifiers are handled by the metaprogram itself. Bounded quantifiers
such as ∀ X, X ⊆ E → ... and ∃ X, X ⊆ E ∧ ... are recognized when the ambient binder type does
not itself transport: the guard is bundled into a subtype and @[irw_equiv] is asked to transport
that subtype. Universal guards may also be batched after several binders, as in
∀ X Y, guardX → guardY → ...; the engine proves a telescope permutation, reuses the same bounded
transport path, and then restores the original binder/guard ordering.
Existential guards may likewise be batched after several witnesses. The engine hoists each guard
next to its witness with a checked logical equivalence, transports the adjacent bounded form, and
then restores the original batched ordering.
This file is deliberately domain-independent. Matroid and Graph registrations live in their
adapter files, so it imports nothing from Matroid.
Small proof-producing lemmas used by the metaprogram #
Coherence cleanup for structural binder equivalences #
When recursion enters a binder transported by a structural equivalence E, the source body is
instantiated at E.symm y. Atomic rules then transport the pieces of that source value again.
For a bare value this produces e (e.symm y), handled by Equiv.apply_symm_apply. Product
projections and sets hide that same cancellation behind their constructors. Forward structural
transport can also hide a payload beneath a constructor, as in optionCongr e (some x), or beneath
function transport. The equations below expose both kinds of structure to the small irw cleanup
simp set so normalization can continue recursively through arbitrary compositions.
These are deliberately not global [simp] lemmas. They belong to the normalization protocol of
irw's internally constructed structural equivalences.
Equiv.setCongr transports a set by image. Applying the element transport to the inverse
transport of a set therefore cancels. This is the set-level analogue of
Equiv.apply_symm_apply.
Applying a function transported backwards by arrowCongr to an argument transported backwards,
then transporting the result forwards, recovers ordinary target-side application.
Forward function-space transport is conjugation by the domain and codomain equivalences. Stating this at function level lets cleanup descend beneath structural constructors containing a transported function.
Structural transport preserves Option.none.
Forward option transport preserves some and transports its payload.
Forward transport cancels inverse transport beneath Option.some.
Transport a guarded universal directly, preserving ordinary bounded-quantifier syntax.
Transport a conjunction-guarded existential directly. The target body is proof-independent, which is the form produced by ordinary bounded-existential notation.
Transport-domain descriptors #
Transport an equality of ambient values when both values are known to lie in a supported domain. The target equality is stated on ambient values as well, so support proofs remain an internal implementation detail.
Supported domains lift structurally to ambient sets whose elements are supported.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The tactic itself #
Everything below is compile-time code, so it lives in a meta section.
Registries #
Identifier of a registered change-of-coordinates system. Phase 1 uses the head declaration of the supplied isomorphism type; later registry entries are indexed by this identifier.
Equations
Instances For
Equations
Equations
Equations
Instances For
Transformation/type constructors recognized by irw (for example Graph.Iso and
Matroid.Iso).
Binder-type equivalence rules used by irw.
Primitive total or supported transport-domain rules used by irw.
Canonicalization rules used only by IRw's private, system-indexed normalizer.
Return the registered system whose type constructor is the head of type, if any.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Infer the unique transformation system mentioned by a registration theorem's telescope.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiate a naturality theorem and return its oriented left- and right-hand sides.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reject equal-priority naturality rules whose left sides overlap but whose proposed canonical forms disagree. This makes import/declaration order irrelevant and reports the problem at the second attribute rather than during an unrelated later proof.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- IRw.irwSystemAttr = Lean.ParserDescr.node `IRw.irwSystemAttr 1024 (Lean.ParserDescr.nonReservedSymbol "irw_system" false)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Metaprogramming core #
The engine lives in IRw.Core rather than IRw.Meta: an inner namespace called Meta would be
ambiguous with Lean.Meta, which this file has open.
Equations
Runtime state shared by every IRw subsystem.
- system : SystemId
- iso : Lean.Expr
- locals : Array LocalTransport
Instances For
Equations
The source object is the penultimate argument of a registered binary transformation system. Carrier and universe parameters may precede it; the target object is the final argument.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Build the initial context and reject unregistered transformation notions early.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- IRw.Core.instBEqMatchQuality.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
Equations
- total (result : EquivResult) : DomainResult
- supported (result : SupportedResult) : DomainResult
Instances For
Equations
Equations
- IRw.Core.mkIffRefl p = Lean.Meta.mkAppM `Iff.refl #[p]
Instances For
Apply an Equiv to an argument. An Equiv is not a function, so the application has to go
through the FunLike coercion; mkApp on the bare equivalence produces an ill-typed term.
Equations
- IRw.Core.mkEquivApply e x = Lean.Meta.mkAppM `DFunLike.coe #[e, x]
Instances For
Apply the inverse of an Equiv to an argument.
Equations
- IRw.Core.mkEquivSymmApply e x = do let __do_lift ← Lean.Meta.mkAppM `Equiv.symm #[e] IRw.Core.mkEquivApply __do_lift x
Instances For
Record the source representative e.symm target introduced beneath a transported binder.
The stored coherence theorem is a local normalization rule e source = target.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check every proof produced by the tactic before it can be installed into a goal. This is intentionally more defensive than most tactics: failures in metaprograms are otherwise liable to surface only much later as kernel errors.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Try a registered theorem by applying the supplied isomorphism as its first explicit argument,
then using unification against source to infer all remaining theorem arguments. Failed attempts
are backtracked completely.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Find the registered binder equivalence which is definitionally the equivalence stored in a supported-domain descriptor. Unlike ordinary binder lookup, coherence with the descriptor can disambiguate two roles whose support subtypes are definitionally equal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replace the implementation field of a supported-domain descriptor by a registered, named
equivalence when the two are definitionally equal. Naturality rules can then state their target
using the public equivalence and the cleanup pass sees the syntactic e (e.symm x) cancellation.
This applies equally to primitive supported domains and to structurally derived ones such as
supported sets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Try proposition-valued naturality declarations as atomic transport facts. Equality-valued declarations are ignored here and remain private-normalizer rules.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- IRw.Core.mkReflEquiv α = do let e ← Lean.Meta.mkAppM `Equiv.refl #[α] IRw.Core.checkedEquivResult α { target := α, equiv := e }
Instances For
Equations
- IRw.Core.isConstApp e n arity = e.isAppOfArity n arity
Instances For
Derive an equivalence for a quantified binder type. Domain-specific equivalences are tried
first; afterwards the routine structurally closes under elementary type constructors. A final
reflexive fallback is intentional: genuinely object-independent binder types (Nat, a fixed index
type, etc.) should remain unchanged.
Resolve a primitive supported/total domain first, then fall back to the legacy total-domain engine and its structural closure.
Lemmas used to tidy up the transported proposition.
This must stay a small, targeted list. Running the full default simp set here is actively
harmful: lemmas such as Set.image_subset_image_iff and Set.mem_image_equiv rewrite a
transported ⇑e '' S ⊆ ⇑e '' T straight back to S ⊆ T, so irw would faithfully build a
transport proof and then throw it away, leaving the goal untouched.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- IRw.Core.isNondependentForall body = !body.hasLooseBVar 0
Instances For
Syntactic occurrence of an arbitrary expression, rather than only a free variable.
Check dependency through both an expression and the types of the free variables it contains.
The latter matters for an opaque Q x: the term does not spell the source object, but the types of
Q and x do.
An opaque proposition is fixed only when it is independent of both the source object and every source-side representative introduced beneath transported binders.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Recognize a set-subset proposition without unfolding it to a dependent function type.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Close set support obligations under transitivity of locally available subset hypotheses.
Small initial support prover. It intentionally uses only local hypotheses and elementary
propositional decomposition; Phase 6 can replace the backend with restricted grind without
changing this interface.
Resource-bounded grind configuration for support certificates. Arithmetic, extensionality,
congruence-closure extras, and the global @[grind] theorem database are deliberately disabled.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Try the restricted support-specific grind database and the current local context.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Collect support proofs carried by subtype-valued subterms. This exposes facts such as the
IsWalk proof bundled into a supported walk when proving support for one of its endpoints.
Prove support using a genuine subtype property contained in term as an explicit premise,
then discharge that premise with its bundled proof.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Try to transport an equality on an ambient carrier through a supported domain. A candidate is usable only when support for both operands follows from the local context.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Prefer the canonical equivalence supplied by a supported domain when a syntactic guard is definitionally that domain's support predicate. This keeps bounded and inferred-supported quantifiers on one coherence path.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reordering batched guarded universal quantifiers #
Lean elaborates
∀ I J K, gI → gJ → gK → P
as one forallE telescope. The bounded-quantifier transporter, intentionally, only consumes the
local shape ∀ I, gI → .... Rather than teach bounded transport a second semantics for batched
guards, we normalize a leading universal telescope by moving any registered unary guard directly
after the binder it guards. The normalization is accompanied by an explicit iff proof, the
ordinary recursive transporter is run on the normalized proposition, and the transported telescope
is then permuted back to the source ordering.
This layer is deliberately only a telescope permutation. It neither invents a transport nor
interprets arbitrary propositions as bounds: a guard is movable only if bundling it with its binder
produces a subtype accepted by @[irw_equiv].
Equations
A candidate guard may be moved directly after binder i only when its type does not mention a
later telescope variable. This is slightly conservative (a later variable may itself eventually be
moved earlier), but it makes the permutation criterion local and prevents us from manufacturing an
ill-scoped dependent telescope.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Find a later proposition binder which is a registered guard for fvars[i].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Discover all independent registered guards in a universal telescope. A proof binder is used at most once.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Remove moved guards from their original positions and insert each immediately after its guarded binder. All other binders keep their relative order.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Check that reordering the local declarations according to order respects all telescope
dependencies. The result is checked again by the kernel when the permutation proof is built; this
pre-check exists to turn a scope problem into a useful trace instead of an opaque abstraction
failure.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Permute the first fvars.size universal/implication binders of source according to order.
fvars and tail must come from opening that prefix of source. Both directions are constructed
by pure lambda/application reshuffling and then kernel-checked.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Whether a transported result still exposes the candidate domain's support immediately after its leading data binder. When role candidates share a raw source carrier, eliminating this guard is useful evidence that the body actually identifies the candidate's intended role.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Existential analogue of hasLeadingForallSupportGuard.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Find the first conjunct after a nonempty leading existential telescope. The conjunct is returned only when it is independent of every witness crossed on the way.
Insert guard as the first conjunct after a leading existential telescope.
Hoist a fixed first conjunct from the end of a leading existential telescope. Every step is an
explicit exists_congr_equiv followed by exists_and_left_explicit, so the returned equivalence is
kernel checked rather than justified by a syntactic rewrite.
Transport a bounded universal ∀ x, guard x → body x through an equivalence between the
corresponding guarded subtypes. The generated target is again an ordinary guarded forall.
Transport a bounded existential ∃ x, guard x ∧ body x through an equivalence between the
corresponding guarded subtypes.
Transport an unguarded universal through a supported domain after proving that its body is automatic outside the source support. The first supported normal form deliberately exposes the target guard.
Transport an unguarded existential through a supported domain after proving that every source witness is supported. The first supported normal form deliberately exposes the target guard.
When several exact supported domains share the same raw carrier, use the quantified body as delayed role evidence. A candidate is committed only if both its support certificate and recursive proposition transport succeed.
Existential counterpart of transportAmbiguousSupportedForall?.
Normalize non-adjacent registered guards in a leading universal telescope, recurse through the already-existing bounded-forall path, and restore the transported telescope to the original binder ordering. This handles batched syntax such as
∀ I J K, I ⊆ E → J ⊆ E → K ⊆ E → P I J K
without duplicating bounded-quantifier transport logic.
Hoist the first guard in a batched existential across all later witnesses, transport the resulting adjacent guarded existential, and restore the batched target shape. Recursion handles the remaining guards after the first supported witness is entered.
Recursive proposition transporter. Every successful branch constructs a kernel-checkable iff proof. An unmatched atomic leaf is left fixed only after checking that it is independent of the source object and all transported local data.
Tactic frontend #
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Debugging frontend: show the proposition that irw i would produce without changing the
goal.
Equations
- IRw.irwQueryTac = Lean.ParserDescr.node `IRw.irwQueryTac 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.nonReservedSymbol "irw? " false) (Lean.ParserDescr.cat `term 0))