Skip to content

Conversation

@Yosuke-Ito-345
Copy link
Contributor

Motivation for this change

Prove that the function pmf is measurable.

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

Reference: How to document

Merge policy

As a rule of thumb:

  • PRs with several commits that make sense individually and that
    all compile are preferentially merged into master.
  • PRs with disorganized commits are very likely to be squash-rebased.
Reminder to reviewers

@Yosuke-Ito-345
Copy link
Contributor Author

@affeldt-aist @t6s
I kindly ask for your review of this pull request.
Please note that I moved the definition of pmf outside of the Section discrete_distribution, because the random variable here need not be discrete and I'm planning to use the lemma pmf_measurable for a general random variable.

Copy link
Member

@t6s t6s left a comment

Choose a reason for hiding this comment

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

The statements and the code look good modulo some cleaning as I commented.
I think in_set1_eq can replace in_set1, but not necessarily by this PR.

Context d (T : measurableType d) (R : realType)
(P : probability T R) (X : {RV P >-> R}).

Lemma pmf_positive_countable : countable [set r | (0 < pmf X r)%R].
Copy link
Member

Choose a reason for hiding this comment

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

pmf_gt0_countable will be more conformant with other names

Proof.
have ->: [set r | 0 < (pmf X r)%:E] =
\bigcup_n [set r | (n.+1%:R^-1 < pmf X r)%R].
rewrite seteqP; split => [r /ltr_add_invr [l] | r [k] _]; last exact: lt_trans.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rewrite seteqP; split => [r /ltr_add_invr [l] | r [k] _]; last exact: lt_trans.
apply/seteqP; split => [r /ltr_add_invr [l] | r [k] _]; last exact: lt_trans.

to make this line fit within 80 chars.

Comment on lines 1099 to 1100
apply/esym/measure_bigcup => //=.
move: (trivIset_comp (fun r => X @^-1` [set r]) q_inj); rewrite /comp => ->.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
apply/esym/measure_bigcup => //=.
move: (trivIset_comp (fun r => X @^-1` [set r]) q_inj); rewrite /comp => ->.
rewrite measure_bigcup// (trivIset_comp (fun r => X @^-1` [set r]))//.

have pmf1_ge0 k s : 0%R <= (pmf X (h k) * \1_[set h k] s)%:E.
by rewrite EFinM; apply: mule_ge0.
apply: (eq_measurable_fun sfun) => [r _|].
case: (pselect ([set h k | k in S] r)) => [rS | nrS].
Copy link
Member

Choose a reason for hiding this comment

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

I would use asboolP instead of pselect to avoid an extra of parentheses:

case/asboolP: ([set h k | k in S] r) => [rS | nrS].

But honestly I'm not sure which is more idiomatic.

apply: (eq_measurable_fun sfun) => [r _|].
case: (pselect ([set h k | k in S] r)) => [rS | nrS].
- pose kr := (pinv S h r).
have neqh k : in_set S k && (k != kr) -> r != h k.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
have neqh k : in_set S k && (k != kr) -> r != h k.
have neqh k : (k \in S) && (k != kr) -> r != h k.

Comment on lines 1139 to 1140
have ->: (r == h k) = false; rewrite ?mulr0// -eq_opE eqbF_neg; apply/negP.
apply/contra_not/nrS; rewrite eq_opE => ->.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
have ->: (r == h k) = false; rewrite ?mulr0// -eq_opE eqbF_neg; apply/negP.
apply/contra_not/nrS; rewrite eq_opE => ->.
suff ->: (r == h k) = false by rewrite mulr0.
apply/negbTE/eqP/contra_not/nrS => ->.

rewrite indicE in_set1_eq.
have ->: (r == h k) = false; rewrite ?mulr0// -eq_opE eqbF_neg; apply/negP.
apply/contra_not/nrS; rewrite eq_opE => ->.
by exists k; rewrite -?(in_setE S k).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
by exists k; rewrite -?(in_setE S k).
by exists k => //; rewrite -(in_setE S k).


#[global] Hint Resolve nat_nonempty : core.

Lemma in_set1_eq {T : eqType} (a : T) (x : T) : x \in [set a] = (x == a).
Copy link
Member

Choose a reason for hiding this comment

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

I think this lemma deserves the name in_set1, and the current in_set1 can be removed at all
(or the latter should be renamed to something like in_set1_fin or in_finset1).

@CohenCyril

Copy link
Member

Choose a reason for hiding this comment

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

in_set1 is not used at all in mathcomp-analysis master!

master$ find . -name "*.v" -exec grep -Hn "in_set1" {} ';'
./classical/classical_sets.v:2199:Lemma in_set1 [T : finType] (x y : T) : (x \in [set y]) = (x \in [set y]%SET).
master$

@Yosuke-Ito-345
Copy link
Contributor Author

@t6s
Thank you for the review.
I incorporated your feedback into the proof.
I'm going to replace the lemma in_set1 with in_set1_eq in another pull request.

@Yosuke-Ito-345
Copy link
Contributor Author

This is an unexpected failure.
The stable version of mathcomp appears to be unchanged since the last pull request.
Do I need to install the development version of mathcomp?
(In my experience, mathcomp-devel is fragile and often fails to compile.)

@t6s
Copy link
Member

t6s commented Jan 28, 2026

The CI failure looks strange and irrelevant to this PR.

@t6s
Copy link
Member

t6s commented Jan 28, 2026

I set up a local env with coq 8.20 and mathcomp 2.4.0, but could not reproduce the error.

@Yosuke-Ito-345
Copy link
Contributor Author

@t6s
Thank you for looking into this error.
For now, I leave the pull request as it is.

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