File: .lake/packages/lean4/src/lean/Lean/Meta/Match/MatchEqs.lean

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.MVarId.contradictionQuick
code: /--
A custom, approximated, and quick `contradiction` tactic.
It only finds contradictions of the form `(h₁ : p)` and `(h₂ : ¬ p)` where
`p`s are structurally equal. The procedure is not quadratic like `contradiction`.

We use it to improve the performance of `proveSubgoalLoop` at `mkSplitterProof`.
We will eventually have to write more efficient proof automation for this module.
The new proof automation should exploit the structure of the generated goals and avoid general purpose tactics
such as `contradiction`.
-/
private def _root_.Lean.MVarId.contradictionQuick (mvarId : MVarId) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: Lean.Meta.casesOnStuckLHS
code: /--
  Helper method for `proveCondEqThm`. Given a goal of the form `C.rec ... xMajor = rhs`,
  apply `cases xMajor`. -/
partial def casesOnStuckLHS (mvarId : MVarId) : MetaM (Array MVarId) 
goal: Lean.MetaM (Array Lean.MVarId)

full_name: Lean.Meta.casesOnStuckLHS.findFVar?
code: /--
  Helper method for `proveCondEqThm`. Given a goal of the form `C.rec ... xMajor = rhs`,
  apply `cases xMajor`. -/
partial def casesOnStuckLHS (mvarId : MVarId) : MetaM (Array MVarId) 
goal: Lean.MetaM (Option Lean.FVarId)

full_name: Lean.Meta.casesOnStuckLHS?
code: def casesOnStuckLHS? (mvarId : MVarId) : MetaM (Option (Array MVarId)) 
goal: Lean.MetaM (Option (Array Lean.MVarId))

full_name: Lean.Meta.Match.unfoldNamedPattern
code: def unfoldNamedPattern (e : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Lean.Meta.Match.forallAltTelescope.isNamedPatternProof
code: /--
  Similar to `forallTelescopeReducing`, but

  1. Eliminates arguments for named parameters and the associated equation proofs.

  2. Equality parameters associated with the `h : discr` notation are replaced with `rfl` proofs.
     Recall that this kind of parameter always occurs after the parameters correspoting to pattern variables.
     `numNonEqParams` is the size of the prefix.

  The continuation `k` takes four arguments `ys args mask type`.
  - `ys` are variables for the hypotheses that have not been eliminated.
  - `eqs` are variables for equality hypotheses associated with discriminants annotated with `h : discr`.
  - `args` are the arguments for the alternative `alt` that has type `altType`. `ys.size <= args.size`
  - `mask[i]` is true if the hypotheses has not been eliminated. `mask.size == args.size`.
  - `type` is the resulting type for `altType`.

  We use the `mask` to build the splitter proof. See `mkSplitterProof`.

  This can be used to use the alternative of a match expression in its splitter.
-/
partial def forallAltTelescope (altType : Expr) (altNumParams numDiscrEqs : Nat)
    (k : (ys : Array Expr) → (eqs : Array Expr) → (args : Array Expr) → (mask : Array Bool) → (type : Expr) → MetaM α)
    : MetaM α 
goal: Bool

full_name: Lean.Meta.Match.forallAltTelescope.go
code: /--
  Similar to `forallTelescopeReducing`, but

  1. Eliminates arguments for named parameters and the associated equation proofs.

  2. Equality parameters associated with the `h : discr` notation are replaced with `rfl` proofs.
     Recall that this kind of parameter always occurs after the parameters correspoting to pattern variables.
     `numNonEqParams` is the size of the prefix.

  The continuation `k` takes four arguments `ys args mask type`.
  - `ys` are variables for the hypotheses that have not been eliminated.
  - `eqs` are variables for equality hypotheses associated with discriminants annotated with `h : discr`.
  - `args` are the arguments for the alternative `alt` that has type `altType`. `ys.size <= args.size`
  - `mask[i]` is true if the hypotheses has not been eliminated. `mask.size == args.size`.
  - `type` is the resulting type for `altType`.

  We use the `mask` to build the splitter proof. See `mkSplitterProof`.

  This can be used to use the alternative of a match expression in its splitter.
-/
partial def forallAltTelescope (altType : Expr) (altNumParams numDiscrEqs : Nat)
    (k : (ys : Array Expr) → (eqs : Array Expr) → (args : Array Expr) → (mask : Array Bool) → (type : Expr) → MetaM α)
    : MetaM α 
goal: Lean.MetaM α

full_name: Lean.Meta.Match.forallAltTelescope
code: /--
  Similar to `forallTelescopeReducing`, but

  1. Eliminates arguments for named parameters and the associated equation proofs.

  2. Equality parameters associated with the `h : discr` notation are replaced with `rfl` proofs.
     Recall that this kind of parameter always occurs after the parameters correspoting to pattern variables.
     `numNonEqParams` is the size of the prefix.

  The continuation `k` takes four arguments `ys args mask type`.
  - `ys` are variables for the hypotheses that have not been eliminated.
  - `eqs` are variables for equality hypotheses associated with discriminants annotated with `h : discr`.
  - `args` are the arguments for the alternative `alt` that has type `altType`. `ys.size <= args.size`
  - `mask[i]` is true if the hypotheses has not been eliminated. `mask.size == args.size`.
  - `type` is the resulting type for `altType`.

  We use the `mask` to build the splitter proof. See `mkSplitterProof`.

  This can be used to use the alternative of a match expression in its splitter.
-/
partial def forallAltTelescope (altType : Expr) (altNumParams numDiscrEqs : Nat)
    (k : (ys : Array Expr) → (eqs : Array Expr) → (args : Array Expr) → (mask : Array Bool) → (type : Expr) → MetaM α)
    : MetaM α 
goal: Lean.MetaM α

full_name: Lean.Meta.Match.SimpH.State.eqsNew
code: /--
  State for the equational theorem hypothesis simplifier.

  Recall that each equation contains additional hypotheses to ensure the associated case does not taken by previous cases.
  We have one hypothesis for each previous case.

  Each hypothesis is of the form `forall xs, eqs → False`

  We use tactics to minimize code duplication.
-/
structure State where
  mvarId : MVarId            -- Goal representing the hypothesis
  xs  : List FVarId          -- Pattern variables for a previous case
  eqs : List FVarId          -- Equations to be processed
  eqsNew : List FVarId := []
goal: List Lean.FVarId

full_name: Lean.Meta.Match.SimpH.State
code: /--
  State for the equational theorem hypothesis simplifier.

  Recall that each equation contains additional hypotheses to ensure the associated case does not taken by previous cases.
  We have one hypothesis for each previous case.

  Each hypothesis is of the form `forall xs, eqs → False`

  We use tactics to minimize code duplication.
-/
structure State where
  mvarId : MVarId            -- Goal representing the hypothesis
  xs  : List FVarId          -- Pattern variables for a previous case
  eqs : List FVarId          -- Equations to be processed
  eqsNew : List FVarId := []
goal: Type

full_name: Lean.Meta.Match.SimpH.State.eqs
code: /--
  State for the equational theorem hypothesis simplifier.

  Recall that each equation contains additional hypotheses to ensure the associated case does not taken by previous cases.
  We have one hypothesis for each previous case.

  Each hypothesis is of the form `forall xs, eqs → False`

  We use tactics to minimize code duplication.
-/
structure State where
  mvarId : MVarId            -- Goal representing the hypothesis
  xs  : List FVarId          -- Pattern variables for a previous case
  eqs : List FVarId          -- Equations to be processed
  eqsNew : List FVarId := []
goal: List Lean.FVarId

full_name: Lean.Meta.Match.SimpH.State.xs
code: /--
  State for the equational theorem hypothesis simplifier.

  Recall that each equation contains additional hypotheses to ensure the associated case does not taken by previous cases.
  We have one hypothesis for each previous case.

  Each hypothesis is of the form `forall xs, eqs → False`

  We use tactics to minimize code duplication.
-/
structure State where
  mvarId : MVarId            -- Goal representing the hypothesis
  xs  : List FVarId          -- Pattern variables for a previous case
  eqs : List FVarId          -- Equations to be processed
  eqsNew : List FVarId := []
goal: List Lean.FVarId

full_name: Lean.Meta.Match.SimpH.State.mvarId
code: /--
  State for the equational theorem hypothesis simplifier.

  Recall that each equation contains additional hypotheses to ensure the associated case does not taken by previous cases.
  We have one hypothesis for each previous case.

  Each hypothesis is of the form `forall xs, eqs → False`

  We use tactics to minimize code duplication.
-/
structure State where
  mvarId : MVarId            -- Goal representing the hypothesis
  xs  : List FVarId          -- Pattern variables for a previous case
  eqs : List FVarId          -- Equations to be processed
  eqsNew : List FVarId := []
goal: Lean.MVarId

full_name: Lean.Meta.Match.SimpH.M
code: abbrev M 
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.SimpH.applySubst
code: /--
  Apply the given substitution to `fvarIds`.
  This is an auxiliary method for `substRHS`.
-/
private def applySubst (s : FVarSubst) (fvarIds : List FVarId) : List FVarId 
goal: List Lean.FVarId

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.SimpH.substRHS
code: /--
  Given an equation of the form `lhs = rhs` where `rhs` is variable in `xs`,
  replace it everywhere with `lhs`.
-/
private def substRHS (eq : FVarId) (rhs : FVarId) : M Unit 
goal: Lean.Meta.Match.SimpH.M Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.SimpH.isDone
code: private def isDone : M Bool 
goal: Lean.Meta.Match.SimpH.M Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.SimpH.contradiction
code: /-- Customized `contradiction` tactic for `simpH?` -/
private def contradiction (mvarId : MVarId) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: Lean.Meta.Match.SimpH.trySubstVarsAndContradiction
code: /--
  Auxiliary tactic that tries to replace as many variables as possible and then apply `contradiction`.
  We use it to discard redundant hypotheses.
-/
partial def trySubstVarsAndContradiction (mvarId : MVarId) : MetaM Bool 
goal: Lean.MetaM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.SimpH.processNextEq
code: private def processNextEq : M Bool 
goal: Lean.Meta.Match.SimpH.M Bool

full_name: Lean.Meta.Match.SimpH.go
code: partial def go : M Bool 
goal: Lean.Meta.Match.SimpH.M Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.simpH?
code: /--
  Auxiliary method for simplifying equational theorem hypotheses.

  Recall that each equation contains additional hypotheses to ensure the associated case was not taken by previous cases.
  We have one hypothesis for each previous case.
-/
private partial def simpH? (h : Expr) (numEqs : Nat) : MetaM (Option Expr) 
goal: Lean.MetaM (Option Lean.Expr)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.substSomeVar
code: private def substSomeVar (mvarId : MVarId) : MetaM (Array MVarId) 
goal: Lean.MetaM (Array Lean.MVarId)

full_name: Lean.Meta.Match.proveCondEqThm.go
code: /--
  Helper method for proving a conditional equational theorem associated with an alternative of
  the `match`-eliminator `matchDeclName`. `type` contains the type of the theorem. -/
partial def proveCondEqThm (matchDeclName : Name) (type : Expr) : MetaM Expr 
goal: Lean.MetaM Unit

full_name: Lean.Meta.Match.proveCondEqThm
code: /--
  Helper method for proving a conditional equational theorem associated with an alternative of
  the `match`-eliminator `matchDeclName`. `type` contains the type of the theorem. -/
partial def proveCondEqThm (matchDeclName : Name) (type : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.withSplitterAlts.go
code: /-- Construct new local declarations `xs` with types `altTypes`, and then execute `f xs`  -/
private partial def withSplitterAlts (altTypes : Array Expr) (f : Array Expr → MetaM α) : MetaM α 
goal: Lean.MetaM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.withSplitterAlts
code: /-- Construct new local declarations `xs` with types `altTypes`, and then execute `f xs`  -/
private partial def withSplitterAlts (altTypes : Array Expr) (f : Array Expr → MetaM α) : MetaM α 
goal: Lean.MetaM α

full_name: Lean.Meta.Match.InjectionAnyResult.solved
code: inductive InjectionAnyResult where
  | solved
  | failed
  | subgoal (mvarId : MVarId)
goal: Lean.Meta.Match.InjectionAnyResult

full_name: Lean.Meta.Match.InjectionAnyResult.subgoal
code: inductive InjectionAnyResult where
  | solved
  | failed
  | subgoal (mvarId : MVarId)
goal: Lean.Meta.Match.InjectionAnyResult

full_name: Lean.Meta.Match.InjectionAnyResult
code: inductive InjectionAnyResult where
  | solved
  | failed
  | subgoal (mvarId : MVarId)
goal: Type

full_name: Lean.Meta.Match.InjectionAnyResult.failed
code: inductive InjectionAnyResult where
  | solved
  | failed
  | subgoal (mvarId : MVarId)
goal: Lean.Meta.Match.InjectionAnyResult

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.injectionAnyCandidate?
code: private def injectionAnyCandidate? (type : Expr) : MetaM (Option (Expr × Expr)) 
goal: Lean.MetaM (Option (Lean.Expr × Lean.Expr))

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.injectionAny
code: private def injectionAny (mvarId : MVarId) : MetaM InjectionAnyResult 
goal: Lean.MetaM Lean.Meta.Match.InjectionAnyResult

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.ConvertM
code: private abbrev ConvertM 
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.mkMap
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.FVarIdMap (Lean.Expr × Nat × Array Bool)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.convertTemplate
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.Meta.Match.ConvertM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.trimFalseTrail
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Array Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.isCastEqRec
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.Meta.Match.ConvertM Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.convertCastEqRec.go
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.Meta.Match.ConvertM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.convertCastEqRec
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.Meta.Match.ConvertM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.proveSubgoalLoop
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.MetaM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkSplitterProof.proveSubgoal
code: /--
  Construct a proof for the splitter generated by `mkEquationsfor`.
  The proof uses the definition of the `match`-declaration as a template (argument `template`).
  - `alts` are free variables corresponding to alternatives of the `match` auxiliary declaration being processed.
  - `altNews` are the new free variables which contains additional hypotheses that ensure they are only used
     when the previous overlapping alternatives are not applicable. -/
private partial def mkSplitterProof (matchDeclName : Name) (template : Expr) (alts altsNew : Array Expr)
    (altsNewNumParams : Array Nat)
    (altArgMasks : Array (Array Bool)) : MetaM Expr 
goal: Lean.MetaM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.withNewAlts
code: /--
  Create new alternatives (aka minor premises) by replacing `discrs` with `patterns` at `alts`.
  Recall that `alts` depends on `discrs` when `numDiscrEqs > 0`, where `numDiscrEqs` is the number of discriminants
  annotated with `h : discr`.
-/
private partial def withNewAlts (numDiscrEqs : Nat) (discrs : Array Expr) (patterns : Array Expr) (alts : Array Expr) (k : Array Expr → MetaM α) : MetaM α 
goal: Lean.MetaM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.withNewAlts.go
code: /--
  Create new alternatives (aka minor premises) by replacing `discrs` with `patterns` at `alts`.
  Recall that `alts` depends on `discrs` when `numDiscrEqs > 0`, where `numDiscrEqs` is the number of discriminants
  annotated with `h : discr`.
-/
private partial def withNewAlts (numDiscrEqs : Nat) (discrs : Array Expr) (patterns : Array Expr) (alts : Array Expr) (k : Array Expr → MetaM α) : MetaM α 
goal: Lean.MetaM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Meta.Match.MatchEqs.0.Lean.Meta.Match.mkEquationsFor
code: /--
  Create conditional equations and splitter for the given match auxiliary declaration. -/
private partial def mkEquationsFor (matchDeclName : Name) :  MetaM MatchEqns 
goal: Lean.MetaM Lean.Meta.Match.MatchEqns

full_name: Lean.Meta.Match.getEquationsForImpl
code: @[export lean_get_match_equations_for]
def getEquationsForImpl (matchDeclName : Name) : MetaM MatchEqns 
goal: Lean.MetaM Lean.Meta.Match.MatchEqns

full_name: Lean.Meta.Match.initFn._@..lake.packages.lean4.src.lean.Lean.Meta.Match.MatchEqs._hyg.13772
code: builtin_initialize registerTraceClass `Meta.Match.matchEqs
goal: IO Unit