fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
transferTransversal_apply'' (q : orbitRel.Quotient (zpowers g) (G ⧸ H)) (k : ZMod (minimalPeriod (g • ·) q.out)) : ↑((g • transferTransversal H g).2.leftQuotientEquiv (g ^ (cast k : ℤ) • q.out)) = if k = 0 then g ^ minimalPeriod (g • ·) q.out * q.out.out else g ^ (cast k : ℤ) * q.out.out := by rw [smul_apply_eq_smul_apply_inv_smul, transferTransversal_apply, transferFunction_apply, ← mul_smul, ← zpow_neg_one, ← zpow_add, quotientEquivSigmaZMod_apply, smul_eq_mul, ← mul_assoc, ← zpow_one_add, Int.cast_add, Int.cast_neg, Int.cast_one, intCast_cast, cast_id', id, ← sub_eq_neg_add, cast_sub_one, add_sub_cancel] by_cases hk : k = 0 · rw [if_pos hk, if_pos hk, zpow_natCast] · rw [if_neg hk, if_neg hk]
lemma
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferTransversal_apply''
null
@[to_additive /-- Given `ϕ : H →+ A` from `H : AddSubgroup G` to an additive commutative group `A`, the transfer homomorphism is `transfer ϕ : G →+ A`. -/] noncomputable transfer [FiniteIndex H] : G →* A := let T : H.LeftTransversal := default { toFun := fun g => diff ϕ T (g • T) map_one' := by rw [one_smul, diff_self] map_mul' := fun g h => by rw [mul_smul, ← diff_mul_diff, smul_diff_smul] } variable (T : H.LeftTransversal) @[to_additive]
def
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transfer
Given `ϕ : H →* A` from `H : Subgroup G` to a commutative group `A`, the transfer homomorphism is `transfer ϕ : G →* A`.
transfer_def [FiniteIndex H] (g : G) : transfer ϕ g = diff ϕ T (g • T) := by rw [transfer, ← diff_mul_diff, ← smul_diff_smul, mul_comm, diff_mul_diff] <;> rfl
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transfer_def
null
transfer_eq_prod_quotient_orbitRel_zpowers_quot [FiniteIndex H] (g : G) [Fintype (Quotient (orbitRel (zpowers g) (G ⧸ H)))] : transfer ϕ g = ∏ q : Quotient (orbitRel (zpowers g) (G ⧸ H)), ϕ ⟨q.out.out⁻¹ * g ^ Function.minimalPeriod (g • ·) q.out * q.out.out, QuotientGroup.out_conj_pow_minimalPeriod_mem H g q.out⟩ := by classical letI := H.fintypeQuotientOfFiniteIndex calc transfer ϕ g = ∏ q : G ⧸ H, _ := transfer_def ϕ (transferTransversal H g) g _ = _ := ((quotientEquivSigmaZMod H g).symm.prod_comp _).symm _ = _ := Finset.prod_sigma _ _ _ _ = _ := by refine Fintype.prod_congr _ _ (fun q => ?_) simp only [quotientEquivSigmaZMod_symm_apply, transferTransversal_apply', transferTransversal_apply''] rw [Fintype.prod_eq_single (0 : ZMod (Function.minimalPeriod (g • ·) q.out)) _] · simp only [if_pos, ZMod.cast_zero, zpow_zero, one_mul, mul_assoc] · intro k hk simp only [if_neg hk, inv_mul_cancel] exact map_one ϕ
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transfer_eq_prod_quotient_orbitRel_zpowers_quot
Explicit computation of the transfer homomorphism.
transfer_eq_pow_aux (g : G) (key : ∀ (k : ℕ) (g₀ : G), g₀⁻¹ * g ^ k * g₀ ∈ H → g₀⁻¹ * g ^ k * g₀ = g ^ k) : g ^ H.index ∈ H := by by_cases hH : H.index = 0 · rw [hH, pow_zero] exact H.one_mem letI := fintypeOfIndexNeZero hH classical replace key : ∀ (k : ℕ) (g₀ : G), g₀⁻¹ * g ^ k * g₀ ∈ H → g ^ k ∈ H := fun k g₀ hk => (congr_arg (· ∈ H) (key k g₀ hk)).mp hk replace key : ∀ q : G ⧸ H, g ^ Function.minimalPeriod (g • ·) q ∈ H := fun q => key (Function.minimalPeriod (g • ·) q) q.out (QuotientGroup.out_conj_pow_minimalPeriod_mem H g q) let f : Quotient (orbitRel (zpowers g) (G ⧸ H)) → zpowers g := fun q => (⟨g, mem_zpowers g⟩ : zpowers g) ^ Function.minimalPeriod (g • ·) q.out have hf : ∀ q, f q ∈ H.subgroupOf (zpowers g) := fun q => key q.out replace key := Subgroup.prod_mem (H.subgroupOf (zpowers g)) fun q (_ : q ∈ Finset.univ) => hf q simpa only [f, minimalPeriod_eq_card, Finset.prod_pow_eq_pow_sum, Fintype.card_sigma, Fintype.card_congr (selfEquivSigmaOrbits (zpowers g) (G ⧸ H)), index_eq_card, Nat.card_eq_fintype_card] using key
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transfer_eq_pow_aux
Auxiliary lemma in order to state `transfer_eq_pow`.
transfer_eq_pow [FiniteIndex H] (g : G) (key : ∀ (k : ℕ) (g₀ : G), g₀⁻¹ * g ^ k * g₀ ∈ H → g₀⁻¹ * g ^ k * g₀ = g ^ k) : transfer ϕ g = ϕ ⟨g ^ H.index, transfer_eq_pow_aux g key⟩ := by classical letI := H.fintypeQuotientOfFiniteIndex change ∀ (k g₀) (hk : g₀⁻¹ * g ^ k * g₀ ∈ H), ↑(⟨g₀⁻¹ * g ^ k * g₀, hk⟩ : H) = g ^ k at key rw [transfer_eq_prod_quotient_orbitRel_zpowers_quot, ← Finset.prod_map_toList, ← Function.comp_def ϕ, List.prod_map_hom] refine congrArg ϕ (Subtype.coe_injective ?_) dsimp only rw [H.coe_mk, ← (zpowers g).coe_mk g (mem_zpowers g), ← (zpowers g).coe_pow, index_eq_card, Nat.card_eq_fintype_card, Fintype.card_congr (selfEquivSigmaOrbits (zpowers g) (G ⧸ H)), Fintype.card_sigma, ← Finset.prod_pow_eq_pow_sum, ← Finset.prod_map_toList] simp only [Subgroup.val_list_prod, List.map_map, ← minimalPeriod_eq_card] congr 2 funext apply key
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transfer_eq_pow
null
transfer_center_eq_pow [FiniteIndex (center G)] (g : G) : transfer (MonoidHom.id (center G)) g = ⟨g ^ (center G).index, (center G).pow_index_mem g⟩ := transfer_eq_pow (id (center G)) g fun k _ hk => by rw [← mul_right_inj, ← hk.comm, mul_inv_cancel_right] variable (G) in
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transfer_center_eq_pow
null
noncomputable transferCenterPow [FiniteIndex (center G)] : G →* center G where toFun g := ⟨g ^ (center G).index, (center G).pow_index_mem g⟩ map_one' := Subtype.ext (one_pow (center G).index) map_mul' a b := by simp_rw [← show ∀ _, (_ : center G) = _ from transfer_center_eq_pow, map_mul] @[simp]
def
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferCenterPow
The transfer homomorphism `G →* center G`.
transferCenterPow_apply [FiniteIndex (center G)] (g : G) : ↑(transferCenterPow G g) = g ^ (center G).index := rfl
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferCenterPow_apply
null
noncomputable transferSylow [FiniteIndex (P : Subgroup G)] : G →* (P : Subgroup G) := @transfer G _ P P (@CommGroup.ofIsMulCommutative P _ ⟨⟨fun a b => Subtype.ext (hP (le_normalizer b.2) a a.2)⟩⟩) (MonoidHom.id P) _ variable [Fact p.Prime] [Finite (Sylow p G)]
def
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferSylow
The homomorphism `G →* P` in Burnside's transfer theorem.
transferSylow_eq_pow_aux (g : G) (hg : g ∈ P) (k : ℕ) (g₀ : G) (h : g₀⁻¹ * g ^ k * g₀ ∈ P) : g₀⁻¹ * g ^ k * g₀ = g ^ k := by haveI : IsMulCommutative (P : Subgroup G) := ⟨⟨fun a b => Subtype.ext (hP (le_normalizer b.2) a a.2)⟩⟩ replace hg := (P : Subgroup G).pow_mem hg k obtain ⟨n, hn, h⟩ := P.conj_eq_normalizer_conj_of_mem (g ^ k) g₀ hg h exact h.trans (Commute.inv_mul_cancel (hP hn (g ^ k) hg).symm) variable [FiniteIndex (P : Subgroup G)]
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferSylow_eq_pow_aux
Auxiliary lemma in order to state `transferSylow_eq_pow`.
transferSylow_eq_pow (g : G) (hg : g ∈ P) : transferSylow P hP g = ⟨g ^ (P : Subgroup G).index, transfer_eq_pow_aux g (transferSylow_eq_pow_aux P hP g hg)⟩ := haveI : IsMulCommutative P := ⟨⟨fun a b => Subtype.ext (hP (le_normalizer b.2) a a.2)⟩⟩ transfer_eq_pow _ _ <| transferSylow_eq_pow_aux P hP g hg
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferSylow_eq_pow
null
transferSylow_restrict_eq_pow : ⇑((transferSylow P hP).restrict (P : Subgroup G)) = (fun x : P => x ^ (P : Subgroup G).index) := funext fun g => transferSylow_eq_pow P hP g g.2
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
transferSylow_restrict_eq_pow
null
ker_transferSylow_isComplement' : IsComplement' (transferSylow P hP).ker P := by have hf : Function.Bijective ((transferSylow P hP).restrict (P : Subgroup G)) := (transferSylow_restrict_eq_pow P hP).symm ▸ (P.2.powEquiv' P.not_dvd_index).bijective rw [Function.Bijective, ← range_eq_top, restrict_range] at hf have := range_eq_top.mp (top_le_iff.mp (hf.2.ge.trans (map_le_range (transferSylow P hP) P))) rw [← (comap_injective this).eq_iff, comap_top, comap_map_eq, sup_comm, SetLike.ext'_iff, normal_mul, ← ker_eq_bot_iff, ← (map_injective (P : Subgroup G).subtype_injective).eq_iff, ker_restrict, subgroupOf_map_subtype, Subgroup.map_bot, coe_top] at hf exact isComplement'_of_disjoint_and_mul_eq_univ (disjoint_iff.2 hf.1) hf.2
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
ker_transferSylow_isComplement'
**Burnside's normal p-complement theorem**: If `N(P) ≤ C(P)`, then `P` has a normal complement.
not_dvd_card_ker_transferSylow : ¬p ∣ Nat.card (transferSylow P hP).ker := (ker_transferSylow_isComplement' P hP).index_eq_card ▸ P.not_dvd_index
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
not_dvd_card_ker_transferSylow
null
ker_transferSylow_disjoint (Q : Subgroup G) (hQ : IsPGroup p Q) : Disjoint (transferSylow P hP).ker Q := disjoint_iff.mpr <| card_eq_one.mp <| (hQ.to_le inf_le_right).card_eq_or_dvd.resolve_right fun h => not_dvd_card_ker_transferSylow P hP <| h.trans <| card_dvd_of_le inf_le_left
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
ker_transferSylow_disjoint
null
normalizer_le_centralizer (hP : IsCyclic P) : P.normalizer ≤ centralizer (P : Set G) := by subst hp by_cases hn : Nat.card G = 1 · have := (Nat.card_eq_one_iff_unique.mp hn).1 rw [Subsingleton.elim P.normalizer (centralizer P)] have := Fact.mk (Nat.minFac_prime hn) have key := card_dvd_of_injective _ (QuotientGroup.kerLift_injective P.normalizerMonoidHom) rw [normalizerMonoidHom_ker, ← index, ← relIndex] at key refine relIndex_eq_one.mp (Nat.eq_one_of_dvd_coprimes ?_ dvd_rfl key) obtain ⟨k, hk⟩ := P.2.exists_card_eq rcases eq_zero_or_pos k with h0 | h0 · rw [hP.card_mulAut, hk, h0, pow_zero, Nat.totient_one] apply Nat.coprime_one_right rw [hP.card_mulAut, hk, Nat.totient_prime_pow Fact.out h0] refine (Nat.Coprime.pow_right _ ?_).mul_right ?_ · apply Nat.Coprime.coprime_dvd_left (relIndex_dvd_of_le_left P.normalizer P.le_centralizer) apply Nat.Coprime.coprime_dvd_left (relIndex_dvd_index_of_le P.le_normalizer) rw [Nat.coprime_comm, Nat.Prime.coprime_iff_not_dvd Fact.out] exact P.not_dvd_index · apply Nat.Coprime.coprime_dvd_left (relIndex_dvd_card (centralizer P) P.normalizer) apply Nat.Coprime.coprime_dvd_left (card_subgroup_dvd_card P.normalizer) have h1 := Nat.gcd_dvd_left (Nat.card G) ((Nat.card G).minFac - 1) have h2 := Nat.gcd_le_right (n := (Nat.card G).minFac - 1) (Nat.card G) (tsub_pos_iff_lt.mpr (Nat.minFac_prime hn).one_lt) contrapose! h2 refine Nat.sub_one_lt_of_le (Nat.card G).minFac_pos (Nat.minFac_le_of_dvd ?_ h1) exact (Nat.two_le_iff _).mpr ⟨ne_zero_of_dvd_ne_zero Nat.card_pos.ne' h1, h2⟩ include hp in
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
normalizer_le_centralizer
null
isComplement' (hP : IsCyclic P) : (MonoidHom.transferSylow P (hP.normalizer_le_centralizer hp)).ker.IsComplement' P := by subst hp by_cases hn : Nat.card G = 1 · have := (Nat.card_eq_one_iff_unique.mp hn).1 rw [Subsingleton.elim (MonoidHom.transferSylow P (hP.normalizer_le_centralizer rfl)).ker ⊥, Subsingleton.elim P.1 ⊤] exact isComplement'_bot_top have := Fact.mk (Nat.minFac_prime hn) exact MonoidHom.ker_transferSylow_isComplement' P (hP.normalizer_le_centralizer rfl)
theorem
GroupTheory
[ "Mathlib.GroupTheory.Complement", "Mathlib.GroupTheory.Sylow" ]
Mathlib/GroupTheory/Transfer.lean
isComplement'
A cyclic Sylow subgroup for the smallest prime has a normal complement.
hammingDist (x y : ∀ i, β i) : ℕ := #{i | x i ≠ y i}
def
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist
The Hamming distance function to the naturals.
@[simp] hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_self
Corresponds to `dist_self`.
hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_nonneg
Corresponds to `dist_nonneg`.
hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_comm
Corresponds to `dist_comm`.
hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_triangle
Corresponds to `dist_triangle`.
hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_triangle_left
Corresponds to `dist_triangle_left`.
hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by rw [hammingDist_comm y] exact hammingDist_triangle _ _ _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_triangle_right
Corresponds to `dist_triangle_right`.
swap_hammingDist : swap (@hammingDist _ β _ _) = hammingDist := by funext x y exact hammingDist_comm _ _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
swap_hammingDist
Corresponds to `swap_dist`.
eq_of_hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 → x = y := by simp_rw [hammingDist, card_eq_zero, filter_eq_empty_iff, Classical.not_not, funext_iff, mem_univ, forall_true_left, imp_self]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
eq_of_hammingDist_eq_zero
Corresponds to `eq_of_dist_eq_zero`.
@[simp] hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 ↔ x = y := ⟨eq_of_hammingDist_eq_zero, fun H => by rw [H] exact hammingDist_self _⟩
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_eq_zero
Corresponds to `dist_eq_zero`.
@[simp] hamming_zero_eq_dist {x y : ∀ i, β i} : 0 = hammingDist x y ↔ x = y := by rw [eq_comm, hammingDist_eq_zero]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hamming_zero_eq_dist
Corresponds to `zero_eq_dist`.
hammingDist_ne_zero {x y : ∀ i, β i} : hammingDist x y ≠ 0 ↔ x ≠ y := hammingDist_eq_zero.not
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_ne_zero
Corresponds to `dist_ne_zero`.
@[simp] hammingDist_pos {x y : ∀ i, β i} : 0 < hammingDist x y ↔ x ≠ y := by rw [← hammingDist_ne_zero, iff_not_comm, not_lt, Nat.le_zero]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_pos
Corresponds to `dist_pos`.
hammingDist_lt_one {x y : ∀ i, β i} : hammingDist x y < 1 ↔ x = y := by rw [Nat.lt_one_iff, hammingDist_eq_zero]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_lt_one
null
hammingDist_le_card_fintype {x y : ∀ i, β i} : hammingDist x y ≤ Fintype.card ι := card_le_univ _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_le_card_fintype
null
hammingDist_comp_le_hammingDist (f : ∀ i, γ i → β i) {x y : ∀ i, γ i} : (hammingDist (fun i => f i (x i)) fun i => f i (y i)) ≤ hammingDist x y := card_mono (monotone_filter_right _ fun i H1 H2 => H1 <| congr_arg (f i) H2)
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_comp_le_hammingDist
null
hammingDist_comp (f : ∀ i, γ i → β i) {x y : ∀ i, γ i} (hf : ∀ i, Injective (f i)) : (hammingDist (fun i => f i (x i)) fun i => f i (y i)) = hammingDist x y := le_antisymm (hammingDist_comp_le_hammingDist _) <| card_mono (monotone_filter_right _ fun i H1 H2 => H1 <| hf i H2)
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_comp
null
hammingDist_smul_le_hammingDist [∀ i, SMul α (β i)] {k : α} {x y : ∀ i, β i} : hammingDist (k • x) (k • y) ≤ hammingDist x y := hammingDist_comp_le_hammingDist fun i => (k • · : β i → β i)
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_smul_le_hammingDist
null
hammingDist_smul [∀ i, SMul α (β i)] {k : α} {x y : ∀ i, β i} (hk : ∀ i, IsSMulRegular (β i) k) : hammingDist (k • x) (k • y) = hammingDist x y := hammingDist_comp (fun i => (k • · : β i → β i)) hk
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_smul
Corresponds to `dist_smul` with the discrete norm on `α`.
hammingNorm (x : ∀ i, β i) : ℕ := #{i | x i ≠ 0}
def
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm
The Hamming weight function to the naturals.
@[simp] hammingDist_zero_right (x : ∀ i, β i) : hammingDist x 0 = hammingNorm x := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_zero_right
Corresponds to `dist_zero_right`.
@[simp] hammingDist_zero_left : hammingDist (0 : ∀ i, β i) = hammingNorm := funext fun x => by rw [hammingDist_comm, hammingDist_zero_right]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_zero_left
Corresponds to `dist_zero_left`.
hammingNorm_nonneg {x : ∀ i, β i} : 0 ≤ hammingNorm x := zero_le _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_nonneg
Corresponds to `norm_nonneg`.
@[simp] hammingNorm_zero : hammingNorm (0 : ∀ i, β i) = 0 := hammingDist_self _
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_zero
Corresponds to `norm_zero`.
@[simp] hammingNorm_eq_zero {x : ∀ i, β i} : hammingNorm x = 0 ↔ x = 0 := hammingDist_eq_zero
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_eq_zero
Corresponds to `norm_eq_zero`.
hammingNorm_ne_zero_iff {x : ∀ i, β i} : hammingNorm x ≠ 0 ↔ x ≠ 0 := hammingNorm_eq_zero.not
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_ne_zero_iff
Corresponds to `norm_ne_zero_iff`.
@[simp] hammingNorm_pos_iff {x : ∀ i, β i} : 0 < hammingNorm x ↔ x ≠ 0 := hammingDist_pos
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_pos_iff
Corresponds to `norm_pos_iff`.
hammingNorm_lt_one {x : ∀ i, β i} : hammingNorm x < 1 ↔ x = 0 := hammingDist_lt_one
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_lt_one
null
hammingNorm_le_card_fintype {x : ∀ i, β i} : hammingNorm x ≤ Fintype.card ι := hammingDist_le_card_fintype
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_le_card_fintype
null
hammingNorm_comp_le_hammingNorm (f : ∀ i, γ i → β i) {x : ∀ i, γ i} (hf : ∀ i, f i 0 = 0) : (hammingNorm fun i => f i (x i)) ≤ hammingNorm x := by simpa only [← hammingDist_zero_right, hf] using hammingDist_comp_le_hammingDist f (y := fun _ ↦ 0)
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_comp_le_hammingNorm
null
hammingNorm_comp (f : ∀ i, γ i → β i) {x : ∀ i, γ i} (hf₁ : ∀ i, Injective (f i)) (hf₂ : ∀ i, f i 0 = 0) : (hammingNorm fun i => f i (x i)) = hammingNorm x := by simpa only [← hammingDist_zero_right, hf₂] using hammingDist_comp f hf₁ (y := fun _ ↦ 0)
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_comp
null
hammingNorm_smul_le_hammingNorm [Zero α] [∀ i, SMulWithZero α (β i)] {k : α} {x : ∀ i, β i} : hammingNorm (k • x) ≤ hammingNorm x := hammingNorm_comp_le_hammingNorm (fun i (c : β i) => k • c) fun i => by simp_rw [smul_zero]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_smul_le_hammingNorm
null
hammingNorm_smul [Zero α] [∀ i, SMulWithZero α (β i)] {k : α} (hk : ∀ i, IsSMulRegular (β i) k) (x : ∀ i, β i) : hammingNorm (k • x) = hammingNorm x := hammingNorm_comp (fun i (c : β i) => k • c) hk fun i => by simp_rw [smul_zero]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingNorm_smul
null
hammingDist_eq_hammingNorm [∀ i, AddGroup (β i)] (x y : ∀ i, β i) : hammingDist x y = hammingNorm (x - y) := by simp_rw [hammingNorm, hammingDist, Pi.sub_apply, sub_ne_zero]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
hammingDist_eq_hammingNorm
Corresponds to `dist_eq_norm`.
Hamming {ι : Type*} (β : ι → Type*) : Type _ := ∀ i, β i
def
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
Hamming
Type synonym for a Pi type which inherits the usual algebraic instances, but is equipped with the Hamming metric and norm, instead of `Pi.normedAddCommGroup` which uses the sup norm.
@[match_pattern] toHamming : (∀ i, β i) ≃ Hamming β := Equiv.refl _
def
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming
`Hamming.toHamming` is the identity function to the `Hamming` of a type.
@[match_pattern] ofHamming : Hamming β ≃ ∀ i, β i := Equiv.refl _ @[simp]
def
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming
`Hamming.ofHamming` is the identity function from the `Hamming` of a type.
toHamming_symm_eq : (@toHamming _ β).symm = ofHamming := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_symm_eq
null
ofHamming_symm_eq : (@ofHamming _ β).symm = toHamming := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_symm_eq
null
toHamming_ofHamming (x : Hamming β) : toHamming (ofHamming x) = x := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_ofHamming
null
ofHamming_toHamming (x : ∀ i, β i) : ofHamming (toHamming x) = x := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_toHamming
null
toHamming_inj {x y : ∀ i, β i} : toHamming x = toHamming y ↔ x = y := Iff.rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_inj
null
ofHamming_inj {x y : Hamming β} : ofHamming x = ofHamming y ↔ x = y := Iff.rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_inj
null
toHamming_zero [∀ i, Zero (β i)] : toHamming (0 : ∀ i, β i) = 0 := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_zero
null
ofHamming_zero [∀ i, Zero (β i)] : ofHamming (0 : Hamming β) = 0 := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_zero
null
toHamming_neg [∀ i, Neg (β i)] {x : ∀ i, β i} : toHamming (-x) = -toHamming x := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_neg
null
ofHamming_neg [∀ i, Neg (β i)] {x : Hamming β} : ofHamming (-x) = -ofHamming x := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_neg
null
toHamming_add [∀ i, Add (β i)] {x y : ∀ i, β i} : toHamming (x + y) = toHamming x + toHamming y := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_add
null
ofHamming_add [∀ i, Add (β i)] {x y : Hamming β} : ofHamming (x + y) = ofHamming x + ofHamming y := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_add
null
toHamming_sub [∀ i, Sub (β i)] {x y : ∀ i, β i} : toHamming (x - y) = toHamming x - toHamming y := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_sub
null
ofHamming_sub [∀ i, Sub (β i)] {x y : Hamming β} : ofHamming (x - y) = ofHamming x - ofHamming y := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_sub
null
toHamming_smul [∀ i, SMul α (β i)] {r : α} {x : ∀ i, β i} : toHamming (r • x) = r • toHamming x := rfl @[simp]
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
toHamming_smul
null
ofHamming_smul [∀ i, SMul α (β i)] {r : α} {x : Hamming β} : ofHamming (r • x) = r • ofHamming x := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
ofHamming_smul
null
@[simp, push_cast] dist_eq_hammingDist (x y : Hamming β) : dist x y = hammingDist (ofHamming x) (ofHamming y) := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
dist_eq_hammingDist
null
@[simp, push_cast] nndist_eq_hammingDist (x y : Hamming β) : nndist x y = hammingDist (ofHamming x) (ofHamming y) := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
nndist_eq_hammingDist
null
@[simp, push_cast] norm_eq_hammingNorm [∀ i, Zero (β i)] (x : Hamming β) : ‖x‖ = hammingNorm (ofHamming x) := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
norm_eq_hammingNorm
null
@[simp, push_cast] nnnorm_eq_hammingNorm [∀ i, AddGroup (β i)] (x : Hamming β) : ‖x‖₊ = hammingNorm (ofHamming x) := rfl
theorem
InformationTheory
[ "Mathlib.Analysis.Normed.Group.Basic" ]
Mathlib/InformationTheory/Hamming.lean
nnnorm_eq_hammingNorm
null
runCoreMWithMessages (info : ContextInfo) (x : CoreM α) : CommandElabM α := do let env := info.env.setExporting false let ctx ← read /- We must execute `x` using the `ngen` stored in `info`. Otherwise, we may create `MVarId`s and `FVarId`s that have been used in `lctx` and `info.mctx`. Similarly, we need to pass in a `namePrefix` because otherwise we can't create auxiliary definitions. -/ let (x, newState) ← (withOptions (fun _ => info.options) x).toIO { currNamespace := info.currNamespace, openDecls := info.openDecls fileName := ctx.fileName, fileMap := ctx.fileMap } { env, ngen := info.ngen, auxDeclNGen := { namePrefix := info.parentDecl?.getD .anonymous } } modify fun state => { state with messages := state.messages ++ newState.messages, traceState.traces := state.traceState.traces ++ newState.traceState.traces } return x
def
Lean
[ "Mathlib.Lean.Elab.Tactic.Meta", "Mathlib.Tactic.Linter.Header" ]
Mathlib/Lean/ContextInfo.lean
runCoreMWithMessages
Embeds a `CoreM` action in `CommandElabM` by supplying the information stored in `info`. Copy of `ContextInfo.runCoreM` that makes use of the `CommandElabM` context for: * logging messages produced by the `CoreM` action, * metavariable generation, * auxiliary declaration generation.
runMetaMWithMessages (info : ContextInfo) (lctx : LocalContext) (x : MetaM α) : CommandElabM α := do (·.1) <$> info.runCoreMWithMessages (Lean.Meta.MetaM.run (ctx := { lctx := lctx }) (s := { mctx := info.mctx }) <| Meta.withLocalInstances (lctx.decls.toList.filterMap id) <| x)
def
Lean
[ "Mathlib.Lean.Elab.Tactic.Meta", "Mathlib.Tactic.Linter.Header" ]
Mathlib/Lean/ContextInfo.lean
runMetaMWithMessages
Embeds a `MetaM` action in `CommandElabM` by supplying the information stored in `info`. Copy of `ContextInfo.runMetaM` that makes use of the `CommandElabM` context for: * message logging (messages produced by the `CoreM` action are migrated back), * metavariable generation, * auxiliary declaration generation, * local instances.
runTactic (ctx : ContextInfo) (i : TacticInfo) (goal : MVarId) (x : MVarId → MetaM α) : CommandElabM α := do if !i.goalsBefore.contains goal then panic!"ContextInfo.runTactic: `goal` must be an element of `i.goalsBefore`" let mctx := i.mctxBefore let lctx := (mctx.decls.find! goal).2 ctx.runMetaMWithMessages lctx <| do let type ← goal.getType let goal ← Meta.mkFreshExprSyntheticOpaqueMVar type x goal.mvarId!
def
Lean
[ "Mathlib.Lean.Elab.Tactic.Meta", "Mathlib.Tactic.Linter.Header" ]
Mathlib/Lean/ContextInfo.lean
runTactic
Run a tactic computation in the context of an infotree node.
runTacticCode (ctx : ContextInfo) (i : TacticInfo) (goal : MVarId) (code : Syntax) : CommandElabM (List MVarId) := do let termCtx ← liftTermElabM read let termState ← liftTermElabM get ctx.runTactic i goal fun goal => Lean.Elab.runTactic' (ctx := termCtx) (s := termState) goal code
def
Lean
[ "Mathlib.Lean.Elab.Tactic.Meta", "Mathlib.Tactic.Linter.Header" ]
Mathlib/Lean/ContextInfo.lean
runTacticCode
Run tactic code, given by a piece of syntax, in the context of an infotree node.
CoreM.withImportModules {α : Type} (modules : Array Name) (run : CoreM α) (searchPath : Option SearchPath := none) (options : Options := {}) (trustLevel : UInt32 := 0) (fileName := "") : IO α := unsafe do if let some sp := searchPath then searchPathRef.set sp Lean.withImportModules (modules.map ({ module := · })) options (trustLevel := trustLevel) fun env => let ctx := {fileName, options, fileMap := default} let state := {env} Prod.fst <$> (CoreM.toIO · ctx state) do run
def
Lean
[ "Mathlib.Init" ]
Mathlib/Lean/CoreM.lean
CoreM.withImportModules
Run a `CoreM α` in a fresh `Environment` with specified `modules : List Name` imported.
successIfFail {α : Type} {M : Type → Type} [MonadError M] [Monad M] (m : M α) : M Exception := do match ← tryCatch (m *> pure none) (pure ∘ some) with | none => throwError "Expected an exception." | some ex => return ex
def
Lean
[ "Mathlib.Init", "Lean.Exception" ]
Mathlib/Lean/Exception.lean
successIfFail
A generalisation of `fail_if_success` to an arbitrary `MonadError`.
isFailedToSynthesize (e : Exception) : IO Bool := do pure <| (← e.toMessageData.toString).startsWith "failed to synthesize"
def
Lean
[ "Mathlib.Init", "Lean.Exception" ]
Mathlib/Lean/Exception.lean
isFailedToSynthesize
Check if an exception is a "failed to synthesize" exception. These exceptions are raised in several different places, and the only commonality is the prefix of the string, so that's what we look for.
rootExpr : GoalsLocation → MetaM Expr | ⟨_, .hyp fvarId⟩ => do instantiateMVars (← fvarId.getType) | ⟨_, .hypType fvarId _⟩ => do instantiateMVars (← fvarId.getType) | ⟨_, .hypValue fvarId _⟩ => do instantiateMVars (← fvarId.getDecl).value | ⟨mvarId, .target _⟩ => do instantiateMVars (← mvarId.getType)
def
Lean
[ "Mathlib.Init", "Lean.Meta.Tactic.Util", "Lean.SubExpr" ]
Mathlib/Lean/GoalsLocation.lean
rootExpr
The root expression of the position specified by the `GoalsLocation`.
pos : GoalsLocation → Pos | ⟨_, .hyp _⟩ => .root | ⟨_, .hypType _ pos⟩ => pos | ⟨_, .hypValue _ pos⟩ => pos | ⟨_, .target pos⟩ => pos
def
Lean
[ "Mathlib.Init", "Lean.Meta.Tactic.Util", "Lean.SubExpr" ]
Mathlib/Lean/GoalsLocation.lean
pos
The `SubExpr.Pos` specified by the `GoalsLocation`.
fvarId? : GoalsLocation → Option FVarId | ⟨_, .hyp fvarId⟩ => fvarId | ⟨_, .hypType fvarId _⟩ => fvarId | ⟨_, .hypValue fvarId _⟩ => fvarId | ⟨_, .target _⟩ => none
def
Lean
[ "Mathlib.Init", "Lean.Meta.Tactic.Util", "Lean.SubExpr" ]
Mathlib/Lean/GoalsLocation.lean
fvarId
The hypothesis specified by the `GoalsLocation`.
@[specialize] firstDeclM (lctx : LocalContext) (f : LocalDecl → m β) : m β := do match (← lctx.findDeclM? (optional ∘ f)) with | none => failure | some b => pure b
def
Lean
[ "Mathlib.Init", "Lean.LocalContext" ]
Mathlib/Lean/LocalContext.lean
firstDeclM
Return the result of `f` on the first local declaration on which `f` succeeds.
@[specialize] lastDeclM (lctx : LocalContext) (f : LocalDecl → m β) : m β := do match (← lctx.findDeclRevM? (optional ∘ f)) with | none => failure | some b => pure b
def
Lean
[ "Mathlib.Init", "Lean.LocalContext" ]
Mathlib/Lean/LocalContext.lean
lastDeclM
Return the result of `f` on the last local declaration on which `f` succeeds.
existsi (mvar : MVarId) (es : List Expr) : MetaM MVarId := do es.foldlM (fun mv e ↦ do let (subgoals,_) ← Elab.Term.TermElabM.run <| Elab.Tactic.run mv do Elab.Tactic.evalTactic (← `(tactic| refine ⟨?_,?_⟩)) let [sg1, sg2] := subgoals | throwError "expected two subgoals" sg1.assign e pure sg2) mvar
def
Lean
[ "Mathlib.Init", "Lean.Elab.Term", "Lean.Elab.Tactic.Basic", "Lean.Meta.Tactic.Assert", "Lean.Meta.Tactic.Clear", "Batteries.CodeAction -- to enable the hole code action" ]
Mathlib/Lean/Meta.lean
existsi
Add the hypothesis `h : t`, given `v : t`, and return the new `FVarId`. -/ def «let» (g : MVarId) (h : Name) (v : Expr) (t : Option Expr := none) : MetaM (FVarId × MVarId) := do (← g.define h (← t.getDM (inferType v)) v).intro1P /-- Has the effect of `refine ⟨e₁,e₂,⋯, ?_⟩`.
partial intros! (mvarId : MVarId) : MetaM (Array FVarId × MVarId) := run #[] mvarId where /-- Implementation of `intros!`. -/ run (acc : Array FVarId) (g : MVarId) := try let ⟨f, g⟩ ← mvarId.intro1 run (acc.push f) g catch _ => pure (acc, g)
def
Lean
[ "Mathlib.Init", "Lean.Elab.Term", "Lean.Elab.Tactic.Basic", "Lean.Meta.Tactic.Assert", "Lean.Meta.Tactic.Clear", "Batteries.CodeAction -- to enable the hole code action" ]
Mathlib/Lean/Meta.lean
intros
Applies `intro` repeatedly until it fails. We use this instead of `Lean.MVarId.intros` to allowing unfolding. For example, if we want to do introductions for propositions like `¬p`, the `¬` needs to be unfolded into `→ False`, and `intros` does not do such unfolding.
_root_.Lean.MVarId.getType'' (mvarId : MVarId) : MetaM Expr := return (← instantiateMVars (← mvarId.getType)).cleanupAnnotations
def
Lean
[ "Mathlib.Init", "Lean.Elab.Term", "Lean.Elab.Tactic.Basic", "Lean.Meta.Tactic.Assert", "Lean.Meta.Tactic.Clear", "Batteries.CodeAction -- to enable the hole code action" ]
Mathlib/Lean/Meta.lean
_root_.Lean.MVarId.getType''
Get the type the given metavariable after instantiating metavariables and cleaning up annotations.
liftMetaTactic' (tac : MVarId → MetaM MVarId) : TacticM Unit := liftMetaTactic fun g => do pure [← tac g] variable {α : Type} @[inline] private def TacticM.runCore (x : TacticM α) (ctx : Context) (s : State) : TermElabM (α × State) := x ctx |>.run s @[inline] private def TacticM.runCore' (x : TacticM α) (ctx : Context) (s : State) : TermElabM α := Prod.fst <$> x.runCore ctx s
def
Lean
[ "Mathlib.Init", "Lean.Elab.Term", "Lean.Elab.Tactic.Basic", "Lean.Meta.Tactic.Assert", "Lean.Meta.Tactic.Clear", "Batteries.CodeAction -- to enable the hole code action" ]
Mathlib/Lean/Meta.lean
liftMetaTactic'
null
run_for (mvarId : MVarId) (x : TacticM α) : TermElabM (Option α × List MVarId) := mvarId.withContext do let pendingMVarsSaved := (← get).pendingMVars modify fun s => { s with pendingMVars := [] } let aux : TacticM (Option α × List MVarId) := /- Important: the following `try` does not backtrack the state. This is intentional because we don't want to backtrack the error message when we catch the "abort internal exception" We must define `run` here because we define `MonadExcept` instance for `TacticM` -/ try let a ← x pure (a, ← getUnsolvedGoals) catch ex => if isAbortTacticException ex then pure (none, ← getUnsolvedGoals) else throw ex try aux.runCore' { elaborator := .anonymous } { goals := [mvarId] } finally modify fun s => { s with pendingMVars := pendingMVarsSaved }
def
Lean
[ "Mathlib.Init", "Lean.Elab.Term", "Lean.Elab.Tactic.Basic", "Lean.Meta.Tactic.Assert", "Lean.Meta.Tactic.Clear", "Batteries.CodeAction -- to enable the hole code action" ]
Mathlib/Lean/Meta.lean
run_for
null
private isBlackListed (declName : Name) : CoreM Bool := do if declName.toString.startsWith "Lean" then return true let env ← getEnv pure <| declName.isInternalDetail || isAuxRecursor env declName || isNoConfusion env declName <||> isRec declName <||> isMatcher declName
def
Lean
[ "Mathlib.Init", "Lean.Meta.Match.MatcherInfo", "Lean.Meta.Tactic.Delta", "Std.Data.HashMap.Basic" ]
Mathlib/Lean/Name.lean
isBlackListed
null
allNames (p : Name → Bool) : CoreM (Array Name) := do (← getEnv).constants.foldM (init := #[]) fun names n _ => do if p n && !(← isBlackListed n) then return names.push n else return names
def
Lean
[ "Mathlib.Init", "Lean.Meta.Match.MatcherInfo", "Lean.Meta.Tactic.Delta", "Std.Data.HashMap.Basic" ]
Mathlib/Lean/Name.lean
allNames
Retrieve all names in the environment satisfying a predicate.
allNamesByModule (p : Name → Bool) : CoreM (Std.HashMap Name (Array Name)) := do (← getEnv).constants.foldM (init := ∅) fun names n _ => do if p n && !(← isBlackListed n) then let some m ← findModuleOf? n | return names match names[m]? with | some others => return names.insert m (others.push n) | none => return names.insert m #[n] else return names
def
Lean
[ "Mathlib.Init", "Lean.Meta.Match.MatcherInfo", "Lean.Meta.Tactic.Delta", "Std.Data.HashMap.Basic" ]
Mathlib/Lean/Name.lean
allNamesByModule
Retrieve all names in the environment satisfying a predicate, gathered together into a `HashMap` according to the module they are defined in.
Lean.Name.decapitalize (n : Name) : Name := n.modifyBase fun | .str p s => .str p s.decapitalize | n => n
def
Lean
[ "Mathlib.Init", "Lean.Meta.Match.MatcherInfo", "Lean.Meta.Tactic.Delta", "Std.Data.HashMap.Basic" ]
Mathlib/Lean/Name.lean
Lean.Name.decapitalize
Decapitalize the last component of a name.
Lean.Name.isAuxLemma (n : Name) : Bool := match n with | .str _ s => "_proof_".isPrefixOf s || "_simp_".isPrefixOf s | _ => false
def
Lean
[ "Mathlib.Init", "Lean.Meta.Match.MatcherInfo", "Lean.Meta.Tactic.Delta", "Std.Data.HashMap.Basic" ]
Mathlib/Lean/Name.lean
Lean.Name.isAuxLemma
Whether the lemma has a name of the form produced by `Lean.Meta.mkAuxLemma`.
Lean.Meta.unfoldAuxLemmas (e : Expr) : MetaM Expr := do deltaExpand e Lean.Name.isAuxLemma
def
Lean
[ "Mathlib.Init", "Lean.Meta.Match.MatcherInfo", "Lean.Meta.Tactic.Delta", "Std.Data.HashMap.Basic" ]
Mathlib/Lean/Name.lean
Lean.Meta.unfoldAuxLemmas
Unfold all lemmas created by `Lean.Meta.mkAuxLemma`.
@[simp] get_pure {α} (x : α) : (Thunk.pure x).get = x := rfl @[simp] theorem get_mk {α} (f : Unit → α) : (Thunk.mk f).get = f () := rfl universe u v variable {α : Type u} {β : Type v}
theorem
Lean
[ "Mathlib.Init" ]
Mathlib/Lean/Thunk.lean
get_pure
null
prod (a : Thunk α) (b : Thunk β) : Thunk (α × β) := Thunk.mk fun _ => (a.get, b.get) @[simp] theorem prod_get_fst {a : Thunk α} {b : Thunk β} : (prod a b).get.1 = a.get := rfl @[simp] theorem prod_get_snd {a : Thunk α} {b : Thunk β} : (prod a b).get.2 = b.get := rfl
def
Lean
[ "Mathlib.Init" ]
Mathlib/Lean/Thunk.lean
prod
The Cartesian product of two thunks.