Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: generalize Reals to realTypes for fdist #103

Merged
merged 103 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
c7a5d72
import fdists from https://github.com/affeldt-aist/trajectories/blob/…
yoshihiro503 Dec 23, 2022
e360eb9
WIP: 2023 01/13 sagyou
yoshihiro503 Jan 13, 2023
5fc5849
WIP: 1/20 sagyou
yoshihiro503 Jan 20, 2023
09c28f8
WIP: yoshihiro503 sagyou 2023 01/27
yoshihiro503 Jan 27, 2023
7a48760
WIP: 2023 02/03 sagyou
yoshihiro503 Feb 3, 2023
3fabe37
refactor: use onem instead of ponem.
yoshihiro503 Feb 10, 2023
ef3925a
feat: introduce a notation "R.-fdist A"
yoshihiro503 Feb 10, 2023
31d62ae
2023 02/10 sagyou
yoshihiro503 Feb 10, 2023
316efac
..
yoshihiro503 Jun 30, 2023
0000367
solved all Admitted proofs for onem in fdist.v
yoshihiro503 Jun 30, 2023
34390df
Rstruct.real_realType
affeldt-aist Jun 30, 2023
779e692
R1? GRing.one
affeldt-aist Jun 30, 2023
91e952e
support proba
yoshihiro503 Jun 30, 2023
81dfe62
convex <- progress...
yoshihiro503 Jun 30, 2023
2722b60
introduce realType
yoshihiro503 Jul 7, 2023
b01da21
move onem and prob to realType_ext
yoshihiro503 Jul 7, 2023
48fc772
fix
affeldt-aist Jul 7, 2023
a9609d5
comment out onem
affeldt-aist Jul 7, 2023
69b2879
fix
affeldt-aist Jul 7, 2023
a20ef0b
progress
affeldt-aist Jul 7, 2023
61c2206
progress
affeldt-aist Jul 7, 2023
2d23313
comment out in Rbigop.v
affeldt-aist Jul 7, 2023
6dae11e
numdomaintype -> realtype in fdist.v
affeldt-aist Jul 7, 2023
1a651f6
fdist
yoshihiro503 Jul 7, 2023
4d3d05a
yoshihiro503 2023 07.21
yoshihiro503 Jul 21, 2023
ae13f2b
2023. 07. 28
yoshihiro503 Jul 28, 2023
b90e9a1
2023 08 04
yoshihiro503 Aug 4, 2023
16cf61f
08/18
yoshihiro503 Aug 18, 2023
ac25f6b
2023 08 25
yoshihiro503 Aug 25, 2023
32826a3
fix opam file
yoshihiro503 Sep 1, 2023
2291e6e
pass fsdists
yoshihiro503 Sep 1, 2023
c81730e
2023 0901
yoshihiro503 Sep 1, 2023
1b6ea2f
pass jfdist_cond.v
yoshihiro503 Sep 8, 2023
6e1628f
pass convex_equiv.v
yoshihiro503 Sep 8, 2023
cc63273
sagyou : 2023 09 08
yoshihiro503 Sep 8, 2023
b00d180
- define ad-hoc coercion Prob.p : prob >-> R
t6s Sep 7, 2023
f3aeab1
Notation %:pp to make Prob_p visible
t6s Sep 8, 2023
0d4d0df
comment
t6s Sep 8, 2023
2fc1d1f
2023 09 15 sagyou
yoshihiro503 Sep 15, 2023
7676be1
..
yoshihiro503 Sep 29, 2023
ed51fba
convex_stone.vの Lemma Convn_permI3 まで
yoshihiro503 Sep 29, 2023
44ef0da
port degree_profile
affeldt-aist Sep 29, 2023
0cd8035
upd graphois.v
affeldt-aist Sep 29, 2023
0ea8082
upd jensen.v
affeldt-aist Sep 29, 2023
4cc0222
upd bayes.v
affeldt-aist Sep 29, 2023
ab7c0c0
upd source_code.v
affeldt-aist Sep 29, 2023
6a9e563
upd expected_value_variance.v
affeldt-aist Sep 29, 2023
b9149f6
upd expected_value_variance_ordn.v
affeldt-aist Sep 29, 2023
dd4dafc
upd expected_value_variance_tuple.v
affeldt-aist Sep 29, 2023
960f1a7
no admit in realType_ext.v
affeldt-aist Sep 29, 2023
d6bd921
2023 09 29 作業分
yoshihiro503 Sep 29, 2023
c24f47b
convex_stone.v
yoshihiro503 Oct 6, 2023
61d7bbc
ln_fact.v
yoshihiro503 Oct 6, 2023
c1dc33e
divergence.v
yoshihiro503 Oct 6, 2023
3e5a857
variation_dist.v
yoshihiro503 Oct 6, 2023
0690067
entropy.v
affeldt-aist Oct 6, 2023
7a56a19
channel.v
affeldt-aist Oct 6, 2023
2df881b
pproba.v
affeldt-aist Oct 6, 2023
77b54e8
easure_channel.v
affeldt-aist Oct 6, 2023
0cbc9a3
necset.v
affeldt-aist Oct 6, 2023
7ee67f5
wip
affeldt-aist Oct 6, 2023
155dc97
log_sum prograss...
yoshihiro503 Oct 6, 2023
323bf09
aep.v completed
affeldt-aist Oct 12, 2023
8769fd8
log_sum.v
yoshihiro503 Oct 13, 2023
1b4a6e2
typ_seq.v
affeldt-aist Oct 13, 2023
21c8db8
binary_symmetric_channel.v
affeldt-aist Oct 13, 2023
e93bb12
types
affeldt-aist Oct 13, 2023
4109acb
jtypes
affeldt-aist Oct 13, 2023
2ee713f
joint_typ_seq.v
affeldt-aist Oct 13, 2023
2e57946
partition_inquality.v
yoshihiro503 Oct 13, 2023
c5d6c9a
channel coding
affeldt-aist Oct 13, 2023
e64509e
string_entropy
affeldt-aist Oct 13, 2023
8c23cd8
success decode bound
affeldt-aist Oct 13, 2023
72df24e
vl direct
affeldt-aist Oct 13, 2023
236fc6b
vl_converse
affeldt-aist Oct 13, 2023
a0137ee
rm warning
ymizoguchi Oct 13, 2023
92e32c2
pinsker.v
yoshihiro503 Oct 13, 2023
03b7ebd
entropy_convex
affeldt-aist Oct 13, 2023
10d875d
error_exponent.v
yoshihiro503 Oct 13, 2023
d606c14
conditional entropy
affeldt-aist Oct 13, 2023
98fe8d1
rm warning
ymizoguchi Oct 13, 2023
a63dcd9
ecc_classic/decoding.v progress...
yoshihiro503 Oct 13, 2023
306a1c0
use mca and order in decoding.v
t6s Oct 16, 2023
94cf07e
put gluing lemmas into a new file; move R0E and R1E to Reals_ext
t6s Oct 16, 2023
795fe07
hamming_code
t6s Oct 16, 2023
1f4db4e
move bsc things to binary_symmetric_channel.v
t6s Oct 16, 2023
295a27b
ldpc done; every file compiles
t6s Oct 16, 2023
9d0e20e
rm warning
ymizoguchi Oct 13, 2023
db2bb2f
rm warning
ymizoguchi Oct 19, 2023
2690df4
fix proof
yoshihiro503 Oct 20, 2023
124b7c3
mv Scope name mcR to realType_ext
yoshihiro503 Oct 20, 2023
e4de50d
remove prodR_gt0 from Rbigop
yoshihiro503 Oct 20, 2023
234f9d6
rm finalg in lib/probability/information_theory
affeldt-aist Oct 31, 2023
b9a3ed2
rm <b= etc. (wip) (#14)
affeldt-aist Nov 2, 2023
1d9d4b7
rename porting_coqR_mcR.v to Rstruct_ext.v (#15)
t6s Nov 2, 2023
88048fa
admits in Reals.ext.v (#16)
affeldt-aist Nov 13, 2023
71fcf47
all admits in Real_ext.v (#17)
affeldt-aist Nov 13, 2023
274afd0
no more <b notations (#18)
affeldt-aist Nov 13, 2023
aae09a0
cleaning (rm duplicates, etc.) (#19)
affeldt-aist Nov 14, 2023
dfa02e0
rm nneg fun (#20)
affeldt-aist Nov 15, 2023
30fca1f
rm onme (wip) (#21)
affeldt-aist Nov 16, 2023
b8a5ef8
CI
affeldt-aist Nov 20, 2023
59dee28
fix
affeldt-aist Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/docker-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
strategy:
matrix:
image:
- 'mathcomp/mathcomp:1.16.0-coq-8.17'
- 'mathcomp/mathcomp:1.17.0-coq-8.17'
- 'mathcomp/mathcomp:1.18.0-coq-8.17'
- 'mathcomp/mathcomp:1.17.0-coq-8.18'
- 'mathcomp/mathcomp:1.18.0-coq-8.18'
fail-fast: false
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ information theory, and linear error-correcting codes.
- [MathComp field](https://math-comp.github.io)
- [MathComp analysis](https://github.com/math-comp/analysis)
- [Hierarchy Builder](https://github.com/math-comp/hierarchy-builder)
- MathComp algebra tactics
- Coq namespace: `infotheo`
- Related publication(s):
- [Formal Adventures in Convex and Conical Spaces](https://arxiv.org/abs/2004.12713) doi:[10.1007/978-3-030-53518-6_2](https://doi.org/10.1007/978-3-030-53518-6_2)
Expand Down
2 changes: 2 additions & 0 deletions _CoqProject
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

lib/ssrZ.v
lib/ssrR.v
lib/realType_ext.v
lib/Reals_ext.v
lib/logb.v
lib/Ranalysis_ext.v
Expand All @@ -23,6 +24,7 @@ lib/euclid.v
lib/dft.v
lib/vandermonde.v
lib/classical_sets_ext.v
lib/Rstruct_ext.v
probability/fdist.v
probability/proba.v
probability/fsdist.v
Expand Down
15 changes: 8 additions & 7 deletions coq-infotheo.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ build: [
]
install: [make "install"]
depends: [
"coq" { (>= "8.17" & < "8.18~") | (= "dev") }
"coq-mathcomp-ssreflect" { (>= "1.16.0" & < "1.18~") | (= "dev") }
"coq-mathcomp-fingroup" { (>= "1.16.0" & < "1.18~") | (= "dev") }
"coq-mathcomp-algebra" { (>= "1.16.0" & < "1.18~") | (= "dev") }
"coq-mathcomp-solvable" { (>= "1.16.0" & < "1.18~") | (= "dev") }
"coq-mathcomp-field" { (>= "1.16.0" & < "1.18~") | (= "dev") }
"coq" { (>= "8.17" & < "8.19~") | (= "dev") }
"coq-mathcomp-ssreflect" { (>= "1.16.0" & < "1.19~") | (= "dev") }
"coq-mathcomp-fingroup" { (>= "1.16.0" & < "1.19~") | (= "dev") }
"coq-mathcomp-algebra" { (>= "1.16.0" & < "1.19~") | (= "dev") }
"coq-mathcomp-solvable" { (>= "1.16.0" & < "1.19~") | (= "dev") }
"coq-mathcomp-field" { (>= "1.16.0" & < "1.19~") | (= "dev") }
"coq-mathcomp-analysis" { (>= "0.5.4") & (< "0.7~")}
"coq-hierarchy-builder" { >= "1.3.0" }
"coq-hierarchy-builder" { = "1.5.0" }
"coq-mathcomp-algebra-tactics" { = "1.1.1" }
]

tags: [
Expand Down
135 changes: 50 additions & 85 deletions ecc_classic/decoding.v
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
(* infotheo: information theory and error-correcting codes in Coq *)
(* Copyright (C) 2020 infotheo authors, license: LGPL-2.1-or-later *)
From mathcomp Require Import all_ssreflect ssralg fingroup finalg perm zmodp.
From mathcomp Require Import matrix vector.
Require Import Reals Lra.
From mathcomp Require Import Rstruct.
From mathcomp Require Import all_ssreflect ssralg fingroup finalg perm zmodp ssrnum.
From mathcomp Require Import matrix vector order.
From mathcomp Require Import lra Rstruct reals.
From mathcomp Require ssrnum.
Require Import Reals.
Require Import ssrR Reals_ext ssr_ext ssralg_ext Rbigop f2 fdist proba.
Require Import realType_ext.
Require Import channel_code channel binary_symmetric_channel hamming pproba.
Require Import Rstruct_ext.

(******************************************************************************)
(* The variety of decoders *)
Expand All @@ -32,7 +35,7 @@ Unset Strict Implicit.
Import Prenex Implicits.

Local Close Scope R_scope.
Import GRing.Theory.
Import GRing.Theory Num.Theory Order.Theory.
Local Open Scope ring_scope.

Definition repairT (B A : finType) n := {ffun 'rV[B]_n -> option 'rV[A]_n}.
Expand All @@ -46,7 +49,7 @@ Definition cancel_on n (F : finFieldType) (C : {vspace 'rV[F]_n}) {B} (e : B ->
forall c, c \in C -> e (s c) = c.

Lemma vspace_not_empty (F : finFieldType) n (C : {vspace 'rV[F]_n}) :
0 < #| [set cw in C] |.
(0 < #| [set cw in C] |)%nat.
Proof. apply/card_gt0P; exists 0; by rewrite inE mem0v. Qed.

Section minimum_distance_decoding.
Expand Down Expand Up @@ -95,7 +98,7 @@ Variables (F : finFieldType) (n : nat) (C : {vspace 'rV[F]_n}).
Variable (f : repairT F F n).

Definition BD_decoding t :=
forall c e, c \in C -> wH e <= t -> f (c + e) = Some c.
forall c e, c \in C -> (wH e <= t)%nat -> f (c + e) = Some c.

End bounded_distance_decoding.

Expand All @@ -105,30 +108,31 @@ Local Open Scope fdist_scope.
Local Open Scope proba_scope.
Local Open Scope channel_scope.

Local Open Scope reals_ext_scope.
Local Open Scope order_scope.

Section maximum_likelihood_decoding.

Variables (A : finFieldType) (B : finType) (W : `Ch(A, B)).
Variables (n : nat) (C : {vspace 'rV[A]_n}).
Variable f : decT B [finType of 'rV[A]_n] n.
Variable P : {fdist 'rV[A]_n}.

Local Open Scope R_scope.
Local Open Scope reals_ext_scope.

Definition ML_decoding :=
forall y : P.-receivable W,
exists x, f y = Some x /\
W ``(y | x) = \rmax_(x' in C) W ``(y | x').
W ``(y | x) = \big[Order.max/0]_(x' in C) W ``(y | x').

End maximum_likelihood_decoding.

Local Open Scope R_scope.

Section maximum_likelihood_decoding_prop.

Variables (A : finFieldType) (B : finType) (W : `Ch(A, B)).
Variables (n : nat) (C : {vspace 'rV[A]_n}).
Variable repair : decT B [finType of 'rV[A]_n] n.
Let P := fdist_uniform_supp (vspace_not_empty C).
Let P := fdist_uniform_supp real_realType (vspace_not_empty C).
Hypothesis ML_dec : ML_decoding W C repair P.

Local Open Scope channel_code_scope.
Expand All @@ -137,15 +141,13 @@ Lemma ML_err_rate x1 x2 y : repair y = Some x1 ->
x2 \in C -> W ``(y | x2) <= W ``(y | x1).
Proof.
move=> Hx1 Hx2.
case/boolP : (W ``(y | x2) == 0%R) => [/eqP -> //| Hcase].
case/boolP : (W ``(y | x2) == 0) => [/eqP -> //| Hcase].
have PWy : receivable_prop P W y.
apply/existsP; exists x2.
by rewrite Hcase andbT fdist_uniform_supp_neq0 inE.
case: (ML_dec (mkReceivable PWy)) => x' [].
rewrite /= Hx1 => -[<-] ->.
rewrite -big_filter.
apply (leR_bigmaxR (fun i => W ``(y | i))).
by rewrite mem_filter /= mem_index_enum andbT.
by apply: (le_bigmax_cond _ (fun i => W ``(y | i))).
Qed.

Variable M : finType.
Expand All @@ -154,28 +156,30 @@ Variable discard : discardT A n M.
Variable enc : encT A M n.
Hypothesis enc_img : enc @: M \subset C.
Hypothesis discard_cancel : forall y x, repair y = Some x -> enc (discard x) = x.
Let dec := [ffun x => omap discard (repair x)].

Import ssrnum.Num.Theory.

Lemma ML_smallest_err_rate phi :
let dec := [ffun x => omap discard (repair x)] in
echa(W, mkCode enc dec) <= echa(W, mkCode enc phi).
Proof.
move=> dec.
apply leR_wpmul2l; first by apply/mulR_ge0 => //; exact/invR_ge0/ltR0n.
rewrite /ErrRateCond /= [in X in _ <= X](eq_bigr
apply/RleP/leR_wpmul2l; first by apply/mulR_ge0 => //; exact/invR_ge0/ltR0n.
rewrite /ErrRateCond /=; apply/RleP.
rewrite [leRHS](eq_bigr
(fun m => 1 - Pr (W ``(|enc m)) [set tb | phi tb == Some m])); last first.
move=> m _; rewrite Pr_to_cplt; congr (_ - Pr _ _).
apply/setP => t; by rewrite !inE negbK.
rewrite [in X in X <= _](eq_bigr
rewrite [leLHS](eq_bigr
(fun m => 1 - Pr (W ``(|enc m)) [set tb | dec tb == Some m])); last first.
move => m _.
rewrite [in LHS]Pr_to_cplt; congr (_ - Pr _ _).
apply/setP => t; by rewrite !inE negbK.
rewrite 2!big_split /= leR_add2l.
rewrite -2!big_morph_oppR leR_oppr oppRK /Pr (exchange_big_dep xpredT) //=.
rewrite [in X in (_ <= X)%R](exchange_big_dep xpredT) //=.
apply leR_sumR => /= tb _.
rewrite 2!big_split /=; apply: lerD => //.
rewrite -2!big_morph_oppR lerNr opprK /Pr (exchange_big_dep xpredT) //=.
rewrite [leRHS](exchange_big_dep xpredT) //=.
apply ler_sum => /= tb _.
rewrite (eq_bigl (fun m => phi tb == Some m)); last by move=> m; rewrite inE.
rewrite [in X in _ <= X](eq_bigl (fun m => dec tb == Some m)); last by move=> m; rewrite inE.
rewrite [leRHS](eq_bigl (fun m => dec tb == Some m)); last by move=> m; rewrite inE.
(* show that phi_ML succeeds more often than phi *)
have [dectb_None|dectb_Some] := boolP (dec tb == None).
case/boolP : (receivable_prop P W tb) => [Hy|Htb].
Expand All @@ -187,14 +191,14 @@ have [dectb_None|dectb_Some] := boolP (dec tb == None).
rewrite Htb andbT fdist_uniform_supp_neq0 inE.
move/subsetP : enc_img; apply; apply/imsetP; by exists m.
rewrite (eq_bigr (fun=> 0)); last by move=> m _; rewrite W_tb.
by rewrite big1 //; apply sumR_ge0.
by rewrite big1 //; apply sumr_ge0.
case/boolP : (phi tb == None) => [/eqP ->|phi_tb].
by rewrite big_pred0 //; apply sumR_ge0.
by rewrite big_pred0 //; apply sumr_ge0.
have [m1 Hm1] : exists m', dec tb = Some m' by destruct (dec tb) => //; exists s.
have [m2 Hm2] : exists m', phi tb = Some m' by destruct (phi tb) => //; exists s.
rewrite Hm1 {}Hm2.
rewrite (eq_bigl [pred m | m == m2]); last by move=> ?; rewrite eq_sym.
rewrite [in X in _ <= X](eq_bigl [pred m | m == m1]); last by move=> ?; rewrite eq_sym.
rewrite [leRHS](eq_bigl [pred m | m == m1]); last by move=> ?; rewrite eq_sym.
rewrite 2!big_pred1_eq; apply ML_err_rate.
move: Hm1; rewrite /dec ffunE /omap /obind /oapp.
move H : (repair tb) => h.
Expand All @@ -207,47 +211,7 @@ End maximum_likelihood_decoding_prop.

Section MD_ML_decoding.

Variable p : prob.

(* TODO: move to file on bsc? *)
Lemma bsc_prob_prop n : p < 1 / 2 ->
forall n1 n2 : nat, (n1 <= n2 <= n)%nat ->
((1 - p) ^ (n - n2) * p ^ n2 <= (1 - p) ^ (n - n1) * p ^ n1)%R.
Proof.
move=> p05 d1 d2 d1d2.
case/boolP : (p == 0%:pr) => [/eqP ->|p0].
destruct d2 as [|d2].
destruct d1 as [|d1]; [exact/leRR | by []].
rewrite !subR0 /= !mul0R !mulR0.
destruct d1 as [|d1] => /=; first by rewrite exp1R mul1R.
rewrite !mul0R !mulR0; exact/leRR.
apply (@leR_pmul2l ((/ (1 - p) ^ (n - d2)) * (/ p ^ d1))%R).
apply mulR_gt0; apply/invR_gt0/pow_lt => //.
rewrite subR_gt0; lra.
by rewrite -prob_gt0.
rewrite (mulRC ((1 - p) ^ (n - d2))) -!mulRA mulRC -!mulRA mulRV; last first.
apply/expR_neq0; rewrite subR_eq0'; apply/gtR_eqF; lra.
rewrite mulR1 -(mulRC (p ^ d1)) [in X in _ <= X]mulRC !mulRA mulVR ?mul1R; last first.
by apply/expR_neq0/gtR_eqF; rewrite -prob_gt0.
rewrite -expRV; last by apply/gtR_eqF; rewrite -prob_gt0.
rewrite -expRV; last by rewrite subR_eq0'; apply/gtR_eqF; lra.
rewrite mulRC expRV; last by apply/gtR_eqF; rewrite -prob_gt0.
rewrite -/(Rdiv _ _) -expRB; last 2 first.
by case/andP : d1d2.
exact/eqP.
rewrite expRV; last first.
rewrite subR_eq0'; apply/eqP => p1.
move: p05; rewrite ltRNge; apply.
lra.
rewrite -/(Rdiv _ _) -expRB; last 2 first.
rewrite leq_sub2l //; by case/andP : d1d2.
rewrite subR_eq0 => ?.
move: p05; rewrite ltRNge; apply.
lra.
suff -> : (n - d1 - (n - d2) = d2 - d1)%nat by apply pow_incr; split => //; lra.
rewrite -subnDA addnC subnDA subKn //.
by case/andP : d1d2.
Qed.
Variable p : {prob R}.

Let card_F2 : #| 'F_2 | = 2%nat. Proof. by rewrite card_Fp. Qed.
Let W := BSC.c card_F2 p.
Expand All @@ -261,7 +225,7 @@ Variable enc : encT [finType of 'F_2] M n.
Hypothesis compatible : cancel_on C enc discard.
Variable P : {fdist 'rV['F_2]_n}.

Lemma MD_implies_ML : p < 1/2 -> MD_decoding [set cw in C] f ->
Lemma MD_implies_ML : p < 1/2 :> R-> MD_decoding [set cw in C] f ->
(forall y, f y != None) -> ML_decoding W C f P.
Proof.
move=> p05 MD f_total y.
Expand All @@ -278,7 +242,7 @@ case: oc Hoc => [c|] Hc; last first.
exists c; split; first by reflexivity.
(* replace W ``^ n (y | f c) with a closed formula because it is a BSC *)
pose dH_y c := dH y c.
pose g : nat -> R := fun d : nat => (1 - p) ^ (n - d) * p ^ d.
pose g : nat -> R := fun d : nat => ((1 - p) ^ (n - d) * p ^ d)%R.
have -> : W ``(y | c) = g (dH_y c).
move: (DMC_BSC_prop p enc (discard c) y).
set cast_card := eq_ind_r _ _ _.
Expand All @@ -287,7 +251,7 @@ have -> : W ``(y | c) = g (dH_y c).
rewrite -/W compatible //.
move/subsetP : f_img; apply.
by rewrite inE; apply/existsP; exists (receivable_rV y); apply/eqP.
transitivity (\big[Rmax/R0]_(c in C) (g (dH_y c))); last first.
transitivity (\big[Order.max/0]_(c in C) (g (dH_y c))); last first.
apply eq_bigr => /= c' Hc'.
move: (DMC_BSC_prop p enc (discard c') y).
set cast_card := eq_ind_r _ _ _.
Expand All @@ -296,10 +260,11 @@ transitivity (\big[Rmax/R0]_(c in C) (g (dH_y c))); last first.
(* the function maxed over is decreasing so we may look for its minimizer,
which is given by minimum distance decoding *)
rewrite (@bigmaxR_bigmin_vec_helper _ _ _ _ _ _ _ _ _ _ codebook_not_empty) //.
- apply eq_bigl => /= i; by rewrite inE.
- by rewrite bigmaxRE; apply eq_bigl => /= i; rewrite inE.
- by apply bsc_prob_prop.
- move=> r; rewrite /g.
apply mulR_ge0; apply pow_le => //; lra.
- move=> r; rewrite /g Prob_pE !coqRE.
apply/RleP/mulr_ge0; apply/exprn_ge0; last exact/prob_ge0.
exact/RleP/onem_ge0/RleP/prob_le1.
- rewrite inE; move/subsetP: f_img; apply.
rewrite inE; apply/existsP; by exists (receivable_rV y); apply/eqP.
- by move=> ? _; rewrite /dH_y max_dH.
Expand Down Expand Up @@ -327,14 +292,14 @@ Variables (A : finFieldType) (B : finType) (W : `Ch(A, B)).
Variables (n : nat) (C : {vspace 'rV[A]_n}).
Variable dec : decT B [finType of 'rV[A]_n] n.
Variable dec_img : oimg dec \subset C.
Let P := fdist_uniform_supp (vspace_not_empty C).
Let P := fdist_uniform_supp real_realType (vspace_not_empty C).

Lemma MAP_implies_ML : MAP_decoding W C dec P -> ML_decoding W C dec P.
Proof.
move=> HMAP.
rewrite /ML_decoding => /= tb.
have Hunpos : 1%:R / INR #| [set cw in C] | > 0.
by rewrite div1R; exact/invR_gt0/ltR0n/vspace_not_empty.
have Hunpos : (#| [set cw in C] |%:R)^-1 > 0 :> R.
by rewrite invr_gt0 ltr0n; exact/vspace_not_empty.
move: (HMAP tb) => [m [tbm]].
rewrite /fdist_post_prob. unlock. simpl.
set tmp := \rmax_(_ <- _ | _) _.
Expand All @@ -344,9 +309,7 @@ move=> H.
evar (h : 'rV[A]_n -> R); rewrite (eq_bigr h) in H; last first.
by move=> v vC; rewrite /h; reflexivity.
rewrite -bigmaxR_distrl in H; last first.
apply/invR_ge0; rewrite ltR_neqAle; split.
apply/eqP; by rewrite eq_sym -receivable_propE receivableP.
exact/fdist_post_prob_den_ge0.
by apply/RleP; rewrite invr_ge0; exact/fdist_post_prob_den_ge0.
rewrite {2 3}/P in H.
set r := index_enum _ in H.
move: H.
Expand All @@ -355,16 +318,18 @@ under [in X in _ = X -> _]eq_bigr.
rewrite fdist_uniform_supp_in; last by rewrite inE.
over.
move=> H.
rewrite -bigmaxR_distrr in H; last exact/ltRW/Hunpos.
rewrite -bigmaxR_distrr in H; last exact/RleP/ltW/Hunpos.
exists m; split; first exact tbm.
rewrite ffunE in H.
set x := (X in _ * _ / X) in H.
have x0 : / x <> 0 by apply/eqP/invR_neq0'; rewrite -receivable_propE receivableP.
have x0 : x^-1 <> 0 by apply/eqP/invr_neq0; rewrite -receivable_propE receivableP.
move/(eqR_mul2r x0) in H.
rewrite /= fdist_uniform_supp_in ?inE // in H; last first.
move/subsetP : dec_img; apply.
by rewrite inE; apply/existsP; exists (receivable_rV tb); apply/eqP.
by move/eqR_mul2l : H => -> //; exact/eqP/gtR_eqF.
move/lt0r_neq0/eqP: Hunpos.
move/eqR_mul2l : H; move/[apply] ->.
by rewrite bigmaxRE.
Qed.

End MAP_decoding_prop.
Expand Down
2 changes: 1 addition & 1 deletion ecc_classic/hamming_code.v
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ Section hamming_code_error_rate.

Variable M : finType.
Hypothesis M_not_0 : 0 < #|M|.
Variable p : prob.
Variable p : {prob R}.
Let card_F2 : #| 'F_2 | = 2%N. by rewrite card_Fp. Qed.
Let W := BSC.c card_F2 p.

Expand Down
Loading
Loading