affeldt-aist / infotheo Goto Github PK
View Code? Open in Web Editor NEWA Coq formalization of information theory and linear error-correcting codes
License: GNU Lesser General Public License v2.1
A Coq formalization of information theory and linear error-correcting codes
License: GNU Lesser General Public License v2.1
Ubuntu 20.04.2 LTS
Release: 20.04
opam --version
2.0.5
coqc --version
The Coq Proof Assistant, version 8.13.1 (March 2021)
compiled on Mar 8 2021 11:40:26 with OCaml 4.08.1
opam list mathcomp
Name Installed Synopsis
coq-mathcomp-algebra 1.12.0 Mathematical Components Library on Algebra
coq-mathcomp-analysis 0.3.6 An analysis library for mathematical components
coq-mathcomp-bigenough 1.0.0 A small library to do epsilon - N reasonning
coq-mathcomp-field 1.12.0 Mathematical Components Library on Fields
coq-mathcomp-fingroup 1.12.0 Mathematical Components Library on finite groups
coq-mathcomp-finmap 1.5.1 Finite sets, finite maps, finitely supported functions
coq-mathcomp-solvable 1.12.0 Mathematical Components Library on finite groups (II)
coq-mathcomp-ssreflect 1.12.0 Small Scale Reflection
Running:
git clone https://github.com/affeldt-aist/infotheo.git
cd infotheo
make
Outputs:
make -f Makefile.coq all
make[1]: Entering directory '/home/user/Documents/infotheo'
COQC lib/ssrR.v
File "./lib/ssrR.v", line 5, characters 29-36:
Error: Unable to locate library Rstruct with prefix mathcomp.
make[2]: *** [Makefile.coq:720: lib/ssrR.vo] Error 1
make[1]: *** [Makefile.coq:343: all] Error 2
make[1]: Leaving directory '/home/user/Documents/infotheo'
make: *** [Makefile:2: all] Error 2
Could anyone help to figure out and solve the issue?
As discussed in coq/opam#1003, it's usually a good idea to have a top-level Makefile
that issues the critical coq_makefile
command for a build. The main advantage is that users (and other build systems such as OPAM and Nix) need only issue make
to build the project from scratch - and one can even change to another build approach based on, say, dune, without changing this build command.
The typical Coq project top-level Makefile currently looks as follows:
all: Makefile.coq
+$(MAKE) -f Makefile.coq all
clean: Makefile.coq
+$(MAKE) -f Makefile.coq cleanall
rm -f Makefile.coq Makefile.coq.conf
Makefile.coq: _CoqProject
coq_makefile -f _CoqProject -o Makefile.coq
_CoqProject Makefile: ;
%: Makefile.coq
+$(MAKE) -f Makefile.coq $@
.PHONY: all clean
Note that this mostly just defers actions to the makefile generated by coq_makefile
.
If this sounds like a good idea, I can make a pull request.
Line 73 in ee75502
Because of this conflict, these two files cannot be imported at the same time.
infotheo/lib/classical_sets_ext.v
Line 32 in 9c353b6
infotheo/probability/convex_choice.v
Line 1849 in ec432de
TODO: b \in X
-> b \in B
, etc.
Lines 1626 to 1669 in d17cdb2
Lines 2561 to 2570 in 8a67187
get rid of the big_enumP warnings that will become error with the next MathComp release
Dear infotheo authors, I want to point out that my co-authors and I have a paper on the formalization of bounds on the trimmed mean algorithm that uses infotheo. It has been accepted at PPDP this year (https://ppdp2021.github.io/#accepted, the paper is called "Trimming Data Sets: a Verified Algorithm for Robust Mean Estimation", soon to be available) and you can find the source code of the formalization here: https://github.com/ieva-itu/robustmean/blob/main/robustmean.v
We are thankful for the all the development of probability theory that we used in our paper, and we think you might appreciate some lemmas that should belong to infotheo more than our development.
As we are all novice Coq programmers and not used to the mathcomp style, I'd appreciate if you could take a look at the code and see whether you're interested in integrating it here, and maybe help us match the style of the infotheo package. This is also why I'm not making a pull request yet.
Line 1100 in 1c69630
it has been merged into MathComp-Analysis
Rstruct.R_eqType and ssrR.R_eqType
Lemma eqRstruct_eqR (m n : R) : (m == n :> Rstruct.R_eqType) = (m == n :> ssrR.R_eqType).
Proof.
Fail reflexivity.
case/boolP: (m == n).
by move/eqP ->; rewrite eqxx.
by move/eqP=> H; apply esym; rewrite -/(is_true _); apply/eqP.
Qed.
Line 470 in 2d094fb
should be subR_le0
I tried to build infotheo using make
:
COQC ecc_modern/ldpc_algo.v
File "./ecc_modern/ldpc_algo.v", line 175, characters 0-76:
Error: ConstructiveCauchyReals.CReal is not an inductive type.
infotheo/probability/convex_choice.v
Line 1942 in de84071
mulRV : forall x : R, x != 0 -> x * / x = 1
invRM : forall r1 r2 : R, r1 <> 0 -> r2 <> 0 -> / (r1 * r2) = / r1 * / r2
The following expression fails to be parsed after importing both proba.v (infotheo) and probability.v (mathcomp-analysis):
Local Open Scope form_scope.
Variables (d : measure_display) (T : measurableType d) (R : realType) (P : probability T R).
Variable (X : {RV P >-> R}).
>>> Error: Syntax error: '->' expected after [term] (in [term]).
A similar reserved notation in proba.v seems to be confusing the parser:
Reserved Notation "{ 'RV' d -> T }" (at level 0, d, T at next level,
format "{ 'RV' d -> T }").
I experienced this issue when trying to use prob_lt0
. The lemma takes as its argument _ : p != 0
and it did not match my goal because of a mismatch between two eqType
structures.
One solution would be to change the interface of prob
to
Module Prob.
Record t := mk_ {
p :> R ;
Op1 : (0 <b= p <b= 1)%R }.
Definition O1 (p : t) : 0 <= p <= 1 :=
match andP (Op1 p) with conj Op p1 => conj (leRP _ _ Op) (leRP _ _ p1) end.
Arguments O1 : simpl never.
Definition mk (q : R) (Oq1 : 0 <= q <= 1) : t.
Proof.
refine (@mk_ q (match Oq1 with conj Oq q1 => _ end)).
by move/leRP: Oq ->; move/leRP: q1 ->.
Defined.
Module Exports.
Notation prob := t.
Notation "q %:pr" := (@mk q (@O1 _)).
Canonical prob_subType := Eval hnf in [subType for p].
Definition prob_eqMixin := [eqMixin of prob by <:].
Canonical prob_eqType := Eval hnf in EqType _ prob_eqMixin.
End Exports.
End Prob.
Export Prob.Exports.
Coercion Prob.p : prob >-> R.
This seems to almost work, but failing at inferring the canonical structure for onem.
Hi!
I am excited to see a formal proof lib for information theory!
If I manage to find the time, I will try to apply it to some proofs about multi-user identification.
Therefore I nixified this: https://github.com/jorsn/infotheo/tree/nixify.
The most recent build from there is also cached in my cachix cache (run cachix use jorsn
).
If you are interested in using nix, I can create a PR and perhaps write a usage note for the README.
If not, feel free to close this issue.
Whether I can maintain the nix stuff (and add it to nixpkgs) depends on whether I will expect to really use it for longer.
ltR_subl_addr: forall x y z : R, x - y < z <-> x < z + y
ltr_subl_addl: forall x y z : R, x - y < z <-> x < y + z
fdists are currently defined over the R type of the standard library. Some developments would like to rely on this library but use structures from the mathcomp library. So we would like to have them generalized (maybe to numFieldType).
Line 760 in 864db9a
"op" should not appear in the lemma name, there are other instance of this problem in this file
Lines 2458 to 2465 in 8231da9
it looks like this lemma should better be in MathComp-Analysis' classical_sets.v
file
Line 8 in 56a667c
this should be cleaned and PRed to MathComp...
Line 308 in 9c353b6
also fix notation?
Lemma intRD (n m : nat) : (n + m)%:Z = (n%:Z + m%:Z)%Z.
Proof. exact: Nat2Z.inj_add. Qed.
Lemma leZ0n (n : nat) : (0 <= n%:Z)%Z.
Proof. exact: Zle_0_nat. Qed.
The definitions of conv_set
and the convex operation for necset_convType
are essentially the same.
We should prepare more lemmas for conv_set
and make necset_convType
rely on them.
(I'm working on this issue in conv_set branch.)
We are missing the following: definition of multiplication of random variables and ring structure for RVs.
Definition mul_RV (U : finType) (P : {fdist U}) (X Y : {RV P -> R}) : {RV P -> R} := fun x => X x * Y x.
Notation "X `* Y" := (mul_RV X Y) : proba_scope.
Arguments mul_RV /.
and
Section RV_ring.
Variables (U : finType) (P : fdist U).
Import topology.
Import GRing.Theory.
Lemma add_RV_addr (X Y : {RV P -> R}) : X `+ Y = (X + Y)%ring.
Proof. reflexivity. Qed.
Lemma sub_RV_subr (X Y : {RV P -> R}) : X `- Y = (X - Y)%ring.
Proof. reflexivity. Qed.
Lemma trans_min_RV_subr (X : {RV P -> R}) (y : R) :
X `-cst y = (X - cst y)%ring.
Proof. reflexivity. Qed.
Definition fdist_supp_choice : U.
by move/set0Pn/xchoose:(fdist_supp_neq0 P).
Defined.
Canonical fdist_supp_pointedType :=
@classical_sets.Pointed.pack U fdist_supp_choice _ _ idfun.
Lemma mul_RV_mulr (X Y : {RV P -> R}) : X `* Y = (X * Y)%ring.
Proof. reflexivity. Qed.
Lemma sq_RV_sqrr (X : {RV P -> R}) : X `^2 = (X ^+ 2)%ring.
Proof. by rewrite /sq_RV/comp_RV; apply boolp.funext => u /=; rewrite mulR1. Qed.
Definition RV_ringE :=
(add_RV_addr, sub_RV_subr, trans_min_RV_subr, mul_RV_mulr, sq_RV_sqrr).
End RV_ring.
Ubuntu 20.04.2 LTS
Release: 20.04
opam --version
2.0.5
coqc --version
The Coq Proof Assistant, version 8.13.1 (March 2021)
compiled on Mar 8 2021 11:40:26 with OCaml 4.08.1
opam list mathcomp
Name Installed Synopsis
coq-mathcomp-algebra 1.12.0 Mathematical Components Library on Algebra
coq-mathcomp-analysis 0.3.6 An analysis library for mathematical components
coq-mathcomp-bigenough 1.0.0 A small library to do epsilon - N reasonning
coq-mathcomp-field 1.12.0 Mathematical Components Library on Fields
coq-mathcomp-fingroup 1.12.0 Mathematical Components Library on finite groups
coq-mathcomp-finmap 1.5.1 Finite sets, finite maps, finitely supported functions
coq-mathcomp-solvable 1.12.0 Mathematical Components Library on finite groups (II)
coq-mathcomp-ssreflect 1.12.0 Small Scale Reflection
Running:
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq-infotheo
Outputs:
``
The following actions will be performed:
∗ install coq-infotheo 0.3.1
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[coq-infotheo.0.3.1] found in cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of coq-infotheo failed at "/home/user/.opam/opam-init/hooks/sandbox.sh build make -j1".
#=== ERROR while compiling coq-infotheo.0.3.1 =================================#
# context 2.0.5 | linux/x86_64 | ocaml-base-compiler.4.11.1 | https://coq.inria.fr/opam/released#2021-03-22 11:00
# path ~/.opam/with-coq/.opam-switch/build/coq-infotheo.0.3.1
# command ~/.opam/opam-init/hooks/sandbox.sh build make -j1
# exit-code 2
# env-file ~/.opam/log/coq-infotheo-51929-d2c37b.env
# output-file ~/.opam/log/coq-infotheo-51929-d2c37b.out
### output ###
# [...]
# Warning: filter_index_enum is deprecated; use big_enumP instead
# Warning: filter_index_enum is deprecated; use big_enumP instead
# Warning: filter_index_enum is deprecated; use big_enumP instead
# COQC toy_examples/expected_value_variance.v
# COQC toy_examples/expected_value_variance_ordn.v
# COQC toy_examples/expected_value_variance_tuple.v
# COQC toy_examples/conditional_entropy.v
# Killed
# make[2]: *** [Makefile.coq:720: toy_examples/conditional_entropy.vo] Error 137
# make[1]: *** [Makefile.coq:343: all] Error 2
# make[1]: Leaving directory '/home/user/.opam/with-coq/.opam-switch/build/coq-infotheo.0.3.1'
# make: *** [Makefile:2: all] Error 2
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build coq-infotheo 0.3.1
└─
╶─ No changes have been performed
# Run eval $(opam env) to update the current shell environment
``
Could anyone help to figure out and solve the issue?
mention that make is actually gmake in the readme
Prob.ge0
should be placed outside Module Prob
and named prob_ge0
.
rename convex_choice.v
to convex.v
@t6s
Line 79 in 56a667c
Line 72 in 2911b1f
is lacking a space to print correctly
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.