Skip to content

feat: q-analogs - #43780

Open
SashaIr wants to merge 10 commits into
leanprover-community:masterfrom
SashaIr:q-analogs
Open

SashaIr wants to merge 10 commits into
leanprover-community:masterfrom
SashaIr:q-analogs

Conversation

@SashaIr

@SashaIr SashaIr commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

An implementation of q-analogs, q-binomials, and counting results.


Open in Gitpod

@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Sep 13, 2026
@github-actions

Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to Zulip and join the Lean community.
Thank you again for joining our community.

@github-actions

github-actions Bot commented Sep 13, 2026

Copy link
Copy Markdown

PR summary bf1d33d12b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Combinatorics.QAnalog.Basic (new file) 833
Mathlib.Combinatorics.QAnalog.Binomial (new file) 850
Mathlib.Combinatorics.QAnalog.Counting (new file) 851
Mathlib.Combinatorics.QAnalog.Subspace (new file) 1781

Declarations diff (regex)

+ Commute.list_prod_one_add_pow_mul
+ Commute.qBinomial_left
+ Commute.qBinomial_right
+ Commute.qFactorial_left
+ Commute.qFactorial_right
+ Commute.qNat_left
+ Commute.qNat_right
+ Commute.qPochhammer_eq_sum_qBinomial
+ card_submodule_finrank_eq_qBinomial
+ filter_notMem_insert_zero_map
+ filter_notMem_map
+ inversions
+ inversions_empty
+ inversions_insert_zero_map
+ inversions_map_succ
+ map_qBinomial
+ map_qNat
+ one_sub_mul_qNat
+ prod_one_add_pow_mul_eq_sum_qBinomial
+ prod_pow_sub_pow_mul_qFactorial
+ qBinomial
+ qBinomial_commute
+ qBinomial_commute_pow
+ qBinomial_eq_zero_of_lt
+ qBinomial_mul_eq_mul
+ qBinomial_mul_prod_pow_sub_pow
+ qBinomial_mul_qFactorial_mul_qFactorial
+ qBinomial_mul_qNat_sub
+ qBinomial_one_left
+ qBinomial_one_right
+ qBinomial_self
+ qBinomial_succ_left
+ qBinomial_succ_right
+ qBinomial_succ_succ
+ qBinomial_succ_succ'
+ qBinomial_symm
+ qBinomial_symm_add
+ qBinomial_symm_of_eq_add
+ qBinomial_zero_right
+ qBinomial_zero_succ
+ qFactorial
+ qFactorial_commute
+ qFactorial_commute_qBinomial
+ qFactorial_commute_qFactorial
+ qFactorial_eq_prod_range
+ qFactorial_int_pos
+ qFactorial_one
+ qFactorial_one_left
+ qFactorial_succ
+ qFactorial_succ'
+ qFactorial_zero
+ qNat
+ qNat_add
+ qNat_commute
+ qNat_commute_pow
+ qNat_commute_qBinomial
+ qNat_commute_qFactorial
+ qNat_commute_qNat
+ qNat_eq_sum_range
+ qNat_mul
+ qNat_mul_one_sub
+ qNat_one
+ qNat_one_left
+ qNat_succ
+ qNat_succ'
+ qNat_two
+ qNat_zero
+ qPochhammer
+ qPochhammer_eq_prod_range
+ qPochhammer_eq_sum_qBinomial
+ qPochhammer_one
+ qPochhammer_self
+ qPochhammer_succ
+ qPochhammer_succ'
+ qPochhammer_zero
+ qPochhammer_zero_left
+ range_succ_eq_insert_map
+ spanEquiv
+ succEmb
+ succEmb_apply
+ sum_pow_inversions_eq_qBinomial
+ sum_pow_sum_eq_qBinomial
+ sum_powersetCard_succ

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean -- stale, waiting for the new build)

Lean-aware diff — post-build, computed from the Lean environment (commit 016b867).

  • +80 new declarations
  • −0 removed declarations
+Commute.list_prod_one_add_pow_mul
+Commute.qBinomial_left
+Commute.qBinomial_right
+Commute.qFactorial_left
+Commute.qFactorial_right
+Commute.qNat_left
+Commute.qNat_right
+Commute.qPochhammer_eq_sum_qBinomial
+QAnalog.card_submodule_finrank_eq_qBinomial
+QAnalog.inversions
+QAnalog.inversions_empty
+QAnalog.inversions_insert_zero_map
+QAnalog.inversions_map_succ
+QAnalog.prod_pow_sub_pow_mul_qFactorial
+QAnalog.qBinomial_mul_prod_pow_sub_pow
+QAnalog.spanEquiv
+QAnalog.succEmb
+QAnalog.sum_pow_inversions_eq_qBinomial
+QAnalog.sum_pow_sum_eq_qBinomial
+QAnalog.«term[_;_]__»
+QAnalog.«term[_]__!»
+QAnalog.«term[_]__»
+map_qBinomial
+map_qNat
+one_sub_mul_qNat
+prod_one_add_pow_mul_eq_sum_qBinomial
+qBinomial
+qBinomial_commute
+qBinomial_commute_pow
+qBinomial_eq_zero_of_lt
+qBinomial_mul_eq_mul
+qBinomial_mul_qFactorial_mul_qFactorial
+qBinomial_mul_qNat_sub
+qBinomial_one_left
+qBinomial_one_right
+qBinomial_self
+qBinomial_succ_left
+qBinomial_succ_right
+qBinomial_succ_succ
+qBinomial_succ_succ'
+qBinomial_symm
+qBinomial_symm_add
+qBinomial_symm_of_eq_add
+qBinomial_zero_right
+qBinomial_zero_succ
+qFactorial
+qFactorial_commute
+qFactorial_commute_qBinomial
+qFactorial_commute_qFactorial
+qFactorial_eq_prod_range
+qFactorial_one
+qFactorial_one_left
+qFactorial_succ
+qFactorial_succ'
+qFactorial_zero
+qNat
+qNat_add
+qNat_commute
+qNat_commute_pow
+qNat_commute_qBinomial
+qNat_commute_qFactorial
+qNat_commute_qNat
+qNat_eq_sum_range
+qNat_mul
+qNat_mul_one_sub
+qNat_one
+qNat_one_left
+qNat_succ
+qNat_succ'
+qNat_two
+qNat_zero
+qPochhammer
+qPochhammer_eq_prod_range
+qPochhammer_eq_sum_qBinomial
+qPochhammer_one
+qPochhammer_self
+qPochhammer_succ
+qPochhammer_succ'
+qPochhammer_zero
+qPochhammer_zero_left

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (4.00, 0.00)
Current number Change Type (weak)
exposed public sections 5070 4

Current commit bf1d33d12b
Reference commit 8d52ea9a14

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-combinatorics Combinatorics label Sep 13, 2026
@b-mehta

b-mehta commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Can you comment on the use of AI in this PR?

@SashaIr

SashaIr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Sure. The initial draft is human-written (by the listed authors), based on the existing implementation of Nat, factorials, and binomials. I fed Aristotle a few of these files to improve, restructure, and make Mathlib-ready.

Most of the code in Basic.lean and Binomial.lean is essentially human-written and AI-polished; Counting.lean is based on another human-written file but some proofs were originally provided by Aristotle in sorry-filling mode, if I recall correctly; Subspace.lean is pretty much entirely AI-generated, I did not even ask for it but Aristotle produced the file together with the others, so I included it in the PR as well.

@SashaIr

SashaIr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

The AI use was originally disclosed in the header, but then I got asked to remove Aristotle from the author list in a discussion in a different PR. It could (should?) be mentioned in the implementation details section.

@SnirBroshi

Copy link
Copy Markdown
Collaborator

The Authors list refers to humans responsible for the code, and AI usage disclosures belong in the PR description, per the contribution guidelines.

@SashaIr

SashaIr commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

I'll make a revision pass and then update everything according to the guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-combinatorics Combinatorics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants