diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate_docs.yml index cef459a3c..e76a4fdf7 100644 --- a/.github/workflows/generate_docs.yml +++ b/.github/workflows/generate_docs.yml @@ -23,25 +23,28 @@ jobs: branch_name=${{ github.head_ref }} echo "destination_dir=mathcomp-analysis_$branch_name" >> $GITHUB_ENV + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v2 + - name: Set-up OCaml uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: 4.14 opam-repositories: | - coq-extra-dev: https://coq.inria.fr/opam/extra-dev coq-released: https://coq.inria.fr/opam/released default: https://github.com/ocaml/opam-repository.git - name: Build Mathcomp Analysis run: opam install -y --deps-only . && opam exec -- make -j 4 - - name: Build coq2html - run: opam install -y coq-rocqnavi && opam show coq-rocqnavi + - name: Install Rocqnavi + run: opam install -y rocq-navi - name: Generate Documents run: | - mkdir -p artifact/${{ env.destination_dir }} - opam exec -- coq2html -title "Mathcomp Analysis" -d artifact/${{ env.destination_dir }} -base mathcomp -Q theories analysis -coqlib https://coq.inria.fr/doc/V8.18.0/stdlib/ -external https://math-comp.github.io/htmldoc_2_1_0/ mathcomp.ssreflect -external https://math-comp.github.io/htmldoc_2_1_0/ mathcomp.algebra classical/*.glob classical/*.v theories/*.glob theories/*.v + mkdir -p artifact + opam exec -- make html + cp -r html artifact/${{ env.destination_dir }} - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/nix-action-8.19.yml b/.github/workflows/nix-action-8.19.yml deleted file mode 100644 index 099228313..000000000 --- a/.github/workflows/nix-action-8.19.yml +++ /dev/null @@ -1,755 +0,0 @@ -jobs: - coq: - needs: [] - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (coq) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"coq\" \\\n --dry-run 2> err > out || (touch fail; - true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - mathcomp: - needs: - - coq - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-fingroup' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-fingroup" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-solvable' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-solvable" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-character' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-character" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp" - mathcomp-analysis: - needs: - - coq - - mathcomp-reals - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-analysis) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-analysis\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-analysis" - mathcomp-analysis-single: - needs: - - coq - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-analysis-single) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-analysis-single\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-finmap' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-analysis-single" - mathcomp-analysis-stdlib: - needs: - - coq - - mathcomp-analysis - - mathcomp-reals-stdlib - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-analysis-stdlib) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-analysis-stdlib\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-analysis' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals-stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-reals-stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-analysis-stdlib" - mathcomp-classical: - needs: - - coq - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-classical) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-classical\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-finmap' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-classical" - mathcomp-experimental-reals: - needs: - - coq - - mathcomp-reals - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-experimental-reals) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-experimental-reals\" \\\n --dry-run 2> - err > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-experimental-reals" - mathcomp-reals: - needs: - - coq - - mathcomp-classical - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-reals) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-reals\" \\\n --dry-run 2> err > out || - (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-classical' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-classical" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-reals" - mathcomp-reals-stdlib: - needs: - - coq - - mathcomp-reals - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-reals-stdlib) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"mathcomp-reals-stdlib\" \\\n --dry-run 2> err > - out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-reals-stdlib" - ssprove: - needs: - - coq - - mathcomp-analysis - - mathcomp-experimental-reals - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (ssprove) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"8.19\" --argstr job \"ssprove\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: equations' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "equations" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-analysis' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-experimental-reals' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "mathcomp-experimental-reals" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: extructures' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "extructures" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: deriving' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "deriving" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.19" --argstr - job "ssprove" -name: Nix CI for bundle 8.19 -on: - pull_request: - paths: - - .github/workflows/nix-action-8.19.yml - pull_request_target: - paths-ignore: - - .github/workflows/nix-action-8.19.yml - types: - - opened - - synchronize - - reopened - push: - branches: - - master diff --git a/.github/workflows/nix-action-8.20.yml b/.github/workflows/nix-action-8.20.yml index d7c23b1bc..7525dfc60 100644 --- a/.github/workflows/nix-action-8.20.yml +++ b/.github/workflows/nix-action-8.20.yml @@ -27,11 +27,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -40,15 +40,16 @@ jobs: name: Getting derivation for current job (coq) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"coq\" \\\n --dry-run 2> err > out || (touch fail; - true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" @@ -81,11 +82,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -94,47 +95,28 @@ jobs: name: Getting derivation for current job (mathcomp) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr - job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-fingroup' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr - job "mathcomp-fingroup" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr - job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-solvable' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr - job "mathcomp-solvable" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr - job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-character' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-character" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp" @@ -168,11 +150,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -181,35 +163,36 @@ jobs: name: Getting derivation for current job (mathcomp-analysis) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-analysis\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-field' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-analysis" @@ -242,11 +225,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -255,47 +238,52 @@ jobs: name: Getting derivation for current job (mathcomp-analysis-single) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-analysis-single\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-ssreflect' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr + job "mathcomp-ssreflect" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-algebra' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-finmap' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-field' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-analysis-single" @@ -330,11 +318,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -343,35 +331,36 @@ jobs: name: Getting derivation for current job (mathcomp-analysis-stdlib) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-analysis-stdlib\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-analysis' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals-stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-reals-stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-analysis-stdlib" @@ -404,11 +393,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -417,31 +406,36 @@ jobs: name: Getting derivation for current job (mathcomp-classical) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-classical\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-ssreflect' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr + job "mathcomp-ssreflect" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-algebra' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-finmap' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-classical" @@ -475,11 +469,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -488,31 +482,32 @@ jobs: name: Getting derivation for current job (mathcomp-experimental-reals) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-experimental-reals\" \\\n --dry-run 2> - err > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + err > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"\ + Error: getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-experimental-reals" @@ -546,11 +541,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -559,27 +554,28 @@ jobs: name: Getting derivation for current job (mathcomp-reals) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-reals\" \\\n --dry-run 2> err > out || - (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-classical' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-classical" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-reals" @@ -613,11 +609,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -626,31 +622,32 @@ jobs: name: Getting derivation for current job (mathcomp-reals-stdlib) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"mathcomp-reals-stdlib\" \\\n --dry-run 2> err > - out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-reals-stdlib" @@ -685,11 +682,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -698,43 +695,48 @@ jobs: name: Getting derivation for current job (ssprove) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"8.20\" --argstr job \"ssprove\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: equations' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "equations" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-boot' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr - job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' + job "mathcomp-boot" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-analysis' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-experimental-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "mathcomp-experimental-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: extructures' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "extructures" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: deriving' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "deriving" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-word' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr + job "mathcomp-word" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.20" --argstr job "ssprove" diff --git a/.github/workflows/nix-action-9.0.yml b/.github/workflows/nix-action-9.0.yml index ed7e7ec60..c8d838127 100644 --- a/.github/workflows/nix-action-9.0.yml +++ b/.github/workflows/nix-action-9.0.yml @@ -27,11 +27,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -40,108 +40,19 @@ jobs: name: Getting derivation for current job (coq) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"coq\" \\\n --dry-run 2> err > out || (touch fail; - true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - mathcomp: - needs: - - coq - runs-on: ubuntu-latest - steps: - - name: Determine which commit to initially checkout - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"target_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n echo \"target_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.target_commit }} - - name: Determine which commit to test - run: "if [ ${{ github.event_name }} = \"push\" ]; then\n echo \"tested_commit=${{ - github.sha }}\" >> $GITHUB_ENV\nelse\n merge_commit=$(git ls-remote ${{ github.event.repository.html_url - }} refs/pull/${{ github.event.number }}/merge | cut -f1)\n mergeable=$(git - merge --no-commit --no-ff ${{ github.event.pull_request.base.sha }} > /dev/null - 2>&1; echo $?; git merge --abort > /dev/null 2>&1 || true)\n if [ -z \"$merge_commit\"\ - \ -o \"x$mergeable\" != \"x0\" ]; then\n echo \"tested_commit=${{ github.event.pull_request.head.sha - }}\" >> $GITHUB_ENV\n else\n echo \"tested_commit=$merge_commit\" >> $GITHUB_ENV\n\ - \ fi\nfi\n" - - name: Git checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v30 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepGetDerivation - name: Getting derivation for current job (mathcomp) - run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"9.0\" --argstr job \"mathcomp\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; - - id: stepCheck - name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-fingroup' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-fingroup" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-solvable' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-solvable" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-character' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-character" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp" mathcomp-analysis: needs: - coq @@ -172,11 +83,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -185,35 +96,36 @@ jobs: name: Getting derivation for current job (mathcomp-analysis) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-analysis\" \\\n --dry-run 2> err > out || - (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-field' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-analysis" @@ -246,11 +158,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -259,47 +171,52 @@ jobs: name: Getting derivation for current job (mathcomp-analysis-single) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-analysis-single\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-ssreflect' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr + job "mathcomp-ssreflect" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-algebra' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-finmap' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-field' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-analysis-single" @@ -334,11 +251,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -347,35 +264,36 @@ jobs: name: Getting derivation for current job (mathcomp-analysis-stdlib) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-analysis-stdlib\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-analysis' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals-stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-reals-stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-analysis-stdlib" @@ -408,11 +326,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -421,31 +339,36 @@ jobs: name: Getting derivation for current job (mathcomp-classical) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-classical\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-ssreflect' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr + job "mathcomp-ssreflect" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-algebra' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-finmap' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-classical" @@ -479,11 +402,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -492,31 +415,32 @@ jobs: name: Getting derivation for current job (mathcomp-experimental-reals) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-experimental-reals\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-experimental-reals" @@ -550,11 +474,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -563,27 +487,28 @@ jobs: name: Getting derivation for current job (mathcomp-reals) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-reals\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-classical' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-classical" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-reals" @@ -617,11 +542,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -630,31 +555,32 @@ jobs: name: Getting derivation for current job (mathcomp-reals-stdlib) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"mathcomp-reals-stdlib\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: stdlib' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-reals-stdlib" @@ -689,11 +615,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -702,43 +628,48 @@ jobs: name: Getting derivation for current job (ssprove) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"9.0\" --argstr job \"ssprove\" \\\n --dry-run 2> err > out || (touch fail; - true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: equations' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "equations" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-boot' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr - job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' + job "mathcomp-boot" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-analysis' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-experimental-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "mathcomp-experimental-reals" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: extructures' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "extructures" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: deriving' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "deriving" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-word' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr + job "mathcomp-word" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "9.0" --argstr job "ssprove" diff --git a/.github/workflows/nix-action-master.yml b/.github/workflows/nix-action-master.yml index f32b28349..5c94b84c9 100644 --- a/.github/workflows/nix-action-master.yml +++ b/.github/workflows/nix-action-master.yml @@ -27,11 +27,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -40,15 +40,16 @@ jobs: name: Getting derivation for current job (coq) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"master\" --argstr job \"coq\" \\\n --dry-run 2> err > out || (touch fail; - true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" @@ -81,11 +82,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -94,19 +95,20 @@ jobs: name: Getting derivation for current job (coq-elpi) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"master\" --argstr job \"coq-elpi\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq-elpi" @@ -140,11 +142,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -153,23 +155,24 @@ jobs: name: Getting derivation for current job (hierarchy-builder) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"master\" --argstr job \"hierarchy-builder\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq-elpi' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq-elpi" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "hierarchy-builder" @@ -203,11 +206,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -216,55 +219,38 @@ jobs: name: Getting derivation for current job (mathcomp) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"master\" --argstr job \"mathcomp\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-fingroup' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-fingroup" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-solvable' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-solvable" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-character' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "mathcomp-character" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "mathcomp" - mathcomp-analysis: + mathcomp-analysis-single: needs: - coq - - mathcomp-reals + - mathcomp-finmap + - mathcomp-bigenough - mathcomp-bigenough + - stdlib - hierarchy-builder runs-on: ubuntu-latest steps: @@ -292,59 +278,71 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-analysis) + name: Getting derivation for current job (mathcomp-analysis-single) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-analysis\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-analysis-single\" \\\n --dry-run 2> err + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-ssreflect' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' + --argstr job "mathcomp-ssreflect" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-algebra' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "mathcomp-algebra" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-finmap' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "mathcomp-finmap" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-bigenough' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "mathcomp-bigenough" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-field' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: stdlib' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "stdlib" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-analysis" - mathcomp-analysis-single: + --argstr job "mathcomp-analysis-single" + mathcomp-bigenough: needs: - coq - - mathcomp-finmap - - mathcomp-bigenough - - mathcomp-bigenough - - stdlib - - hierarchy-builder runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -371,69 +369,44 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-analysis-single) + name: Getting derivation for current job (mathcomp-bigenough) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-analysis-single\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-bigenough\" \\\n --dry-run 2> err > out + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-finmap' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-boot' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-field' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-field" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + --argstr job "mathcomp-boot" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-analysis-single" - mathcomp-analysis-stdlib: + --argstr job "mathcomp-bigenough" + mathcomp-classical: needs: - coq - - mathcomp-analysis - - mathcomp-reals-stdlib - - stdlib + - mathcomp-finmap - hierarchy-builder runs-on: ubuntu-latest steps: @@ -461,54 +434,58 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-analysis-stdlib) + name: Getting derivation for current job (mathcomp-classical) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-analysis-stdlib\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-classical\" \\\n --dry-run 2> err > out + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-analysis' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-ssreflect' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-analysis" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals-stdlib' + --argstr job "mathcomp-ssreflect" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-algebra' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-reals-stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' + --argstr job "mathcomp-algebra" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-finmap' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' + --argstr job "mathcomp-finmap" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-analysis-stdlib" - mathcomp-bigenough: + --argstr job "mathcomp-classical" + mathcomp-experimental-reals: needs: - coq + - mathcomp-reals + - mathcomp-bigenough + - hierarchy-builder runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -535,44 +512,51 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-bigenough) + name: Getting derivation for current job (mathcomp-experimental-reals) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-bigenough\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-experimental-reals\" \\\n --dry-run 2> + err > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"\ + Error: getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' - name: Building/fetching current CI target + --argstr job "mathcomp-reals" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-bigenough' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "mathcomp-bigenough" - mathcomp-classical: + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: hierarchy-builder' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "hierarchy-builder" + - if: steps.stepCheck.outputs.status != 'fetched' + name: Building/fetching current CI target + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "mathcomp-experimental-reals" + mathcomp-finmap: needs: - coq - - mathcomp-finmap - - hierarchy-builder runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -599,52 +583,44 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-classical) + name: Getting derivation for current job (mathcomp-finmap) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-classical\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-finmap\" \\\n --dry-run 2> err > out + || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-algebra' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-boot' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-algebra" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-finmap' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-finmap" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + --argstr job "mathcomp-boot" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-classical" - mathcomp-experimental-reals: + --argstr job "mathcomp-finmap" + mathcomp-reals: needs: - coq - - mathcomp-reals - - mathcomp-bigenough + - mathcomp-classical - hierarchy-builder runs-on: ubuntu-latest steps: @@ -672,50 +648,50 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-experimental-reals) + name: Getting derivation for current job (mathcomp-reals) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-experimental-reals\" \\\n --dry-run 2> - err > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-reals\" \\\n --dry-run 2> err > out || + (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting + derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-bigenough' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-classical' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-bigenough" - - if: steps.stepCheck.outputs.status == 'built' + --argstr job "mathcomp-classical" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: hierarchy-builder' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-experimental-reals" - mathcomp-finmap: + --argstr job "mathcomp-reals" + mathcomp-reals-stdlib: needs: - coq + - mathcomp-reals + - stdlib + - hierarchy-builder runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -742,44 +718,50 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-finmap) + name: Getting derivation for current job (mathcomp-reals-stdlib) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-finmap\" \\\n --dry-run 2> err > out - || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"mathcomp-reals-stdlib\" \\\n --dry-run 2> err + > out || (touch fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: + getting derivation failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-ssreflect' + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: mathcomp-reals' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-ssreflect" - - if: steps.stepCheck.outputs.status == 'built' + --argstr job "mathcomp-reals" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: stdlib' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "stdlib" + - if: steps.stepCheck.outputs.status != 'fetched' + name: 'Building/fetching previous CI target: hierarchy-builder' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" + --argstr job "hierarchy-builder" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-finmap" - mathcomp-reals: - needs: - - coq - - mathcomp-classical - - hierarchy-builder + --argstr job "mathcomp-reals-stdlib" + rocq-core: + needs: [] runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -806,49 +788,34 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-reals) + name: Getting derivation for current job (rocq-core) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-reals\" \\\n --dry-run 2> err > out || - (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"rocq-core\" \\\n --dry-run 2> err > out || (touch + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-classical' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-classical" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-reals" - mathcomp-reals-stdlib: - needs: - - coq - - mathcomp-reals - - stdlib - - hierarchy-builder + --argstr job "rocq-core" + rocq-elpi: + needs: [] runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -875,47 +842,32 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community name: math-comp - id: stepGetDerivation - name: Getting derivation for current job (mathcomp-reals-stdlib) + name: Getting derivation for current job (rocq-elpi) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle - \"master\" --argstr job \"mathcomp-reals-stdlib\" \\\n --dry-run 2> err - > out || (touch fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + \"master\" --argstr job \"rocq-elpi\" \\\n --dry-run 2> err > out || (touch + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: coq' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: mathcomp-reals' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-reals" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: stdlib' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "stdlib" - - if: steps.stepCheck.outputs.status == 'built' - name: 'Building/fetching previous CI target: hierarchy-builder' - run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "hierarchy-builder" - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" - --argstr job "mathcomp-reals-stdlib" + --argstr job "rocq-elpi" stdlib: needs: - coq @@ -945,11 +897,11 @@ jobs: fetch-depth: 0 ref: ${{ env.tested_commit }} - name: Cachix install - uses: cachix/install-nix-action@v30 + uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixpkgs-unstable - name: Cachix setup math-comp - uses: cachix/cachix-action@v15 + uses: cachix/cachix-action@v16 with: authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} extraPullNames: coq, coq-community @@ -958,19 +910,20 @@ jobs: name: Getting derivation for current job (stdlib) run: "NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr bundle \"master\" --argstr job \"stdlib\" \\\n --dry-run 2> err > out || (touch - fail; true)\n" - - name: Error reporting - run: "echo \"out=\"; cat out\necho \"err=\"; cat err\n" - - name: Failure check - run: if [ -e fail ]; then exit 1; else exit 0; fi; + fail; true)\ncat out err\nif [ -e fail ]; then echo \"Error: getting derivation + failed\"; exit 1; fi\n" - id: stepCheck name: Checking presence of CI target for current job - run: (echo -n status=; cat out err | grep "built:" | sed "s/.*/built/") >> $GITHUB_OUTPUT - - if: steps.stepCheck.outputs.status == 'built' + run: "if $(cat out err | grep -q \"built:\") ; then\n echo \"CI target needs + actual building\"\n if $(cat out err | grep -q \"derivations will be built:\"\ + ) ; then\n echo \"waiting a bit for derivations that should be in cache\"\ + \n sleep 30\n fi\nelse\n echo \"CI target already built\"\n echo \"\ + status=fetched\" >> $GITHUB_OUTPUT\nfi\n" + - if: steps.stepCheck.outputs.status != 'fetched' name: 'Building/fetching previous CI target: coq' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "coq" - - if: steps.stepCheck.outputs.status == 'built' + - if: steps.stepCheck.outputs.status != 'fetched' name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" --argstr job "stdlib" diff --git a/.gitignore b/.gitignore index 6eeb1c7a7..ac8865cd8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ Makefile.coq Makefile.coq.conf + +html/ diff --git a/.nix/config.nix b/.nix/config.nix index 1dbcc48de..c4a555866 100644 --- a/.nix/config.nix +++ b/.nix/config.nix @@ -48,10 +48,6 @@ in ## alternative configuration ## When generating GitHub Action CI, one workflow file ## will be created per bundle - bundles."8.19".coqPackages = common-bundle // { - coq.override.version = "8.19"; - mathcomp.override.version = "2.2.0"; - }; bundles."8.20".coqPackages = common-bundle // { coq.override.version = "8.20"; @@ -60,7 +56,6 @@ in bundles."9.0".coqPackages = common-bundle // { coq.override.version = "9.0"; - mathcomp.override.version = "2.3.0"; }; bundles."master" = { rocqPackages = { @@ -68,6 +63,8 @@ in stdlib.override.version = "master"; rocq-elpi.override.version = "master"; rocq-elpi.override.elpi-version = "2.0.7"; + mathcomp-analysis.job = false; # current bug in coq-nix-toolbox + mathcomp-analysis-stdlib.job = false; }; coqPackages = common-bundle // { coq.override.version = "master"; stdlib.override.version = "master"; diff --git a/.nix/coq-nix-toolbox.nix b/.nix/coq-nix-toolbox.nix index 8cfef937a..17666c57c 100644 --- a/.nix/coq-nix-toolbox.nix +++ b/.nix/coq-nix-toolbox.nix @@ -1 +1 @@ -"36b6af97e5de62782c4cc0dfdda3a40e64d668ad" +"52aaa743836510268bf94deb898de0f8bd0501be" diff --git a/AUTHORS.md b/AUTHORS.md index 1c3dc7413..e91b2bd42 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -8,7 +8,7 @@ - Assia Mahboubi, Inria, initial author - Damien Rouhling, when at Inria, initial author - Pierre Roux, Onera -- Kazuhiko Sakaguchi, University of Tsukuba -> Inria -> CNRS, Inria, ENS de Lyon, UCBL, LIP +- Kazuhiko Sakaguchi, Inria -> CNRS, ENS de Lyon, UCBL, LIP - Zachary Stone, - Pierre-Yves Strub, when at École polytechnique, initial author - Laurent Théry, Inria diff --git a/CHANGELOG.md b/CHANGELOG.md index b781bc463..bc6e0fe77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,159 @@ # Changelog -Latest releases: [[1.10.0] - 2025-04-21](#1100---2025-04-21), [[1.9.0] - 2025-02-20](#190---2025-02-20), and [[1.8.0] - 2024-12-19](#180---2024-12-19) +Latest releases: [[1.11.0] - 2025-05-02](#1110---2025-05-02), [[1.10.0] - 2025-04-21](#1100---2025-04-21), and [[1.9.0] - 2025-02-20](#190---2025-02-20) + +## [1.11.0] - 2025-05-02 + +### Added + +- in `unstable.v`: + + lemmas `eq_exists2l`, `eq_exists2r` + + module `ProperNotations` with notations `++>`, `==>`, `~~>` + +- in `mathcomp_extra.v`: + + lemmas `inr_inj`, `inl_inj` + +- in `boolp.v`: + + lemmas `orW`, `or3W`, `or4W` + +- in `classical_sets.v`: + + lemmas `in_set1`, `inr_in_set_inr`, `inl_in_set_inr`, `mem_image`, `mem_range`, `image_f` + + lemmas `inr_in_set_inl`, `inl_in_set_inl` + + lemmas `set_cst`, `image_nonempty` + +- in `functions.v`: + + lemma `natmulfctE` + +- in `constructive_ereal.v`: + + lemma `EFin_bigmax` + + lemmas `expe_ge0`, `expe_eq0`, `expe_gt0` + +- in `ereal.v`: + + lemmas `ereal_infEN`, `ereal_supN`, `ereal_infN`, `ereal_supEN` + + lemmas `ereal_supP`, `ereal_infP`, `ereal_sup_gtP`, `ereal_inf_ltP`, + `ereal_inf_leP`, `ereal_sup_geP`, `lb_ereal_infNy_adherent`, + `ereal_sup_real`, `ereal_inf_real` + + lemmas `ereal_sup_cst`, `ereal_inf_cst`, + `ereal_sup_pZl`, `ereal_supZl`, `ereal_inf_pZl`, `ereal_infZl` + +- in `sequences.v`: + + lemmas `ereal_inf_seq`, `ereal_sup_seq` + +- in `realfun.v`: + + lemma `cvge_ninftyP` + +- in `exp.v`: + + lemma `poweRE` + + lemmas `lnNy`, `powR_cvg0`, `derivable_powR`, `powR_derive1` + + Instance `is_derive1_powR` + +- in `measure.v`: + + lemmas `mnormalize_id`, `measurable_fun_eqP` + +- in `lebesgue_integral_approximation.v` (now `measurable_fun_approximation.v`): + + lemma `measurable_prod` + + lemma `measurable_fun_lte` + + lemma `measurable_fun_lee` + + lemma `measurable_fun_eqe` + + lemma `measurable_poweR` + +- in `ftc.v`: + + lemma `integrable_locally` + +- in `probability.v`: + + lemmas `eq_bernoulli`, `eq_bernoulliV2` + +### Changed + +- in `pi_irrational`: + + definition `rational` + +### Renamed + +- in `kernel.v`: + + `isFiniteTransition` -> `isFiniteTransitionKernel` + +- in `ereal.v`: + + `ereal_sup_le` -> `ereal_sup_ge` + +- in `pseudometric_normed_Zmodule.v`: + + `opp_continuous` -> `oppr_continuous` + +- in `lebesgue_integral_approximation.v` (now `measurable_fun_approximation.v`): + + `emeasurable_fun_lt` -> `measurable_lte` + + `emeasurable_fun_le` -> `measurable_lee` + + `emeasurable_fun_eq` -> `measurable_lee` + + `emeasurable_fun_neq` -> `measurable_neqe` + +- file `lebesgue_integral_approximation.v` -> `measurable_fun_approximation.v` + +### Generalized + +- in `functions.v`: + + `fct_sumE`, `addrfctE`, `sumrfctE` (from `zmodType` to `nmodType`) + + `scalerfctE` (from `pointedType` to `Type`) + +- in `normedtype.v`: + + lemmas `gt0_cvgMlNy`, `gt0_cvgMly` + +- in `measurable_realfun.v` + + lemma `measurable_ln` + +### Removed + +- in `functions.v`: + + definitions `fct_ringMixin`, `fct_ringMixin` (was only used in an `HB.instance`) + +- in `constructive_ereal.v`: + + notations `esum_ninftyP`, `esum_ninfty`, `esum_pinftyP`, `esum_pinfty` (deprecated since 0.6.0) + +- in `pseudometric_structure.v`: + + notations `cvg_ballPpos`, `app_cvg_locally` (deprecated since 0.6.0) + +- in `product_topology.v`: + + notation `compact_setM` (deprecated since 0.6.0) + +- in `separation_axioms.v`: + + notations `cvg_map_lim`, `cvgi_map_lim` (deprecated since 0.6.6) + +- in `sequences.v`: + + notation `nonincreasing_cvg_ge` (deprecated since 0.6.6) + + notation `nondecreasing_cvg_le` (deprecated since 0.6.6) + + notations `nonincreasing_cvg`, `nondecreasing_cvg`, `nonincreasing_is_cvg`, + `nondecreasing_is_cvg`, `nondecreasing_dvg_lt`, `near_nondecreasing_is_cvg`, + `near_nonincreasing_is_cvg` (deprecated since 0.6.6) + + notation `ereal_nondecreasing_opp` (deprecated since 0.6.6) + + notations `ereal_nondecreasing_cvg`, `ereal_nondecreasing_is_cvg`, `ereal_nonincreasing_cvg`, + `ereal_nonincreasing_is_cvg` (deprecated since 0.6.6) + + notations `lim_sup`, `lim_inf`, `lim_infN`, `lim_supE`, `lim_infE`, `lim_inf_le_lim_sup`, + `cvg_lim_infE`, `cvg_lim_supE`, `le_lim_supD`, `le_lim_infD`, `lim_supD`, `lim_infD` + + notations `lim_einf_shift`, `lim_esup_le_cvg`, `lim_einfN`, `lim_esupN`, `lim_einf_sup`, + `cvgNy_lim_einf_sup`, `cvg_lim_einf_sup`, `is_cvg_lim_einfE`, `is_cvg_lim_esupE` + +- in `exp.v`: + + notation `gt0_ler_powR` (deprecated since 0.6.5) + +- in `measure.v`: + + notation `measurable_fun_ext` (deprecated since 0.6.2) + + notations `measurable_fun_id`, `measurable_fun_cst`, `measurable_fun_comp` (deprecated since 0.6.3) + + notation `measurable_funT_comp` (deprecated since 0.6.3) + +- in `measurable_realfun.v`: + + notation `measurable_fun_ln` (deprecated since 0.6.3) + + notations `emeasurable_itv_bnd_pinfty`, `emeasurable_itv_ninfty_bnd` (deprecated since 0.6.2) + + notation `measurable_fun_lim_sup` (deprecated since 0.6.6) + + notation `measurable_fun_max` (deprecated since 0.6.3) + + notation `measurable_fun_er_map` (deprecated since 0.6.3) + + notations `emeasurable_funN`, `emeasurable_fun_max`, `emeasurable_fun_min`, + `emeasurable_fun_funepos`, `emeasurable_fun_funeneg` (deprecated since 0.6.3) + + notation `measurable_fun_lim_esup` (deprecated since 0.6.6) + +- in `lebesgue_integral_nonneg.v`: + + notations `ge0_integralM_EFin`, `ge0_integralM`, `integralM_indic`, `integralM_indic_nnsfun` + (deprecated since 0.6.4) + +- in `lebesgue_integrable.v`: + + notation `integralM` (deprecated since 0.6.4) ## [1.10.0] - 2025-04-21 diff --git a/CHANGELOG_UNRELEASED.md b/CHANGELOG_UNRELEASED.md index 3a2ed8859..43953d0f5 100644 --- a/CHANGELOG_UNRELEASED.md +++ b/CHANGELOG_UNRELEASED.md @@ -4,19 +4,267 @@ ### Added +- in new file `gauss_integral_alternative` + + add lemmas `integral0y_gauss_fin_num`, + `integral0y_u0`, + `integrable0y_u`, + `max_y_ge0`, + `u_dominates`, + `int0yu_fin_num`, + `cvgy_int0yu0`, + `dint0yuE`, + `derivable_int0yu`, + `rc_int0yu0`, + `gauss_integration` +- in `probability.v`: + + lemmas `eq_bernoulli`, `eq_bernoulliV2` + +- in `measure.v`: + + lemmas `mnormalize_id`, `measurable_fun_eqP` + +- in `ftc.v`: + + lemma `integrable_locally` + +- in `constructive_ereal.v`: + + lemma `EFin_bigmax` + +- in `mathcomp_extra.v`: + + lemmas `inr_inj`, `inl_inj` + +- in `classical_sets.v`: + + lemmas `in_set1`, `inr_in_set_inr`, `inl_in_set_inr`, `mem_image`, `mem_range`, `image_f` + + lemmas `inr_in_set_inl`, `inl_in_set_inl` + +- in `lebesgue_integral_approximation.v` (now `measurable_fun_approximation.v`): + + lemma `measurable_prod` + + lemma `measurable_fun_lte` + + lemma `measurable_fun_lee` + + lemma `measurable_fun_eqe` + + lemma `measurable_poweR` + +- in `exp.v`: + + lemma `poweRE` + +- in `exp.v`: + + lemmas `lnNy`, `powR_cvg0`, `derivable_powR`, `powR_derive1` + + Instance `is_derive1_powR` +- in `realfun.v`: + + lemma `cvge_ninftyP` + +- in `boolp.v`: + + lemmas `orW`, `or3W`, `or4W` + +- in `classical_sets.v`: + + lemmas `set_cst`, `image_nonempty` + +- in `unstable.v`: + + lemmas `eq_exists2l`, `eq_exists2r` + + module `ProperNotations` with notations `++>`, `==>`, `~~>` +- in `functions.v`: + + lemma `natmulfctE` + +- in `ereal.v`: + + lemmas `ereal_infEN`, `ereal_supN`, `ereal_infN`, `ereal_supEN` + + lemmas `ereal_supP`, `ereal_infP`, `ereal_sup_gtP`, `ereal_inf_ltP`, + `ereal_inf_leP`, `ereal_sup_geP`, `lb_ereal_infNy_adherent`, + `ereal_sup_real`, `ereal_inf_real` +- in `constructive_ereal.v`: + + lemmas `expe_ge0`, `expe_eq0`, `expe_gt0` + +- in `ereal.v`: + + lemmas `ereal_sup_cst`, `ereal_inf_cst`, + `ereal_sup_pZl`, `ereal_supZl`, `ereal_inf_pZl`, `ereal_infZl` + +- in `sequences.v`: + + lemmas `ereal_inf_seq`, `ereal_sup_seq` +- in `unstable.v`: + + lemma `subrKC` + +- in `convex.v`: + + definition `convex_quasi_associative` + * implemented through a module `ConvexQuasiAssoc` containing + `law` and helper lemmas + + lemmas `convR_itv`, `convR_line_path` +- in `num_topology.v` + + `topologicalType` instance on `R^o` for `R : numDomainType` + +- in `tvs.v` + + HB classes `TopologicalNmodule`, `TopologicalZmodule`, `TopologicalLmodule` + `UniformNmodule`, `UniformZmodule`, `UniformLmodule` + + notation `topologicalZmodType` + + mixin `PreTopologicalNmodule_isTopologicalNmodule`, + `TopologicalNmodule_isTopologicalZmodule`, + `TopologicalZmodule_isTopologicalLmodule`, + `PreUniformNmodule_isUniformNmodule`, + `UniformNmodule_isUniformZmodule`, + `PreUniformLmodule_isUniformLmodule` + + structure `topologicalLmodule` + + factories `PreTopologicalNmodule_isTopologicalZmodule`, + `TopologicalNmodule_isTopologicalLmodule`, + `PreUniformNmodule_isUniformZmodule`, + `UniformNmodule_isUniformLmodule` + + lemmas `sub_continuous`, `sub_unif_continuous` + +- in `constructive_ereal.v`: + + `inve` a total involutive inversion function on `\bar R`, denoted `^-1` in + the `ereal_scope` coinciding with `x^-1%R` when `x != 0` but such that + `0^-1 = +oo` and `-oo^-1 = -oo`, + + notation `x / y` in `ereal_scope` for `x / y = x * y^-1`, + + lemmas `inver`, `inveP`, `fine_invr`, `inve0`, `inve1`, `invey`, `invey`, + `inveNy`, `inveK`, `invr_inj`, `inveN`, `inve_eq0`, `inve_ge0`, `inve_gt0`, + `inv_gt0P`, `inve_lt0`, `inve_le0`, `inve_le0P`, + + predicate `inveM_def` with notation `x *^-1? y` defining a sufficient + condition for the inverse and product to commute, with lemmas `inveMP`, + `inveM_defE`, `inveM` and `fin_inveM_def`, + + compatibility lemma `mule_defE` to bridge the former definition of + `mule_def` with the new one. + + lemma `fin_numV` + + lemmas `mulVe`, `lee_pV2`, `lte_pV2`, `ltee_pV2`, `inve_pge`, `inve_pgt`, + `inve_ple`, `inve_plt`, `inve_gt1`, `inve_ge1`. + +- in `lebesgue_integral_differentiation.v`: + + lemma `nicely_shrinking_fin_num` + +- in `normed_module.v`: + + definition `pseudoMetric_normed` + + factory `Lmodule_isNormed` +- in `num_normedtype.v`: + + lemmas `gt0_cvgMrNy`, `gt0_cvgMry` + +- in `probability.v`: + + definition `exponential_pdf` + + lemmas `exponential_pdf_ge0`, `lt0_exponential_pdf`, + `measurable_exponential_pdf`, `exponential_pdfE`, + `in_continuous_exponential_pdf`, `within_continuous_exponential_pdf` + + definition `exponential_prob` + + lemmas `derive1_exponential_pdf`, `exponential_prob_itv0c`, + `integral_exponential_pdf`, `integrable_exponential_pdf` +- in `exp.v` + + lemma `expR_ge1Dxn` +- in `classical_sets.v` + + lemma `bigcup_mkord_ord` + +- in `measure.v`: + + definition `g_sigma_preimage` + + lemma `g_sigma_preimage_comp` + + definition `measure_tuple_display` + + lemma `measurable_tnth` + + lemma `measurable_fun_tnthP` + + lemma `measurable_cons` + + lemma `measurable_behead` + +- in `lebesgue_integral_theory/lebesgue_integral_nonneg.v`: + + lemmas `ge0_nondecreasing_set_nondecreasing_integral`, + `ge0_nondecreasing_set_cvg_integral`, + `le0_nondecreasing_set_nonincreasing_integral`, + `le0_nondecreasing_set_cvg_integral` + +- in new file `gauss_integral_unbounded` + + add lemmas `integral0y_gauss_fin_num`, + `integral0y_u0`, + `integrable0y_u`, + `max_y_ge0`, + `u_dominates`, + `int0yu_fin_num`, + `cvgy_int0yu0`, + `derive1_int0yuE`, + `derivable_int0yu`, + `rcvg0_int0yu`, + `gauss_integration` + ### Changed +- in `convex.v`: + + convex combination operator `a <| t |> b` changed from + `(1-t)a + tb` to `ta + (1-t)b` + +- in `sequences.v`: + + lemma `subset_seqDU` + +- in `measure.v`: + + lemmas `seqDU_measurable`, `measure_gt0` + + notations `\forall x \ae mu, P`, `f = g %[ae mu in D]`, `f = g %[ae mu]` + + instances `ae_eq_equiv`, `comp_ae_eq`, `comp_ae_eq2`, `comp_ae_eq2'`, `sub_ae_eq2` + + lemma `ae_eq_comp2` + + lemma `ae_foralln` + + lemma `ae_eqe_mul2l` + +- new file `ess_sup_inf.v`: + + lemma `measure0_ae` + + definition `ess_esup` + + lemmas `ess_supEae`, `ae_le_measureP`, `ess_supEmu0`, `ess_sup_ge`, + `ess_supP`, `le_ess_sup`, `eq_ess_sup`, `ess_sup_cst`, `ess_sup_ae_cst`, + `ess_sup_gee`, `abs_sup_eq0_ae_eq`, `abs_ess_sup_eq0`, `ess_sup_pZl`, + `ess_supZl`, `ess_sup_eqNyP`, `ess_supD`, `ess_sup_absD` + + notation `ess_supr` + + lemmas `ess_supr_bounded`, `ess_sup_eqr0_ae_eq`, `ess_suprZl`, + `ess_sup_ger`, `ess_sup_ler`, `ess_sup_cstr`, `ess_suprD`, `ess_sup_normD` + + definition `ess_inf` + + lemmas `ess_infEae`, `ess_infEN`, `ess_supEN`, `ess_infN`, `ess_supN`, + `ess_infP`, `ess_inf_le`, `le_ess_inf`, `eq_ess_inf`, `ess_inf_cst`, + `ess_inf_ae_cst`, `ess_inf_gee`, `ess_inf_pZl`, `ess_infZl`, `ess_inf_eqyP`, + `ess_infD` + + notation `ess_infr` + + lemmas `ess_infr_bounded`, `ess_infrZl`, `ess_inf_ger`, `ess_inf_ler`, + `ess_inf_cstr` + +- in `measure.v`: + + notation `{ae mu, P}` (near use `{near _, _}` notation) + + definition `ae_eq` + + `ae_eq` lemmas now for `ringType`-valued functions (instead of `\bar R`) + +- in `convex.v`: + + definition `convex_realDomainType` generalized and + renamed accordingly `convex_numDomainType` +- in `tvs.v` + + HB class `UniformZmodule` now contains `TopologicalZmodule` + + HB class `UniformLmodule` now contains `TopologicalLmodule` + +- in `constructive_ereal.v`: + + `mule` has special cases optimizing computation for +oo and -oo + + `mule_def` has been rewritten to optimize computation in several cases. + +- in `lebesgue_integral_nonneg.v`: + + lemma `integral_abs_eq0` (remove redundant hypotheses) + +- in `lebesgue_integral_differentiation.v`: + + definition `iavg` (to use `inve`) + ### Renamed -- in `kernel.v`: - + `isFiniteTransition` -> `isFiniteTransitionKernel` +- in `measure.v` + + definition `ess_sup` moved to `ess_sup_inf.v` + +- in `convex.v` + + lemma `conv_gt0` to `convR_gt0` +- in `tvs.v` + + HB class `TopologicalNmodule` moved to `PreTopologicalNmodule` + + HB class `TopologicalZmodule` moved to `PreTopologicalZmodule` + + HB class `TopologicalLmodule` moved to `PreTopologicalLmodule` + + structure `topologicalLmodule` moved to `preTopologicalLmodule` + + HB class `UniformNmodule` moved to `PreUniformNmodule` + + HB class `UniformZmodule` moved to `PreUniformZmodule` + + HB class `UniformLmodule` moved to `PreUniformLmodule` + ### Generalized +- in `derive.v`: + + `derive_cst`, `derive1_cst` +- in `convex.v` + + parameter `R` of `convType` from `realDomainType` to `numDomainType` + +- in `derive.v`: + + lemmas `is_deriveX`, `deriveX`, `exp_derive`, `exp_derive1` + ### Deprecated ### Removed +- in `measure.v`: + + definition `almost_everywhere_notation` + + lemma `ess_sup_ge0` + ### Infrastructure ### Misc diff --git a/INSTALL.md b/INSTALL.md index 35fce0bbb..9049f4c3f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,16 +2,16 @@ ## Requirements -- [The Coq Proof Assistant version ≥ 8.19](https://coq.inria.fr) -- [Mathematical Components version ≥ 2.1.0](https://github.com/math-comp/math-comp) -- [Finmap library version ≥ 2.0.0](https://github.com/math-comp/finmap) -- [Hierarchy builder version >= 1.7.0](https://github.com/math-comp/hierarchy-builder) -- [bigenough >= 1.0.0](https://github.com/math-comp/bigenough) +- [The Coq Proof Assistant version ≥ 8.20 / Rocq Prover version ≥ 9.0](https://rocq-prover.org) +- [Mathematical Components version ≥ 2.2.0](https://github.com/math-comp/math-comp) +- [Finmap library version ≥ 2.1.0](https://github.com/math-comp/finmap) +- [Hierarchy builder version ≥ 1.7.0](https://github.com/math-comp/hierarchy-builder) +- [bigenough ≥ 1.0.0](https://github.com/math-comp/bigenough) These requirements can be installed in a custom way, or through [opam](https://opam.ocaml.org/) (the recommended way) using -the repository https://coq.inria.fr/opam/released, which you can add by typing -`opam repo add coq-released https://coq.inria.fr/opam/released`. +the repository https://rocq-prover.org/opam/released, which you can add by typing +`opam repo add rocq-released https://rocq-prover.org/opam/released`. Detailed instructions for possible installations of Mathematical Components are located [here](https://github.com/math-comp/math-comp/blob/master/INSTALL.md). @@ -22,8 +22,10 @@ Detailed instructions for possible installations of Mathematical Components are + type `opam install coq-mathcomp-analysis.X.Y.Z` where `X.Y.Z` is the version number (all the dependencies should be automatically installed, assuming `opam` has been properly configured and `coq-released` repository is added) -- Custom (assuming the requirements are met): - + type `make` to use the provided `Makefile` +- Custom: + + first, install the required dependencies, for example with opam + type `opam install --deps-only coq-mathcomp-analysis.X.Y.Z` + + assuming the requirements are met, type `make` to use the provided `Makefile` ## From scratch instructions @@ -40,7 +42,7 @@ $ sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/instal $ export OPAMROOT=~/.opam_mathcomp_analysis # opam configuration, metadata, logs, temporary directories and caches $ opam init -j4 # adapt to the number of cores you have $ eval `opam config env` -$ opam repo add coq-released https://coq.inria.fr/opam/released +$ opam repo add rocq-released https://rocq-prover.org/opam/released ``` 3. Install our package (and all its dependencies) ``` @@ -48,7 +50,7 @@ $ opam install coq-mathcomp-analysis ``` To install a precise version, type, say ``` -$ opam install coq-mathcomp-analysis.1.9.0 +$ opam install coq-mathcomp-analysis.1.11.0 ``` 4. Everytime you want to work in this same context, you need to type ``` @@ -71,28 +73,28 @@ using [proof general for emacs](https://github.com/ProofGeneral/PG) ## Break-down of phase 3 of the installation procedure step by step -With the example of Coq 8.19.0 and MathComp 2.1.0. For other versions, update the +With the example of Coq 8.20.1 and MathComp 2.3.0. For other versions, update the version numbers accordingly. -1. Install Coq 8.19.0 +1. Install Coq 8.20.1 ``` -$ opam install coq.8.19.0 +$ opam install coq.8.20.1 ``` 2. Install the Mathematical Components ``` -$ opam install coq-mathcomp-ssreflect.2.1.0 -$ opam install coq-mathcomp-fingroup.2.1.0 -$ opam install coq-mathcomp-algebra.2.1.0 -$ opam install coq-mathcomp-solvable.2.1.0 -$ opam install coq-mathcomp-field.2.1.0 +$ opam install coq-mathcomp-ssreflect.2.3.0 +$ opam install coq-mathcomp-fingroup.2.3.0 +$ opam install coq-mathcomp-algebra.2.3.0 +$ opam install coq-mathcomp-solvable.2.3.0 +$ opam install coq-mathcomp-field.2.3.0 ``` 3. Install the Finite maps library ``` -$ opam install coq-mathcomp-finmap.2.0.0 +$ opam install coq-mathcomp-finmap.2.2.0 ``` 4. Install the Hierarchy Builder ``` -$ opam install coq-hierarchy-builder.1.6.0 +$ opam install coq-hierarchy-builder.1.8.0 ``` 5. Download and compile `coq-mathcomp-analysis` without installing ``` diff --git a/Makefile.common b/Makefile.common index 9a76396c2..936cd4ca8 100644 --- a/Makefile.common +++ b/Makefile.common @@ -6,9 +6,11 @@ # pre-makefile::, this-clean:: and __always__:: may be extended # # Additionally, the following variables may be customized: # SUBDIRS?= -COQBIN?=$(dir $(shell which coqtop)) -COQMAKEFILE?=$(COQBIN)coq_makefile -COQDEP?=$(COQBIN)coqdep +COQBIN?=$(dir $(shell command -v coqtop || command -v rocq)) +COQMAKEFILE?=$(shell command -v coq_makefile || echo "$(COQBIN)rocq makefile") +COQC?=$(shell command -v coqc || echo "$(COQBIN)rocq c") +COQDEP?=$(shell command -v coqdep || echo "$(COQBIN)rocq dep") +COQDOC?=$(shell command -v coqdoc || echo "$(COQBIN)rocq doc") COQPROJECT?=_CoqProject COQMAKEOPTIONS?= COQMAKEFILEOPTIONS?= @@ -44,7 +46,7 @@ all: config build Makefile.coq: pre-makefile $(COQPROJECT) Makefile (echo "From mathcomp.algebra Require Import interval_inference." > test_interval_inference.v \ - && (rocq c test_interval_inference.v > /dev/null 2>&1) \ + && ($(COQC) test_interval_inference.v > /dev/null 2>&1) \ && test -f interval_inference.v -o -f reals/interval_inference.v \ && touch rm_interval_inference) || true $(RM) test_interval_inference.v @@ -117,54 +119,24 @@ endif %.vo: __always__ Makefile.coq +$(COQMAKE) $@ -# the doc targets doc and doc-clean are essentially copied from the Mathematical -# Components repository -# we reuse the scripts from the math-comp git repo (which is hard wired) -# modulo one fix: we change builddoc_lib.sh:l.18 to s/\(\*{5,}+\)//g; - -MATHCOMP = ../math-comp/ - -doc: __always__ Makefile.coq - mkdir -p _build_doc/ - cp -r $(COQFILES) -t _build_doc/ --parents - cp _CoqProject Makefile* _build_doc - mkdir -p _build_doc/htmldoc - . $(MATHCOMP)etc/utils/builddoc_lib.sh; \ - cd _build_doc && mangle_sources $(COQFILES) - +cd _build_doc && $(COQMAKE) -# let's forget about the dependency graph for the time being... -# cd _build_doc && grep -v vio: .Makefile.coq.d > depend -# cd _build_doc && cat depend | $(MATHCOMP)etc/buildlibgraph $(COQFILES) > htmldoc/depend.js - cd _build_doc && $(COQBIN)coqdoc -t "MathComp Analysis" \ - -g --utf8 -Q classical mathcomp.classical -Q theories mathcomp.analysis \ - --parse-comments \ - --multi-index $(COQFILES) -d htmldoc - . $(MATHCOMP)etc/utils/builddoc_lib.sh; \ - cd _build_doc && postprocess_html - cp $(MATHCOMP)etc/artwork/coqdoc.css _build_doc/htmldoc - -doc-clean: - rm -rf _build_doc/ - -coq2html: - coqdep -f _CoqProject > depend.d - ../coq2html/ocamldot/ocamldot depend.d > depend.dot - gsed -i 's/Classical/mathcomp\.classical/' depend.dot - gsed -i 's/Theories/mathcomp\.analysis/' depend.dot - gsed -i 's/Reals_stdlib/mathcomp\.reals_stdlib/' depend.dot - gsed -i 's/Experimental_reals/mathcomp\.experimental_reals/' depend.dot - gsed -i 's/Reals/mathcomp\.reals/' depend.dot - gsed -i 's/Analysis_stdlib/mathcomp\.analysis_stdlib/' depend.dot - gsed -i 's/\//\./g' depend.dot - ../coq2html/tools/generate-hierarchy-graph.sh - find . -not -path '*/.*' -name "*.v" -or -name "*.glob" | xargs ../coq2html/coq2html \ - -hierarchy-graph hierarchy-graph.dot \ - -dependency-graph depend.dot \ - -title "Mathcomp Analysis" \ - -d html/ -base mathcomp -Q theories analysis \ - -coqlib https://rocq-prover.org/doc/V8.20.1/stdlib/ \ - -external https://math-comp.github.io/htmldoc_2_3_0/ mathcomp.ssreflect \ - -external https://math-comp.github.io/htmldoc_2_3_0/ mathcomp.algebra - -coq2html-clean: - rm -f */*.glob +# Html documentation + +DOCDIR=html + +$(DOCDIR)/dependency_graph.pre: + mkdir -p $(DOCDIR) + coqdep -f _CoqProject | perl etc/builddoc_dependency_dot.pl > $(DOCDIR)/dependency_graph.pre + +$(DOCDIR)/dependency_graph.dot: $(DOCDIR)/dependency_graph.pre + mkdir -p $(DOCDIR) + tred $(DOCDIR)/dependency_graph.pre > $(DOCDIR)/dependency_graph.dot + +html: build $(DOCDIR)/dependency_graph.dot + mkdir -p $(DOCDIR) + find . -not -path '*/.*' -name "*.v" -or -name "*.glob" | xargs rocqnavi \ + -title "Mathcomp Analysis" \ + -d $(DOCDIR) -base mathcomp -Q theories analysis \ + -coqlib https://rocq-prover.org/doc/V8.20.1/stdlib/ \ + -dependency-graph $(DOCDIR)/dependency_graph.dot \ + -external https://math-comp.github.io/htmldoc_2_3_0/ mathcomp.ssreflect \ + -external https://math-comp.github.io/htmldoc_2_3_0/ mathcomp.algebra diff --git a/Makefile.coq.local b/Makefile.coq.local index c6a0262c5..b757c395c 100644 --- a/Makefile.coq.local +++ b/Makefile.coq.local @@ -1,5 +1,5 @@ pre-all:: - if command -v coqc > /dev/null && (coqc --version | grep -q '8.18\|8.19\|8.20') ; then \ + if command -v coqc > /dev/null && (coqc --version | grep -q '8.20') ; then \ for f in $(shell grep "From Corelib" $$(find . -name "*.v") | cut -d: -f1) ; do \ sed -i.bak 's/From Corelib/From Coq/' $${f} ; \ sed -i.bak 's/PosDef/PArith/' $${f} ; \ diff --git a/README.md b/README.md index c046a73a7..20be5e33a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ - # Analysis library compatible with Mathematical Components [![Nix CI][nix-action-shield]][nix-action-link] @@ -11,9 +7,9 @@ Follow the instructions on https://github.com/coq-community/templates to regener [nix-action-link]: https://github.com/math-comp/analysis/actions?query=branch%3Amaster+event%3Apush [chat-shield]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg -[chat-link]: https://coq.zulipchat.com/login/#narrow/stream/237666-math-comp-analysis +[chat-link]: https://rocq-prover.zulipchat.com/#narrow/channel/237666-math-comp-analysis -This repository contains a real analysis library for the Coq proof-assistant. +This repository contains a real analysis library for the Coq / Rocq proof-assistant. It is based on the [Mathematical Components](https://math-comp.github.io/) library. In terms of [opam](https://opam.ocaml.org/doc/Install.html), it comes as the following packages: @@ -28,7 +24,7 @@ In terms of [opam](https://opam.ocaml.org/doc/Install.html), it comes as the fol - [Authors](AUTHORS.md) - License: [CeCILL-C](LICENSE) -- Compatible Rocq versions: Coq 8.19 to 8.20, Rocq 9.0 (or dev) +- Compatible Rocq versions: Coq 8.20, Rocq 9.0 (or dev) - Additional dependencies: - [MathComp ssreflect 2.1.0 or later](https://math-comp.github.io) - [MathComp fingroup 2.1.0 or later](https://math-comp.github.io) @@ -46,7 +42,7 @@ The easiest way to install the latest released version of MathComp-Analysis libr via the [opam](https://opam.ocaml.org/doc/Install.html) package manager: ```shell -opam repo add coq-released https://coq.inria.fr/opam/released +opam repo add rocq-released https://rocq-prover.org/opam/released opam install coq-mathcomp-analysis ``` Note that the packages `coq-mathcomp-classical` and `coq-mathcomp-reals` will be installed as dependencies. @@ -58,7 +54,7 @@ To build and install manually, make sure that the dependencies are met and do: ``` shell git clone https://github.com/math-comp/analysis.git cd analysis -make # or make -j +make # or make -j make install ``` @@ -77,7 +73,7 @@ We try to preserve backward compatibility as best as we can. Each file is documented in its header in ASCII. -[HTML rendering of the source code](https://math-comp.github.io/analysis/htmldoc_1_10_0/index.html) (using a fork of [`coq2html`](https://github.com/xavierleroy/coq2html)). +[HTML rendering of the source code](https://math-comp.github.io/analysis/htmldoc_1_11_0/index.html) (using [`rocqnavi`](https://github.com/affeldt-aist/rocqnavi)). It includes inheritance diagrams for the mathematical structures that MathComp-Analysis adds on top of MathComp's ones. Overview presentations: @@ -92,6 +88,7 @@ Publications about MathComp-Analysis: - [Measure Construction by Extension in Dependent Type Theory with Application to Integration](https://arxiv.org/pdf/2209.02345.pdf) (2023) doi:[10.1007/s10817-023-09671-5](https://doi.org/10.1007/s10817-023-09671-5) - [The Radon-Nikodým Theorem and the Lebesgue-Stieltjes Measure in Coq](https://www.jstage.jst.go.jp/article/jssst/41/2/41_2_41/_pdf/-char/en) (2024) doi:[10.11309/jssst.41.2_41](https://doi.org/10.11309/jssst.41.2_41) - [A Comprehensive Overview of the Lebesgue Differentiation Theorem in Coq](https://drops.dagstuhl.de/storage/00lipics/lipics-vol309-itp2024/LIPIcs.ITP.2024.5/LIPIcs.ITP.2024.5.pdf) (2024) doi:[10.4230/LIPIcs.ITP.2024.5](https://doi.org/10.4230/LIPIcs.ITP.2024.5) +- [Prouver que pi est irrationnel avec MathComp-Analysis](https://hal.science/hal-04859455/document) (2025) Other work using MathComp-Analysis: - [A Formal Classical Proof of Hahn-Banach in Coq](https://lipn.univ-paris13.fr/~kerjean/slides/slidesTYPES19.pdf) (2019) @@ -99,6 +96,8 @@ Other work using MathComp-Analysis: - [CoqQ: Foundational Verification of Quantum Programs](https://arxiv.org/pdf/2207.11350.pdf) (2023) - [Experimenting with an intrinsically-typed probabilistic programming language in Coq](https://staff.aist.go.jp/reynald.affeldt/documents/syntax-aplas2023.pdf) (2023) - [Taming Differentiable Logics with Coq Formalisation](https://drops.dagstuhl.de/storage/00lipics/lipics-vol309-itp2024/LIPIcs.ITP.2024.4/LIPIcs.ITP.2024.4.pdf) (2024) +- [Décomposition Algébrique Cylindrique en Coq/Rocq](https://inria.hal.science/hal-04859512/document) (2025) +- [Semantics of Probabilistic Programs using s-Finite Kernels in Dependent Type Theory](https://dl.acm.org/doi/pdf/10.1145/3732291) (2025) ## Development information diff --git a/_CoqProject b/_CoqProject index 0932b31a0..da9108d6c 100644 --- a/_CoqProject +++ b/_CoqProject @@ -69,6 +69,7 @@ theories/homotopy_theory/homotopy.v theories/homotopy_theory/wedge_sigT.v theories/homotopy_theory/continuous_path.v +theories/ess_sup_inf.v theories/function_spaces.v theories/ereal.v theories/cantor.v @@ -99,7 +100,7 @@ theories/numfun.v theories/lebesgue_integral_theory/simple_functions.v theories/lebesgue_integral_theory/lebesgue_integral_definition.v -theories/lebesgue_integral_theory/lebesgue_integral_approximation.v +theories/lebesgue_integral_theory/measurable_fun_approximation.v theories/lebesgue_integral_theory/lebesgue_integral_monotone_convergence.v theories/lebesgue_integral_theory/lebesgue_integral_nonneg.v theories/lebesgue_integral_theory/lebesgue_integrable.v @@ -119,5 +120,6 @@ theories/kernel.v theories/pi_irrational.v theories/gauss_integral.v theories/showcase/summability.v +theories/showcase/gauss_integral_unbounded.v analysis_stdlib/Rstruct_topology.v analysis_stdlib/showcase/uniform_bigO.v diff --git a/classical/boolp.v b/classical/boolp.v index da455229d..736318900 100644 --- a/classical/boolp.v +++ b/classical/boolp.v @@ -341,6 +341,30 @@ Proof. by rewrite /asbool; case: pselect=> h; constructor. Qed. Lemma asboolW (P : Prop) : `[

] -> P. Proof. by case: asboolP. Qed. +Lemma orW A B : A \/ B -> A + B. +Proof. +have [|NA] := asboolP A; first by left. +have [|NB] := asboolP B; first by right. +by move=> AB; exfalso; case: AB. +Qed. + +Lemma or3W A B C : [\/ A, B | C] -> A + B + C. +Proof. +have [|NA] := asboolP A; first by left; left. +have [|NB] := asboolP B; first by left; right. +have [|NC] := asboolP C; first by right. +by move=> ABC; exfalso; case: ABC. +Qed. + +Lemma or4W A B C D : [\/ A, B, C | D] -> A + B + C + D. +Proof. +have [|NA] := asboolP A; first by left; left; left. +have [|NB] := asboolP B; first by left; left; right. +have [|NC] := asboolP C; first by left; right. +have [|ND] := asboolP D; first by right. +by move=> ABCD; exfalso; case: ABCD. +Qed. + (* Shall this be a coercion ?*) Lemma asboolT (P : Prop) : P -> `[

]. Proof. by case: asboolP. Qed. diff --git a/classical/classical_sets.v b/classical/classical_sets.v index 21edb0eb0..44dd372c0 100644 --- a/classical/classical_sets.v +++ b/classical/classical_sets.v @@ -555,6 +555,7 @@ Qed. Notation setTP := setTPn (only parsing). Lemma in_set0 (x : T) : (x \in set0) = false. Proof. by rewrite memNset. Qed. + Lemma in_setT (x : T) : x \in setT. Proof. by rewrite mem_set. Qed. Lemma in_setC (x : T) A : (x \in ~` A) = (x \notin A). @@ -1241,6 +1242,13 @@ Notation bigcupM1l := bigcupX1l (only parsing). #[deprecated(since="mathcomp-analysis 1.3.0", note="renamed to bigcupX1r.")] Notation bigcupM1r := bigcupX1r (only parsing). +Lemma set_cst {T I} (x : T) (A : set I) : + [set x | _ in A] = if A == set0 then set0 else [set x]. +Proof. +apply/seteqP; split=> [_ [i +] <-|t]; first by case: ifPn => // /eqP ->. +by case: ifPn => // /set0P[i Ai ->{t}]; exists i. +Qed. + Section set_order. Import Order.TTheory. @@ -1441,9 +1449,15 @@ Implicit Types (A B : set aT) (f : aT -> rT) (Y : set rT). Lemma imageP f A a : A a -> (f @` A) (f a). Proof. by exists a. Qed. +Lemma image_f f A a : a \in A -> f a \in [set f x | x in A]. +Proof. by rewrite !inE; apply/imageP. Qed. + Lemma imageT (f : aT -> rT) (a : aT) : range f (f a). Proof. by apply: imageP. Qed. +Lemma mem_range f a : f a \in range f. +Proof. by rewrite !inE; apply/imageT. Qed. + End base_image_lemmas. #[global] Hint Extern 0 ((?f @` _) (?f _)) => solve [apply: imageP; assumption] : core. @@ -1458,6 +1472,10 @@ Proof. by move=> f_inj; rewrite propeqE; split => [[b Ab /f_inj <-]|/(imageP f)//]. Qed. +Lemma mem_image {f A a} : injective f -> + (f a \in [set f x | x in A]) = (a \in A). +Proof. by move=> /image_inj finj; apply/idP/idP; rewrite !inE finj. Qed. + Lemma image_id A : id @` A = A. Proof. by rewrite eqEsubset; split => a; [case=> /= x Ax <-|exists a]. Qed. @@ -1521,6 +1539,9 @@ Proof. by move=> b [x [Aa Ba <-]]; split; apply: imageP. Qed. Lemma nonempty_image f A : f @` A !=set0 -> A !=set0. Proof. by case=> b [a]; exists a. Qed. +Lemma image_nonempty f A : A !=set0 -> f @` A !=set0. +Proof. by move=> [x] Ax; exists (f x), x. Qed. + Lemma image_subset f A B : A `<=` B -> f @` A `<=` f @` B. Proof. by move=> AB _ [a Aa <-]; exists a => //; apply/AB. Qed. @@ -1643,6 +1664,8 @@ Proof. by rewrite preimage_false; under eq_fun do rewrite inE. Qed. End image_lemmas. Arguments sub_image_setI {aT rT f A B} t _. +Arguments subset_set1 {_ _ _}. +Arguments subset_set2 {_ _ _ _}. Lemma image2_subset {aT bT rT : Type} (f : aT -> bT -> rT) (A B : set aT) (C D : set bT) : A `<=` B -> C `<=` D -> @@ -1732,6 +1755,22 @@ Proof. by apply/disj_setPS/disj_setPS; rewrite -some_setI -some_set0 sub_image_someP. Qed. +Lemma inl_in_set_inr A B (x : A) (Y : set B) : + inl x \in [set inr y | y in Y] = false. +Proof. by apply/negP; rewrite inE/= => -[]. Qed. + +Lemma inr_in_set_inl A B (y : B) (X : set A) : + inr y \in [set inl x | x in X] = false. +Proof. by apply/negP; rewrite inE/= => -[]. Qed. + +Lemma inr_in_set_inr A B (y : B) (Y : set B) : + inr y \in [set @inr A B y | y in Y] = (y \in Y). +Proof. by apply/idP/idP => [/[!inE][/= [x ? [<-]]]|/[!inE]]//; exists y. Qed. + +Lemma inl_in_set_inl A B (x : A) (X : set A) : + inl x \in [set @inl A B x | x in X] = (x \in X). +Proof. by apply/idP/idP => [/[!inE][/= [y ? [<-]]]|/[!inE]]//; exists x. Qed. + Section bigop_lemmas. Context {T I : Type}. Implicit Types (A : set T) (i : I) (P : set I) (F G : I -> set T). @@ -2219,6 +2258,9 @@ Proof. by apply: setC_inj; rewrite setC_bigcap setC_bigsetI bigcup_seq. Qed. End bigcup_seq. +Lemma in_set1 [T : finType] (x y : T) : (x \in [set y]) = (x \in [set y]%SET). +Proof. by apply/idP/idP; rewrite !inE /= => /eqP. Qed. + Lemma bigcup_pred [T : finType] [U : Type] (P : {pred T}) (f : T -> set U) : \bigcup_(t in [set` P]) f t = \big[setU/set0]_(t in P) f t. Proof. @@ -2269,6 +2311,13 @@ rewrite -(big_mkord xpredT F) -bigcup_seq. by apply: eq_bigcupl; split=> i; rewrite /= mem_index_iota leq0n. Qed. +Lemma bigcup_mkord_ord n (G : 'I_n.+1 -> set T) : + \bigcup_(i < n.+1) G (inord i) = \big[setU/set0]_(i < n.+1) G i. +Proof. +rewrite bigcup_mkord; apply: eq_bigr => /= i _; congr G. +by apply/val_inj => /=; rewrite inordK. +Qed. + Lemma bigcap_mkord n F : \bigcap_(i < n) F i = \big[setI/setT]_(i < n) F i. Proof. by apply: setC_inj; rewrite setC_bigsetI setC_bigcap bigcup_mkord. Qed. @@ -2451,6 +2500,8 @@ HB.instance Definition _ := isPointed.Build Prop False. HB.instance Definition _ := isPointed.Build nat 0. HB.instance Definition _ (T T' : pointedType) := isPointed.Build (T * T')%type (point, point). +HB.instance Definition _ (n : nat) (T : pointedType) := + isPointed.Build (n.-tuple T) (nseq n point). HB.instance Definition _ m n (T : pointedType) := isPointed.Build 'M[T]_(m, n) (\matrix_(_, _) point)%R. HB.instance Definition _ (T : choiceType) := isPointed.Build (option T) None. diff --git a/classical/filter.v b/classical/filter.v index aef5ac187..d78b663e6 100644 --- a/classical/filter.v +++ b/classical/filter.v @@ -131,7 +131,13 @@ From mathcomp Require Import cardinality mathcomp_extra fsbigop set_interval. (* canonical filter associated to F *) (* P must have the form forall x, Q x. *) (* Equivalent to F Q. *) +(* Prefer this notation when P is an *) +(* existing statement to be relativised *) +(* (i.e., has its own definition). *) (* \forall x \near F, P x <-> F (fun x => P x). *) +(* Prefer this notation when the *) +(* statement forall x, P x does not stand *) +(* alone. *) (* \near x, P x := \forall y \near x, P y. *) (* {near F & G, P} == same as {near H, P}, where H is the *) (* product of the filters F and G *) diff --git a/classical/functions.v b/classical/functions.v index e74eff13c..0a2692dbd 100644 --- a/classical/functions.v +++ b/classical/functions.v @@ -119,9 +119,10 @@ Add Search Blacklist "_mixin_". (* ``` *) (* *) (* ``` *) -(* Section function_space == canonical ringType and lmodType *) -(* structures for functions whose range is *) -(* a ringType, comRingType, or lmodType. *) +(* Section function_space == canonical nmodType, zmodType, ringType, *) +(* comRingType, and lmodType structures for *) +(* functions whose range is nmodType, zmodType, *) +(* ringType, comRingType, and lmodType resp. *) (* fctE == multi-rule for fct *) (* ``` *) (* *) @@ -1734,7 +1735,7 @@ Lemma reindex_bigcup {aT rT I} (f : aT -> I) (P : set aT) (Q : set I) (F : I -> set rT) : set_fun P Q f -> set_surj P Q f -> \bigcup_(x in Q) F x = \bigcup_(x in P) F (f x). Proof. -by move=> /image_subP fPQ /(surj_image_eq fPQ)<-; rewrite bigcup_image. +by move=> /image_subP fPQ /(surj_image_eq fPQ) QE; rewrite -[Q]QE bigcup_image. Qed. Arguments reindex_bigcup {aT rT I} f P Q. @@ -1742,7 +1743,7 @@ Lemma reindex_bigcap {aT rT I} (f : aT -> I) (P : set aT) (Q : set I) (F : I -> set rT) : set_fun P Q f -> set_surj P Q f -> \bigcap_(x in Q) F x = \bigcap_(x in P) F (f x). Proof. -by move=> /image_subP fPQ /(surj_image_eq fPQ)<-; rewrite bigcap_image. +by move=> /image_subP fPQ /(surj_image_eq fPQ) QE; rewrite -[Q]QE bigcap_image. Qed. Arguments reindex_bigcap {aT rT I} f P Q. @@ -2568,26 +2569,62 @@ Qed. Obligation Tactic := idtac. -Program Definition fct_zmodMixin (T : Type) (M : zmodType) := - @GRing.isZmodule.Build (T -> M) \0 (fun f x => - f x) (fun f g => f \+ g) - _ _ _ _. -Next Obligation. by move=> T M f g h; rewrite funeqE=> x /=; rewrite addrA. Qed. -Next Obligation. by move=> T M f g; rewrite funeqE=> x /=; rewrite addrC. Qed. -Next Obligation. by move=> T M f; rewrite funeqE=> x /=; rewrite add0r. Qed. -Next Obligation. by move=> T M f; rewrite funeqE=> x /=; rewrite addNr. Qed. -HB.instance Definition _ (T : Type) (M : zmodType) := fct_zmodMixin T M. - -Program Definition fct_ringMixin (T : pointedType) (M : ringType) := - @GRing.Zmodule_isRing.Build (T -> M) (cst 1) (fun f g => f \* g) _ _ _ _ _ _. -Next Obligation. by move=> T M f g h; rewrite funeqE=> x /=; rewrite mulrA. Qed. -Next Obligation. by move=> T M f; rewrite funeqE=> x /=; rewrite mul1r. Qed. -Next Obligation. by move=> T M f; rewrite funeqE=> x /=; rewrite mulr1. Qed. -Next Obligation. by move=> T M f g h; rewrite funeqE=> x/=; rewrite mulrDl. Qed. -Next Obligation. by move=> T M f g h; rewrite funeqE=> x/=; rewrite mulrDr. Qed. -Next Obligation. -by move=> T M ; apply/eqP; rewrite funeqE => /(_ point) /eqP; rewrite oner_eq0. -Qed. -HB.instance Definition _ (T : pointedType) (M : ringType) := fct_ringMixin T M. +Section fct_nmodType. +Variables (T : Type) (M : nmodType). +Implicit Types f g h : T -> M. + +Let addrA : associative (fun f g => f \+ g). +Proof. by move=> f g h; rewrite funeqE=> x /=; rewrite addrA. Qed. + +Let addrC : commutative (fun f g => f \+ g). +Proof. by move=> f g; rewrite funeqE=> x /=; rewrite addrC. Qed. + +Let add0r : left_id \0 (fun f g => f \+ g). +Proof. by move=> f; rewrite funeqE=> x /=; rewrite add0r. Qed. + +HB.instance Definition _ := + @GRing.isNmodule.Build (T -> M) \0 (fun f g => f \+ g) addrA addrC add0r. + +End fct_nmodType. + +Section fct_zmodType. +Variables (T : Type) (M : zmodType). +Implicit Types f : T -> M. + +Let addNr : left_inverse 0 (fun f => \- f) +%R. +Proof. by move=> f; rewrite funeqE=> x /=; rewrite [LHS]addNr. Qed. + +HB.instance Definition _ := + @GRing.Nmodule_isZmodule.Build (T -> M) (fun f => \- f) addNr. + +End fct_zmodType. + +Section fct_ringType. +Variables (T : pointedType) (M : ringType). +Implicit Types f g h : T -> M. + +Let mulrA : associative (fun f g => f \* g). +Proof. by move=> f g h; rewrite funeqE=> x /=; rewrite mulrA. Qed. + +Let mul1r : left_id (cst 1) (fun f g => f \* g). +Proof. by move=> f; rewrite funeqE=> x /=; rewrite mul1r. Qed. + +Let mulr1 : right_id (cst 1) (fun f g => f \* g). +Proof. by move=> f; rewrite funeqE=> x /=; rewrite mulr1. Qed. + +Let mulrDl : left_distributive (fun f g => f \* g) +%R. +Proof. by move=> f g h; rewrite funeqE=> x/=; rewrite mulrDl. Qed. + +Let mulrDr : right_distributive (fun f g => f \* g) +%R. +Proof. by move=> f g h; rewrite funeqE=> x/=; rewrite mulrDr. Qed. + +Let oner_neq0 : cst 1 != 0 :> (T -> M). +Proof. by apply/eqP; rewrite funeqE => /(_ point) /eqP; rewrite oner_eq0. Qed. + +HB.instance Definition _ := @GRing.Zmodule_isRing.Build (T -> M) (cst 1) + (fun f g => f \* g) mulrA mul1r mulr1 mulrDl mulrDr oner_neq0. + +End fct_ringType. Program Definition fct_comRingType (T : pointedType) (M : comRingType) := GRing.Ring_hasCommutativeMul.Build (T -> M) _. @@ -2612,7 +2649,7 @@ Qed. HB.instance Definition _ := fct_lmodMixin. End fct_lmod. -Lemma fct_sumE (I T : Type) (M : zmodType) r (P : {pred I}) (f : I -> T -> M) +Lemma fct_sumE (I T : Type) (M : nmodType) r (P : {pred I}) (f : I -> T -> M) (x : T) : (\sum_(i <- r | P i) f i) x = \sum_(i <- r | P i) f i x. Proof. by elim/big_rec2: _ => //= i y ? Pi <-. Qed. @@ -2627,13 +2664,17 @@ Section function_space_lemmas. Local Open Scope ring_scope. Import GRing.Theory. -Lemma addrfctE (T : Type) (K : zmodType) (f g : T -> K) : +Lemma addrfctE (T : Type) (K : nmodType) (f g : T -> K) : f + g = (fun x => f x + g x). Proof. by []. Qed. -Lemma sumrfctE (T : Type) (K : zmodType) (s : seq (T -> K)) : +Lemma sumrfctE (T : Type) (K : nmodType) (s : seq (T -> K)) : \sum_(f <- s) f = (fun x => \sum_(f <- s) f x). -Proof. by apply/funext => x;elim/big_ind2 : _ => // _ a _ b <- <-. Qed. +Proof. by apply/funext => x; elim/big_ind2 : _ => // _ a _ b <- <-. Qed. + +Lemma natmulfctE (U : Type) (K : nmodType) (f : U -> K) n : + f *+ n = (fun x => f x *+ n). +Proof. by elim: n => [//|n h]; rewrite funeqE=> ?; rewrite !mulrSr h. Qed. Lemma opprfctE (T : Type) (K : zmodType) (f : T -> K) : - f = (fun x => - f x). Proof. by []. Qed. @@ -2642,7 +2683,7 @@ Lemma mulrfctE (T : pointedType) (K : ringType) (f g : T -> K) : f * g = (fun x => f x * g x). Proof. by []. Qed. -Lemma scalrfctE (T : pointedType) (K : ringType) (L : lmodType K) +Lemma scalrfctE (T : Type) (K : ringType) (L : lmodType K) k (f : T -> L) : k *: f = (fun x : T => k *: f x). Proof. by []. Qed. diff --git a/classical/mathcomp_extra.v b/classical/mathcomp_extra.v index cac221b08..6245db399 100644 --- a/classical/mathcomp_extra.v +++ b/classical/mathcomp_extra.v @@ -464,3 +464,9 @@ End trunc_floor_ceil. Lemma natr_int {R : archiNumDomainType} n : n%:R \is a @Num.int R. Proof. by rewrite Num.Theory.intrEge0. Qed. + +Lemma inr_inj {A B} : injective (@inr A B). +Proof. by move=> ? ? []. Qed. + +Lemma inl_inj {A B} : injective (@inl A B). +Proof. by move=> ? ? []. Qed. diff --git a/classical/unstable.v b/classical/unstable.v index b6c313702..563dcb989 100644 --- a/classical/unstable.v +++ b/classical/unstable.v @@ -35,6 +35,11 @@ Unset Printing Implicit Defensive. Import Order.TTheory GRing.Theory Num.Theory. Local Open Scope ring_scope. +Section ssralg. +Lemma subrKC {V : zmodType} (x y : V) : x + (y - x) = y. +Proof. by rewrite addrC subrK. Qed. +End ssralg. + (* NB: Coq 8.17.0 generalizes dependent_choice from Set to Type making the following lemma redundant *) Section dependent_choice_Type. @@ -442,3 +447,39 @@ Proof. move=> lt_mn i; rewrite big_nat [ltRHS]big_nat ltr_sum//. by apply/hasP; exists m; rewrite ?mem_index_iota leqnn lt_mn. Qed. + + +Lemma eq_exists2l (A : Type) (P P' Q : A -> Prop) : + (forall x, P x <-> P' x) -> + (exists2 x, P x & Q x) <-> (exists2 x, P' x & Q x). +Proof. +by move=> eqQ; split=> -[x p q]; exists x; move: p q; rewrite ?eqQ. +Qed. + +Lemma eq_exists2r (A : Type) (P Q Q' : A -> Prop) : + (forall x, Q x <-> Q' x) -> + (exists2 x, P x & Q x) <-> (exists2 x, P x & Q' x). +Proof. +by move=> eqP; split=> -[x p q]; exists x; move: p q; rewrite ?eqP. +Qed. + +Declare Scope signature_scope. +Delimit Scope signature_scope with signature. + +Import -(notations) Morphisms. +Arguments Proper {A}%_type R%_signature m. +Arguments respectful {A B}%_type (R R')%_signature _ _. + +Module ProperNotations. + +Notation " R ++> R' " := (@respectful _ _ (R%signature) (R'%signature)) + (right associativity, at level 55) : signature_scope. + +Notation " R ==> R' " := (@respectful _ _ (R%signature) (R'%signature)) + (right associativity, at level 55) : signature_scope. + +Notation " R ~~> R' " := (@respectful _ _ (Program.Basics.flip (R%signature)) (R'%signature)) + (right associativity, at level 55) : signature_scope. + +Export -(notations) Morphisms. +End ProperNotations. diff --git a/coq-mathcomp-classical.opam b/coq-mathcomp-classical.opam index 6490d780e..3f7475502 100644 --- a/coq-mathcomp-classical.opam +++ b/coq-mathcomp-classical.opam @@ -15,12 +15,12 @@ the Coq proof-assistant and using the Mathematical Components library.""" build: [make "-C" "classical" "-j%{jobs}%"] install: [make "-C" "classical" "install"] depends: [ - ("coq" {>= "8.19" & < "8.21~"} - | "rocq-core" { (>= "9.0" & < "9.1~") | (= "dev") }) - "coq-mathcomp-ssreflect" { (>= "2.1.0") } + ("coq" {>= "8.20" & < "8.21~"} + | "coq-core" { (>= "9.0" & < "9.1~") | (= "dev") }) + "coq-mathcomp-ssreflect" { (>= "2.2.0" & < "2.5~") | (= "dev") } "coq-mathcomp-fingroup" "coq-mathcomp-algebra" - "coq-mathcomp-finmap" { (>= "2.0.0") } + "coq-mathcomp-finmap" { (>= "2.1.0") } "coq-hierarchy-builder" { (>= "1.7.0") } ] diff --git a/default.nix b/default.nix index 1a24d7a18..ec2742873 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ bundle ? null, job ? null, inNixShell ? null, src ? ./., }@args: let auto = fetchGit { - url = "https://github.com/coq-community/coq-nix-toolbox.git"; + url = "https://github.com/rocq-community/coq-nix-toolbox.git"; ref = "master"; rev = import .nix/coq-nix-toolbox.nix; }; diff --git a/etc/builddoc_dependency_dot.pl b/etc/builddoc_dependency_dot.pl new file mode 100644 index 000000000..14fa5161d --- /dev/null +++ b/etc/builddoc_dependency_dot.pl @@ -0,0 +1,41 @@ +print "digraph depend {\n"; +print " node [shape = ellipse,style=filled,colorscheme = paired12];\n"; +print " subgraph cluster_analysis { label=\"Analysis\" }\n"; +print " subgraph cluster_classical { label=\"Classical\" }\n"; +print " subgraph cluster_reals { label=\"Reals\" }\n"; +print " subgraph cluster_experimental_reals { label=\"ExperimentalReals\" }\n"; +print " subgraph cluster_analysis { label=\"Analysis\" }\n"; +print " subgraph cluster_topology { label=\"Topology\" }\n"; +print " subgraph cluster_normedtype { label=\"NormedType\" }\n"; +print " subgraph cluster_lebesgue_integral { label=\"Lebesgue_integral\" }\n"; +while (<>) { + if (m/([^\s]*)\.vo.*:(.*)/) { + $dests = $2 ; + ($path,$src) = ($1 =~ s/\//\//rg =~ m/^(?:(.*\/))?([^.]*)$/); + if ($path =~ m/classical\//) { + $url="mathcomp.classical.$src.html"; + print "subgraph cluster_classical { \"$path$src\"[label=\"$src\",URL=\"$url\",fillcolor=1]}\n"; + }elsif ($path =~ m/reals\// or $path =~ m/reals_stdlib\//) { + print "subgraph cluster_reals { \"$path$src\"[label=\"$src\",fillcolor=2,fontcolor=white]}" + }elsif ($path =~ m/experimental_reals\//) { + print "subgraph cluster_experimental_reals { \"$path$src\"[label=\"$src\",fillcolor=3]}" + }elsif ($path =~ m/theories\/topology_theory\//) { + print "subgraph cluster_topology { \"$path$src\"[label=\"$src\",fillcolor=4,fontcolor=white]}" + }elsif ($path =~ m/theories\/normedtype_theory\//) { + print "subgraph cluster_normedtype { \"$path$src\"[label=\"$src\",fillcolor=9]}" + }elsif ($path =~ m/theories\/lebesgue_integral_theory\//) { + print "subgraph cluster_lebesgue_integral { \"$path$src\"[label=\"$src\",fillcolor=10,fontcolor=white]}" + }elsif ($path =~ m/theories\//) { + print "subgraph cluster_analysis { \"$path$src\"[label=\"$src\",fillcolor=5]}" + }elsif ($path =~ m/analysis_stdlib\/.*/) { + print "subgraph cluster_analysis { \"$path$src\"[label=\"$src\",fillcolor=5]}" + }else { + $url="/mathcomp.$src.html"; + print "\"$path$src\"[label=\"$src\",URL=\"$url\",fillcolor=6,fontcolor=white]" + } + for my $dest (split(" ", $dests)) { + print " \"$1\" -> \"$path$src\";\n" if ($dest =~ m/(.*)\.vo/); + } + } +} +print "}\n"; diff --git a/experimental_reals/Makefile.coq.local b/experimental_reals/Makefile.coq.local index c6a0262c5..b757c395c 100644 --- a/experimental_reals/Makefile.coq.local +++ b/experimental_reals/Makefile.coq.local @@ -1,5 +1,5 @@ pre-all:: - if command -v coqc > /dev/null && (coqc --version | grep -q '8.18\|8.19\|8.20') ; then \ + if command -v coqc > /dev/null && (coqc --version | grep -q '8.20') ; then \ for f in $(shell grep "From Corelib" $$(find . -name "*.v") | cut -d: -f1) ; do \ sed -i.bak 's/From Corelib/From Coq/' $${f} ; \ sed -i.bak 's/PosDef/PArith/' $${f} ; \ diff --git a/reals/Makefile.coq.local b/reals/Makefile.coq.local index c6a0262c5..b757c395c 100644 --- a/reals/Makefile.coq.local +++ b/reals/Makefile.coq.local @@ -1,5 +1,5 @@ pre-all:: - if command -v coqc > /dev/null && (coqc --version | grep -q '8.18\|8.19\|8.20') ; then \ + if command -v coqc > /dev/null && (coqc --version | grep -q '8.20') ; then \ for f in $(shell grep "From Corelib" $$(find . -name "*.v") | cut -d: -f1) ; do \ sed -i.bak 's/From Corelib/From Coq/' $${f} ; \ sed -i.bak 's/PosDef/PArith/' $${f} ; \ diff --git a/reals/constructive_ereal.v b/reals/constructive_ereal.v index f1ca3fa3e..323de8133 100644 --- a/reals/constructive_ereal.v +++ b/reals/constructive_ereal.v @@ -33,6 +33,7 @@ From mathcomp Require Import mathcomp_extra interval_inference. (* | `r%:E` |==| injects real numbers into `\bar R` | *) (* | `+%E, -%E, *%E` |==| addition/opposite/multiplication for | *) (* | | | extended reals | *) +(* | `x^-1`, `x / y` |==| inverse and division for extended reals | *) (* | `er_map (f : T -> T')` |==| the `\bar T -> \bar T'` lifting of `f` | *) (* | `sqrte` |==| square root for extended reals | *) (* | `` `\| x \|%E `` |==| the absolute value of `x` | *) @@ -46,6 +47,7 @@ From mathcomp Require Import mathcomp_extra interval_inference. (* | | | nor $-\infty + \infty$ | *) (* | `x *? y` |==| the multiplication of `x` and `y` is not | *) (* | | | of the form $0 * +\infty$ or $0 * -\infty$ | *) +(* | `x *^-1? y` |==| the inverse commutes with the product | *) (* | `(_ <= _)%E`, `(_ < _)%E`,|==| comparison relations for extended reals | *) (* | `(_ >= _)%E`, `(_ > _)%E` | | | *) (* | `(\sum_(i in A) f i)%E`|==| bigop-like notation in scope `%E` | *) @@ -59,6 +61,7 @@ From mathcomp Require Import mathcomp_extra interval_inference. (* r%:E == injects real numbers into \bar R *) (* +%E, -%E, *%E == addition/opposite/multiplication for extended *) (* reals *) +(* x^-1, x / y == inverse and division for extended reals *) (* er_map (f : T -> T') == the \bar T -> \bar T' lifting of f *) (* sqrte == square root for extended reals *) (* `| x |%E == the absolute value of x *) @@ -72,6 +75,7 @@ From mathcomp Require Import mathcomp_extra interval_inference. (* nor -oo + oo *) (* x *? y == the multiplication of the extended real numbers *) (* x and y is not of the form 0 * +oo or 0 * -oo *) +(* x *^-1? y == the inverse commutes with the product *) (* (_ <= _)%E, (_ < _)%E, == comparison relations for extended reals *) (* (_ >= _)%E, (_ > _)%E *) (* (\sum_(i in A) f i)%E == bigop-like notation in scope %E *) @@ -531,6 +535,8 @@ Implicit Types x y z : \bar R. Definition mule x y := match x, y with | x%:E , y%:E => (x * y)%:E + | +oo, +oo | -oo, -oo => +oo + | +oo, -oo | -oo, +oo => -oo | -oo, y | y, -oo => if y == 0 then 0 else if 0 < y then -oo else +oo | +oo, y | y, +oo => if y == 0 then 0 else if 0 < y then +oo else -oo end. @@ -538,10 +544,19 @@ Arguments mule : simpl never. Definition abse x : \bar R := if x is r%:E then `|r|%:E else +oo. +Definition inve x := + match x with + | x%:E => if x == 0%R then +oo else (x^-1)%:E + | +oo => 0 + | -oo => -oo + end. +Arguments inve : simpl never. + Definition expe x n := iterop n mule x 1. End ERealArith. Arguments mule : simpl never. +Arguments inve : simpl never. Notation "+%dE" := (@GRing.add (\bar^d _)). Notation "+%E" := (@GRing.add (\bar _)). @@ -557,6 +572,10 @@ Notation "x * y" := (mule x%dE y%dE : \bar^d _) : ereal_dual_scope. Notation "x * y" := (mule x%E y%E) : ereal_scope. Notation "`| x |" := (abse x%dE : \bar^d _) : ereal_dual_scope. Notation "`| x |" := (abse x%E) : ereal_scope. +Notation "x ^-1" := (inve x%dE : \bar^d _) : ereal_dual_scope. +Notation "x ^-1" := (inve x) : ereal_scope. +Notation "x / y" := (mule x%dE (inve y%dE) : \bar^d _) : ereal_dual_scope. +Notation "x / y" := (mule x (inve y)) : ereal_scope. Arguments abse {R}. Notation "x ^+ n" := (expe x%dE n : \bar^d _) : ereal_dual_scope. Notation "x ^+ n" := (expe x%E n) : ereal_scope. @@ -707,9 +726,6 @@ Proof. by elim: n => //= n ->. Qed. Lemma enatmul_ninfty n : -oo *+ n.+1 = -oo :> \bar R. Proof. by elim: n => //= n ->. Qed. -Lemma EFin_natmul (r : R) n : (r *+ n)%:E = r%:E *+ n. -Proof. by case: n => //; elim => //= n <-. Qed. - Lemma mule2n x : x *+ 2 = x + x. Proof. by []. Qed. Lemma expe2 x : x ^+ 2 = x * x. Proof. by []. Qed. @@ -799,13 +815,16 @@ Lemma EFinB r r' : (r - r')%:E = r%:E - r'%:E. Proof. by []. Qed. Lemma EFinM r r' : (r * r')%:E = r%:E * r'%:E. Proof. by []. Qed. +Lemma EFin_natmul (r : R) n : (r *+ n)%:E = r%:E *+ n. +Proof. exact: raddfMn. Qed. + Lemma prodEFin T s (P : pred T) (f : T -> R) : \prod_(i <- s | P i) (f i)%:E = (\prod_(i <- s | P i) f i)%:E. Proof. by elim/big_ind2 : _ => // _ x _ y -> ->; rewrite EFinM. Qed. Lemma sumEFin I s P (F : I -> R) : \sum_(i <- s | P i) (F i)%:E = (\sum_(i <- s | P i) F i)%:E. -Proof. by rewrite (big_morph _ EFinD erefl). Qed. +Proof. exact/esym/raddf_sum. Qed. Lemma EFin_min : {morph (@EFin R) : r s / Num.min r s >-> Order.min r s}. Proof. by move=> x y; rewrite !minElt lte_fin -fun_if. Qed. @@ -940,32 +959,36 @@ Lemma EFin_expe r n : (r ^+ n)%:E = r%:E ^+ n. Proof. by elim: n => [//|n IHn]; rewrite exprS EFinM IHn expeS. Qed. Definition mule_def x y := - ~~ (((x == 0) && (`| y | == +oo)) || ((y == 0) && (`| x | == +oo))). - + match x, y with + | _%:E, _%:E | +oo, +oo | -oo, -oo | +oo, -oo | -oo, +oo => true + | r%:E, _ | _, r%:E => (r != 0%R) + end. +Arguments mule_def : simpl never. Local Notation "x *? y" := (mule_def x y). +Definition mule_defE x y : x *? y = + ~~ (((x == 0) && (`| y | == +oo)) || ((y == 0) && (`| x | == +oo))). +Proof. +by rewrite /mule_def; case: x => [r||]; case: y => [s||]//=; + rewrite ?(andbF, orbF, eqxx, andbT). +Qed. + Lemma mule_defC x y : x *? y = y *? x. -Proof. by rewrite [in LHS]/mule_def orbC. Qed. +Proof. by rewrite !mule_defE orbC. Qed. Lemma mule_def_fin x y : x \is a fin_num -> y \is a fin_num -> x *? y. -Proof. -move: x y => [x| |] [y| |] finx finy//. -by rewrite /mule_def negb_or 2!negb_and/= 2!orbT. -Qed. +Proof. by case: x y => [r||] [s||]. Qed. Lemma mule_def_neq0_infty x y : x != 0 -> y \isn't a fin_num -> x *? y. -Proof. by move: x y => [x| |] [y| |]// x0 _; rewrite /mule_def (negbTE x0). Qed. +Proof. by case: x y => [?||] [?||]. Qed. -Lemma mule_def_infty_neq0 x y : x \isn't a fin_num -> y!= 0 -> x *? y. -Proof. by move: x y => [x| |] [y| |]// _ y0; rewrite /mule_def (negbTE y0). Qed. +Lemma mule_def_infty_neq0 x y : x \isn't a fin_num -> y != 0 -> x *? y. +Proof. by case: x y => [?||] [?||]. Qed. Lemma neq0_mule_def x y : x * y != 0 -> x *? y. Proof. -move: x y => [x| |] [y| |] //; first by rewrite mule_def_fin. -- by have [->|?] := eqVneq x 0%R; rewrite ?mul0e ?eqxx// mule_def_neq0_infty. -- by have [->|?] := eqVneq x 0%R; rewrite ?mul0e ?eqxx// mule_def_neq0_infty. -- by have [->|?] := eqVneq y 0%R; rewrite ?mule0 ?eqxx// mule_def_infty_neq0. -- by have [->|?] := eqVneq y 0%R; rewrite ?mule0 ?eqxx// mule_def_infty_neq0. +by move: x y => [x| |] [y| |] //=; + apply: contra_neq => -> //=; rewrite (mule0, mul0e). Qed. Lemma ltpinfty_adde_def : {in [pred x | x < +oo] &, forall x y, x +? y}. @@ -1180,15 +1203,6 @@ move=> fio; apply/idP/existsP => [/eqP /=|[/= i /andP[Pi /eqP fi]]]. by apply/eqP/esum_eqyP => //; exists i. Qed. -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed `esum_eqNyP`")] -Notation esum_ninftyP := esum_eqNyP (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed `esum_eqNy`")] -Notation esum_ninfty := esum_eqNy (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed `esum_eqyP`")] -Notation esum_pinftyP := esum_eqyP (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed `esum_eqy`")] -Notation esum_pinfty := esum_eqy (only parsing). - Lemma adde_ge0 x y : 0 <= x -> 0 <= y -> 0 <= x + y. Proof. by move: x y => [r0| |] [r1| |] // ? ?; rewrite !lee_fin addr_ge0. Qed. @@ -1220,11 +1234,11 @@ Lemma sume_le0 T (f : T -> \bar R) (P : pred T) : (forall t, P t -> f t <= 0) -> forall l, \sum_(i <- l | P i) f i <= 0. Proof. by move=> f0 l; elim/big_rec : _ => // t x Pt; apply/adde_le0/f0. Qed. -Lemma mulNyy : -oo * +oo = -oo :> \bar R. Proof. by rewrite /mule /= lt0y. Qed. +Lemma mulNyy : -oo * +oo = -oo :> \bar R. Proof. by []. Qed. -Lemma mulyNy : +oo * -oo = -oo :> \bar R. Proof. by rewrite muleC mulNyy. Qed. +Lemma mulyNy : +oo * -oo = -oo :> \bar R. Proof. by []. Qed. -Lemma mulyy : +oo * +oo = +oo :> \bar R. Proof. by rewrite /mule /= lt0y. Qed. +Lemma mulyy : +oo * +oo = +oo :> \bar R. Proof. by []. Qed. Lemma mulNyNy : -oo * -oo = +oo :> \bar R. Proof. by []. Qed. @@ -1307,7 +1321,6 @@ move: x y => [x| |] [y| |] //; rewrite /mule/= ?(lee_fin, lte_fin). - by move=> x0 _; case: ifP => _ //; rewrite lt_leAnge /= x0 andbF leNy0. - move=> _; rewrite le_eqVlt => /predU1P[<-|->]; first by rewrite eqxx. by case: ifP => _ //; rewrite leNy0. -- by rewrite lt0y leNy0. Qed. Lemma mule_ge0_le0 x y : 0 <= x -> y <= 0 -> x * y <= 0. @@ -1347,18 +1360,14 @@ Proof. by case: x => [x //||//]; rewrite /= real0 /Order.comparable le0y. Qed. Lemma real_muleN (x y : \bar R) : (0 >=< x)%O -> (0 >=< y)%O -> x * - y = - (x * y). Proof. -rewrite !real_fine; case: x y => [x||] [y||] /= xr yr; rewrite /mule/=. +rewrite !real_fine; case: x y => [x||] [y||] /= xr yr; rewrite /mule//=. - by rewrite mulrN. - by case: ifP; rewrite ?oppe0//; case: ifP. - by case: ifP; rewrite ?oppe0//; case: ifP. - rewrite EFinN oppe_eq0; case: ifP; rewrite ?oppe0// oppe_gt0 !lte_fin. by case: (real_ltgtP xr yr) => // <-; rewrite eqxx. -- by case: ifP. -- by case: ifP. - rewrite EFinN oppe_eq0; case: ifP; rewrite ?oppe0// oppe_gt0 !lte_fin. by case: (real_ltgtP xr yr) => // <-; rewrite eqxx. -- by rewrite lt0y. -- by rewrite lt0y. Qed. Lemma real_mulNe (x y : \bar R) : (0 >=< x)%O -> (0 >=< y)%O -> @@ -1394,6 +1403,15 @@ Qed. Lemma lte0_abs x : x < 0 -> `|x| = - x. Proof. by move=> /ltW/lee0_abs. Qed. +Lemma expe_eq0 x n : (x ^+ n == 0) = (n > 0)%N && (x == 0). +Proof. by elim: n => [|n ih]; rewrite ?expeS ?mule_eq0 ?ih ?andKb// gt_eqF. Qed. + +Lemma expe_gt0 x n : 0 < x -> 0 < x ^+ n. +Proof. by elim: n => //n ih /[dup] /ih xn0 x0; rewrite expeS mule_gt0. Qed. + +Lemma expe_ge0 x n : 0 <= x -> 0 <= x ^+ n. +Proof. by elim: n => // n ih x0; rewrite expeS mule_ge0// ih. Qed. + End ERealArithTh_numDomainType. Notation "x +? y" := (adde_def x%dE y%dE) : ereal_dual_scope. Notation "x +? y" := (adde_def x y) : ereal_scope. @@ -1849,11 +1867,9 @@ move: x y => [x| |] [y| |]; rewrite ?(lte_fin,andbF,andbT,orbF,eqxx,andbT)//=. move=> ->; rewrite ?(mulN1e,mul1e,sgr0,mul0e). - by rewrite mulr_infty; have [/ltr0_sg|/gtr0_sg|] := ltgtP y 0%R; move=> ->; rewrite ?(mulN1e,mul1e,sgr0,mul0e). -- by rewrite mulyy ltry. -- by rewrite mulyNy. +- by rewrite ltry. - by rewrite mulr_infty; have [/ltr0_sg|/gtr0_sg|] := ltgtP y 0%R; move=> ->; rewrite ?(mulN1e,mul1e,sgr0,mul0e). -- by rewrite mulNyy. - by rewrite ltNyr. Qed. @@ -2323,17 +2339,14 @@ rewrite /mule/=; move: x y z => [r| |] [s| |] [t| |] //= s0 t0. + rewrite lte_fin -[in LHS](addr0 0%R) ltr_leD // lte_fin s0. by case: ltgtP t0 => // [t0|[<-{t}]] _; [rewrite gt_eqF|rewrite eqxx]. + by move: t0; rewrite lee_fin; case: (ltgtP t). -- by rewrite ltry; case: ltgtP s0. -- by rewrite ltry; case: ltgtP t0. -- by rewrite ltry. +- by case: ltgtP s0. +- by case: ltgtP t0. - rewrite !eqe paddr_eq0 //; move: s0; rewrite lee_fin. case: (ltgtP s) => //= [s0|->{s}] _; rewrite ?add0e. + rewrite lte_fin -[in LHS](addr0 0%R) ltr_leD // lte_fin s0. by case: ltgtP t0 => // [t0|[<-{t}]]. + by move: t0; rewrite lee_fin; case: (ltgtP t). -- by rewrite ltry; case: ltgtP s0. -- by rewrite ltry; case: ltgtP s0. -- by rewrite ltry; case: ltgtP s0. +- by case: ltgtP s0. Qed. Lemma ge0_muleDr x y z : 0 <= y -> 0 <= z -> x * (y + z) = x * y + x * z. @@ -2351,9 +2364,7 @@ rewrite /mule/=; move: x y z => [r| |] [s| |] [t| |] //= s0 t0. + rewrite !lte_fin -[in LHS](addr0 0%R) ltNge lerD // ?ltW //=. by rewrite !ltNge ltW //. + by case: (ltgtP t). -- by rewrite ltry; case: ltgtP s0. -- by rewrite ltry; case: ltgtP t0. -- by rewrite ltry. +- by case: ltgtP s0. - rewrite !eqe naddr_eq0 //; move: s0; rewrite lee_fin. case: (ltgtP s) => //= [s0|->{s}] _; rewrite ?add0e. + rewrite !lte_fin -[in LHS](addr0 0%R) ltNge lerD // ?ltW //=. @@ -2366,6 +2377,81 @@ Qed. Lemma le0_muleDr x y z : y <= 0 -> z <= 0 -> x * (y + z) = x * y + x * z. Proof. by move=> y0 z0; rewrite !(muleC x) le0_muleDl. Qed. +Lemma inver r : r%:E^-1 = if r == 0%R then +oo else r^-1%R%:E. +Proof. by []. Qed. + +Variant inve_spec : \bar R -> \bar R -> Type := +| InveZero : inve_spec 0 +oo +| InvePInfty : inve_spec +oo 0 +| InveNInfty : inve_spec -oo -oo +| InveNZero r : r != 0%R -> inve_spec r%:E r^-1%:E. + +Lemma inveP x : inve_spec x x^-1. +Proof. +rewrite /inve; case: x => [r||]/=; do ?by constructor. +by case: eqVneq => // [->|]; constructor. +Qed. + +Lemma fine_invr r : fine r%:E^-1 = r^-1%R. +Proof. by rewrite inver; case: eqP => //= ->; rewrite invr0. Qed. + +Lemma inve0 : 0^-1 = +oo :> \bar R. Proof. by rewrite inver eqxx. Qed. +Lemma inve1 : 1^-1 = 1 :> \bar R. Proof. by rewrite inver oner_eq0 invr1. Qed. +Lemma invey : +oo^-1 = 0 :> \bar R. Proof. by []. Qed. +Lemma inveNy : -oo^-1 = -oo :> \bar R. Proof. by []. Qed. + +Lemma inveK : involutive (inve : \bar R -> \bar R). +Proof. +move=> x; case: (inveP x); rewrite ?inve0//= => r r_neq0. +by rewrite inver invr_eq0 (negPf r_neq0) invrK. +Qed. + +Lemma invr_inj : injective (inve : \bar R -> \bar R). +Proof. exact: can_inj inveK. Qed. + +Lemma inveN x : x \is a fin_num -> x != 0 -> (- x)^-1 = - x^-1. +Proof. +case: (inveP x); rewrite ?eqxx//= => r r_neq0 _ _; rewrite EFinN. +by rewrite -invrN// inver oppr_eq0 (negPf r_neq0). +Qed. + +Lemma inve_eq0 x : (x^-1 == 0) = (x == +oo). +Proof. by case: inveP; rewrite ?eqxx //= => r /negPf; rewrite eqe invr_eq0. Qed. + +Lemma inve_ge0 x : (0 <= x^-1) = (0 <= x). +Proof. +by case: inveP; rewrite ?le0y ?lexx //= => r; rewrite lee_fin invr_ge0. +Qed. + +Lemma inve_gt0 x : x != 0 -> x != +oo -> (0 < x^-1) = (0 < x). +Proof. +rewrite !lt_def inve_eq0 inve_ge0. +by case: leP => /[!(andbT, andbF)]//= _ -> ->. +Qed. + +Lemma inve_gt0P x : reflect ((0 < x^-1) = (0 < x)) ((x != 0) && (x != +oo)). +Proof. +apply/(iffP idP); first by move=> /andP[]; exact:inve_gt0. +case: eqP => [->|x0]; first by rewrite inve0 lt0y ltxx. +by case: eqP => [->|xy]; first by rewrite invey ltxx lt0y. +Qed. + +Lemma inve_le0P x : reflect ((x^-1 <= 0) = (x <= 0)) ((x != 0) && (x != +oo)). +Proof. +by rewrite !leNgt; apply/(iffP idP)=> [/inve_gt0P->|/negb_inj /inve_gt0P]. +Qed. + +Lemma inve_le0 x : x != 0 -> x != +oo -> (x^-1 <= 0) = (x <= 0). +Proof. by move=> xN0 xNy; rewrite !leNgt inve_gt0. Qed. + +Lemma inve_lt0 x : (x^-1 < 0) = (x < 0). +Proof. by rewrite !ltNge inve_ge0. Qed. + +Lemma fin_numV x : x != 0 -> x != -oo -> x^-1 \is a fin_num. +Proof. +by move: x => [x| |]//; rewrite eqe => x0 _; rewrite inver (negbTE x0). +Qed. + Lemma gee_pMl y x : y \is a fin_num -> 0 <= x -> y <= 1 -> y * x <= x. Proof. move=> yfin; rewrite le_eqVlt => /predU1P[<-|]; first by rewrite mule0. @@ -2392,7 +2478,6 @@ move=> [y| |] [z| |]//. by rewrite mulr_infty ltr0_sg// mulN1e leNye. + by move=> _; rewrite mulyy leey. + by move=> _; rewrite mulNyy leNye. - + by move=> _; rewrite mulNyy leNye. Qed. Lemma lee_wpmul2l x : 0 <= x -> {homo *%E x : y z / y <= z}. @@ -2495,11 +2580,7 @@ have xoo r : `|r%:E * +oo| = `|r|%:E * +oo. move=> [x| |] [y| |] //=; first by rewrite normrM. - by rewrite -abseN -muleNN abseN -EFinN xoo normrN. - by rewrite muleC xoo muleC. -- by rewrite mulyy. -- by rewrite mulyy mulyNy. - by rewrite -abseN -muleNN abseN -EFinN xoo normrN. -- by rewrite mulyy mulNyy. -- by rewrite mulyy. Qed. Lemma fine_max : @@ -2509,6 +2590,11 @@ by move=> [x| |] [y| |]//= _ _; apply/esym; have [ab|ba] := leP x y; [apply/max_idPr; rewrite lee_fin|apply/max_idPl; rewrite lee_fin ltW]. Qed. +Lemma EFin_bigmax {I : Type} (s : seq I) (P : I -> bool) (F : I -> R) r : + \big[maxe/r%:E]_(i <- s | P i) (F i)%:E = + (\big[Num.max/r]_(i <- s | P i) F i)%:E. +Proof. by rewrite (big_morph _ EFin_max erefl). Qed. + Lemma fine_min : {in fin_num &, {mono @fine R : x y / mine x y >-> (Num.min x y)%:E}}. Proof. @@ -2595,7 +2681,7 @@ Qed. Lemma lee_pemull x y : 0 <= y -> 1 <= x -> y <= x * y. Proof. -move: x y => [x| |] [y| |] //; last by rewrite mulyy. +move: x y => [x| |] [y| |] //. - by rewrite -EFinM 3!lee_fin; exact: ler_peMl. - move=> _; rewrite lee_fin => x1. by rewrite mulr_infty gtr0_sg ?mul1e// (lt_le_trans _ x1). @@ -2605,7 +2691,7 @@ Qed. Lemma lee_nemull x y : y <= 0 -> 1 <= x -> x * y <= y. Proof. -move: x y => [x| |] [y| |] //; last by rewrite mulyNy. +move: x y => [x| |] [y| |] //. - by rewrite -EFinM 3!lee_fin; exact: ler_neMl. - move=> _; rewrite lee_fin => x1. by rewrite mulr_infty gtr0_sg ?mul1e// (lt_le_trans _ x1). @@ -3282,6 +3368,116 @@ Variable R : realFieldType. Implicit Types x y : \bar R. Implicit Types r : R. +Definition inveM_def x y := + match x, y with + | r%:E, s%:E => [&& (r == 0) ==> (s >= 0) & (s == 0) ==> (r >= 0)]%R + | +oo, +oo => true + | -oo, -oo | +oo, -oo | -oo, +oo => false + | r%:E, +oo | +oo, r%:E => (r > 0)%R + | r%:E, -oo | -oo, r%:E => (r > 0)%R + end. +Arguments inveM_def : simpl never. + +Notation "x *^-1? y" := (inveM_def x y) + (format "x *^-1? y", at level 50) : ereal_scope. + +Lemma inveM_defE x y : (x *^-1? y) = + [&& (x == 0) ==> (0 <= y < +oo), + (y == 0) ==> (0 <= x < +oo), + (`|x| == +oo) ==> (y > 0) & + (`|y| == +oo) ==> (x > 0)]. +Proof. +rewrite /inveM_def; case: x y => [r||]//= [s||]//=; +by rewrite ?eqe ?ltry ?ltxx ?andbT// lte_fin; case: ltgtP; rewrite //= andbF. +Qed. + +Lemma inveMP x y : reflect ((x * y)^-1 = x^-1 * y^-1) (x *^-1? y). +Proof. +rewrite /inveM_def. +case: (inveP x) => [|||r rN0]; case: (inveP y) => [|||s sN0]//=; +rewrite ?(eqxx, lexx, ltxx, mule0, mul0e, mulyy, inve0, invey)//=; + do ?by constructor. +- by rewrite mulyr sgrV implybT andbT; case: sgrP sN0 => //=; + rewrite (mulN1e, mul1e); constructor. +- by rewrite mulyr; case: sgrP sN0 => //=; + rewrite (mulN1e, mul1e); constructor. +- by rewrite !mulNyr sgrV; case: sgrP sN0 => //=; + rewrite (mulN1e, mul1e); constructor. +- by rewrite mulry sgrV implybT andTb; case: sgrP rN0 => //=; + rewrite (mulN1e, mul1e); constructor. +- by rewrite mulry; case: sgrP rN0 => //=; + rewrite (mulN1e, mul1e); constructor. +- by rewrite mulrNy [RHS]mulrNy sgrV; case: sgrP rN0 => //=; + rewrite (mulN1e, mul1e); constructor. +- by rewrite !inver invfM EFinM mulf_eq0 (negPf rN0) (negPf sN0); + constructor. +Qed. + +Lemma inveM x y : x *^-1? y -> (x * y)^-1 = x^-1 * y^-1. +Proof. by move/inveMP. Qed. + +Lemma fin_inveM_def x y : x != 0 -> y != 0 -> + x \is a fin_num -> y \is a fin_num -> x *^-1? y. +Proof. +by rewrite /inveM_def/=; case: x y => [r||]//= [s||]//= /[!eqe]/negPf-> /negPf->. +Qed. + +Lemma mulVe x : x != 0 -> x \is a fin_num -> x^-1 * x = 1. +Proof. +move: x => [||]// r; rewrite eqe => r0 _. +by rewrite inver (negbTE r0) -EFinM mulVf. +Qed. + +Local Notation nonneg := [pred x : \bar R | x >= 0]. + +Lemma lee_pV2 : {in nonneg &, {mono inve : x y /~ x <= y}}. +Proof. +move=> x y; case: (inveP x) => [|||r]; case: (inveP y) => [|||s]//=; +rewrite ?inE ?lexx// ?lee_fin. +- by case: (ltgtP s). +- by case: (ltgtP s) => //= s_gt0 _ _ _; rewrite invr_ge0 (ltW s_gt0) leey. +- by case: (ltgtP r) => //= r_gt0; rewrite leey. +- by case: (ltgtP r) => //= r_gt0 _ _ _; rewrite invr_le0 (lt_geF). +by case: (ltgtP s 0%R); case: (ltgtP r 0%R) => // *; rewrite lef_pV2. +Qed. + +Lemma lte_pV2 : {in nonneg &, {mono inve : x y /~ x < y}}. +Proof. exact: leW_nmono_in lee_pV2. Qed. + +Definition ltee_pV2 := (lee_pV2, lte_pV2). + +Lemma inve_pge : {in nonneg &, forall x y, (x <= y^-1) = (y <= x^-1)}. +Proof. +move=> x y /[!inE]; case: (inveP x) => [|||r]; rewrite ?lee_fin ?ltxx//=. +- move=> _; case: (inveP y) => [|||s]; rewrite ?lexx//= lee_fin => ? s_ge0. + by rewrite lee_fin invr_ge0 s_ge0 leey. +- move=> _; case: (inveP y) => [|||s]; rewrite ?lexx//= lee_fin => sN0 s_ge0. + by rewrite lee_fin [RHS]lt_geF// lt_def sN0. +case: ltgtP => // r_gt0 _ _. +case: (inveP y) => [|||s sN0]; rewrite ?ltxx//= ?lte_fin ?lee_fin. +- by rewrite leey invr_ge0 (ltW r_gt0). +- by rewrite [LHS]lt_geF. +by case: ltgtP sN0 => // s_gt0; rewrite -lef_pV2 ?qualifE/= ?invr_gt0// invrK. +Qed. + +Lemma inve_pgt : {in nonneg &, forall x y, (x < y^-1) = (y < x^-1)}. +Proof. +move=> x y /[!inE] sgt0 ygt0; rewrite !lt_def inve_pge//. +by rewrite (can2_eq inveK inveK) eq_sym. +Qed. + +Lemma inve_ple : {in nonneg &, forall x y, (x^-1 <= y) = (y^-1 <= x)}. +Proof. by move=> x y ? ?; rewrite -lee_pV2 ?inveK// inE inve_ge0. Qed. + +Lemma inve_plt : {in nonneg &, forall x y, (x^-1 < y) = (y^-1 < x)}. +Proof. by move=> x y ? ?; rewrite -lte_pV2 ?inveK// inE inve_ge0. Qed. + +Lemma inve_gt1 x : 0 <= x -> (1 < x^-1) = (x < 1). +Proof. by move=> x0; rewrite inve_pgt ?inve1//= inE/= ?lee01. Qed. + +Lemma inve_ge1 x : 0 <= x -> (1 <= x^-1) = (x <= 1). +Proof. by move=> x0; rewrite inve_pge ?inve1//= inE/= ?lee01. Qed. + Lemma lee_addgt0Pr x y : reflect (forall e, (0 < e)%R -> x <= y + e%:E) (x <= y). Proof. @@ -3316,8 +3512,8 @@ move: x y => [x||] [y||] // in x0 h *. by rewrite -lte_fin (lt_le_trans _ (h _ h01))// mule_gt0// lte_fin. rewrite lee_fin leNgt; apply/negP => yx. have /h : (0 < (y + x) / (2 * x) < 1)%R. - apply/andP; split; first by rewrite divr_gt0 // ?addr_gt0// ?mulr_gt0. - by rewrite ltr_pdivrMr ?mulr_gt0// mul1r mulr_natl mulr2n ltrD2r. + rewrite ltr_pdivlMr ?ltr_pdivrMr ?mulr_gt0// mul0r mul1r. + by rewrite mulr_natl mulr2n ltrD2r yx addr_gt0. rewrite -(EFinM _ x) lee_fin invrM ?unitfE// ?gt_eqF// -mulrA mulrAC. by rewrite mulVr ?unitfE ?gt_eqF// mul1r; apply/negP; rewrite -ltNge midf_lt. - by rewrite leey. @@ -3515,8 +3711,7 @@ case: x y => [x||] [y||] //= age0. + by rewrite sqrtr0 sgr0 mul0e sqrte0. + by rewrite mul1e/= -sqrtr_gt0 -sgr_gt0 -lte_fin => /gt0_muley->. + by move=> y0; rewrite EFinN mulN1e/= ltr0_sqrtr// sgr0 mul0e. -- by rewrite mulyy. -- by rewrite mulyNy mule0. +- by rewrite mule0. Qed. Lemma sqr_sqrte x : 0 <= x -> sqrte x ^+ 2 = x. @@ -4354,7 +4549,7 @@ wlog : r r1 r_pneq0 r_nneq0 / (0 <= r)%R => wlog_r0. rewrite /contract !ger0_norm //; last first. by rewrite divr_ge0 // subr_ge0 (le_trans _ (ltW r1)) // ler_norm. apply: (@mulIr _ (1 + r / (1 - r))%R); first by rewrite unitfE. -rewrite -(mulrA (r / _)) mulVr ?unitfE // mulr1. +rewrite -(mulrA (r / _)%R) mulVr ?unitfE // mulr1. rewrite -[X in (X + _ / _)%R](@divrr _ (1 - r)%R) -?mulrDl ?subrK ?div1r //. by rewrite unitfE subr_eq0 eq_sym lt_eqF // ltr_normlW. Qed. diff --git a/theories/Make b/theories/Make index ab6dede6e..9b1e8967c 100644 --- a/theories/Make +++ b/theories/Make @@ -35,6 +35,7 @@ homotopy_theory/homotopy.v homotopy_theory/wedge_sigT.v homotopy_theory/continuous_path.v +ess_sup_inf.v function_spaces.v cantor.v tvs.v @@ -63,7 +64,7 @@ numfun.v lebesgue_integral_theory/simple_functions.v lebesgue_integral_theory/lebesgue_integral_definition.v -lebesgue_integral_theory/lebesgue_integral_approximation.v +lebesgue_integral_theory/measurable_fun_approximation.v lebesgue_integral_theory/lebesgue_integral_monotone_convergence.v lebesgue_integral_theory/lebesgue_integral_nonneg.v lebesgue_integral_theory/lebesgue_integrable.v @@ -85,3 +86,4 @@ pi_irrational.v gauss_integral.v all_analysis.v showcase/summability.v +showcase/gauss_integral_unbounded.v \ No newline at end of file diff --git a/theories/charge.v b/theories/charge.v index 8cdeda7e8..8416f0ae4 100644 --- a/theories/charge.v +++ b/theories/charge.v @@ -1405,12 +1405,12 @@ Lemma measurable_is_max_approxRN m j : measurable (E m j). Proof. rewrite is_max_approxRNE; apply: measurableI => /=. rewrite -[X in measurable X]setTI. - by apply: emeasurable_fun_eq => //; [exact: measurable_max_approxRN_seq| - exact: measurable_approxRN_seq]. + by apply: measurable_eqe => //; [exact: measurable_max_approxRN_seq| + exact: measurable_approxRN_seq]. rewrite [T in measurable T](_ : _ = \bigcap_(k in `I_j) [set x | g_ k x < g_ j x])//. apply: bigcap_measurableType => k _. -by rewrite -[X in measurable X]setTI; apply: emeasurable_fun_lt => //; +by rewrite -[X in measurable X]setTI; apply: measurable_lte => //; exact: measurable_approxRN_seq. Qed. @@ -1543,7 +1543,7 @@ have cvgM : (M - m.+1%:R^-1%:E) @[m --> \oo] --> M. + by rewrite fin_num_adde_defl. + exact: cvg_cst. + apply/fine_cvgP; split; first exact: nearW. - rewrite [X in X @ _ --> _](_ : _ = (fun x => x.+1%:R^-1))//. + rewrite [X in X @ _ --> _](_ : _ = (fun x => x.+1%:R^-1)%R)//. apply/gtr0_cvgV0; first exact: nearW. apply/cvgrnyP. rewrite [X in X @ _](_ : _ = fun n => n + 1)%N; first exact: cvg_addnr. @@ -1567,9 +1567,9 @@ have [muA0|] := eqVneq (mu A) 0. move=> x _; rewrite -(@gee0_abs _ (_ + _)); last first. by rewrite adde_ge0 ?fRN_ge0. over. - rewrite (@integral_abs_eq0 _ _ _ _ setT)//. + rewrite integral_abs_eq0//. by rewrite (le_lt_trans _ h)// integral_ge0// => x Ax; exact: fRN_ge0. - by apply: emeasurable_funD => //; exact: measurable_fun_fRN. + by apply: emeasurable_funD => //; exact: measurable_funS measurable_fun_fRN. rewrite neq_lt ltNge measure_ge0//= => muA_gt0. pose mid := ((fine (nu A) - fine (\int[mu]_(x in A) fRN x)) / 2)%R. pose e := (mid / fine (mu A))%R. @@ -2100,13 +2100,15 @@ Proof. move=> mE mf; rewrite [in RHS](funeposneg f) integralB //; last 2 first. - exact: integrable_funepos. - exact: integrable_funeneg. -rewrite -(ae_eq_integral _ _ _ _ _ - (ae_eq_mul2l f (ae_eq_Radon_Nikodym_SigmaFinite mE)))//; last 2 first. -- apply: emeasurable_funM => //; first exact: measurable_int mf. - apply: measurable_funTS. - exact: measurable_int (Radon_Nikodym_SigmaFinite.f_integrable _). -- apply: emeasurable_funM => //; first exact: measurable_int mf. - exact: measurable_funTS. +transitivity (\int[mu]_(x in E) (f x * Radon_Nikodym_SigmaFinite.f nu mu x)). + apply: ae_eq_integral => //. + - apply: emeasurable_funM => //; first exact: measurable_int mf. + exact: measurable_funTS. + - apply: emeasurable_funM => //; first exact: measurable_int mf. + apply: measurable_funTS. + exact: measurable_int (Radon_Nikodym_SigmaFinite.f_integrable _). + - apply: ae_eqe_mul2l. + exact/ae_eq_sym/ae_eq_Radon_Nikodym_SigmaFinite. rewrite [in LHS](funeposneg f). under [in LHS]eq_integral => x xE. rewrite muleBl; last 2 first. - exact: Radon_Nikodym_SigmaFinite.f_fin_num. diff --git a/theories/convex.v b/theories/convex.v index 871e5fd77..4894d1573 100644 --- a/theories/convex.v +++ b/theories/convex.v @@ -1,4 +1,4 @@ -(* mathcomp analysis (c) 2022 Inria and AIST. License: CeCILL-C. *) +(* mathcomp analysis (c) 2025 Inria and AIST. License: CeCILL-C. *) From mathcomp Require Import all_ssreflect ssralg ssrint ssrnum finmap. From mathcomp Require Import matrix interval zmodp vector fieldext falgebra. From mathcomp Require Import mathcomp_extra unstable boolp classical_sets. @@ -11,18 +11,23 @@ From HB Require Import structures. (* # Convexity *) (* *) (* This file provides a small account of convexity using convex spaces, to be *) -(* completed with material from infotheo. *) +(* completed with material from InfoTheo. *) (* *) (* ``` *) -(* isConvexSpace R T == interface for convex spaces *) -(* ConvexSpace R == structure of convex space *) -(* a <| t |> b == convexity operator *) +(* convex_quasi_associative == quasi-associativity of the operator of *) +(* convex spaces *) +(* isConvexSpace R T == interface for convex spaces with *) +(* R : numDomainType *) +(* The HB class is ConvexSpace. *) +(* a <| t |> b == convexity operator *) (* ``` *) (* *) -(* E : lmodType R with R : realDomainType and R : realDomainType are shown to *) -(* be convex spaces with the following aliases: *) -(* convex_lmodType E == E : lmodType T as a convex spaces *) -(* convex_realDomainType R == R : realDomainType as a convex space *) +(* For `R : numDomainType`, `E : lmodType R` and `R` itself are shown to be *) +(* convex spaces with the following aliases: *) +(* ``` *) +(* convex_lmodType E == E : lmodType R as a convex space *) +(* convex_numDomainType R == R : numDomainType as a convex space *) +(* ``` *) (* *) (******************************************************************************) @@ -42,18 +47,70 @@ Import numFieldNormedType.Exports. Declare Scope convex_scope. Local Open Scope convex_scope. -HB.mixin Record isConvexSpace (R : realDomainType) T := { +Module ConvexQuasiAssoc. +Section def. +Variables (R : numDomainType) (T : Type) (conv : {i01 R} -> T -> T -> T). + +Local Notation "x <| p |> y" := (conv p x y). + +Definition law := forall (p q r s : {i01 R}) (a b c : T), + p%:num = r%:num * s%:num -> + `1- (s%:num) = `1- (p%:num) * `1- (q%:num) -> + a <| p |> (b <| q |> c) = (a <| r |> b) <| s |> c. +End def. + +(** technical relations between the parameters of the quasi-associativity law *) +Section lemmas. + +Lemma pq_sr (R : comRingType) (p q r s : R) : + p = r * s -> + 1 - s = (1 - p) * (1 - q) -> + (1 - p) * q = s * (1 - r). +Proof. +move=> prs spq. +rewrite -[LHS]opprK -mulrN -[X in - X = _](addrK ((1 - p) * 1)). +rewrite -mulrDr (addrC _ 1) -spq mulr1 prs. +by rewrite !opprB addrC subrKA mulrDr mulr1 mulrN mulrC. +Qed. + +Lemma sE (R : ringType) (p q s : R) : + 1 - s = (1 - p) * (1 - q) -> + s = 1 - (1 - p) * (1 - q). +Proof. by move/eqP; rewrite subr_eq addrC -subr_eq => /eqP ->. Qed. + +Lemma qE (R : comUnitRingType) (p q r s : R) : + 1 - p \is a GRing.unit -> + p = r * s -> + 1 - s = (1 - p) * (1 - q) -> + q = (s * (1 - r)) / (1 - p). +Proof. +move=> p1unit /pq_sr /[apply] /(congr1 ( *%R (1 - p)^-1)). +by rewrite mulrA mulVr// mul1r mulrC. +Qed. + +Lemma rE (R : unitRingType) (p r s : R) : + s \is a GRing.unit -> p = r * s -> r = p / s. +Proof. +move=> sunit /(congr1 ( *%R^~ s^-1)) ->. +by rewrite -mulrA divrr// mulr1. +Qed. + +End lemmas. + +End ConvexQuasiAssoc. + +Definition convex_quasi_associative := ConvexQuasiAssoc.law. + +HB.mixin Record isConvexSpace (R : numDomainType) T := { conv : {i01 R} -> T -> T -> T ; - conv0 : forall a b, conv 0%:i01 a b = a ; + conv1 : forall a b, conv 1%:i01 a b = a ; convmm : forall (p : {i01 R}) a, conv p a a = a ; convC : forall (p : {i01 R}) a b, conv p a b = conv (1 - p%:inum)%:i01 b a; - convA : forall (p q r : {i01 R}) (a b c : T), - p%:inum * (`1-(q%:inum)) = (`1-(p%:inum * q%:inum)) * r%:inum -> - conv p a (conv q b c) = conv (p%:inum * q%:inum)%:i01 (conv r a b) c + convA : convex_quasi_associative conv }. #[short(type=convType)] -HB.structure Definition ConvexSpace (R : realDomainType) := +HB.structure Definition ConvexSpace (R : numDomainType) := {T of isConvexSpace R T & Choice T}. Notation "a <| p |> b" := (conv p a b) : convex_scope. @@ -62,102 +119,116 @@ Section convex_space_lemmas. Context R (A : convType R). Implicit Types a b : A. -Lemma conv1 a b : a <| 1%:i01 |> b = b. +Lemma conv0 a b : a <| 0%:i01 |> b = b. Proof. -rewrite convC/= [X in _ <| X |> _](_ : _ = 0%:i01) ?conv0//. -by apply/val_inj => /=; rewrite subrr. +rewrite convC/= [X in _ <| X |> _](_ : _ = 1%:i01) ?conv1//. +by apply/val_inj => /=; rewrite subr0. Qed. End convex_space_lemmas. Local Open Scope convex_scope. -Definition convex_lmodType {R : realDomainType} (E : lmodType R) : Type := E. +Definition convex_lmodType {R : numDomainType} (E : lmodType R) : Type := E. Section lmodType_convex_space. -Context {R : realDomainType} {E' : lmodType R}. +Context {R : numDomainType} {E' : lmodType R}. Implicit Type p q r : {i01 R}. Let E := convex_lmodType E'. -Let avg p (a b : E) := `1-(p%:inum) *: a + p%:inum *: b. +Let avg p (a b : E) := p%:inum *: a + `1-(p%:inum) *: b. -Let avg0 a b : avg 0%:i01 a b = a. -Proof. by rewrite /avg/= onem0 scale0r scale1r addr0. Qed. +Let avg1 a b : avg 1%:i01 a b = a. +Proof. by rewrite /avg/= onem1 scale0r scale1r addr0. Qed. Let avgI p x : avg p x x = x. -Proof. by rewrite /avg -scalerDl/= addrC add_onemK scale1r. Qed. +Proof. by rewrite /avg -scalerDl/= add_onemK scale1r. Qed. Let avgC p x y : avg p x y = avg (1 - (p%:inum))%:i01 y x. Proof. by rewrite /avg onemK addrC. Qed. -Let avgA p q r (a b c : E) : - p%:inum * (`1-(q%:inum)) = (`1-(p%:inum * q%:inum)) * r%:inum -> - avg p a (avg q b c) = avg (p%:inum * q%:inum)%:i01 (avg r a b) c. +Let avgA : convex_quasi_associative avg. Proof. -move=> pq; rewrite /avg. +move=> p q r s a b c prs spq; rewrite /avg. rewrite [in LHS]scalerDr [in LHS]addrA [in RHS]scalerDr; congr (_ + _ + _). -- rewrite scalerA; congr (_ *: _) => /=. - by rewrite mulrDr mulr1 mulrN -pq mulrBr mulr1 opprB addrA subrK. -- by rewrite 2!scalerA; congr (_ *: _). -- by rewrite scalerA. +- by rewrite scalerA mulrC prs. +- by rewrite !scalerA; congr *:%R; rewrite (ConvexQuasiAssoc.pq_sr prs). +- by rewrite scalerA spq. Qed. HB.instance Definition _ := Choice.on E. HB.instance Definition _ := - isConvexSpace.Build R E avg0 avgI avgC avgA. + isConvexSpace.Build R E avg1 avgI avgC avgA. End lmodType_convex_space. -Definition convex_realDomainType (R : realDomainType) : Type := R^o. +Definition convex_numDomainType (R : numDomainType) : Type := R^o. -Section realDomainType_convex_space. -Context {R : realDomainType}. +Section numDomainType_convex_space. +Context {R : numDomainType}. Implicit Types p q : {i01 R}. -Let E := @convex_realDomainType R. - Let avg p (a b : convex_lmodType R^o) := a <| p |> b. -Let avg0 a b : avg 0%:i01 a b = a. -Proof. by rewrite /avg conv0. Qed. +Let avg1 a b : avg 1%:i01 a b = a. +Proof. exact: conv1. Qed. Let avgI p x : avg p x x = x. -Proof. by rewrite /avg convmm. Qed. +Proof. exact: convmm. Qed. Let avgC p x y : avg p x y = avg (1 - (p%:inum))%:i01 y x. -Proof. by rewrite /avg convC. Qed. +Proof. exact: convC. Qed. -Let avgA p q r (a b c : R) : - p%:inum * (`1-(q%:inum)) = (`1-(p%:inum * q%:inum)) * r%:inum -> - avg p a (avg q b c) = avg (p%:inum * q%:inum)%:i01 (avg r a b) c. -Proof. by move=> h; rewrite /avg (convA _ _ r). Qed. +Let avgA : convex_quasi_associative avg. +Proof. exact: convA. Qed. HB.instance Definition _ := @isConvexSpace.Build R R^o - _ avg0 avgI avgC avgA. + _ avg1 avgI avgC avgA. -End realDomainType_convex_space. +End numDomainType_convex_space. -Section conv_realDomainType. -Context {R : realDomainType}. +Section conv_numDomainType. +Context {R : numDomainType}. -Lemma conv_gt0 (a b : R^o) (t : {i01 R}) : 0 < a -> 0 < b -> 0 < a <| t |> b. +Lemma convR_gt0 (a b : R^o) (t : {i01 R}) : 0 < a -> 0 < b -> 0 < a <| t |> b. Proof. move=> a0 b0. have [->|t0] := eqVneq t 0%:i01; first by rewrite conv0. have [->|t1] := eqVneq t 1%:i01; first by rewrite conv1. -rewrite addr_gt0// mulr_gt0//; last by rewrite lt_neqAle eq_sym t0/=. -by rewrite onem_gt0// lt_neqAle t1/=. +rewrite addr_gt0// mulr_gt0//; first by rewrite lt_neqAle eq_sym t0 ge0. +by rewrite subr_gt0 lt_neqAle t1 le1. Qed. -Lemma convRE (a b : R^o) (t : {i01 R}) : a <| t |> b = `1-(t%:inum) * a + t%:inum * b. +Lemma convRE (a b : R^o) (t : {i01 R}) : + a <| t |> b = t%:inum * a + `1-(t%:inum) * b. Proof. by []. Qed. -End conv_realDomainType. +Lemma convR_itv (a b : R^o) (t : {i01 R}) : a <= b -> a <| t |> b \in `[a, b]. +Proof. +move=> ab; rewrite convRE in_itv /=. +rewrite -{1}(subrKC a b). +rewrite mulrDr addrA -mulrDl. +rewrite subrKC mul1r. +rewrite lerDl mulr_ge0/=; [|by rewrite subr_ge0 le1|by rewrite subr_ge0]. +rewrite -[leRHS](convmm t b) convRE lerD//. +by rewrite ler_wpM2l. +Qed. + +Let convRCE (a b : R^o) (t : {i01 R}) : + a <| t |> b = `1-(t%:inum) * b + t%:inum * a. +Proof. by rewrite addrC convRE. Qed. + +Lemma convR_line_path (a b : R^o) (t : {i01 R}) : + a <| t |> b = line_path b a t%:num. +Proof. by rewrite convRCE. Qed. + +End conv_numDomainType. Definition convex_function (R : realType) (D : set R) (f : R -> R^o) := - forall (t : {i01 R}), {in D &, forall (x y : R^o), (f (x <| t |> y) <= f x <| t |> f y)%R}. + forall (t : {i01 R}), + {in D &, forall (x y : R^o), (f (x <| t |> y) <= f x <| t |> f y)%R}. (* TODO: generalize to convTypes once we have ordered convTypes (mathcomp 2) *) (* ref: http://www.math.wisc.edu/~nagel/convexity.pdf *) @@ -183,10 +254,10 @@ Qed. Let convexf_ptP : a < b -> (forall x, a <= x <= b -> 0 <= L x - f x) -> forall t, f (a <| t |> b) <= f a <| t |> f b. Proof. -move=> ab h t; set x := a <| t |> b; have /h : a <= x <= b. - by rewrite -(conv1 a b) -{1}(conv0 a b) /x !le_line_path//= ge0/=. +move=> ba h t; set x := a <| t |> b; have /h : a <= x <= b. + by have:= convR_itv t (ltW ba); rewrite in_itv/=. rewrite subr_ge0 => /le_trans; apply. -by rewrite LE// /x line_pathK ?lt_eqF// convC line_pathK ?gt_eqF. +by rewrite LE// /x {2}convC 2!convR_line_path !line_pathK//= ?(eq_sym b) lt_eqF. Qed. Hypothesis HDf : {in `]a, b[, forall x, derivable f x 1}. @@ -210,7 +281,8 @@ have [c2 Ic2 Hc2] : exists2 c2, x < c2 < b & (f b - f x) / (b - x) = 'D_1 f c2. have derivef z : z \in `]x, b[ -> is_derive z 1 f ('D_1 f z). by move=> zxb; apply/derivableP/xbf; exact: zxb. have [|z zxb fbfx] := MVT xb derivef. - apply/(derivable_oo_continuous_bnd_within (And3 xbf _ cvg_left))/cvg_at_right_filter. + apply/(derivable_oo_continuous_bnd_within (And3 xbf _ cvg_left)). + apply/cvg_at_right_filter. have := derivable_within_continuous HDf. rewrite continuous_open_subspace//. by apply; rewrite inE/= in_itv/= ax. @@ -221,7 +293,8 @@ have [c1 Ic1 Hc1] : exists2 c1, a < c1 < x & (f x - f a) / (x - a) = 'D_1 f c1. have derivef z : z \in `]a, x[ -> is_derive z 1 f ('D_1 f z). by move=> zax; apply /derivableP/axf. have [|z zax fxfa] := MVT ax derivef. - apply/(derivable_oo_continuous_bnd_within (And3 axf cvg_right _))/cvg_at_left_filter. + apply/(derivable_oo_continuous_bnd_within (And3 axf cvg_right _)). + apply/cvg_at_left_filter. have := derivable_within_continuous HDf. rewrite continuous_open_subspace//. by apply; rewrite inE/= in_itv/= ax. diff --git a/theories/derive.v b/theories/derive.v index a9afea403..e4449d526 100644 --- a/theories/derive.v +++ b/theories/derive.v @@ -59,8 +59,8 @@ Reserved Notation "''D_' v f" (at level 10, v, f at next level, format "''D_' v f"). Reserved Notation "''D_' v f c" (at level 10, v, f at next level, format "''D_' v f c"). (* printing *) -Reserved Notation "f ^` ()" (at level 8, format "f ^` ()"). -Reserved Notation "f ^` ( n )" (at level 8, format "f ^` ( n )"). +Reserved Notation "f ^` ()" (format "f ^` ()"). +Reserved Notation "f ^` ( n )" (format "f ^` ( n )"). Section Differential. Context {K : numDomainType} {V W : normedModType K}. @@ -1241,7 +1241,7 @@ move=> dfx; apply: DeriveDef; first exact: derivableZ. by rewrite deriveZ // derive_val. Qed. -Lemma derive_cst (k : R) (x v : V) : 'D_v (cst k) x = 0. +Lemma derive_cst (k : W) (x v : V) : 'D_v (cst k) x = 0. Proof. by rewrite derive_val. Qed. End Derive_lemmasVW. @@ -1322,9 +1322,11 @@ by rewrite deriveM // !derive_val. Qed. Global Instance is_deriveX f n x v (df : R) : - is_derive x v f df -> is_derive x v (f ^+ n.+1) ((n.+1%:R * f x ^+n) *: df). + is_derive x v f df -> is_derive x v (f ^+ n) ((n%:R * f x ^+ n.-1) *: df). Proof. -move=> dfx; elim: n => [|n ihn]; first by rewrite expr1 expr0 mulr1 scale1r. +case: n => [fdf|n dfx]. + by rewrite expr0 mul0r scale0r; exact: is_derive_cst. +elim: n => [|n ihn]; first by rewrite expr1 expr0 mulr1 scale1r. rewrite exprS; apply: is_derive_eq. rewrite scalerA -scalerDl mulrCA -[f x * _]exprS. by rewrite [in LHS]mulr_natl exprfctE -mulrSr mulr_natl. @@ -1334,7 +1336,7 @@ Lemma derivableX f n x v : derivable f x v -> derivable (f ^+ n) x v. Proof. by case: n => [_|n /derivableP]; [rewrite expr0|]. Qed. Lemma deriveX f n x v : derivable f x v -> - 'D_v (f ^+ n.+1) x = (n.+1%:R * f x ^+ n) *: 'D_v f x. + 'D_v (f ^+ n) x = (n%:R * f x ^+ n.-1) *: 'D_v f x. Proof. by move=> /derivableP df; rewrite derive_val. Qed. Fact der_inv f x v : f x != 0 -> derivable f x v -> @@ -1389,7 +1391,8 @@ Lemma is_derive_shift {R : numFieldType} x v (k : R) : is_derive x v (shift k) v. Proof. by apply: DeriveDef => //; rewrite derive_val addr0. Qed. -Lemma derive1_cst {R : numFieldType} (k : R) t : (cst k)^`() t = 0. +Lemma derive1_cst {R : numFieldType} (V : normedModType R) (k : V) t : + (cst k)^`() t = 0. Proof. by rewrite derive1E derive_cst. Qed. Lemma derive1Mr {R : numFieldType} (f : R -> R) (x r : R) : @@ -1412,14 +1415,14 @@ by apply: derivableM; first exact: derivable_id. Qed. Lemma exp_derive {R : numFieldType} n x v : - 'D_v (@GRing.exp R ^~ n.+1) x = n.+1%:R *: x ^+ n *: v. + 'D_v (@GRing.exp R ^~ n) x = n%:R *: x ^+ n.-1 *: v. Proof. have /= := @deriveX R R id n x v (@derivable_id _ _ _ _). by rewrite fctE => ->; rewrite derive_id. Qed. Lemma exp_derive1 {R : numFieldType} n x : - (@GRing.exp R ^~ n.+1)^`() x = n.+1%:R *: x ^+ n. + (@GRing.exp R ^~ n)^`() x = n%:R *: x ^+ n.-1. Proof. by rewrite derive1E exp_derive [LHS]mulr1. Qed. Lemma EVT_max (R : realType) (f : R -> R) (a b : R) : (* TODO : Filter not infered *) diff --git a/theories/ereal.v b/theories/ereal.v index 2f7d013e8..bed1b1707 100644 --- a/theories/ereal.v +++ b/theories/ereal.v @@ -9,7 +9,7 @@ From mathcomp Require Import all_ssreflect all_algebra archimedean finmap. From mathcomp Require Import boolp classical_sets functions. From mathcomp Require Import fsbigop cardinality set_interval. From mathcomp Require Import reals interval_inference topology. -From mathcomp Require Export constructive_ereal. +From mathcomp Require Export constructive_ereal unstable. (**md**************************************************************************) (* # Extended real numbers, classical part ($\overline{\mathbb{R}}$) *) @@ -463,6 +463,21 @@ rewrite lteNl => /ereal_sup_gt[_ [y Sy <-]]. by rewrite lteNl oppeK => xlty; exists y. Qed. +Lemma ereal_infEN S : ereal_inf S = - ereal_sup (-%E @` S). +Proof. by []. Qed. + +Lemma ereal_supN S : ereal_sup (-%E @` S) = - ereal_inf S. +Proof. by rewrite oppeK. Qed. + +Lemma ereal_infN S : ereal_inf (-%E @` S) = - ereal_sup S. +Proof. +rewrite /ereal_inf; congr (- ereal_sup _) => /=. +by rewrite image_comp -[RHS]image_id; apply: eq_imagel => /= ?; rewrite oppeK. +Qed. + +Lemma ereal_supEN S : ereal_sup S = - ereal_inf (-%E @` S). +Proof. by rewrite ereal_infN oppeK. Qed. + End ereal_supremum. Section ereal_supremum_realType. @@ -523,7 +538,7 @@ Proof. by move=> Soo; apply/eqP; rewrite eq_le leey/=; exact: ereal_sup_ubound. Qed. -Lemma ereal_sup_le S x : (exists2 y, S y & x <= y) -> x <= ereal_sup S. +Lemma ereal_sup_ge S x : (exists2 y, S y & x <= y) -> x <= ereal_sup S. Proof. by move=> [y Sy] /le_trans; apply; exact: ereal_sup_ubound. Qed. Lemma ereal_sup_ninfty S : ereal_sup S = -oo <-> S `<=` [set -oo]. @@ -591,11 +606,137 @@ rewrite -ereal_sup_EFin; [|exact/has_lb_ubN|exact/nonemptyN]. by rewrite !image_comp. Qed. +Lemma ereal_supP S x : + reflect (forall y : \bar R, S y -> y <= x) (ereal_sup S <= x). +Proof. +apply/(iffP idP) => [+ y Sy|]. + by move=> /(le_trans _)->//; rewrite ereal_sup_ge//; exists y. +apply: contraPP => /negP; rewrite -ltNge -existsPNP. +by move=> /ereal_sup_gt[y Sy ltyx]; exists y => //; rewrite lt_geF. +Qed. + +Lemma ereal_infP S x : + reflect (forall y : \bar R, S y -> x <= y) (x <= ereal_inf S). +Proof. +rewrite leeNr; apply/(equivP (ereal_supP _ _)); setoid_rewrite leeNr. +split=> [ge_x y Sy|ge_x _ [y Sy <-]]; rewrite ?oppeK// ?ge_x//. +by rewrite -[y]oppeK ge_x//; exists y. +Qed. + +Lemma ereal_sup_gtP S x : + reflect (exists2 y : \bar R, S y & x < y) (x < ereal_sup S). +Proof. +rewrite ltNge; apply/(equivP negP); rewrite -(rwP (ereal_supP _ _)) -existsPNP. +by apply/eq_exists2r => y; rewrite (rwP2 negP idP) -ltNge. +Qed. + +Lemma ereal_inf_ltP S x : + reflect (exists2 y : \bar R, S y & y < x) (ereal_inf S < x). +Proof. +rewrite ltNge; apply/(equivP negP); rewrite -(rwP (ereal_infP _ _)) -existsPNP. +by apply/eq_exists2r => y; rewrite (rwP2 negP idP) -ltNge. +Qed. + +Lemma ereal_inf_leP S x : S (ereal_inf S) -> + reflect (exists2 y : \bar R, S y & y <= x) (ereal_inf S <= x). +Proof. +move=> Sinf; apply: (iffP idP); last exact: ereal_inf_le. +by move=> Sx; exists (ereal_inf S). +Qed. + +Lemma ereal_sup_geP S x : S (ereal_sup S) -> + reflect (exists2 y : \bar R, S y & x <= y) (x <= ereal_sup S). +Proof. +move=> Ssup; apply: (iffP idP); last exact: ereal_sup_ge. +by move=> Sx; exists (ereal_sup S). +Qed. + +Lemma lb_ereal_infNy_adherent S e : + ereal_inf S = -oo -> exists2 x : \bar R, S x & x < e%:E. +Proof. by move=> infNy; apply/ereal_inf_ltP; rewrite infNy ltNyr. Qed. + +Lemma ereal_sup_real : @ereal_sup R (range EFin) = +oo. +Proof. +rewrite hasNub_ereal_sup//; last by exists 0%R. +by apply/has_ubPn => x; exists (x+1)%R => //; rewrite ltrDl. +Qed. + +Lemma ereal_inf_real : @ereal_inf R (range EFin) = -oo. +Proof. +rewrite /ereal_inf [X in ereal_sup X](_ : _ = range EFin); last first. + apply/seteqP; split => x/=[y]. + by move=> [z] _ <- <-; exists (-z)%R. + by move=> _ <-; exists (-y%:E); first (by exists (-y)%R); rewrite oppeK. +by rewrite ereal_sup_real. +Qed. + End ereal_supremum_realType. #[deprecated(since="mathcomp-analysis 1.3.0", note="Renamed `ereal_sup_ubound`.")] Notation ereal_sup_ub := ereal_sup_ubound (only parsing). #[deprecated(since="mathcomp-analysis 1.3.0", note="Renamed `ereal_inf_lbound`.")] Notation ereal_inf_lb := ereal_inf_lbound (only parsing). +#[deprecated(since="mathcomp-analysis 1.11.0", note="Renamed `ereal_sup_ge`.")] +Notation ereal_sup_le := ereal_sup_ge. +Arguments ereal_supP {R S x}. +Arguments ereal_infP {R S x}. +Arguments ereal_sup_gtP {R S x}. +Arguments ereal_inf_ltP {R S x}. +Arguments ereal_sup_geP {R S x}. +Arguments ereal_inf_leP {R S x}. + +Section ereal_sup_cst. +Context {R : realFieldType}. +Implicit Types (x : \bar R) (X : set (\bar R)). +Local Open Scope ereal_scope. + +Lemma ereal_sup_cst T x (A : set T) : A != set0 -> ereal_sup (cst x @` A) = x. +Proof. by move=> AN0; rewrite set_cst ifN// ereal_sup1. Qed. + +Lemma ereal_inf_cst T x (A : set T) : A != set0 -> ereal_inf (cst x @` A) = x. +Proof. by move=> AN0; rewrite set_cst ifN// ereal_inf1. Qed. + +End ereal_sup_cst. + +Section ereal_supZ. +Context {R : realType}. +Implicit Types (r s : R) (X : set (\bar R)). +Local Open Scope ereal_scope. + +Lemma ereal_sup_pZl X r : (0 < r)%R -> + ereal_sup [set r%:E * x | x in X] = r%:E * ereal_sup X. +Proof. +move=> /[dup] r_gt0; rewrite lt0r => /andP[r_neq0 r_ge0]. +gen have gen : r r_gt0 {r_ge0 r_neq0} X / + ereal_sup [set r%:E * x | x in X] <= r%:E * ereal_sup X. + apply/ereal_supP => y/= [x Ax <-]; rewrite lee_pmul2l//=. + by apply/ereal_supP => //=; exists x. +apply/eqP; rewrite eq_le gen//= -lee_pdivlMl//. +rewrite (le_trans _ (gen _ _ _)) ?invr_gt0 ?image_comp//=. +by under eq_imagel do rewrite /= muleA -EFinM mulVf ?mul1e//=; rewrite image_id. +Qed. + +Lemma ereal_supZl X r : X != set0 -> (0 <= r)%R -> + ereal_sup [set r%:E * x | x in X] = r%:E * ereal_sup X. +Proof. +move=> AN0; have [r_gt0|//|<-] := ltgtP => _; first by rewrite ereal_sup_pZl. +by rewrite mul0e; under eq_imagel do rewrite mul0e/=; rewrite ereal_sup_cst. +Qed. + +Lemma ereal_inf_pZl X r : (0 < r)%R -> + ereal_inf [set r%:E * x | x in X] = r%:E * ereal_inf X. +Proof. +move=> r_gt0; rewrite !ereal_infEN muleN image_comp/=; congr (- _). +by under eq_imagel do rewrite /= -muleN; rewrite -image_comp ereal_sup_pZl. +Qed. + +Lemma ereal_infZl X r : X != set0 -> (0 < r)%R -> + ereal_sup [set r%:E * x | x in X] = r%:E * ereal_sup X. +Proof. +move=> XN0 r_gt0; rewrite !ereal_supEN muleN image_comp/=; congr (- _). +by under eq_imagel do rewrite /= -muleN; rewrite -image_comp ereal_inf_pZl. +Qed. + +End ereal_supZ. Lemma restrict_abse T (R : numDomainType) (f : T -> \bar R) (D : set T) : (abse \o f) \_ D = abse \o (f \_ D). @@ -800,8 +941,8 @@ Lemma ereal_nbhs_nbhs (p : \bar R) (A : set (\bar R)) : Proof. move: p => -[p| [M [Mreal MA]] | [M [Mreal MA]]] //=. - move=> /nbhs_ballP[_/posnumP[e]] ballA. - apply/nbhs_ballP; exists (e%:num / 2) => //= r per. - apply/nbhs_ballP; exists (e%:num / 2) => //= x rex. + apply/nbhs_ballP; exists (e%:num / 2)%R => //= r per. + apply/nbhs_ballP; exists (e%:num / 2)%R => //= x rex. apply/ballA/(@ball_splitl _ _ r) => //; exact/ball_sym. - exists (M + 1)%R; split; first by rewrite realD. move=> -[x| _ |_] //=; last by exists M. @@ -965,7 +1106,7 @@ suff [x [? [ubSx x1]]] : exists x, (x < csup)%R /\ ubound (contract @` S) x /\ exists (expand x); split => [|y Sy]. by rewrite -(contractK (ereal_sup S)) lt_expand // inE // contract_le1. by rewrite -(contractK y) le_expand //; apply: ubSx; exists y. -exists ((supc + csup) / 2); split; first by rewrite midf_lt. +exists ((supc + csup) / 2)%R; split; first by rewrite midf_lt. split => [r [y Sy <-{r}]|]. rewrite (@le_trans _ _ supc) ?midf_le //; last by rewrite ltW. apply: sup_ubound; last by exists y. diff --git a/theories/ess_sup_inf.v b/theories/ess_sup_inf.v new file mode 100644 index 000000000..b477a35ae --- /dev/null +++ b/theories/ess_sup_inf.v @@ -0,0 +1,367 @@ +From HB Require Import structures. +From mathcomp Require Import all_ssreflect all_algebra archimedean finmap. +From mathcomp Require Import mathcomp_extra boolp classical_sets functions. +From mathcomp Require Import cardinality fsbigop reals interval_inference ereal. +From mathcomp Require Import topology normedtype sequences esum numfun. +From mathcomp Require Import measure lebesgue_measure. + +(**md**************************************************************************) +(* # Essential infimum and essential supremum *) +(* *) +(* ``` *) +(* ess_sup f == essential supremum of the function f : T -> R where T is a *) +(* semiRingOfSetsType and R is a realType *) +(* ess_inf f == essential infimum *) +(* ``` *) +(* *) +(******************************************************************************) + +Set Implicit Arguments. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Import Order.TTheory GRing.Theory Num.Def Num.Theory. +Import numFieldNormedType.Exports. + +Local Open Scope classical_set_scope. +Local Open Scope ring_scope. +Local Open Scope ereal_scope. + +Section essential_supremum. +Context d {T : semiRingOfSetsType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Type f : T -> \bar R. + +Definition ess_sup f := ereal_inf [set y | \forall x \ae mu, f x <= y]. + +Lemma ess_supEae f : ess_sup f = ereal_inf [set y | \forall x \ae mu, f x <= y]. +Proof. by []. Qed. + +End essential_supremum. + +Section essential_supremum_lemmas. +Context d {T : measurableType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Types (f g : T -> \bar R) (h k : T -> R) (x y : \bar R) (r : R). + +(* NB: note that this lemma does not depends on the new definitions introduced + in this file and might be move earlier in the file hierarchy later *) +Lemma ae_le_measureP f y : measurable_fun [set: T] f -> + (\forall x \ae mu, f x <= y) <-> mu (f @^-1` `]y, +oo[) = 0. +Proof. +move=> f_meas; have fVroo_meas : d.-measurable (f @^-1` `]y, +oo[). + by rewrite -[_ @^-1` _]setTI; apply/f_meas=> //; exact/emeasurable_itv. +have setCfVroo : f @^-1` `]y, +oo[ = ~` [set x | f x <= y]. + by apply: setC_inj; rewrite preimage_setC setCitv/= set_itvxx setU0 setCK. +split. + move=> [N [dN muN0 inN]]; rewrite (subset_measure0 _ dN)// => x. + by rewrite setCfVroo; apply: inN. +set N := (X in mu X) => muN0; exists N; rewrite -setCfVroo. +by split => //; exact: fVroo_meas. +Qed. + +Local Notation ess_sup := (ess_sup mu). + +Lemma ess_supEmu0 f : measurable_fun [set: T] f -> + ess_sup f = ereal_inf [set y | mu (f @^-1` `]y, +oo[) = 0]. +Proof. +by move=> ?; congr (ereal_inf _); apply/predeqP => r; exact: ae_le_measureP. +Qed. + +Lemma ess_sup_ge f : \forall x \ae mu, f x <= ess_sup f. +Proof. +rewrite ess_supEae//; set I := (X in ereal_inf X). +have [->|IN0] := eqVneq I set0. + by rewrite ereal_inf0; apply: nearW => ?; rewrite leey. +have [u uI uinf] := ereal_inf_seq IN0. +rewrite -(cvg_lim _ uinf)//; near=> x. +rewrite lime_ge//; first by apply/cvgP: uinf. +by apply: nearW; near: x; apply/ae_foralln => n; apply: uI. +Unshelve. all: by end_near. Qed. + +Lemma ess_supP f y : reflect (\forall x \ae mu, f x <= y) (ess_sup f <= y). +Proof. +apply: (iffP (ereal_inf_leP _)) => /=; last 2 first. +- by move=> [z fz zy]; near do apply: le_trans zy. +- by move=> fy; exists y. +by rewrite -ess_supEae//; exact: ess_sup_ge. +Unshelve. all: by end_near. Qed. + +Lemma le_ess_sup f g : (\forall x \ae mu, f x <= g x) -> ess_sup f <= ess_sup g. +Proof. +move=> fg; apply/ess_supP => //. +near do rewrite (le_trans (near fg _ _))//=. +exact: ess_sup_ge. +Unshelve. all: by end_near. Qed. + +Lemma eq_ess_sup f g : (\forall x \ae mu, f x = g x) -> ess_sup f = ess_sup g. +Proof. +move=> fg; apply/eqP; rewrite eq_le !le_ess_sup//=; + by apply: filterS fg => x ->. +Qed. + +Lemma ess_sup_cst x : 0 < mu [set: T] -> ess_sup (cst x) = x. +Proof. +move=> muT_gt0; apply/eqP; rewrite eq_le; apply/andP; split. + by apply/ess_supP => //; apply: nearW. +have ae_proper := ae_properfilter_algebraOfSetsType muT_gt0. +by near (almost_everywhere mu) => y; near: y; apply: ess_sup_ge. +Unshelve. all: by end_near. Qed. + +Lemma ess_sup_ae_cst f y : 0 < mu [set: T] -> + (\forall x \ae mu, f x = y) -> ess_sup f = y. +Proof. by move=> muT_gt0 /= /eq_ess_sup->; rewrite ess_sup_cst. Qed. + +Lemma ess_sup_gee f a : 0 < mu [set: T] -> + (\forall x \ae mu, a <= f x) -> a <= ess_sup f. +Proof. by move=> *; rewrite -(ess_sup_cst a)//; apply: le_ess_sup. Qed. + +Lemma abs_sup_eq0_ae_eq f : ess_sup (abse \o f) = 0 -> f = \0 %[ae mu]. +Proof. +move=> ess_sup_f_eq0; near=> x => _ /=; apply/eqP. +rewrite -abse_eq0 eq_le abse_ge0 andbT; near: x. +by apply/ess_supP; rewrite ess_sup_f_eq0. +Unshelve. all: by end_near. Qed. + +Lemma abs_ess_sup_eq0 f : mu [set: T] > 0 -> + f = \0 %[ae mu] -> ess_sup (abse \o f) = 0. +Proof. +move=> muT_gt0 f0; apply/eqP; rewrite eq_le; apply/andP; split. + by apply/ess_supP => /=; near do rewrite (near f0 _ _)//= normr0//. +by rewrite -[0]ess_sup_cst// le_ess_sup//=; near=> x; rewrite abse_ge0. +Unshelve. all: by end_near. Qed. + +Lemma ess_sup_pZl f r : (0 < r)%R -> + ess_sup (cst r%:E \* f) = r%:E * ess_sup f. +Proof. +move=> /[dup] /ltW r_ge0 r_gt0. +gen have esc_le : r f r_ge0 r_gt0 / + ess_sup (cst r%:E \* f) <= r%:E * ess_sup f. + by apply/ess_supP; near do rewrite /cst/= lee_pmul2l//; apply/ess_supP. +apply/eqP; rewrite eq_le esc_le// -lee_pdivlMl//=. +apply: le_trans (esc_le _ _ _ _); rewrite ?invr_gt0 ?invr_ge0//. +by under eq_fun do rewrite muleA -EFinM mulVf ?mul1e ?gt_eqF//. +Unshelve. all: by end_near. Qed. + +Lemma ess_supZl f r : mu [set: T] > 0 -> (0 <= r)%R -> + ess_sup (cst r%:E \* f) = r%:E * ess_sup f. +Proof. +move=> muTN0; case: ltgtP => // [r_gt0|<-] _; first exact: ess_sup_pZl. +by under eq_fun do rewrite mul0e; rewrite mul0e ess_sup_cst. +Qed. + +Lemma ess_sup_eqNyP f : ess_sup f = -oo <-> \forall x \ae mu, f x = -oo. +Proof. +rewrite (rwP eqP) -leeNy_eq (eq_near (fun=> rwP eqP)). +by under eq_near do rewrite -leeNy_eq; apply/(rwP2 idP (ess_supP _ _)). +Qed. + +Lemma ess_supD f g : ess_sup (f \+ g) <= ess_sup f + ess_sup g. +Proof. +by apply/ess_supP; near do rewrite leeD//; apply/ess_supP. +Unshelve. all: by end_near. Qed. + +Lemma ess_sup_absD f g : + ess_sup (abse \o (f \+ g)) <= ess_sup (abse \o f) + ess_sup (abse \o g). +Proof. +rewrite (le_trans _ (ess_supD _ _))// le_ess_sup//. +by apply/nearW => x; apply/lee_abs_add. +Qed. + +End essential_supremum_lemmas. +Arguments ess_sup_ae_cst {d T R mu f}. +Arguments ess_supP {d T R mu f y}. + +Section real_essential_supremum. +Context d {T : semiRingOfSetsType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Types f : T -> R. + +Notation ess_supr f := (ess_sup mu (EFin \o f)). + +End real_essential_supremum. + +Section real_essential_supremum_lemmas. +Context d {T : measurableType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Types (f : T -> R) (r : R). + +Notation ess_supr f := (ess_sup mu (EFin \o f)). + +Lemma ess_supr_bounded f : ess_supr f < +oo -> + exists M, \forall x \ae mu, (f x <= M)%R. +Proof. +set g := EFin \o f => ltfy; have [|supfNy] := eqVneq (ess_sup mu g) -oo. + by move=> /ess_sup_eqNyP fNy; exists 0%:R; apply: filterS fNy. +have supf_fin : ess_supr f \is a fin_num by case: ess_sup ltfy supfNy. +by exists (fine (ess_supr f)); near do rewrite -lee_fin fineK//; apply/ess_supP. +Unshelve. all: by end_near. Qed. + +Lemma ess_sup_eqr0_ae_eq f : ess_supr (normr \o f) = 0 -> f = 0%R %[ae mu]. +Proof. +under [X in ess_sup _ X]eq_fun do rewrite /= -abse_EFin. +move=> /abs_sup_eq0_ae_eq; apply: filterS => x /= /(_ _)/eqP. +by rewrite eqe => /(_ _)/eqP. +Qed. + +Lemma ess_suprZl f r : mu [set: T] > 0 -> (0 <= r)%R -> + ess_supr (cst r \* f)%R = r%:E * ess_supr f. +Proof. by move=> muT_gt0 r_ge0; rewrite -ess_supZl. Qed. + +Lemma ess_sup_ger f x : 0 < mu [set: T] -> (forall t, x <= (f t)%:E) -> + x <= ess_supr f. +Proof. by move=> muT f0; apply/ess_sup_gee => //=; apply: nearW. Qed. + +Lemma ess_sup_ler f y : (forall t, (f t)%:E <= y) -> ess_supr f <= y. +Proof. by move=> ?; apply/ess_supP; apply: nearW. Qed. + +Lemma ess_sup_cstr y : 0 < mu [set: T] -> ess_supr (cst y) = y%:E. +Proof. by move=> muN0; rewrite (ess_sup_ae_cst y%:E)//=; apply: nearW. Qed. + +Lemma ess_suprD f g : ess_supr (f \+ g) <= ess_supr f + ess_supr g. +Proof. by rewrite (le_trans _ (ess_supD _ _ _)). Qed. + +Lemma ess_sup_normD f g : + ess_supr (normr \o (f \+ g)) <= ess_supr (normr \o f) + ess_supr (normr \o g). +Proof. +rewrite (le_trans _ (ess_suprD _ _))// le_ess_sup//. +by apply/nearW => x; apply/ler_normD. +Qed. + +End real_essential_supremum_lemmas. +Notation ess_supr mu f := (ess_sup mu (EFin \o f)). + +Section essential_infimum. +Context d {T : semiRingOfSetsType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Types f : T -> \bar R. + +Definition ess_inf f := ereal_sup [set y | \forall x \ae mu, y <= f x]. + +Lemma ess_infEae f : ess_inf f = ereal_sup [set y | \forall x \ae mu, y <= f x]. +Proof. by []. Qed. + +End essential_infimum. + +Section essential_infimum_lemmas. +Context d {T : measurableType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Types (f : T -> \bar R) (x y : \bar R) (r : R). + +Local Notation ess_inf := (ess_inf mu). +Local Notation ess_sup := (ess_sup mu). + +Lemma ess_infEN f : ess_inf f = - ess_sup (\- f). +Proof. +rewrite ess_supEae ess_infEae ereal_infEN oppeK; congr (ereal_sup _). +apply/seteqP; split=> [y /= y_le|_ [/= y y_ge <-]]. + by exists (- y); rewrite ?oppeK//=; apply: filterS y_le => x; rewrite leeN2. +by apply: filterS y_ge => x; rewrite leeNl. +Qed. + +Lemma ess_supEN f : ess_sup f = - ess_inf (\- f). +Proof. +by rewrite ess_infEN oppeK; apply/eq_ess_sup/nearW => ?; rewrite oppeK. +Qed. + +Lemma ess_infN f : ess_inf (\- f) = - ess_sup f. +Proof. by rewrite ess_supEN oppeK. Qed. + +Lemma ess_supN f : ess_sup (\- f) = - ess_inf f. +Proof. by rewrite ess_infEN oppeK. Qed. + +Lemma ess_infP f y : reflect (\forall x \ae mu, y <= f x) (y <= ess_inf f). +Proof. +by rewrite ess_infEN leeNr; apply: (iffP ess_supP); + apply: filterS => x; rewrite leeN2. +Qed. + +Lemma ess_inf_le f : \forall x \ae mu, ess_inf f <= f x. +Proof. exact/ess_infP. Qed. + +Lemma le_ess_inf f g : (\forall x \ae mu, f x <= g x) -> ess_inf f <= ess_inf g. +Proof. +move=> fg; apply/ess_infP => //. +near do rewrite (le_trans _ (near fg _ _))//=. +exact: ess_inf_le. +Unshelve. all: by end_near. Qed. + +Lemma eq_ess_inf f g : (\forall x \ae mu, f x = g x) -> ess_inf f = ess_inf g. +Proof. +move=> fg; apply/eqP; rewrite eq_le !le_ess_inf//=; + by apply: filterS fg => x ->. +Qed. + +Lemma ess_inf_cst x : 0 < mu [set: T] -> ess_inf (cst x) = x. +Proof. +by move=> ?; rewrite ess_infEN (ess_sup_ae_cst (- x)) ?oppeK//=; apply: nearW. +Qed. + +Lemma ess_inf_ae_cst f y : 0 < mu [set: T] -> + (\forall x \ae mu, f x = y) -> ess_inf f = y. +Proof. by move=> muT_gt0 /= /eq_ess_inf->; rewrite ess_inf_cst. Qed. + +Lemma ess_inf_gee f y : 0 < mu [set: T] -> + (\forall x \ae mu, y <= f x) -> y <= ess_inf f. +Proof. by move=> *; rewrite -(ess_inf_cst y)//; apply: le_ess_inf. Qed. + +Lemma ess_inf_pZl f r : (0 < r)%R -> ess_inf (cst r%:E \* f) = r%:E * ess_inf f. +Proof. +move=> r_gt0; rewrite !ess_infEN muleN; congr (- _). +by under eq_fun do rewrite -muleN; rewrite ess_sup_pZl. +Qed. + +Lemma ess_infZl f r : mu [set: T] > 0 -> (0 <= r)%R -> + ess_inf (cst r%:E \* f) = r%:E * ess_inf f. +Proof. +move=> muTN0; case: ltgtP => // [a_gt0|<-] _; first exact: ess_inf_pZl. +by under eq_fun do rewrite mul0e; rewrite mul0e ess_inf_cst. +Qed. + +Lemma ess_inf_eqyP f : ess_inf f = +oo <-> \forall x \ae mu, f x = +oo. +Proof. +rewrite (rwP eqP) -leye_eq (eq_near (fun=> rwP eqP)). +by under eq_near do rewrite -leye_eq; apply/(rwP2 idP (ess_infP _ _)). +Qed. + +Lemma ess_infD f g : ess_inf (f \+ g) >= ess_inf f + ess_inf g. +Proof. +by apply/ess_infP; near do rewrite leeD//; apply/ess_infP. +Unshelve. all: by end_near. Qed. + +End essential_infimum_lemmas. +Arguments ess_inf_ae_cst {d T R mu f}. +Arguments ess_infP {d T R mu f y}. + +Section real_essential_infimum. +Context d {T : measurableType d} {R : realType}. +Variable mu : {measure set T -> \bar R}. +Implicit Types (f : T -> R) (x : \bar R) (r : R). + +Notation ess_infr f := (ess_inf mu (EFin \o f)). + +Lemma ess_infr_bounded f : ess_infr f > -oo -> + exists M, \forall x \ae mu, (f x >= M)%R. +Proof. +set g := EFin \o f => ltfy; have [|inffNy] := eqVneq (ess_inf mu g) +oo. + by move=> /ess_inf_eqyP fNy; exists 0%:R; apply: filterS fNy. +have inff_fin : ess_infr f \is a fin_num by case: ess_inf ltfy inffNy. +by exists (fine (ess_infr f)); near do rewrite -lee_fin fineK//; apply/ess_infP. +Unshelve. all: by end_near. Qed. + +Lemma ess_infrZl f r : mu [set: T] > 0 -> (0 <= r)%R -> + ess_infr (cst r \* f)%R = r%:E * ess_infr f. +Proof. by move=> muT_gt0 r_ge0; rewrite -ess_infZl. Qed. + +Lemma ess_inf_ger f x : 0 < mu [set: T] -> (forall t, x <= (f t)%:E) -> + x <= ess_infr f. +Proof. by move=> muT f0; apply/ess_inf_gee => //=; apply: nearW. Qed. + +Lemma ess_inf_ler f x : (forall t, x <= (f t)%:E) -> x <= ess_infr f. +Proof. by move=> ?; apply/ess_infP; apply: nearW. Qed. + +Lemma ess_inf_cstr r : 0 < mu [set: T] -> ess_infr (cst r) = r%:E. +Proof. by move=> muN0; rewrite (ess_inf_ae_cst r%:E)//=; apply: nearW. Qed. + +End real_essential_infimum. +Notation ess_infr mu f := (ess_inf mu (EFin \o f)). diff --git a/theories/exp.v b/theories/exp.v index 230b3c1ab..d4e0311df 100644 --- a/theories/exp.v +++ b/theories/exp.v @@ -170,9 +170,9 @@ rewrite -mulrA mulrC -mulrA mulr_natl -[X in _ *+ X]subn0 -sumr_const_nat. apply ler_sum_nat => i /=. case: n => //= n ni. rewrite normrM. -pose d := (n.-1 - i)%nat. -rewrite -[(n - i)%nat]prednK ?subn_gt0// predn_sub -/d. -rewrite -(subnK (_ : i <= n.-1)%nat) -/d; last first. +pose d := (n.-1 - i)%N. +rewrite -[(n - i)%N]prednK ?subn_gt0// predn_sub -/d. +rewrite -(subnK (_ : i <= n.-1)%N) -/d; last first. by rewrite -ltnS prednK// (leq_ltn_trans _ ni). rewrite addnC exprD mulrAC -mulrA. apply: ler_pM => //. @@ -182,7 +182,7 @@ apply: le_trans (_ : d.+1%:R * K ^+ d <= _); last first. by rewrite ler_nat ltnS /d -subn1 -subnDA leq_subr. rewrite (le_trans (ler_norm_sum _ _ _))//. rewrite mulr_natl -[X in _ *+ X]subn0 -sumr_const_nat ler_sum_nat//= => j jd1. -rewrite -[in leRHS](subnK (_ : j <= d)%nat) -1?ltnS // addnC exprD normrM. +rewrite -[in leRHS](subnK (_ : j <= d)%N) -1?ltnS // addnC exprD normrM. by rewrite ler_pM// normrX lerXn2r// qualifE/= (le_trans _ zLK). Qed. @@ -319,23 +319,33 @@ rewrite -addn1 series_addn series_exp_coeff0 big_add1 big1 ?addr0//. by move=> i _; rewrite /exp_coeff /= expr0n mul0r. Unshelve. all: by end_near. Qed. -Local Lemma expR_ge1Dx_subproof x : 0 <= x -> 1 + x <= expR x. +Lemma expR_ge1Dxn x n : 0 <= x -> 1 + x ^+ n.+1 / n.+1`!%:R <= expR x. Proof. move=> x_ge0; rewrite /expR. -pose f (x : R) i := (i == 0%nat)%:R + x *+ (i == 1%nat). -have F n : (1 < n)%nat -> \sum_(0 <= i < n) (f x i) = 1 + x. - move=> /subnK<-. - by rewrite addn2 !big_nat_recl //= /f /= mulr1n !mulr0n big1 ?add0r ?addr0. -have -> : 1 + x = limn (series (f x)). - by apply/esym/lim_near_cst => //; near=> n; apply: F; near: n. -apply: ler_lim; first by apply: is_cvg_near_cst; near=> n; apply: F; near: n. +pose f n (x : R) i := (i == 0)%:R + x ^+ n / n`!%:R *+ (i == n). +have F m : (n.+1 < m)%N -> + \sum_(0 <= i < m) (f n.+1 x i) = 1 + x ^+ n.+1 / n.+1`!%:R. + move=> n1m. + rewrite (@big_cat_nat _ _ _ n.+2)//= big_nat_recr// big_nat_recl//=. + rewrite big_nat_cond big1 ?addr0; last first. + by move=> i /[!andbT] /[!leq0n]/= ni; rewrite /f/= lt_eqF//= add0r. + rewrite big_nat_cond big1 ?addr0; last first. + move=> i /[!andbT] /andP[ni mi]; rewrite /f !gtn_eqF//= ?add0r//. + exact: ltn_trans ni. + by rewrite /f/= add0r mulr0n addr0 eqxx 2!mulr1n. +rewrite [leLHS](_ : _ = limn (series (f n.+1 x))); last first. + by apply/esym/(@lim_near_cst R^o) => //; near=> k; apply: F; near: k. +apply: ler_lim; first by apply: is_cvg_near_cst; near=> k; apply: F; near: k. exact: is_cvg_series_exp_coeff. -by near=> n; apply: ler_sum => -[|[|i]] _; - rewrite /f /exp_coeff /= !(mulr0n, mulr1n, expr0, expr1, divr1, addr0, add0r) - // exp_coeff_ge0. +near=> k; apply: ler_sum => -[|[|i]] _; rewrite /f /exp_coeff/= ?add0r. +- by rewrite !(mulr0n, expr0, addr0, divr1). +- case: n F; first by rewrite !(mulr0n, mulr1n, expr0, addr0, add0r, divr1). + by move=> n F; rewrite mulr0n expr1 divr1. +- rewrite eqSS; case: eqP => [->|_]; rewrite ?mulr1n//. + by rewrite mulr0n divr_ge0// exprn_ge0. Unshelve. all: by end_near. Qed. -Lemma exp_coeffE x : exp_coeff x = (fun n => (fun n => (n`!%:R)^-1) n * x ^+ n). +Lemma exp_coeffE x : exp_coeff x = fun n => (fun n => (n`!%:R)^-1) n * x ^+ n. Proof. by apply/funext => i; rewrite /exp_coeff /= mulrC. Qed. Import GRing.Theory. @@ -386,7 +396,8 @@ Proof. by rewrite -[X in _ X * _ = _]addr0 expRxDyMexpx expR0. Qed. Lemma pexpR_gt1 x : 0 < x -> 1 < expR x. Proof. -by move=> x0; rewrite (lt_le_trans _ (expR_ge1Dx_subproof (ltW x0)))// ltrDl. +move=> x0; rewrite (lt_le_trans _ (expR_ge1Dxn 0%N (ltW x0)))// ltrDl. +by rewrite expr1 divr1. Qed. Lemma expR_gt0 x : 0 < expR x. @@ -786,10 +797,16 @@ Lemma concave_ln (t : {i01 R}) (a b : R^o) : 0 < a -> 0 < b -> (ln a : R^o) <| t |> (ln b : R^o) <= ln (a <| t |> b). Proof. move=> a0 b0; have := convex_expR t (ln a) (ln b). -by rewrite !lnK// -(@ler_ln) ?posrE ?expR_gt0 ?conv_gt0// expRK. +by rewrite !lnK// -(@ler_ln) ?posrE ?expR_gt0 ?convR_gt0// expRK. Qed. Local Close Scope convex_scope. +Lemma lnNy : ln x @[x --> 0^'+] --> -oo. +Proof. +apply/cvgrNyPle => y; near=> x; rewrite -ler_expR lnK; last by rewrite posrE. +by near: x; apply: nbhs_right_le; exact: expR_gt0. +Unshelve. end_near. Qed. + End Ln. Section PowR. @@ -1020,11 +1037,13 @@ rewrite le_eqVlt => /predU1P[<-|b0] p0 q0 pq. have iq1 : q^-1 <= 1 by rewrite -pq ler_wpDl// invr_ge0 ltW. have ap0 : (0 < a `^ p)%R by rewrite powR_gt0. have bq0 : (0 < b `^ q)%R by rewrite powR_gt0. -have := @concave_ln _ (Itv01 (eqbRL (invr_ge0 _) (ltW q0)) iq1) _ _ ap0 bq0. +have := @concave_ln _ (Itv01 (eqbRL (invr_ge0 _) (ltW q0)) iq1) _ _ bq0 ap0. +rewrite 2!(convC (Itv01 _ _)). have pq' : (p^-1 = 1 - q^-1)%R by rewrite -pq addrK. +have qp' : (q^-1 = 1 - p^-1)%R by rewrite -pq addrAC subrr add0r. rewrite !convRE/= /onem -pq' -[_ <= ln _]ler_expR expRD (mulrC p^-1). -rewrite ln_powR mulrAC divff ?mul1r ?gt_eqF// (mulrC q^-1). rewrite ln_powR mulrAC divff ?mul1r ?gt_eqF//. +rewrite ln_powR -qp' mulrA mulVf ?gt_eqF// ?mul1r. rewrite lnK ?posrE// lnK ?posrE// => /le_trans; apply. rewrite lnK//; last by rewrite posrE addr_gt0// mulr_gt0// ?invr_gt0. by rewrite (mulrC _ p^-1) (mulrC _ q^-1). @@ -1053,12 +1072,55 @@ Qed. Canonical powR_inum (i : Itv.t) (x : Itv.def (@Itv.num_sem R) i) p := Itv.mk (num_spec_powR x p). +Lemma powR_cvg0 (x : R) : 0 < x -> a `^ x @[a --> 0^'+] --> 0. +Proof. +move=> x0; apply: (@cvg_trans _ ((expR (ln a * x)) @[a --> 0^'+])). + by apply: near_eq_cvg; near=> a; rewrite /powR gt_eqF 1?mulrC. +apply: (@cvg_comp _ _ _ _ _ _ (@ninfty_nbhs R)). + by apply: gt0_cvgMlNy; rewrite ?x0//; exact: lnNy. +exact/cvgNy_compNP/cvgr_expR. +Unshelve. end_near. Qed. + +Lemma derivable_powR v x : v != 0 -> + {in `]0, +oo[, forall a, derivable (powR ^~ x) a v}. +Proof. +move=> v0 a; rewrite in_itv/= andbT => a0. +apply: (@near_eq_derivable _ _ _ (fun a' => expR (x * ln a'))) => //. + by near=> b; rewrite /powR gt_eqF//; near: b; exact: lt_nbhsr. +apply: diff_derivable; apply: differentiable_comp; last exact/derivable1_diffP. +apply: differentiableM => //; apply/derivable1_diffP. +by apply: ex_derive; exact: is_derive1_ln. +Unshelve. end_near. Qed. + +Lemma powR_derive1 a : {in `]0, +oo[%R, + (powR ^~ a) ^`()%classic =1 (fun x => a * x `^ (a - 1))}. +Proof. +move=> x; rewrite in_itv/= andbT => x0. +rewrite derive1E. +rewrite (@near_eq_derive _ _ _ _ (fun x => expR (a * ln x)))//; last first. + by near=> z; rewrite /powR gt_eqF//; near: z; exact: lt_nbhsr. +rewrite -derive1E. +rewrite derive1_comp//=; last first. + by apply: derivableM => //; apply: ex_derive; exact: is_derive1_ln. +rewrite 2!derive1E. +rewrite deriveM//; last by apply: ex_derive; exact: is_derive1_ln. +rewrite !derive_val scaler0 addr0. +have [_ ->] := (is_derive1_ln x0). +rewrite mulrC powRB; last by rewrite (@gt_eqF _ _ x)//; apply: implybT. +by rewrite powRr1 ?ltW// mulrA [in RHS]mulrAC /powR gt_eqF. +Unshelve. end_near. Qed. + +Global Instance is_derive1_powR (a x : R) : 0 < x -> + is_derive x 1 (powR ^~ a) (a * x `^ (a - 1))%R. +Proof. +move=> x_gt0; split. + by apply: derivable_powR; rewrite ?in_itv/= ?andbT. +by rewrite -derive1E powR_derive1// in_itv andbT. +Qed. + End PowR. Notation "a `^ x" := (powR a x) : ring_scope. -#[deprecated(since="mathcomp-analysis 0.6.5", note="renamed `ge0_ler_powR`")] -Notation gt0_ler_powR := ge0_ler_powR. - Section poweR. Local Open Scope ereal_scope. Context {R : realType}. @@ -1093,6 +1155,21 @@ Proof. by case: x => // x xf; rewrite poweR_EFin powRN. Qed. Lemma poweRNyr r : r != 0%R -> -oo `^ r = 0. Proof. by move=> r0 /=; rewrite (negbTE r0). Qed. +Lemma poweRE x r : + poweR x r = if r == 0%R then + (if x \is a fin_num then fine x `^ r else 1)%:E + else if x == +oo then +oo + else if x == -oo then 0 + else (fine x `^ r)%:E. +Proof. +case: ifPn => [/eqP r0|r0]. + case: ifPn => finx; last by rewrite r0 poweRe0. + by rewrite -poweR_EFin; case: x finx. +case: ifPn => [/eqP ->|xy]; first by rewrite poweRyr. +case: ifPn => [/eqP ->|xNy]; first by rewrite poweRNyr. +by rewrite -poweR_EFin// fineK// fin_numE xNy. +Qed. + Lemma poweR_eqy x r : x `^ r = +oo -> x = +oo. Proof. by case: x => [x| |] //=; case: ifP. Qed. diff --git a/theories/forms.v b/theories/forms.v index 68511d0ee..524f0f36c 100644 --- a/theories/forms.v +++ b/theories/forms.v @@ -15,17 +15,15 @@ Unset Printing Implicit Defensive. Local Open Scope ring_scope. Import GRing.Theory Num.Theory. -Reserved Notation "'[ u , v ]" - (at level 2, format "'[hv' ''[' u , '/ ' v ] ']'"). -Reserved Notation "'[ u , v ]_ M" - (at level 2, format "'[hv' ''[' u , '/ ' v ]_ M ']'"). -Reserved Notation "'[ u ]_ M" (at level 2, format "''[' u ]_ M"). -Reserved Notation "'[ u ]" (at level 2, format "''[' u ]"). +Reserved Notation "'[ u , v ]" (format "'[hv' ''[' u , '/ ' v ] ']'"). +Reserved Notation "'[ u , v ]_ M" (format "'[hv' ''[' u , '/ ' v ]_ M ']'"). +Reserved Notation "'[ u ]_ M" (format "''[' u ]_ M"). +Reserved Notation "'[ u ]" (format "''[' u ]"). Reserved Notation "u '``_' i" - (at level 3, i at level 2, left associativity, format "u '``_' i"). + (at level 3, i at level 2, left associativity, format "u '``_' i"). Reserved Notation "A ^_|_" (at level 8, format "A ^_|_"). Reserved Notation "A _|_ B" (at level 69, format "A _|_ B"). -Reserved Notation "eps_theta .-sesqui" (at level 2, format "eps_theta .-sesqui"). +Reserved Notation "eps_theta .-sesqui" (format "eps_theta .-sesqui"). Notation "u '``_' i" := (u (0 : 'I_1) i) : ring_scope. Notation "''e_' i" := (delta_mx 0 i) diff --git a/theories/ftc.v b/theories/ftc.v index ddd76c947..0772d72b8 100644 --- a/theories/ftc.v +++ b/theories/ftc.v @@ -65,6 +65,24 @@ Notation mu := (@lebesgue_measure R). Local Open Scope ereal_scope. Implicit Types (f : R -> R) (a : itv_bound R). +Lemma integrable_locally f (A : set R) : measurable A -> + mu.-integrable A (EFin \o f) -> locally_integrable [set: R] (f \_ A). +Proof. +move=> mA intf; split. +- move/integrableP : intf => [mf _]. + by apply/(measurable_restrictT _ _).1 => //; exact/measurable_EFinP. +- exact: openT. +- move=> K _ cK. + move/integrableP : intf => [mf]. + rewrite integral_mkcond/=. + under eq_integral do rewrite restrict_EFin restrict_normr. + apply: le_lt_trans. + apply: ge0_subset_integral => //=; first exact: compact_measurable. + apply/measurable_EFinP/measurableT_comp/measurable_EFinP => //=. + move/(measurable_restrictT _ _).1 : mf => /=. + by rewrite restrict_EFin; exact. +Qed. + Let FTC0 f a : mu.-integrable setT (EFin \o f) -> let F x := (\int[mu]_(t in [set` Interval a (BRight x)]) f t)%R in forall x, a < BRight x -> lebesgue_pt f x -> @@ -118,7 +136,7 @@ apply: cvg_at_right_left_dnbhs. rewrite {ixdf} -/mu. rewrite [g in g n @[n --> _] --> _ -> _](_ : _ = fun n => (d n)^-1%:E * \int[mu]_(y in E x n) (f y)%:E); last first. - by apply/funext => n; rewrite muE. + by apply/funext => n; rewrite muE inver// gt_eqF. move/fine_cvgP => [_ /=]. set g := _ \o _ => gf. set h := (f in f n @[n --> \oo] --> _). @@ -213,7 +231,8 @@ apply: cvg_at_right_left_dnbhs. rewrite /g /= fineM//=; last first. apply: integral_fune_fin_num => //; first exact: (nice_E _).1. by apply: integrableS intf => //; exact: (nice_E _).1. - by rewrite muE/= invrN mulNr -mulrN. + by rewrite muE inver oppr_eq0 lt_eqF. + by rewrite muE/= inver oppr_eq0 lt_eqF// invrN mulNr -mulrN. Unshelve. all: by end_near. Qed. Let FTC0_restrict f a x (u : R) : (x < u)%R -> @@ -576,7 +595,7 @@ have [k FGk] : exists k : R, {in `]a, b[, (F - G =1 cst k)%R}. apply: subset_itvSoo zxy => //=; rewrite bnd_simp. * by move: xab; rewrite in_itv/= => /andP[/ltW]. * by move: yab; rewrite in_itv/= => /andP[_ /ltW]. - move=> H; pose c := (a + b) / 2. + move=> H; pose c := ((a + b) / 2)%R. exists (F c - G c)%R => u /(H u c); apply. by rewrite in_itv/= midf_lt//= midf_lt. have [c GFc] : exists c : R, forall x, x \in `]a, b[ -> (F x - G x)%R = c. @@ -688,7 +707,7 @@ transitivity (\sum_(0 <= i /(_ (ltnSn _))[]. - - have : {within `[a + n%:R + 2^-1, a + n.+1%:R], continuous F}. + - have : {within `[a + n%:R + 2^-1%R, a + n.+1%:R], continuous F}. apply: derivable_within_continuous => x. rewrite in_itv/= => /andP[aSn _]. by apply: dF; rewrite (lt_le_trans _ aSn)// -addrA ltrDl ltr_wpDl. @@ -1630,7 +1649,7 @@ rewrite (@increasing_ge0_integration_by_substitutiony (\- (F \o -%R))%R); last 8 by apply: funext => r/=; rewrite fctE opprK. - apply/continuous_within_itvcyP; split. move=> x; rewrite in_itv/= opprK andbT => Fbx. - apply: continuous_comp; first exact: opp_continuous. + apply: continuous_comp; first exact: oppr_continuous. by apply: cG; rewrite in_itv/= ltrNl. by rewrite /= !opprK; exact/cvg_at_leftNP. - move=> z; rewrite in_itv/= opprK andbT => Fbz. diff --git a/theories/function_spaces.v b/theories/function_spaces.v index e340cb5c9..a920e9e63 100644 --- a/theories/function_spaces.v +++ b/theories/function_spaces.v @@ -109,7 +109,7 @@ Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. -Obligation Tactic := idtac. +Local Obligation Tactic := idtac. Import Order.TTheory GRing.Theory Num.Theory. Local Open Scope classical_set_scope. @@ -152,13 +152,13 @@ HB.instance Definition _ (U : Type) (T : U -> uniformType) := Uniform.copy (forall x : U, T x) (prod_topology T). HB.instance Definition _ (U T : topologicalType) := - Topological.copy - (continuousType U T) + Topological.copy + (continuousType U T) (weak_topology (id : continuousType U T -> (U -> T))). HB.instance Definition _ (U : topologicalType) (T : uniformType) := - Uniform.copy - (continuousType U T) + Uniform.copy + (continuousType U T) (weak_topology (id : continuousType U T -> (U -> T))). End ArrowAsProduct. @@ -222,9 +222,9 @@ Lemma tychonoff (I : eqType) (T : I -> topologicalType) (forall i, compact (A i)) -> compact [set f : forall i, T i | forall i, A i (f i)]. Proof. -case: (pselect ([set f : forall i, T i | forall i, A i (f i)] == set0)). - move/eqP => -> _; exact: compact0. -case/negP/set0P=> a0 Aa0 Aco; rewrite compact_ultra => F FU FA. +have [-> _|] := eqVneq [set f : forall i, T i | forall i, A i (f i)] set0. + exact: compact0. +case/set0P => a0 Aa0 Aco; rewrite compact_ultra => F FU FA. set subst_coord := fun (i : I) (pi : T i) (f : forall x : I, T x) (j : I) => if eqP is ReflectT e then ecast i (T i) (esym e) pi else f j. have subst_coordT i pi f : subst_coord i pi f i = pi. @@ -244,12 +244,12 @@ have pFA i : pF i (A i). move=> Aipi; have [f Af] := filter_ex FA. exists (subst_coord i pi f); last exact: subst_coordT. move=> j; have [<-{j}|] := eqVneq i j; first by rewrite subst_coordT. - by move=> /subst_coordN ->; apply: Af. + by move=> /subst_coordN ->; exact: Af. have cvpFA i : A i `&` [set p | pF i --> p] !=set0. by rewrite -ultra_cvg_clusterE; apply: Aco. exists (fun i => xget (a0 i) (A i `&` [set p | pF i --> p])). split=> [i|]; first by have /(xgetPex (a0 i)) [] := cvpFA i. -apply/cvg_sup => i; apply/cvg_image=> //. +apply/cvg_sup => i; apply/cvg_image=> //. by have /(xgetPex (a0 i)) [] := cvpFA i. Qed. @@ -423,11 +423,9 @@ Qed. End product_embeddings. -Global Instance prod_topology_filter (U : Type) (T : U -> ptopologicalType) (f : prod_topology T) : - ProperFilter (nbhs f). -Proof. -exact: nbhs_pfilter. -Qed. +Global Instance prod_topology_filter (U : Type) (T : U -> ptopologicalType) + (f : prod_topology T) : ProperFilter (nbhs f). +Proof. exact: nbhs_pfilter. Qed. End product_spaces. @@ -514,8 +512,11 @@ Unshelve. all: by end_near. Qed. HB.instance Definition _ := Uniform_isComplete.Build (arrow_uniform_type T U) fun_complete. -HB.instance Definition _ (R : numFieldType) := - Uniform_isComplete.Build (arrow_uniform_type T U) cauchy_cvg. +(*HB.instance Definition _ (R : numFieldType) := + Uniform_isComplete.Build (arrow_uniform_type T U) cauchy_cvg.*) +(* NB: commented out because +Warning: HB: no new instance is generated [HB.no-new-instance,HB,elpi,default] +*) End fun_Complete. @@ -554,13 +555,13 @@ HB.instance Definition _ (U : choiceType) (R : numFieldType) PseudoMetric.copy (U -> V) (arrow_uniform_type U V). HB.instance Definition _ (U : topologicalType) (T : uniformType) := - Uniform.copy - (continuousType U T) + Uniform.copy + (continuousType U T) (weak_topology (id : continuousType U T -> (U -> T))). -HB.instance Definition _ (U : topologicalType) (R : realType) +HB.instance Definition _ (U : topologicalType) (R : realType) (T : pseudoMetricType R) := - PseudoMetric.on + PseudoMetric.on (weak_topology (id : continuousType U T -> (U -> T))). End ArrowAsUniformType. @@ -1426,7 +1427,7 @@ Lemma continuous_curry (f : U * V -> W) : continuous (curry f) /\ forall u, continuous (curry f u). Proof. move=> ctsf; split; first last. - move=> u z; apply: continuous_comp; last exact: ctsf. + move=> u z; apply: (continuous_comp _ (ctsf (u, z))). by apply: cvg_pair => //=; exact: cvg_cst. move=> x; apply/compact_open_cvgP => K O /= cptK oO fKO. near=> z => w /= [+ + <-]; near: z. diff --git a/theories/gauss_integral.v b/theories/gauss_integral.v index 44a3e99a8..9742ddb1b 100644 --- a/theories/gauss_integral.v +++ b/theories/gauss_integral.v @@ -62,7 +62,7 @@ Let mu : {measure set _ -> \bar R} := @lebesgue_measure R. Definition integral0y_gauss := \int[mu]_(x in `[0%R, +oo[) gauss_fun x. -Let integral0y_gauss_ge0 : 0 <= integral0y_gauss. +Lemma integral0y_gauss_ge0 : 0 <= integral0y_gauss. Proof. by apply: Rintegral_ge0 => //= x _; rewrite gauss_fun_ge0. Qed. Definition integral0_gauss x := \int[mu]_(t in `[0, x]) gauss_fun t. @@ -81,10 +81,10 @@ Qed. Definition u x t := expR (- x ^+ 2 * oneDsqr t) / oneDsqr t. -Let u_ge0 x t : 0 <= u x t. +Lemma u_ge0 x t : 0 <= u x t. Proof. by rewrite /u divr_ge0// ?expR_ge0. Qed. -Let measurable_u x : measurable_fun setT (u x). +Lemma measurable_u x : measurable_fun setT (u x). Proof. apply: measurable_funM => //=. apply: measurableT_comp => //=; apply: measurable_funM => //=. @@ -95,7 +95,7 @@ Qed. Local Notation "'d1 f" := (partial1of2 f). -Let partial1_u x t : ('d1 u) x t = - 2 * x * gauss_fun x * gauss_fun (t * x). +Lemma partial1_u x t : ('d1 u) x t = - 2 * x * gauss_fun x * gauss_fun (t * x). Proof. rewrite partial1of2E /u /= deriveMr//= -derive1E. rewrite derive1_comp// [in X in _ * (_ * X)]derive1Mr//. diff --git a/theories/hoelder.v b/theories/hoelder.v index 06385c4ac..5665424f9 100644 --- a/theories/hoelder.v +++ b/theories/hoelder.v @@ -5,7 +5,7 @@ From mathcomp Require Import mathcomp_extra unstable boolp classical_sets. From mathcomp Require Import functions cardinality fsbigop reals ereal. From mathcomp Require Import topology normedtype sequences real_interval. From mathcomp Require Import esum measure lebesgue_measure lebesgue_integral. -From mathcomp Require Import numfun exp convex interval_inference. +From mathcomp Require Import numfun exp convex interval_inference ess_sup_inf. (**md**************************************************************************) (* # Hoelder's Inequality *) @@ -43,7 +43,7 @@ HB.lock Definition Lnorm {d} {T : measurableType d} {R : realType} mu (f @^-1` (setT `\ 0%R)) else (\int[mu]_x (`|f x| `^ p)%:E) `^ p^-1)%E - | +oo%E => (if mu [set: T] > 0 then ess_sup mu (normr \o f) else 0)%E + | +oo%E => (if mu [set: T] > 0 then ess_supr mu (normr \o f) else 0)%E | -oo%E => 0%E end. Canonical locked_Lnorm := Unlockable Lnorm.unlock. @@ -68,7 +68,7 @@ Lemma Lnorm_ge0 p f : 0 <= 'N_p[f]. Proof. rewrite unlock; move: p => [r/=|/=|//]. by case: ifPn => // r0; exact: poweR_ge0. -by case: ifPn => // /ess_sup_ge0; apply => t/=. +by case: ifPn => // /ess_sup_ger; apply => t/=. Qed. Lemma eq_Lnorm p f g : f =1 g -> 'N_p[f] = 'N_p[g]. @@ -148,7 +148,7 @@ rewrite (ae_eq_integral (cst 0)) => [|//||//|]; first by rewrite integral0. by rewrite normrM => ->; rewrite mul0r. Qed. -Let normalized p f x := `|f x| / fine 'N_p%:E[f]. +Let normalized p f x := (`|f x| / fine 'N_p%:E[f])%R. Let normalized_ge0 p f x : (0 <= normalized p f x)%R. Proof. by rewrite /normalized divr_ge0// fine_ge0// Lnorm_ge0. Qed. @@ -291,15 +291,15 @@ Lemma convex_powR p : 1 <= p -> Proof. move=> p1 t x y /[!inE] /= /[!in_itv] /= /[!andbT] x_ge0 y_ge0. have p0 : 0 < p by rewrite (lt_le_trans _ p1). -rewrite !convRE; set w1 := `1-(t%:inum); set w2 := t%:inum. -have [->|w10] := eqVneq w1 0. - rewrite !mul0r !add0r; have [->|w20] := eqVneq w2 0. - by rewrite !mul0r powR0// gt_eqF. - by rewrite ge1r_powRZ// /w2 lt_neqAle eq_sym w20/=; apply/andP. +rewrite !convRE; set w1 := t%:num; set w2 := `1-(t%:inum). have [->|w20] := eqVneq w2 0. - by rewrite !mul0r !addr0 ge1r_powRZ// onem_le1// andbT lt0r w10 onem_ge0. + rewrite !mul0r !addr0; have [->|w10] := eqVneq w1 0. + by rewrite !mul0r powR0// gt_eqF. + by rewrite ge1r_powRZ// /w1 lt_neqAle eq_sym w10/=; apply/andP. +have [->|w10] := eqVneq w1 0. + by rewrite !mul0r !add0r ge1r_powRZ// onem_le1// andbT lt0r w20 onem_ge0. have [->|p_neq1] := eqVneq p 1. - by rewrite !powRr1// addr_ge0// mulr_ge0// /w2 ?onem_ge0. + by rewrite !powRr1// addr_ge0// mulr_ge0// /w1 ?onem_ge0. have {p_neq1} {}p1 : 1 < p by rewrite lt_neqAle eq_sym p_neq1. pose q := p / (p - 1). have q1 : 1 <= q by rewrite /q ler_pdivlMr// ?mul1r ?gerBl// subr_gt0. @@ -308,15 +308,15 @@ have pq1 : p^-1 + q^-1 = 1. rewrite /q invf_div -{1}(div1r p) -mulrDl addrCA subrr addr0. by rewrite mulfV// gt_eqF. rewrite -(@powRr1 _ (w1 * x `^ p + w2 * y `^ p)); last first. - by rewrite addr_ge0// mulr_ge0// ?powR_ge0// /w2 ?onem_ge0// itv_ge0. + by rewrite addr_ge0// mulr_ge0// ?powR_ge0// /w1 ?onem_ge0// itv_ge0. have -> : 1 = p^-1 * p by rewrite mulVf ?gt_eqF. rewrite powRrM (ge0_ler_powR (le_trans _ (ltW p1)))//. -- by rewrite nnegrE addr_ge0// mulr_ge0 /w2 ?onem_ge0. +- by rewrite nnegrE addr_ge0// mulr_ge0 /w1 ?onem_ge0. - by rewrite nnegrE powR_ge0. have -> : w1 * x + w2 * y = w1 `^ (p^-1) * w1 `^ (q^-1) * x + w2 `^ (p^-1) * w2 `^ (q^-1) * y. rewrite -!powRD pq1; [|exact/implyP..]. - by rewrite !powRr1// /w2 ?onem_ge0. + by rewrite !powRr1// /w1 ?onem_ge0. apply: (@le_trans _ _ ((w1 * x `^ p + w2 * y `^ p) `^ (p^-1) * (w1 + w2) `^ q^-1)). pose a1 := w1 `^ p^-1 * x. pose a2 := w2 `^ p^-1 * y. @@ -324,9 +324,9 @@ apply: (@le_trans _ _ ((w1 * x `^ p + w2 * y `^ p) `^ (p^-1) * have : a1 * b1 + a2 * b2 <= (a1 `^ p + a2 `^ p) `^ p^-1 * (b1 `^ q + b2 `^ q) `^ q^-1. by apply: hoelder2 => //; rewrite ?mulr_ge0 ?powR_ge0. - rewrite ?powRM ?powR_ge0 -?powRrM ?mulVf ?powRr1 ?gt_eqF ?onem_ge0/w2//. + rewrite ?powRM ?powR_ge0 -?powRrM ?mulVf ?powRr1 ?gt_eqF ?onem_ge0/w1//. by rewrite mulrAC (mulrAC _ y) => /le_trans; exact. -by rewrite {2}/w1 {2}/w2 subrK powR1 mulr1. +by rewrite {2}/w1 {2}/w2 subrKC powR1 mulr1. Qed. End convex_powR. @@ -343,9 +343,9 @@ Proof. move=> p1; rewrite (@le_trans _ _ ((2^-1 * `| f x | + 2^-1 * `| g x |) `^ p))//. rewrite ge0_ler_powR ?nnegrE ?(le_trans _ p1)//. by rewrite (le_trans (ler_normD _ _))// 2!normrM ger0_norm. -rewrite {1 3}(_ : 2^-1 = 1 - 2^-1); last by rewrite {2}(splitr 1) div1r addrK. -rewrite (@convex_powR _ _ p1 (Itv01 _ _))// ?inE/= ?in_itv/= ?normr_ge0 ?invr_ge0//. -by rewrite invf_le1 ?ler1n. +rewrite {2 4}(_ : 2^-1 = 1 - 2^-1); last by rewrite {2}(splitr 1) div1r addrK. +by apply: (convex_powR p1 (Itv01 _ _)) => //=; + rewrite ?inE/= ?in_itv/= ?normr_ge0// ?invr_ge0// invf_le1 ?ler1n. Qed. Let measurableT_comp_powR f p : diff --git a/theories/kernel.v b/theories/kernel.v index a9cce8456..b94e43867 100644 --- a/theories/kernel.v +++ b/theories/kernel.v @@ -1577,14 +1577,14 @@ Definition mkproduct := End kproduct_measure. -(* [Theorem 14.22, Klenke 2014] (3/3): the composition of finite transition - kernels is sigma-finite *) HB.instance Definition _ d0 d1 d2 (T0 : measurableType d0) (T1 : measurableType d1) (T2 : measurableType d2) {R : realType} (k1 : R.-ftker T0 ~> T1) (k2 : R.-ftker (T0 * T1) ~> T2) := @isKernel.Build _ _ T0 (T1 * T2)%type R (mkproduct k1 k2) (measurable_kproduct k1 k2). +(* [Theorem 14.22, Klenke 2014] (3/3): the composition of finite transition + kernels is sigma-finite *) Section sigma_finite_kproduct. Context d0 d1 d2 (T0 : measurableType d0) (T1 : measurableType d1) (T2 : measurableType d2) {R : realType} diff --git a/theories/lebesgue_integral_theory/lebesgue_Rintegral.v b/theories/lebesgue_integral_theory/lebesgue_Rintegral.v index f2370e0ab..4c635bc68 100644 --- a/theories/lebesgue_integral_theory/lebesgue_Rintegral.v +++ b/theories/lebesgue_integral_theory/lebesgue_Rintegral.v @@ -7,8 +7,8 @@ From mathcomp Require Import cardinality reals fsbigop interval_inference ereal. From mathcomp Require Import topology tvs normedtype sequences real_interval. From mathcomp Require Import function_spaces esum measure lebesgue_measure. From mathcomp Require Import numfun realfun simple_functions. +From mathcomp Require Import measurable_fun_approximation. From mathcomp Require Import lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. From mathcomp Require Import lebesgue_integral_monotone_convergence. From mathcomp Require Import lebesgue_integral_nonneg. From mathcomp Require Import lebesgue_integrable. diff --git a/theories/lebesgue_integral_theory/lebesgue_integrable.v b/theories/lebesgue_integral_theory/lebesgue_integrable.v index dab72d85f..cddc5321e 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integrable.v +++ b/theories/lebesgue_integral_theory/lebesgue_integrable.v @@ -7,8 +7,8 @@ From mathcomp Require Import functions cardinality reals fsbigop. From mathcomp Require Import interval_inference topology ereal tvs normedtype. From mathcomp Require Import sequences real_interval function_spaces esum. From mathcomp Require Import measure lebesgue_measure numfun realfun. -From mathcomp Require Import simple_functions lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. +From mathcomp Require Import simple_functions measurable_fun_approximation. +From mathcomp Require Import lebesgue_integral_definition. From mathcomp Require Import lebesgue_integral_monotone_convergence. From mathcomp Require Import lebesgue_integral_nonneg. @@ -68,8 +68,10 @@ have /integrableP intone : mu.-integrable D (f \_ N). by apply/measurable_restrict => //; exact: measurable_funS mf. rewrite (eq_integral ((abse \o f) \_ N)); last first. by move=> t _; rewrite restrict_abse. - rewrite -integral_mkcondr (@integral_abs_eq0 _ _ _ _ D)//; first exact: measurableI. - by apply: (subset_measure0 _ _ _ muN0) => //; exact: measurableI. + rewrite -integral_mkcondr integral_abs_eq0//. + - exact: measurableI. + - exact: measurable_funS mf. + - by apply: (subset_measure0 _ _ _ muN0) => //; exact: measurableI. have h1 : mu.-integrable D f <-> mu.-integrable D (f \_ ~` N). split=> [/integrableP intf|/integrableP intCf]. apply/integrableP; split. @@ -519,8 +521,6 @@ Lemma integralZr r : Proof. by rewrite muleC -integralZl; under eq_integral do rewrite muleC. Qed. End integralZl. -#[deprecated(since="mathcomp-analysis 0.6.4", note="use `integralZl` instead")] -Notation integralM := integralZl (only parsing). Section integralD_EFin. Local Open Scope ereal_scope. @@ -982,7 +982,7 @@ move=> itf itg fg; pose E j := D `&` [set x | f x - g x >= j.+1%:R^-1%:E]. have msf := measurable_int _ itf. have msg := measurable_int _ itg. have mE j : measurable (E j). - rewrite /E; apply: emeasurable_fun_le => //. + rewrite /E; apply: measurable_lee => //. by apply/(emeasurable_funD msf)/measurableT_comp => //; case: mg. have muE j : mu (E j) = 0. apply/eqP; rewrite -measure_le0. @@ -1031,12 +1031,9 @@ have mufg : mu (D `&` [set x | f x < g x]) = 0. have h : ~` [set x | D x -> f x = g x] = D `&` [set x | f x != g x]. apply/seteqP; split => [x/= /not_implyP[? /eqP]//|x/= [Dx fgx]]. by apply/not_implyP; split => //; exact/eqP. -apply/negligibleP. - by rewrite h; apply: emeasurable_fun_neq. -rewrite h set_neq_lt setIUr measureU//. +apply/negligibleP; first by rewrite h; apply: measurable_neqe. +rewrite h set_neq_lt setIUr measureU//; [|exact: measurable_lte..|]. - by rewrite [X in X + _]mufg add0e [LHS]mugf. -- exact: emeasurable_fun_lt. -- exact: emeasurable_fun_lt. - apply/seteqP; split => [x [[Dx/= + [_]]]|//]. by move=> /lt_trans => /[apply]; rewrite ltxx. Qed. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral.v b/theories/lebesgue_integral_theory/lebesgue_integral.v index a3980ea41..7bfb2c3bd 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral.v @@ -1,7 +1,7 @@ (* mathcomp analysis (c) 2025 Inria and AIST. License: CeCILL-C. *) From mathcomp Require Export simple_functions. +From mathcomp Require Export measurable_fun_approximation. From mathcomp Require Export lebesgue_integral_definition. -From mathcomp Require Export lebesgue_integral_approximation. From mathcomp Require Export lebesgue_integral_monotone_convergence. From mathcomp Require Export lebesgue_integral_nonneg. From mathcomp Require Export lebesgue_integrable. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_definition.v b/theories/lebesgue_integral_theory/lebesgue_integral_definition.v index b9fbb6918..4299c6c2b 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_definition.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral_definition.v @@ -65,8 +65,7 @@ Proof. by []. Qed. End simple_fun_raw_integral. -#[global] Hint Extern 0 (is_true (0 <= (_ : {measure set _ -> \bar _}) _)%E) => - solve [apply: measure_ge0] : core. +#[global] Hint Extern 0 (is_true (0 <= _)) => solve [apply: measure_ge0] : core. Section sintegral_lemmas. Context d (T : sigmaRingType d) (R : realType). @@ -134,7 +133,7 @@ have [->|r0] := eqVneq r 0%R. rewrite !sintegralET ge0_mule_fsumr; last exact: nnsfun_mulemu_ge0. rewrite (reindex_fsbigT ( *%R r))/=; last first. by exists ( *%R r^-1); [exact: mulKf|exact: mulVKf]. -by apply: eq_fsbigr => x; rewrite preimage_cstM// [_ / r]mulrC mulKf// muleA. +by apply: eq_fsbigr => x; rewrite preimage_cstM// [(_ / r)%R]mulrC mulKf// muleA. Qed. End sintegralrM. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v b/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v index 6fff020c2..420dbf497 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral_differentiation.v @@ -7,8 +7,8 @@ From mathcomp Require Import cardinality reals fsbigop interval_inference ereal. From mathcomp Require Import topology tvs normedtype sequences real_interval. From mathcomp Require Import esum function_spaces measure lebesgue_measure. From mathcomp Require Import numfun realfun simple_functions. +From mathcomp Require Import measurable_fun_approximation. From mathcomp Require Import lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. From mathcomp Require Import lebesgue_integral_monotone_convergence. From mathcomp Require Import lebesgue_integral_nonneg. From mathcomp Require Import lebesgue_integrable. @@ -95,9 +95,9 @@ suff apxf eps : exists h : rT -> rT, (eps > 0)%R -> [/\ continuous h, mu.-integrable E (EFin \o h) & \int[mu]_(z in E) `|(f z - h z)%:E| < eps%:E]. - pose g_ n := projT1 (cid (apxf n.+1%:R^-1)); exists g_; split. - - by move=> n; have [] := projT2 (cid (apxf n.+1%:R^-1)). - - by move=> n; have [] := projT2 (cid (apxf n.+1%:R^-1)). + pose g_ n := projT1 (cid (apxf n.+1%:R^-1)%R); exists g_; split. + - by move=> n; have [] := projT2 (cid (apxf n.+1%:R^-1%R)). + - by move=> n; have [] := projT2 (cid (apxf n.+1%:R^-1%R)). apply/cvg_ballP => eps epspos. have /cvg_ballP/(_ eps epspos)[N _ Nball] := @cvge_harmonic rT. exists N => //; apply: (subset_trans Nball) => n. @@ -105,7 +105,7 @@ suff apxf eps : exists h : rT -> rT, (eps > 0)%R -> rewrite ?ger0_norm; first last. - by rewrite -le_expandLR // ?inE ?normr0// expand0 integral_ge0. - by rewrite -le_expandLR // ?inE ?normr0// expand0. - have [] := projT2 (cid (apxf n.+1%:R^-1)) => // _ _ ipaxfn. + have [] := projT2 (cid (apxf n.+1%:R^-1%R)) => // _ _ ipaxfn. by rewrite -lt_expandRL ?contractK// inE contract_le1. have [|] := ltP 0%R eps; last by exists point. move: eps => _/posnumP[eps]. @@ -113,7 +113,7 @@ have [g [gfe2 ig]] : exists g : {sfun R >-> rT}, \int[mu]_(z in E) `|(f z - g z)%:E| < (eps%:num / 2)%:E /\ mu.-integrable E (EFin \o g). have [g_ [intG ?]] := approximation_sfun_integrable mE intf. - move/fine_fcvg/cvg_ballP/(_ (eps%:num / 2)) => -[] // n _ Nb; exists (g_ n). + move/fine_fcvg/cvg_ballP/(_ (eps%:num / 2)%R) => -[] // n _ Nb; exists (g_ n). have fg_fin_num : \int[mu]_(z in E) `|(f z - g_ n z)%:E| \is a fin_num. rewrite integral_fune_fin_num// integrable_abse//. by under eq_fun do rewrite EFinB; apply: integrableB => //; exact: intG. @@ -372,18 +372,16 @@ Local Open Scope ereal_scope. Local Notation mu := lebesgue_measure. -Definition iavg f A := (fine (mu A))^-1%:E * \int[mu]_(y in A) `| (f y)%:E |. +Definition iavg f A := (mu A)^-1 * \int[mu]_(y in A) `| (f y)%:E |. Lemma iavg0 f : iavg f set0 = 0. Proof. by rewrite /iavg integral_set0 mule0. Qed. Lemma iavg_ge0 f A : 0 <= iavg f A. -Proof. -by rewrite /iavg mule_ge0 ?integral_ge0// lee_fin invr_ge0// fine_ge0. -Qed. +Proof. by rewrite /iavg mule_ge0 ?integral_ge0// inve_ge0. Qed. Lemma iavg_restrict f D A : measurable D -> measurable A -> - iavg (f \_ D) A = ((fine (mu A))^-1)%:E * \int[mu]_(y in D `&` A) `|f y|%:E. + iavg (f \_ D) A = (mu A)^-1 * \int[mu]_(y in D `&` A) `|f y|%:E. Proof. move=> mD mA; rewrite /iavg setIC [in RHS]integral_mkcondr/=; congr *%E. apply: eq_integral => /= y yx1. @@ -395,14 +393,22 @@ Lemma iavgD f g A : measurable A -> mu A < +oo -> iavg (f \+ g)%R A <= iavg f A + iavg g A. Proof. move=> mA Aoo mf mg; have [r0|r0] := eqVneq (mu A) 0. - by rewrite /iavg r0/= invr0 !mul0e adde0. -rewrite -muleDr//=; last by rewrite ge0_adde_def// inE integral_ge0. -rewrite lee_pmul2l//; last first. - by rewrite lte_fin invr_gt0// fine_gt0// Aoo andbC/= lt0e r0/=. + rewrite /iavg integral_abs_eq0//= ?mule0; last first. + exact/measurable_EFinP/measurable_funD. + rewrite (@integral_abs_eq0 _ _ _ mu _ (EFin \o f))//= ?mule0; last first. + exact/measurable_EFinP. + rewrite (@integral_abs_eq0 _ _ _ mu _ (EFin \o g))//= ?mule0 ?adde0//. + exact: measurableT_comp. +rewrite -muleDr//=; last 2 first. + by rewrite fin_numV// -ltNye// (@lt_le_trans _ _ 0). + by rewrite ge0_adde_def// inE integral_ge0. +rewrite lee_pmul2l//; last 2 first. + by rewrite fin_numV// -ltNye// (@lt_le_trans _ _ 0). + by rewrite inve_gt0 -?ltey// measure_gt0. rewrite -ge0_integralD//=; [|by do 2 apply: measurableT_comp..]. apply: ge0_le_integral => //=. - by do 2 apply: measurableT_comp => //; exact: measurable_funD. -- by move=> /= x _; rewrite adde_ge0. +- by move=> /= x _; exact: adde_ge0. - by apply: measurableT_comp => //; apply: measurable_funD => //; exact: measurableT_comp. - by move=> /= x _; exact: ler_normD. @@ -424,11 +430,10 @@ Local Notation HL := HL_maximal. Lemma HL_maximal_ge0 f D : locally_integrable D f -> forall x, 0 <= HL (f \_ D) x. Proof. -move=> Df x; apply: ereal_sup_le => //=. +move=> Df x; apply: ereal_sup_ge => //=. pose k := \int[mu]_(x in D `&` ball x 1) `|f x|%:E. -exists ((fine (mu (ball x 1)))^-1%:E * k); last first. - rewrite mule_ge0 ?integral_ge0//. - by rewrite lee_fin// invr_ge0// fine_ge0. +exists ((mu (ball x 1))^-1 * k); last first. + by rewrite mule_ge0 ?inve_ge0// integral_ge0. exists 1%R; first by rewrite in_itv/= ltr01. rewrite iavg_restrict//; last exact: measurable_ball. by case: Df => _ /open_measurable. @@ -467,12 +472,11 @@ have k_gt0 : 0 < k. move: a0; rewrite le_eqVlt => /predU1P[a0|a0]. move: afxr; rewrite -{a}a0 => xrk. near (0%R : R)^'+ => d. - have xrdk : 0 < (fine (mu (ball x (r + d))))^-1%:E * k. - rewrite mule_gt0// lte_fin invr_gt0// fine_gt0//. - rewrite lebesgue_measure_ball; last by rewrite addr_ge0// ltW. - by rewrite ltry andbT lte_fin pmulrn_lgt0// addr_gt0. - exists (ball x d). - by split; [exact: ball_open|exact: ballxx]. + have xrdk : 0 < (mu (ball x (r + d)))^-1 * k. + rewrite mule_gt0// lebesgue_measure_ball; last by rewrite addr_ge0// ltW. + rewrite inver mulrn_eq0/= gt_eqF; last by rewrite addr_gt0. + by rewrite lte_fin// invr_gt0// pmulrn_lgt0// addr_gt0. + exists (ball x d); first by split; [exact: ball_open|exact: ballxx]. move=> y; rewrite /ball/= => xyd. have ? : ball x r `<=` ball y (r + d). move=> /= z; rewrite /ball/= => xzr; rewrite -(subrK x y) -(addrA (y - x)%R). @@ -486,9 +490,8 @@ move: a0; rewrite le_eqVlt => /predU1P[a0|a0]. by rewrite in_itv/= andbT addr_gt0. apply/lt_le_trans/(lt_le_trans xrdk); rewrite /iavg. do 2 (rewrite lebesgue_measure_ball; last by rewrite addr_ge0// ltW). - rewrite lee_wpmul2l// lee_fin invr_ge0// fine_ge0// lee_fin pmulrn_rge0//. - by rewrite addr_gt0. -have ka_pos : fine k / a \is Num.pos. + by rewrite lee_wpmul2l// inve_ge0 lee_fin pmulrn_rge0// addr_gt0. +have ka_pos : (fine k / a)%R \is Num.pos. by rewrite posrE divr_gt0// fine_gt0 // k_gt0/= locally_integrable_ltbally. have k_fin_num : k \is a fin_num. by rewrite ge0_fin_numE ?locally_integrable_ltbally ?integral_ge0. @@ -496,16 +499,18 @@ have kar : (0 < 2^-1 * (fine k / a) - r)%R. move: afxr; rewrite -{1}(fineK k_fin_num) -lte_pdivrMr; last first. by rewrite fine_gt0// k_gt0/= ltey_eq k_fin_num. rewrite (lebesgue_measure_ball _ (ltW r0))//. - rewrite -!EFinM !lte_fin -invf_div ltf_pV2 ?posrE ?pmulrn_lgt0//. + rewrite -!EFinM inver mulrn_eq0/= gt_eqF// lte_fin -invf_div. + rewrite ltf_pV2 ?posrE ?pmulrn_lgt0//. rewrite /= -[in X in X -> _]mulr_natl -ltr_pdivlMl//. by rewrite -[in X in X -> _]subr_gt0. near (0%R : R)^'+ => d. -have axrdk : a%:E < (fine (mu (ball x (r + d))))^-1%:E * k. +have axrdk : a%:E < (mu (ball x (r + d)))^-1 * k. rewrite lebesgue_measure_ball//; last by rewrite addr_ge0// ltW. + rewrite inver mulrn_eq0/= gt_eqF ?addr_gt0//. rewrite -(fineK k_fin_num) -lte_pdivrMr; last first. by rewrite fine_gt0// k_gt0/= locally_integrable_ltbally. rewrite -!EFinM !lte_fin -invf_div ltf_pV2//; last first. - by rewrite posrE fine_gt0// ltry andbT lte_fin pmulrn_lgt0// addr_gt0. + by rewrite posrE// pmulrn_lgt0// addr_gt0. rewrite -mulr_natl -ltr_pdivlMl// -ltrBrDl. by near: d; exact: nbhs_right_lt. exists (ball x d). @@ -518,15 +523,13 @@ have ? : k <= \int[mu]_(z in ball y (r + d)) `|(f z)%:E|. apply: ge0_subset_integral => //; [exact: measurable_ball| exact: measurable_ball|]. exact/measurable_funTS/measurableT_comp/measurableT_comp. -have afxrdi : a%:E < (fine (mu (ball x (r + d))))^-1%:E * +have afxrdi : a%:E < (mu (ball x (r + d)))^-1 * \int[mu]_(z in ball y (r + d)) `|(f z)%:E|. - apply/(lt_le_trans axrdk)/lee_wpmul2l => //. - by rewrite lee_fin invr_ge0 fine_ge0. + by apply/(lt_le_trans axrdk)/lee_wpmul2l => //; rewrite inve_ge0. have /lt_le_trans : a%:E < iavg f (ball y (r + d)). apply: (lt_le_trans afxrdi); rewrite /iavg. do 2 (rewrite lebesgue_measure_ball; last by rewrite addr_ge0// ltW). - rewrite lee_wpmul2l ?lexx// lee_fin invr_ge0// fine_ge0//= lee_fin. - by rewrite pmulrn_rge0// addr_gt0. + by rewrite inver. apply; apply: ereal_sup_ubound => /=. by exists (r + d)%R => //; rewrite in_itv/= andbT addr_gt0. Unshelve. all: by end_near. Qed. @@ -560,12 +563,9 @@ have cMfx_int x : c%:E < HL f x -> \int[mu]_(y in ball x (r_ x)) `|(f y)|%:E > c%:E * mu (ball x (r_ x)). move=> cMfx; rewrite /r_; case: pselect => //= => {}cMfx. case: (r_proof _ cMfx) => /= r r0. - have ? : 0 < (fine (mu (ball x r)))%:E. - rewrite lte_fin fine_gt0// (lebesgue_measure_ball _ (ltW r0))// ltry. - by rewrite lte_fin mulrn_wgt0. - rewrite /iavg -(@lte_pmul2r _ (fine (mu (ball x r)))%:E)//. - rewrite muleAC -[in X in _ < X]EFinM mulVf ?gt_eqF// mul1e fineK//. - by rewrite ge0_fin_numE// (lebesgue_measure_ball _ (ltW r0)) ltry. + rewrite /iavg (lebesgue_measure_ball _ (ltW r0)) inver mulrn_eq0//= gt_eqF//. + rewrite -(@lte_pmul2r _ (r *+ 2)%:E)//; last by rewrite lte_fin// pmulrn_rgt0. + by rewrite muleAC -[in X in _ < X]EFinM mulVf ?gt_eqF ?pmulrn_rgt0// mul1e. set B := fun r => ball r (r_ r). have {}Kcmf : K `<=` cover [set i | HL f i > c%:E] (fun i => ball i (r_ i)). by move=> r /Kcmf /= cMfr; exists r => //; exact: ballxx. @@ -698,7 +698,8 @@ near (0%R:R)^'+ => r. have r0 : (0 < r)%R by near: r; exact: nbhs_right_gt. have [d /= d0 {}fx'] := fx' _ e0. near=> t; have [t0|t0] := leP t 0%R; first by rewrite davg0. -by rewrite fin_numM// exf/=. +rewrite fin_numM ?exf//=. +by rewrite (lebesgue_measure_ball _ (ltW _))// inver mulrn_eq0/= gt_eqF. Unshelve. all: by end_near. Qed. Lemma continuous_cvg_davg : davg f x r @[r --> 0%R] --> 0. @@ -713,8 +714,8 @@ near=> t. have [t0|t0] := leP t 0%R; first by rewrite /= davg0//= subrr normr0 ltW. rewrite sub0r normrN /= ger0_norm; last by rewrite fine_ge0// davg_ge0. rewrite -lee_fin fineK//; last by rewrite dfx//= sub0r normrN gtr0_norm. -rewrite /davg/= /iavg/= lee_pdivrMl//; last first. - by rewrite fine_gt0// lebesgue_measure_ball// ?ltry ?lte_fin ?mulrn_wgt0 ?ltW. +rewrite /davg/= /iavg/= (lebesgue_measure_ball _ (ltW t0))//. +rewrite inver mulrn_eq0/= gt_eqF// lee_pdivrMl//; last by rewrite pmulrn_rgt0. rewrite (@le_trans _ _ (\int[mu]_(y in ball x t) e%:E))//. apply: ge0_le_integral => //=. - exact: measurable_ball. @@ -724,7 +725,7 @@ rewrite (@le_trans _ _ (\int[mu]_(y in ball x t) e%:E))//. - move=> y xty; rewrite lee_fin distrC fx'//; apply: (lt_le_trans xty). by near: t; exact: nbhs0_ltW. rewrite integral_cst//=; last exact: measurable_ball. -by rewrite muleC fineK// (lebesgue_measure_ball _ (ltW t0)). +by rewrite muleC (lebesgue_measure_ball _ (ltW t0)). Unshelve. all: by end_near. Qed. End continuous_cvg_davg. @@ -810,11 +811,9 @@ near=> e. apply: ub_ereal_sup => _ [b [eb] /= b0] <-. suff : forall r, davg f x r <= HL_maximal f x + `|f x|%:E by exact. move=> r. -apply: (@le_trans _ _ ((fine (mu (ball x r)))^-1%:E * +apply: (@le_trans _ _ ((mu (ball x r))^-1 * \int[mu]_(y in ball x r) (`|(f y)%:E| + `|(f x)%:E|))). - - rewrite /davg lee_wpmul2l//. - by rewrite lee_fin invr_ge0 fine_ge0. - apply: ge0_le_integral => //. + - rewrite /davg lee_wpmul2l ?inve_ge0//; apply: ge0_le_integral => //. + exact: measurable_ball. + do 2 apply: measurableT_comp => //=; apply: measurable_funB => //. exact: measurableT_comp. @@ -822,7 +821,7 @@ apply: (@le_trans _ _ ((fine (mu (ball x r)))^-1%:E * + apply: emeasurable_funD => //; do 2 apply: measurableT_comp => //. exact: measurable_funS mf. by move=> /= y xry; rewrite -EFinD lee_fin// ler_normB. -rewrite [leLHS](_ : _ = (fine (mu (ball x r)))^-1%:E * +rewrite [leLHS](_ : _ = (mu (ball x r))^-1 * (\int[mu]_(y in ball x r) `|(f y)%:E| + \int[mu]_(y in ball x r) `|(f x)%:E|)); last first. congr *%E; rewrite ge0_integralD//=; first exact: measurable_ball. @@ -830,16 +829,16 @@ rewrite [leLHS](_ : _ = (fine (mu (ball x r)))^-1%:E * have [r0|r0] := lerP r 0. rewrite (ball0 _ _).2// !integral_set0 adde0 mule0 adde_ge0//. by apply: HL_maximalT_ge0; split => //; exact: openT. -rewrite muleDr//; last by rewrite ge0_adde_def// inE integral_ge0. +rewrite muleDr//; last 2 first. + by rewrite (lebesgue_measure_ball _ (ltW r0)) inver mulrn_eq0//= gt_eqF. + by rewrite ge0_adde_def// inE integral_ge0. rewrite leeD//. - by apply: ereal_sup_ubound => /=; exists r => //; rewrite in_itv/= r0. + by apply: ereal_sup_ubound => /=; exists r => //; rewrite in_itv/= r0. under eq_integral do rewrite -(mule1 `| _ |). rewrite ge0_integralZl//; last exact: measurable_ball. -rewrite integral_cst//; last exact: measurable_ball. -rewrite mul1e muleCA !(lebesgue_measure_ball _ (ltW r0)). -rewrite [X in _ * (_ * X)](_ : _ = mu (ball x r))//. -rewrite (lebesgue_measure_ball _ (ltW r0))//. -by rewrite /= -EFinM mulVf ?mulr1// mulrn_eq0/= gt_eqF. +rewrite integral_cst//=; last exact: measurable_ball. +rewrite mul1e muleCA (lebesgue_measure_ball _ (ltW r0)). +by rewrite inver mulrn_eq0 ?gt_eqF// -EFinM mulVf ?mulr1// mulrn_eq0/= gt_eqF. Unshelve. all: by end_near. Qed. End lim_sup_davg. @@ -888,7 +887,7 @@ move=> Ef; have {Ef} : mu.-negligible (E `&` [set x | 0 < f^* x]). near \oo => m; exists m => //=. rewrite -(@fineK _ (f^* x)) ?gt0_fin_numE ?ltey// lte_fin. rewrite invf_plt ?posrE//; last by rewrite fine_gt0// ltey fx0. - set r := _^-1; rewrite (lt_le_trans (truncnS_gt _))//. + set r := _^-1%R; rewrite (lt_le_trans (truncnS_gt _))//. by rewrite ler_nat ltnS; near: m; exact: nbhs_infty_ge. apply: negligibleS => z /= /not_implyP[Ez H]; split => //. rewrite ltNge; apply: contra_notN H. @@ -920,7 +919,7 @@ have {ex_g_} ex_gn n : exists gn : R -> R, mu.-integrable (B k) (EFin \o gn) & \int[mu]_(z in B k) `|f_ k z - gn z|%:E <= n.+1%:R^-1%:E]. case: ex_g_ => g_ [cg intg] /fine_cvgP[] [m _ fgfin] /cvgrPdist_le. - move=> /(_ n.+1%:R^-1 ltac:(by []))[p _] /(_ _ (leq_addr m p)). + move=> /(_ n.+1%:R^-1%R ltac:(by []))[p _] /(_ _ (leq_addr m p)). rewrite sub0r normrN -lee_fin => /= fg0. exists (g_ (p + m)%N); split => //. rewrite (le_trans _ fg0)// ger0_norm ?fine_ge0 ?integral_ge0// fineK//. @@ -1014,7 +1013,7 @@ have fgn_null n : mu [set x | `|(f_ k \- g_B n) x|%:E >= (e / 2)%:E] <= rewrite lee_pdivlMl ?invr_gt0 ?divr_gt0// -[X in mu X]setTI. apply: le_trans. apply: (@le_integral_comp_abse _ _ _ mu _ measurableT - (EFin \o (f_ k \- g_B n)%R) (e / 2) id) => //=. + (EFin \o (f_ k \- g_B n)%R) (e / 2)%R id) => //=. by apply: measurableT_comp => //; case: (locf_g_B n). by rewrite divr_gt0. set h := (fun x => `|(f_ k \- g_ n) x|%:E) \_ (B k). @@ -1037,7 +1036,7 @@ rewrite (@le_trans _ _ ((4 / (e / 2))%:E * n.+1%:R^-1%:E))//. by apply: measurableU => //; [exact: mEHL|exact: mfge]. rewrite (le_trans (measureU2 _ _ _))//=; [exact: mEHL|exact: mfge|]. apply: le_trans; first by apply: leeD; [exact: HL_null|exact: fgn_null]. - rewrite -muleDl// lee_pmul2r// -EFinD lee_fin -{2}(mul1r (_^-1)). + rewrite -muleDl// lee_pmul2r// -EFinD lee_fin -{2}(mul1r (_^-1)%R). by rewrite -mulrDl natr1. rewrite -lee_pdivlMl ?divr_gt0// -EFinM lee_fin -(@invrK _ r). rewrite -invfM lef_pV2 ?posrE ?divr_gt0// -(@natr1 _ n) -lerBlDr. @@ -1117,7 +1116,7 @@ Local Notation mu := lebesgue_measure. Local Open Scope ereal_scope. Lemma lebesgue_density (A : set R) : measurable A -> - {ae mu, forall x, mu (A `&` ball x r) * (fine (mu (ball x r)))^-1%:E + {ae mu, forall x, mu (A `&` ball x r) * (mu (ball x r))^-1 @[r --> 0^'+] --> (\1_A x)%:E}. Proof. move=> mA; have := lebesgue_differentiation (locally_integrable_indic openT mA). @@ -1125,18 +1124,17 @@ apply: filter_app; first exact: (ae_filter_ringOfSetsType mu). apply: aeW => /= x Ax. apply: (sube_cvg0 _ _).1 => //. move: Ax; rewrite /lebesgue_pt /davg /= -/mu => Ax. -have : (fine (mu (ball x r)))^-1%:E * +have : (mu (ball x r))^-1 * `|\int[mu]_(y in ball x r) (\1_A y - \1_A x)%:E | @[r --> 0^'+] --> 0. apply: (@squeeze_cvge _ _ _ R (cst 0) _ _ _ _ _ Ax) => //; [|exact: cvg_cst]. - near=> a. - apply/andP; split; first by rewrite mule_ge0// lee_fin invr_ge0// fine_ge0. - rewrite lee_pmul2l//; last first. - rewrite lte_fin invr_gt0// fine_gt0//. - by rewrite lebesgue_measure_ball// ltry andbT lte_fin mulrn_wgt0. + near=> a; rewrite mule_ge0 ?inve_ge0///= lee_pmul2l//; last 2 first. + by rewrite lebesgue_measure_ball// fin_numV// eqe mulrn_eq0/= gt_eqF. + rewrite lebesgue_measure_ball// inver mulrn_eq0/= gt_eqF// lte_fin. + by rewrite invr_gt0// pmulrn_rgt0. apply: le_abse_integral => //; first exact: measurable_ball. - by apply/measurable_EFinP; exact: measurable_funB. + exact/measurable_EFinP/measurable_funB. set f := (f in f r @[r --> 0^'+] --> _ -> _). -rewrite (_ : f = fun r => (fine (mu (ball x r)))^-1%:E * +rewrite (_ : f = fun r => (mu (ball x r))^-1 * `|mu (A `&` ball x r) - (\1_A x)%:E * mu (ball x r)|); last first. apply/funext => r; rewrite /f integralB_EFin//=; last 3 first. - exact: measurable_ball. @@ -1160,7 +1158,7 @@ rewrite (_ : f = fun r => (fine (mu (ball x r)))^-1%:E * rewrite indicE; have [xA xrA0|xA] := boolP (x \in A); last first. apply: iffRL; apply/propeqP; apply: eq_cvg => r. by rewrite -mulNrn mulr0n adde0 mul0e sube0 gee0_abs// muleC. -have {xrA0} /cvgeN : (fine (mu (ball x r)))^-1%:E * +have {xrA0} /cvgeN : (mu (ball x r))^-1 * (mu (ball x r) - mu (A `&` ball x r)) @[r --> 0^'+] --> 0. move: xrA0; apply: cvg_trans; apply: near_eq_cvg; near=> r. rewrite mul1e lee0_abs; last first. @@ -1170,12 +1168,12 @@ have {xrA0} /cvgeN : (fine (mu (ball x r)))^-1%:E * rewrite fin_num_adde_defl// fin_numN ge0_fin_numE//. by rewrite lebesgue_measure_ball// ltry. rewrite oppe0; apply: cvg_trans; apply: near_eq_cvg; near=> r. -rewrite -mulNrn mulr1n muleBr//; last first. +rewrite -mulNrn mulr1n muleBr//; last 2 first. + by rewrite lebesgue_measure_ball// inver mulrn_eq0//= gt_eqF. by rewrite fin_num_adde_defr// ge0_fin_numE// lebesgue_measure_ball//= ?ltry. -rewrite (_ : (fine (mu (ball x r)))^-1%:E * mu (ball x r) = 1); last first. - rewrite -[X in _ * X](@fineK _ (mu (ball x r)))//; last first. - by rewrite lebesgue_measure_ball//= ?ltry. - by rewrite -EFinM mulVf// lebesgue_measure_ball//= gt_eqF// mulrn_wgt0. +rewrite (_ : (mu (ball x r))^-1 * mu (ball x r) = 1); last first. + rewrite lebesgue_measure_ball// inver mulrn_eq0//= gt_eqF//. + by rewrite -EFinM mulVf// mulrn_eq0/= gt_eqF. by rewrite oppeB// addeC EFinN muleC. Unshelve. all: by end_near. Qed. @@ -1211,6 +1209,10 @@ rewrite (@le_lt_trans _ _ (lebesgue_measure (ball x (r_ n)%:num)))//. by rewrite lebesgue_measure_ball// ltry. Qed. +Lemma nicely_shrinking_fin_num x E : nicely_shrinking x E -> + forall n, mu (E n) \is a fin_num. +Proof. by move=> xE n; rewrite ge0_fin_numE// (nicely_shrinking_lty xE). Qed. + End nicely_shrinking. Section nice_lebesgue_differentiation. @@ -1220,9 +1222,10 @@ Variable E : R -> (set R)^nat. Hypothesis hE : forall x, nicely_shrinking x (E x). Local Notation mu := lebesgue_measure. + Lemma nice_lebesgue_differentiation (f : R -> R) : locally_integrable setT f -> forall x, lebesgue_pt f x -> - (fine (mu (E x n)))^-1%:E * \int[mu]_(y in E x n) (f y)%:E + (mu (E x n))^-1 * \int[mu]_(y in E x n) (f y)%:E @[n --> \oo] --> (f x)%:E. Proof. move=> locf x fx; apply: (sube_cvg0 _ _).1 => //=; apply/cvg_abse0P. @@ -1239,27 +1242,25 @@ apply: (@squeeze_cvge _ _ _ _ (cst 0) _ (fun n => C%:E * davg f x (r_ x n)%:num)); last 2 first. exact: cvg_cst. move/cvge_at_rightP: fx => /(_ (fun r => (r_ x r)%:num)) fx. - by rewrite -(mule0 C%:E); apply: cvgeM => //;[exact: mule_def_fin | - exact: cvg_cst | apply: fx; split => //; exact: r_0]. + by rewrite -(mule0 C%:E); apply: cvgeM => //; + [exact: cvg_cst | apply: fx; split => //; exact: r_0]. near=> n. apply/andP; split => //=. -apply: (@le_trans _ _ ((fine (mu (E x n)))^-1%:E * +apply: (@le_trans _ _ ((mu (E x n))^-1 * `| \int[mu]_(y in E x n) ((f y)%:E + (- f x)%:E) |)). have fxE : (- f x)%:E = - (fine (mu (E x n)))^-1%:E * \int[mu]_(y in E x n) (- f x)%:E. + (mu (E x n))^-1 * \int[mu]_(y in E x n) (- f x)%:E. rewrite integral_cst//=; last exact: (hE _).1. - rewrite muleCA -[X in _ * (_ * X)](@fineK _ (mu (E x n))); last first. - by rewrite ge0_fin_numE// (nicely_shrinking_lty (hE x)). - rewrite -EFinM mulVf ?mulr1// neq_lt fine_gt0 ?orbT//. - by rewrite (nicely_shrinking_gt0 (hE x))//= (nicely_shrinking_lty (hE x)). - rewrite [in leLHS]fxE -muleDr//; last first. + rewrite muleCA mulVe ?mule1 ?(nicely_shrinking_fin_num (hE x))//. + by rewrite gt_eqF// (nicely_shrinking_gt0 (hE x)). + rewrite [in leLHS]fxE -muleDr//; last 2 first. + rewrite fin_numV//. + by rewrite -measure_gt0/= (nicely_shrinking_gt0 (hE x)). + by rewrite -ltNye (@lt_le_trans _ _ 0). rewrite integral_cst//=; last exact: (hE _).1. - rewrite fin_num_adde_defl// fin_numM// gt0_fin_numE. - by rewrite (nicely_shrinking_lty (hE x)). - by rewrite (nicely_shrinking_gt0 (hE x)). - rewrite abseM gee0_abs; last by rewrite lee_fin// invr_ge0// fine_ge0. - rewrite lee_pmul//; first by rewrite lee_fin// invr_ge0// fine_ge0. - rewrite integralD//=. + by rewrite fin_num_adde_defl// fin_numM// (nicely_shrinking_fin_num (hE x)). + rewrite abseM gee0_abs; last by rewrite inve_ge0. + rewrite lee_pmul ?inve_ge0// integralD//=. - exact: (hE x).1. - apply/integrableP; split. by apply/measurable_EFinP; case: locf => + _ _; exact: measurable_funS. @@ -1276,16 +1277,18 @@ apply: (@le_trans _ _ ((fine (mu (E x n)))^-1%:E * rewrite integral_cst //=; last exact: (hE _).1. by rewrite lte_mul_pinfty// (nicely_shrinking_lty (hE x)). rewrite muleA lee_pmul//. -- by rewrite lee_fin invr_ge0// fine_ge0. -- rewrite -(@invrK _ C) -EFinM -invfM lee_fin lef_pV2//; last 2 first. +- by rewrite inve_ge0. +- rewrite -(fineK (nicely_shrinking_fin_num (hE x) _)) inver gt_eqF; last first. + rewrite fine_gt0// (nicely_shrinking_gt0 (hE x))//=. + by rewrite (nicely_shrinking_lty (hE x)). + rewrite lebesgue_measure_ball// inver mulrn_eq0/= gt_eqF// -EFinM. + rewrite -(@invrK _ C) -invfM lee_fin lef_pV2//; last 2 first. rewrite posrE fine_gt0// (nicely_shrinking_gt0 (hE x))//=. by rewrite (nicely_shrinking_lty (hE x)). - rewrite posrE mulr_gt0// ?invr_gt0// fine_gt0//. - by rewrite lebesgue_measure_ball// ltry andbT lte_fin mulrn_wgt0. + by rewrite posrE mulr_gt0// ?invr_gt0// fine_gt0//. rewrite lter_pdivrMl // -lee_fin EFinM fineK; last first. - by rewrite lebesgue_measure_ball// ltry andbT lte_fin mulrn_wgt0. - rewrite fineK; last by rewrite ge0_fin_numE// (nicely_shrinking_lty (hE x)). - exact: muEr_. + by rewrite (nicely_shrinking_fin_num (hE x)). + by have := muEr_ n; rewrite lebesgue_measure_ball. - apply: le_trans. + apply: le_abse_integral => //; first exact: (hE x).1. apply/measurable_EFinP; apply/measurable_funB => //. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_dominated_convergence.v b/theories/lebesgue_integral_theory/lebesgue_integral_dominated_convergence.v index 2d542d3bd..e093742fb 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_dominated_convergence.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral_dominated_convergence.v @@ -7,8 +7,8 @@ From mathcomp Require Import cardinality reals fsbigop interval_inference ereal. From mathcomp Require Import topology tvs normedtype sequences real_interval. From mathcomp Require Import function_spaces esum measure lebesgue_measure. From mathcomp Require Import numfun realfun simple_functions. +From mathcomp Require Import measurable_fun_approximation. From mathcomp Require Import lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. From mathcomp Require Import lebesgue_integral_monotone_convergence. From mathcomp Require Import lebesgue_integral_nonneg. From mathcomp Require Import lebesgue_integrable. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_fubini.v b/theories/lebesgue_integral_theory/lebesgue_integral_fubini.v index b3512a203..83bf79b25 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_fubini.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral_fubini.v @@ -7,8 +7,8 @@ From mathcomp Require Import cardinality reals fsbigop interval_inference ereal. From mathcomp Require Import topology tvs normedtype sequences real_interval. From mathcomp Require Import esum measure lebesgue_measure numfun realfun. From mathcomp Require Import function_spaces simple_functions. +From mathcomp Require Import measurable_fun_approximation. From mathcomp Require Import lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. From mathcomp Require Import lebesgue_integral_monotone_convergence. From mathcomp Require Import lebesgue_integral_nonneg lebesgue_integrable. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_monotone_convergence.v b/theories/lebesgue_integral_theory/lebesgue_integral_monotone_convergence.v index cdba34dc4..71bad5b62 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_monotone_convergence.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral_monotone_convergence.v @@ -7,8 +7,8 @@ From mathcomp Require Import functions cardinality reals fsbigop. From mathcomp Require Import interval_inference topology ereal tvs normedtype. From mathcomp Require Import sequences real_interval function_spaces esum. From mathcomp Require Import measure lebesgue_measure numfun realfun. -From mathcomp Require Import simple_functions lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. +From mathcomp Require Import simple_functions measurable_fun_approximation. +From mathcomp Require Import lebesgue_integral_definition. (**md**************************************************************************) (* # Monotone convergence theorem for the Lebesgue Integral *) diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_nonneg.v b/theories/lebesgue_integral_theory/lebesgue_integral_nonneg.v index a1c12bb9a..329bdb0e6 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_nonneg.v +++ b/theories/lebesgue_integral_theory/lebesgue_integral_nonneg.v @@ -7,8 +7,8 @@ From mathcomp Require Import functions cardinality reals fsbigop. From mathcomp Require Import interval_inference topology ereal tvs normedtype. From mathcomp Require Import sequences real_interval function_spaces esum. From mathcomp Require Import measure lebesgue_measure numfun realfun. -From mathcomp Require Import simple_functions lebesgue_integral_definition. -From mathcomp Require Import lebesgue_integral_approximation. +From mathcomp Require Import simple_functions measurable_fun_approximation. +From mathcomp Require Import lebesgue_integral_definition. From mathcomp Require Import lebesgue_integral_monotone_convergence. (**md**************************************************************************) @@ -138,12 +138,10 @@ rewrite (@nd_ge0_integral_lim _ _ _ mu (fun x => k%:E * h1 x) kg). - by move=> x m n mn; rewrite /kg ler_pM//; exact/lefP/nd_nnsfun_approx. - move=> x. rewrite [X in X @ \oo --> _](_ : _ = (fun n => k%:E * (g n x)%:E)) ?funeqE//. - exact/cvgeMl/cvg_nnsfun_approx. + exact/cvgeZl/cvg_nnsfun_approx. Qed. End ge0_integralZl_EFin. -#[deprecated(since="mathcomp-analysis 0.6.4", note="use `ge0_integralZl_EFin` instead")] -Notation ge0_integralM_EFin := ge0_integralZl_EFin (only parsing). Section ge0_linearityD. Local Open Scope ereal_scope. @@ -322,8 +320,6 @@ by rewrite ge0_integralZl// muleC. Qed. End ge0_integralZ. -#[deprecated(since="mathcomp-analysis 0.6.4", note="use `ge0_integralZl` instead")] -Notation ge0_integralM := ge0_integralZl (only parsing). Section integralZl_indic. Local Open Scope ereal_scope. @@ -354,10 +350,6 @@ Qed. End integralZl_indic. Arguments integralZl_indic {d T R m D} mD f. -#[deprecated(since="mathcomp-analysis 0.6.4", note="use `integralZl_indic` instead")] -Notation integralM_indic := integralZl_indic (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.4", note="use `integralZl_indic_nnsfun` instead")] -Notation integralM_indic_nnsfun := integralZl_indic_nnsfun (only parsing). Section ge0_integral_mscale. Local Open Scope ereal_scope. @@ -1083,10 +1075,9 @@ rewrite -ge0_integral_bigsetU//=; first last. rewrite big_mkord -bigsetU_seqDU. move: n => [|n]. rewrite big_ord0 integral_set0. - apply: ereal_sup_le. + apply: ereal_sup_ge. exists (\int[mu]_(x in `[0%R, 1%:R]) (f x)%:E) => //. - apply: integral_ge0. - by move=> ? _; rewrite lee_fin f0. + by apply: integral_ge0 => /= ? _; rewrite lee_fin f0. rewrite [X in \int[_]_(_ in X) _](_ : _ = `[0%R, n.+1%:R]%classic); last first. rewrite eqEsubset; split => x/=; rewrite in_itv/=. rewrite -(bigcup_mkord _ (fun k => `[0%R, k.+1%:R]%classic)). @@ -1097,7 +1088,7 @@ rewrite [X in \int[_]_(_ in X) _](_ : _ = `[0%R, n.+1%:R]%classic); last first. rewrite -(bigcup_mkord _ (fun k => `[0%R, k.+1%:R]%classic)). exists n => //=. by rewrite in_itv/= x0 Snx. -apply: ereal_sup_le. +apply: ereal_sup_ge. exists (\int[mu]_(x in `[0%R, n.+1%:R]) (f x)%:E); first by exists n. apply: ge0_subset_integral => //= [|? _]; last by rewrite lee_fin f0. exact/measurable_EFinP/measurableT_comp. @@ -1319,16 +1310,15 @@ rewrite (_ : (fun _ => _) = cst 0) // ?lim_cst// funeqE => n. by rewrite -(if_0 n); apply: eq_integral => x _; rewrite gee0_abs// /f_. Unshelve. all: by end_near. Qed. -Lemma integral_abs_eq0 D (N : set T) (f : T -> \bar R) : - measurable N -> measurable D -> N `<=` D -> measurable_fun D f -> +Lemma integral_abs_eq0 (N : set T) (f : T -> \bar R) : + measurable N -> measurable_fun N f -> mu N = 0 -> \int[mu]_(x in N) `|f x| = 0. Proof. -move=> mN mD ND mf muN0; rewrite integralEpatch//. +move=> mN mf muN0; rewrite integralEpatch//. rewrite (eq_integral (abse \o (f \_ N))); last first. by move=> t _; rewrite restrict_abse. apply/ae_eq_integral_abs => //. - apply/measurable_restrict => //; rewrite setIidr//. - exact: (measurable_funS mD). + by apply/measurable_restrict => //; rewrite setIidr. exists N; split => // t /= /not_implyP[_]. by rewrite patchE; case: ifPn => //; rewrite inE. Qed. @@ -1349,8 +1339,10 @@ rewrite -integral_mkcondr [X in _ + X = _](_ : _ = 0) ?adde0//. rewrite -integral_mkcondr (eq_integral (abse \o f)); last first. move=> x; rewrite in_setI => /andP[xD xN]. by rewrite /= gee0_abs// f0//; rewrite inE in xD. -rewrite (@integral_abs_eq0 D)//; first exact: measurableI. -by apply: (subset_measure0 _ _ _ muN0) => //; exact: measurableI. +rewrite integral_abs_eq0//. +- exact: measurableI. +- exact: measurable_funS mf. +- by apply: (subset_measure0 _ _ _ muN0) => //; exact: measurableI. Qed. Lemma ge0_ae_eq_integral (D : set T) (f g : T -> \bar R) : @@ -1566,3 +1558,93 @@ Qed. End lebesgue_measure_integral. Arguments integral_Sset1 {R f A} r. + +Section ge0_nondecreasing_set_cvg_integral. +Context {d : measure_display} {T : measurableType d} {R : realType}. +Variables (F : (set T)^nat) (f : T -> \bar R) (mu : measure T R). +Local Open Scope ereal_scope. +Hypotheses (nndF : nondecreasing_seq F) (mF : forall i, measurable (F i)). +Hypothesis mf : forall i, measurable_fun (F i) f. +Hypothesis f0 : forall i x, F i x -> 0 <= f x. + +Lemma ge0_nondecreasing_set_nondecreasing_integral : + nondecreasing_seq (fun i => \int[mu]_(x in F i) f x). +Proof. +apply/nondecreasing_seqP => n; apply: ge0_subset_integral => //=. +- by move=> ?; exact: f0. +- by rewrite -subsetEset; exact: nndF. +Qed. + +Lemma ge0_nondecreasing_set_cvg_integral : + \int[mu]_(x in F i) f x @[i --> \oo] --> \int[mu]_(x in \bigcup_i F i) f x. +Proof. +apply: cvg_toP. + apply: ereal_nondecreasing_is_cvgn. + exact: ge0_nondecreasing_set_nondecreasing_integral. +under eq_fun do rewrite integral_mkcond/=. +rewrite -monotone_convergence//=; last 3 first. +- by move=> n; apply/(measurable_restrictT f). +- by move=> n x _; apply: erestrict_ge0 => {}x; exact: f0. +- move=> x _; apply/nondecreasing_seqP => n; apply: restrict_lee => //. + by move=> {}x; exact: f0. + by rewrite -subsetEset; exact: nndF. +rewrite [RHS]integral_mkcond/=. +apply: eq_integral => /=; rewrite /g_sigma_algebraType/ocitv_type => x _. +transitivity (ereal_sup (range (fun n => (f \_ (F n)) x))). + apply/cvg_lim => //. + apply/ereal_nondecreasing_cvgn/nondecreasing_seqP => n; apply: restrict_lee. + by move=> {}x; exact: f0. + by rewrite -subsetEset; exact: nndF. +apply/eqP; rewrite eq_le; apply/andP; split. +- apply: ub_ereal_sup => _/= [n _ <-]. + apply: restrict_lee; last exact: bigcup_sup. + by move=> ? [? _]; exact: f0. +- rewrite patchE; case: ifPn=> [|/negP]. + rewrite inE => -[n _ Fnx]. + by apply: ereal_sup_ge; exists (f \_ (F n) x) => //; rewrite patchE mem_set. + rewrite inE -[X in X -> _]/((~` _) x) setC_bigcup => nFx. + apply/ereal_sup_ge; exists point => //=; exists 0%R => //. + by rewrite patchE memNset//; exact: nFx. +Qed. + +End ge0_nondecreasing_set_cvg_integral. + +Section le0_nondecreasing_set_cvg_integral. +Context {d : measure_display} {T : measurableType d} {R : realType}. +Variables (F : (set T)^nat) (f : T -> \bar R) (mu : measure T R). +Local Open Scope ereal_scope. +Hypotheses (nndF : nondecreasing_seq F) (mF : forall i, measurable (F i)). +Hypothesis mf : forall i, measurable_fun (F i) f. +Hypothesis f0 : forall i x, F i x -> f x <= 0. + +Let intNS n : (- \int[mu]_(x in F n) f x) = \int[mu]_(x in F n) - f x. +Proof. +apply/esym; apply: integralN => /=; apply: fin_num_adde_defr. +rewrite integral0_eq// => x Fnx. +by rewrite (@le0_funeposE _ _ (F n)) ?inE//; exact: f0. +Qed. + +Let mNf i : measurable_fun (F i) (\- f). +Proof. by apply: measurableT_comp => //; exact: mf. Qed. + +Let Nf_ge0 i x: F i x -> 0%R <= - f x. +Proof. by move=> Six; rewrite leeNr oppe0; exact: f0 Six. Qed. + +Lemma le0_nondecreasing_set_nonincreasing_integral : + nonincreasing_seq (fun i => \int[mu]_(x in F i) f x). +Proof. +move=> m n mn; rewrite -leeN2 2!intNS. +exact: ge0_nondecreasing_set_nondecreasing_integral. +Qed. + +Lemma le0_nondecreasing_set_cvg_integral : + \int[mu]_(x in F i) f x @[i --> \oo] --> \int[mu]_(x in \bigcup_i F i) f x. +Proof. +apply/cvgeNP; rewrite -integralN/=; last first. + apply: fin_num_adde_defr; rewrite integral0_eq// => x [n _ Fnx]. + by rewrite (le0_funeposE (@f0 n))// inE. +under eq_cvg do rewrite intNS. +exact: ge0_nondecreasing_set_cvg_integral. +Qed. + +End le0_nondecreasing_set_cvg_integral. diff --git a/theories/lebesgue_integral_theory/lebesgue_integral_approximation.v b/theories/lebesgue_integral_theory/measurable_fun_approximation.v similarity index 90% rename from theories/lebesgue_integral_theory/lebesgue_integral_approximation.v rename to theories/lebesgue_integral_theory/measurable_fun_approximation.v index 4850ce47c..edae45093 100644 --- a/theories/lebesgue_integral_theory/lebesgue_integral_approximation.v +++ b/theories/lebesgue_integral_theory/measurable_fun_approximation.v @@ -6,11 +6,11 @@ From mathcomp Require Import mathcomp_extra unstable boolp classical_sets. From mathcomp Require Import functions cardinality reals fsbigop. From mathcomp Require Import interval_inference topology ereal tvs normedtype. From mathcomp Require Import sequences real_interval function_spaces esum. -From mathcomp Require Import measure lebesgue_measure numfun realfun. -From mathcomp Require Import simple_functions lebesgue_integral_definition. +From mathcomp Require Import measure lebesgue_measure numfun realfun exp. +From mathcomp Require Import simple_functions. (**md**************************************************************************) -(* # Approximation theorem for the Lebesgue integral *) +(* # Approximation theorem for measurable functions *) (* *) (* Applications: measurability of arithmetic of functions, Lusin's theorem. *) (* *) @@ -524,11 +524,9 @@ have mfg : measurable (D `&` [set x | f x *? g x]). (g @^-1` (~` [set 0]) `|` f @^-1` (~` [set -oo; +oo])). by rewrite setIIr; apply: measurableI; rewrite setIUr; apply: measurableU; do ?[apply: mf|apply: mg]. - apply/predeqP=> x; rewrite /preimage/= /mule_def !(negb_and, negb_or). - rewrite !(rwP2 eqP idP) !(rwP2 negP idP) !(rwP2 orP idP). - rewrite !(rwP2 negP idP) !(rwP2 orP idP) !(rwP2 andP idP). - rewrite eqe_absl leey andbT (orbC (g x == +oo)). - by rewrite eqe_absl leey andbT (orbC (f x == +oo)). + apply/predeqP=> x; rewrite /preimage/= /mule_def/=. + rewrite !(rwP2 eqP idP, rwP2 negP idP, rwP2 orP idP, rwP2 andP idP). + by case: (f x) (g x) => [?||] [?||]//=; rewrite ?(orbT, andbT, orbF). wlog fg : D mD mf mg mfg / forall x, D x -> f x *? g x => [hwlogM|]; last first. have [f_ f_cvg] := approximation_sfun mD mf. have [g_ g_cvg] := approximation_sfun mD mg. @@ -576,8 +574,8 @@ Section measurable_sum. Context d (T : measurableType d) (R : realType). Implicit Types (D : set T) (f g : T -> R). -Lemma measurable_sum D I s (h : I -> (T -> R)) : - (forall n, measurable_fun D (h n)) -> +Lemma measurable_sum D I s (h : I -> T -> R) : + (forall i, measurable_fun D (h i)) -> measurable_fun D (fun x => \sum_(i <- s) h i x). Proof. move=> mh; apply/measurable_EFinP. @@ -586,6 +584,17 @@ rewrite (_ : _ \o _ = (fun t => \sum_(i <- s) (h i t)%:E)); last first. by apply/emeasurable_sum => i; exact/measurable_EFinP. Qed. +Lemma measurable_prod D (I : eqType) (s : seq I) (h : I -> T -> R) : + (forall i, i \in s -> measurable_fun D (h i)) -> + measurable_fun D (fun x => \prod_(i <- s) h i x). +Proof. +elim: s => [mh|x y ih mh]. + by under eq_fun do rewrite big_nil//=; exact: measurable_cst. +under eq_fun do rewrite big_cons//=; apply: measurable_funM => //. +- by apply: mh; rewrite mem_head. +- by apply: ih => n ny; apply: mh; rewrite inE orbC ny. +Qed. + End measurable_sum. Section emeasurable_comparison. @@ -594,35 +603,93 @@ Context d {T : measurableType d} {R : realType}. Variables (D : set T) (mD : measurable D). Implicit Types f g : T -> \bar R. -Lemma emeasurable_fun_lt f g : measurable_fun D f -> measurable_fun D g -> +Lemma measurable_lte f g : measurable_fun D f -> measurable_fun D g -> measurable (D `&` [set x | f x < g x]). Proof. move=> mf mg; under eq_set do rewrite -sube_gt0. by apply: emeasurable_fun_o_infty => //; exact: emeasurable_funB. Qed. -Lemma emeasurable_fun_le f g : measurable_fun D f -> measurable_fun D g -> +Lemma measurable_lee f g : measurable_fun D f -> measurable_fun D g -> measurable (D `&` [set x | f x <= g x]). Proof. move=> mf mg; under eq_set do rewrite -sube_le0. by apply: emeasurable_fun_infty_c => //; exact: emeasurable_funB. Qed. -Lemma emeasurable_fun_eq f g : measurable_fun D f -> measurable_fun D g -> +Lemma measurable_eqe f g : measurable_fun D f -> measurable_fun D g -> measurable (D `&` [set x | f x = g x]). Proof. move=> mf mg; rewrite set_eq_le setIIr. -by apply: measurableI; apply: emeasurable_fun_le. +by apply: measurableI; exact: measurable_lee. Qed. -Lemma emeasurable_fun_neq f g : measurable_fun D f -> measurable_fun D g -> +Lemma measurable_neqe f g : measurable_fun D f -> measurable_fun D g -> measurable (D `&` [set x | f x != g x]). Proof. move=> mf mg; rewrite set_neq_lt setIUr. -by apply: measurableU; exact: emeasurable_fun_lt. +by apply: measurableU; exact: measurable_lte. Qed. End emeasurable_comparison. +#[deprecated(since="mathcomp-analysis 1.11.0", note="renamed to `measurable_lte`")] +Notation emeasurable_fun_lt := measurable_lte (only parsing). +#[deprecated(since="mathcomp-analysis 1.11.0", note="renamed to `measurable_lee`")] +Notation emeasurable_fun_le := measurable_lee (only parsing). +#[deprecated(since="mathcomp-analysis 1.11.0", note="renamed to `measurable_eqe`")] +Notation emeasurable_fun_eq := measurable_eqe (only parsing). +#[deprecated(since="mathcomp-analysis 1.11.0", note="renamed to `measurable_neqe`")] +Notation emeasurable_fun_neq := measurable_neqe (only parsing). + +Section emeasurable_fun_comparison. +Context d (T : measurableType d) (R : realType). +Implicit Types (D : set T) (f g : T -> \bar R). +Local Open Scope ereal_scope. + +Lemma measurable_fun_lte D f g : measurable_fun D f -> measurable_fun D g -> + measurable_fun D (fun x => f x < g x). +Proof. +move=> mf mg mD; apply: (measurable_fun_bool true) => //. +exact: measurable_lte. +Qed. + +Lemma measurable_fun_lee D f g : measurable_fun D f -> measurable_fun D g -> + measurable_fun D (fun x => f x <= g x). +Proof. +move=> mf mg mD; apply: (measurable_fun_bool true) => //. +exact: measurable_lee. +Qed. + +Lemma measurable_fun_eqe D f g : measurable_fun D f -> measurable_fun D g -> + measurable_fun D (fun x => f x == g x). +Proof. +move=> mf mg. +rewrite (_ : (fun x => f x == g x) = (fun x => (f x <= g x) && (g x <= f x))). + by apply: measurable_and; exact: measurable_fun_lee. +by under eq_fun do rewrite eq_le. +Qed. + +End emeasurable_fun_comparison. + +Lemma measurable_poweR (R : realType) r : + measurable_fun [set: \bar R] (poweR ^~ r). +Proof. +under eq_fun do rewrite poweRE. +rewrite -/(measurable_fun _ _). +apply: measurable_fun_ifT => //=. + apply/measurable_EFinP => //=. + apply: measurable_fun_ifT => //=. + apply: (measurable_fun_bool true). + rewrite setTI (_ : _ @^-1` _ = EFin @` setT). + by apply: measurable_image_EFin; exact: measurableT. + apply/seteqP; split => [x finx|x [s sx <-//]]/=. + by exists (fine x) => //; rewrite fineK. + exact: (@measurableT_comp _ _ _ _ _ _ (@powR R ^~ r)). +apply: measurable_fun_ifT => //=; first exact: measurable_fun_eqe. +apply: measurable_fun_ifT => //=; first exact: measurable_fun_eqe. +apply/measurable_EFinP => //=. +exact: (@measurableT_comp _ _ _ _ _ _ (@powR R ^~ r)). +Qed. Section measurable_comparison. Context d (T : measurableType d) (R : realType). @@ -633,7 +700,7 @@ Lemma measurable_fun_le D f g : measurable (D `&` [set x | f x <= g x]). Proof. move=> mD mf mg; under eq_set => x do rewrite -lee_fin. -by apply: emeasurable_fun_le => //; exact: measurableT_comp. +by apply: measurable_lee => //; exact: measurableT_comp. Qed. End measurable_comparison. @@ -703,7 +770,7 @@ Proof. move: eps=> _/posnumP[eps] mf; pose f' := EFin \o f. have mf' : measurable_fun A f' by exact/measurable_EFinP. have [/= g_ gf'] := @approximation_sfun _ R rT _ _ mA mf'. -pose e2n n := (eps%:num / 2) / (2 ^ n.+1)%:R. +pose e2n n := ((eps%:num / 2) / (2 ^ n.+1)%:R)%R. have e2npos n : (0 < e2n n)%R by rewrite divr_gt0. have gK' n := @lusin_simple (g_ n) (e2n n) (e2npos n). pose gK n := projT1 (cid (gK' n)); have gKP n := projT2 (cid (gK' n)). diff --git a/theories/lebesgue_measure.v b/theories/lebesgue_measure.v index a0dfb2aaa..4ed29faad 100644 --- a/theories/lebesgue_measure.v +++ b/theories/lebesgue_measure.v @@ -898,7 +898,7 @@ Proof. move=> mD muDoo epspos. have /ereal_inf_lt[z [/= M' covDM sMz zDe]] : mu D < mu D + (eps / 2)%:E. by rewrite lte_spaddre ?lte_fin ?divr_gt0// ge0_fin_numE. -pose e2 n := (eps / 2) / (2 ^ n.+1)%:R. +pose e2 n := ((eps / 2) / (2 ^ n.+1)%:R)%R. have e2pos n : (0 < e2 n)%R by rewrite ?divr_gt0. pose M n := if pselect (M' n = set0) then set0 else (`] inf (M' n), sup (M' n) + e2 n [%classic)%R. @@ -991,7 +991,7 @@ move=> mD finD epspos. wlog : eps epspos D mD finD / exists ab : R * R, D `<=` `[ab.1, ab.2]%classic. move=> WL; have [] := @lebesgue_nearly_bounded _ (eps / 2)%R mD finD. by rewrite divr_gt0. - case=> a b /= muDabe; have [] := WL (eps / 2) _ (D `&` `[a,b]). + case=> a b /= muDabe; have [] := WL (eps / 2)%R _ (D `&` `[a,b]). - by rewrite divr_gt0. - exact: measurableI. - by rewrite (le_lt_trans _ finD)// le_measure// inE//; exact: measurableI. @@ -1157,7 +1157,7 @@ have finite_set_F i : finite_set (F i). rewrite /= nneseries_esum//= set_mem_set// esum_fset// fsbig_finite//=. rewrite set_fsetK. apply: (@le_trans _ _ (\sum_(i0 <- C) (1 / (2 ^ i.+1)%:R)%:E)). - under eq_bigr do rewrite -(mul1r (_ / _)) EFinM. + under eq_bigr do rewrite -(mul1r (_ / _)%R) EFinM. rewrite -ge0_sume_distrl// EFinM lee_wpmul2r// sumEFin lee_fin. by rewrite -(natr_sum _ _ _ (cst 1%N)) ler_nat -card_fset_sum1. rewrite big_seq [in leRHS]big_seq; apply: lee_sum => // j. diff --git a/theories/measurable_realfun.v b/theories/measurable_realfun.v index 4b7cfff1b..1b51c1763 100644 --- a/theories/measurable_realfun.v +++ b/theories/measurable_realfun.v @@ -391,10 +391,6 @@ Hint Extern 0 (measurable [set _]) => solve [apply: measurable_set1| apply: emeasurable_set1] : core. #[global] Hint Extern 0 (measurable [set` _] ) => exact: measurable_itv : core. -#[deprecated(since="mathcomp-analysis 0.6.2", note="use `emeasurable_itv` instead")] -Notation emeasurable_itv_bnd_pinfty := emeasurable_itv (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.2", note="use `emeasurable_itv` instead")] -Notation emeasurable_itv_ninfty_bnd := emeasurable_itv (only parsing). Lemma fine_measurable (R : realType) (D : set (\bar R)) : measurable D -> measurable_fun D fine. @@ -899,7 +895,7 @@ Implicit Types D : set R. Lemma oppr_measurable D : measurable_fun D -%R. Proof. apply: measurable_funTS => /=; apply: continuous_measurable_fun. -exact: opp_continuous. +exact: oppr_continuous. Qed. Lemma normr_measurable D : measurable_fun D (@normr _ R). @@ -1125,27 +1121,20 @@ by rewrite -[_ @^-1` _]setTI; exact: m1. Qed. End measurable_fun_realType. -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed `measurable_fun_limn_sup`")] -Notation measurable_fun_lim_sup := measurable_fun_limn_sup (only parsing). -Lemma measurable_ln (R : realType) : measurable_fun [set~ (0:R)] (@ln R). +Lemma measurable_ln (R : realType) : measurable_fun [set: R] (@ln R). Proof. -rewrite (_ : [set~ 0] = `]-oo, 0[ `|` `]0, +oo[); last first. - by rewrite -(setCitv `[0, 0]); apply/seteqP; split => [|]x/=; - rewrite in_itv/= -eq_le eq_sym; [move/eqP/negbTE => ->|move/negP/eqP]. +rewrite -set_itvNyy (@itv_bndbnd_setU _ _ _ (BRight 0))//. apply/measurable_funU => //; split. - apply/measurable_restrictT => //=. rewrite (_ : _ \_ _ = cst 0)//; apply/funext => y; rewrite patchE. by case: ifPn => //; rewrite inE/= in_itv/= => y0; rewrite ln0// ltW. -- have : {in `]0, +oo[%classic, continuous (@ln R)}. - by move=> x; rewrite inE/= in_itv/= andbT => x0; exact: continuous_ln. - rewrite -continuous_open_subspace; last exact: interval_open. - by move/subspace_continuous_measurable_fun; apply; exact: measurable_itv. +- apply: subspace_continuous_measurable_fun => //. + rewrite continuous_open_subspace; last exact: interval_open. + by move=> x; rewrite inE/= in_itv/= andbT => x0; exact: continuous_ln. Qed. #[global] Hint Extern 0 (measurable_fun _ (@ln _)) => solve [apply: measurable_ln] : core. -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurable_ln` instead")] -Notation measurable_fun_ln := measurable_ln (only parsing). Lemma measurable_expR (R : realType) : measurable_fun [set: R] expR. Proof. by apply: continuous_measurable_fun; exact: continuous_expR. Qed. @@ -1170,13 +1159,11 @@ Notation measurable_fun_pow := measurable_funX (only parsing). Lemma measurable_powR (R : realType) p : measurable_fun [set: R] (@powR R ^~ p). Proof. -apply: measurable_fun_if => //. +apply: measurable_fun_ifT => //. - apply: (measurable_fun_bool true). rewrite (_ : _ @^-1` _ = [set 0]) ?setTI//. by apply/seteqP; split => [_ /eqP ->//|_ -> /=]; rewrite eqxx. -- rewrite setTI; apply: measurableT_comp => //. - rewrite (_ : _ @^-1` _ = [set~ 0]); first exact: measurableT_comp. - by apply/seteqP; split => [x /negP/negP/eqP|x x0]//=; exact/negbTE/eqP. +- by apply: measurableT_comp => //; exact: measurable_funM. Qed. #[global] Hint Extern 0 (measurable_fun _ (@powR _ ^~ _)) => solve [apply: measurable_powR] : core. @@ -1192,9 +1179,6 @@ rewrite /powR; apply: measurable_fun_if => //. exact: mulrr_measurable. Qed. -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurable_maxr` instead")] -Notation measurable_fun_max := measurable_maxr (only parsing). - Module NGenCInfty. Section ngencinfty. Implicit Types x y z : nat. @@ -1457,8 +1441,6 @@ apply: measurable_fun_ifT => //=. + by apply: (measurable_fun_bool true); exact/emeasurable_fin_num. + exact/measurable_EFinP/measurableT_comp. Qed. -#[deprecated(since="mathcomp-analysis 0.6.3", note="renamed `measurable_er_map`")] -Notation measurable_fun_er_map := measurable_er_map (only parsing). Section emeasurable_fun. Local Open Scope ereal_scope. @@ -1547,19 +1529,6 @@ Qed. End emeasurable_fun. Arguments emeasurable_fun_cvg {d T R D} f_. -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurableT_comp` instead")] -Notation emeasurable_funN := measurableT_comp (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurable_maxe` instead")] -Notation emeasurable_fun_max := measurable_maxe (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurable_mine` instead")] -Notation emeasurable_fun_min := measurable_mine (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurable_funepos` instead")] -Notation emeasurable_fun_funepos := measurable_funepos (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="use `measurable_funeneg` instead")] -Notation emeasurable_fun_funeneg := measurable_funeneg (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed `measurable_fun_limn_esup`")] -Notation measurable_fun_lim_esup := measurable_fun_limn_esup (only parsing). - Section open_itv_cover. Context {R : realType}. Implicit Types (A : set R). @@ -1571,7 +1540,7 @@ Lemma outer_measure_open_itv_cover A : (l^* A)%mu = ereal_inf [set \sum_(k _ /= [F [Fitv AF <-]]. + apply: le_ereal_inf => _ /= [F [Fitv AF <-]]. exists (fun i => `](sval (cid (Fitv i))).1, (sval (cid (Fitv i))).2]%classic). + split=> [i|]. * have [?|?] := ltP (sval (cid (Fitv i))).1 (sval (cid (Fitv i))).2. @@ -1583,48 +1552,48 @@ apply/eqP; rewrite eq_le; apply/andP; split. + apply: eq_eseriesr => k _; rewrite /l wlength_itv/=. case: (Fitv k) => /= -[a b]/= Fkab. by case: cid => /= -[x1 x2] ->; rewrite wlength_itv. -- have [/lb_ereal_inf_adherent lA|] := - boolP ((l^* A)%mu \is a fin_num); last first. - rewrite ge0_fin_numE ?outer_measure_ge0// -leNgt leye_eq => /eqP ->. - exact: leey. - apply/lee_addgt0Pr => /= e e0. - have : (0 < e / 2)%R by rewrite divr_gt0. - move=> /lA[_ [/= F [mF AF]] <-]; rewrite -/((l^* A)%mu) => lFe. - have Fcover n : exists2 B, F n `<=` B & - is_open_itv B /\ l B <= l (F n) + (e / 2 ^+ n.+2)%:E. - have [[a b] _ /= abFn] := mF n. - exists `]a, b + e / 2^+n.+2[%classic. - rewrite -abFn => x/= /[!in_itv] /andP[->/=] /le_lt_trans; apply. - by rewrite ltrDl divr_gt0. - split; first by exists (a, b + e / 2^+n.+2). - have [ab|ba] := ltP a b. - rewrite /l -abFn !wlength_itv//= !lte_fin ifT. - by rewrite ab -!EFinD lee_fin addrAC. - by rewrite ltr_wpDr// divr_ge0// ltW. - rewrite -abFn [in leRHS]set_itv_ge ?bnd_simp -?leNgt// /l wlength0 add0r. - rewrite wlength_itv//=; case: ifPn => [abe|_]; last first. - by rewrite lee_fin divr_ge0// ltW. - by rewrite -EFinD addrAC lee_fin -[leRHS]add0r lerD2r subr_le0. - pose G := fun n => sval (cid2 (Fcover n)). - have FG n : F n `<=` G n by rewrite /G; case: cid2. - have Gitv n : is_open_itv (G n) by rewrite /G; case: cid2 => ? ? []. - have lGFe n : l (G n) <= l (F n) + (e / 2 ^+ n.+2)%:E. - by rewrite /G; case: cid2 => ? ? []. - have AG : A `<=` \bigcup_k G k. - by apply: (subset_trans AF) => [/= r [n _ /FG Gnr]]; exists n. - apply: (@le_trans _ _ (\sum_(0 <= k /=; exists G. - exact: lee_nneseries. - rewrite nneseriesD//; last first. - by move=> i _; rewrite lee_fin// divr_ge0// ltW. - rewrite [in leRHS](splitr e) EFinD addeA leeD//; first exact/ltW. - have := @cvg_geometric_eseries_half R e 1; rewrite expr1. - rewrite [X in eseries X](_ : _ = (fun k => (e / (2 ^+ (k.+2))%:R)%:E)); last first. - by apply/funext => n; rewrite addn2 natrX. - move/cvg_lim => <-//; apply: lee_nneseries => //. - - by move=> n _; rewrite lee_fin divr_ge0// ltW. - - by move=> n _; rewrite lee_fin -natrX. +have [/lb_ereal_inf_adherent lA|] := + boolP ((l^* A)%mu \is a fin_num); last first. + rewrite ge0_fin_numE ?outer_measure_ge0// -leNgt leye_eq => /eqP ->. + exact: leey. +apply/lee_addgt0Pr => /= e e0. +have : (0 < e / 2)%R by rewrite divr_gt0. +move=> /lA[_ [/= F [mF AF]] <-]; rewrite -/((l^* A)%mu) => lFe. +have Fcover n : exists2 B, F n `<=` B & + is_open_itv B /\ l B <= l (F n) + (e / 2 ^+ n.+2)%:E. + have [[a b] _ /= abFn] := mF n. + exists `]a, (b + e / 2^+n.+2)%R[%classic. + rewrite -abFn => x/= /[!in_itv] /andP[->/=] /le_lt_trans; apply. + by rewrite ltrDl divr_gt0. + split; first by exists (a, b + e / 2^+n.+2)%R. + have [ab|ba] := ltP a b. + rewrite /l -abFn !wlength_itv//= !lte_fin ifT. + by rewrite ab -!EFinD lee_fin addrAC. + by rewrite ltr_wpDr// divr_ge0// ltW. + rewrite -abFn [in leRHS]set_itv_ge ?bnd_simp -?leNgt// /l wlength0 add0r. + rewrite wlength_itv//=; case: ifPn => [abe|_]; last first. + by rewrite lee_fin divr_ge0// ltW. + by rewrite -EFinD addrAC lee_fin -[leRHS]add0r lerD2r subr_le0. +pose G := fun n => sval (cid2 (Fcover n)). +have FG n : F n `<=` G n by rewrite /G; case: cid2. +have Gitv n : is_open_itv (G n) by rewrite /G; case: cid2 => ? ? []. +have lGFe n : l (G n) <= l (F n) + (e / 2 ^+ n.+2)%:E. + by rewrite /G; case: cid2 => ? ? []. +have AG : A `<=` \bigcup_k G k. + by apply: (subset_trans AF) => [/= r [n _ /FG Gnr]]; exists n. +apply: (@le_trans _ _ (\sum_(0 <= k /=; exists G. + exact: lee_nneseries. +rewrite nneseriesD//; last first. + by move=> i _; rewrite lee_fin// divr_ge0// ltW. +rewrite [in leRHS](splitr e) EFinD addeA leeD//; first exact/ltW. +have := @cvg_geometric_eseries_half R e 1; rewrite expr1. +rewrite [X in eseries X](_ : _ = (fun k => (e / (2 ^+ (k.+2))%:R)%:E)); last first. + by apply/funext => n; rewrite addn2 natrX. +move/cvg_lim => <-//; apply: lee_nneseries => //. +- by move=> n _; rewrite lee_fin divr_ge0// ltW. +- by move=> n _; rewrite lee_fin -natrX. Qed. End open_itv_cover. @@ -1632,7 +1601,6 @@ End open_itv_cover. Section egorov. Context d {R : realType} {T : measurableType d}. Context (mu : {measure set T -> \bar R}). - Local Open Scope ereal_scope. (*TODO : this generalizes to any metric space with a borel measure*) @@ -1653,7 +1621,7 @@ have Einc k : nonincreasing_seq (E k). by exists i => //; exact: mi. have mE k n : measurable (E k n). apply: bigcup_measurable => q /= ?. - have -> : [set x | h q x >= k.+1%:R^-1]%R = h q @^-1` `[k.+1%:R^-1, +oo[. + have -> : [set x | h q x >= k.+1%:R^-1]%R = h q @^-1` `[(k.+1%:R^-1)%R, +oo[. by rewrite eqEsubset; split => z; rewrite /= in_itv /= andbT. exact: mfunh. have nEcvg x k : exists n, A x -> (~` E k n) x. @@ -1669,7 +1637,7 @@ have Ek0 k : \bigcap_n (E k n) = set0. by have [N /(_ Az) ?] := nEcvg z k; exists N. by exists 0%N => //; rewrite setC_bigcup => n _ []. have badn' k : exists n, mu (E k n) < ((eps / 2) / (2 ^ k.+1)%:R)%:E. - pose ek : R := eps / 2 / (2 ^ k.+1)%:R. + pose ek : R := (eps / 2 / (2 ^ k.+1)%:R)%R. have : mu \o E k @ \oo --> mu set0. rewrite -(Ek0 k); apply: nonincreasing_cvg_mu => //. - by rewrite (le_lt_trans _ finA)// le_measure// ?inE// => ? [? _ []]. diff --git a/theories/measure.v b/theories/measure.v index 1e5eec41b..f39b03891 100644 --- a/theories/measure.v +++ b/theories/measure.v @@ -219,10 +219,18 @@ From mathcomp Require Import sequences esum numfun. (* sigma-subadditivity *) (* mu.-negligible A == A is mu negligible *) (* measure_is_complete mu == the measure mu is complete *) -(* {ae mu, forall x, P x} == P holds almost everywhere for the measure mu, *) +(* {ae mu, P} == P holds almost everywhere for the measure mu, *) (* declared as an instance of the type of *) (* filters *) -(* ae_eq D f g == f is equal to g almost everywhere *) +(* P must be of the form forall x, Q x. *) +(* Prefer this notation when P is an existing *) +(* statement (i.e., a definition) that needs to *) +(* be relativised. *) +(* \forall x \ae mu, P x == equivalent to {ae mu, forall x, P x} *) +(* Prefer this notation when the statement *) +(* forall x, P x does not stand alone. *) +(* f = g %[ae mu in D ] == f is equal to g almost everywhere in D *) +(* f = g %[ae mu] == f is equal to g almost everywhere *) (* ``` *) (* *) (* ## Measure extension theorem *) @@ -268,6 +276,11 @@ From mathcomp Require Import sequences esum numfun. (* generated from T1 x T2, with T1 and T2 *) (* semiRingOfSetsType's with resp. display *) (* d1 and d2 *) +(* g_sigma_preimage n (f : 'I_n -> aT -> rT) == the sigma-algebra over aT *) +(* generated by the projections f *) +(* n.-tuple T is equipped with a *) +(* measurableType using g_sigma_preimage *) +(* and the tnth projections. *) (* ``` *) (* *) (* ## More measure-theoretic definitions *) @@ -282,6 +295,7 @@ From mathcomp Require Import sequences esum numfun. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. +Import ProperNotations. Import Order.TTheory GRing.Theory Num.Def Num.Theory. Reserved Notation "'s<|' D , G '|>'" (at level 40, G, D at next level). @@ -1306,6 +1320,10 @@ move=> A B mA mB; case: (semi_measurableD A B) => // [D [Dfin Dl -> _]]. by apply: fin_bigcup_measurable. Qed. +Lemma seqDU_measurable (F : sequence (set T)) : + (forall n, measurable (F n)) -> forall n, measurable (seqDU F n). +Proof. by move=> Fmeas n; apply/measurableD/bigsetU_measurable. Qed. + End ringofsets_lemmas. Section algebraofsets_lemmas. @@ -1516,6 +1534,12 @@ by move=> fg mf mD A mA; rewrite [X in measurable X](_ : _ = D `&` f @^-1` A); [exact: mf|exact/esym/eq_preimage]. Qed. +Lemma measurable_fun_eqP D (f g : T1 -> T2) : + {in D, f =1 g} -> measurable_fun D f <-> measurable_fun D g. +Proof. +by move=> eq_fg; split; apply/eq_measurable_fun => // ? ?; rewrite eq_fg. +Qed. + Lemma measurable_cst D (r : T2) : measurable_fun D (cst r : T1 -> _). Proof. by move=> mD /= Y mY; rewrite preimage_cst; case: ifPn; rewrite ?setIT ?setI0. @@ -1582,14 +1606,7 @@ End measurable_fun. #[global] Hint Extern 0 (measurable_fun _ id) => solve [apply: measurable_id] : core. Arguments eq_measurable_fun {d1 d2 T1 T2 D} f {g}. -#[deprecated(since="mathcomp-analysis 0.6.2", note="renamed `eq_measurable_fun`")] -Notation measurable_fun_ext := eq_measurable_fun (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="renamed `measurable_id`")] -Notation measurable_fun_id := measurable_id (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="renamed `measurable_cst`")] -Notation measurable_fun_cst := measurable_cst (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.3", note="renamed `measurable_comp`")] -Notation measurable_fun_comp := measurable_comp (only parsing). +Arguments measurable_fun_eqP {d1 d2 T1 T2 D} f {g}. Section measurable_fun_measurableType. Context d1 d2 d3 (T1 : measurableType d1) (T2 : measurableType d2) @@ -1701,8 +1718,6 @@ End measurable_fun_measurableType. solve [apply: measurable_id] : core. Arguments eq_measurable_fun {d1 d2 T1 T2 D} f {g}. Arguments measurable_fun_bool {d1 T1 D f} b. -#[deprecated(since="mathcomp-analysis 0.6.3", note="renamed `measurableT_comp`")] -Notation measurable_funT_comp := measurableT_comp (only parsing). Section measurability. @@ -2001,6 +2016,9 @@ have /[!big_ord0] ->// := @measure_semi_additive _ _ _ mu (fun=> set0) 0%N. exact: trivIset_set0. Qed. +Lemma measure_gt0 x : (0%R < mu x) = (mu x != 0). +Proof. by rewrite lt_def measure_ge0 andbT. Qed. + Hint Resolve measure0 : core. Hint Resolve measure_ge0 : core. @@ -3647,6 +3665,13 @@ HB.instance Definition _ := End mnormalize. +Lemma mnormalize_id d (T : measurableType d) (R : realType) + (P P' : probability T R) : mnormalize P P' = P. +Proof. +apply/funext => x; rewrite /mnormalize/= probability_setT. +by rewrite onee_eq0/= invr1 mule1. +Qed. + Section pdirac. Context d (T : measurableType d) (R : realType). @@ -4088,7 +4113,8 @@ Qed. Section ae. Definition almost_everywhere d (T : semiRingOfSetsType d) (R : realFieldType) - (mu : set T -> \bar R) (P : T -> Prop) := mu.-negligible (~` [set x | P x]). + (mu : set T -> \bar R) : set_system T := + fun P => mu.-negligible (~` [set x | P x]). Let almost_everywhereT d (T : semiRingOfSetsType d) (R : realFieldType) (mu : {content set T -> \bar R}) : almost_everywhere mu setT. @@ -4107,16 +4133,14 @@ Proof. by rewrite /almost_everywhere => mA mB; rewrite setCI; exact: negligibleU. Qed. -#[global] -Instance ae_filter_ringOfSetsType d {T : ringOfSetsType d} (R : realFieldType) +Definition ae_filter_ringOfSetsType d {T : ringOfSetsType d} (R : realFieldType) (mu : {measure set T -> \bar R}) : Filter (almost_everywhere mu). Proof. by split; [exact: almost_everywhereT|exact: almost_everywhereI| exact: almost_everywhereS]. Qed. -#[global] -Instance ae_properfilter_algebraOfSetsType d {T : algebraOfSetsType d} +Definition ae_properfilter_algebraOfSetsType d {T : algebraOfSetsType d} (R : realFieldType) (mu : {measure set T -> \bar R}) : mu [set: T] > 0 -> ProperFilter (almost_everywhere mu). Proof. @@ -4129,86 +4153,146 @@ End ae. #[global] Hint Extern 0 (Filter (almost_everywhere _)) => (apply: ae_filter_ringOfSetsType) : typeclass_instances. +#[global] Hint Extern 0 (Filter (nbhs (almost_everywhere _))) => + (apply: ae_filter_ringOfSetsType) : typeclass_instances. #[global] Hint Extern 0 (ProperFilter (almost_everywhere _)) => (apply: ae_properfilter_algebraOfSetsType) : typeclass_instances. +#[global] Hint Extern 0 (ProperFilter (nbhs (almost_everywhere _))) => + (apply: ae_properfilter_algebraOfSetsType) : typeclass_instances. -Definition almost_everywhere_notation d (T : semiRingOfSetsType d) - (R : realFieldType) (mu : set T -> \bar R) (P : T -> Prop) - & (phantom Prop (forall x, P x)) := almost_everywhere mu P. -Notation "{ 'ae' m , P }" := - (almost_everywhere_notation m (inPhantom P)) : type_scope. +Notation "{ 'ae' m , P }" := {near almost_everywhere m, P} : type_scope. +Notation "\forall x \ae mu , P" := (\forall x \near almost_everywhere mu, P) + (format "\forall x \ae mu , P", + x name, P at level 200, at level 200): type_scope. +Definition ae_eq d (T : semiRingOfSetsType d) (R : realType) + (mu : {measure set T -> \bar R}) (V : T -> Type) D (f g : forall x, V x) := + \forall x \ae mu, D x -> f x = g x. +Notation "f = g %[ae mu 'in' D ]" := (\forall x \ae mu, D x -> f x = g x) + (format "f = g '%[ae' mu 'in' D ]", + g at next level, D at level 200, at level 70). +Notation "f = g %[ae mu ]" := (f = g %[ae mu in setT ]) + (format "f = g '%[ae' mu ]", g at next level, at level 70). + +Lemma measure0_ae d {T : algebraOfSetsType d} {R : realType} + (mu : {measure set T -> \bar R}) (P : set T) : + mu [set: T] = 0 -> \forall x \ae mu, P x. +Proof. by move=> x; exists setT. Qed. Lemma aeW {d} {T : semiRingOfSetsType d} {R : realFieldType} (mu : {measure set _ -> \bar R}) (P : T -> Prop) : - (forall x, P x) -> {ae mu, forall x, P x}. + (forall x, P x) -> \forall x \ae mu, P x. Proof. move=> aP; have -> : P = setT by rewrite predeqE => t; split. by apply/negligibleP; [rewrite setCT|rewrite setCT measure0]. Qed. +Instance ae_eq_equiv d (T : ringOfSetsType d) R mu V D : + RelationClasses.Equivalence (@ae_eq d T R mu V D). +Proof. +split. +- by move=> f; near=> x. +- by move=> f g eqfg; near=> x => Dx; rewrite (near eqfg). +- by move=> f g h eqfg eqgh; near=> x => Dx; rewrite (near eqfg) ?(near eqgh). +Unshelve. all: by end_near. Qed. + Section ae_eq. -Local Open Scope ereal_scope. +Local Open Scope ring_scope. Context d (T : sigmaRingType d) (R : realType). +Implicit Types (U V : Type) (W : ringType). Variables (mu : {measure set T -> \bar R}) (D : set T). -Implicit Types f g h i : T -> \bar R. - -Definition ae_eq f g := {ae mu, forall x, D x -> f x = g x}. +Local Notation ae_eq := (ae_eq mu D). -Lemma ae_eq0 f g : measurable D -> mu D = 0 -> ae_eq f g. +Lemma ae_eq0 U (f g : T -> U) : measurable D -> mu D = 0 -> f = g %[ae mu in D]. Proof. by move=> mD D0; exists D; split => // t/= /not_implyP[]. Qed. -Lemma ae_eq_comp (j : \bar R -> \bar R) f g : +Instance comp_ae_eq U V (j : T -> U -> V) : + Proper (ae_eq ==> ae_eq) (fun f x => j x (f x)). +Proof. by move=> f g; apply: filterS => x /[apply] /= ->. Qed. + +Instance comp_ae_eq2 U U' V (j : T -> U -> U' -> V) : + Proper (ae_eq ==> ae_eq ==> ae_eq) (fun f g x => j x (f x) (g x)). +Proof. by move=> f f' + g g'; apply: filterS2 => x + + Dx => -> // ->. Qed. + +Instance comp_ae_eq2' U U' V (j : U -> U' -> V) : + Proper (ae_eq ==> ae_eq ==> ae_eq) (fun f g x => j (f x) (g x)). +Proof. by move=> f f' + g g'; apply: filterS2 => x + + Dx => -> // ->. Qed. + +Instance sub_ae_eq2 : Proper (ae_eq ==> ae_eq ==> ae_eq) (@GRing.sub_fun T R). +Proof. exact: (@comp_ae_eq2' _ _ R (fun x y => x - y)). Qed. + +Lemma ae_eq_refl U (f : T -> U) : ae_eq f f. Proof. exact/aeW. Qed. +Hint Resolve ae_eq_refl : core. + +Lemma ae_eq_comp U V (j : U -> V) f g : ae_eq f g -> ae_eq (j \o f) (j \o g). -Proof. by apply: filterS => x /[apply] /= ->. Qed. +Proof. by move->. Qed. -Lemma ae_eq_funeposneg f g : ae_eq f g <-> ae_eq f^\+ g^\+ /\ ae_eq f^\- g^\-. -Proof. -split=> [fg|[]]. - split; apply: filterS fg => x /[apply]. - by rewrite !funeposE => ->. - by rewrite !funenegE => ->. -apply: filterS2 => x + + Dx => /(_ Dx) fg /(_ Dx) gf. -by rewrite (funeposneg f) (funeposneg g) fg gf. -Qed. +Lemma ae_eq_comp2 U V (j : T -> U -> V) f g : + ae_eq f g -> ae_eq (fun x => j x (f x)) (fun x => j x (g x)). +Proof. by apply: filterS => x /[swap] + ->. Qed. -Lemma ae_eq_refl f : ae_eq f f. Proof. exact/aeW. Qed. +Lemma ae_eq_funeposneg (f g : T -> \bar R) : + ae_eq f g <-> ae_eq f^\+ g^\+ /\ ae_eq f^\- g^\-. +Proof. +split=> [fg|[pfg nfg]]. + by split; near=> x => Dx; rewrite !(funeposE,funenegE) (near fg). +by near=> x => Dx; rewrite (funeposneg f) (funeposneg g) ?(near pfg, near nfg). +Unshelve. all: by end_near. Qed. -Lemma ae_eq_sym f g : ae_eq f g -> ae_eq g f. -Proof. by apply: filterS => x + Dx => /(_ Dx). Qed. +Lemma ae_eq_sym U (f g : T -> U) : ae_eq f g -> ae_eq g f. +Proof. by symmetry. Qed. -Lemma ae_eq_trans f g h : ae_eq f g -> ae_eq g h -> ae_eq f h. -Proof. by apply: filterS2 => x + + Dx => /(_ Dx) ->; exact. Qed. +Lemma ae_eq_trans U (f g h : T -> U) : ae_eq f g -> ae_eq g h -> ae_eq f h. +Proof. by apply transitivity. Qed. -Lemma ae_eq_sub f g h i : ae_eq f g -> ae_eq h i -> ae_eq (f \- h) (g \- i). -Proof. by apply: filterS2 => x + + Dx => /(_ Dx) -> /(_ Dx) ->. Qed. +Lemma ae_eq_sub W (f g h i : T -> W) : ae_eq f g -> ae_eq h i -> ae_eq (f \- h) (g \- i). +Proof. by apply: filterS2 => x + + Dx => /= /(_ Dx) -> /(_ Dx) ->. Qed. -Lemma ae_eq_mul2r f g h : ae_eq f g -> ae_eq (f \* h) (g \* h). -Proof. by apply: filterS => x /[apply] ->. Qed. +Lemma ae_eq_mul2r W (f g h : T -> W) : ae_eq f g -> ae_eq (f \* h) (g \* h). +Proof. by move=>/(ae_eq_comp2 (fun x y => y * h x)). Qed. -Lemma ae_eq_mul2l f g h : ae_eq f g -> ae_eq (h \* f) (h \* g). -Proof. by apply: filterS => x /[apply] ->. Qed. +Lemma ae_eq_mul2l W (f g h : T -> W) : ae_eq f g -> ae_eq (h \* f) (h \* g). +Proof. by move=>/(ae_eq_comp2 (fun x y => h x * y)). Qed. -Lemma ae_eq_mul1l f g : ae_eq f (cst 1) -> ae_eq g (g \* f). -Proof. by apply: filterS => x /[apply] ->; rewrite mule1. Qed. +Lemma ae_eq_mul1l W (f g : T -> W) : ae_eq f (cst 1) -> ae_eq g (g \* f). +Proof. by apply: filterS => x /= /[apply] ->; rewrite mulr1. Qed. -Lemma ae_eq_abse f g : ae_eq f g -> ae_eq (abse \o f) (abse \o g). +Lemma ae_eq_abse (f g : T -> \bar R) : ae_eq f g -> ae_eq (abse \o f) (abse \o g). Proof. by apply: filterS => x /[apply] /= ->. Qed. +Lemma ae_foralln (P : nat -> T -> Prop) : + (forall n, \forall x \ae mu, P n x) -> \forall x \ae mu, forall n, P n x. +Proof. +move=> /(_ _)/cid - /all_sig[A /all_and3[Ameas muA0 NPA]]. +have seqDUAmeas := seqDU_measurable Ameas. +exists (\bigcup_n A n); split => //. +- exact/bigcup_measurable. +- rewrite seqDU_bigcup_eq measure_bigcup// eseries0// => i _ _. + by rewrite (@subset_measure0 _ _ _ _ _ (A i))//=; apply: subset_seqDU. +- by move=> x /=; rewrite -existsNP => -[n NPnx]; exists n => //; apply: NPA. +Qed. + End ae_eq. Section ae_eq_lemmas. -Context d (T : sigmaRingType d) (R : realType). -Implicit Types mu : {measure set T -> \bar R}. +Context d (T : sigmaRingType d) (R : realType) (U : Type). +Implicit Types (mu : {measure set T -> \bar R}) (A : set T) (f g : T -> U). Lemma ae_eq_subset mu A B f g : B `<=` A -> ae_eq mu A f g -> ae_eq mu B f g. -Proof. -move=> BA [N [mN N0 fg]]; exists N; split => //. -by apply: subset_trans fg; apply: subsetC => z /= /[swap] /BA ? ->. -Qed. +Proof. by move=> BA; apply: filterS => x + /BA; apply. Qed. End ae_eq_lemmas. +Section ae_eqe. +Context d (T : sigmaRingType d) (R : realType). +Implicit Types (mu : {measure set T -> \bar R}) (D : set T) (f g h : T -> \bar R). + +Lemma ae_eqe_mul2l mu D f g h : ae_eq mu D f g -> ae_eq mu D (h \* f)%E (h \* g). +Proof. by apply: filterS => x /= /[apply] ->. Qed. + +End ae_eqe. + Definition sigma_subadditive {T} {R : numFieldType} (mu : set T -> \bar R) := forall (F : (set T) ^nat), mu (\bigcup_n (F n)) <= \sum_(i solve [apply: measurable_snd] : core. +Definition g_sigma_preimage d (rT : semiRingOfSetsType d) (aT : Type) + (n : nat) (f : 'I_n -> aT -> rT) : set (set aT) := + <>. + +Lemma g_sigma_preimage_comp d1 {T1 : semiRingOfSetsType d1} n + {T : pointedType} (f : 'I_n -> T -> T1) {T2 : Type} (g : T2 -> T) : + g_sigma_preimage (fun i => f i \o g) = + preimage_set_system [set: T2] g (g_sigma_preimage f). +Proof. +rewrite -[RHS]g_sigma_preimageE; congr (<>). +case: n => [|n] in f *; first by rewrite !big_ord0 preimage_set_system0. +rewrite predeqE => B; split. +- rewrite -bigcup_mkord_ord => -[i Ii [A mA <-{B}]]. + have iE : Ordinal Ii = inord i by apply/val_inj => /=; rewrite inordK. + exists (f (inord i) @^-1` A) => //. + rewrite -bigcup_mkord_ord; exists i => //. + by exists A => //; rewrite -iE setTI. +- move=> [C]. + rewrite -bigcup_mkord_ord => -[i Ii [A mA <-{C}]] <-{B}. + rewrite -bigcup_mkord_ord; exists i => //. + by exists A => //; rewrite !setTI -comp_preimage. +Qed. + +Definition measure_tuple_display : measure_display -> measure_display. +Proof. exact. Qed. + +Section measurable_tuple. +Context {d} {T : sigmaRingType d}. +Variable n : nat. + +Let coors : 'I_n -> n.-tuple T -> T := fun i x => @tnth n T x i. + +Let tuple_set0 : g_sigma_preimage coors set0. +Proof. exact: sigma_algebra0. Qed. + +Let tuple_setC A : g_sigma_preimage coors A -> g_sigma_preimage coors (~` A). +Proof. exact: sigma_algebraC. Qed. + +Let tuple_bigcup (F : _^nat) : (forall i, g_sigma_preimage coors (F i)) -> + g_sigma_preimage coors (\bigcup_i (F i)). +Proof. exact: sigma_algebra_bigcup. Qed. + +HB.instance Definition _ := @isMeasurable.Build (measure_tuple_display d) + (n.-tuple T) (g_sigma_preimage coors) tuple_set0 tuple_setC tuple_bigcup. + +End measurable_tuple. + +Lemma measurable_tnth d (T : sigmaRingType d) n (i : 'I_n) : + measurable_fun [set: n.-tuple T] (@tnth _ T ^~ i). +Proof. +move=> _ Y mY; rewrite setTI; apply: sub_sigma_algebra => /=. +rewrite -bigcup_seq/=; exists i => /=; first by rewrite mem_index_enum. +by exists Y => //; rewrite setTI. +Qed. + +Section measurable_cons. +Context d1 d2 (T1 : measurableType d1) (T2 : measurableType d2). + +Lemma measurable_fun_tnthP n (f : T1 -> n.-tuple T2) : + measurable_fun [set: T1] f <-> + forall i, measurable_fun [set: T1] (@tnth n T2 ^~ i \o f). +Proof. +apply: (@iff_trans _ (g_sigma_preimage + (fun i => @tnth n T2 ^~ i \o f) `<=` measurable)). + rewrite g_sigma_preimage_comp; split=> [mf A [/= C preC <-]|prefS]. + exact: mf. + by move=> _ A mA; apply: prefS; exists A. +split=> [tnthfS i|mf]. +- move=> _ A mA. + apply: tnthfS; apply: sub_sigma_algebra. + case: n i => [[] []//|n i] in f *. + rewrite -bigcup_mkord_ord. + exists i; first exact: ltn_ord. + by exists A => //; rewrite inord_val. +- apply: smallest_sub; first exact: sigma_algebra_measurable. + case: n => [|n] in f mf *; first by rewrite big_ord0. + rewrite -bigcup_mkord_ord; apply: bigcup_sub => i Ii. + by move=> A [B mB <-]; exact: mf. +Qed. + +Lemma measurable_cons (f : T1 -> T2) n (g : T1 -> n.-tuple T2) : + measurable_fun [set: T1] f -> measurable_fun [set: T1] g -> + measurable_fun [set: T1] (fun x => [the n.+1.-tuple T2 of f x :: g x]). +Proof. +move=> mf mg; apply/measurable_fun_tnthP => /= i. +have [->//|i0] := eqVneq i ord0. +have i1n : (i.-1 < n)%N by rewrite prednK ?lt0n// -ltnS. +pose j := Ordinal i1n. +rewrite (_ : _ \o _ = fun x => tnth (g x) j)//. + apply: (@measurableT_comp _ _ _ _ _ _ (fun x => tnth x j)) => //=. + exact: measurable_tnth. +apply/funext => x /=. +rewrite (_ : i = lift ord0 j) ?tnthS//. +by apply/val_inj => /=; rewrite /bump/= add1n prednK// lt0n. +Qed. + +End measurable_cons. + +Lemma measurable_behead d (T : measurableType d) n : + measurable_fun [set: n.+1.-tuple T] (fun x => [tuple of behead x]). +Proof. +move=> _ Y mY; rewrite setTI. +set f := fun x : (n.+1).-tuple T => [tuple of behead x] : n.-tuple T. +move: mY; rewrite /measurable/= => + F [] sF. +pose F' := image_set_system setT f F. +move=> /(_ F') /=. +have -> : F' Y = F (f @^-1` Y) by rewrite /F' /image_set_system /= setTI. +move=> /[swap] bigF; apply; split; first exact: sigma_algebra_image. +move=> A; rewrite /= {}/F' /image_set_system /= setTI. +set bign := (X in X A) => bignA. +apply: bigF; rewrite big_ord_recl /=; right. +set bign1 := (X in X (_ @^-1` _)). +have -> : bign1 = preimage_set_system [set: n.+1.-tuple T] f bign. + rewrite (big_morph _ (preimage_set_systemU _ _) (preimage_set_system0 _ _)). + apply: eq_bigr => i _; rewrite -preimage_set_system_comp. + congr preimage_set_system. + by apply: funext=> t/=; rewrite [in LHS](tuple_eta t) tnthS. +by exists A => //; rewrite setTI. +Qed. + Lemma measurable_fun_if_pair d d' (X : measurableType d) (Y : measurableType d') (x y : X -> Y) : measurable_fun setT x -> measurable_fun setT y -> @@ -5341,29 +5545,11 @@ End absolute_continuity. Notation "m1 `<< m2" := (measure_dominates m1 m2). Section absolute_continuity_lemmas. -Context d (T : measurableType d) (R : realType). -Implicit Types m : {measure set T -> \bar R}. +Context d (T : measurableType d) (R : realType) (U : Type). +Implicit Types (m : {measure set T -> \bar R}) (f g : T -> U). Lemma measure_dominates_ae_eq m1 m2 f g E : measurable E -> m2 `<< m1 -> ae_eq m1 E f g -> ae_eq m2 E f g. Proof. by move=> mE m21 [A [mA A0 ?]]; exists A; split => //; exact: m21. Qed. End absolute_continuity_lemmas. - -Section essential_supremum. -Context d {T : semiRingOfSetsType d} {R : realType}. -Variable mu : {measure set T -> \bar R}. -Implicit Types f : T -> R. - -Definition ess_sup f := - ereal_inf (EFin @` [set r | mu (f @^-1` `]r, +oo[) = 0]). - -Lemma ess_sup_ge0 f : 0 < mu [set: T] -> (forall t, 0 <= f t)%R -> - 0 <= ess_sup f. -Proof. -move=> muT f0; apply: lb_ereal_inf => _ /= [r /eqP rf <-]; rewrite leNgt. -apply/negP => r0; apply/negP : rf; rewrite gt_eqF// (_ : _ @^-1` _ = setT)//. -by apply/seteqP; split => // x _ /=; rewrite in_itv/= (lt_le_trans _ (f0 x)). -Qed. - -End essential_supremum. diff --git a/theories/normedtype_theory/ereal_normedtype.v b/theories/normedtype_theory/ereal_normedtype.v index 103e19812..c492b4b7c 100644 --- a/theories/normedtype_theory/ereal_normedtype.v +++ b/theories/normedtype_theory/ereal_normedtype.v @@ -88,7 +88,7 @@ Lemma limf_esup_ge0 f F : ~ F set0 -> Proof. move=> F0 f0; rewrite limf_esupE; apply: lb_ereal_inf => /= x [A]. have [-> /F0//|/set0P[y Ay FA] <-{x}] := eqVneq A set0. -by apply: ereal_sup_le; exists (f y). +by apply: ereal_sup_ge; exists (f y). Qed. End limf_esup_einf_realType. diff --git a/theories/normedtype_theory/normed_module.v b/theories/normedtype_theory/normed_module.v index 18bfa7713..7e4e29a10 100644 --- a/theories/normedtype_theory/normed_module.v +++ b/theories/normedtype_theory/normed_module.v @@ -4,7 +4,7 @@ From mathcomp Require Import all_ssreflect ssralg ssrint ssrnum finmap matrix. From mathcomp Require Import rat interval zmodp vector fieldext falgebra. From mathcomp Require Import archimedean. From mathcomp Require Import mathcomp_extra unstable boolp classical_sets. -From mathcomp Require Import functions cardinality set_interval. +From mathcomp Require Import filter functions cardinality set_interval. From mathcomp Require Import interval_inference ereal reals topology. From mathcomp Require Import function_spaces real_interval. From mathcomp Require Import prodnormedzmodule tvs num_normedtype. @@ -26,6 +26,13 @@ From mathcomp Require Import ereal_normedtype pseudometric_normed_Zmodule. (* We endow `numFieldType` with the types of norm-related notions (accessible *) (* with `Import numFieldNormedType.Exports`). *) (* *) +(* ``` *) +(* pseudoMetric_normed M == an alias for the pseudometric structure defined *) +(* from a normed module *) +(* M : normedZmodType K with K : numFieldType. *) +(* Lmodule_isNormed M == factory for a normed module defined using *) +(* an L-module M over R : numFieldType *) +(* ``` *) (* ## Hulls *) (* ``` *) (* Rhull A == the real interval hull of a set A *) @@ -131,8 +138,10 @@ by exists (ball x r) => //; split; [exists x, r|exact: ballxx]. Qed. HB.instance Definition _ := - Uniform_isTvs.Build K V add_continuous scale_continuous locally_convex. - + PreTopologicalNmodule_isTopologicalNmodule.Build V add_continuous. +HB.instance Definition _ := + TopologicalNmodule_isTopologicalLmodule.Build K V scale_continuous. +HB.instance Definition _ := Uniform_isTvs.Build K V locally_convex. HB.instance Definition _ := PseudoMetricNormedZmod_Tvs_isNormedModule.Build K V normrZ. @@ -221,6 +230,87 @@ Module Exports. Export numFieldTopology.Exports. HB.reexport. End Exports. End numFieldNormedType. Import numFieldNormedType.Exports. +Definition pseudoMetric_normed (M : Type) : Type := M. + +HB.instance Definition _ (K : numFieldType) (M : normedZmodType K) := + Choice.on (pseudoMetric_normed M). +HB.instance Definition _ (K : numFieldType) (M : normedZmodType K) := + Num.NormedZmodule.on (pseudoMetric_normed M). + +Module pseudoMetric_from_normedZmodType. +Section pseudoMetric_from_normedZmodType. +Variables (K : numFieldType) (M : normedZmodType K). + +Notation T := (pseudoMetric_normed M). + +Definition ball (x : T) (r : K) : set T := ball_ Num.norm x r. + +Definition ent : set_system (T * T) := entourage_ ball. + +Definition nbhs (x : T) : set_system T := nbhs_ ent x. + +Lemma nbhsE : nbhs = nbhs_ ent. Proof. by []. Qed. + +#[export] HB.instance Definition _ := hasNbhs.Build T nbhs. + +Lemma ball_center x (e : K) : 0 < e -> ball x e x. +Proof. by rewrite /ball/= subrr normr0. Qed. + +Lemma ball_sym x y (e : K) : ball x e y -> ball y e x. +Proof. by rewrite /ball /= distrC. Qed. + +Lemma ball_triangle x y z e1 e2 : ball x e1 y -> ball y e2 z -> + ball x (e1 + e2) z. +Proof. +rewrite /ball /= => ? ?. +rewrite -[x](subrK y) -(addrA (x + _)). +by rewrite (le_lt_trans (ler_normD _ _))// ltrD. +Qed. + +Lemma entourageE : ent = entourage_ ball. +Proof. by []. Qed. + +#[export] HB.instance Definition _ := @Nbhs_isPseudoMetric.Build K T + ent nbhsE ball ball_center ball_sym ball_triangle entourageE. + +End pseudoMetric_from_normedZmodType. +Module Exports. HB.reexport. End Exports. +End pseudoMetric_from_normedZmodType. +Export pseudoMetric_from_normedZmodType.Exports. + +HB.factory Record Lmodule_isNormed (R : numFieldType) M + of GRing.Lmodule R M := { + norm : M -> R; + ler_normD : forall x y, norm (x + y) <= norm x + norm y ; + normrZ : forall (l : R) (x : M), norm (l *: x) = `|l| * norm x ; + normr0_eq0 : forall x : M, norm x = 0 -> x = 0 +}. + +HB.builders Context R M of Lmodule_isNormed R M. + +Lemma normrMn x n : norm (x *+ n) = norm x *+ n. +Proof. +have := normrZ n%:R x; rewrite ger0_norm// mulr_natl => <-. +by rewrite scaler_nat. +Qed. + +Lemma normrN x : norm (- x) = norm x. +Proof. by have := normrZ (- 1)%R x; rewrite scaleN1r normrN normr1 mul1r. Qed. + +HB.instance Definition _ := Num.Zmodule_isNormed.Build + R M ler_normD normr0_eq0 normrMn normrN. + +HB.instance Definition _ := PseudoMetric.copy M (pseudoMetric_normed M). + +HB.instance Definition _ := isPointed.Build M 0. + +HB.instance Definition _ := NormedZmod_PseudoMetric_eq.Build R M erefl. + +HB.instance Definition _ := + PseudoMetricNormedZmod_Lmodule_isNormedModule.Build R M normrZ. + +HB.end. + Lemma scaler1 {R : numFieldType} h : h%:A = h :> R. Proof. by rewrite /GRing.scale/= mulr1. Qed. diff --git a/theories/normedtype_theory/num_normedtype.v b/theories/normedtype_theory/num_normedtype.v index 08b8eec1d..c0a79548f 100644 --- a/theories/normedtype_theory/num_normedtype.v +++ b/theories/normedtype_theory/num_normedtype.v @@ -505,21 +505,31 @@ rewrite pmulrn ceil_le_int// [ceil _]intEsign. by rewrite le_gtF ?expr0 ?mul1r ?lez_nat ?ceil_ge0//; near: n; apply: Foo. Unshelve. all: by end_near. Qed. -Lemma gt0_cvgMlNy {R : realFieldType} (M : R) (f : R -> R) : (0 < M)%R -> - (f r) @[r --> -oo] --> -oo -> (f r * M)%R @[r --> -oo] --> -oo. +Section gt0_cvg. +Context {R : realFieldType} {F : set_system R} {FF : Filter F}. +Variables (M : R) (f : R -> R). +Hypothesis M0 : 0 < M. + +Lemma gt0_cvgMlNy : (f r) @[r --> F] --> -oo -> (f r * M)%R @[r --> F] --> -oo. Proof. -move=> M0 /cvgrNyPle fy; apply/cvgrNyPle => A. +move=> /cvgrNyPle fy; apply/cvgrNyPle => A. by apply: filterS (fy (A / M)) => x; rewrite ler_pdivlMr. Qed. -Lemma gt0_cvgMly {R : realFieldType} (M : R) (f : R -> R) : (0 < M)%R -> - f r @[r --> +oo] --> +oo -> (f r * M)%R @[r --> +oo] --> +oo. +Lemma gt0_cvgMrNy : (f r) @[r --> F] --> -oo -> (M * f r)%R @[r --> F] --> -oo. +Proof. by move=> fy; under eq_fun do rewrite mulrC; exact: gt0_cvgMlNy. Qed. + +Lemma gt0_cvgMly : f r @[r --> F] --> +oo -> (f r * M)%R @[r --> F] --> +oo. Proof. -move=> M0 /cvgryPge fy; apply/cvgryPge => A. -apply: filterS (fy (A / M)) => x. -by rewrite ler_pdivrMr. +move=> /cvgryPge fy; apply/cvgryPge => A. +by apply: filterS (fy (A / M)) => x; rewrite ler_pdivrMr. Qed. +Lemma gt0_cvgMry : f r @[r --> F] --> +oo -> (M * f r)%R @[r --> F] --> +oo. +Proof. by move=> fy; under eq_fun do rewrite mulrC; exact: gt0_cvgMly. Qed. + +End gt0_cvg. + Lemma cvgNy_compNP {T : topologicalType} {R : numFieldType} (f : R -> T) (l : set_system T) : f x @[x --> -oo] --> l <-> (f \o -%R) x @[x --> +oo] --> l. @@ -538,7 +548,6 @@ have f_opp : f =1 (fun x => (f \o -%R) (- x)) by move=> x; rewrite /comp opprK. by rewrite (eq_cvg +oo _ f_opp) fmap_comp ninfty. Qed. - Section monotonic_itv_bigcup. Context {R : realType}. Implicit Types (F : R -> R) (a : R). diff --git a/theories/normedtype_theory/pseudometric_normed_Zmodule.v b/theories/normedtype_theory/pseudometric_normed_Zmodule.v index b42cfb8d9..2c93a3da7 100644 --- a/theories/normedtype_theory/pseudometric_normed_Zmodule.v +++ b/theories/normedtype_theory/pseudometric_normed_Zmodule.v @@ -516,7 +516,7 @@ continuous on pseudoMetricNormedZmodType *) Section continuity_pseudoMetricNormedZmodType. Context {K : numFieldType} {V : pseudoMetricNormedZmodType K}. -Lemma opp_continuous : continuous (@GRing.opp V). +Lemma oppr_continuous : continuous (@GRing.opp V). Proof. move=> x; apply/cvgrPdist_lt=> e e0; near do rewrite -opprD normrN. exact: cvgr_dist_lt. @@ -542,6 +542,8 @@ by exists e => //= y; exact/le_lt_trans/ler_dist_dist. Qed. End continuity_pseudoMetricNormedZmodType. +#[deprecated(since="mathcomp-analysis 1.11.0", note="renamed to `oppr_continuous`")] +Notation opp_continuous := oppr_continuous (only parsing). (* TODO: generalize to R : numFieldType *) Section hausdorff. @@ -1115,7 +1117,7 @@ Context (F : set_system T) {FF : Filter F}. Implicit Types (f g : T -> V) (s : T -> K) (k : K) (x : T) (a b : V). Lemma cvgN f a : f @ F --> a -> - f @ F --> - a. -Proof. by move=> ?; apply: continuous_cvg => //; exact: opp_continuous. Qed. +Proof. by move=> ?; apply: continuous_cvg => //; exact: oppr_continuous. Qed. Lemma cvgNP f a : - f @ F --> - a <-> f @ F --> a. Proof. by split=> /cvgN//; rewrite !opprK. Qed. diff --git a/theories/pi_irrational.v b/theories/pi_irrational.v index 0c31cf80e..70724c64b 100644 --- a/theories/pi_irrational.v +++ b/theories/pi_irrational.v @@ -29,7 +29,7 @@ exact/continuous_horner. Qed. (* TODO: move somewhere to classical *) -Definition rational {R : realType} (x : R) := exists m n, x = (m%:R / n%:R)%R. +Definition rational {R : realType} (x : R) := exists m n, x = (m%:~R / n%:R)%R. Module pi_irrational. Local Open Scope ring_scope. @@ -411,6 +411,10 @@ Lemma pi_irrationnal {R : realType} : ~ rational (pi : R). Proof. move=> [a [b]]; have [->|b0 piratE] := eqVneq b O. by rewrite invr0 mulr0; apply/eqP; rewrite gt_eqF// pi_gt0. +have [na ana] : exists na, (a%:~R = na %:R :> R)%R. + exists `|a|; rewrite natr_absz gtr0_norm//. + by have := @pi_gt0 R; rewrite piratE pmulr_lgt0 ?invr_gt0 ?ltr0n ?lt0n// ltr0z. +rewrite {}ana in piratE. have [N _] := pi_irrational.intfsin_small b0 (esym piratE) (@ltr01 R). near \oo%classic => n. have Nn : (N <= n)%N by near: n; exists N. diff --git a/theories/probability.v b/theories/probability.v index ea66fdc90..a8cfb9b05 100644 --- a/theories/probability.v +++ b/theories/probability.v @@ -59,6 +59,8 @@ From mathcomp Require Import ftc gauss_integral. (* standard deviation s *) (* Using normal_peak and normal_pdf. *) (* normal_prob m s == normal probability measure *) +(* exponential_pdf r == pdf of the exponential distribution with rate r *) +(* exponential_prob r == exponential probability measure *) (* ``` *) (* *) (******************************************************************************) @@ -229,7 +231,7 @@ have cdf_ns : cdf X (a + n.+1%:R^-1) @[n --> \oo] --> s%:E. rewrite -[X in _ --> X]addr0; apply: (@cvgD _ R^o); first exact: cvg_cst. by rewrite gtr0_cvgV0 ?cvg_shiftS; [exact: cvgr_idn | near=> n]. have cdf_na : cdf X (a + n.+1%:R^-1) @[n --> \oo] --> cdf X a. - pose F n := X @^-1` `]-oo, a + n.+1%:R^-1]. + pose F n := X @^-1` `]-oo, a + n.+1%:R^-1%R]. suff : P (F n) @[n --> \oo] --> P (\bigcap_n F n). by rewrite [in X in _ --> X -> _]/F -preimage_bigcap -itvNycEbigcap. apply: nonincreasing_cvg_mu => [| | |m n mn]. @@ -1047,6 +1049,23 @@ Qed. HB.instance Definition _ := @Measure_isProbability.Build _ _ R bernoulli bernoulli_setT. +Lemma eq_bernoulli (P : probability bool R) : + P [set true] = p%:E -> P =1 bernoulli. +Proof. +move=> Ptrue sb; rewrite /bernoulli /bernoulli_pmf. +have Pfalse: P [set false] = (1 - p%:E)%E. + rewrite -Ptrue -(@probability_setT _ _ _ P) setT_bool measureU//; last first. + by rewrite disjoints_subset => -[]//. + by rewrite addeAC subee ?add0e//= Ptrue. +have: (0 <= p%:E <= 1)%E by rewrite -Ptrue measure_ge0 probability_le1. +rewrite !lee_fin => ->. +have eq_sb := etrans (bigcup_imset1 (_ : set bool) id) (image_id _). +rewrite -[in LHS](eq_sb sb)/= measure_fin_bigcup//; last 2 first. +- exact: finite_finset. +- by move=> [] [] _ _ [[]]//= []. +- by apply: eq_fsbigr => /= -[]. +Qed. + End bernoulli. Section bernoulli_measure. @@ -1076,6 +1095,17 @@ Qed. End bernoulli_measure. Arguments bernoulli {R}. +Lemma eq_bernoulliV2 {R : realType} (P : probability bool R) : + P [set true] = P [set false] -> P =1 bernoulli 2^-1. +Proof. +move=> Ptrue_eq_false; apply/eq_bernoulli. +have : P [set: bool] = 1%E := probability_setT. +rewrite setT_bool measureU//=; last first. + by rewrite disjoints_subset => -[]//. +rewrite Ptrue_eq_false -mule2n; move/esym/eqP. +by rewrite -mule_natl -eqe_pdivrMl// mule1 => /eqP<-. +Qed. + Section integral_bernoulli. Context {R : realType}. Variables (p : R) (p01 : (0 <= p <= 1)%R). @@ -1703,3 +1733,181 @@ apply: ge0_le_integral => //=. Qed. End normal_probability. + +Section exponential_pdf. +Context {R : realType}. +Notation mu := lebesgue_measure. +Variable rate : R. +Hypothesis rate_gt0 : 0 < rate. + +Let exponential_pdfT x := rate * expR (- rate * x). +Definition exponential_pdf := exponential_pdfT \_ `[0%R, +oo[. + +Lemma exponential_pdf_ge0 x : 0 <= exponential_pdf x. +Proof. +by apply: restrict_ge0 => {}x _; apply: mulr_ge0; [exact: ltW|exact: expR_ge0]. +Qed. + +Lemma lt0_exponential_pdf x : x < 0 -> exponential_pdf x = 0. +Proof. +move=> x0; rewrite /exponential_pdf patchE ifF//. +by apply/negP; rewrite inE/= in_itv/= andbT; apply/negP; rewrite -ltNge. +Qed. + +Let continuous_exponential_pdfT : continuous exponential_pdfT. +Proof. +move=> x. +apply: (@continuousM _ R^o (fun=> rate) (fun x => expR (- rate * x))). + exact: cst_continuous. +apply: continuous_comp; last exact: continuous_expR. +by apply: continuousM => //; apply: (@continuousN _ R^o); exact: cst_continuous. +Qed. + +Lemma measurable_exponential_pdf : measurable_fun [set: R] exponential_pdf. +Proof. +apply/measurable_restrict => //; apply: measurable_funTS. +exact: continuous_measurable_fun. +Qed. + +Lemma exponential_pdfE x : 0 <= x -> exponential_pdf x = exponential_pdfT x. +Proof. +by move=> x0; rewrite /exponential_pdf patchE ifT// inE/= in_itv/= x0. +Qed. + +Lemma in_continuous_exponential_pdf : + {in `]0, +oo[%R, continuous exponential_pdf}. +Proof. +move=> x; rewrite in_itv/= andbT => x0. +apply/(@cvgrPdist_lt _ R^o) => e e0; near=> y. +rewrite 2?(exponential_pdfE (ltW _))//; last by near: y; exact: lt_nbhsr. +near: y; move: e e0; apply/(@cvgrPdist_lt _ R^o). +by apply: continuous_comp => //; exact: continuous_exponential_pdfT. +Unshelve. end_near. Qed. + +Lemma within_continuous_exponential_pdf : + {within [set` `[0, +oo[%R], continuous exponential_pdf}. +Proof. +apply/continuous_within_itvcyP; split. + exact: in_continuous_exponential_pdf. +apply/(@cvgrPdist_le _ R^o) => e e0; near=> t. +rewrite 2?exponential_pdfE//. +near: t; move: e e0; apply/cvgrPdist_le. +by apply: cvg_at_right_filter; exact: continuous_exponential_pdfT. +Unshelve. end_near. Qed. + +End exponential_pdf. + +Definition exponential_prob {R : realType} (rate : R) := + fun V => (\int[lebesgue_measure]_(x in V) (exponential_pdf rate x)%:E)%E. + +Section exponential_prob. +Context {R : realType}. +Local Open Scope ring_scope. +Notation mu := lebesgue_measure. +Variable rate : R. +Hypothesis rate_gt0 : 0 < rate. + +Lemma derive1_exponential_pdf : + {in `]0, +oo[%R, (fun x => - (expR : R^o -> R^o) (- rate * x))^`()%classic + =1 exponential_pdf rate}. +Proof. +move=> z; rewrite in_itv/= andbT => z0. +rewrite derive1_comp// derive1N// derive1_id mulN1r derive1_comp// derive1E. +have/funeqP -> := @derive_expR R. +by rewrite derive1Ml// derive1_id mulr1 mulrN opprK mulrC exponential_pdfE ?ltW. +Qed. + +Let cexpNM : continuous (fun z : R^o => expR (- rate * z)). +Proof. +move=> z; apply: continuous_comp; last exact: continuous_expR. +by apply: continuousM => //; apply: (@continuousN _ R^o); exact: cst_continuous. +Qed. + +Lemma exponential_prob_itv0c (x : R) : 0 < x -> + exponential_prob rate `[0, x] = (1 - (expR (- rate * x))%:E)%E. +Proof. +move=> x0. +rewrite (_: 1 = - (- expR (- rate * 0))%:E)%E; last first. + by rewrite mulr0 expR0 EFinN oppeK. +rewrite addeC. +apply: (@continuous_FTC2 _ _ (fun x => - expR (- rate * x))) => //. +- apply: (@continuous_subspaceW R^o _ _ [set` `[0, +oo[%R]). + + exact: subset_itvl. + + exact: within_continuous_exponential_pdf. +- split. + + by move=> z _; exact: ex_derive. + + by apply/cvg_at_right_filter; apply: cvgN; exact: cexpNM. + + by apply/cvg_at_left_filter; apply: cvgN; exact: cexpNM. +- move=> z; rewrite in_itv/= => /andP[z0 _]. + by apply: derive1_exponential_pdf; rewrite in_itv/= andbT. +Qed. + +Lemma integral_exponential_pdf : (\int[mu]_x (exponential_pdf rate x)%:E = 1)%E. +Proof. +have mEex : measurable_fun setT (EFin \o exponential_pdf rate). + by apply/measurable_EFinP; exact: measurable_exponential_pdf. +rewrite -(setUv `[0, +oo[%classic) ge0_integral_setU//=; last 4 first. + exact: measurableC. + by rewrite setUv. + by move=> x _; rewrite lee_fin exponential_pdf_ge0. + exact/disj_setPCl. +rewrite [X in _ + X]integral0_eq ?adde0; last first. + by move=> x x0; rewrite /exponential_pdf patchE ifF// memNset. +rewrite (@ge0_continuous_FTC2y _ _ + (fun x => - (expR (- rate * x))) _ 0)//. +- by rewrite mulr0 expR0 EFinN oppeK add0e. +- by move=> x _; apply: exponential_pdf_ge0. +- exact: within_continuous_exponential_pdf. +- rewrite -oppr0; apply: (@cvgN _ R^o). + rewrite (_ : (fun x => expR (- rate * x)) = + (fun z => expR (- z)) \o (fun z => rate * z)); last first. + by apply: eq_fun => x; rewrite mulNr. + apply: (@cvg_comp _ R^o _ _ _ _ (pinfty_nbhs R)); last exact: cvgr_expR. + exact: gt0_cvgMry. +- by apply: (@cvgN _ R^o); apply: cvg_at_right_filter; exact: cexpNM. +- exact: derive1_exponential_pdf. +Qed. + +Lemma integrable_exponential_pdf : + mu.-integrable setT (EFin \o (exponential_pdf rate)). +Proof. +have mEex : measurable_fun setT (EFin \o exponential_pdf rate). + by apply/measurable_EFinP; exact: measurable_exponential_pdf. +apply/integrableP; split => //. +under eq_integral do rewrite /= ger0_norm ?exponential_pdf_ge0//. +by rewrite /= integral_exponential_pdf ltry. +Qed. + +Local Notation exponential := (exponential_prob rate). + +Let exponential0 : exponential set0 = 0%E. +Proof. by rewrite /exponential integral_set0. Qed. + +Let exponential_ge0 A : (0 <= exponential A)%E. +Proof. +rewrite /exponential integral_ge0//= => x _. +by rewrite lee_fin exponential_pdf_ge0. +Qed. + +Let exponential_sigma_additive : semi_sigma_additive exponential. +Proof. +move=> /= F mF tF mUF; rewrite /exponential; apply: cvg_toP. + apply: ereal_nondecreasing_is_cvgn => m n mn. + apply: lee_sum_nneg_natr => // k _ _; apply: integral_ge0 => /= x Fkx. + by rewrite lee_fin; apply: exponential_pdf_ge0. +rewrite ge0_integral_bigcup//=. +- apply/measurable_funTS/measurableT_comp => //. + exact: measurable_exponential_pdf. +- by move=> x _; rewrite lee_fin exponential_pdf_ge0. +Qed. + +HB.instance Definition _ := isMeasure.Build _ _ _ + exponential exponential0 exponential_ge0 exponential_sigma_additive. + +Let exponential_setT : exponential [set: R] = 1%E. +Proof. by rewrite /exponential integral_exponential_pdf. Qed. + +HB.instance Definition _ := + @Measure_isProbability.Build _ _ R exponential exponential_setT. + +End exponential_prob. diff --git a/theories/realfun.v b/theories/realfun.v index 4001c69ff..4df34d65b 100644 --- a/theories/realfun.v +++ b/theories/realfun.v @@ -38,7 +38,6 @@ From mathcomp Require Import normedtype derive sequences real_interval. (* total_variation a b f == the sup over all variations of f from a to b *) (* neg_tv a f x == the decreasing component of f *) (* pos_tv a f x == the increasing component of f *) -(* *) (* ``` *) (* *) (* Limit superior and inferior for functions: *) @@ -374,6 +373,19 @@ move /not_near_inftyP => eps_sep; exists (PosNum eps_gt0) => A /=. by case: (eps_sep _ (num_real A)) => x ? ?; exists x. Unshelve. all: by end_near. Qed. +(* NB: almost the same proof as cvg_ninftyP *) +Lemma cvge_ninftyP (f : R -> \bar R) (l : \bar R) : + f x @[x --> -oo] --> l <-> + forall u : R^nat, (u n @[n --> \oo] --> -oo) -> f (u n) @[n --> \oo] --> l. +Proof. +rewrite cvgNy_compNP cvge_pinftyP/= (@bij_forall R^nat _ -%R)//. +have u_opp (u : R^nat) : + ((- u) n @[n --> \oo] --> +oo) = (u n @[n --> \oo] --> -oo). + by rewrite propeqE cvgNry. +by under eq_forall do + (rewrite u_opp; under (eq_cvg _ (nbhs l)) do rewrite opprK). +Qed. + End cvge_fun_dvg_seq. Section fun_cvg_realType. @@ -976,13 +988,13 @@ Qed. Lemma lime_inf_sup f a : lime_inf f a <= lime_sup f a. Proof. rewrite lime_inf_lim lime_sup_lim; apply: lee_lim => //. -near=> r; rewrite ereal_sup_le//. +near=> r; rewrite ereal_sup_ge//. have ? : exists2 x, ball a r x /\ x <> a & f x = f (a + r / 2)%R. exists (a + r / 2)%R => //; split. rewrite /ball/= opprD addrA subrr sub0r normrN gtr0_norm ?divr_gt0//. by rewrite ltr_pdivrMr// ltr_pMr// ltr1n. by apply/eqP; rewrite gt_eqF// ltr_pwDr// divr_gt0. -by exists (f (a + r / 2)) => //=; rewrite inf_ballE ereal_inf_lbound. +by exists (f (a + r / 2))%R => //=; rewrite inf_ballE ereal_inf_lbound. Unshelve. all: by end_near. Qed. Local Lemma lim_lime_sup' f a l : @@ -1365,7 +1377,7 @@ apply: (@segment_can_le (- b) (- a) (f \o -%R) (- g)); rewrite /= ?lerN2 ?opprK //. pose fun_neg : subspace `[-b,-a] -> subspace `[a,b] := itvN_oppr a b. move=> z; apply: (@continuous_comp _ _ _ [fun of fun_neg]); last exact: fC. - exact/subspaceT_continuous/continuous_subspaceT/opp_continuous. + exact/subspaceT_continuous/continuous_subspaceT/oppr_continuous. by move=> z zab; rewrite -[- g]/(@GRing.opp _ \o g)/= fK ?opprK// oppr_itvcc. Qed. @@ -2303,7 +2315,7 @@ Lemma total_variationN a b f : TV a b (\- f) = TV a b f. Proof. by rewrite /TV; rewrite variationsN. Qed. Lemma total_variation_le a b f g : a <= b -> - (TV a b (f \+ g)%R <= TV a b f + TV a b g)%E. + (TV a b (f \+ g) <= TV a b f + TV a b g)%E. Proof. rewrite le_eqVlt => /predU1P[<-{b}|ab]. by rewrite !total_variationxx adde0. @@ -2323,7 +2335,7 @@ have BVabfg : BV a b (f \+ g). apply: ub_ereal_sup => y /= [r' [s' abs <-{r'} <-{y}]]. apply: (@le_trans _ _ (variation a b f s' + variation a b g s')%:E). exact: variation_le. -by rewrite EFinD leeD// ereal_sup_le//; +by rewrite EFinD leeD// ereal_sup_ge//; (eexists; last exact: lexx); (eexists; last reflexivity); exact: variations_variation. Qed. @@ -2338,7 +2350,7 @@ have [abf|abf] := pselect (BV a b f); last first. by apply: variations_neq0 => //; rewrite (lt_trans ac). have H s t : itv_partition a c s -> itv_partition c b t -> (TV a b f >= (variation a c f s)%:E + (variation c b f t)%:E)%E. - move=> acs cbt; rewrite -EFinD; apply: ereal_sup_le. + move=> acs cbt; rewrite -EFinD; apply: ereal_sup_ge. exists (variation a b f (s ++ t))%:E. eexists; last reflexivity. by exists (s ++ t) => //; exact: itv_partition_cat acs cbt. @@ -2370,13 +2382,13 @@ rewrite le_eqVlt => /predU1P[<-{b}|cb]; first by rewrite total_variationxx adde0 case : (pselect (bounded_variation a c f)); first last. move=> nbdac; have /eqP -> : TV a c f == +oo%E. have: (-oo < TV a c f)%E by apply: (lt_le_trans _ (total_variation_ge0 f (ltW ac))). - by rewrite ltNye_eq => /orP [] => // /bounded_variationP => /(_ (ltW ac)). + by rewrite ltNye_eq => /orP[|//] => /bounded_variationP => /(_ (ltW ac)). by rewrite addye ?leey // -ltNye (@lt_le_trans _ _ 0)%E // ?total_variation_ge0 // ltW. -case : (pselect (bounded_variation c b f)); first last. - move=> nbdac; have /eqP -> : TV c b f == +oo%E. +have [|nbdac] := pselect (bounded_variation c b f); first last. + have /eqP -> : TV c b f == +oo%E. have: (-oo < TV c b f)%E. exact: (lt_le_trans _ (total_variation_ge0 f (ltW cb))). - by rewrite ltNye_eq => /orP [] => // /bounded_variationP => /(_ (ltW cb)). + by rewrite ltNye_eq => /orP[|//] => /bounded_variationP => /(_ (ltW cb)). rewrite addey ?leey // -ltNye (@lt_le_trans _ _ 0%E)//. exact/total_variation_ge0/ltW. move=> bdAB bdAC. @@ -2389,7 +2401,7 @@ apply: (le_trans (variation_itv_partitionLR _ ac _ _)) => //. apply: sup_ubound => /=. case: bdAB => M ubdM; case: bdAC => N ubdN; exists (N + M). move=> q [?] [i pabi <-] [? [j pbcj <-]] <-. - by apply: lerD; [apply: ubdN;exists i|apply:ubdM;exists j]. + by apply: lerD; [apply: ubdN; exists i|apply: ubdM; exists j]. exists (variation a c f (itv_partitionL l c)). by apply: variations_variation; exact: itv_partitionLP pacl. exists (variation c b f (itv_partitionR l c)). diff --git a/theories/sequences.v b/theories/sequences.v index cbe564d5f..1581a64d1 100644 --- a/theories/sequences.v +++ b/theories/sequences.v @@ -282,6 +282,9 @@ apply/funext => n; rewrite -setIDA; apply/seteqP; split; last first. by rewrite /seqDU -setIDA bigcup_mkord -big_distrr/= setDIr setIUr setDIK set0U. Qed. +Lemma subset_seqDU (A : (set T)^nat) (i : nat) : seqDU A i `<=` A i. +Proof. by move=> ?; apply: subDsetl. Qed. + End seqDU. Arguments trivIset_seqDU {T} F. #[global] Hint Resolve trivIset_seqDU : core. @@ -488,12 +491,6 @@ Lemma cvg_has_inf u_ : cvgn u_ -> has_inf (u_ @` setT). Proof. by move/is_cvgN/cvg_has_sup; rewrite -has_inf_supN image_comp. Qed. End sequences_R_lemmas_realFieldType. -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nonincreasing_cvgn_ge`")] -Notation nonincreasing_cvg_ge := nonincreasing_cvgn_ge (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nondecreasing_cvgn_le`")] -Notation nondecreasing_cvg_le := nondecreasing_cvgn_le (only parsing). Section partial_sum. Variables (V : zmodType) (u_ : V ^nat). @@ -702,27 +699,6 @@ by split=> //; apply/eqP; rewrite -subr_eq0 -limB //; exact/eqP/cvg_lim. Qed. End sequences_R_lemmas. -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nonincreasing_cvgn`")] -Notation nonincreasing_cvg := nonincreasing_cvgn (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nondecreasing_cvgn`")] -Notation nondecreasing_cvg := nondecreasing_cvgn (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nonincreasing_is_cvgn`")] -Notation nonincreasing_is_cvg := nonincreasing_is_cvgn (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nondecreasing_is_cvgn`")] -Notation nondecreasing_is_cvg := nondecreasing_is_cvgn (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `nondecreasing_dvgn_lt`")] -Notation nondecreasing_dvg_lt := nondecreasing_dvgn_lt (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `near_nondecreasing_is_cvgn`")] -Notation near_nondecreasing_is_cvg := near_nondecreasing_is_cvgn (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", - note="renamed to `near_nonincreasing_is_cvgn`")] -Notation near_nonincreasing_is_cvg := near_nonincreasing_is_cvgn (only parsing). Definition harmonic {R : fieldType} : R ^nat := [sequence n.+1%:R^-1]_n. Arguments harmonic {R} n /. @@ -1286,6 +1262,50 @@ Unshelve. all: by end_near. Qed. (** Sequences of extended real numbers *) +Section ereal_inf_sup_seq. +Context {R : realType}. +Implicit Types (S : set (\bar R)). +Local Open Scope ereal_scope. + +Lemma ereal_inf_seq S : S != set0 -> + {u : (\bar R)^nat | forall i, S (u i) & u @ \oo --> ereal_inf S}. +Proof. +move=> SN0; apply/cid2; have [|Ninfy] := eqVneq (ereal_inf S) +oo. + move=> /[dup]/ereal_inf_pinfty/subset_set1/orW[/eqP/negPn/[!SN0]//|->] ->. + by exists (fun=> +oo) => //; apply: cvg_cst. +suff: exists2 v : (\bar R)^nat, v @ \oo --> ereal_inf S & + forall n, exists2 x : \bar R, x \in S & x < v n. + move=> [v vcvg] /(_ _)/sig2W-/all_sig/= [u /all_and2[/(_ _)/set_mem Su u_lt]]. + exists u => //; move: vcvg. + have: cst (ereal_inf S) @ \oo --> ereal_inf S by exact: cvg_cst. + apply: squeeze_cvge; apply: nearW => n; rewrite /cst/=. + by rewrite ereal_inf_le /= 1?ltW; last by exists (u n). +have [infNy|NinfNy] := eqVneq (ereal_inf S) -oo. + exists [sequence - (n%:R%:E)]_n => /=; last first. + by move=> n; setoid_rewrite set_mem_set; apply: lb_ereal_infNy_adherent. + rewrite infNy; apply/cvgNey; under eq_cvg do rewrite EFinN oppeK. + exact/cvgeryP/cvgr_idn. +have inf_fin : ereal_inf S \is a fin_num by case: ereal_inf Ninfy NinfNy. +exists [sequence ereal_inf S + n.+1%:R^-1%:E]_n => /=; last first. + by move=> n; setoid_rewrite set_mem_set; exact: lb_ereal_inf_adherent. +apply/sube_cvg0 => //=; apply/cvg_abse0P. +rewrite (@eq_cvg _ _ _ _ (fun n => n.+1%:R^-1%:E)). + exact: cvge_harmonic. +by move=> n /=; rewrite /= addrAC subee// add0e gee0_abs. +Unshelve. all: by end_near. Qed. + +Lemma ereal_sup_seq S : S != set0 -> + {u : nat -> \bar R | forall i, S (u i) & u @ \oo --> ereal_sup S}. +Proof. +move=> SN0; have NSN0 : [set - x | x in S] != set0. + by have /set0P[x Sx] := SN0; apply/set0P; exists (- x), x. +have [u /= Nxu] := ereal_inf_seq NSN0. +rewrite ereal_infN => /cvgeN; rewrite oppeK => Nu_to_sup. +by exists (\- u) => // i; have [? ? <-] := Nxu i; rewrite oppeK. +Qed. + +End ereal_inf_sup_seq. + Notation "\big [ op / idx ]_ ( m <= i (\big[ op / idx ]_(m <= i < n | P) F))) : big_scope. Notation "\big [ op / idx ]_ ( m <= i ->. Qed. End lim_esup_inf. -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `limn_einf_shift`")] -Notation lim_einf_shift := limn_einf_shift (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `limn_esup_le_cvg`")] -Notation lim_esup_le_cvg := limn_esup_le_cvg (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `limn_einfN`")] -Notation lim_einfN := limn_einfN (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `limn_esupN`")] -Notation lim_esupN := limn_esupN (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `limn_einf_sup`")] -Notation lim_einf_sup := limn_einf_sup (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `cvgNy_limn_einf_sup`")] -Notation cvgNy_lim_einf_sup := cvgNy_limn_einf_sup (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `cvg_limn_einf_sup`")] -Notation cvg_lim_einf_sup := cvg_limn_einf_sup (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `is_cvg_limn_einfE`")] -Notation is_cvg_lim_einfE := is_cvg_limn_einfE (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.6", note="renamed to `is_cvg_limn_esupE`")] -Notation is_cvg_lim_esupE := is_cvg_limn_esupE (only parsing). Lemma geometric_le_lim {R : realType} (n : nat) (a x : R) : 0 <= a -> 0 < x -> `|x| < 1 -> series (geometric a x) n <= a * (1 - x)^-1. diff --git a/theories/showcase/gauss_integral_unbounded.v b/theories/showcase/gauss_integral_unbounded.v new file mode 100644 index 000000000..6939f103a --- /dev/null +++ b/theories/showcase/gauss_integral_unbounded.v @@ -0,0 +1,590 @@ +From mathcomp Require Import all_ssreflect ssralg ssrnum interval. +From mathcomp Require Import boolp classical_sets functions reals ereal. +From mathcomp Require Import topology normedtype sequences exp measure. +From mathcomp Require Import lebesgue_measure numfun lebesgue_integral. +From mathcomp Require Import interval_inference real_interval realfun derive. +From mathcomp Require Import trigo ftc gauss_integral. + +(**md**************************************************************************) +(* # Improper Integral *) +(* # calculating gauss integrals by limit *) +(* ref: https://www.phys.uconn.edu/~rozman/Courses/P2400_17S/ *) +(* downloads/gaussian-integral.pdf *) +(* u (x : R) (y : R) : R == a function dominates gauss_fun over `[0, +oo[ *) +(* int0yu (x : R) : R == (u x) integrated for y over `[0, +oo[, which is *) +(* J in ref. *) +(* *) +(* *) +(******************************************************************************) + +Set Implicit Arguments. +Unset Strict Implicit. +Unset Printing Implicit Defensive. + +Import Order.TTheory GRing.Theory Num.Def Num.Theory. +Import Num numFieldTopology.Exports numFieldNormedType.Exports. + +Local Open Scope classical_set_scope. +Local Open Scope ring_scope. +Local Open Scope ereal_scope. + +Section gauss_integral_alternative. +Context {R : realType}. +Local Notation mu := lebesgue_measure. +Local Notation gauss_fun := (@gauss_fun R). +Local Notation u := (@gauss_integral_proof.u R). +Local Notation "'d1 f" := (partial1of2 f). + +Section gauss_integral_preliminaries. + +Lemma integral0y_gauss_fin_num : + (\int[mu]_(x in `[0%R, +oo[) (gauss_fun x)%:E)%E \is a fin_num. +Proof. +rewrite ge0_fin_numE//; last first. + by apply: integral_ge0 => //= x _; rewrite lee_fin gauss_fun_ge0. +rewrite (_: `[0%R, +oo[%classic = `[0%R, 1%R[ `|` `[1%R, +oo[); last first. + by apply: set_interval.itv_bndbnd_setU; rewrite bnd_simp. +rewrite ge0_integral_setU => //=; last 3 first. +- by apply/measurable_funTS/measurable_EFinP; exact: measurable_gauss_fun. +- by move=> ? _; exact: gauss_fun_ge0. +- apply: lt_disjoint => x y; rewrite !in_itv/= => /andP[_ +] /andP[+ _]. + exact: lt_le_trans. +apply: lte_add_pinfty. + apply: (@le_lt_trans _ _ (\int[mu]_(x in `[0%R, 1%R[) (cst 1) x))%E. + apply: ge0_le_integral => //; last 2 first. + - by apply/measurable_funTS/measurable_EFinP; exact: measurable_gauss_fun. + - by move=> x _; rewrite lee_fin gauss_fun_le1. + by move=> ? _; rewrite lee_fin gauss_fun_ge0. + rewrite integral_cst/=; last exact: measurable_itv. + by rewrite lebesgue_measure_itv/= lte01 oppr0 adde0 mule1 ltry. +apply: (@le_lt_trans _ _ (\int[mu]_(x in `[1%R, +oo[) (expR (- x))%:E))%E. + apply: ge0_le_integral => //=. + - by move=> x _; rewrite lee_fin gauss_fun_ge0. + - by apply/measurable_funTS/measurable_EFinP; exact: measurable_gauss_fun. + - apply/measurable_funTS/measurableT_comp => //; exact: measurableT_comp. + move=> x; rewrite in_itv/= => /andP[x1 _]. + by rewrite lee_fin ler_expR lerN2 expr2 ler_peMl// (le_trans _ x1). +have cvgr_NexpR : -%R (@expR R (- x)) @[x --> +oo%R] --> 0%R. + by rewrite -oppr0; apply: cvgN; exact: cvgr_expR. +rewrite (ge0_continuous_FTC2y _ _ cvgr_NexpR); last 5 first. +- by move=> x x0; rewrite expR_ge0. +- apply/continuous_within_itvcyP; split. + move=> ? _; apply: continuous_comp. + exact: continuousN. + exact: continuous_expR. + apply: cvg_at_right_filter. + rewrite expRN; under eq_cvg do rewrite expRN; apply: cvgV => //. + exact: continuous_expR. +- move=> ? _; exact: ex_derive. +- apply: cvg_at_right_filter. + apply: cvgN => //; rewrite expRN; under eq_cvg do rewrite expRN. + by apply: cvgV => //; exact: continuous_expR. +- by move=> x x1; rewrite derive1E derive_val mulrN1 opprK. +by rewrite -EFinB ltry. +Qed. + +End gauss_integral_preliminaries. + +Section u_properties. + +Lemma integral0y_u0 : + (\int[mu]_(y in `[0%R, +oo[) (u 0%R y)%:E = (@pi R / 2)%:E). +Proof. +rewrite /gauss_integral_proof.u expr0n/= oppr0. +under eq_integral do rewrite mul0r expR0 div1r. +exact: integral0y_oneDsqr. +Qed. + +Lemma integrable0y_u x : mu.-integrable `[0%R, +oo[ (EFin \o u x). +Proof. +have ? : measurable_fun `[(0%R : R), +oo[ (EFin \o u x). + apply/measurable_EFinP/measurable_funTS. + exact: gauss_integral_proof.measurable_u. +apply/integrableP; split => //. +apply/abse_integralP => //. +rewrite -fin_num_abs ge0_fin_numE; last first. + by apply: integral_ge0 => z z0; rewrite lee_fin gauss_integral_proof.u_ge0. +apply: (@le_lt_trans _ _ (\int[mu]_(y in `[0%R, +oo[) (EFin \o u 0%R) y))%E. + apply: ge0_le_integral => //. + - by move=> z _; rewrite lee_fin gauss_integral_proof.u_ge0. + - by move=> z _; rewrite lee_fin gauss_integral_proof.u_ge0. + - apply/measurable_EFinP/measurable_funTS. + exact: gauss_integral_proof.measurable_u. + move=> z z0; rewrite lee_fin ler_pdivrMr ?oneDsqr_gt0// divfK ?oneDsqr_neq0//. + rewrite ler_expR expr0n oppr0/= mul0r pmulr_lle0 ?oneDsqr_gt0//. + by rewrite lerNl oppr0 sqr_ge0. +by rewrite integral0y_u0 ltry. +Qed. + +End u_properties. + +Section gauss_dominates. +Local Open Scope ring_scope. + +Definition max_x : R := (Num.sqrt 2)^-1. + +Let max_x_ge0 : (0 <= max_x). Proof. by rewrite invr_ge0. Qed. + +Definition max_y : R := 2 / Num.sqrt 2 / Num.sqrt (expR 1). + +Lemma max_y_ge0 : (0 <= max_y). Proof. by rewrite mulr_ge0. Qed. + +Definition ndgauss (x : R) := (2 * x * expR (- x ^+ 2)). + +Definition nd2gauss (x : R) := (expR (- x ^+ 2) * (2 - 4 * x ^+ 2)). + +Let ndgaussE : ndgauss^`() = nd2gauss. +Proof. +apply/funext => x; rewrite /ndgauss/= derive1E derive_val/GRing.scale/= 2!mulr1. +rewrite -mulr2n mulrCA mulrN -mulrDr addrC; congr (_ * (_ + - _))%R. +by rewrite expr2 -(mulr_natr x) mulrCA mulrAC -mulrC mulrA -natrM. +Qed. + +Let ndgauss_maxE : ndgauss max_x = max_y. +Proof. +rewrite /ndgauss/= /max_x exprVn expRN sqr_sqrtr//. +by rewrite -(div1r 2) expRM powR12_sqrt ?expR_ge0//. +Qed. + +Let ndgauss_ub (x : R) : 0 <= x -> ndgauss x <= max_y. +Proof. +rewrite le_eqVlt => /predU1P[<- |x0]. + rewrite /ndgauss mulr0 mul0r; exact: max_y_ge0. +rewrite -ndgauss_maxE. +have [xmax|xmax] := leP x max_x. +- apply: (@ger0_derive1_ndecr _ _ 0 max_x) => //; last exact: ltW; last first. + exact: derivable_within_continuous. + move=> y /[!in_itv]/= => /andP[y0 ymax]. + rewrite ndgaussE mulr_ge0 ?expR_ge0// subr_ge0. + rewrite (natrM _ 2 2) -mulrA ler_piMr// -ler_pdivlMl// mulr1. + move/ltW : ymax => /(lerXn2r 2); rewrite !nnegrE => /(_ (ltW y0) max_x_ge0). + by rewrite /max_x exprVn sqr_sqrtr. +- apply: (@ler0_derive1_nincry _ _ max_x) => //; last exact/ltW; last first. + exact: derivable_within_continuous. + move=> y /[!in_itv]/= => /andP[ymax _]. + rewrite ndgaussE /nd2gauss mulr_ge0_le0 ?expR_ge0// subr_le0. + rewrite (natrM _ 2 2) -mulrA ler_peMr// -ler_pdivrMl// mulr1. + move/ltW : (ymax) => /(lerXn2r 2). + rewrite !nnegrE => /(_ max_x_ge0 (ltW (le_lt_trans max_x_ge0 ymax))). + by rewrite /max_x exprVn sqr_sqrtr//. +Qed. + +Let d1u_tmp (x' y : R) : 'd1 u x' y = oneDsqr y * - 2 * x' * u x' y. +Proof. +rewrite gauss_integral_proof.partial1_u. +rewrite -![in RHS]mulrA [RHS]mulrC -![in RHS]mulrA. +rewrite mulVf ?oneDsqr_neq0// mulr1 -!mulrA; congr (_ * (_ * _))%R. +rewrite -expRD exprMn_comm//; last by rewrite /GRing.comm mulrC. +by rewrite mulrDr mulr1 mulNr mulrC. +Qed. + +Lemma u_dominates (x : R) : (0 < x) -> + \forall e \near (0:R)^'+, + let I := (ball x e : set R) : set R in + let c := (x - e : R) : R in + forall (x1 : R) + (y : [the measurableType (R.-ocitv.-measurable).-sigma of + g_sigma_algebraType R.-ocitv.-measurable]), + `](x - e)%R, (x + e)[%classic x1 -> + `[0%R, +oo[%classic y -> + (normr (('d1 u) x1 y) <= max_y * expR (- c ^+ 2 * y ^+ 2))%R. +Proof. +move=> x0. +near=> e; move=> x' y /=; rewrite in_itv/= d1u_tmp => /andP[/ltW xex' x'xe] y0. +have x'0 : 0 < x'. + by rewrite (lt_le_trans _ xex')// subr_gt0; near: e; apply: nbhs_right_lt. +rewrite [leLHS](_ : _ = 2 * normr x' * (expR (- x' ^+ 2 * oneDsqr y))); + last first. + rewrite /u/gauss_integral_proof.u. + rewrite -2![in LHS]mulrA mulrC -3![in LHS]mulrA mulVf ?oneDsqr_neq0// mulr1. + rewrite normrM normrN (@ger0_norm _ 2)//. + by rewrite normrM (@ger0_norm _ (expR _)) ?expR_ge0// mulrA. +rewrite mulrDr mulr1 expRD mulrA ler_pM//. + by move: y0; rewrite in_itv/= andbT => y0; rewrite ger0_norm ?ndgauss_ub ?ltW. +rewrite ler_expR 2!mulNr lerN2 ler_wpM2r// ?sqr_ge0//. +by rewrite ler_sqr ?nnegrE// ltW// subr_gt0; near: e; exact: nbhs_right_lt. +Unshelve. end_near. Qed. + +End gauss_dominates. + +Section derive_and_integral_u. +Local Open Scope ring_scope. +Local Import Num Num.Theory. + +Let int0yu (x : R) := \int[mu]_(y in `[0, +oo[) u x y. + +Lemma int0yu_fin_num x : (\int[mu]_(x0 in `[0%R, +oo[) (u x x0)%:E)%E \is a fin_num. +Proof. +move: (integrable0y_u x). +have int0yu_ge0 : (0 <= \int[mu]_(x0 in `[0%R, +oo[) (u x x0)%:E)%E. + by apply: integral_ge0 => y _; rewrite lee_fin gauss_integral_proof.u_ge0. +move/integrableP => [_]. +rewrite ge0_fin_numE => //. +have : measurable_fun `[(0 : R), +oo[ (EFin \o u x). + apply/measurable_EFinP; apply/measurable_funTS. + exact: gauss_integral_proof.measurable_u. +move/(abse_integralP mu (measurable_itv _)) => [_]. +by rewrite -(@ge0_fin_numE _ (`| _|))// abse_fin_num ge0_fin_numE/=. +Qed. + +Lemma cvgy_int0yu0 : int0yu x @[x --> +oo] --> 0. +Proof. +apply/cvgrPdist_le => /= e e0; near=> x; rewrite sub0r. +rewrite ler0_norm ?oppr_le0; last first. + by apply: Rintegral_ge0 => ? ?; exact: gauss_integral_proof.u_ge0. +rewrite opprK (@le_trans _ _ (expR (- x ^+ 2) * int0yu 0))//. + rewrite [leRHS](_ : _ = fine ((expR (- x ^+ 2))%:E) * int0yu 0) => //. + rewrite -fineM => //; last exact: int0yu_fin_num. + rewrite /int0yu/Rintegral fine_le ?fin_numM//. + - exact: int0yu_fin_num. + - exact: int0yu_fin_num. + rewrite -ge0_integralZl//=; last 2 first. + - apply/measurable_funTS/measurable_EFinP. + exact: gauss_integral_proof.measurable_u. + - by move=> ? _; rewrite lee_fin gauss_integral_proof.u_ge0. + apply: le_integral => //; first exact: integrable0y_u. + by rewrite integrableZl//; exact: integrable0y_u. + move=> y _. + rewrite lee_fin ler_pdivrMr ?oneDsqr_gt0//. + rewrite mulrA divfK ?oneDsqr_neq0//. + rewrite expr0n oppr0/= mul0r expR0 mulr1 ler_expR. + by rewrite ler_neMr ?oneDsqr_ge1// oppr_le0; exact: sqr_ge0. +rewrite /int0yu/Rintegral integral0y_u0/=. +rewrite -ler_pdivlMr; last exact: lt_le_trans (pihalf_ge1 _). +rewrite expRN -[leRHS]invrK lef_pV2 ?posrE; last 2 first. +- exact: expR_gt0. +- by rewrite invr_gt0 divr_gt0//; apply: lt_le_trans (pihalf_ge1 _). +rewrite -[leLHS]lnK ?posrE; last first. + by rewrite invr_gt0 divr_gt0//; apply: lt_le_trans (pihalf_ge1 _). +rewrite ler_expR -ler_sqrt; last exact: sqr_ge0. +by rewrite sqrtr_sqr ger0_norm. +Unshelve. end_near. Qed. + +Let der_mulrE (x : R) : (fun z => x * z)^`() = cst x. +Proof. +under eq_fun do rewrite mulrC. +by apply/funext => z; rewrite (@derive1Mr R id z x)// derive1_id mul1r. +Qed. + +Let integrable0y_gaussZl (c : R) : c != 0 -> mu.-integrable `[0, +oo[ + (fun z => (expR (- (c * z) ^+ 2))%:E). +Proof. +suff : (forall c : R, 0 < c -> mu.-integrable `[0, +oo[ + (fun z => (expR (- (c * z) ^+ 2))%:E)). + move=> Hsuff; rewrite neq_lt => /orP; case => c0. + - under [X in _.-integrable _ X]eq_fun do rewrite -sqrrN -(mulNr c). + by apply: Hsuff; rewrite oppr_gt0. + - exact: Hsuff. +move=> /= {}c c0. +have mcg : measurable_fun `[@GRing.zero R, +oo[ + (fun x => (expR (- (c * x)^+2))%:E). + exact/measurable_EFinP/(measurableT_comp measurable_gauss_fun). +apply/integrableP; split => //; apply/abse_integralP => //=. +rewrite -ge0_fin_numE; last exact: abse_ge0. +rewrite abse_fin_num ge0_fin_numE; last first. + apply: integral_ge0 => z _. + exact: gauss_fun_ge0. +under eq_integral. + move=> z _. + have -> :((expR (- (c * z) ^+ 2))%:E = + c^-1%:E * (((gauss_fun \o (fun z => c * z)) * (fun z => c * z)^`()) z)%:E)%E. + rewrite !fctE derive1E derive_val EFinM muleC -muleA -EFinM. + by rewrite /GRing.scale/= mulr1 mulfV ?mulr1// gt_eqF. + over. +rewrite ge0_integralZl//; first last. + - by rewrite lee_fin invr_ge0 ltW. + - move=> x _. + rewrite !fctE derive1E derive_val /GRing.scale/= mulr1. + by rewrite lee_fin mulr_ge0 ?gauss_fun_ge0 ?ltW. + - under [X in _ _ X]eq_fun. + move=> x. + rewrite !fctE derive1E derive_val /GRing.scale/= mulr1. + over. + apply/measurable_EFinP. + rewrite /=. + apply: (measurableT_comp (mulrr_measurable _)). + exact: (measurableT_comp measurable_gauss_fun). +rewrite -increasing_ge0_integration_by_substitutiony//= ?der_mulrE; last 8 first. +- by move=> ? ? _ _ +; rewrite ltr_pM2l. +- by move=> ? _; exact: cst_continuous. +- exact: is_cvg_cst. +- exact: is_cvg_cst. +- split => //; apply: cvgZr; exact: cvg_at_right_filter. +- apply/cvgryPge => r; under eq_near do rewrite -ler_pdivrMl//. + apply: nbhs_pinfty_ge; exact: num_real. +- by apply: continuous_subspaceT; exact: continuous_gauss_fun. +- move=> ? _; exact: gauss_fun_ge0. +have cV_ge0 : (0 <= (c^-1)%:E)%E by rewrite lee_fin invr_ge0 ltW. +apply: lte_mul_pinfty => //. +rewrite -ge0_fin_numE mulr0; first exact: integral0y_gauss_fin_num. +by apply: integral_ge0 => ? _; rewrite lee_fin gauss_fun_ge0. +Qed. + +Let derivable_u (x y : R) : derivable (u^~ y) x 1. +Proof. +rewrite /u/gauss_integral_proof.u. +apply/derivable1_diffP/differentiableM; last by apply: differentiableV => //. +by apply: differentiable_comp => //; exact/derivable1_diffP. +Qed. + +Let substE x : 0 < x -> + (\int[mu]_(y in `[0%R, +oo[) (expR (- x ^+ 2 * oneDsqr y))%:E = + \int[mu]_(y in `[0%R, +oo[) + ((((fun z => gauss_fun x / x * gauss_fun z) \o + (fun z => x * z)) * (fun z => x * z)^`()) y)%:E)%E. +Proof. +move=> x0; apply: eq_integral => y _. +rewrite !fctE derive1E derive_val /GRing.scale/= mulr1. +rewrite mulrAC divfK//; last by rewrite gt_eqF. +by rewrite mulrDr mulr1 mulNr -exprMn expRD. +Qed. + +Let int_substE x : 0 < x -> + (\int[mu]_(y in `[0%R, +oo[) (expR (- x ^+ 2 * oneDsqr y))%:E + = \int[mu]_(x1 in `[0%R, +oo[) (gauss_fun x / x * gauss_fun x1)%:E)%E. +Proof. +move=> x0; rewrite substE; last exact: x0. +rewrite -increasing_ge0_integration_by_substitutiony ?der_mulrE; last 8 first. +- by move=> ? ?; rewrite !in_itv/= 2!andbT; rewrite ltr_pM2l. +- by move=> ? _; exact: cst_continuous. +- exact: is_cvg_cst. +- exact: is_cvg_cst. +- by split => //; apply: cvgZr; exact: cvg_at_right_filter. +- apply/cvgryPge => r; near=> t; rewrite -lter_pdivrMl; last exact: x0; near: t. + by apply:nbhs_pinfty_ge; rewrite num_real. +- apply: continuous_subspaceT. + by move=> ?; apply: continuousZr; exact: continuous_gauss_fun. +- by move=> y _; rewrite mulr_ge0 ?expR_ge0// divr_ge0 ?expR_ge0// ltW. +by rewrite mulr0. +Unshelve. end_near. Qed. + +Let derive1_int0yuE_subproof1 x : 0 < x -> + int0yu^`() x = \int[mu]_(y in `[0, +oo[) ('d1 u) x y. +Proof. +move=> x0. +near ((0:R)^'+) => e. +have xex : `]x - e, x + e[%classic x by rewrite -ball_itv; exact: ballxx. +pose G := (fun y => (max_y) * expR (- (x - e) ^+ 2 * y ^+ 2)). +rewrite (@differentiation_under_integral R _ _ mu _ _ _ _ _ _ xex _ _ G)//. +- by move=> ? _; exact: integrable0y_u. +- by move=> ?; rewrite mulr_ge0// ?expR_ge0// max_y_ge0. +- under [X in _ _ X]eq_fun do rewrite EFinM mulNr. + under [X in _ _ X]eq_fun do (rewrite -exprMn_comm; last exact: mulrC). + apply/integrableZl=> //; rewrite integrable0y_gaussZl ?gt_eqF// subr_gt0. + by near: e; exact: nbhs_right_lt. +- by rewrite {}/G; near: e; exact: u_dominates. +Unshelve. end_near. Qed. + +Let derive1_int0yuE_subproof2 x : (0 < x) -> + \int[mu]_(y in `[0, +oo[) ('d1 u) x y = + -2 * x * \int[mu]_(y in `[0, +oo[) (expR ((- x ^+ 2) * oneDsqr y)). +Proof. +move=> x0. +have mexpRVxexpR (D : set R) : + measurable_fun D (fun y => gauss_fun x / x * gauss_fun y). + apply: measurable_funM => //; apply: measurable_funTS. + exact: measurable_gauss_fun. +rewrite /Rintegral (_ : - 2 * x = fine (- 2 * x)%:E)//. +rewrite -fineM//; last first. + rewrite ge0_fin_numE; last by apply: integral_ge0 => ? _; exact: expR_ge0. + apply: (@le_lt_trans _ _ + (\int[mu]_(y in `[0%R, +oo[) (gauss_fun (x * y))%:E)%E). + apply: ge0_le_integral => //. + - apply/measurable_EFinP/measurable_funTS. + apply: measurableT_comp => //. + apply: measurable_funM => //. + exact: measurable_funD. + - by move=> y _; exact: gauss_fun_ge0. + - apply/measurable_EFinP/measurable_funTS. + apply: measurableT_comp => //. + exact: measurable_gauss_fun. + - move=> y _; rewrite lee_fin ler_expR. + by rewrite mulNr lerN2 mulrDr exprMn lerDr mulr1 sqr_ge0. + under eq_integral => y _. + rewrite [X in X%:E](_ : _ = + ((gauss_fun \o ( *%R x)) \* ( *%R x)^`()) y * x^-1); last first. + by rewrite der_mulrE/= mulfK ?gt_eqF. + rewrite EFinM. + over. + rewrite ge0_integralZr// ?lee_fin ?invr_ge0 ?ltW//; last 2 first. + - apply/measurable_EFinP/measurable_funM; last by rewrite der_mulrE. + apply/measurable_funTS/measurableT_comp => //. + exact: measurable_gauss_fun. + - by move=> ? _; rewrite lee_fin der_mulrE mulr_ge0// ?gauss_fun_ge0 ?ltW. + rewrite -increasing_ge0_integration_by_substitutiony ?der_mulrE; last 8 first. + - by move=> ? ? _ _; rewrite ?ltr_pM2l ?invr_gt0. + - by move=> ? _; exact: cst_continuous. + - exact: is_cvg_cst. + - exact: is_cvg_cst. + - split; first (move=> ? _; exact: ex_derive). + by apply: cvgMr; apply: cvg_at_right_filter; exact: cvg_id. + - by under eq_cvg do rewrite mulrC; apply: gt0_cvgMly => //; rewrite invr_gt0. + - apply: continuous_subspaceT => y; exact: continuous_gauss_fun. + - by move=> y _; exact: gauss_fun_ge0. + rewrite lte_mul_pinfty ?ltry ?mulr0 ?integral0y_gauss_fin_num//. + by rewrite integral_ge0// => ? _; rewrite lee_fin gauss_fun_ge0. +rewrite mulNr EFinN mulNe -ge0_integralZl ?lee_fin ?mulr_ge0 ?ltW//; last first. + apply/measurable_EFinP/measurableT_comp => //. + by apply: measurable_funM => //; exact: measurable_funD. +rewrite -integral_ge0N; last first. + by move=> ? _; apply: mulr_ge0; rewrite ?expR_ge0// mulr_ge0// ltW. +congr fine; apply: eq_integral=> y; rewrite inE/= in_itv/= => y0. +rewrite /partial1of2 derive1E derive_val. +rewrite 3!scaler0 2!add0r mulrC scalerA /GRing.scale/= mulrA mulr1. +by rewrite mulVf// mul1r -mulr2n mulNr mulr_natl. +Qed. + +Lemma derive1_int0yuE : {in `]0, +oo[, + int0yu^`() =1 + (fun x => (- 2) * gauss_integral_proof.integral0y_gauss * gauss_fun x)}. +Proof. +move=> x; rewrite in_itv/= => /andP[x0 _]. +rewrite derive1_int0yuE_subproof1//. +rewrite derive1_int0yuE_subproof2//. +rewrite /Rintegral int_substE//. +under eq_integral do rewrite EFinM; rewrite ge0_integralZl//=; last 3 first. +- by apply/measurable_EFinP/measurable_funTS; exact: measurable_gauss_fun. +- by move=> ? _; exact: gauss_fun_ge0. +- by rewrite lee_fin divr_ge0 ?expR_ge0// ltW. +rewrite fineM//=; last exact: integral0y_gauss_fin_num. +by rewrite -3!mulrA [X in (-2 * X)]mulrCA !mulrA mulfK ?gt_eqF// mulrAC. +Unshelve. all: end_near. Qed. + +Let cvg_u (y : R) : u x y @[x --> 0^'] --> u 0 y. +Proof. +apply/cvgrPdist_lep; near=> e; near=> t. +rewrite {1}/u/gauss_integral_proof.u expr0n/= oppr0 mul0r expR0. +have /normr_idP -> : 0 <= 1 / oneDsqr y - u t y. + rewrite -mulNr -mulrDl divr_ge0 ?oneDsqr_ge0// subr_ge0 -expR0 ler_expR. + by rewrite mulNr oppr_le0 mulr_ge0// ?sqr_ge0 ?oneDsqr_ge0. +rewrite -mulNr -mulrDl ler_pdivrMr ?oneDsqr_gt0// lerBlDl -lerBlDr. +rewrite -[leLHS]lnK; last by rewrite posrE subr_gt0 -ltr_pdivlMr ?oneDsqr_gt0. +rewrite ler_expR -ler_pdivrMr ?oneDsqr_gt0// lerNr -ler_sqrt; last first. + rewrite lerNr oppr0 mulr_le0_ge0 ?invr_ge0 ?oneDsqr_ge0// ln_le0//. + by rewrite gerBl mulr_ge0// oneDsqr_ge0. +rewrite sqrtr_sqr. +near: t; rewrite near_nbhs; apply: dnbhs0_le. +rewrite sqrtr_gt0 oppr_gt0 pmulr_llt0 ?invr_gt0 ?oneDsqr_gt0// ln_lt0//. +apply/andP; split; last by rewrite gtrBl mulr_gt0// oneDsqr_gt0. +by rewrite subr_gt0 -ltr_pdivlMr ?oneDsqr_gt0. +Unshelve. all:end_near. Qed. + +Lemma derivable_int0yu : {in `]0, +oo[, forall x, derivable int0yu x 1}. +Proof. +move=> x; rewrite in_itv/= andbT => x0. +near (0:R)^'+ => e. +pose ballx : set R := ball x e. +have ballx_x : `]x - e, x + e[%classic x. + rewrite -ball_itv. + exact: ballxx. +pose c : R := x - e. +apply: (@derivable_under_integral _ _ (measurableTypeR R) _ _ _ _ _ _ _ ballx_x + _ _ (fun y => (max_y) * expR (- c ^+ 2 * y ^+ 2))) => //. +- by move=> ? _; exact: integrable0y_u. +- by move=> /= ?; rewrite mulr_ge0// ?expR_ge0// max_y_ge0. +- rewrite (_ : _ \o _ = + (fun x=> (max_y)%:E * (expR (- c ^+ 2 * x ^+ 2))%:E)%E)//. + apply: integrableZl => //=. + under [X in _.-integrable _ X]eq_fun => z. + rewrite mulNr -exprMn_comm; last exact: mulrC. + over. + apply: integrable0y_gaussZl. + by rewrite gt_eqF// subr_gt0; near: e; apply: nbhs_right_lt. +- by rewrite {}/ballx {}/c; near: e; exact: u_dominates. +Unshelve. all: end_near. Qed. + +Lemma rc_int0yu0 : int0yu x @[x --> 0^'+] --> int0yu 0. +Proof. +apply/cvg_at_rightP. +move=> x_ [x_ge0 x_0]. +rewrite /int0yu. +suff : [/\ mu.-integrable `[0%R, +oo[ (EFin \o u 0), +(\int[mu]_(x in `[0%R, +oo[) `|(EFin \o u (x_ n)) x - (EFin \o u 0) x|)%E + @[n --> \oo] --> 0%E + & (\int[mu]_(x in `[0%R, +oo[) (EFin \o u (x_ n)) x)%E @[n --> \oo] --> + (\int[mu]_(x in `[0%R, +oo[) (EFin \o u 0) x)%E]. + move=> [_ lim_norm0 cvgint0yu]. + apply: fine_cvg; rewrite fineK; first exact: cvgint0yu. + rewrite integral0y_u0 ge0_fin_numE; first by rewrite ltry. + by rewrite lee_fin divr_ge0// pi_ge0. +have intbl0y_u0 : mu.-integrable `[0%R, +oo[ (EFin \o u 0). + exact: integrable0y_u. +apply: (dominated_convergence _ _ _ _ intbl0y_u0) => //. +- move=> n; apply/measurable_funTS/measurable_EFinP. + exact: gauss_integral_proof.measurable_u. +- apply/measurable_funTS/measurable_EFinP. + exact: gauss_integral_proof.measurable_u. +- apply: aeW => /= y _; apply: cvg_EFin. + apply: nearW => n; rewrite ge0_fin_numE; first exact: ltry. + by rewrite lee_fin mulr_ge0// ?expR_ge0// invr_ge0// oneDsqr_ge0. + apply: (cvgr_dnbhsP (u ^~ y) 0%R (u 0 y)).1; first exact: cvg_u. + split; last exact: x_0. + by move=> n; rewrite gt_eqF. +- apply: aeW => /= x n _. + have /normr_idP -> : (0 <= gauss_integral_proof.u (x_ n) x)%R. + by rewrite mulr_ge0// ?expR_ge0 ?invr_ge0 ?oneDsqr_ge0. + rewrite lee_fin. + apply: ler_pM => //; rewrite ?expR_ge0 ?invr_ge0 ?oneDsqr_ge0//. + rewrite expr0n oppr0 mul0r ler_expR mulNr oppr_le0. + by rewrite mulr_ge0 ?sqr_ge0// oneDsqr_ge0. +Qed. + +End derive_and_integral_u. + +Section Gauss_integration. + +Let integrable0y_gauss : mu.-integrable `[0%R, +oo[ (EFin \o gauss_fun). +Proof. +apply/integrableP; split. + by apply/measurable_EFinP/measurableT_comp => //; exact: measurableT_comp. +apply/abse_integralP => //. + by apply/measurable_EFinP/measurableT_comp => //; exact: measurableT_comp. +rewrite -ge0_fin_numE ?abse_ge0// abse_fin_num. +exact: integral0y_gauss_fin_num. +Qed. + +Lemma gauss_integration : (\int[mu]_x (gauss_fun x))%R = Num.sqrt pi. +Proof. +rewrite /Rintegral ge0_symfun_integralT; last 3 first. +- by move=> x; rewrite gauss_fun_ge0. +- exact: continuous_gauss_fun. +- by move=> x; rewrite /gauss_fun fctE sqrrN. +rewrite -set_itvcy fineM//=; last exact: integral0y_gauss_fin_num. +apply: (@mulIf R (2^-1)) => //. +rewrite mulrAC mulfV// mul1r -[LHS]ger0_norm -?sqrtr_sqr; last first. + exact: gauss_integral_proof.integral0y_gauss_ge0. +rewrite -(@ger0_norm _ 2)// -(@sqrtr_sqr _ 2)//-sqrtrV// -[RHS]sqrtrM ?pi_ge0//. +apply/eqP; rewrite eqr_sqrt ?sqr_ge0 ?divr_ge0 ?pi_ge0//; apply/eqP. +rewrite [in RHS]expr2 invfM// mulrA. +apply: (@mulIf _ (- 2)%R) => //; rewrite [RHS]mulrN divfK// mulrC -[RHS]add0r. +apply: EFin_inj; rewrite EFinB. +have cdint0yu x : {for x, continuous +(fun x1 : R => (- 2 * gauss_integral_proof.integral0y_gauss * gauss_fun x1)%R)}. + apply: continuousM; first exact: cvg_cst. + by move=> ?; exact: continuous_gauss_fun. +rewrite -integral0y_u0 -[X in _ = 0%:E - X]fineK; last by rewrite integral0y_u0. +rewrite -(le0_continuous_FTC2y _ _ cvgy_int0yu0 _ _ derive1_int0yuE); last 4 first. +- move=> x x0; rewrite -mulN1r -!mulrA mulN1r lerNl oppr0. + rewrite pmulr_rge0// mulr_ge0 ?gauss_fun_ge0//. + exact: gauss_integral_proof.integral0y_gauss_ge0. +- apply/continuous_within_itvcyP; split; first by move=> x _; exact: cdint0yu. + apply: cvg_at_right_filter; exact: cdint0yu. +- exact: rc_int0yu0. +- by move=> x x0; apply: derivable_int0yu; rewrite in_itv/= andbT. +under [RHS]eq_integral do rewrite !EFinM EFinN !mulNe. +rewrite integral_ge0N; last first. +- move=> x _; rewrite lee_fin mulr_ge0 ?gauss_fun_ge0// mulr_ge0//. + exact: gauss_integral_proof.integral0y_gauss_ge0. +rewrite ge0_integralZl//; last 3 first. +- apply: measurable_funTS; apply/measurable_EFinP. + exact: measurable_gauss_fun. +- by move=> x _; apply: gauss_fun_ge0. +- apply: mulr_ge0 => //. + exact: gauss_integral_proof.integral0y_gauss_ge0. +rewrite expr2 mulrA [LHS]EFinM EFinM EFinN !mulNe; congr (- (_ * _)). +by rewrite fineK// ?integral0y_gauss_fin_num. +Qed. + +End Gauss_integration. + +End gauss_integral_alternative. diff --git a/theories/topology_theory/bool_topology.v b/theories/topology_theory/bool_topology.v index df8f74f0d..bdd696a64 100644 --- a/theories/topology_theory/bool_topology.v +++ b/theories/topology_theory/bool_topology.v @@ -7,8 +7,7 @@ From mathcomp Require Import discrete_topology. (**md**************************************************************************) (* # Topology for boolean numbers *) -(* pseudoMetric_bool == an alias for bool equipped with the *) -(* discrete pseudometric *) +(* This file equips bool with the discrete pseudometric. *) (******************************************************************************) Import Order.TTheory GRing.Theory Num.Theory. diff --git a/theories/topology_theory/matrix_topology.v b/theories/topology_theory/matrix_topology.v index 7c7de95ff..22a51d9d6 100644 --- a/theories/topology_theory/matrix_topology.v +++ b/theories/topology_theory/matrix_topology.v @@ -53,13 +53,6 @@ HB.instance Definition _ := Nbhs_isNbhsTopological.Build 'M[T]_(m, n) End matrix_Topology. -Section matrix_PointedTopology. -Variables (m n : nat) (T : pointedType). -Implicit Types M : 'M[T]_(m, n). -HB.instance Definition _ := Pointed.on 'M[T]_(m, n). - -End matrix_PointedTopology. - Section matrix_Uniform. Local Open Scope relation_scope. Variables (m n : nat) (T : uniformType). diff --git a/theories/topology_theory/num_topology.v b/theories/topology_theory/num_topology.v index 8521246fd..7a213364c 100644 --- a/theories/topology_theory/num_topology.v +++ b/theories/topology_theory/num_topology.v @@ -26,9 +26,62 @@ Local Open Scope ring_scope. HB.instance Definition _ (R : numDomainType) := hasNbhs.Build R^o (nbhs_ball_ (ball_ (fun x => `|x|))). +Module TopologicalNumDomainType. +Section TopologicalNumDomainType. +Variable (R : numDomainType). + +Lemma nbhs_filter (p : R^o) : ProperFilter (nbhs p). +Proof. +split. + move=> [] e e0 /subsetP/(_ p). + by rewrite !in_setE/= subrr normr0. +split=> [|P Q|P Q]. +- by exists 1; [exact: ltr01|exact: subsetT]. +- move=> [] /= e e0 /subsetP eP [] /= f f0 /subsetP fQ. + exists (Order.min e f) => /=. + by rewrite [Num.min e f]/(Order.min e f); case: ifP. + apply/subsetP => x. + rewrite in_setE in_setI/= => pef. + apply/andP; split. + apply/eP/mem_set/(lt_le_trans pef). + by case: (@real_ltP _ e f) => //; exact: gtr0_real. + apply/fQ/mem_set/(lt_le_trans pef). + by case: (@real_ltP _ f e) => //; exact: gtr0_real. +- move=> PQ [] /= e e0 eP. + by exists e => //; exact: (subset_trans eP). +Qed. + +Lemma nbhs_singleton (p : R^o) (A : set R) : nbhs p A -> A p. +Proof. +move=> [] /= e e0 /subsetP /(_ p). +by rewrite !in_setE/= subrr normr0 e0 => /(_ erefl). +Qed. + +Lemma nbhs_nbhs (p : R^o) (A : set R) : nbhs p A -> nbhs p (nbhs^~ A). +Proof. +move=> [] /= e e0 /subsetP eA; exists e => //. +apply/subsetP => x /[!inE]/= xe. +exists (e - `|p - x|); first by rewrite /= subr_gt0. +apply/subsetP => y; rewrite inE/= ltrBrDl => ye. +apply/eA/mem_set => /=. +by rewrite -(subrK x p) -addrA (le_lt_trans (ler_normD _ _)). +Qed. + +End TopologicalNumDomainType. + +End TopologicalNumDomainType. + +HB.instance Definition _ (R : numDomainType) := Nbhs_isNbhsTopological.Build R^o + (@TopologicalNumDomainType.nbhs_filter R) + (@TopologicalNumDomainType.nbhs_singleton R) + (@TopologicalNumDomainType.nbhs_nbhs R). + +HB.instance Definition _ (R : numFieldType) := Nbhs_isPseudoMetric.Build R R^o + nbhs_ball_normE ball_norm_center ball_norm_symmetric ball_norm_triangle erefl. + HB.instance Definition _ (R : numFieldType) := - Nbhs_isPseudoMetric.Build R R^o - nbhs_ball_normE ball_norm_center ball_norm_symmetric ball_norm_triangle erefl. + Uniform_isPseudoMetric.Build R R^o + ball_norm_center ball_norm_symmetric ball_norm_triangle erefl. Lemma real_order_nbhsE (R : realFieldType) (x : R^o) : nbhs x = filter_from (fun i => itv_open_ends i /\ x \in i) (fun i => [set` i]). @@ -109,12 +162,12 @@ by apply: contra_not_neq AsupA => <-. Qed. Lemma right_bounded_interior (R : realType) (X : set R) : - has_ubound X -> X^° `<=` [set r | r < sup X]. + has_ubound X -> X° `<=` [set r | r < sup X]. Proof. move=> uX r Xr; rewrite /mkset ltNge; apply/negP. rewrite le_eqVlt => /orP[/eqP supXr|]; last first. by apply/negP; rewrite -leNgt sup_ubound//; exact: interior_subset. -suff : ~ X^° (sup X) by rewrite supXr. +suff : ~ X° (sup X) by rewrite supXr. case/nbhs_ballP => _/posnumP[e] supXeX. have [f XsupXf] : exists f : {posnum R}, X (sup X + f%:num). exists (e%:num / 2)%:pos; apply supXeX; rewrite /ball /= opprD addNKr normrN. @@ -124,12 +177,12 @@ by apply/negP; rewrite -ltNge; rewrite ltrDl. Qed. Lemma left_bounded_interior (R : realType) (X : set R) : - has_lbound X -> X^° `<=` [set r | inf X < r]. + has_lbound X -> X° `<=` [set r | inf X < r]. Proof. move=> lX r Xr; rewrite /mkset ltNge; apply/negP. rewrite le_eqVlt => /orP[/eqP rinfX|]; last first. by apply/negP; rewrite -leNgt inf_lbound//; exact: interior_subset. -suff : ~ X^° (inf X) by rewrite -rinfX. +suff : ~ X° (inf X) by rewrite -rinfX. case/nbhs_ballP => _/posnumP[e] supXeX. have [f XsupXf] : exists f : {posnum R}, X (inf X - f%:num). exists (e%:num / 2)%:pos; apply supXeX; rewrite /ball /= opprB addrC subrK. diff --git a/theories/topology_theory/product_topology.v b/theories/topology_theory/product_topology.v index b17982c65..8f5ee2b03 100644 --- a/theories/topology_theory/product_topology.v +++ b/theories/topology_theory/product_topology.v @@ -227,8 +227,6 @@ exists (N2, N1`*`G); first by split => //; exists (N1, G). case=> a [b i] /= [N2a [N1b]] Gi. by apply: (ngPr (b, a, i)); split => //; exact: N1N2N. Unshelve. all: by end_near. Qed. -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `compact_setX`")] -Notation compact_setM := compact_setX (only parsing). Lemma swap_continuous {X Y : topologicalType} : continuous (@swap X Y). Proof. diff --git a/theories/topology_theory/pseudometric_structure.v b/theories/topology_theory/pseudometric_structure.v index acbe4b4cc..a00fa2c99 100644 --- a/theories/topology_theory/pseudometric_structure.v +++ b/theories/topology_theory/pseudometric_structure.v @@ -9,7 +9,7 @@ From mathcomp Require Import uniform_structure. (* # PseudoMetric Spaces *) (* This file provides pseudometric spaces, complete pseudometric spaces, *) (* and the corresponding theory. Note that a classic metric space is simply *) -(* pseudometric + hausdorff. However we will make extensive use of the of the *) +(* pseudometric + hausdorff. However we will make extensive use of the *) (* non-hausdorff case, such as in our proof of Urysohn's lemma. *) (* *) (* ## Mathematical structures *) @@ -238,16 +238,6 @@ Lemma fcvg_ballP {F} {FF : Filter F} (y : M) : F --> y <-> forall eps : R, 0 < eps -> \forall y' \near F, ball y eps y'. Proof. by rewrite -filter_fromP !nbhs_simpl /=. Qed. -Lemma __deprecated__cvg_ballPpos {F} {FF : Filter F} (y : M) : - F --> y <-> forall eps : {posnum R}, \forall y' \near F, ball y eps%:num y'. -Proof. -split => [/fcvg_ballP + eps|pos]; first exact. -by apply/fcvg_ballP=> _/posnumP[eps] //. -Qed. -#[deprecated(since="mathcomp-analysis 0.6.0", - note="use a combination of `cvg_ballP` and `posnumP`")] -Notation cvg_ballPpos := __deprecated__cvg_ballPpos (only parsing). - Lemma fcvg_ball {F} {FF : Filter F} (y : M) : F --> y -> forall eps : R, 0 < eps -> \forall y' \near F, ball y eps y'. Proof. by move/fcvg_ballP. Qed. @@ -293,9 +283,6 @@ Qed. Arguments nbhsx_ballx {R M} x eps. Arguments near_ball {R M} y eps. -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed `cvg_ball`")] -Notation app_cvg_locally := cvg_ball (only parsing). - Section pseudoMetricType_numFieldType. Context {R : numFieldType} {M : pseudoMetricType R}. diff --git a/theories/topology_theory/separation_axioms.v b/theories/topology_theory/separation_axioms.v index 24893b303..452143cdf 100644 --- a/theories/topology_theory/separation_axioms.v +++ b/theories/topology_theory/separation_axioms.v @@ -15,7 +15,7 @@ From mathcomp Require Import connected supremum_topology sigT_topology. (* # Separation Axioms *) (* *) (* This file introduces the separation axioms, a series of topological *) -(* properties about separating points and sets. They are somtimes denoted by *) +(* properties about separating points and sets. They are sometimes denoted by *) (* the names T0 through T6. Although we use their full names (hausdorff, *) (* accessible, uniform, etc). This file also provides related topological *) (* properties like zero dimensional and perfect, and discrete. *) @@ -51,7 +51,6 @@ From mathcomp Require Import connected supremum_topology sigT_topology. (* includes `iter n split_ent E`. *) (* Critically, `gauge E` forms a uniform space *) (* with a countable uniformity. *) -(* perfect_set A := closed A /\ limit_point A = A *) (* ``` *) (******************************************************************************) @@ -396,12 +395,6 @@ move=> f_prop fl; apply: get_unique => // l' fl'; exact: cvgi_unique _ fl' fl. Qed. End hausdorff_ptopologicalType. - -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvg_lim`")] -Notation cvg_map_lim := cvg_lim (only parsing). -#[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgi_lim`")] -Notation cvgi_map_lim := cvgi_lim (only parsing). - #[global] Hint Resolve close_refl : core. Arguments close_cvg {T} F1 F2 {FF2} _. diff --git a/theories/topology_theory/topology.v b/theories/topology_theory/topology.v index a8e29039d..1211f26dd 100644 --- a/theories/topology_theory/topology.v +++ b/theories/topology_theory/topology.v @@ -1,4 +1,4 @@ -(* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +(* mathcomp analysis (c) 2025 Inria and AIST. License: CeCILL-C. *) From mathcomp Require Export bool_topology. From mathcomp Require Export num_topology. From mathcomp Require Export quotient_topology. diff --git a/theories/topology_theory/topology_structure.v b/theories/topology_theory/topology_structure.v index 1043a10aa..88d9b539e 100644 --- a/theories/topology_theory/topology_structure.v +++ b/theories/topology_theory/topology_structure.v @@ -77,9 +77,9 @@ From mathcomp Require Export filter. (* *) (******************************************************************************) -Reserved Notation "A °" (at level 1, format "A °"). -Reserved Notation "[ 'locally' P ]" (at level 0, format "[ 'locally' P ]"). -Reserved Notation "x ^'" (at level 2, format "x ^'"). +Reserved Notation "A °" (format "A °"). +Reserved Notation "[ 'locally' P ]" (format "[ 'locally' P ]"). +Reserved Notation "x ^'" (format "x ^'"). Set Implicit Arguments. Unset Strict Implicit. diff --git a/theories/tvs.v b/theories/tvs.v index eb38ad196..fe4359304 100644 --- a/theories/tvs.v +++ b/theories/tvs.v @@ -12,26 +12,43 @@ From mathcomp Require Import topology function_spaces. (* *) (* This file introduces locally convex topological vector spaces. *) (* ``` *) -(* NbhsNmodule == HB class, join of Nbhs and Nmodule *) -(* NbhsZmodule == HB class, join of Nbhs and Zmodule *) -(* NbhsLmodule K == HB class, join of Nbhs and Lmodule over K *) -(* K is a numDomainType. *) -(* TopologicalNmodule == HB class, joint of Topological and Nmodule *) -(* TopologicalZmodule == HB class, joint of Topological and Zmodule *) -(* topologicalLmodType K == topological space and Lmodule over K *) -(* K is a numDomainType. *) -(* The HB class is TopologicalLmodule. *) -(* UniformZmodule == HB class, joint of Uniform and Zmodule *) -(* UniformLmodule K == HB class, joint of Uniform and Lmodule over K *) -(* K is a numDomainType. *) -(* convex A == A : set M is a convex set of elements of M *) -(* M is an Lmodule over R : numDomainType. *) -(* tvsType R == interface type for a locally convex topological *) -(* vector space on a numDomain R *) -(* A tvs is constructed over a uniform space. *) -(* The HB class is Tvs. *) -(* TopologicalLmod_isTvs == factory allowing the construction of a tvs from *) -(* an Lmodule which is also a topological space. *) +(* NbhsNmodule == HB class, join of Nbhs and Nmodule *) +(* NbhsZmodule == HB class, join of Nbhs and Zmodule *) +(* NbhsLmodule K == HB class, join of Nbhs and Lmodule over K *) +(* K is a numDomainType. *) +(* PreTopologicalNmodule == HB class, join of Topological and Nmodule *) +(* TopologicalNmodule == HB class, PreTopologicalNmodule with a *) +(* continuous addition *) +(* PreTopologicalZmodule == HB class, join of Topological and Zmodule *) +(* topologicalZmodType == topological abelian group *) +(* TopologicalZmodule == HB class, join of TopologicalNmodule and *) +(* Zmodule with a continuous opposite operator *) +(* preTopologicalLmodType K == topological space and Lmodule over K *) +(* K is a numDomainType *) +(* The HB class is PreTopologicalLmodule. *) +(* topologicalLmodType K == topologicalNmodule and Lmodule over K with a *) +(* continuous scaling operation *) +(* The HB class is TopologicalLmodule. *) +(* PreUniformNmodule == HB class, join of Uniform and Nmodule *) +(* UniformNmodule == HB class, join of Uniform and Nmodule with a *) +(* uniformly continuous addition *) +(* PreUniformZmodule == HB class, join of Uniform and Zmodule *) +(* UniformZmodule == HB class, join of UniformNmodule and Zmodule *) +(* with uniformly continuous opposite operator *) +(* PreUniformLmodule K == HB class, join of Uniform and Lmodule over K *) +(* K is a numDomainType. *) +(* UniformLmodule K == HB class, join of UniformNmodule and Lmodule *) +(* with a uniformly continuous scaling operation *) +(* K is a numFieldType. *) +(* convex A == A : set M is a convex set of elements of M *) +(* M is an Lmodule over R : numDomainType. *) +(* tvsType R == interface type for a locally convex *) +(* tvs on a numDomain R *) +(* A tvs is constructed over a uniform space. *) +(* The HB class is Tvs. *) +(* PreTopologicalLmod_isTvs == factory allowing the construction of a tvs *) +(* from an Lmodule which is also a topological *) +(* space *) (* ``` *) (* HB instances: *) (* - The type R^o (R : numFieldType) is endowed with the structure of Tvs. *) @@ -62,37 +79,261 @@ HB.structure Definition NbhsZmodule := {M of Nbhs M & GRing.Zmodule M}. HB.structure Definition NbhsLmodule (K : numDomainType) := {M of Nbhs M & GRing.Lmodule K M}. -HB.structure Definition TopologicalNmodule := +HB.structure Definition PreTopologicalNmodule := {M of Topological M & GRing.Nmodule M}. -HB.structure Definition TopologicalZmodule := + +HB.mixin Record PreTopologicalNmodule_isTopologicalNmodule M + of PreTopologicalNmodule M := { + add_continuous : continuous (fun x : M * M => x.1 + x.2) ; +}. + +HB.structure Definition TopologicalNmodule := + {M of PreTopologicalNmodule M & PreTopologicalNmodule_isTopologicalNmodule M}. + +HB.structure Definition PreTopologicalZmodule := {M of Topological M & GRing.Zmodule M}. +HB.mixin Record TopologicalNmodule_isTopologicalZmodule M + of Topological M & GRing.Zmodule M := { + opp_continuous : continuous (-%R : M -> M) ; +}. + +#[short(type="topologicalZmodType")] +HB.structure Definition TopologicalZmodule := + {M of TopologicalNmodule M & GRing.Zmodule M + & TopologicalNmodule_isTopologicalZmodule M}. + +HB.factory Record PreTopologicalNmodule_isTopologicalZmodule M + of Topological M & GRing.Zmodule M := { + sub_continuous : continuous (fun x : M * M => x.1 - x.2) ; +}. + +HB.builders Context M of PreTopologicalNmodule_isTopologicalZmodule M. + +Lemma opp_continuous : continuous (-%R : M -> M). +Proof. +move=> x; rewrite /continuous_at. +rewrite -(@eq_cvg _ _ _ (fun x => 0 - x)); last by move=> y; exact: add0r. +rewrite -[- x]add0r. +apply: (@continuous_comp _ _ _ (fun x => (0, x)) (fun x : M * M => x.1 - x.2)). + by apply: cvg_pair => /=; [exact: cvg_cst|exact: cvg_id]. +exact: sub_continuous. +Qed. + +Lemma add_continuous : continuous (fun x : M * M => x.1 + x.2). +Proof. +move=> x; rewrite /continuous_at. +rewrite -(@eq_cvg _ _ _ (fun x => x.1 - (- x.2))); last first. + by move=> y; rewrite opprK. +rewrite -[in x.1 + _](opprK x.2). +apply: (@continuous_comp _ _ _ (fun x => (x.1, - x.2)) (fun x => x.1 - x.2)). + apply: cvg_pair; first exact: cvg_fst. + by apply: continuous_comp; [exact: cvg_snd|exact: opp_continuous]. +exact: sub_continuous. +Qed. + +HB.instance Definition _ := + PreTopologicalNmodule_isTopologicalNmodule.Build M add_continuous. + +HB.instance Definition _ := + TopologicalNmodule_isTopologicalZmodule.Build M opp_continuous. + +HB.end. + +Section TopologicalZmoduleTheory. +Variables (M : topologicalZmodType). + +Lemma sub_continuous : continuous (fun x : M * M => x.1 - x.2). +Proof. +move=> x; apply: (@continuous_comp _ _ _ (fun x => (x.1, - x.2)) + (fun x : M * M => x.1 + x.2)); last exact: add_continuous. +apply: cvg_pair; first exact: cvg_fst. +by apply: continuous_comp; [exact: cvg_snd|exact: opp_continuous]. +Qed. + +End TopologicalZmoduleTheory. + +#[short(type="preTopologicalLmodType")] +HB.structure Definition PreTopologicalLmodule (K : numDomainType) := + {M of Topological M & GRing.Lmodule K M}. + +HB.mixin Record TopologicalZmodule_isTopologicalLmodule (R : numDomainType) M + of Topological M & GRing.Lmodule R M := { + scale_continuous : continuous (fun z : R^o * M => z.1 *: z.2) ; +}. + #[short(type="topologicalLmodType")] HB.structure Definition TopologicalLmodule (K : numDomainType) := - {M of Topological M & GRing.Lmodule K M}. + {M of TopologicalZmodule M & GRing.Lmodule K M + & TopologicalZmodule_isTopologicalLmodule K M}. + +HB.factory Record TopologicalNmodule_isTopologicalLmodule (R : numDomainType) M + of Topological M & GRing.Lmodule R M := { + scale_continuous : continuous (fun z : R^o * M => z.1 *: z.2) ; +}. + +HB.builders Context R M of TopologicalNmodule_isTopologicalLmodule R M. + +Lemma opp_continuous : continuous (-%R : M -> M). +Proof. +move=> x; rewrite /continuous_at. +rewrite -(@eq_cvg _ _ _ (fun x => -1 *: x)); last by move=> y; rewrite scaleN1r. +rewrite -[- x]scaleN1r. +apply: (@continuous_comp M (R^o * M)%type M (fun x => (-1, x)) + (fun x => x.1 *: x.2)); last exact: scale_continuous. +by apply: (@cvg_pair _ _ _ _ (nbhs (-1 : R^o))); [exact: cvg_cst|exact: cvg_id]. +Qed. + +#[warning="-HB.no-new-instance"] +HB.instance Definition _ := + TopologicalNmodule_isTopologicalZmodule.Build M opp_continuous. +HB.instance Definition _ := + TopologicalZmodule_isTopologicalLmodule.Build R M scale_continuous. + +HB.end. + +HB.structure Definition PreUniformNmodule := {M of Uniform M & GRing.Nmodule M}. + +HB.mixin Record PreUniformNmodule_isUniformNmodule M of PreUniformNmodule M := { + add_unif_continuous : unif_continuous (fun x : M * M => x.1 + x.2) +}. + +HB.structure Definition UniformNmodule := + {M of PreUniformNmodule M & PreUniformNmodule_isUniformNmodule M}. + +HB.structure Definition PreUniformZmodule := {M of Uniform M & GRing.Zmodule M}. + +HB.mixin Record UniformNmodule_isUniformZmodule M + of Uniform M & GRing.Zmodule M := { + opp_unif_continuous : unif_continuous (-%R : M -> M) +}. + +HB.structure Definition UniformZmodule := + {M of UniformNmodule M & GRing.Zmodule M & UniformNmodule_isUniformZmodule M}. + +HB.factory Record PreUniformNmodule_isUniformZmodule M + of Uniform M & GRing.Zmodule M := { + sub_unif_continuous : unif_continuous (fun x : M * M => x.1 - x.2) +}. + +HB.builders Context M of PreUniformNmodule_isUniformZmodule M. + +Lemma opp_unif_continuous : unif_continuous (-%R : M -> M). +Proof. +have unif : unif_continuous (fun x => (0, x) : M * M). + move=> /= U [[]] /= U1 U2 [] U1e U2e /subsetP U12. + apply: filterS U2e => x xU2/=. + have /U12 : ((0, 0), x) \in U1 `*` U2. + by rewrite in_setX/= (mem_set xU2) andbT inE; exact: entourage_refl. + by rewrite inE/= => -[[[a1 a2] [b1 b2]]]/= /[swap]-[] -> -> <-. +move=> /= U /sub_unif_continuous /unif /=. +rewrite -comp_preimage/= /comp/= /nbhs/=. +by congr entourage => /=; rewrite eqEsubset; split=> x /=; rewrite !sub0r. +Qed. + +Lemma add_unif_continuous : unif_continuous (fun x : M * M => x.1 + x.2). +Proof. +have unif: unif_continuous (fun x => (x.1, -x.2) : M * M). + move=> /= U [[]]/= U1 U2 [] U1e /opp_unif_continuous. + rewrite /nbhs/= => U2e /subsetP U12. + apply: (@filterS _ _ entourage_filter + ((fun xy => (xy.1.1, xy.2.1, (-xy.1.2, -xy.2.2))) @^-1` (U1 `*` U2))). + move=> /= [] [] a1 a2 [] b1 b2/= [] ab1 ab2. + have /U12 : (a1, b1, (-a2, -b2)) \in U1 `*` U2 by rewrite !inE. + by rewrite inE/= => [] [] [] [] c1 c2 [] d1 d2/= cd [] <- <- <- <-. + exists (U1, ((fun xy : M * M => (- xy.1, - xy.2)) @^-1` U2)); first by split. + by move=> /= [] [] a1 a2 [] b1 b2/= [] aU bU; exists (a1, b1, (a2, b2)). +move=> /= U /sub_unif_continuous/unif; rewrite /nbhs/=. +rewrite -comp_preimage/=/comp/=. +by congr entourage; rewrite eqEsubset; split=> x /=; rewrite !opprK. +Qed. + +HB.instance Definition _ := + PreUniformNmodule_isUniformNmodule.Build M add_unif_continuous. +HB.instance Definition _ := + UniformNmodule_isUniformZmodule.Build M opp_unif_continuous. + +HB.end. -HB.structure Definition UniformZmodule := {M of Uniform M & GRing.Zmodule M}. -HB.structure Definition UniformLmodule (K : numDomainType) := +Section UniformZmoduleTheory. +Variables (M : UniformZmodule.type). + +Lemma sub_unif_continuous : unif_continuous (fun x : M * M => x.1 - x.2). +Proof. +suff unif: unif_continuous (fun x => (x.1, - x.2) : M * M). + by move=> /= U /add_unif_continuous/unif; rewrite /nbhs/= -comp_preimage. +move=> /= U [[]]/= U1 U2 [] U1e /opp_unif_continuous. +rewrite /nbhs/= => U2e /subsetP U12. +apply: (@filterS _ _ entourage_filter + ((fun xy => (xy.1.1, xy.2.1, (- xy.1.2, - xy.2.2))) @^-1` (U1 `*` U2))). + move=> /= [] [] a1 a2 [] b1 b2/= [] ab1 ab2. + have /U12 : (a1, b1, (-a2, -b2)) \in U1 `*` U2 by rewrite !inE. + by rewrite inE/= => [] [] [] [] c1 c2 [] d1 d2/= cd [] <- <- <- <-. +exists (U1, ((fun xy : M * M => (- xy.1, - xy.2)) @^-1` U2)); first by split. +by move=> /= [] [] a1 a2 [] b1 b2/= [] aU bU; exists (a1, b1, (a2, b2)). +Qed. + +End UniformZmoduleTheory. + +HB.structure Definition PreUniformLmodule (K : numDomainType) := {M of Uniform M & GRing.Lmodule K M}. +HB.mixin Record PreUniformLmodule_isUniformLmodule (R : numFieldType) M + of PreUniformLmodule R M := { + scale_unif_continuous : unif_continuous (fun z : R^o * M => z.1 *: z.2) ; +}. + +HB.structure Definition UniformLmodule (R : numFieldType) := + {M of UniformZmodule M & GRing.Lmodule R M + & PreUniformLmodule_isUniformLmodule R M}. + +HB.factory Record UniformNmodule_isUniformLmodule (R : numFieldType) M + of PreUniformLmodule R M := { + scale_unif_continuous : unif_continuous (fun z : R^o * M => z.1 *: z.2) ; +}. + +HB.builders Context R M of UniformNmodule_isUniformLmodule R M. + +Lemma opp_unif_continuous : unif_continuous (-%R : M -> M). +Proof. +have unif: unif_continuous (fun x => (-1, x) : R^o * M). + move=> /= U [[]] /= U1 U2 [] U1e U2e /subsetP U12. + rewrite /nbhs/=. + apply: filterS U2e => x xU2/=. + have /U12 : ((-1, -1), x) \in U1 `*` U2. + rewrite in_setX/= (mem_set xU2) andbT. + by apply/mem_set; exact: entourage_refl. + by rewrite inE/= => [[[]]] [] a1 a2 [] b1 b2/= abU [] {2}<- <- <-/=. +move=> /= U /scale_unif_continuous/unif/=. +rewrite /nbhs/=. +rewrite -comp_preimage/=/comp/=. +by congr entourage; rewrite eqEsubset; split=> x /=; rewrite !scaleN1r. +Qed. + +#[warning="-HB.no-new-instance"] +HB.instance Definition _ := + UniformNmodule_isUniformZmodule.Build M opp_unif_continuous. +HB.instance Definition _ := + PreUniformLmodule_isUniformLmodule.Build R M scale_unif_continuous. + +HB.end. + Definition convex (R : numDomainType) (M : lmodType R) (A : set M) := forall x y (lambda : R), x \in A -> y \in A -> 0 < lambda -> lambda < 1 -> lambda *: x + (1 - lambda) *: y \in A. HB.mixin Record Uniform_isTvs (R : numDomainType) E of Uniform E & GRing.Lmodule R E := { - add_continuous : continuous (fun x : E * E => x.1 + x.2) ; - scale_continuous : continuous (fun z : R^o * E => z.1 *: z.2) ; locally_convex : exists2 B : set (set E), (forall b, b \in B -> convex b) & basis B }. #[short(type="tvsType")] HB.structure Definition Tvs (R : numDomainType) := - {E of Uniform_isTvs R E & Uniform E & GRing.Lmodule R E}. + {E of Uniform_isTvs R E & Uniform E & TopologicalLmodule R E}. Section properties_of_topologicalLmodule. -Context (R : numDomainType) (E : topologicalLmodType R) (U : set E). +Context (R : numDomainType) (E : preTopologicalLmodType R) (U : set E). Lemma nbhsN_subproof (f : continuous (fun z : R^o * E => z.1 *: z.2)) (x : E) : nbhs x U -> nbhs (-x) (-%R @` U). @@ -127,7 +368,7 @@ Unshelve. all: by end_near. Qed. End properties_of_topologicalLmodule. -HB.factory Record TopologicalLmod_isTvs (R : numDomainType) E +HB.factory Record PreTopologicalLmod_isTvs (R : numDomainType) E of Topological E & GRing.Lmodule R E := { add_continuous : continuous (fun x : E * E => x.1 + x.2) ; scale_continuous : continuous (fun z : R^o * E => z.1 *: z.2) ; @@ -135,7 +376,7 @@ HB.factory Record TopologicalLmod_isTvs (R : numDomainType) E (forall b, b \in B -> convex b) & basis B }. -HB.builders Context R E of TopologicalLmod_isTvs R E. +HB.builders Context R E of PreTopologicalLmod_isTvs R E. Definition entourage : set_system (E * E) := fun P => exists (U : set E), nbhs (0 : E) U /\ @@ -348,8 +589,11 @@ move=> x B; rewrite -nbhs_ballE/= => -[r] r0 Bxr /=. by exists (ball x r) => //; split; [exists x, r|exact: ballxx]. Qed. -HB.instance Definition _ := Uniform_isTvs.Build R R^o - standard_add_continuous standard_scale_continuous standard_locally_convex. +HB.instance Definition _ := + PreTopologicalNmodule_isTopologicalNmodule.Build R^o standard_add_continuous. +HB.instance Definition _ := + TopologicalNmodule_isTopologicalLmodule.Build R R^o standard_scale_continuous. +HB.instance Definition _ := Uniform_isTvs.Build R R^o standard_locally_convex. End standard_topology. @@ -359,8 +603,8 @@ Context (K : numFieldType) (E F : tvsType K). Local Lemma prod_add_continuous : continuous (fun x : (E * F) * (E * F) => x.1 + x.2). Proof. move => [/= xy1 xy2] /= U /= [] [A B] /= [nA nB] nU. -have [/= A0 [A01 A02] nA1] := @add_continuous K E (xy1.1, xy2.1) _ nA. -have [/= B0 [B01 B02] nB1] := @add_continuous K F (xy1.2, xy2.2) _ nB. +have [/= A0 [A01 A02] nA1] := @add_continuous E (xy1.1, xy2.1) _ nA. +have [/= B0 [B01 B02] nB1] := @add_continuous F (xy1.2, xy2.2) _ nB. exists ([set xy | A0.1 xy.1 /\ B0.1 xy.2], [set xy | A0.2 xy.1 /\ B0.2 xy.2]). by split; [exists (A0.1, B0.1)|exists (A0.2, B0.2)]. move => [[x1 y1][x2 y2]] /= [] [] a1 b1 [] a2 b2. @@ -401,8 +645,11 @@ move => [x1 y1] [x2 y2] l /[!inE] /= -[xe1 yf1] [xe2 yf2] l0 l1. by split; rewrite -inE; [apply: Bcb; rewrite ?inE|apply: Bcf; rewrite ?inE]. Qed. +HB.instance Definition _ := PreTopologicalNmodule_isTopologicalNmodule.Build + (E * F)%type prod_add_continuous. +HB.instance Definition _ := TopologicalNmodule_isTopologicalLmodule.Build + K (E * F)%type prod_scale_continuous. HB.instance Definition _ := - Uniform_isTvs.Build K (E * F)%type - prod_add_continuous prod_scale_continuous prod_locally_convex. + Uniform_isTvs.Build K (E * F)%type prod_locally_convex. End prod_Tvs.