Skip to content

Counting distribution - #2064

Draft
lyonel2017 wants to merge 3 commits into
math-comp:masterfrom
lyonel2017:feature-counting-distribution
Draft

lyonel2017 wants to merge 3 commits into
math-comp:masterfrom
lyonel2017:feature-counting-distribution

Conversation

@lyonel2017

@lyonel2017 lyonel2017 commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor
Motivation for this change

Porting the distr library from experimental_real in order to use esum (extracted from #2049).

Depends on #2062.

Checklist
  • added corresponding entries in CHANGELOG_UNRELEASED.md
  • added corresponding documentation in the headers

Reference: How to document

Reminder to reviewers

@affeldt-aist affeldt-aist added this to the 1.18.0 milestone Jul 30, 2026
@lyonel2017
lyonel2017 force-pushed the feature-counting-distribution branch 2 times, most recently from c83d705 to 3855cd8 Compare August 3, 2026 18:33
@affeldt-aist

affeldt-aist commented Aug 9, 2026 •

Copy link
Copy Markdown
Member

Note for later: check how le_esum_fine (and le_pos_esum_fine) are used and decide they are worth keeping

@affeldt-aist

Copy link
Copy Markdown
Member

PR #2062 merged -> need rebasing

@lyonel2017
lyonel2017 force-pushed the feature-counting-distribution branch from 3855cd8 to ac892f5 Compare August 11, 2026 11:41
@lyonel2017

Copy link
Copy Markdown
Contributor Author

PR #2062 merged -> need rebasing

I made a rebase.

@affeldt-aist

Copy link
Copy Markdown
Member

The CI is reporting a couple of errors, e.g.:

File "./theories/probability_theory/counting_distr.v", line 157, characters 0-36:
Error: The LHS of ge_ereal_sup
    (ereal_sup _ <= _)%E
does not match any subterm of the goal

@lyonel2017

Copy link
Copy Markdown
Contributor Author

A, I messed up something. I will fix this. If that's okay, I will make a few more changes. I started using this PR in a project, and there are things I don't like and/or that are poorly designed (mostly for dlim).

@affeldt-aist

Copy link
Copy Markdown
Member

No problem (we still have to review #2063 beforehand anyway).

Don't hesitate to make micro PRs, especially if among the issues you spotted there are potential fixes to things that have already been merged in master (I am thinking about this PR #2062 we merged some time ago) because we are likely to make a release the end of the month.

@lyonel2017
lyonel2017 force-pushed the feature-counting-distribution branch from fafee44 to 2bf37db Compare August 26, 2026 11:10
@lyonel2017

Copy link
Copy Markdown
Contributor Author

I finish my changes (the issue where in the changes propose in #2064).

No problem (we still have to review #2063 beforehand anyway).

Review of #2063 does not necessary need to be done before #2064, except if we want to use result establish on lesbegue_integrale to do some simplification (if possible).

HB.structure Definition Distribution (R : realType) (T : choiceType) :=
{f of @isDistribution R T f}.

Notation "{ 'distr' T / R }" := (@Distribution.type R T)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adopting the notation R.-distr T? (There are already several datatypes whose notation follow this pattern in MathComp.)


(* -------------------------------------------------------------------- *)
Section Clamp.
Context {R : realType}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type could be generalized to at least realFieldType and therefore this section is a candidate for PR to MathComp. It might go to unstable.v for a while but really MathComp looks like the right place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I open a PR: #2106


Implicit Types (mu : {distr T / R}) (A B E : pred T) (f : T -> R).

Definition dinsupp mu := fun x => mu x != 0 :> R.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notation of support does not need to be specialized to "distribution".


Definition pr mu E := fine (esum [set: T] (EFin \o (fun x => (E x)%:R * mu x))).
Definition prc mu E A := pr mu [predI E & A] / pr mu A.
Definition esp mu f := fine (esum [set: T] (EFin \o (fun x => f x * mu x))).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expectation is also defined in random_variable.v but for probability measure. It should maybe be generalized to subprobability measure so that the notation can be shared (provided "distributions" are shown to be subprobability measures, which they are).

Section DistrTheory.
Context {R : realType} {T : choiceType} (mu : T -> R).

Definition isdistr :=

@affeldt-aist affeldt-aist Sep 22, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might give raise to a "factory" in HB parlance: an alternative definition that is shown to produce a "distribution" by using HB.builder.


Definition mkdistrd := @isDistribution.Build R T mu isd1 isd2 isd3.

Definition ispredistr {T : choiceType} (mu : T -> R) :=

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could have been another mixin but it is actually not used in this PR.

Section Restr.
Context (R : realType) (T : choiceType) (p : pred T).

Definition drestr_fun (mu : {distr T / R}) :=

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is redefining mrestr which is already in measure_function.v (and that would have come for free if "distributions" were shown to be (probability) measures).

(* -------------------------------------------------------------------- *)
(* Generic facts about [einfs] / [limn_einf] missing from sequences.v, *)
(* used below to make [dlim] total on sequences of subdistributions. *)
Lemma einfs_le {R : realType} (u : (\bar R)^nat) n m :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do a smaller PR with these facts to accelerate the review process.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I open a PR: #2107

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants