Module infotheo.information_theory.source_code

From mathcomp Require Import all_ssreflect ssralg ssrnum matrix.
From mathcomp Require Import Rstruct reals.
Require Import realType_ln fdist proba.

# Definition of a source code ``` encT, decT == types for the source encoder and source decoder scode_fl == definition of a fixed-length source code esrc( P , sc ) == error rate of the source code sc ```

Set Implicit Arguments.
Set SsrOldRewriteGoalsOrder.
Unset Strict Implicit.
Import Prenex Implicits.

From mathcomp Require Import normedtype.
Import numFieldNormedType.Exports.

Declare Scope source_code_scope.

Section scode_definition.
Variables (A : finType) (B : Type) (k : nat).

Definition
encT

encT not a defined object.

:= 'rV[A]_k -> B.

Definition
decT

decT not a defined object.

:= B -> 'rV[A]_k.

Record scode := mkScode { enc : encT ; dec : decT }.

End scode_definition.

Local Open Scope fdist_scope.
Local Open Scope proba_scope.

Section scode_vl_definition.
Variables (R : realType) (A : finType) (k n : nat).

Definition
scode_vl

scode_vl not a defined object.

:= scode A (seq bool) k.

Variables (P : R.-fdist A) (f : {RV (P `^ n) -> seq bool}).

Definition
E_leng_cw

E_leng_cw not a defined object.

:= `E (((fun x => x%:R : R)%R \o size) `o f).

End scode_vl_definition.
Arguments E_leng_cw {R A n} _.

Section scode_fl_definition.
Variables (R : realType) (A : finType) (k n : nat).

Definition
scode_fl

scode_fl not a defined object.

:= scode A 'rV[bool]_n k.

Definition
SrcRate

SrcRate not a defined object.

(sc : scode_fl) : R := (n%:R / k%:R)%R.

End scode_fl_definition.

Section code_error_rate.
Variables (R : realType) (A : finType) (B : Type) (P : R.-fdist A).
Variables (k : nat) (sc : scode A B k).

Definition
SrcErrRate

SrcErrRate not a defined object.

:= Pr (P `^ k) [set ta | dec sc (enc sc ta) != ta].

End code_error_rate.

Notation "esrc( P , sc )" := (SrcErrRate P sc) (at level 40) : source_code_scope.

Section extension.
Variables (A : finType) (B : Type).

Definition
extension

extension not a defined object.

(f : A -> seq B) : seq A -> seq B :=
  fun a => flatten (map f a).

Definition
uniquely_decodable

uniquely_decodable not a defined object.

(f : A -> seq B):= injective (extension f).

Lemma uniq_dec_inj (f : A -> seq B) : uniquely_decodable f -> injective f.
Proof.
rewrite /uniquely_decodable/extension.
move=> f_uniq a1 a2 eq_f1_f2.
move:(f_uniq [:: a1] [:: a2]); rewrite /= !cats0.
by move=>tmp; move/tmp:eq_f1_f2=>[].
Qed.

End extension.