diff --git a/.github/workflows/docker-action.yml b/.github/workflows/docker-action.yml deleted file mode 100644 index 2275c619e..000000000 --- a/.github/workflows/docker-action.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Docker CI - -on: - push: - branches: - - master - pull_request: - branches: - - '**' - -jobs: - build: - # the OS must be GNU/Linux to be able to use the docker-coq-action - runs-on: ubuntu-latest - strategy: - matrix: - image: - - 'mathcomp/mathcomp:1.17.0-coq-8.15' - - 'mathcomp/mathcomp:1.17.0-coq-8.16' - - 'mathcomp/mathcomp:1.17.0-coq-8.17' - - 'mathcomp/mathcomp:1.18.0-coq-8.18' - - 'mathcomp/mathcomp:1.19.0-coq-8.19' - fail-fast: false - steps: - - uses: actions/checkout@v2 - - uses: coq-community/docker-coq-action@v1 - with: - opam_file: 'coq-mathcomp-analysis.opam' - custom_image: ${{ matrix.image }} - install: | - startGroup "Install dependencies" - opam pin add -n -y -k path coq-mathcomp-classical $WORKDIR - opam pin add -n -y -k path $PACKAGE $WORKDIR - opam update -y - opam install -y -j 2 coq-mathcomp-classical --deps-only - endGroup - -# See also: -# https://github.com/coq-community/docker-coq-action#readme -# https://github.com/erikmd/docker-coq-github-action-demo diff --git a/.github/workflows/nix-action-8.15.yml b/.github/workflows/nix-action-8.15.yml deleted file mode 100644 index 14a5f06fb..000000000 --- a/.github/workflows/nix-action-8.15.yml +++ /dev/null @@ -1,203 +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@v3 - 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@v3 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v12 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepCheck - name: Checking presence of CI target coq - run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ - \ bundle \"8.15\" --argstr job \"coq\" \\\n --dry-run 2>&1 > /dev/null)\n\ - echo $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\" | sed \"\ - s/.*/built/\") >> $GITHUB_OUTPUT\n" - - 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.15" --argstr - job "coq" - mathcomp-analysis: - 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@v3 - 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@v3 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v12 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepCheck - name: Checking presence of CI target mathcomp-analysis - run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ - \ bundle \"8.15\" --argstr job \"mathcomp-analysis\" \\\n --dry-run 2>&1\ - \ > /dev/null)\necho $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"\ - built:\" | sed \"s/.*/built/\") >> $GITHUB_OUTPUT\n" - - 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.15" --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.15" --argstr - job "mathcomp-classical" - - 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.15" --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.15" --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.15" --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.15" --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@v3 - 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@v3 - with: - fetch-depth: 0 - ref: ${{ env.tested_commit }} - - name: Cachix install - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Cachix setup math-comp - uses: cachix/cachix-action@v12 - with: - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - extraPullNames: coq, coq-community - name: math-comp - - id: stepCheck - name: Checking presence of CI target mathcomp-analysis-single - run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ - \ bundle \"8.15\" --argstr job \"mathcomp-analysis-single\" \\\n --dry-run\ - \ 2>&1 > /dev/null)\necho $nb_dry_run\necho status=$(echo $nb_dry_run | grep\ - \ \"built:\" | sed \"s/.*/built/\") >> $GITHUB_OUTPUT\n" - - 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.15" --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.15" --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.15" --argstr - job "mathcomp-finmap" - - 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.15" --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.15" --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.15" --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.15" --argstr - job "mathcomp-analysis-single" -name: Nix CI for bundle 8.15 -'on': - pull_request: - paths: - - .github/workflows/nix-action-8.15.yml - pull_request_target: - paths-ignore: - - .github/workflows/nix-action-8.15.yml - types: - - opened - - synchronize - - reopened - push: - branches: - - master diff --git a/.github/workflows/nix-action-8.16.yml b/.github/workflows/nix-action-8.16.yml index 21a404361..51220bd4c 100644 --- a/.github/workflows/nix-action-8.16.yml +++ b/.github/workflows/nix-action-8.16.yml @@ -46,6 +46,90 @@ jobs: name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.16" --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@v3 + 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@v3 + with: + fetch-depth: 0 + ref: ${{ env.tested_commit }} + - name: Cachix install + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Cachix setup math-comp + uses: cachix/cachix-action@v12 + with: + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: coq, coq-community + name: math-comp + - id: stepCheck + name: Checking presence of CI target mathcomp + run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ + \ bundle \"8.16\" --argstr job \"mathcomp\" \\\n --dry-run 2>&1 > /dev/null)\n\ + echo $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\" | sed \"\ + s/.*/built/\") >> $GITHUB_OUTPUT\n" + - 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.16" --argstr + job "coq" + - if: steps.stepCheck.outputs.status == 'built' + name: 'Building/fetching previous CI target: coq-elpi' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.16" --argstr + job "coq-elpi" + - 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.16" --argstr + job "hierarchy-builder" + - 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.16" --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.16" --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.16" --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.16" --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.16" --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.16" --argstr + job "mathcomp-character" + - 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.16" --argstr + job "mathcomp" mathcomp-analysis: needs: - coq @@ -117,6 +201,7 @@ jobs: mathcomp-analysis-single: needs: - coq + - mathcomp-finmap runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -186,6 +271,62 @@ jobs: name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.16" --argstr job "mathcomp-analysis-single" + mathcomp-finmap: + 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@v3 + 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@v3 + with: + fetch-depth: 0 + ref: ${{ env.tested_commit }} + - name: Cachix install + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Cachix setup math-comp + uses: cachix/cachix-action@v12 + with: + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: coq, coq-community + name: math-comp + - id: stepCheck + name: Checking presence of CI target mathcomp-finmap + run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ + \ bundle \"8.16\" --argstr job \"mathcomp-finmap\" \\\n --dry-run 2>&1 >\ + \ /dev/null)\necho $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\"\ + \ | sed \"s/.*/built/\") >> $GITHUB_OUTPUT\n" + - 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.16" --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.16" --argstr + job "mathcomp-ssreflect" + - 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.16" --argstr + job "mathcomp-finmap" name: Nix CI for bundle 8.16 'on': pull_request: diff --git a/.github/workflows/nix-action-8.17.yml b/.github/workflows/nix-action-8.17.yml index 8bc32c55d..e8fc9f198 100644 --- a/.github/workflows/nix-action-8.17.yml +++ b/.github/workflows/nix-action-8.17.yml @@ -46,6 +46,90 @@ jobs: name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.17" --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@v3 + 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@v3 + with: + fetch-depth: 0 + ref: ${{ env.tested_commit }} + - name: Cachix install + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Cachix setup math-comp + uses: cachix/cachix-action@v12 + with: + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: coq, coq-community + name: math-comp + - id: stepCheck + name: Checking presence of CI target mathcomp + run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ + \ bundle \"8.17\" --argstr job \"mathcomp\" \\\n --dry-run 2>&1 > /dev/null)\n\ + echo $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\" | sed \"\ + s/.*/built/\") >> $GITHUB_OUTPUT\n" + - 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.17" --argstr + job "coq" + - if: steps.stepCheck.outputs.status == 'built' + name: 'Building/fetching previous CI target: coq-elpi' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.17" --argstr + job "coq-elpi" + - 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.17" --argstr + job "hierarchy-builder" + - 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.17" --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.17" --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.17" --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.17" --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.17" --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.17" --argstr + job "mathcomp-character" + - 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.17" --argstr + job "mathcomp" mathcomp-analysis: needs: - coq @@ -117,6 +201,7 @@ jobs: mathcomp-analysis-single: needs: - coq + - mathcomp-finmap runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -186,6 +271,62 @@ jobs: name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.17" --argstr job "mathcomp-analysis-single" + mathcomp-finmap: + 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@v3 + 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@v3 + with: + fetch-depth: 0 + ref: ${{ env.tested_commit }} + - name: Cachix install + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Cachix setup math-comp + uses: cachix/cachix-action@v12 + with: + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: coq, coq-community + name: math-comp + - id: stepCheck + name: Checking presence of CI target mathcomp-finmap + run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ + \ bundle \"8.17\" --argstr job \"mathcomp-finmap\" \\\n --dry-run 2>&1 >\ + \ /dev/null)\necho $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\"\ + \ | sed \"s/.*/built/\") >> $GITHUB_OUTPUT\n" + - 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.17" --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.17" --argstr + job "mathcomp-ssreflect" + - 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.17" --argstr + job "mathcomp-finmap" name: Nix CI for bundle 8.17 'on': pull_request: diff --git a/.github/workflows/nix-action-8.18.yml b/.github/workflows/nix-action-8.18.yml index 93401dd06..c6a1329c0 100644 --- a/.github/workflows/nix-action-8.18.yml +++ b/.github/workflows/nix-action-8.18.yml @@ -46,6 +46,90 @@ jobs: name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.18" --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@v3 + 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@v3 + with: + fetch-depth: 0 + ref: ${{ env.tested_commit }} + - name: Cachix install + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Cachix setup math-comp + uses: cachix/cachix-action@v12 + with: + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: coq, coq-community + name: math-comp + - id: stepCheck + name: Checking presence of CI target mathcomp + run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ + \ bundle \"8.18\" --argstr job \"mathcomp\" \\\n --dry-run 2>&1 > /dev/null)\n\ + echo $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\" | sed \"\ + s/.*/built/\") >> $GITHUB_OUTPUT\n" + - 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.18" --argstr + job "coq" + - if: steps.stepCheck.outputs.status == 'built' + name: 'Building/fetching previous CI target: coq-elpi' + run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.18" --argstr + job "coq-elpi" + - 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.18" --argstr + job "hierarchy-builder" + - 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.18" --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.18" --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.18" --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.18" --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.18" --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.18" --argstr + job "mathcomp-character" + - 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.18" --argstr + job "mathcomp" mathcomp-analysis: needs: - coq @@ -117,6 +201,7 @@ jobs: mathcomp-analysis-single: needs: - coq + - mathcomp-finmap runs-on: ubuntu-latest steps: - name: Determine which commit to initially checkout @@ -186,6 +271,62 @@ jobs: name: Building/fetching current CI target run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "8.18" --argstr job "mathcomp-analysis-single" + mathcomp-finmap: + 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@v3 + 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@v3 + with: + fetch-depth: 0 + ref: ${{ env.tested_commit }} + - name: Cachix install + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Cachix setup math-comp + uses: cachix/cachix-action@v12 + with: + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + extraPullNames: coq, coq-community + name: math-comp + - id: stepCheck + name: Checking presence of CI target mathcomp-finmap + run: "nb_dry_run=$(NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link \\\n --argstr\ + \ bundle \"8.18\" --argstr job \"mathcomp-finmap\" \\\n --dry-run 2>&1 >\ + \ /dev/null)\necho $nb_dry_run\necho status=$(echo $nb_dry_run | grep \"built:\"\ + \ | sed \"s/.*/built/\") >> $GITHUB_OUTPUT\n" + - 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.18" --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.18" --argstr + job "mathcomp-ssreflect" + - 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.18" --argstr + job "mathcomp-finmap" name: Nix CI for bundle 8.18 'on': pull_request: diff --git a/.github/workflows/nix-action-master.yml b/.github/workflows/nix-action-master.yml index cd21cfa2c..6761e5d84 100644 --- a/.github/workflows/nix-action-master.yml +++ b/.github/workflows/nix-action-master.yml @@ -158,6 +158,7 @@ jobs: mathcomp: needs: - coq + - coq-elpi - hierarchy-builder runs-on: ubuntu-latest steps: @@ -204,6 +205,14 @@ jobs: 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: 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' + 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' name: 'Building/fetching previous CI target: mathcomp-ssreflect' run: NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link --argstr bundle "master" diff --git a/.nix/config.nix b/.nix/config.nix index 49d742f0a..c747c2af3 100644 --- a/.nix/config.nix +++ b/.nix/config.nix @@ -31,30 +31,39 @@ ## select an entry to build in the following `bundles` set ## defaults to "default" - default-bundle = "8.18"; + default-bundle = "8.16"; ## write one `bundles.name` attribute set per ## alternative configuration ## When generating GitHub Action CI, one workflow file ## will be created per bundle - bundles."8.15".coqPackages.coq.override.version = "8.15"; bundles."8.16".push-branches = [ "master" "hierarchy-builder" ]; - bundles."8.16".coqPackages.coq.override.version = "8.16"; + bundles."8.16".coqPackages = { + coq.override.version = "8.16"; + mathcomp.override.version = "mathcomp-2.0.0"; + mathcomp-finmap.override.version = "master"; + }; bundles."8.17".push-branches = [ "master" "hierarchy-builder" ]; - bundles."8.17".coqPackages.coq.override.version = "8.17"; + bundles."8.17".coqPackages = { + coq.override.version = "8.17"; + mathcomp.override.version = "mathcomp-2.0.0"; + mathcomp-finmap.override.version = "master"; + }; bundles."8.18".push-branches = [ "master" "hierarchy-builder" ]; - bundles."8.18".coqPackages.coq.override.version = "8.18"; - bundles."8.19".push-branches = [ "master" "hierarchy-builder" ]; - bundles."8.19".coqPackages.coq.override.version = "8.19"; + bundles."8.18".coqPackages = { + coq.override.version = "8.18"; + mathcomp.override.version = "mathcomp-2.0.0"; + mathcomp-finmap.override.version = "master"; + }; bundles."master".push-branches = [ "master" "hierarchy-builder" ]; bundles."master".coqPackages = { coq.override.version = "master"; coq-elpi.override.version = "coq-master"; hierarchy-builder.override.version = "master"; - mathcomp.override.version = "mathcomp-1"; + mathcomp.override.version = "master"; mathcomp-bigenough.override.version = "1.0.1"; - mathcomp-finmap.override.version = "1.5.2"; + mathcomp-finmap.override.version = "master"; }; ## Cachix caches to use in CI @@ -62,17 +71,17 @@ cachix.coq = {}; cachix.math-comp.authToken = "CACHIX_AUTH_TOKEN"; cachix.coq-community = {}; - + ## If you have write access to one of these caches you can ## provide the auth token or signing key through a secret ## variable on GitHub. Then, you should give the variable ## name here. For instance, coq-community projects can use ## the following line instead of the one above: # cachix.coq-community.authToken = "CACHIX_AUTH_TOKEN"; - + ## Or if you have a signing key for a given Cachix cache: # cachix.my-cache.signingKey = "CACHIX_SIGNING_KEY" - + ## Note that here, CACHIX_AUTH_TOKEN and CACHIX_SIGNING_KEY ## are the names of secret variables. They are set in ## GitHub's web interface. diff --git a/.nix/coq-nix-toolbox.nix b/.nix/coq-nix-toolbox.nix index 396053186..b0c3834f0 100644 --- a/.nix/coq-nix-toolbox.nix +++ b/.nix/coq-nix-toolbox.nix @@ -1 +1 @@ -"dc4241093d78f8fcf4854ced9d17c925c9a85fef" +"7e631f043d424ce82f3308824bf64fbfdee04c80" diff --git a/.nix/coq-overlays/mathcomp/default.nix b/.nix/coq-overlays/mathcomp/default.nix new file mode 100644 index 000000000..dbaf5872b --- /dev/null +++ b/.nix/coq-overlays/mathcomp/default.nix @@ -0,0 +1,122 @@ +############################################################################ +# This file mainly provides the `mathcomp` derivation, which is # +# essentially a meta-package containing all core mathcomp libraries # +# (ssreflect fingroup algebra solvable field character). They can be # +# accessed individually through the passthrough attributes of mathcomp # +# bearing the same names (mathcomp.ssreflect, etc). # +############################################################################ +# Compiling a custom version of mathcomp using `mathcomp.override`. # +# This is the replacement for the former `mathcomp_ config` function. # +# See the documentation at doc/languages-frameworks/coq.section.md. # +############################################################################ + +{ lib, ncurses, graphviz, lua, fetchzip, + coq-elpi, hierarchy-builder, + mkCoqDerivation, recurseIntoAttrs, withDoc ? false, single ? false, + coqPackages, coq, version ? null }@args: +with builtins // lib; +let + repo = "math-comp"; + owner = "math-comp"; + withDoc = single && (args.withDoc or false); + defaultVersion = with versions; switch coq.coq-version [ + { case = isGe "8.11"; out = "1.14.0"; } + { case = range "8.11" "8.15"; out = "1.13.0"; } + { case = range "8.10" "8.13"; out = "1.12.0"; } + { case = range "8.7" "8.12"; out = "1.11.0"; } + { case = range "8.7" "8.11"; out = "1.10.0"; } + { case = range "8.7" "8.11"; out = "1.9.0"; } + { case = range "8.7" "8.9"; out = "1.8.0"; } + { case = range "8.6" "8.9"; out = "1.7.0"; } + { case = range "8.5" "8.7"; out = "1.6.4"; } + ] null; + release = { + "1.14.0".sha256 = "07yamlp1c0g5nahkd2gpfhammcca74ga2s6qr7a3wm6y6j5pivk9"; + "1.13.0".sha256 = "0j4cz2y1r1aw79snkcf1pmicgzf8swbaf9ippz0vg99a572zqzri"; + "1.12.0".sha256 = "1ccfny1vwgmdl91kz5xlmhq4wz078xm4z5wpd0jy5rn890dx03wp"; + "1.11.0".sha256 = "06a71d196wd5k4wg7khwqb7j7ifr7garhwkd54s86i0j7d6nhl3c"; + "1.10.0".sha256 = "1b9m6pwxxyivw7rgx82gn5kmgv2mfv3h3y0mmjcjfypi8ydkrlbv"; + "1.9.0".sha256 = "0lid9zaazdi3d38l8042lczb02pw5m9wq0yysiilx891hgq2p81r"; + "1.8.0".sha256 = "07l40is389ih8bi525gpqs3qp4yb2kl11r9c8ynk1ifpjzpnabwp"; + "1.7.0".sha256 = "0wnhj9nqpx2bw6n1l4i8jgrw3pjajvckvj3lr4vzjb3my2lbxdd1"; + "1.6.4".sha256 = "09ww48qbjsvpjmy1g9yhm0rrkq800ffq21p6fjkbwd34qvd82raz"; + "1.6.1".sha256 = "1ilw6vm4dlsdv9cd7kmf0vfrh2kkzr45wrqr8m37miy0byzr4p9i"; + }; + releaseRev = v: "mathcomp-${v}"; + + # list of core mathcomp packages sorted by dependency order + packages = [ "ssreflect" "fingroup" "algebra" "solvable" "field" "character" "all" ]; + + mathcomp_ = package: let + mathcomp-deps = if package == "single" then [] + else map mathcomp_ (head (splitList (pred.equal package) packages)); + pkgpath = if package == "single" then "mathcomp" else "mathcomp/${package}"; + pname = if package == "single" then "mathcomp" else "mathcomp-${package}"; + pkgallMake = '' + echo "all.v" > Make + echo "-I ." >> Make + echo "-R . mathcomp.all" >> Make + ''; + derivation = mkCoqDerivation ({ + inherit version pname defaultVersion release releaseRev repo owner; + + mlPlugin = versions.isLe "8.6" coq.coq-version; + nativeBuildInputs = optionals withDoc [ graphviz lua ]; + buildInputs = [ ncurses ]; + propagatedBuildInputs = [ coq-elpi hierarchy-builder ] ++ mathcomp-deps; + + buildFlags = optional withDoc "doc"; + + preBuild = '' + if [[ -f etc/utils/ssrcoqdep ]] + then patchShebangs etc/utils/ssrcoqdep + fi + if [[ -f etc/buildlibgraph ]] + then patchShebangs etc/buildlibgraph + fi + '' + '' + cd ${pkgpath} + '' + optionalString (package == "all") pkgallMake; + + meta = { + homepage = "https://math-comp.github.io/"; + license = licenses.cecill-b; + maintainers = with maintainers; [ vbgl jwiegley cohencyril ]; + }; + } // optionalAttrs (package != "single") + { passthru = genAttrs packages mathcomp_; } + // optionalAttrs withDoc { + htmldoc_template = + fetchzip { + url = "https://github.com/math-comp/math-comp.github.io/archive/doc-1.12.0.zip"; + sha256 = "0y1352ha2yy6k2dl375sb1r68r1qi9dyyy7dyzj5lp9hxhhq69x8"; + }; + postBuild = '' + cp -rf _build_doc/* . + rm -r _build_doc + ''; + postInstall = + let tgt = "$out/share/coq/${coq.coq-version}/"; in + optionalString withDoc '' + mkdir -p ${tgt} + cp -r htmldoc ${tgt} + cp -r $htmldoc_template/htmldoc_template/* ${tgt}/htmldoc/ + ''; + buildTargets = "doc"; + extraInstallFlags = [ "-f Makefile.coq" ]; + }); + patched-derivation1 = derivation.overrideAttrs (o: + optionalAttrs (o.pname != null && o.pname == "mathcomp-all" && + o.version != null && o.version != "dev" && versions.isLt "1.7" o.version) + { preBuild = ""; buildPhase = ""; installPhase = "echo doing nothing"; } + ); + patched-derivation = patched-derivation1.overrideAttrs (o: + optionalAttrs (versions.isLe "8.7" coq.coq-version || + (o.version != "dev" && versions.isLe "1.7" o.version)) + { + installFlags = o.installFlags ++ [ "-f Makefile.coq" ]; + } + ); + in patched-derivation; +in +mathcomp_ (if single then "single" else "all") diff --git a/CHANGELOG.md b/CHANGELOG.md index 445d1fb7a..bf0a8172d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,8 +64,8 @@ Latest releases: [[0.7.0] - 2024-01-19](#070---2024-01-19) and [[0.6.7] - 2024-0 + new lemma `continuous_within_itvP`. - in file `realfun.v`, - + new definitions `itv_partition`, `itv_partitionL`, `itv_partitionR`, - `variation`, `variations`, `bounded_variation`, `total_variation`, + + new definitions `itv_partition`, `itv_partitionL`, `itv_partitionR`, + `variation`, `variations`, `bounded_variation`, `total_variation`, `neg_tv`, and `pos_tv`. + new lemmas `left_right_continuousP`, @@ -74,20 +74,20 @@ Latest releases: [[0.7.0] - 2024-01-19](#070---2024-01-19) and [[0.6.7] - 2024-0 + new lemmas `itv_partition_nil`, `itv_partition_cons`, `itv_partition1`, `itv_partition_size_neq0`, `itv_partitionxx`, `itv_partition_le`, `itv_partition_cat`, `itv_partition_nth_size`, - `itv_partition_nth_ge`, `itv_partition_nth_le`, - `nondecreasing_fun_itv_partition`, `nonincreasing_fun_itv_partition`, - `itv_partitionLP`, `itv_partitionRP`, `in_itv_partition`, + `itv_partition_nth_ge`, `itv_partition_nth_le`, + `nondecreasing_fun_itv_partition`, `nonincreasing_fun_itv_partition`, + `itv_partitionLP`, `itv_partitionRP`, `in_itv_partition`, `notin_itv_partition`, `itv_partition_rev`, + new lemmas `variation_zip`, `variation_prev`, `variation_next`, `variation_nil`, - `variation_ge0`, `variationN`, `variation_le`, `nondecreasing_variation`, - `nonincreasing_variation`, `variationD`, `variation_itv_partitionLR`, + `variation_ge0`, `variationN`, `variation_le`, `nondecreasing_variation`, + `nonincreasing_variation`, `variationD`, `variation_itv_partitionLR`, `le_variation`, `variation_opp_rev`, `variation_rev_opp` + new lemmas `variations_variation`, `variations_neq0`, `variationsN`, `variationsxx` + new lemmas `bounded_variationxx`, `bounded_variationD`, `bounded_variationN`, - `bounded_variationl`, `bounded_variationr`, `variations_opp`, + `bounded_variationl`, `bounded_variationr`, `variations_opp`, `nondecreasing_bounded_variation` + new lemmas `total_variationxx`, `total_variation_ge`, `total_variation_ge0`, diff --git a/CHANGELOG_UNRELEASED.md b/CHANGELOG_UNRELEASED.md index 67bb43c3b..2d1ba5e50 100644 --- a/CHANGELOG_UNRELEASED.md +++ b/CHANGELOG_UNRELEASED.md @@ -4,6 +4,12 @@ ### Added +- in `cantor.v`: + + definitions `pointed_principal_filter`, + `pointed_discrete_topology` + + lemma `discrete_pointed` + + lemma `discrete_bool_compact` + ### Changed ### Renamed diff --git a/README.md b/README.md index e669c9de9..a35cba041 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,11 @@ the Coq proof-assistant and using the Mathematical Components library. - Pierre-Yves Strub (initial) - Laurent Théry - License: [CeCILL-C](LICENSE) +<<<<<<< HEAD - Compatible Coq versions: Coq 8.15 to 8.18 (or dev) +======= +- Compatible Coq versions: Coq 8.14 to 8.18 (or dev) +>>>>>>> origin/hierarchy-builder - Additional dependencies: - [MathComp ssreflect 1.17 or later](https://math-comp.github.io) - [MathComp fingroup 1.17 or later](https://math-comp.github.io) diff --git a/classical/boolp.v b/classical/boolp.v index 7acb9098c..0f5864740 100644 --- a/classical/boolp.v +++ b/classical/boolp.v @@ -4,7 +4,7 @@ (* Copyright (c) - 2015--2018 - Inria *) (* Copyright (c) - 2016--2018 - Polytechnique *) (* -------------------------------------------------------------------- *) - +From HB Require Import structures. From mathcomp Require Import all_ssreflect. (**md**************************************************************************) @@ -168,7 +168,7 @@ Proof. by move: x (x) y => /propT-> [] []. Qed. Record mclassic := { _ : forall (P : Prop), {P} + {~P}; - _ : forall T, Choice.mixin_of T + _ : forall T, hasChoice T }. Lemma choice X Y (P : X -> Y -> Prop) : @@ -215,7 +215,7 @@ exists (fun (P : pred T) (n : nat) => by exists 0; case: pselect => // -[]; exists x. Qed. -Lemma gen_choiceMixin {T : Type} : Choice.mixin_of T. +Lemma gen_choiceMixin (T : Type) : hasChoice T. Proof. by case: classic. Qed. Lemma lem (P : Prop): P \/ ~P. @@ -321,28 +321,23 @@ Proof. by move=> [] []; rewrite ?(trueE, falseE) ?propeqE; tauto. Qed. Definition gen_eq (T : Type) (u v : T) := `[]. Lemma gen_eqP (T : Type) : Equality.axiom (@gen_eq T). Proof. by move=> x y; apply: (iffP (asboolP _)). Qed. -Definition gen_eqMixin {T : Type} := EqMixin (@gen_eqP T). +Definition gen_eqMixin (T : Type) : hasDecEq T := + hasDecEq.Build T (@gen_eqP T). -Canonical arrow_eqType (T : Type) (T' : eqType) := - EqType (T -> T') gen_eqMixin. -Canonical arrow_choiceType (T : Type) (T' : choiceType) := - ChoiceType (T -> T') gen_choiceMixin. +HB.instance Definition _ (T : Type) (T' : T -> eqType) := + gen_eqMixin (forall t : T, T' t). -Definition dep_arrow_eqType (T : Type) (T' : T -> eqType) := - EqType (forall x : T, T' x) gen_eqMixin. -Definition dep_arrow_choiceClass (T : Type) (T' : T -> choiceType) := - Choice.Class (Equality.class (dep_arrow_eqType T')) gen_choiceMixin. -Definition dep_arrow_choiceType (T : Type) (T' : T -> choiceType) := - Choice.Pack (dep_arrow_choiceClass T'). +HB.instance Definition _ (T : Type) (T' : T -> choiceType) := + gen_choiceMixin (forall t : T, T' t). -Canonical Prop_eqType := EqType Prop gen_eqMixin. -Canonical Prop_choiceType := ChoiceType Prop gen_choiceMixin. +HB.instance Definition _ := gen_eqMixin Prop. +HB.instance Definition _ := gen_choiceMixin Prop. Section classicType. Variable T : Type. Definition classicType := T. -Canonical classicType_eqType := EqType classicType gen_eqMixin. -Canonical classicType_choiceType := ChoiceType classicType gen_choiceMixin. +HB.instance Definition _ := gen_eqMixin classicType. +HB.instance Definition _ := gen_choiceMixin classicType. End classicType. Notation "'{classic' T }" := (classicType T) (format "'{classic' T }") : type_scope. @@ -350,8 +345,8 @@ Notation "'{classic' T }" := (classicType T) Section eclassicType. Variable T : eqType. Definition eclassicType : Type := T. -Canonical eclassicType_eqType := EqType eclassicType (Equality.class T). -Canonical eclassicType_choiceType := ChoiceType eclassicType gen_choiceMixin. +HB.instance Definition _ := Equality.copy eclassicType T. +HB.instance Definition _ := gen_choiceMixin eclassicType. End eclassicType. Notation "'{eclassic' T }" := (eclassicType T) (format "'{eclassic' T }") : type_scope. @@ -367,11 +362,11 @@ Proof. by move=> + G Gs x => /(_ x)/cid[x' <-]. Qed. Arguments canon {T U sort} x. Lemma Peq : canonical Type eqType. -Proof. by apply: canon => T; exists [eqType of {classic T}]. Qed. +Proof. by apply: canon => T; exists {classic T}. Qed. Lemma Pchoice : canonical Type choiceType. -Proof. by apply: canon => T; exists [choiceType of {classic T}]. Qed. +Proof. by apply: canon => T; exists {classic T}. Qed. Lemma eqPchoice : canonical eqType choiceType. -Proof. by apply: canon=> T; exists [choiceType of {eclassic T}]; case: T. Qed. +Proof. by apply: canon => T; exists {eclassic T}; case: T => //= T [?]//. Qed. Lemma not_True : (~ True) = False. Proof. exact/propext. Qed. Lemma not_False : (~ False) = True. Proof. by apply/propext; split=> _. Qed. @@ -827,10 +822,9 @@ move=> g f h /asboolP fg /asboolP gh; apply/asboolP => x. by rewrite (le_trans (fg x)). Qed. -Definition porderMixin := - @LePOrderMixin _ lef ltf ltf_def lef_refl lef_anti lef_trans. - -Canonical porderType := POrderType fun_display (aT -> T) porderMixin. +#[export] +HB.instance Definition _ := @Order.isPOrder.Build + fun_display (aT -> T) lef ltf ltf_def lef_refl lef_anti lef_trans. End FunOrder. @@ -867,15 +861,13 @@ apply/idP/idP => [/asboolP f_le_g|/eqP <-]. - apply/asboolP => x; exact: leIr. Qed. -Definition latticeMixin := - LatticeMixin meetfC joinfC meetfA joinfA joinfKI meetfKU lef_meet. - -Canonical latticeType := LatticeType (aT -> T) latticeMixin. +#[export] +HB.instance Definition _ := Order.POrder_isLattice.Build _ (aT -> T) + meetfC joinfC meetfA joinfA joinfKI meetfKU lef_meet. End FunLattice. Module Exports. -Canonical porderType. -Canonical latticeType. +HB.reexport. End Exports. End FunOrder. Export FunOrder.Exports. diff --git a/classical/cardinality.v b/classical/cardinality.v index d9ce6b8db..2cce9b33a 100644 --- a/classical/cardinality.v +++ b/classical/cardinality.v @@ -458,12 +458,6 @@ Lemma eq_countable T U (A : set T) (B : set U) : A #= B -> countable A = countable B. Proof. by move=> /card_le_eql leA; rewrite /countable leA. Qed. -Lemma countable_setT_countMixin (T : Type) : - countable (@setT T) -> Countable.mixin_of T. -Proof. -by move=> /pcard_leP/unsquash f; exists f 'oinv_f; apply: in1TT 'funoK_f. -Qed. - Lemma countableP (T : countType) (A : set T) : countable A. Proof. by apply/card_leP; squash (to_setT \o choice.pickle). Qed. #[global] Hint Resolve countableP : core. @@ -651,7 +645,7 @@ Proof. exact/card_le_finite/card_le_setD. Qed. Lemma finite_setU T (A B : set T) : finite_set (A `|` B) = (finite_set A /\ finite_set B). Proof. -pose fP := @finite_fsetP [choiceType of {classic T}]; rewrite propeqE; split. +pose fP := @finite_fsetP {classic T}; rewrite propeqE; split. by move=> finAUB; split; apply: sub_finite_set finAUB. by case=> /fP[X->]/fP[Y->]; apply/fP; exists (X `|` Y)%fset; rewrite set_fsetU. Qed. @@ -1095,7 +1089,7 @@ Qed. Lemma card_nat2 : [set: nat * nat] #= [set: nat]. Proof. exact/eq_card_nat/infinite_prod_nat/countableP. Qed. -Canonical rat_pointedType := PointedType rat 0. +HB.instance Definition _ := isPointed.Build rat 0. Lemma infinite_rat : infinite_set [set: rat]. Proof. @@ -1110,7 +1104,9 @@ Lemma choicePcountable {T : choiceType} : countable [set: T] -> {T' : countType | T = T' :> Type}. Proof. move=> /pcard_leP/unsquash f. -by exists (CountType T (CountMixin (in1TT 'funoK_f))). +pose TcM := PCanIsCountable (in1TT 'funoK_f). +pose TC : countType := HB.pack T TcM. +by exists TC. Qed. Lemma eqPcountable {T : eqType} : countable [set: T] -> @@ -1282,21 +1278,18 @@ Qed. Lemma fimfun_valP f (Pf : f \in fimfun) : fimfun_Sub Pf = f :> (_ -> _). Proof. by []. Qed. -Canonical fimfun_subType := SubType T _ _ fimfun_rect fimfun_valP. +HB.instance Definition _ := isSub.Build _ _ T fimfun_rect fimfun_valP. End fimfun. Lemma fimfuneqP aT rT (f g : {fimfun aT >-> rT}) : f = g <-> f =1 g. Proof. by split=> [->//|fg]; apply/val_inj/funext. Qed. -Definition fimfuneqMixin aT (rT : eqType) := - [eqMixin of {fimfun aT >-> rT} by <:]. -Canonical fimfuneqType aT (rT : eqType) := - EqType {fimfun aT >-> rT} (fimfuneqMixin aT rT). -Definition fimfunchoiceMixin aT (rT : choiceType) := - [choiceMixin of {fimfun aT >-> rT} by <:]. -Canonical fimfunchoiceType aT (rT : choiceType) := - ChoiceType {fimfun aT >-> rT} (fimfunchoiceMixin aT rT). +HB.instance Definition _ aT (rT : eqType) := + [Equality of {fimfun aT >-> rT} by <:]. + +HB.instance Definition _ aT (rT : choiceType) := + [Choice of {fimfun aT >-> rT} by <:]. Lemma finite_image_cst {aT rT : Type} (x : rT) : finite_set (range (cst x : aT -> _)). @@ -1325,10 +1318,10 @@ Proof. split=> [|f g]; rewrite !inE/=; first exact: finite_image_cst. by move=> fA gA; apply: (finite_image11 (fun x y => x - y)). Qed. -Canonical fimfun_add := AddrPred fimfun_zmod_closed. -Canonical fimfun_zmod := ZmodPred fimfun_zmod_closed. -Definition fimfun_zmodMixin := [zmodMixin of {fimfun aT >-> rT} by <:]. -Canonical fimfun_zmodType := ZmodType {fimfun aT >-> rT} fimfun_zmodMixin. +HB.instance Definition _ := + GRing.isZmodClosed.Build (aT -> rT) fimfun fimfun_zmod_closed. +HB.instance Definition _ := + [SubChoice_isSubZmodule of {fimfun aT >-> rT} by <:]. Implicit Types (f g : {fimfun aT >-> rT}). diff --git a/classical/classical_sets.v b/classical/classical_sets.v index ddebf5da0..5d586a362 100644 --- a/classical/classical_sets.v +++ b/classical/classical_sets.v @@ -1,5 +1,6 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) -From mathcomp Require Import all_ssreflect ssralg matrix finmap order ssrnum. +From HB Require Import structures. +From mathcomp Require Import all_ssreflect ssralg matrix finmap ssrnum. From mathcomp Require Import ssrint interval. From mathcomp Require Import mathcomp_extra boolp. @@ -1262,14 +1263,12 @@ Section SetMonoids. Variable (T : Type). Import Monoid. -Canonical setU_monoid := Law (@setUA T) (@set0U T) (@setU0 T). -Canonical setU_comoid := ComLaw (@setUC T). -Canonical setU_mul_monoid := MulLaw (@setTU T) (@setUT T). -Canonical setI_monoid := Law (@setIA T) (@setTI T) (@setIT T). -Canonical setI_comoid := ComLaw (@setIC T). -Canonical setI_mul_monoid := MulLaw (@set0I T) (@setI0 T). -Canonical setU_add_monoid := AddLaw (@setUIl T) (@setUIr T). -Canonical setI_add_monoid := AddLaw (@setIUl T) (@setIUr T). +HB.instance Definition _ := isComLaw.Build (set T) set0 setU setUA setUC set0U. +HB.instance Definition _ := isMulLaw.Build (set T) setT setU setTU setUT. +HB.instance Definition _ := isComLaw.Build (set T) setT setI setIA setIC setTI. +HB.instance Definition _ := isMulLaw.Build (set T) set0 setI set0I setI0. +HB.instance Definition _ := isAddLaw.Build (set T) setU setI setUIl setUIr. +HB.instance Definition _ := isAddLaw.Build (set T) setI setU setIUl setIUr. End SetMonoids. @@ -2245,76 +2244,25 @@ Lemma inTT_bij [T1 T2 : Type] [f : T1 -> T2] : {in [set: T1], bijective f} -> bijective f. Proof. by case=> [g /in1TT + /in1TT +]; exists g. Qed. -Module Pointed. +HB.mixin Record isPointed T := { point : T }. -Definition point_of (T : Type) := T. +#[short(type=pointedType)] +HB.structure Definition Pointed := {T of isPointed T & Choice T}. -Record class_of (T : Type) := Class { - base : Choice.class_of T; - mixin : point_of T -}. - -Section ClassDef. - -Structure type := Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of cT in c. - -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). -Local Coercion base : class_of >-> Choice.class_of. - -Definition pack m := - fun bT b of phant_id (Choice.class bT) b => @Pack T (Class b m). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. - -End ClassDef. - -Module Exports. - -Coercion sort : type >-> Sortclass. -Coercion base : class_of >-> Choice.class_of. -Coercion mixin : class_of >-> point_of. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Notation pointedType := type. -Notation PointedType T m := (@pack T m _ _ idfun). -Notation "[ 'pointedType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'pointedType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'pointedType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'pointedType' 'of' T ]") : form_scope. - -End Exports. - -End Pointed. - -Export Pointed.Exports. - -Definition point {M : pointedType} : M := Pointed.mixin (Pointed.class M). +(* NB: was arrow_pointedType *) +HB.instance Definition _ (T : Type) (T' : T -> pointedType) := + isPointed.Build (forall t : T, T' t) (fun=> point). -Canonical arrow_pointedType (T : Type) (T' : pointedType) := - PointedType (T -> T') (fun=> point). - -Definition dep_arrow_pointedType (T : Type) (T' : T -> pointedType) := - Pointed.Pack - (Pointed.Class (dep_arrow_choiceClass T') (fun i => @point (T' i))). - -Canonical unit_pointedType := PointedType unit tt. -Canonical bool_pointedType := PointedType bool false. -Canonical Prop_pointedType := PointedType Prop False. -Canonical nat_pointedType := PointedType nat 0. -Canonical prod_pointedType (T T' : pointedType) := - PointedType (T * T') (point, point). -Canonical matrix_pointedType m n (T : pointedType) := - PointedType 'M[T]_(m, n) (\matrix_(_, _) point)%R. -Canonical option_pointedType (T : choiceType) := PointedType (option T) None. -Canonical pointed_fset {T : choiceType} := PointedType {fset T} fset0. +HB.instance Definition _ := isPointed.Build unit tt. +HB.instance Definition _ := isPointed.Build bool false. +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 _ m n (T : pointedType) := + isPointed.Build 'M[T]_(m, n) (\matrix_(_, _) point)%R. +HB.instance Definition _ (T : choiceType) := isPointed.Build (option T) None. +HB.instance Definition _ (T : choiceType) := isPointed.Build {fset T} fset0. Notation get := (xget point). Notation "[ 'get' x | E ]" := (get [set x | E]) @@ -2360,108 +2308,56 @@ Lemma unsquashK {T} : cancel (@unsquash T) squash. Proof. by move=> []. Qed. (* Empty types *) -Module Empty. +HB.mixin Record isEmpty T := { + axiom : T -> False +}. + +#[short(type="emptyType")] +HB.structure Definition Empty := {T of isEmpty T & Finite T}. + +HB.factory Record Choice_isEmpty T of Choice T := { + axiom : T -> False +}. +HB.builders Context T of Choice_isEmpty T. + +Definition pickle : T -> nat := fun=> 0%N. +Definition unpickle : nat -> option T := fun=> None. +Lemma pickleK : pcancel pickle unpickle. +Proof. by move=> x; case: (axiom x). Qed. +HB.instance Definition _ := isCountable.Build T pickleK. -Definition mixin_of T := T -> False. +Lemma fin_axiom : Finite.axiom ([::] : seq T). +Proof. by move=> /[dup]/axiom. Qed. +HB.instance Definition _ := isFinite.Build T fin_axiom. -Section EqMixin. -Variables (T : Type) (m : mixin_of T). +HB.instance Definition _ := isEmpty.Build T axiom. +HB.end. + +HB.factory Record Type_isEmpty T := { + axiom : T -> False +}. +HB.builders Context T of Type_isEmpty T. Definition eq_op (x y : T) := true. -Lemma eq_opP : Equality.axiom eq_op. Proof. by []. Qed. -Definition eqMixin := EqMixin eq_opP. -End EqMixin. +Lemma eq_opP : Equality.axiom eq_op. Proof. by move=> ? /[dup]/axiom. Qed. +HB.instance Definition _ := hasDecEq.Build T eq_opP. -Section ChoiceMixin. -Variables (T : Type) (m : mixin_of T). Definition find of pred T & nat : option T := None. Lemma findP (P : pred T) (n : nat) (x : T) : find P n = Some x -> P x. Proof. by []. Qed. Lemma ex_find (P : pred T) : (exists x : T, P x) -> exists n : nat, find P n. -Proof. by case. Qed. +Proof. by move=> [/[dup]/axiom]. Qed. Lemma eq_find (P Q : pred T) : P =1 Q -> find P =1 find Q. Proof. by []. Qed. -Definition choiceMixin := Choice.Mixin findP ex_find eq_find. -End ChoiceMixin. +HB.instance Definition _ := hasChoice.Build T findP ex_find eq_find. -Section CountMixin. -Variables (T : Type) (m : mixin_of T). -Definition pickle : T -> nat := fun=> 0. -Definition unpickle : nat -> option T := fun=> None. -Lemma pickleK : pcancel pickle unpickle. Proof. by []. Qed. -Definition countMixin := CountMixin pickleK. -End CountMixin. - -Section FinMixin. -Variables (T : countType) (m : mixin_of T). -Lemma fin_axiom : Finite.axiom ([::] : seq T). Proof. by []. Qed. -Definition finMixin := FinMixin fin_axiom. -End FinMixin. - -Section ClassDef. - -Set Primitive Projections. -Record class_of T := Class { - base : Finite.class_of T; - mixin : mixin_of T -}. -Unset Primitive Projections. -Local Coercion base : class_of >-> Finite.class_of. - -Structure type : Type := Pack {sort; _ : class_of sort}. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c as cT' := cT return class_of cT' in c. -Definition clone c of phant_id class c := @Pack T c. - -Definition pack (m0 : mixin_of T) := - fun bT b & phant_id (Finite.class bT) b => - fun m & phant_id m0 m => Pack (@Class T b m). - -Definition eqType := @Equality.Pack cT class. -Definition choiceType := @Choice.Pack cT class. -Definition countType := @Countable.Pack cT class. -Definition finType := @Finite.Pack cT class. - -End ClassDef. - -Module Import Exports. -Coercion base : class_of >-> Finite.class_of. -Coercion mixin : class_of >-> mixin_of. -Coercion sort : type >-> Sortclass. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion countType : type >-> Countable.type. -Canonical countType. -Coercion finType : type >-> Finite.type. -Canonical finType. -Notation emptyType := type. -Notation EmptyType T m := (@pack T m _ _ id _ id). -Notation "[ 'emptyType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'emptyType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'emptyType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'emptyType' 'of' T ]") : form_scope. -Coercion eqMixin : mixin_of >-> Equality.mixin_of. -Coercion choiceMixin : mixin_of >-> Choice.mixin_of. -Coercion countMixin : mixin_of >-> Countable.mixin_of. -End Exports. - -End Empty. -Export Empty.Exports. +HB.instance Definition _ := Choice_isEmpty.Build T axiom. +HB.end. -Definition False_emptyMixin : Empty.mixin_of False := id. -Canonical False_eqType := EqType False False_emptyMixin. -Canonical False_choiceType := ChoiceType False False_emptyMixin. -Canonical False_countType := CountType False False_emptyMixin. -Canonical False_finType := FinType False (Empty.finMixin False_emptyMixin). -Canonical False_emptyType := EmptyType False False_emptyMixin. +HB.instance Definition _ := Type_isEmpty.Build False id. -Definition void_emptyMixin : Empty.mixin_of void := @of_void _. -Canonical void_emptyType := EmptyType void void_emptyMixin. +HB.instance Definition _ := isEmpty.Build void (@of_void _). -Definition no {T : emptyType} : T -> False := - let: Empty.Pack _ (Empty.Class _ f) := T in f. +Definition no {T : emptyType} : T -> False := @axiom T. Definition any {T : emptyType} {U} : T -> U := @False_rect _ \o no. Lemma empty_eq0 {T : emptyType} : all_equal_to (set0 : set T). @@ -2481,13 +2377,17 @@ Arguments qcanon {T C sort alt} x. Lemma choicePpointed : quasi_canonical choiceType pointedType. Proof. -apply: qcanon => T; have [/unsquash x|/(_ (squash _)) TF] := pselect $|T|. - by right; exists (PointedType T x); case: T x. +apply: qcanon => -[Ts [Tc Te]]. +set T := Choice.Pack _. +have [/unsquash x|/(_ (squash _)) TF] := pselect $|T|. + right. + pose Tp := isPointed.Build T x. + pose TT : pointedType := HB.pack T Te Tc Tp. + by exists TT. left. -pose cT := CountType _ (TF : Empty.mixin_of T). -pose fM := Empty.finMixin (TF : Empty.mixin_of cT). -exists (EmptyType (FinType _ fM) TF) => //=. -by case: T TF @cT @fM. +pose TMixin := Choice_isEmpty.Build T TF. +pose TT : emptyType := HB.pack T Te Tc TMixin. +by exists TT. Qed. Lemma eqPpointed : quasi_canonical eqType pointedType. @@ -2720,7 +2620,8 @@ Hypothesis (Rsucc : forall s, exists t, R s t /\ s <> t /\ Let Teq := @gen_eqMixin T. Let Tch := @gen_choiceMixin T. -Let Tp := Pointed.Pack (Pointed.Class (Choice.Class Teq Tch) t0). +Let Tp : pointedType := (* FIXME: use HB.pack *) + Pointed.Pack (@Pointed.Class T (isPointed.Axioms_ t0) Tch Teq). Let lub := fun A : {A : set T | total_on A R} => [get t : Tp | (forall s, sval A s -> R s t) /\ forall r, (forall s, sval A s -> R s r) -> R t r]. @@ -2888,7 +2789,8 @@ Lemma ZL_preorder T (t0 : T) (R : T -> T -> Prop) : exists t, premaximal R t. Proof. set Teq := @gen_eqMixin T; set Tch := @gen_choiceMixin T. -set Tp := Pointed.Pack (Pointed.Class (Choice.Class Teq Tch) t0). +pose Tpo := isPointed.Build T t0. +pose Tp : pointedType := HB.pack T Teq Tch Tpo. move=> Rrefl Rtrans tot_max. set eqR := fun s t => R s t /\ R t s; set ceqR := fun s => [set t | eqR s t]. have eqR_trans r s t : eqR r s -> eqR s t -> eqR r t. @@ -3138,13 +3040,14 @@ Proof. by rewrite setUC setKU. Qed. Lemma meetKU B A : A `|` (A `&` B) = A. Proof. by rewrite setIC setKI. Qed. -Definition orderMixin := @MeetJoinMixin _ _ (fun A B => `[]) setI - setU le_def lt_def (@setIC _) (@setUC _) (@setIA _) (@setUA _) joinKI meetKU - (@setIUl _) setIid. +#[export] +HB.instance Definition _ : Choice (set T) := Choice.copy _ (set T). -Local Canonical porderType := POrderType set_display (set T) orderMixin. -Local Canonical latticeType := LatticeType (set T) orderMixin. -Local Canonical distrLatticeType := DistrLatticeType (set T) orderMixin. +#[export] +HB.instance Definition _ := + Order.isMeetJoinDistrLattice.Build set_display (set T) + le_def lt_def (@setIC _) (@setUC _) (@setIA _) (@setUA _) + joinKI meetKU (@setIUl _) setIid. Lemma SetOrder_sub0set A : (set0 <= A)%O. Proof. by apply/asboolP; apply: sub0set. Qed. @@ -3152,12 +3055,13 @@ Proof. by apply/asboolP; apply: sub0set. Qed. Lemma SetOrder_setTsub A : (A <= setT)%O. Proof. exact/asboolP. Qed. -Local Canonical bLatticeType := - BLatticeType (set T) (Order.BLattice.Mixin SetOrder_sub0set). -Local Canonical tbLatticeType := - TBLatticeType (set T) (Order.TBLattice.Mixin SetOrder_setTsub). -Local Canonical bDistrLatticeType := [bDistrLatticeType of set T]. -Local Canonical tbDistrLatticeType := [tbDistrLatticeType of set T]. +#[export] +HB.instance Definition _ := Order.hasBottom.Build set_display (set T) + SetOrder_sub0set. + +#[export] +HB.instance Definition _ := Order.hasTop.Build set_display (set T) + SetOrder_setTsub. Lemma subKI A B : B `&` (A `\` B) = set0. Proof. by rewrite setDE setICA setICr setI0. Qed. @@ -3165,26 +3069,21 @@ Proof. by rewrite setDE setICA setICr setI0. Qed. Lemma joinIB A B : (A `&` B) `|` A `\` B = A. Proof. by rewrite setUC -setDDr setDv setD0. Qed. -Local Canonical cbDistrLatticeType := CBDistrLatticeType (set T) - (@CBDistrLatticeMixin _ _ (fun A B => A `\` B) subKI joinIB). +#[export] +HB.instance Definition _ := + Order.hasRelativeComplement.Build set_display (set T) subKI joinIB. -Local Canonical ctbDistrLatticeType := CTBDistrLatticeType (set T) - (@CTBDistrLatticeMixin _ _ _ (fun A => ~` A) (fun x => esym (setTD x))). +#[export] +HB.instance Definition _ := Order.hasComplement.Build set_display (set T) + (fun x => esym (setTD x)). End SetOrder. +Module Exports. HB.reexport. End Exports. End Internal. Module Exports. -Canonical Internal.porderType. -Canonical Internal.latticeType. -Canonical Internal.distrLatticeType. -Canonical Internal.bLatticeType. -Canonical Internal.tbLatticeType. -Canonical Internal.bDistrLatticeType. -Canonical Internal.tbDistrLatticeType. -Canonical Internal.cbDistrLatticeType. -Canonical Internal.ctbDistrLatticeType. +Export Internal.Exports. Section exports. Context {T : Type}. diff --git a/classical/fsbigop.v b/classical/fsbigop.v index 23086e007..18b4d06fb 100644 --- a/classical/fsbigop.v +++ b/classical/fsbigop.v @@ -319,8 +319,11 @@ have [->|a0] := eqVneq a zero. rewrite big_distrr [RHS](full_fsbigID (F @^-1` [set zero])); last first. apply: sub_finite_set finF => x /= [Px aFN0]. by split=> //; apply: contra_not aFN0 => ->; rewrite Monoid.simpm. -rewrite [X in plus X _](_ : _ = zero) ?Monoid.simpm; last first. - by rewrite fsbig1// => i [_ ->]; rewrite Monoid.simpm. +set b0 := bigop _ _ _. +set b1 := bigop _ _ _. +set b2 := bigop _ _ _. +rewrite (_ : b1 = zero) ?Monoid.simpm; last first. + by rewrite /b1 fsbig1// => i [_ ->]; rewrite Monoid.simpm. apply/esym/fsbig_fwiden => //. by move=> x [Px Fx0]; rewrite /= in_finite_support// inE. move=> i []; rewrite /preimage/= in_finite_support //. diff --git a/classical/functions.v b/classical/functions.v index 491b639d4..ace873725 100644 --- a/classical/functions.v +++ b/classical/functions.v @@ -52,7 +52,7 @@ Add Search Blacklist "_mixin_". (* [fun f in A] == the function f from the set A to the set f @` A*) (* 'split_ d f == partial injection from aT : Type to rt : Type; *) (* f : aT -> rT, d : rT -> aT *) -(* split := 'split_point *) +(* split := 'split_(fun=> point) *) (* @to_setT T == function that associates to x : T a dependent *) (* pair of x with a proof that x belongs to setT *) (* (i.e., the type set_type [set: T]) *) @@ -80,7 +80,7 @@ Add Search Blacklist "_mixin_". (* A and B are intended to be the ranges of f and g *) (* 'pinv_ d A f == inverse of the function [fun f in A] over *) (* f @` A, function d outside of f @` A *) -(* pinv := notation for 'pinv_point *) +(* pinv := notation for 'pinv_(fun=> point) *) (* ``` *) (* *) (* ## Function restriction *) @@ -268,11 +268,12 @@ Notation "{ 'inv' aT >-> rT }" := (@Inversible.type aT rT) : type_scope. Notation "[ 'inv' 'of' f ]" := [the {inv _ >-> _} of f : _ -> _] : form_scope. Definition phant_inv aT rT (f : {inv aT >-> rT}) of phantom (_ -> _) f := @inv _ _ f. -Notation "f ^-1" := (@inv _ _ f%FUN) (only printing) : fun_scope. Notation "f ^-1" := (@inv _ _ f%function) (only printing) : function_scope. -Notation "f ^-1" := (@phant_inv _ _ _ (Phantom (_ -> _) f%FUN)) : fun_scope. Notation "f ^-1" := (@phant_inv _ _ _ (Phantom (_ -> _) f%function)) : function_scope. +(* TODO: remove the following notations in fun_scope *) +Notation "f ^-1" := (@inv _ _ f%FUN) (only printing) : fun_scope. +Notation "f ^-1" := (@phant_inv _ _ _ (Phantom (_ -> _) f%FUN)) : fun_scope. HB.structure Definition InvFun aT rT A B := {f of Inv aT rT f & isFun aT rT A B f}. @@ -959,7 +960,7 @@ HB.instance Definition _ (f : {bij A >-> B}) := Surject.on (split f). End split. Notation "''split_' a" := (split_ a) : form_scope. -Notation split := 'split_point. +Notation split := 'split_(fun=> point). (** More Builders *) @@ -1577,10 +1578,12 @@ End addition. Section addition. Context {V : zmodType} (x : V). +Local Open Scope ring_scope. +(* TODO: promote -%R to empty scope in mathcomp/HB *) HB.instance Definition _ := Inv.Build V V (-%R) (-%R). -Lemma inv_oppr : (-%R)^-1 = (-%R). Proof. by []. Qed. +Lemma inv_oppr : (-%R)^-1%FUN = (-%R). Proof. by []. Qed. Lemma oppr_can2_subproof : Inv_Can2 V V setT setT (-%R). Proof. by split => // y _; rewrite inv_oppr ?GRing.opprK. Qed. @@ -1850,7 +1853,7 @@ End inj. End patch. Notation restrict := (patch (fun=> point)). -Notation "f \_ D" := (restrict D f) : fun_scope. +Notation "f \_ D" := (restrict D f) : function_scope. Lemma patchE aT (rT : pointedType) (f : aT -> rT) (B : set aT) x : (f \_ B) x = if x \in B then f x else point. @@ -2531,16 +2534,16 @@ End funpPinj. End pointed_inverse. Notation "''pinv_' dflt" := (pinv_ dflt) : form_scope. -Notation pinv := 'pinv_point. +Notation pinv := 'pinv_(fun=> point). Notation "''pPbij_' dflt" := (pPbij_ dflt) : form_scope. -Notation pPbij := 'pPbij_point. +Notation pPbij := 'pPbij_(fun=> point). Notation selfPbij := 'pPbij_id. Notation "''pPinj_' dflt" := (pPinj_ dflt) : form_scope. -Notation pPinj := 'pPinj_point. +Notation pPinj := 'pPinj_(fun=> point). Notation "''injpPfun_' dflt" := (injpPfun_ dflt) : form_scope. -Notation injpPfun := 'injpPfun_point. +Notation injpPfun := 'injpPfun_(fun=> point). Notation "''funpPinj_' dflt" := (funpPinj_ dflt) : form_scope. -Notation funpPinj := 'funpPinj_point. +Notation funpPinj := 'funpPinj_(fun=> point). Section function_space. Local Open Scope ring_scope. @@ -2558,16 +2561,16 @@ Qed. Obligation Tactic := idtac. Program Definition fct_zmodMixin (T : Type) (M : zmodType) := - @ZmodMixin (T -> M) \0 (fun f x => - f x) (fun f g => f \+ g) _ _ _ _. + @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. -Canonical fct_zmodType T (M : zmodType) := ZmodType (T -> M) (fct_zmodMixin T M). +HB.instance Definition _ (T : Type) (M : zmodType) := fct_zmodMixin T M. Program Definition fct_ringMixin (T : pointedType) (M : ringType) := - @RingMixin [zmodType of T -> M] (cst 1) (fun f g => f \* g) - _ _ _ _ _ _. + @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. @@ -2576,25 +2579,30 @@ 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. -Canonical fct_ringType (T : pointedType) (M : ringType) := - RingType (T -> M) (fct_ringMixin T M). +HB.instance Definition _ (T : pointedType) (M : ringType) := fct_ringMixin T M. -Program Canonical fct_comRingType (T : pointedType) (M : comRingType) := - ComRingType (T -> M) _. -Next Obligation. by move=> T M f g; rewrite funeqE => x/=; rewrite mulrC. Qed. +Program Definition fct_comRingType (T : pointedType) (M : comRingType) := + GRing.Ring_hasCommutativeMul.Build (T -> M) _. +Next Obligation. +by move=> T M f g; rewrite funeqE => x; rewrite /GRing.mul/= mulrC. +Qed. +HB.instance Definition _ (T : pointedType) (M : comRingType) := + fct_comRingType T M. -Program Definition fct_lmodMixin (U : Type) (R : ringType) (V : lmodType R) - := @LmodMixin R [zmodType of U -> V] (fun k f => k \*: f) _ _ _ _. -Next Obligation. by move=> U R V k f v; rewrite funeqE=> x; exact: scalerA. Qed. -Next Obligation. by move=> U R V f; rewrite funeqE=> x /=; rewrite scale1r. Qed. +Section fct_lmod. +Variables (U : Type) (R : ringType) (V : lmodType R). +Program Definition fct_lmodMixin := @GRing.Zmodule_isLmodule.Build R (U -> V) + (fun k f => k \*: f) _ _ _ _. +Next Obligation. by move=> k f v; rewrite funeqE=> x; exact: scalerA. Qed. +Next Obligation. by move=> f; rewrite funeqE=> x /=; rewrite scale1r. Qed. Next Obligation. -by move=> U R V f g h; rewrite funeqE => x /=; rewrite scalerDr. +by move=> f g h; rewrite funeqE => x /=; rewrite scalerDr. Qed. Next Obligation. -by move=> U R V f g h; rewrite funeqE => x /=; rewrite scalerDl. +by move=> f g h; rewrite funeqE => x /=; rewrite scalerDl. Qed. -Canonical fct_lmodType U (R : ringType) (V : lmodType R) := - LmodType _ (U -> V) (fct_lmodMixin U V). +HB.instance Definition _ := fct_lmodMixin. +End fct_lmod. Lemma fct_sumE (I T : Type) (M : zmodType) r (P : {pred I}) (f : I -> T -> M) (x : T) : diff --git a/classical/mathcomp_extra.v b/classical/mathcomp_extra.v index 6e9fc6b51..49ab82ea2 100644 --- a/classical/mathcomp_extra.v +++ b/classical/mathcomp_extra.v @@ -1,11 +1,6 @@ (* mathcomp analysis (c) 2022 Inria and AIST. License: CeCILL-C. *) Require Import BinPos. From mathcomp Require choice. -(* Missing coercion (done before Import to avoid redeclaration error, - thanks to KS for the trick) *) -(* MathComp 1.15 addition *) -Coercion choice.Choice.mixin : choice.Choice.class_of >-> choice.Choice.mixin_of. - From mathcomp Require Import all_ssreflect finmap ssralg ssrnum ssrint rat. From mathcomp Require Import finset interval. @@ -203,8 +198,8 @@ Implicit Types i : interval R. Lemma mem_miditv i : (i.1 < i.2)%O -> miditv i \in i. Proof. move: i => [[ba a|[]] [bb b|[]]] //= ab; first exact: mid_in_itv. - by rewrite !in_itv -lteif_subl_addl subrr lteif01. -by rewrite !in_itv lteif_subl_addr -lteif_subl_addl subrr lteif01. + by rewrite !in_itv -lteifBlDl subrr lteif01. +by rewrite !in_itv lteifBlDr -lteifBlDl subrr lteif01. Qed. Lemma miditv_le_left i b : (i.1 < i.2)%O -> (BSide b (miditv i) <= i.2)%O. @@ -244,7 +239,7 @@ End itv_porderType. Lemma sumr_le0 (R : numDomainType) I (r : seq I) (P : pred I) (F : I -> R) : (forall i, P i -> F i <= 0)%R -> (\sum_(i <- r | P i) F i <= 0)%R. -Proof. by move=> F0; elim/big_rec : _ => // i x Pi; apply/ler_naddl/F0. Qed. +Proof. by move=> F0; elim/big_rec : _ => // i x Pi; apply/ler_wnDl/F0. Qed. Lemma enum_ord0 : enum 'I_0 = [::]. Proof. by apply/eqP; rewrite -size_eq0 size_enum_ord. Qed. @@ -376,13 +371,13 @@ Proof. by rewrite -mulr2n -mulr_natr mulfVK //= pnatr_eq0. Qed. Lemma ler_addgt0Pr x y : reflect (forall e, e > 0 -> x <= y + e) (x <= y). Proof. -apply/(iffP idP)=> [lexy e e_gt0 | lexye]; first by rewrite ler_paddr// ltW. +apply/(iffP idP)=> [lexy e e_gt0 | lexye]; first by rewrite ler_wpDr// ltW. have [||ltyx]// := comparable_leP. rewrite (@comparabler_trans _ (y + 1))// /Order.comparable ?lexye ?ltr01//. - by rewrite ler_addl ler01 orbT. + by rewrite lerDl ler01 orbT. have /midf_lt [_] := ltyx; rewrite le_gtF//. -rewrite -(@addrK _ y y) addrAC -addrA 2!mulrDl -splitr lexye//. -by rewrite divr_gt0// ?ltr0n// subr_gt0. +rewrite -(subrKA y) addrACA 2!mulrDl -splitr lexye//. +by rewrite addrC divr_gt0// ?ltr0n// subr_gt0. Qed. Lemma ler_addgt0Pl x y : reflect (forall e, e > 0 -> x <= e + y) (x <= y). @@ -394,9 +389,9 @@ Lemma in_segment_addgt0Pr x y z : reflect (forall e, e > 0 -> y \in `[x - e, z + e]) (y \in `[x, z]). Proof. apply/(iffP idP)=> [xyz e /[dup] e_gt0 /ltW e_ge0 | xyz_e]. - by rewrite in_itv /= ler_subl_addr !ler_paddr// (itvP xyz). + by rewrite in_itv /= lerBlDr !ler_wpDr// (itvP xyz). by rewrite in_itv /= ; apply/andP; split; apply/ler_addgt0Pr => ? /xyz_e; - rewrite in_itv /= ler_subl_addr => /andP []. + rewrite in_itv /= lerBlDr => /andP []. Qed. Lemma in_segment_addgt0Pl x y z : @@ -408,14 +403,14 @@ Qed. Lemma lt_le a b : (forall x, x < a -> x < b) -> a <= b. Proof. -move=> ab; apply/ler_addgt0Pr => e e_gt0; rewrite -ler_subl_addr ltW//. -by rewrite ab // ltr_subl_addr -ltr_subl_addl subrr. +move=> ab; apply/ler_addgt0Pr => e e_gt0; rewrite -lerBlDr ltW//. +by rewrite ab // ltrBlDr -ltrBlDl subrr. Qed. Lemma gt_ge a b : (forall x, b < x -> a < x) -> a <= b. Proof. move=> ab; apply/ler_addgt0Pr => e e_gt0. -by rewrite ltW// ab// -ltr_subl_addl subrr. +by rewrite ltW// ab// -ltrBlDl subrr. Qed. End lt_le_gt_ge. @@ -468,546 +463,9 @@ Proof. by rewrite big_seq_fsetE/= sum1_card cardfE. Qed. Arguments big_rmcond {R idx op I r} P. Arguments big_rmcond_in {R idx op I r} P. -(*****************************) -(* MathComp 1.16.0 additions *) -(*****************************) - -Section bigminr_maxr. -Import Num.Def. - -Lemma bigminr_maxr (R : realDomainType) I r (P : pred I) (F : I -> R) x : - \big[minr/x]_(i <- r | P i) F i = - \big[maxr/- x]_(i <- r | P i) - F i. -Proof. -by elim/big_rec2: _ => [|i y _ _ ->]; rewrite ?oppr_max opprK. -Qed. -End bigminr_maxr. - -Section SemiGroupProperties. -Variables (R : Type) (op : R -> R -> R). -Hypothesis opA : associative op. - -(* Convert an AC op : R -> R -> R to a com_law on option R *) -Definition AC_subdef of associative op & commutative op := - fun x => oapp (fun y => Some (oapp (op^~ y) y x)) x. -Definition oAC := nosimpl AC_subdef. - -Hypothesis opC : commutative op. -Let opCA : left_commutative op. Proof. by move=> x *; rewrite !opA (opC x). Qed. -Let opAC : right_commutative op. -Proof. by move=> *; rewrite -!opA [X in op _ X]opC. Qed. - -Hypothesis opyy : idempotent op. - -Local Notation oop := (oAC opA opC). - -Lemma opACE x y : oop (Some x) (Some y) = some (op x y). Proof. by []. Qed. - -Lemma oopA_subdef : associative oop. -Proof. by move=> [x|] [y|] [z|]//; rewrite /oAC/= opA. Qed. - -Lemma oopx1_subdef : left_id None oop. Proof. by case. Qed. -Lemma oop1x_subdef : right_id None oop. Proof. by []. Qed. - -Lemma oopC_subdef : commutative oop. -Proof. by move=> [x|] [y|]//; rewrite /oAC/= opC. Qed. - -Canonical opAC_law := Monoid.Law oopA_subdef oopx1_subdef oop1x_subdef. -Canonical opAC_com_law := Monoid.ComLaw oopC_subdef. - -Context [x : R]. - -Lemma some_big_AC [I : Type] r P (F : I -> R) : - Some (\big[op/x]_(i <- r | P i) F i) = - oop (\big[oop/None]_(i <- r | P i) Some (F i)) (Some x). -Proof. by elim/big_rec2 : _ => //= i [y|] _ Pi [] -> //=; rewrite opA. Qed. - -Lemma big_ACE [I : Type] r P (F : I -> R) : - \big[op/x]_(i <- r | P i) F i = - odflt x (oop (\big[oop/None]_(i <- r | P i) Some (F i)) (Some x)). -Proof. by apply: Some_inj; rewrite some_big_AC. Qed. - -Lemma big_undup_AC [I : eqType] r P (F : I -> R) (opK : idempotent op) : - \big[op/x]_(i <- undup r | P i) F i = \big[op/x]_(i <- r | P i) F i. -Proof. by rewrite !big_ACE !big_undup//; case=> //= ?; rewrite /oAC/= opK. Qed. - -Lemma perm_big_AC [I : eqType] [r] s [P : pred I] [F : I -> R] : - perm_eq r s -> \big[op/x]_(i <- r | P i) F i = \big[op/x]_(i <- s | P i) F i. -Proof. by rewrite !big_ACE => /(@perm_big _ _)->. Qed. - -Section Id. -Hypothesis opxx : op x x = x. - -Lemma big_const_idem I (r : seq I) P : \big[op/x]_(i <- r | P i) x = x. -Proof. by elim/big_ind : _ => // _ _ -> ->. Qed. - -Lemma big_id_idem I (r : seq I) P F : - op (\big[op/x]_(i <- r | P i) F i) x = \big[op/x]_(i <- r | P i) F i. -Proof. by elim/big_rec : _ => // ? ? ?; rewrite -opA => ->. Qed. - -Lemma big_mkcond_idem I r (P : pred I) F : - \big[op/x]_(i <- r | P i) F i = \big[op/x]_(i <- r) (if P i then F i else x). -Proof. -elim: r => [|i r]; rewrite ?(big_nil, big_cons)//. -by case: ifPn => Pi ->//; rewrite -[in LHS]big_id_idem. -Qed. - -Lemma big_split_idem I r (P : pred I) F1 F2 : - \big[op/x]_(i <- r | P i) op (F1 i) (F2 i) = - op (\big[op/x]_(i <- r | P i) F1 i) (\big[op/x]_(i <- r | P i) F2 i). -Proof. by elim/big_rec3 : _ => [//|i ? ? _ _ ->]; rewrite // opCA -!opA opCA. Qed. - -Lemma big_id_idem_AC I (r : seq I) P F : - \big[op/x]_(i <- r | P i) op (F i) x = \big[op/x]_(i <- r | P i) F i. -Proof. by rewrite big_split_idem big_const_idem ?big_id_idem. Qed. - -Lemma bigID_idem I r (a P : pred I) F : - \big[op/x]_(i <- r | P i) F i = - op (\big[op/x]_(i <- r | P i && a i) F i) - (\big[op/x]_(i <- r | P i && ~~ a i) F i). -Proof. -rewrite -big_id_idem_AC big_mkcond_idem !(big_mkcond_idem _ _ F) -big_split_idem. -by apply: eq_bigr => i; case: ifPn => //=; case: ifPn. -Qed. - -End Id. - -Lemma big_rem_AC (I : eqType) (r : seq I) z (P : pred I) F : z \in r -> - \big[op/x]_(y <- r | P y) F y = - if P z then op (F z) (\big[op/x]_(y <- rem z r | P y) F y) - else \big[op/x]_(y <- rem z r | P y) F y. -Proof. -by move=> /[!big_ACE] /(big_rem _)->//; case: ifP; case: (bigop _ _ _) => /=. -Qed. - -Lemma bigD1_AC (I : finType) j (P : pred I) F : P j -> - \big[op/x]_(i | P i) F i = op (F j) (\big[op/x]_(i | P i && (i != j)) F i). -Proof. by move=> /[!big_ACE] /(bigD1 _)->; case: (bigop _ _) => /=. Qed. - -Variable le : rel R. -Hypothesis le_refl : reflexive le. -Hypothesis op_incr : forall x y, le x (op x y). - -Lemma sub_big I [s] (P P' : {pred I}) (F : I -> R) : (forall i, P i -> P' i) -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s | P' i) F i). -Proof. -move=> PP'; rewrite !big_ACE (bigID P P')/=. -under [in X in le _ X]eq_bigl do rewrite (andb_idl (PP' _)). -case: (bigop _ _ _) (bigop _ _ _) => [y|] [z|]//=. - by rewrite opAC op_incr. -by rewrite opC op_incr. -Qed. - -Lemma sub_big_seq (I : eqType) s s' P (F : I -> R) : - (forall i, count_mem i s <= count_mem i s')%N -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s' | P i) F i). -Proof. -rewrite !big_ACE => /count_subseqP[_ /subseqP[m sm ->]]/(perm_big _)->. -by rewrite big_mask big_tnth// -!big_ACE sub_big// => j /andP[]. -Qed. - -Lemma sub_big_seq_cond (I : eqType) s s' P P' (F : I -> R) : - (forall i, count_mem i (filter P s) <= count_mem i (filter P' s'))%N -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s' | P' i) F i). -Proof. by move=> /(sub_big_seq xpredT F); rewrite !big_filter. Qed. - -Lemma uniq_sub_big (I : eqType) s s' P (F : I -> R) : uniq s -> uniq s' -> - {subset s <= s'} -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s' | P i) F i). -Proof. -move=> us us' ss'; rewrite sub_big_seq => // i; rewrite !count_uniq_mem//. -by have /implyP := ss' i; case: (_ \in s) (_ \in s') => [] []. -Qed. - -Lemma uniq_sub_big_cond (I : eqType) s s' P P' (F : I -> R) : - uniq (filter P s) -> uniq (filter P' s') -> - {subset [seq i <- s | P i] <= [seq i <- s' | P' i]} -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s' | P' i) F i). -Proof. by move=> u u' /(uniq_sub_big xpredT F u u'); rewrite !big_filter. Qed. - -Lemma sub_big_idem (I : eqType) s s' P (F : I -> R) : - {subset s <= s'} -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s' | P i) F i). -Proof. -move=> ss'; rewrite -big_undup_AC// -[X in le _ X]big_undup_AC//. -by rewrite uniq_sub_big ?undup_uniq// => i; rewrite !mem_undup; apply: ss'. -Qed. - -Lemma sub_big_idem_cond (I : eqType) s s' P P' (F : I -> R) : - {subset [seq i <- s | P i] <= [seq i <- s' | P' i]} -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s' | P' i) F i). -Proof. by move=> /(sub_big_idem xpredT F); rewrite !big_filter. Qed. - -Lemma sub_in_big [I : eqType] (s : seq I) (P P' : {pred I}) (F : I -> R) : - {in s, forall i, P i -> P' i} -> - le (\big[op/x]_(i <- s | P i) F i) (\big[op/x]_(i <- s | P' i) F i). -Proof. -move=> PP'; apply: sub_big_seq_cond => i; rewrite leq_count_subseq//. -rewrite subseq_filter filter_subseq andbT; apply/allP => j. -by rewrite !mem_filter => /andP[/PP'/[apply]->]. -Qed. - -Lemma le_big_ord n m [P : {pred nat}] [F : nat -> R] : (n <= m)%N -> - le (\big[op/x]_(i < n | P i) F i) (\big[op/x]_(i < m | P i) F i). -Proof. -by move=> nm; rewrite (big_ord_widen_cond m)// sub_big => //= ? /andP[]. -Qed. - -Lemma subset_big [I : finType] [A A' P : {pred I}] (F : I -> R) : - A \subset A' -> - le (\big[op/x]_(i in A | P i) F i) (\big[op/x]_(i in A' | P i) F i). -Proof. -move=> AA'; apply: sub_big => y /andP[yA yP]; apply/andP; split => //. -exact: subsetP yA. -Qed. - -Lemma subset_big_cond (I : finType) (A A' P P' : {pred I}) (F : I -> R) : - [set i in A | P i] \subset [set i in A' | P' i] -> - le (\big[op/x]_(i in A | P i) F i) (\big[op/x]_(i in A' | P' i) F i). -Proof. by move=> /subsetP AP; apply: sub_big => i; have /[!inE] := AP i. Qed. - -Lemma le_big_nat_cond n m n' m' (P P' : {pred nat}) (F : nat -> R) : - (n' <= n)%N -> (m <= m')%N -> (forall i, (n <= i < m)%N -> P i -> P' i) -> - le (\big[op/x]_(n <= i < m | P i) F i) (\big[op/x]_(n' <= i < m' | P' i) F i). -Proof. -move=> len'n lemm' PP'i; rewrite uniq_sub_big_cond ?filter_uniq ?iota_uniq//. -move=> i; rewrite !mem_filter !mem_index_iota => /and3P[Pi ni im]. -by rewrite PP'i ?ni//= (leq_trans _ ni)// (leq_trans im). -Qed. - -Lemma le_big_nat n m n' m' [P] [F : nat -> R] : (n' <= n)%N -> (m <= m')%N -> - le (\big[op/x]_(n <= i < m | P i) F i) (\big[op/x]_(n' <= i < m' | P i) F i). -Proof. by move=> len'n lemm'; rewrite le_big_nat_cond. Qed. - -Lemma le_big_ord_cond n m (P P' : {pred nat}) (F : nat -> R) : - (n <= m)%N -> (forall i : 'I_n, P i -> P' i) -> - le (\big[op/x]_(i < n | P i) F i) (\big[op/x]_(i < m | P' i) F i). -Proof. -move=> nm PP'; rewrite -!big_mkord le_big_nat_cond//= => i ni. -by have := PP' (Ordinal ni). -Qed. - -End SemiGroupProperties. - -Section bigmaxmin. -Local Notation max := Order.max. -Local Notation min := Order.min. -Local Open Scope order_scope. -Variables (d : _) (T : porderType d). -Variables (I : Type) (r : seq I) (f : I -> T) (x0 x : T) (P : pred I). - -Lemma bigmax_le : - x0 <= x -> (forall i, P i -> f i <= x) -> \big[max/x0]_(i <- r | P i) f i <= x. -Proof. by move=> ? ?; elim/big_ind: _ => // *; rewrite maxEle; case: ifPn. Qed. - -Lemma bigmax_lt : - x0 < x -> (forall i, P i -> f i < x) -> \big[max/x0]_(i <- r | P i) f i < x. -Proof. by move=> ? ?; elim/big_ind: _ => // *; rewrite maxElt; case: ifPn. Qed. - -Lemma lt_bigmin : - x < x0 -> (forall i, P i -> x < f i) -> x < \big[min/x0]_(i <- r | P i) f i. -Proof. by move=> ? ?; elim/big_ind: _ => // *; rewrite minElt; case: ifPn. Qed. - -Lemma le_bigmin : - x <= x0 -> (forall i, P i -> x <= f i) -> x <= \big[min/x0]_(i <- r | P i) f i. -Proof. by move=> ? ?; elim/big_ind: _ => // *; rewrite minEle; case: ifPn. Qed. - -End bigmaxmin. - -Section bigmax. -Local Notation max := Order.max. -Local Open Scope order_scope. -Variables (d : unit) (T : orderType d). - -Section bigmax_Type. -Variables (I : Type) (r : seq I) (x : T). -Implicit Types (P a : pred I) (F : I -> T). - -Lemma bigmax_mkcond P F : \big[max/x]_(i <- r | P i) F i = - \big[max/x]_(i <- r) (if P i then F i else x). -Proof. by rewrite big_mkcond_idem ?maxxx//; [exact: maxA|exact: maxC]. Qed. - -Lemma bigmax_split P F1 F2 : - \big[max/x]_(i <- r | P i) (max (F1 i) (F2 i)) = - max (\big[max/x]_(i <- r | P i) F1 i) (\big[max/x]_(i <- r | P i) F2 i). -Proof. by rewrite big_split_idem ?maxxx//; [exact: maxA|exact: maxC]. Qed. - -Lemma bigmax_idl P F : - \big[max/x]_(i <- r | P i) F i = max x (\big[max/x]_(i <- r | P i) F i). -Proof. by rewrite maxC big_id_idem ?maxxx//; exact: maxA. Qed. - -Lemma bigmax_idr P F : - \big[max/x]_(i <- r | P i) F i = max (\big[max/x]_(i <- r | P i) F i) x. -Proof. by rewrite [LHS]bigmax_idl maxC. Qed. - -Lemma bigmaxID a P F : \big[max/x]_(i <- r | P i) F i = - max (\big[max/x]_(i <- r | P i && a i) F i) - (\big[max/x]_(i <- r | P i && ~~ a i) F i). -Proof. by rewrite (bigID_idem maxA maxC _ _ a) ?maxxx. Qed. - -End bigmax_Type. - -Let le_maxr_id (x y : T) : x <= max x y. Proof. by rewrite le_maxr lexx. Qed. - -Lemma sub_bigmax [x0] I s (P P' : {pred I}) (F : I -> T) : - (forall i, P i -> P' i) -> - \big[max/x0]_(i <- s | P i) F i <= \big[max/x0]_(i <- s | P' i) F i. -Proof. exact: (sub_big maxA maxC). Qed. - -Lemma sub_bigmax_seq [x0] (I : eqType) s s' P (F : I -> T) : {subset s <= s'} -> - \big[max/x0]_(i <- s | P i) F i <= \big[max/x0]_(i <- s' | P i) F i. -Proof. exact: (sub_big_idem maxA maxC maxxx). Qed. - -Lemma sub_bigmax_cond [x0] (I : eqType) s s' P P' (F : I -> T) : - {subset [seq i <- s | P i] <= [seq i <- s' | P' i]} -> - \big[max/x0]_(i <- s | P i) F i <= \big[max/x0]_(i <- s' | P' i) F i. -Proof. exact: (sub_big_idem_cond maxA maxC maxxx). Qed. - -Lemma sub_in_bigmax [x0] [I : eqType] (s : seq I) (P P' : {pred I}) (F : I -> T) : - {in s, forall i, P i -> P' i} -> - \big[max/x0]_(i <- s | P i) F i <= \big[max/x0]_(i <- s | P' i) F i. -Proof. exact: (sub_in_big maxA maxC). Qed. - -Lemma le_bigmax_nat [x0] n m n' m' P (F : nat -> T) : n' <= n -> m <= m' -> - \big[max/x0]_(n <= i < m | P i) F i <= \big[max/x0]_(n' <= i < m' | P i) F i. -Proof. exact: (le_big_nat maxA maxC). Qed. - -Lemma le_bigmax_nat_cond [x0] n m n' m' (P P' : {pred nat}) (F : nat -> T) : - (n' <= n)%N -> (m <= m')%N -> (forall i, n <= i < m -> P i -> P' i) -> - \big[max/x0]_(n <= i < m | P i) F i <= \big[max/x0]_(n' <= i < m' | P' i) F i. -Proof. exact: (le_big_nat_cond maxA maxC). Qed. - -Lemma le_bigmax_ord [x0] n m (P : {pred nat}) (F : nat -> T) : (n <= m)%N -> - \big[max/x0]_(i < n | P i) F i <= \big[max/x0]_(i < m | P i) F i. -Proof. exact: (le_big_ord maxA maxC). Qed. - -Lemma le_bigmax_ord_cond [x0] n m (P P' : {pred nat}) (F : nat -> T) : - (n <= m)%N -> (forall i : 'I_n, P i -> P' i) -> - \big[max/x0]_(i < n | P i) F i <= \big[max/x0]_(i < m | P' i) F i. -Proof. exact: (le_big_ord_cond maxA maxC). Qed. - -Lemma subset_bigmax [x0] [I : finType] (A A' P : {pred I}) (F : I -> T) : - A \subset A' -> - \big[max/x0]_(i in A | P i) F i <= \big[max/x0]_(i in A' | P i) F i. -Proof. exact: (subset_big maxA maxC). Qed. - -Lemma subset_bigmax_cond [x0] (I : finType) (A A' P P' : {pred I}) (F : I -> T) : - [set i in A | P i] \subset [set i in A' | P' i] -> - \big[max/x0]_(i in A | P i) F i <= \big[max/x0]_(i in A' | P' i) F i. -Proof. exact: (subset_big_cond maxA maxC). Qed. - -Section bigmax_finType. -Variables (I : finType) (x : T). -Implicit Types (P : pred I) (F : I -> T). - -Lemma bigmaxD1 j P F : P j -> - \big[max/x]_(i | P i) F i = max (F j) (\big[max/x]_(i | P i && (i != j)) F i). -Proof. by move/(bigD1_AC maxA maxC) ->. Qed. - -Lemma le_bigmax_cond j P F : P j -> F j <= \big[max/x]_(i | P i) F i. -Proof. by move=> Pj; rewrite (bigmaxD1 _ Pj) le_maxr lexx. Qed. - -Lemma le_bigmax F j : F j <= \big[max/x]_i F i. -Proof. exact: le_bigmax_cond. Qed. - -(* NB: as of [2022-08-02], bigop.bigmax_sup already exists for nat *) -Lemma bigmax_sup j P m F : P j -> m <= F j -> m <= \big[max/x]_(i | P i) F i. -Proof. by move=> Pj ?; apply: le_trans (le_bigmax_cond _ Pj). Qed. - -Lemma bigmax_leP m P F : reflect (x <= m /\ forall i, P i -> F i <= m) - (\big[max/x]_(i | P i) F i <= m). -Proof. -apply: (iffP idP) => [|[? ?]]; last exact: bigmax_le. -rewrite bigmax_idl le_maxl => /andP[-> leFm]; split=> // i Pi. -by apply: le_trans leFm; exact: le_bigmax_cond. -Qed. - -Lemma bigmax_ltP m P F : - reflect (x < m /\ forall i, P i -> F i < m) (\big[max/x]_(i | P i) F i < m). -Proof. -apply: (iffP idP) => [|[? ?]]; last exact: bigmax_lt. -rewrite bigmax_idl lt_maxl => /andP[-> ltFm]; split=> // i Pi. -by apply: le_lt_trans ltFm; exact: le_bigmax_cond. -Qed. - -Lemma bigmax_eq_arg j P F : P j -> (forall i, P i -> x <= F i) -> - \big[max/x]_(i | P i) F i = F [arg max_(i > j | P i) F i]. -Proof. -move=> Pi0; case: arg_maxP => //= i Pi PF PxF. -apply/eqP; rewrite eq_le le_bigmax_cond // andbT. -by apply/bigmax_leP; split => //; exact: PxF. -Qed. - -Lemma eq_bigmax j P F : P j -> (forall i, P i -> x <= F i) -> - {i0 | i0 \in P & \big[max/x]_(i | P i) F i = F i0}. -Proof. -by move=> Pi0 Hx; rewrite (bigmax_eq_arg Pi0) //; eexists => //; case:arg_maxP. -Qed. - -Lemma le_bigmax2 P F1 F2 : (forall i, P i -> F1 i <= F2 i) -> - \big[max/x]_(i | P i) F1 i <= \big[max/x]_(i | P i) F2 i. -Proof. -move=> FG; elim/big_ind2 : _ => // a b e f ba fe. -rewrite le_maxr 2!le_maxl ba fe /= andbT; have [//|/= af] := leP f a. -by rewrite (le_trans ba) // (le_trans _ fe) // ltW. -Qed. - -End bigmax_finType. - -End bigmax. -Arguments bigmax_mkcond {d T I r}. -Arguments bigmaxID {d T I r}. -Arguments bigmaxD1 {d T I x} j. -Arguments bigmax_sup {d T I x} j. -Arguments bigmax_eq_arg {d T I} x j. -Arguments eq_bigmax {d T I x} j. - -Section bigmin. -Local Notation min := Order.min. -Local Open Scope order_scope. -Variables (d : _) (T : orderType d). - -Section bigmin_Type. -Variable (I : Type) (r : seq I) (x : T). -Implicit Types (P a : pred I) (F : I -> T). - -Lemma bigmin_mkcond P F : \big[min/x]_(i <- r | P i) F i = - \big[min/x]_(i <- r) (if P i then F i else x). -Proof. rewrite big_mkcond_idem ?minxx//; [exact: minA|exact: minC]. Qed. - -Lemma bigmin_split P F1 F2 : - \big[min/x]_(i <- r | P i) (min (F1 i) (F2 i)) = - min (\big[min/x]_(i <- r | P i) F1 i) (\big[min/x]_(i <- r | P i) F2 i). -Proof. rewrite big_split_idem ?minxx//; [exact: minA|exact: minC]. Qed. - -Lemma bigmin_idl P F : - \big[min/x]_(i <- r | P i) F i = min x (\big[min/x]_(i <- r | P i) F i). -Proof. rewrite minC big_id_idem ?minxx//; exact: minA. Qed. - -Lemma bigmin_idr P F : - \big[min/x]_(i <- r | P i) F i = min (\big[min/x]_(i <- r | P i) F i) x. -Proof. by rewrite [LHS]bigmin_idl minC. Qed. - -Lemma bigminID a P F : \big[min/x]_(i <- r | P i) F i = - min (\big[min/x]_(i <- r | P i && a i) F i) - (\big[min/x]_(i <- r | P i && ~~ a i) F i). -Proof. by rewrite (bigID_idem minA minC _ _ a) ?minxx. Qed. - -End bigmin_Type. - -Let le_minr_id (x y : T) : x >= min x y. Proof. by rewrite le_minl lexx. Qed. - -Lemma sub_bigmin [x0] I s (P P' : {pred I}) (F : I -> T) : - (forall i, P' i -> P i) -> - \big[min/x0]_(i <- s | P i) F i <= \big[min/x0]_(i <- s | P' i) F i. -Proof. exact: (sub_big minA minC ge_refl). Qed. - -Lemma sub_bigmin_cond [x0] (I : eqType) s s' P P' (F : I -> T) : - {subset [seq i <- s | P i] <= [seq i <- s' | P' i]} -> - \big[min/x0]_(i <- s' | P' i) F i <= \big[min/x0]_(i <- s | P i) F i. -Proof. exact: (sub_big_idem_cond minA minC minxx ge_refl). Qed. - -Lemma sub_bigmin_seq [x0] (I : eqType) s s' P (F : I -> T) : {subset s' <= s} -> - \big[min/x0]_(i <- s | P i) F i <= \big[min/x0]_(i <- s' | P i) F i. -Proof. exact: (sub_big_idem minA minC minxx ge_refl). Qed. - -Lemma sub_in_bigmin [x0] [I : eqType] (s : seq I) (P P' : {pred I}) (F : I -> T) : - {in s, forall i, P' i -> P i} -> - \big[min/x0]_(i <- s | P i) F i <= \big[min/x0]_(i <- s | P' i) F i. -Proof. exact: (sub_in_big minA minC ge_refl). Qed. - -Lemma le_bigmin_nat [x0] n m n' m' P (F : nat -> T) : - (n <= n')%N -> (m' <= m)%N -> - \big[min/x0]_(n <= i < m | P i) F i <= \big[min/x0]_(n' <= i < m' | P i) F i. -Proof. exact: (le_big_nat minA minC ge_refl). Qed. - -Lemma le_bigmin_nat_cond [x0] n m n' m' (P P' : pred nat) (F : nat -> T) : - (n <= n')%N -> (m' <= m)%N -> (forall i, n' <= i < m' -> P' i -> P i) -> - \big[min/x0]_(n <= i < m | P i) F i <= \big[min/x0]_(n' <= i < m' | P' i) F i. -Proof. exact: (le_big_nat_cond minA minC ge_refl). Qed. - -Lemma le_bigmin_ord [x0] n m (P : pred nat) (F : nat -> T) : (m <= n)%N -> - \big[min/x0]_(i < n | P i) F i <= \big[min/x0]_(i < m | P i) F i. -Proof. exact: (le_big_ord minA minC ge_refl). Qed. - -Lemma le_bigmin_ord_cond [x0] n m (P P' : pred nat) (F : nat -> T) : - (m <= n)%N -> (forall i : 'I_m, P' i -> P i) -> - \big[min/x0]_(i < n | P i) F i <= \big[min/x0]_(i < m | P' i) F i. -Proof. exact: (le_big_ord_cond minA minC ge_refl). Qed. - -Lemma subset_bigmin [x0] [I : finType] [A A' P : {pred I}] (F : I -> T) : - A' \subset A -> - \big[min/x0]_(i in A | P i) F i <= \big[min/x0]_(i in A' | P i) F i. -Proof. exact: (subset_big minA minC ge_refl). Qed. - -Lemma subset_bigmin_cond [x0] (I : finType) (A A' P P' : {pred I}) (F : I -> T) : - [set i in A' | P' i] \subset [set i in A | P i] -> - \big[min/x0]_(i in A | P i) F i <= \big[min/x0]_(i in A' | P' i) F i. -Proof. exact: (subset_big_cond minA minC ge_refl). Qed. - -Section bigmin_finType. -Variable (I : finType) (x : T). -Implicit Types (P : pred I) (F : I -> T). - -Lemma bigminD1 j P F : P j -> - \big[min/x]_(i | P i) F i = min (F j) (\big[min/x]_(i | P i && (i != j)) F i). -Proof. by move/(bigD1_AC minA minC) ->. Qed. - -Lemma bigmin_le_cond j P F : P j -> \big[min/x]_(i | P i) F i <= F j. -Proof. -have := mem_index_enum j; rewrite unlock; elim: (index_enum I) => //= i l ih. -rewrite inE => /orP [/eqP-> ->|/ih leminlfi Pi]; first by rewrite le_minl lexx. -by case: ifPn => Pj; [rewrite le_minl leminlfi// orbC|exact: leminlfi]. -Qed. - -Lemma bigmin_le j F : \big[min/x]_i F i <= F j. -Proof. exact: bigmin_le_cond. Qed. - -Lemma bigmin_inf j P m F : P j -> F j <= m -> \big[min/x]_(i | P i) F i <= m. -Proof. by move=> Pj ?; apply: le_trans (bigmin_le_cond _ Pj) _. Qed. - -Lemma bigmin_geP m P F : reflect (m <= x /\ forall i, P i -> m <= F i) - (m <= \big[min/x]_(i | P i) F i). -Proof. -apply: (iffP idP) => [lemFi|[lemx lemPi]]; [split|exact: le_bigmin]. -- by rewrite (le_trans lemFi)// bigmin_idl le_minl lexx. -- by move=> i Pi; rewrite (le_trans lemFi)// (bigminD1 _ Pi)// le_minl lexx. -Qed. - -Lemma bigmin_gtP m P F : - reflect (m < x /\ forall i, P i -> m < F i) (m < \big[min/x]_(i | P i) F i). -Proof. -apply: (iffP idP) => [lemFi|[lemx lemPi]]; [split|exact: lt_bigmin]. -- by rewrite (lt_le_trans lemFi)// bigmin_idl le_minl lexx. -- by move=> i Pi; rewrite (lt_le_trans lemFi)// (bigminD1 _ Pi)// le_minl lexx. -Qed. - -Lemma bigmin_eq_arg j P F : P j -> (forall i, P i -> F i <= x) -> - \big[min/x]_(i | P i) F i = F [arg min_(i < j | P i) F i]. -Proof. -move=> Pi0; case: arg_minP => //= i Pi PF PFx. -apply/eqP; rewrite eq_le bigmin_le_cond //=. -by apply/bigmin_geP; split => //; exact: PFx. -Qed. - -Lemma eq_bigmin j P F : P j -> (forall i, P i -> F i <= x) -> - {i0 | i0 \in P & \big[min/x]_(i | P i) F i = F i0}. -Proof. -by move=> Pi0 Hx; rewrite (bigmin_eq_arg Pi0) //; eexists => //; case:arg_minP. -Qed. - -End bigmin_finType. - -End bigmin. -Arguments bigmin_mkcond {d T I r}. -Arguments bigminID {d T I r}. -Arguments bigminD1 {d T I x} j. -Arguments bigmin_inf {d T I x} j. -Arguments bigmin_eq_arg {d T I} x j. -Arguments eq_bigmin {d T I x} j. - -(************************************) -(* End of MathComp 1.16.0 additions *) -(************************************) +(*******************************) +(* MathComp > 1.16.0 additions *) +(*******************************) Reserved Notation "`1- x" (format "`1- x", at level 2). @@ -1034,10 +492,10 @@ Lemma onem_ge0 r : r <= 1 -> 0 <= `1-r. Proof. by rewrite le_eqVlt => /predU1P[->|/onem_gt0/ltW]; rewrite ?onem1. Qed. Lemma onem_le1 r : 0 <= r -> `1-r <= 1. -Proof. by rewrite ler_subl_addr ler_addl. Qed. +Proof. by rewrite lerBlDr lerDl. Qed. Lemma onem_lt1 r : 0 < r -> `1-r < 1. -Proof. by rewrite ltr_subl_addr ltr_addl. Qed. +Proof. by rewrite ltrBlDr ltrDl. Qed. Lemma onemX_ge0 r n : 0 <= r -> r <= 1 -> 0 <= `1-(r ^+ n). Proof. by move=> ? ?; rewrite subr_ge0 exprn_ile1. Qed. @@ -1071,15 +529,15 @@ Lemma ler_gtP (R : numFieldType) (x y : R) : Proof. apply: (equivP (ler_addgt0Pr _ _)); split=> [xy z|xz e e_gt0]. by rewrite -subr_gt0 => /xy; rewrite addrC addrNK. -by apply: xz; rewrite -[ltLHS]addr0 ler_lt_add. +by apply: xz; rewrite -[ltLHS]addr0 ler_ltD. Qed. Lemma ler_ltP (R : numFieldType) (x y : R) : reflect (forall z, z < x -> z <= y) (x <= y). Proof. apply: (equivP (ler_addgt0Pr _ _)); split=> [xy z|xz e e_gt0]. - by rewrite -subr_gt0 => /xy; rewrite addrCA -[leLHS]addr0 ler_add2l subr_ge0. -by rewrite -ler_subl_addr xz// -[ltRHS]subr0 ler_lt_sub. + by rewrite -subr_gt0 => /xy; rewrite addrCA -[leLHS]addr0 lerD2l subr_ge0. +by rewrite -lerBlDr xz// -[ltRHS]subr0 ler_ltB. Qed. Definition inv_fun T (R : unitRingType) (f : T -> R) x := (f x)^-1%R. @@ -1256,7 +714,7 @@ Let a4gt0 : 0 < 4%:R * a. Proof. by rewrite mulr_gt0 ?ltr0n. Qed. Lemma deg2_poly_min x : p.[- b / (2%:R * a)] <= p.[x]. Proof. rewrite [p]deg2_poly_canonical ?pnatr_eq0// -/a -/b -/c /delta !hornerE/=. -by rewrite ler_pmul2l// ler_add2r addrC mulNr subrr ?mulr0 ?expr0n sqr_ge0. +by rewrite ler_pM2l// lerD2r addrC mulNr subrr ?mulr0 ?expr0n sqr_ge0. Qed. Lemma deg2_poly_minE : p.[- b / (2%:R * a)] = - delta / (4%:R * a). @@ -1269,9 +727,9 @@ Qed. Lemma deg2_poly_ge0 : reflect (forall x, 0 <= p.[x]) (delta <= 0). Proof. apply/(iffP idP) => [dlt0 x | /(_ (- b / (2%:R * a)))]; last first. - by rewrite deg2_poly_minE ler_pdivl_mulr// mul0r oppr_ge0. + by rewrite deg2_poly_minE ler_pdivlMr// mul0r oppr_ge0. apply: le_trans (deg2_poly_min _). -by rewrite deg2_poly_minE ler_pdivl_mulr// mul0r oppr_ge0. +by rewrite deg2_poly_minE ler_pdivlMr// mul0r oppr_ge0. Qed. End Pdeg2RealConvex. @@ -1356,7 +814,7 @@ pose r2 := (- b + Num.sqrt delta) / (2%:R * a). pose x0 := Num.max (r1 + 1) (r2 + 1). move: (pge0 x0); rewrite (Real.deg2_poly_factor degp' (ltW dge0)). rewrite !hornerE/= -mulrA nmulr_rge0// leNgt => /negbTE<-. -by apply: mulr_gt0; rewrite subr_gt0 lt_maxr ltr_addl ltr01 ?orbT. +by apply: mulr_gt0; rewrite subr_gt0 lt_maxr ltrDl ltr01 ?orbT. Qed. End Degle2PolyRealClosedConvex. @@ -1434,7 +892,7 @@ Arguments le_bigmax_seq {d T} x {I r} i0 P. (* NB: PR 1079 to MathComp in progress *) Lemma gerBl {R : numDomainType} (x y : R) : 0 <= y -> x - y <= x. -Proof. by move=> y0; rewrite ler_subl_addl ler_addr. Qed. +Proof. by move=> y0; rewrite lerBlDl lerDr. Qed. (* the following appears in MathComp 2.1.0 and MathComp 1.18.0 *) Section normr. diff --git a/classical/set_interval.v b/classical/set_interval.v index 7d716fa91..7d13ca4bb 100644 --- a/classical/set_interval.v +++ b/classical/set_interval.v @@ -196,8 +196,8 @@ Qed. Lemma lb_ubN E x : lbound E x <-> ubound (-%R @` E) (- x). Proof. split=> [/lbP xlbE|/ubP xlbE]. -by move=> _ [z Ez <-]; rewrite ler_oppr opprK; apply xlbE. -by move=> y Ey; rewrite -(opprK x) ler_oppl; apply xlbE; exists y. +by move=> _ [z Ez <-]; rewrite lerNr opprK; apply xlbE. +by move=> y Ey; rewrite -(opprK x) lerNl; apply xlbE; exists y. Qed. Lemma ub_lbN E x : ubound E x <-> lbound (-%R @` E) (- x). @@ -243,10 +243,10 @@ Qed. Lemma has_lbPn E : ~ has_lbound E <-> (forall x, exists2 y, E y & y < x). Proof. split=> [/has_lb_ubN /has_ubPn NEnub x|Enlb /has_lb_ubN]. - have [y ENy ltxy] := NEnub (- x); exists (- y); rewrite 1?ltr_oppl //. + have [y ENy ltxy] := NEnub (- x); exists (- y); rewrite 1?ltrNl //. by case: ENy => z Ez <-; rewrite opprK. apply/has_ubPn => x; have [y Ey ltyx] := Enlb (- x). -exists (- y); last by rewrite ltr_oppr. +exists (- y); last by rewrite ltrNr. by exists y => //; rewrite opprK. Qed. @@ -257,10 +257,10 @@ move: a => [b r|[|]] _ //. suff: ~ has_lbound `]-oo, r[%classic. by case: b => //; apply/contra_not/subset_has_lbound => x /ltW. apply/has_lbPn => x; exists (minr (r - 1) (x - 1)). - by rewrite !set_itvE/= lt_minl ltr_subl_addr ltr_addl ltr01. - by rewrite lt_minl orbC ltr_subl_addr ltr_addl ltr01. + by rewrite !set_itvE/= lt_minl ltrBlDr ltrDl ltr01. + by rewrite lt_minl orbC ltrBlDr ltrDl ltr01. case=> r /(_ (r - 1)) /=; rewrite in_itv /= => /(_ erefl). -by apply/negP; rewrite -ltNge ltr_subl_addr ltr_addl. +by apply/negP; rewrite -ltNge ltrBlDr ltrDl. Qed. Lemma hasNubound_itv (a : itv_bound R) : a != +oo%O -> @@ -271,9 +271,9 @@ move: a => [b r|[|]] _ //. case: b => //; apply/contra_not/subset_has_ubound => x. by rewrite !set_itvE => /ltW. apply/has_ubPn => x; rewrite !set_itvE; exists (maxr (r + 1) (x + 1)); - by rewrite ?in_itv /= ?andbT lt_maxr ltr_addl ltr01 // orbT. + by rewrite ?in_itv /= ?andbT lt_maxr ltrDl ltr01 // orbT. case=> r /(_ (r + 1)) /=; rewrite in_itv /= => /(_ erefl). -by apply/negP; rewrite -ltNge ltr_addl. +by apply/negP; rewrite -ltNge ltrDl. Qed. End interval_hasNbound. @@ -290,9 +290,9 @@ Lemma opp_itv_bnd_infty (R : numDomainType) (x : R) b : [set` Interval -oo%O (BSide (negb b) (- x))]. Proof. rewrite predeqE => /= r; split=> [[y xy <-]|xr]. - by case: b xy; rewrite !in_itv/= andbT (ler_opp2, ltr_opp2). + by case: b xy; rewrite !in_itv/= andbT (lerN2, ltrN2). exists (- r); rewrite ?opprK //. -by case: b xr; rewrite !in_itv/= andbT (ler_oppr, ltr_oppr). +by case: b xr; rewrite !in_itv/= andbT (lerNr, ltrNr). Qed. Lemma opp_itv_infty_bnd (R : numDomainType) (x : R) b : @@ -300,9 +300,9 @@ Lemma opp_itv_infty_bnd (R : numDomainType) (x : R) b : [set` Interval (BSide (negb b) (- x)) +oo%O]. Proof. rewrite predeqE => /= r; split=> [[y xy <-]|xr]. - by case: b xy; rewrite !in_itv/= andbT (ler_opp2, ltr_opp2). + by case: b xy; rewrite !in_itv/= andbT (lerN2, ltrN2). exists (- r); rewrite ?opprK //. -by case: b xr; rewrite !in_itv/= andbT (ler_oppl, ltr_oppl). +by case: b xr; rewrite !in_itv/= andbT (lerNl, ltrNl). Qed. Lemma opp_itv_bnd_bnd (R : numDomainType) a b (x y : R) : @@ -310,17 +310,17 @@ Lemma opp_itv_bnd_bnd (R : numDomainType) a b (x y : R) : [set` Interval (BSide (~~ b) (- y)) (BSide (~~ a) (- x))]. Proof. rewrite predeqE => /= r; split => [[{}r + <-]|]. - by rewrite !in_itv/= 2!lteif_opp2 negbK andbC. + by rewrite !in_itv/= 2!lteifN2 negbK andbC. rewrite in_itv/= negbK => yrab. -by exists (- r); rewrite ?opprK// !in_itv lteif_oppr andbC lteif_oppl. +by exists (- r); rewrite ?opprK// !in_itv lteifNr andbC lteifNl. Qed. Lemma opp_itvoo (R : numDomainType) (x y : R) : -%R @` `]x, y[%classic = `](- y), (- x)[%classic. Proof. rewrite predeqE => /= r; split => [[{}r + <-]|]. - by rewrite !in_itv/= !ltr_opp2 andbC. -by exists (- r); rewrite ?opprK// !in_itv/= ltr_oppl ltr_oppr andbC. + by rewrite !in_itv/= !ltrN2 andbC. +by exists (- r); rewrite ?opprK// !in_itv/= ltrNl ltrNr andbC. Qed. (** lemmas between itv and set-theoretic operations *) @@ -357,7 +357,7 @@ Variable R : numDomainType. Implicit Types (a b t r : R) (A : set R). Lemma mem_1B_itvcc t : (1 - t \in `[0, 1]) = (t \in `[0, 1]). -Proof. by rewrite !in_itv/= subr_ge0 ger_addl oppr_le0 andbC. Qed. +Proof. by rewrite !in_itv/= subr_ge0 gerDl oppr_le0 andbC. Qed. Definition line_path a b t : R := (1 - t) * a + t * b. @@ -390,14 +390,14 @@ Proof. by apply/funext => t; rewrite line_pathEl subrr mulr0 add0r. Qed. Lemma leW_line_path a b : a <= b -> {homo line_path a b : x y / x <= y}. Proof. -by move=> ? ? ? ?; rewrite !line_pathEl ler_add ?ler_wpmul2r// subr_ge0. +by move=> ? ? ? ?; rewrite !line_pathEl lerD ?ler_wpM2r// subr_ge0. Qed. Definition factor a b x := (x - a) / (b - a). Lemma leW_factor a b : a <= b -> {homo factor a b : x y / x <= y}. Proof. -by move=> ? ? ? ?; rewrite /factor ler_wpmul2r ?ler_add// invr_ge0 subr_ge0. +by move=> ? ? ? ?; rewrite /factor ler_wpM2r ?lerD// invr_ge0 subr_ge0. Qed. Lemma factor_flat a : factor a a = cst 0. @@ -474,9 +474,9 @@ Proof. move=> ltab; rewrite -ndline_pathE. apply: bij_subr => //=; rewrite setTI ?ndline_pathE. apply/predeqP => t /=; rewrite !in_itv/= {1}line_pathEl line_pathEr. -rewrite -lteif_subl_addr subrr -lteif_pdivr_mulr ?subr_gt0// mul0r. -rewrite -lteif_subr_addr subrr -lteif_ndivr_mulr ?subr_lt0// mul0r. -by rewrite lteif_subr_addl addr0. +rewrite -lteifBlDr subrr -lteif_pdivrMr ?subr_gt0// mul0r. +rewrite -lteifBrDr subrr -lteif_ndivrMr ?subr_lt0// mul0r. +by rewrite lteifBrDl addr0. Qed. Lemma factor_itv_bij ba bb a b : a < b -> diff --git a/coq-mathcomp-analysis.opam b/coq-mathcomp-analysis.opam index 7bc0a0325..12286a782 100644 --- a/coq-mathcomp-analysis.opam +++ b/coq-mathcomp-analysis.opam @@ -19,7 +19,7 @@ build: [make "-C" "theories" "-j%{jobs}%"] install: [make "-C" "theories" "install"] depends: [ "coq-mathcomp-classical" { = version} - "coq-mathcomp-solvable" { (>= "1.17.0" & < "1.20~") | (= "dev") } + "coq-mathcomp-solvable" { (>= "2.0.0") | (= "dev") } "coq-mathcomp-field" "coq-mathcomp-bigenough" { (>= "1.0.0") } ] diff --git a/coq-mathcomp-classical.opam b/coq-mathcomp-classical.opam index 1f2b1c898..455c334d8 100644 --- a/coq-mathcomp-classical.opam +++ b/coq-mathcomp-classical.opam @@ -18,12 +18,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.15" & < "8.20~") | (= "dev") } - "coq-mathcomp-ssreflect" { (>= "1.17.0" & < "1.20~") | (= "dev") } + "coq" { (>= "8.16" & < "8.20~") | (= "dev") } + "coq-mathcomp-ssreflect" { (>= "2.0.0") | (= "dev") } "coq-mathcomp-fingroup" "coq-mathcomp-algebra" - "coq-mathcomp-finmap" { (>= "1.5.1" & < "1.6~") | (= "dev") } - "coq-hierarchy-builder" { (>= "1.2.0") } + "coq-mathcomp-finmap" { (>= "2.0.0") | (= "dev") } + "coq-hierarchy-builder" { (>= "1.4.0") } ] tags: [ diff --git a/theories/Rstruct.v b/theories/Rstruct.v index 90945aa50..3ce44ea26 100644 --- a/theories/Rstruct.v +++ b/theories/Rstruct.v @@ -29,6 +29,7 @@ Require Import Rdefinitions Raxioms RIneq Rbasic_fun Zwf. Require Import Epsilon FunctionalExtensionality Ranalysis1 Rsqrt_def. Require Import Rtrigo1 Reals. From mathcomp Require Import all_ssreflect ssralg poly mxpoly ssrnum. +From HB Require Import structures. Set Implicit Arguments. Unset Strict Implicit. @@ -53,8 +54,7 @@ Proof. by move=> r1 r2; rewrite /eqr; case: Req_EM_T=> H; apply: (iffP idP). Qed. -Canonical R_eqMixin := EqMixin eqrP. -Canonical R_eqType := Eval hnf in EqType R R_eqMixin. +#[hnf] HB.instance Definition _ := hasDecEq.Build R eqrP. Fact inhR : inhabited R. Proof. exact: (inhabits 0). Qed. @@ -76,17 +76,15 @@ suff->: u = v by rewrite PEQ. by congr epsilon; apply: functional_extensionality=> x; rewrite PEQ. Qed. -Definition R_choiceMixin : choiceMixin R := - Choice.Mixin pickR_some pickR_ex pickR_ext. - -Canonical R_choiceType := Eval hnf in ChoiceType R R_choiceMixin. +#[hnf] +HB.instance Definition _ := hasChoice.Build R pickR_some pickR_ex pickR_ext. Fact RplusA : associative (Rplus). Proof. by move=> *; rewrite Rplus_assoc. Qed. -Definition R_zmodMixin := ZmodMixin RplusA Rplus_comm Rplus_0_l Rplus_opp_l. - -Canonical R_zmodType := Eval hnf in ZmodType R R_zmodMixin. +#[hnf] +HB.instance Definition _ := GRing.isZmodule.Build R + RplusA Rplus_comm Rplus_0_l Rplus_opp_l. Fact RmultA : associative (Rmult). Proof. by move=> *; rewrite Rmult_assoc. Qed. @@ -94,22 +92,24 @@ Proof. by move=> *; rewrite Rmult_assoc. Qed. Fact R1_neq_0 : R1 != R0. Proof. by apply/eqP/R1_neq_R0. Qed. -Definition R_ringMixin := RingMixin RmultA Rmult_1_l Rmult_1_r - Rmult_plus_distr_r Rmult_plus_distr_l R1_neq_0. +#[hnf] +HB.instance Definition _ := GRing.Zmodule_isRing.Build R + RmultA Rmult_1_l Rmult_1_r Rmult_plus_distr_r Rmult_plus_distr_l R1_neq_0. -Canonical R_ringType := Eval hnf in RingType R R_ringMixin. -Canonical R_comRingType := Eval hnf in ComRingType R Rmult_comm. +#[hnf] +HB.instance Definition _ := GRing.Ring_hasCommutativeMul.Build R Rmult_comm. Import Monoid. -Canonical Radd_monoid := Law RplusA Rplus_0_l Rplus_0_r. -Canonical Radd_comoid := ComLaw Rplus_comm. +HB.instance Definition _ := isComLaw.Build R 0 Rplus + RplusA Rplus_comm Rplus_0_l. -Canonical Rmul_monoid := Law RmultA Rmult_1_l Rmult_1_r. -Canonical Rmul_comoid := ComLaw Rmult_comm. +HB.instance Definition _ := isComLaw.Build R 1 Rmult + RmultA Rmult_comm Rmult_1_l. -Canonical Rmul_mul_law := MulLaw Rmult_0_l Rmult_0_r. -Canonical Radd_add_law := AddLaw Rmult_plus_distr_r Rmult_plus_distr_l. +HB.instance Definition _ := isMulLaw.Build R 0 Rmult Rmult_0_l Rmult_0_r. +HB.instance Definition _ := isAddLaw.Build R Rmult Rplus + Rmult_plus_distr_r Rmult_plus_distr_l. Definition Rinvx r := if (r != 0) then / r else r. @@ -136,26 +136,19 @@ Qed. Lemma Rinvx_out : {in predC unit_R, Rinvx =1 id}. Proof. by move=> x; rewrite inE/= /Rinvx -if_neg => ->. Qed. -Definition R_unitRingMixin := - UnitRingMixin RmultRinvx RinvxRmult intro_unit_R Rinvx_out. - -Canonical R_unitRing := - Eval hnf in UnitRingType R R_unitRingMixin. - -Canonical R_comUnitRingType := - Eval hnf in [comUnitRingType of R]. +#[hnf] +HB.instance Definition _ := GRing.Ring_hasMulInverse.Build R + RmultRinvx RinvxRmult intro_unit_R Rinvx_out. Lemma R_idomainMixin x y : x * y = 0 -> (x == 0) || (y == 0). Proof. by move=> /Rmult_integral []->; rewrite eqxx ?orbT. Qed. -Canonical R_idomainType := Eval hnf in IdomainType R R_idomainMixin. +#[hnf] +HB.instance Definition _ := GRing.ComUnitRing_isIntegral.Build R + R_idomainMixin. -Lemma R_fieldMixin : GRing.Field.mixin_of [unitRingType of R]. -Proof. by done. Qed. - -Definition R_fieldIdomainMixin := FieldIdomainMixin R_fieldMixin. - -Canonical R_fieldType := FieldType R R_fieldMixin. +Lemma R_fieldMixin : GRing.field_axiom R. Proof. by []. Qed. +HB.instance Definition _ := GRing.UnitRing_isField.Build R R_fieldMixin. (** Reflect the order on the reals to bool *) @@ -228,11 +221,8 @@ move=> H; apply/andP; split; [apply/eqP|apply/RlebP]. exact: Rlt_le. Qed. -Definition R_numMixin := NumMixin Rleb_norm_add addr_Rgtb0 Rnorm0_eq0 - Rleb_leVge RnormM Rleb_def Rltb_def. -Canonical R_porderType := POrderType ring_display R R_numMixin. -Canonical R_numDomainType := NumDomainType R R_numMixin. -Canonical R_normedZmodType := NormedZmodType R R R_numMixin. +HB.instance Definition _ := Num.IntegralDomain_isNumRing.Build R + Rleb_norm_add addr_Rgtb0 Rnorm0_eq0 Rleb_leVge RnormM Rleb_def Rltb_def. Lemma RleP : forall x y, reflect (Rle x y) (x <= y)%R. Proof. exact: RlebP. Qed. @@ -244,27 +234,22 @@ Proof. exact: RltbP. Qed. (* Lemma RgtP : forall x y, reflect (Rgt x y) (x > y)%R. *) (* Proof. exact: RltbP. Qed. *) -Canonical R_numFieldType := [numFieldType of R]. - Lemma Rreal_axiom (x : R) : (0 <= x)%R || (x <= 0)%R. Proof. case: (Rle_dec 0 x)=> [/RleP ->|] //. by move/Rnot_le_lt/Rlt_le/RleP=> ->; rewrite orbT. Qed. -Lemma R_total : totalPOrderMixin R_porderType. +Lemma R_total : total (<=%O : rel R). Proof. move=> x y; case: (Rle_lt_dec x y) => [/RleP -> //|/Rlt_le/RleP ->]; by rewrite orbT. Qed. -Canonical R_latticeType := LatticeType R R_total. -Canonical R_distrLatticeType := DistrLatticeType R R_total. -Canonical R_orderType := OrderType R R_total. -Canonical R_realDomainType := [realDomainType of R]. -Canonical R_realFieldType := [realFieldType of R]. +HB.instance Definition _ := Order.POrder_isTotal.Build _ R R_total. -Lemma Rarchimedean_axiom : Num.archimedean_axiom R_numDomainType. +Lemma Rarchimedean_axiom : + Num.archimedean_axiom [the numDomainType of R : Type]. Proof. move=> x; exists (Z.abs_nat (up x) + 2)%N. have [Hx1 Hx2]:= (archimed x). @@ -282,7 +267,7 @@ apply/RltbP/Rabs_def1. apply/Rplus_le_compat_r/IHz; split; first exact: Zlt_le_weak. exact: Zlt_pred. apply: (Rle_trans _ (IZR 0)); first exact: IZR_le. - by apply/RlebP/(ler0n R_numDomainType (Z.abs_nat z)). + by apply/RlebP/(ler0n [the numDomainType of R : Type] (Z.abs_nat z)). apply: (Rlt_le_trans _ (IZR (up x) - 1)). apply: Ropp_lt_cancel; rewrite Ropp_involutive. rewrite Ropp_minus_distr /Rminus -opp_IZR -{2}(Z.opp_involutive (up x)). @@ -300,16 +285,14 @@ apply: (Rlt_le_trans _ (IZR (up x) - 1)). rewrite mulrnDr; apply: (Rlt_le_trans _ 2). by rewrite -{1}[1]Rplus_0_r; apply/Rplus_lt_compat_l/Rlt_0_1. rewrite -[2]Rplus_0_l; apply: Rplus_le_compat_r. - by apply/RlebP/(ler0n R_numDomainType (Z.abs_nat _)). + by apply/RlebP/(ler0n [the numDomainType of R : Type] (Z.abs_nat _)). apply: Rminus_le. rewrite /Rminus Rplus_assoc [- _ + _]Rplus_comm -Rplus_assoc -!/(Rminus _ _). exact: Rle_minus. Qed. -(* Canonical R_numArchiDomainType := ArchiDomainType R Rarchimedean_axiom. *) -(* (* Canonical R_numArchiFieldType := [numArchiFieldType of R]. *) *) -(* Canonical R_realArchiDomainType := [realArchiDomainType of R]. *) -Canonical R_realArchiFieldType := ArchiFieldType R Rarchimedean_axiom. +HB.instance Definition _ := Num.RealField_isArchimedean.Build R + Rarchimedean_axiom. (** Here are the lemmas that we will use to prove that R has the rcfType structure. *) @@ -349,7 +332,8 @@ have Hg: (fun x=> f x * f x ^+ n)%R =1 g. by apply: (continuity_eq Hg); exact: continuity_mult. Qed. -Lemma Rreal_closed_axiom : Num.real_closed_axiom R_numDomainType. +Lemma Rreal_closed_axiom : + Num.real_closed_axiom [the numDomainType of R : Type]. Proof. move=> p a b; rewrite !le_eqVlt. case Hpa: ((p.[a])%R == 0%R). @@ -372,8 +356,7 @@ apply:continuity_scal; apply: continuity_exp=> x esp Hesp. by exists esp; split=> // y []. Qed. -Canonical R_rcfType := RcfType R Rreal_closed_axiom. -(* Canonical R_realClosedArchiFieldType := [realClosedArchiFieldType of R]. *) +HB.instance Definition _ := Num.RealField_isClosed.Build R Rreal_closed_axiom. End ssreal_struct. @@ -432,9 +415,8 @@ Proof. by move=> supE x Ex; apply/ge_supremum_Nmem => //; exact: Rsupremums_neq0. Qed. -Definition real_realMixin : Real.mixin_of _ := - RealMixin (@Rsup_ub (0 : R)) (real_sup_adherent 0). -Canonical real_realType := RealType R real_realMixin. +HB.instance Definition _ := ArchimedeanField_isReal.Build R + (@Rsup_ub (0 : R)) (real_sup_adherent 0). Implicit Types (x y : R) (m n : nat). @@ -486,7 +468,7 @@ Proof. elim: n => // n IH; by rewrite S_INR IH RplusE -addn1 natrD. Qed. Lemma RsqrtE x : 0 <= x -> sqrt x = Num.sqrt x. Proof. move => x0; apply/eqP; have [t1 t2] := conj (sqrtr_ge0 x) (sqrt_pos x). -rewrite eq_sym -(eqr_expn2 (_: 0 < 2)%N t1) //; last by apply /RleP. +rewrite eq_sym -(eqrXn2 (_: 0 < 2)%N t1) //; last by apply /RleP. rewrite sqr_sqrtr // !exprS expr0 mulr1 -RmultE ?sqrt_sqrt //; by apply/RleP. Qed. @@ -583,7 +565,7 @@ Proof. move=> k0; elim: s => /= [|h [/=|h' t ih]]. by rewrite bigmaxr_nil mulr0. by rewrite !bigmaxr_un. -by rewrite bigmaxr_cons {}ih bigmaxr_cons maxr_pmulr. +by rewrite bigmaxr_cons {}ih bigmaxr_cons maxr_pMr. Qed. #[deprecated(note="To be removed. Use topology.v's bigmax/min lemmas instead.")] @@ -705,20 +687,7 @@ Require Import signed topology. Section analysis_struct. -Canonical R_pointedType := [pointedType of R for pointed_of_zmodule R_ringType]. -Canonical R_filteredType := - [filteredType R of R for filtered_of_normedZmod R_normedZmodType]. -Canonical R_topologicalType : topologicalType := TopologicalType R - (topologyOfEntourageMixin - (uniformityOfBallMixin - (@nbhs_ball_normE _ R_normedZmodType) - (pseudoMetric_of_normedDomain R_normedZmodType))). -Canonical R_uniformType : uniformType := - UniformType R - (uniformityOfBallMixin (@nbhs_ball_normE _ R_normedZmodType) - (pseudoMetric_of_normedDomain R_normedZmodType)). -Canonical R_pseudoMetricType : pseudoMetricType R_numDomainType := - PseudoMetricType R (pseudoMetric_of_normedDomain R_normedZmodType). +HB.instance Definition _ := PseudoMetric.copy R R^o. (* TODO: express using ball?*) Lemma continuity_pt_nbhs (f : R -> R) x : @@ -742,10 +711,10 @@ Lemma continuity_pt_cvg (f : R -> R) (x : R) : Proof. eapply iff_trans; first exact: continuity_pt_nbhs. apply iff_sym. -have FF : Filter (f @ x). +have FF : Filter (f @ x)%classic. by typeclasses eauto. (*by apply fmap_filter; apply: @filter_filter' (locally_filter _).*) -case: (@fcvg_ballP _ _ (f @ x) FF (f x)) => {FF}H1 H2. +case: (@fcvg_ballP _ _ (f @ x)%classic FF (f x)) => {FF}H1 H2. (* TODO: in need for lemmas and/or refactoring of already existing lemmas (ball vs. Rabs) *) split => [{H2} - /H1 {}H1 eps|{H1} H]. - have {H1} [//|_/posnumP[x0] Hx0] := H1 eps%:num. diff --git a/theories/altreals/discrete.v b/theories/altreals/discrete.v index 362817804..d2b0f71e9 100644 --- a/theories/altreals/discrete.v +++ b/theories/altreals/discrete.v @@ -4,6 +4,7 @@ (* Copyright (c) - 2016--2018 - Polytechnique *) (* -------------------------------------------------------------------- *) +From HB Require Import structures. From mathcomp Require Import all_ssreflect all_algebra. From mathcomp.classical Require Import boolp. Require Import xfinmap reals. @@ -39,27 +40,19 @@ Variable T : Type. Variable E : pred T. Record pred_sub : Type := - PSubSub { rsval : T; rsvalP : rsval \in E }. + PSubSub { rsval :> T; rsvalP : rsval \in E }. -Coercion rsval : pred_sub >-> T. - -Canonical pred_sub_subType := Eval hnf in [subType for rsval]. +HB.instance Definition _ := [isSub for rsval]. End Def. -Definition pred_sub_eqMixin (T : eqType) (E : pred T) := - Eval hnf in [eqMixin of pred_sub E by <:]. -Canonical pred_sub_eqType (T : eqType) (E : pred T) := - Eval hnf in EqType (@pred_sub T E) (pred_sub_eqMixin E). +HB.instance Definition _ (T : eqType) (E : pred T) := + [Equality of pred_sub E by <:]. -Definition pred_sub_choiceMixin (T : choiceType) (E : pred T) := - Eval hnf in [choiceMixin of pred_sub E by <:]. -Canonical pred_sub_choiceType (T : choiceType) (E : pred T) := - Eval hnf in ChoiceType (@pred_sub T E) (pred_sub_choiceMixin E). +HB.instance Definition _ (T : choiceType) (E : pred T) := + [Choice of pred_sub E by <:]. -Definition pred_sub_countMixin (T : countType) (E : pred T) := - Eval hnf in [countMixin of pred_sub E by <:]. -Canonical pred_sub_countType (T : countType) (E : pred T) := - Eval hnf in CountType (@pred_sub T E) (pred_sub_countMixin E). +HB.instance Definition _ (T : countType) (E : pred T) := + [Countable of pred_sub E by <:]. End PredSubtype. Notation "[ 'psub' E ]" := (@pred_sub _ E) @@ -77,7 +70,7 @@ End PIncl. Section Countable. Variable (T : Type) (E : pred T). -CoInductive countable : Type := +Variant countable : Type := Countable (rpickle : [psub E] -> nat) (runpickle : nat -> option [psub E]) @@ -113,20 +106,13 @@ End CanCountable. Section CountType. Variables (T : eqType) (E : pred T) (c : countable E). -Definition countable_countMixin := CountMixin (rpickleK c). -Definition countable_choiceMixin := CountChoiceMixin countable_countMixin. - -Definition countable_choiceType := - ChoiceType [psub E] countable_choiceMixin. - -Definition countable_countType := - CountType countable_choiceType countable_countMixin. +Definition countable_countMixin := Countable.copy [psub E] + (pcan_type (rpickleK c)). +Definition countable_choiceMixin := Choice.copy [psub E] + (pcan_type (rpickleK c)). End CountType. End CountableTheory. -Notation "[ 'countable' 'of' c ]" := (countable_countType c) - (format "[ 'countable' 'of' c ]"). - (* -------------------------------------------------------------------- *) Section Finite. Variables (T : eqType). @@ -183,7 +169,7 @@ Variables (T : eqType) (E F : pred T). Lemma countable_sub: {subset E <= F} -> countable F -> countable E. Proof. move=> le_EF [f g fgK]; pose f' (x : [psub E]) := f (pincl le_EF x). -pose g' x := obind (insub (sT := [subType of [psub E]])) (omap val (g x)). +pose g' x := obind (insub (sT := [the subType _ of [psub E]])) (omap val (g x)). by exists f' g' => x; rewrite /f' /g' fgK /= valK. Qed. End CountSub. @@ -196,7 +182,8 @@ Hypothesis cE : forall i, countable (E i). Lemma cunion_countable : countable [pred x | `[< exists i, x \in E i >]]. Proof. -pose S := { i : nat & [countable of cE i] }; set F := [pred x | _]. +pose Ci i : countType := HB.pack [psub (E i)] (countable_countMixin (cE i)). +pose S := { i : nat & Ci i }; set F := [pred x | _]. have H: forall (x : [psub F]), exists i : nat, val x \in E i. by case=> x /= /asboolP[i] Eix; exists i. have G: forall (x : S), val (tagged x) \in F. diff --git a/theories/altreals/distr.v b/theories/altreals/distr.v index e7744c7dc..b81cca9e7 100644 --- a/theories/altreals/distr.v +++ b/theories/altreals/distr.v @@ -70,7 +70,8 @@ Lemma summable_mu : summable mu. Proof. by case: mu. Qed. End DistrCoreTh. -#[global] Hint Resolve ge0_mu le1_mu summable_mu : core. +#[global] Hint Extern 0 (is_true (0 <= _)) => solve [apply: ge0_mu] : core. +#[global] Hint Resolve le1_mu summable_mu : core. (* -------------------------------------------------------------------- *) Section Clamp. @@ -174,13 +175,13 @@ Lemma isdistr_finP {R : realType} {I : finType} (mu : I -> R) : Proof. split=> -[ ge0_mu le1]; split=> //. + by apply/le1; rewrite /index_enum -enumT enum_uniq. + move=> J uqJ; rewrite big_uniq 1?(le_trans _ le1) //=. - by rewrite [X in _<=X](bigID (mem J)) /= ler_addl sumr_ge0. + by rewrite [X in _<=X](bigID (mem J)) /= lerDl sumr_ge0. Qed. Lemma le1_mu1 {R : realType} {T : choiceType} (mu : {distr T / R}) x : mu x <= 1. Proof. -apply/(@le_trans _ _ (psum mu)) => //; rewrite -[mu x]ger0_norm //. +apply/(@le_trans _ _ (psum mu)) => //; rewrite -[mu x]ger0_norm//. by apply/ger1_psum. Qed. @@ -267,7 +268,7 @@ Local Lemma has_sup_mrat s J : uniq J -> \sum_(i <- J) mrat s i <= 1. Proof. move=> uqJ; rewrite -mulr_suml /= -natr_sum; case: (size s =P 0%N). by move=> ->; rewrite invr0 mulr0 ler01. -move=> /eqP nz_s; rewrite ler_pdivr_mulr ?ltr0n ?lt0n // mul1r. +move=> /eqP nz_s; rewrite ler_pdivrMr ?ltr0n ?lt0n // mul1r. rewrite ler_nat (bigID (mem s)) /= [X in (_+X)%N]big1 ?addn0. by move=> i /count_memPn. have ->: (size s = \sum_(i <- undup s) count_mem i s)%N. @@ -362,10 +363,10 @@ Proof. split=> [x|J uqJ]; first by apply/ge0_psum. rewrite /mlet psum_bigop; first by move=> y x; rewrite mulr_ge0. move=> u; apply/(le_summable (F2 := mu)) => //. - by move=> x; rewrite mulr_ge0 //= ler_pimulr ?le1_mu1. + by move=> x; rewrite mulr_ge0 //= ler_piMr ?le1_mu1. apply/(le_trans _ (le1_mu mu))/le_psum => //. move=> x; rewrite sumr_ge0 /= => [y _|]; first by rewrite mulr_ge0. -rewrite -mulr_sumr ler_pimulr //; apply/(le_trans _ (le1_mu (f x))). +rewrite -mulr_sumr ler_piMr //; apply/(le_trans _ (le1_mu (f x))). have := summable_mu (f x) => /gerfinseq_psum => /(_ _ uqJ). by apply/(le_trans _)/ler_sum=> y _; apply/ler_norm. Qed. @@ -437,7 +438,7 @@ Proof. (* summable -> refactor *) move=> le_f; unlock dlet=> y /=; apply/le_psum/summable_mlet. move=> x; rewrite mulr_ge0 //=; case: (mu x =P 0). by move=> ->; rewrite !mul0r. -by move/dinsuppPn/le_f/(_ y) => h; rewrite ler_pmul. +by move/dinsuppPn/le_f/(_ y) => h; rewrite ler_pM. Qed. Lemma le_mu_dlet f mu nu : mu <=1 nu -> dlet f mu <=1 dlet f nu. @@ -445,7 +446,7 @@ Proof. move=> le_mu x; unlock dlet; rewrite /= /mlet. apply/le_psum/summable_mlet => y; rewrite mulr_ge0 //=. case: (mu y =P 0) => [->|]; first by rewrite mul0r mulr_ge0. -by move=>/dinsuppPn=> h; rewrite ler_pmul. +by move=>/dinsuppPn=> h; rewrite ler_pM. Qed. Lemma le_dlet f g mu nu : @@ -495,7 +496,7 @@ Proof. unlock dlet; rewrite /= /mlet => /eq0_psum h x /dinsuppP /eqP mu_x. have {}/h: summable (fun x => mu x * F x y). apply/(le_summable (F2 := mu)) => // z. - by rewrite mulr_ge0 //= ler_pimulr // le1_mu1. + by rewrite mulr_ge0 //= ler_piMr // le1_mu1. by move/(_ x)/eqP; rewrite mulf_eq0 (negbTE mu_x) /= => /eqP. Qed. End BindTheory. @@ -515,9 +516,9 @@ rewrite (eq_psum (F2 := fun y => psum (S^~ y))) => [x|]. rewrite __admitted__interchange_psum. + by move=> x; apply/summableZ/summable_mlet. + rewrite {}/S; apply/(le_summable (F2 := mu)) => //. - move=> x; rewrite ge0_psum /= psumZ ?ler_pimulr //. + move=> x; rewrite ge0_psum /= psumZ ?ler_piMr //. apply/(le_trans _ (le1_mu (f1 x)))/le_psum => //. - by move=> y; rewrite mulr_ge0 //= ler_pimulr ?le1_mu1. + by move=> y; rewrite mulr_ge0 //= ler_piMr ?le1_mu1. apply/eq_psum=> y /=; rewrite -psumZr //. by apply/eq_psum=> x /=; rewrite {}/S mulrA. Qed. @@ -566,8 +567,7 @@ apply/(@le_trans _ _ (\sum_(j <- J) f K j)); last first. have /(gerfinseq_psum uqJ) := summable_mu (f K). move/le_trans=> -/(_ _ (le1_mu (f K)))=> h. by apply/(le_trans _ h)/ler_sum=> i _; apply/ler_norm. -apply/ler_sum=> j _; rewrite /F; case/boolP: `[< _ >]; [done|]. -by move=> _; apply/ge0_mu. +by apply/ler_sum=> j _; rewrite /F; case/boolP: `[< _ >]. Qed. Definition dlim T (f : nat -> distr T) := @@ -861,7 +861,7 @@ Implicit Types (mu : {distr T / R}) (A B E : pred T). Lemma summable_pr E mu : summable (fun x => (E x)%:R * mu x). Proof. apply/(le_summable (F2 := mu)) => [x|]; last by apply/summable_mu. - by rewrite mulr_ge0 ?ler0n //= ler_pimull // lern1 leq_b1. + by rewrite mulr_ge0 ?ler0n //= ler_piMl // lern1 leq_b1. Qed. Lemma pr_pred0 mu : \P_[mu] pred0 = 0. @@ -1000,7 +1000,7 @@ Proof. move=> le_BA; apply/le_psum; last first. apply/summableMl => //; exists 1=> // x. by rewrite ger0_norm ?(ler0n, lern1) ?leq_b1. -move=> x; rewrite mulr_ge0 ?ler0n ?ler_wpmul2r //. +move=> x; rewrite mulr_ge0 ?ler0n ?ler_wpM2r //. rewrite ler_nat; have := le_BA x; rewrite -!topredE /=. by case: (B x) => // ->. Qed. @@ -1015,7 +1015,7 @@ Lemma le_exp mu f1 f2: \E?_[mu] f1 -> \E?_[mu] f2 -> f1 <=1 f2 -> \E_[mu] f1 <= \E_[mu] f2. Proof. move=> sm1 sm2 le_f; apply/le_sum => //. -by move=> x; rewrite ler_wpmul2r. +by move=> x; rewrite ler_wpM2r. Qed. Lemma le_in_pr E1 E2 mu : @@ -1024,7 +1024,7 @@ Lemma le_in_pr E1 E2 mu : Proof. move=> le; rewrite /pr; apply/le_psum; last by apply/summable_pr. move=> x; rewrite mulr_ge0 ?ler0n //=; case/boolP: (x \in dinsupp mu). - move/le; rewrite -!topredE /= => E12; rewrite ler_wpmul2r //. + move/le; rewrite -!topredE /= => E12; rewrite ler_wpM2r //. by rewrite ler_nat; case: (E1 x) E12 => // ->. by move/dinsuppPn=> ->; rewrite !mulr0. Qed. @@ -1044,7 +1044,7 @@ Lemma le1_prc A B mu : \P_[mu, B] A <= 1. Proof. have := ge0_pr B mu; rewrite /prc le_eqVlt. case/orP=> [/eqP<-|]; first by rewrite invr0 mulr0 ler01. -by move/ler_pdivr_mulr=> ->; rewrite mul1r le_in_pr // => x _ /andP[]. +by move/ler_pdivrMr=> ->; rewrite mul1r le_in_pr // => x _ /andP[]. Qed. Lemma prc_sum A mu : 0 < \P_[mu] A -> @@ -1137,11 +1137,11 @@ Proof. by rewrite pr_or opprB addrCA subrr addr0. Qed. Lemma ler_pr_or A B mu : \P_[mu] [predU A & B] <= \P_[mu] A + \P_[mu] B. -Proof. by rewrite pr_or ler_subl_addr ler_addl ge0_pr. Qed. +Proof. by rewrite pr_or lerBlDr lerDl ge0_pr. Qed. Lemma ler_pr_and A B mu : \P_[mu] [predI A & B] <= \P_[mu] A + \P_[mu] B. -Proof. by rewrite pr_and ler_subl_addr ler_addl ge0_pr. Qed. +Proof. by rewrite pr_and lerBlDr lerDl ge0_pr. Qed. Lemma pr_predC E mu: \P_[mu](predC E) = \P_[mu] predT - \P_[mu] E. Proof. @@ -1174,11 +1174,11 @@ case=> M ltM; rewrite /has_esp; apply/summable_seqP. exists (Num.max M 0); first by rewrite le_maxr lexx orbT. move=> J uqJ; apply/(@le_trans _ _ (\sum_(j <- J) M * mu j)). apply/ler_sum=> j _; rewrite normrM [X in _*X]ger0_norm //. - by apply/ler_wpmul2r=> //; apply/ltW. + by apply/ler_wpM2r=> //; apply/ltW. case: (ltrP M 0) => [lt0_M|ge0_M]. rewrite ?(ltW lt0_M) // -mulr_sumr. by rewrite nmulr_rle0 //; apply/sumr_ge0. -by rewrite -mulr_sumr ler_pimulr // -pr_mem ?le1_pr. +by rewrite -mulr_sumr ler_piMr // -pr_mem ?le1_pr. Qed. Lemma bounded_has_exp mu F : @@ -1199,7 +1199,7 @@ move=> ge0M bd; apply/(@le_trans _ _ (\E_[mu] (fun _ => M))). + by apply/bounded_has_exp; exists M. + by apply/has_expC. + by move=> x; apply/(le_trans _ (bd x))/ler_norm. -by rewrite exp_cst ler_pimull // le1_pr. +by rewrite exp_cst ler_piMl // le1_pr. Qed. Lemma __admitted__exp_dlet mu (nu : T -> {distr U / R}) F : @@ -1244,21 +1244,21 @@ elim: {i} s (l i) (ge0_l i) (x i) => [|j s ih] li ge0_li xi. by rewrite !big_nil !addr0 => ->; rewrite !mul1r. rewrite !big_cons; have := ge0_l j; rewrite le_eqVlt. case/orP => [/eqP<-|gt0_lj]. - by rewrite !Monoid.simpm /=; apply/ih. + by rewrite !Monoid.simpm /= !Monoid.simpm; apply/ih. rewrite !addrA => eq1; pose z := (li * xi + l j * x j) / (li + l j). -have nz_lij: li + l j != 0 by rewrite gt_eqF ?ltr_paddl. +have nz_lij: li + l j != 0 by rewrite gt_eqF ?ltr_wpDl. have/ih := eq1 => -/(_ _ z); rewrite [_ * (_ / _)]mulrC. rewrite mulfVK // => {}ih; apply/(le_trans (ih _)). by rewrite addr_ge0 ?ge0_l. -rewrite ler_add2r {ih}/z mulrDl ![_*_/_]mulrAC. +rewrite lerD2r {ih}/z [_ / _]mulrDl ![_*_/_]mulrAC. set c1 : R := _ / _; set c2 : R := _ / _; have eqc2: c2 = 1 - c1. apply/(mulfI nz_lij); rewrite mulrBr mulr1 ![(li + l j)*_]mulrC. by apply/eqP; rewrite !mulfVK // eq_sym subr_eq addrC. set c := (li + l j); pose z := (c * c1 * f xi + c * c2 * f (x j)). apply/(@le_trans _ _ z); last by rewrite /z ![_*(_/_)]mulrC !mulfVK. -rewrite {}/z -![c * _ * _]mulrA -mulrDr ler_wpmul2l ?addr_ge0 //. +rewrite {}/z -![c * _ * _]mulrA -mulrDr ler_wpM2l ?addr_ge0 //. rewrite eqc2 cvx_f // ?leNye ?leey // divr_ge0 ?addr_ge0 //=. -by rewrite ler_pdivr_mulr ?mul1r ?ler_addl ?ltr_paddl. +by rewrite ler_pdivrMr ?mul1r ?lerDl ?ltr_wpDl. Qed. End Jensen. End Jensen. diff --git a/theories/altreals/realseq.v b/theories/altreals/realseq.v index f611a0d0b..7462ed1c7 100644 --- a/theories/altreals/realseq.v +++ b/theories/altreals/realseq.v @@ -112,18 +112,17 @@ case: l1 l2 => [l1||] [l2||] //= lt_l12; last first. + exists (NNInf 0), (NPInf 1) => x y; rewrite !inE => lt1 lt2. by apply/(lt_trans lt1)/(lt_trans ltr01). + exists (NNInf (l2-1)), (B1 l2) => x y; rewrite !inE. - rewrite ltr_norml [-1 < _]ltr_subr_addl. + rewrite ltr_norml [-1 < _]ltrBrDl. by move => lt1 /andP[lt2 _]; apply/(lt_trans lt1). + exists (B1 l1), (NPInf (l1+1)) => x y; rewrite !inE. - rewrite ltr_norml ltr_subl_addr [1+_]addrC => /andP[_]. + rewrite ltr_norml ltrBlDr [1+_]addrC => /andP[_]. by move=> lt1 lt2; apply/(lt_trans lt1). pose e := l2 - l1; exists (B l1 (e/2%:R)), (B l2 (e/2%:R)). have gt0_e: 0 < e by rewrite subr_gt0. move=> x y; rewrite !inE/= /eclamp pmulr_rle0 // invr_le0. rewrite lern0 /= !ltr_distl => /andP[_ lt1] /andP[lt2 _]. apply/(lt_trans lt1)/(le_lt_trans _ lt2). -rewrite ler_subr_addl addrCA -mulrDl -mulr2n -mulr_natr. -by rewrite mulfK ?pnatr_eq0 //= /e addrCA subrr addr0. +by rewrite lerBrDl addrCA -splitr /e addrCA subrr addr0. Qed. Lemma separable {R : realType} (l1 l2 : \bar R) : @@ -210,14 +209,14 @@ Lemma ncvg_nbounded u x : ncvg u x%:E -> nbounded u. Proof. (* FIXME: factor out `sup` of a finite set *) case/(_ (B x 1)) => K cu; pose S := [seq `|u n| | n <- iota 0 K]. pose M : R := sup [set x : R | x \in S]; pose e := Num.max (`|x| + 1) (M + 1). -apply/asboolP/nboundedP; exists e => [|n]; first by rewrite lt_maxr ltr_paddl. +apply/asboolP/nboundedP; exists e => [|n]; first by rewrite lt_maxr ltr_wpDl. case: (ltnP n K); last first. move/cu; rewrite inE eclamp_id ?ltr01 // => ltunBx1. rewrite lt_maxr; apply/orP; left; rewrite -[u n](addrK x) addrAC. - by apply/(le_lt_trans (ler_norm_add _ _)); rewrite addrC ltr_add2l. + by apply/(le_lt_trans (ler_normD _ _)); rewrite addrC ltrD2l. move=> lt_nK; have: `|u n| \in S; first by apply/map_f; rewrite mem_iota. move=> un_S; rewrite lt_maxr; apply/orP; right. -case E: {+}K lt_nK => [|k] // lt_nSk; apply/ltr_spaddr; first apply/ltr01. +case E: {+}K lt_nK => [|k] // lt_nSk; apply/ltr_pwDr; first apply/ltr01. suff : has_sup (fun x : R => x \in S) by move/sup_upper_bound/ubP => ->. split; first by exists `|u 0%N|; rewrite /S E inE eqxx. elim: {+}S => [|v s [ux /ubP hux]]; first by exists 0; apply/ubP. @@ -229,7 +228,7 @@ Qed. Lemma nboundedC c : nbounded c%:S. Proof. apply/asboolP/nboundedP; exists (`|c| + 1). - by rewrite ltr_spaddr. by move=> _; rewrite ltr_addl. + by rewrite ltr_pwDr. by move=> _; rewrite ltrDl. Qed. Lemma ncvgC c : ncvg c%:S c%:E. @@ -244,20 +243,20 @@ Proof. move=> cu cv; elim/nbh_finW => e /= gt0_e; pose z := e / 2%:R. case: (cu (B lu z)) (cv (B lv z)) => [ku {}cu] [kv {}cv]. exists (maxn ku kv) => n; rewrite geq_max => /andP[leu lev]. -rewrite inE opprD addrACA (le_lt_trans (ler_norm_add _ _)) //. +rewrite inE opprD addrACA (le_lt_trans (ler_normD _ _)) //. move: (cu _ leu) (cv _ lev); rewrite !inE eclamp_id. by rewrite mulr_gt0 // invr_gt0 ltr0Sn. -move=> cu' cv'; suff ->: e = z + z by rewrite ltr_add. -by rewrite -mulrDl -mulr2n -mulr_natr mulfK ?pnatr_eq0. +move=> cu' cv'; suff ->: e = z + z by rewrite ltrD. +exact: splitr. Qed. Lemma ncvgN u lu : ncvg u lu -> ncvg (- u) (- lu). Proof. case: lu => [lu||] cu /=; first last. + elim/nbh_pinfW=> M; case: (cu (NNInf (-M))) => K {}cu. - by exists K => n /cu; rewrite !inE ltr_oppr. + by exists K => n /cu; rewrite !inE ltrNr. + elim/nbh_ninfW=> M; case: (cu (NPInf (-M))) => K {}cu. - by exists K => n /cu; rewrite !inE ltr_oppl. + by exists K => n /cu; rewrite !inE ltrNl. elim/nbh_finW => e /= gt0_e; case: (cu (B lu e)). by move=> K {}cu; exists K=> n /cu; rewrite !inE -opprD normrN eclamp_id. Qed. @@ -286,10 +285,10 @@ Lemma ncvgMl u v : ncvg u 0%:E -> nbounded v -> ncvg (u \* v) 0%:E. move=> cu /asboolP/nboundedP [M gt0_M ltM]; elim/nbh_finW => e /= gt0_e. case: (cu (B 0 (e / (M + 1)))) => K {}cu; exists K => n le_Kn. rewrite inE subr0 normrM; apply/(@lt_trans _ _ (e / (M + 1) * M)). - apply/ltr_pmul => //; have /cu := le_Kn; rewrite inE subr0 eclamp_id //. + apply/ltr_pM => //; have /cu := le_Kn; rewrite inE subr0 eclamp_id //. by rewrite mulr_gt0 // invr_gt0 addr_gt0. -rewrite -mulrAC -mulrA gtr_pmulr // ltr_pdivr_mulr ?addr_gt0 //. -by rewrite mul1r ltr_addl. +rewrite -mulrAC -mulrA gtr_pMr // ltr_pdivrMr ?addr_gt0 //. +by rewrite mul1r ltrDl. Qed. Lemma ncvgMr u v : ncvg v 0%:E -> nbounded u -> ncvg (u \* v) 0%:E. @@ -542,7 +541,7 @@ elim/nbh_finW=> /= e gt0_e; have sS: has_sup S. have /sup_adherent := sS => /(_ _ gt0_e) [r] [N ->] lt_uN. exists N => n le_Nn; rewrite !inE distrC ger0_norm ?subr_ge0. by move/ubP : (sup_upper_bound sS) => -> //; exists n. -by rewrite ltr_subl_addr -ltr_subl_addl (lt_le_trans lt_uN) ?mn_u. +by rewrite ltrBlDr -ltrBlDl (lt_le_trans lt_uN) ?mn_u. Qed. End LimOp. diff --git a/theories/altreals/realsum.v b/theories/altreals/realsum.v index 7b9989a0e..caaa40645 100644 --- a/theories/altreals/realsum.v +++ b/theories/altreals/realsum.v @@ -70,7 +70,7 @@ Proof. by move=> x; rewrite /fpos /fneg -{1}oppr0 -oppr_min normrN. Qed. Lemma fposZ f c : 0 <= c -> fpos (c \*o f) =1 c \*o fpos f. Proof. move=> ge0_c x; rewrite /fpos /= -{1}(mulr0 c). -by rewrite -maxr_pmulr // normrM ger0_norm. +by rewrite -maxr_pMr // normrM ger0_norm. Qed. Lemma fnegZ f c : 0 <= c -> fneg (c \*o f) =1 c \*o fneg f. @@ -83,7 +83,7 @@ Lemma fpos_natrM f (n : T -> nat) x : fpos (fun x => (n x)%:R * f x) x = (n x)%:R * fpos f x. Proof. rewrite /fpos -[in RHS]normr_nat -normrM. -by rewrite maxr_pmulr ?ler0n // mulr0. +by rewrite maxr_pMr ?ler0n // mulr0. Qed. Lemma fneg_natrM f (n : T -> nat) x : @@ -143,7 +143,7 @@ case/summableP=> M ge0_M bM; pose E (p : nat) := [pred x | `|f x| > 1 / p.+1%:~R set F := [pred x | _]; have le: {subset F <= [pred x | `[< exists p, x \in E p >]]}. move=> x; rewrite !inE => nz_fx. pose j := `|floor (1 / `|f x|)|%N; exists j; rewrite inE. - rewrite ltr_pdivr_mulr ?ltr0z // -ltr_pdivr_mull ?normr_gt0 //. + rewrite ltr_pdivrMr ?ltr0z // -ltr_pdivrMl ?normr_gt0 //. rewrite mulr1 /j div1r -addn1 /= PoszD intrD mulr1z. rewrite gez0_abs ?floor_ge0 ?invr_ge0 ?normr_ge0 //. by rewrite -RfloorE; apply lt_succ_Rfloor. @@ -185,7 +185,7 @@ elim/nbh_finW=>e /= gt0_e. case: (sup_adherent gt0_e supE)=> x [K ->] lt_uK. exists K=> n le_Kn; rewrite inE distrC ger0_norm ?subr_ge0. by move/ubP: (sup_upper_bound supE); apply; exists n. -rewrite ltr_subl_addr addrC -ltr_subl_addr. +rewrite ltrBlDr addrC -ltrBlDr. by rewrite (lt_le_trans lt_uK) //; apply/mono_u. Qed. @@ -444,15 +444,15 @@ Hypothesis smS : summable S. Lemma ptsum_homo x y : (x <= y)%N -> (\sum_(i < x) S i <= \sum_(i < y) S i). Proof. move=> le_xy; rewrite -!(big_mkord predT) -(subnKC le_xy) /=. -by rewrite /index_iota !subn0 iotaD big_cat /= ler_addl sumr_ge0. +by rewrite /index_iota !subn0 iotaD big_cat /= lerDl sumr_ge0. Qed. Lemma psummable_ptbounded : nbounded (fun n => \sum_(i < n) S i). Proof. apply/asboolP/nboundedP; exists (psum S + 1). - rewrite ltr_spaddr ?ltr01 1?(le_trans (normr_ge0 (S 0%N))) //. + rewrite ltr_pwDr ?ltr01 1?(le_trans (normr_ge0 (S 0%N))) //. by apply/ger1_psum. -move=> n; rewrite ltr_spaddr ?ltr01 // ger0_norm ?sumr_ge0 //. +move=> n; rewrite ltr_pwDr ?ltr01 // ger0_norm ?sumr_ge0 //. apply/(le_trans _ (ger_big_ord_psum _ n)) => //. by apply/ler_sum=> /= i _; apply/ler_norm. Qed. @@ -506,9 +506,9 @@ have bd_v n : v n <= psum S. by move=> J _; apply/ler_norm. case: (ncvg_mono_bnd hm_v) => [|l cv]. apply/asboolP/nboundedP; exists (psum S + 1) => //. - by apply/(le_lt_trans (ge0_psum S)); rewrite ltr_addl ltr01. + by apply/(le_lt_trans (ge0_psum S)); rewrite ltrDl ltr01. move=> n; rewrite ger0_norm ?sumr_ge0 //. - by rewrite (le_lt_trans (bd_v n)) // ltr_addl ltr01. + by rewrite (le_lt_trans (bd_v n)) // ltrDl ltr01. have le_lS: l <= psum S by rewrite -lee_fin (ncvg_leC _ cv). rewrite (nlimE cv) /= (rwP eqP) eq_le le_lS andbT. rewrite leNgt; apply/negP=> {le_lS} /(lt_psum smS)[J]. @@ -564,8 +564,8 @@ Proof. case=> [M1 h1] [M2 h2]; exists (M1 + M2) => J /=. pose M := \sum_(x : J) (`|S1 (val x)| + `|S2 (val x)|). rewrite (@le_trans _ _ M) // ?ler_sum // => [K _|]. - by rewrite ler_norm_add. -by rewrite /M big_split ler_add ?(h1, h2). + by rewrite ler_normD. +by rewrite /M big_split lerD ?(h1, h2). Qed. (* -------------------------------------------------------------------- *) @@ -606,7 +606,7 @@ Qed. Lemma summableZ (S : T -> R) c : summable S -> summable (c \*o S). Proof. case=> [M h]; exists (`|c| * M) => J; move/(_ J): h => /=. -move/(ler_wpmul2l (normr_ge0 c)); rewrite mulr_sumr. +move/(ler_wpM2l (normr_ge0 c)); rewrite mulr_sumr. move/(le_trans _); apply; rewrite le_eqVlt; apply/orP. by left; apply/eqP/eq_bigr=> j _; rewrite normrM. Qed. @@ -622,7 +622,7 @@ Lemma summableMl (S1 S2 : T -> R) : Proof. case=> M leM smS2; apply/summable_abs. apply/(le_summable (F2 := M \*o \`|S2|)). -+ by move=> x /=; rewrite normr_ge0 /= normrM ler_wpmul2r. ++ by move=> x /=; rewrite normr_ge0 /= normrM ler_wpM2r. + by apply/summableZ/summable_abs. Qed. @@ -771,7 +771,7 @@ Lemma le_psum_condl (S : T -> R) (P : pred T) : summable S -> psum (fun x => (P x)%:R * S x) <= psum S. Proof. move=> smS; apply/le_psum_abs=> // x; rewrite normrM. -by apply/ler_pimull => //; rewrite normr_nat lern1 leq_b1. +by apply/ler_piMl => //; rewrite normr_nat lern1 leq_b1. Qed. (* -------------------------------------------------------------------- *) @@ -804,19 +804,19 @@ rewrite !psumE // (rwP eqP) eq_le -(rwP andP); split. apply/sup_le_ub. + by exists 0, fset0; rewrite big_fset0. apply/ubP=> _ [J ->]; rewrite big_split /=. - apply/ler_add; rewrite -psumE 1?(le_trans _ (gerfin_psum J _)) //. + apply/lerD; rewrite -psumE 1?(le_trans _ (gerfin_psum J _)) //. + by apply/ler_sum=> j _ /=; apply/ler_norm. + by apply/ler_sum=> j _ /=; apply/ler_norm. -rewrite -ler_subr_addr; apply/sup_le_ub. +rewrite -lerBrDr; apply/sup_le_ub. + by exists 0, fset0; rewrite big_fset0. -apply/ubP=> _ [J1 ->]; rewrite ler_subr_addr addrC. -rewrite -ler_subr_addr; apply/sup_le_ub. +apply/ubP=> _ [J1 ->]; rewrite lerBrDr addrC. +rewrite -lerBrDr; apply/sup_le_ub. + by exists 0, fset0; rewrite big_fset0. -apply/ubP=> _ [J2 ->]; rewrite ler_subr_addr addrC. +apply/ubP=> _ [J2 ->]; rewrite lerBrDr addrC. pose J := J1 `|` J2; rewrite -psumE ?(le_trans _ (gerfin_psum J _)) //. pose D := \sum_(j : J) (S1 (val j) + S2 (val j)). apply/(@le_trans _ _ D); last by apply/ler_sum=> i _; apply/ler_norm. -rewrite /D big_split /=; apply/ler_add; apply/big_fset_subset=> //. +rewrite /D big_split /=; apply/lerD; apply/big_fset_subset=> //. + by apply/fsubsetP/fsubsetUl. + by apply/fsubsetP/fsubsetUr. Qed. @@ -839,13 +839,13 @@ have smZ := summableZ c smS; rewrite (rwP eqP) eq_le. apply/andP; split; first rewrite {1}/psum asboolT //. apply/sup_le_ub. + by exists 0, fset0; rewrite big_fset0. - apply/ubP=> _ [J ->]; rewrite -ler_pdivr_mull //. + apply/ubP=> _ [J ->]; rewrite -ler_pdivrMl //. rewrite mulr_sumr (le_trans _ (gerfin_psum J _)) //. apply/ler_sum=> /= j _; rewrite normrM. by rewrite gtr0_norm // mulKf ?gt_eqF. -rewrite -ler_pdivl_mull // {1}/psum asboolT //; apply/sup_le_ub. +rewrite -ler_pdivlMl // {1}/psum asboolT //; apply/sup_le_ub. + by exists 0, fset0; rewrite big_fset0. -apply/ubP=> _ [J ->]; rewrite ler_pdivl_mull //. +apply/ubP=> _ [J ->]; rewrite ler_pdivlMl //. rewrite mulr_sumr; apply/(le_trans _ (gerfin_psum J _))=> //. by apply/ler_sum=> /= j _; rewrite normrM (gtr0_norm gt0_c). Qed. @@ -903,7 +903,7 @@ move=> eq_r ler; set s := RHS; have h J: uniq J -> \sum_(x <- J) `|S x| <= s. rewrite (perm_big [seq x <- r | x \in J]) /=. apply/uniq_perm; rewrite ?filter_uniq // => x. by rewrite !mem_filter andbC. - by rewrite big_filter ler_addl sumr_ge0. + by rewrite big_filter lerDl sumr_ge0. case/summable_of_bd: h => smS le_psum; apply/eqP. by rewrite eq_le le_psum /=; apply/gerfinseq_psum. Qed. @@ -1146,12 +1146,12 @@ Lemma le_sum S1 S2 : summable S1 -> summable S2 -> (S1 <=1 S2) -> sum S1 <= sum S2. Proof. -move=> smS1 smS2 leS; rewrite /sum ler_sub //. +move=> smS1 smS2 leS; rewrite /sum lerB //. apply/le_psum/summable_fpos => // x. by rewrite ge0_fpos /= le_fpos. apply/le_psum/summable_fneg => // x. rewrite -!fposN ge0_fpos le_fpos // => y. -by rewrite ler_opp2. +by rewrite lerN2. Qed. Lemma sum0 : sum (fun _ : T => 0) = 0 :> R. diff --git a/theories/altreals/xfinmap.v b/theories/altreals/xfinmap.v index 4de1b19cb..85eae7ff5 100644 --- a/theories/altreals/xfinmap.v +++ b/theories/altreals/xfinmap.v @@ -25,11 +25,11 @@ Proof. by case: J => J /= /canonical_uniq. Qed. (* -------------------------------------------------------------------- *) Lemma enum_fset0 (T : choiceType) : - enum [finType of fset0] = [::] :> seq (@fset0 T). + enum (fset0 : finType) = [::] :> seq (@fset0 T). Proof. by rewrite enumT unlock. Qed. Lemma enum_fset1 (T : choiceType) (x : T) : - enum [finType of [fset x]] = [:: [`fset11 x]]. + enum ([fset x] : finType) = [:: [`fset11 x]]. Proof. apply/perm_small_eq=> //; apply/uniq_perm => //. by apply/enum_uniq. @@ -125,7 +125,7 @@ Lemma big_fset_subset (I J : {fset T}) (F : T -> R) : Proof. move=> ge0_F le_IJ; rewrite !big_fset_seq /=. rewrite [X in _<=X](bigID [pred j : T | j \in I]) /=. -rewrite ler_paddr ?sumr_ge0 // -[X in _<=X]big_filter. +rewrite ler_wpDr ?sumr_ge0 // -[X in _<=X]big_filter. rewrite le_eqVlt; apply/orP; left; apply/eqP/perm_big. apply/uniq_perm; rewrite ?filter_uniq //; last move=> i. rewrite mem_filter; case/boolP: (_ \in _) => //=. diff --git a/theories/cantor.v b/theories/cantor.v index 439c41e34..11e37fecf 100644 --- a/theories/cantor.v +++ b/theories/cantor.v @@ -14,9 +14,10 @@ From HB Require Import structures. (* homeomorphism_cantor_like, and cantor_surj, a.k.a. Alexandroff-Hausdorff. *) (* *) (* ``` *) +(* pointed_principal_filter == alias for pointed types with principal *) +(* filters *) (* cantor_space == the Cantor space, with its canonical metric *) (* cantor_like T == perfect + compact + hausdroff + zero dimensional *) -(* pointed_discrete T == equips T with the discrete topology *) (* tree_of T == builds a topological tree with levels (T n) *) (* ``` *) (* *) @@ -44,8 +45,48 @@ Import numFieldTopology.Exports. Local Open Scope classical_set_scope. +(* we start by introducing an alias for pointed types with + principal filters *) +Definition pointed_principal_filter (P : pointedType) : Type := P. +HB.instance Definition _ (P : pointedType) := + Pointed.on (pointed_principal_filter P). +HB.instance Definition _ (P : pointedType) := + hasNbhs.Build (pointed_principal_filter P) principal_filter. + +(* we use `discrete_topology` to equip pointed types + with a discrete topology *) +Section discrete_topology_for_pointed_types. + +Let discrete_pointed_subproof (P : pointedType) : + discrete_space (pointed_principal_filter P). +Proof. by []. Qed. + +Definition pointed_discrete_topology (P : pointedType) : Type := + discrete_topology (discrete_pointed_subproof P). + +End discrete_topology_for_pointed_types. +(* note that in topology.v, we already have: +HB.instance Definition _ := discrete_uniform_mixin. +and +HB.instance Definition _ := discrete_pseudometric_mixin. *) + +(* we need the following proof when using + `discrete_hausdorff` or `discrete_zero_dimension` *) +Lemma discrete_pointed (T : pointedType) : + discrete_space (pointed_discrete_topology T). +Proof. +apply/funext => /= x; apply/funext => A; apply/propext; split. +- by move=> [E hE EA] x0 ->{x0}; apply: EA => /=; apply: hE => /=; exists x. +- move=> h; exists [set x | x.1 = x.2]; first by move=> -[a b] [t _] [<- <-]. + by move=> y /= xy; exact: h. +Qed. + Definition cantor_space := - product_uniformType (fun _ : nat => @discrete_uniformType _ discrete_bool). + prod_topology (fun _ : nat => discrete_topology discrete_bool). + +HB.instance Definition _ := Pointed.on cantor_space. +HB.instance Definition _ := Nbhs.on cantor_space. +HB.instance Definition _ := Topological.on cantor_space. Definition cantor_like (T : topologicalType) := [/\ perfect_set [set: T], @@ -53,17 +94,27 @@ Definition cantor_like (T : topologicalType) := hausdorff_space T & zero_dimensional T]. +(* TODO: move to topology.v? *) +Lemma discrete_bool_compact : compact [set: discrete_topology discrete_bool]. +Proof. by rewrite setT_bool; apply/compactU; exact: compact_set1. Qed. + Lemma cantor_space_compact : compact [set: cantor_space]. Proof. -have := @tychonoff _ (fun _ : nat => _) _ (fun=> bool_compact). +have := @tychonoff _ (fun _ : nat => _) _ (fun=> discrete_bool_compact). by congr (compact _); rewrite eqEsubset. Qed. Lemma cantor_space_hausdorff : hausdorff_space cantor_space. -Proof. by apply: hausdorff_product => ?; exact: discrete_hausdorff. Qed. +Proof. +apply: hausdorff_product => ?; apply: discrete_hausdorff. +exact: discrete_pointed. +Qed. Lemma cantor_zero_dimensional : zero_dimensional cantor_space. -Proof. by apply: zero_dimension_prod => _; exact: discrete_zero_dimension. Qed. +Proof. +apply: zero_dimension_prod => _; apply: discrete_zero_dimension. +exact: discrete_pointed. +Qed. Lemma cantor_perfect : perfect_set [set: cantor_space]. Proof. by apply: perfect_diagonal => _; exists (true, false). Qed. @@ -112,7 +163,7 @@ Hypothesis refine_separates: forall x y : X, x != y -> Let refine_subset n U e : @refine_apx n U e `<=` U. Proof. by rewrite [X in _ `<=` X](refine_cover n); exact: bigcup_sup. Qed. -Let T := product_topologicalType K. +Let T := prod_topology K. Local Fixpoint branch_apx (b : T) n := if n is m.+1 then refine_apx (branch_apx b m) (b m) else [set: X]. @@ -284,8 +335,8 @@ Local Lemma cantor_map : exists f : cantor_space -> T, set_inj [set: cantor_space] f ]. Proof. have [] := @tree_map_props - (fun=> [topologicalType of bool]) T c_ind c_invar cmptT hsdfT. -- by []. + (fun=> discrete_topology discrete_bool) T c_ind c_invar cmptT hsdfT. +- by move=> ?; exact: discrete_pointed. - move=> n V; rewrite eqEsubset; split => [t Vt|t [? ? []]//]. have [?|?] := pselect (U_ n `&` V !=set0 /\ ~` U_ n `&` V !=set0). + have [Unt|Unt] := pselect (U_ n t). @@ -312,7 +363,8 @@ have [] := @tree_map_props rewrite {1 2}/c_ind; case: pselect => /=; rewrite ?UnA. by move=> _; case: e; case => // ? ?; apply/not_andP; left. by apply: absurd; split; [exists x | exists y]. -- move=> f [ctsf surjf injf]; exists f; split => //; apply: injf. +- move=> f [ctsf surjf injf]; exists f; split => //. + apply: injf. by move=> n U i j _ _ [z] [] [] + Uz [+ _]; move: i j => [] []. Qed. @@ -345,30 +397,25 @@ End TreeStructure. Section FinitelyBranchingTrees. Context {R : realType}. -Definition pointed_discrete (P : pointedType) : pseudoMetricType R := - @discrete_pseudoMetricType R - (@discrete_uniformType (TopologicalType - (FilteredType P P principal_filter) - discrete_topological_mixin) - erefl) erefl. - Definition tree_of (T : nat -> pointedType) : pseudoMetricType R := - @product_pseudoMetricType R _ - (fun n => pointed_discrete (T n)) - (countableP _). + [the pseudoMetricType R of prod_topology + (fun n => pointed_discrete_topology (T n))]. Lemma cantor_like_finite_prod (T : nat -> topologicalType) : - (forall n, finite_set [set: pointed_discrete (T n)]) -> + (forall n, finite_set [set: pointed_discrete_topology (T n)]) -> (forall n, (exists xy : T n * T n, xy.1 != xy.2)) -> cantor_like (tree_of T). Proof. move=> finiteT twoElems; split. -- exact/(@perfect_diagonal (pointed_discrete \o T))/twoElems. +- exact/(@perfect_diagonal (pointed_discrete_topology \o T))/twoElems. - have := tychonoff (fun n => finite_compact (finiteT n)). - by congr (compact _) => //=; rewrite eqEsubset. -- apply: (@hausdorff_product _ (pointed_discrete \o T)) => n. - exact: discrete_hausdorff. -- by apply zero_dimension_prod => ?; exact: discrete_zero_dimension. + set A := (X in compact X -> _). + suff : A = [set: tree_of (fun x : nat => T x)] by move=> ->. + by rewrite eqEsubset. +- apply: (@hausdorff_product _ (pointed_discrete_topology \o T)) => n. + by apply: discrete_hausdorff; exact: discrete_pointed. +- apply: zero_dimension_prod => ?; apply: discrete_zero_dimension. + exact: discrete_pointed. Qed. End FinitelyBranchingTrees. @@ -454,7 +501,11 @@ apply: cid; have [//| _ _ _ + _] := projT2 (cid (ent_balls' (count_unif n))). by rewrite -subTset => /(_ point I) [W Q ?]; exists W; exact: Q. Qed. -Let K n := PointedType (classicType_choiceType (K' n)) (K'p n). +HB.instance Definition _ n := gen_eqMixin (K' n). +HB.instance Definition _ n := gen_choiceMixin (K' n). +HB.instance Definition _ n := isPointed.Build (K' n) (K'p n). + +Let K n := [the pointedType of K' n]. Let Tree := @tree_of R K. Let embed_refine n (U : set T) (k : K n) := @@ -475,8 +526,9 @@ Local Lemma cantor_surj_pt1 : exists2 f : Tree -> T, continuous f & set_surj [set: Tree] [set: T] f. Proof. pose entn n := projT2 (cid (ent_balls' (count_unif n))). -have [//| | |? []//| |? []// | |] := @tree_map_props (@pointed_discrete R \o K) - T (embed_refine) (embed_invar) cptT hsdfT. +have [//| | |? []//| |? []// | |] := @tree_map_props + (pointed_discrete_topology \o K) T (embed_refine) (embed_invar) cptT hsdfT. +- by move=> n; exact: discrete_pointed. - move=> n U; rewrite eqEsubset; split=> [t Ut|t [? ? []]//]. have [//|_ _ _ + _] := entn n; rewrite -subTset. move=> /(_ t I)[W cbW Wt]; exists (existT _ W cbW) => //. @@ -506,7 +558,7 @@ have [//| | |? []//| |? []// | |] := @tree_map_props (@pointed_discrete R \o K) have [z [Dz DzE]] := Csub _ cbD. have /ent_closure:= DzE _ Dx => /(_ (ent_count_unif n))/ctE [_ /= Exz]. have /ent_closure:= DzE _ Dy => /(_ (ent_count_unif n))/ctE [Ezy _]. - exact: (@entourage_split [uniformType of T] z). + exact: (@entourage_split _ (*[the uniformType of T]*) z). by move=> f [ctsf surjf _]; exists f. Qed. @@ -514,7 +566,7 @@ Local Lemma cantor_surj_pt2 : exists f : {surj [set: cantor_space] >-> [set: Tree]}, continuous f. Proof. have [|f [ctsf _]] := @homeomorphism_cantor_like R Tree; last by exists f. -apply: (@cantor_like_finite_prod _ (@pointed_discrete R \o K)) => [n /=|n]. +apply: (@cantor_like_finite_prod _ (pointed_discrete_topology \o K)) => [n /=|n]. have [//| fs _ _ _ _] := projT2 (cid (ent_balls' (count_unif n))). suff -> : [set: {classic K' n}] = (@projT1 (set T) _) @^-1` (projT1 (cid (ent_balls' (count_unif n)))). diff --git a/theories/charge.v b/theories/charge.v index f2fb02d85..30b2d11b0 100644 --- a/theories/charge.v +++ b/theories/charge.v @@ -88,7 +88,7 @@ Local Open Scope classical_set_scope. Local Open Scope ereal_scope. HB.mixin Record isAdditiveCharge d (T : semiRingOfSetsType d) (R : numFieldType) - (mu : set T -> \bar R) := { charge_semi_additive : semi_additive mu }. + (mu : set T -> \bar R) := { charge_semi_additive : measure.semi_additive mu }. #[short(type=additive_charge)] HB.structure Definition AdditiveCharge d (T : semiRingOfSetsType d) @@ -123,7 +123,7 @@ Let finite : fin_num_fun mu. Proof. exact: charge_finite. Qed. HB.instance Definition _ := SigmaFinite_isFinite.Build d T R mu finite. -Let semi_additive : semi_additive mu. +Let semi_additive : measure.semi_additive mu. Proof. move=> I n mI trivI mUI. rewrite (semi_sigma_additive_is_additive charge0)//. @@ -153,7 +153,7 @@ Qed. Hint Resolve charge0 : core. Lemma charge_semi_additiveW nu : - nu set0 = 0 -> semi_additive nu -> semi_additive2 nu. + nu set0 = 0 -> measure.semi_additive nu -> semi_additive2 nu. Proof. move=> nu0 anu A B mA mB + AB; rewrite -bigcup2inE bigcup_mkord. move=> /(anu (bigcup2 A B)) ->. @@ -284,7 +284,7 @@ Qed. HB.instance Definition _ := SigmaFinite_isFinite.Build _ _ _ restr crestr_finite_measure_function. -Let crestr_semi_additive : semi_additive restr. +Let crestr_semi_additive : measure.semi_additive restr. Proof. move=> F n mF tF mU; pose FD i := F i `&` D. have mFD i : measurable (FD i) by exact: measurableI. @@ -340,7 +340,7 @@ Qed. Let crestr0_sigma_additive : semi_sigma_additive restr. Proof. move=> F mF tF mU; rewrite /crestr0 mem_set//. -rewrite [X in X --> _](_ : _ = (fun n => \sum_(0 <= i < n) crestr nu mD (F i))). +rewrite [X in X @ _ --> _](_ : _ = (fun n => \sum_(0 <= i < n) crestr nu mD (F i))). exact: charge_semi_sigma_additive. by apply/funext => n; apply: eq_bigr => i _; rewrite mem_set. Qed. @@ -363,7 +363,7 @@ Proof. by []. Qed. Let czero_sigma_additive : semi_sigma_additive czero. Proof. -move=> F mF tF mUF; rewrite [X in X --> _](_ : _ = cst 0); first exact: cvg_cst. +move=> F mF tF mUF; rewrite [X in X @ _ --> _](_ : _ = cst 0); first exact: cvg_cst. by apply/funext => n; rewrite big1. Qed. @@ -385,14 +385,27 @@ Let cscale0 : cscale set0 = 0. Proof. by rewrite /cscale charge0 mule0. Qed. Let cscale_finite_measure_function U : measurable U -> cscale U \is a fin_num. Proof. by move=> mU; apply: fin_numM => //; exact: fin_num_measure. Qed. +HB.instance Definition _ := SigmaFinite_isFinite.Build _ _ _ + cscale cscale_finite_measure_function. + +Let cscale_semi_additive : measure.semi_additive cscale. +Proof. +move=> F n mF tF mU; rewrite /cscale charge_semi_additive//. +rewrite fin_num_sume_distrr// => i j _ _. +by rewrite fin_num_adde_defl// fin_num_measure. +Qed. + +HB.instance Definition _ := + isAdditiveCharge.Build _ _ _ cscale cscale_semi_additive. + Let cscale_sigma_additive : semi_sigma_additive cscale. Proof. -move=> F mF tF mUF; rewrite /cscale; rewrite [X in X --> _](_ : _ = +move=> F mF tF mUF; rewrite /cscale; rewrite [X in X @ _ --> _](_ : _ = (fun n => r%:E * \sum_(0 <= i < n) nu (F i))); last first. apply/funext => k; rewrite fin_num_sume_distrr// => i j _ _. by rewrite fin_num_adde_defl// fin_num_measure. rewrite /mscale; have [->|r0] := eqVneq r 0%R. - rewrite mul0e [X in X --> _](_ : _ = (fun=> 0)); first exact: cvg_cst. + rewrite mul0e [X in X @ _ --> _](_ : _ = (fun=> 0)); first exact: cvg_cst. by under eq_fun do rewrite mul0e. by apply: cvgeMl => //; apply: charge_semi_sigma_additive. Qed. @@ -572,7 +585,7 @@ have SSF : S = \bigcup_i SF i. have mSF n : measurable (SF n). apply: measurableD; first by apply: measurableI => //; have [] := hF n. by apply: bigcup_measurable => // k _; have [] := hF k. -have SFS : (fun n => \sum_(0 <= i < n) nu (SF i)) --> nu S. +have SFS : (\sum_(0 <= i < n) nu (SF i)) @[n --> \oo] --> nu S. by rewrite SSF; apply: charge_semi_sigma_additive => //; [by rewrite /SF -seqDUIE; exact: trivIset_seqDU|exact: bigcup_measurable]. have nuS_ n : nu (SF n) <= 0 by have [_] := hF n; apply => // x -[[]]. @@ -627,22 +640,22 @@ Let next_elt A : Proof. pose m := mine (d_ A * 2^-1%R%:E) 1; apply/cid. have := d_ge0 A; rewrite le_eqVlt => /predU1P[<-|d_gt0]. - by exists set0; split => //; rewrite charge0. + by exists set0; split => //; rewrite charge0 mul0e minEle lee01. have /ereal_sup_gt/cid2[_ [B/= [mB BDA <- mnuB]]] : m < d_ A. rewrite /m; have [->|dn1oo] := eqVneq (d_ A) +oo. by rewrite min_r ?ltey ?gt0_mulye ?leey. rewrite -(@fineK _ (d_ A)); last by rewrite gt0_fin_numE// ltey. rewrite -EFinM -fine_min// lte_fin lt_minl; apply/orP; left. - by rewrite ltr_pdivr_mulr// ltr_pmulr ?ltr1n// fine_gt0// d_gt0/= ltey. + by rewrite ltr_pdivrMr// ltr_pMr ?ltr1n// fine_gt0// d_gt0/= ltey. by exists B; split => //; rewrite (le_trans _ (ltW mnuB)). Qed. Let mine2_cvg_0_cvg_0 (u : (\bar R)^nat) : (forall k, 0 <= u k) -> - mine (u n * 2^-1%:E) 1 @[n --> \oo] --> 0 -> u --> 0. + mine (u n * 2^-1%:E) 1 @[n --> \oo] --> 0 -> u n @[n --> \oo] --> 0. Proof. move=> u0 h. have u2 n : u n = 2%:E * (u n * 2^-1%:E) by rewrite muleCA -EFinM divff ?mule1. -under eq_cvg do rewrite u2. +rewrite (eq_cvg _ _ u2) -[X in _ --> X]/(nbhs 0). rewrite -(mule0 2%:E); apply: cvgeMl => //. by apply: (mine_cvg_0_cvg_0 lte01) => // n; rewrite mule_ge0. Qed. @@ -669,27 +682,25 @@ have tA : trivIset setT (A_ \o v). set Aoo := \bigcup_k A_ (v k). have mAoo : measurable Aoo by exact: bigcup_measurable. exists (D `\` Aoo). -have cvg_nuA : (fun n => \sum_(0 <= i < n) nu (A_ (v i))) --> nu Aoo. +have cvg_nuA : (\sum_(0 <= i < n) nu (A_ (v i))) @[n --> \oo]--> nu Aoo. exact: charge_semi_sigma_additive. have nuAoo : 0 <= nu Aoo. move/cvg_lim : cvg_nuA => <-//=; apply: nneseries_ge0 => n _. exact: nuA_ge0. -have A_cvg_0 : (fun n => nu (A_ (v n))) --> 0. - rewrite [X in X --> _](_ : _ = (fun n => (fine (nu (A_ (v n))))%:E)); last first. +have A_cvg_0 : nu (A_ (v n)) @[n --> \oo] --> 0. + rewrite [X in X @ _ --> _](_ : _ = (fun n => (fine (nu (A_ (v n))))%:E)); last first. by apply/funext => n/=; rewrite fineK// fin_num_measure. - apply: continuous_cvg => //. - apply: (@cvg_series_cvg_0 _ [normedModType R of R^o]). - rewrite (_ : series _ = - fine \o (fun n => \sum_(0 <= i < n) nu (A_ (v i)))); last first. + apply: continuous_cvg => //; apply: cvg_series_cvg_0. + rewrite (_ : series _ = fine \o (fun n => \sum_(0 <= i < n) nu (A_ (v i)))); last first. apply/funext => n /=. by rewrite /series/= sum_fine//= => i _; rewrite fin_num_measure. move: cvg_nuA; rewrite -(@fineK _ (nu Aoo)) ?fin_num_measure//. by move=> /fine_cvgP[_ ?]; apply/cvg_ex; exists (fine (nu Aoo)). -have mine_cvg_0 : (fun n => mine (g_ (v n) * 2^-1%:E) 1) --> 0. +have mine_cvg_0 : (mine (g_ (v n) * 2^-1%:E) 1) @[n --> \oo] --> 0. apply: (@squeeze_cvge _ _ _ _ _ _ (fun n => nu (A_ (v n)))); [|exact: cvg_cst|by []]. by apply: nearW => n /=; rewrite nuA_g_ andbT le_minr lee01 andbT mule_ge0. -have d_cvg_0 : g_ \o v --> 0 by apply: mine2_cvg_0_cvg_0 => //=. +have g_cvg_0 : (g_ \o v) n @[n --> \oo] --> 0 by apply: mine2_cvg_0_cvg_0 => //=. have nuDAoo : nu D >= nu (D `\` Aoo). rewrite -[in leRHS](@setDUK _ Aoo D); last first. by apply: bigcup_sub => i _; exact: A_D. @@ -710,7 +721,7 @@ have nudelta n : nu E <= g_ (v n). apply/le_ereal_sup => x/= [A' [mA' A'D ?]]. exists A' => //; split => //. by apply: (subset_trans A'D); apply: setDS; rewrite Ubig. -apply: (@closed_cvg _ _ _ _ _ (fun v => nu E <= v) _ _ _ d_cvg_0) => //. +apply: (@closed_cvg _ _ _ _ _ (fun v => nu E <= v) _ _ _ g_cvg_0) => //. exact: closed_ereal_le_ereal. exact: nearW. Unshelve. all: by end_near. Qed. @@ -763,13 +774,14 @@ Let next_elt U : { A | [/\ A `<=` ~` U, Proof. pose m := maxe (s_ U * 2^-1%R%:E) (- 1%E); apply/cid. have := s_le0 U; rewrite le_eqVlt => /predU1P[->|s_lt0]. - by exists set0; split => //; rewrite ?charge0//; exact: negative_set0. + exists set0; split => //; rewrite ?charge0 ?mul0e ?maxEle ?lee0N1//. + exact: negative_set0. have /ereal_inf_lt/cid2[_ [B/= [mB BU] <-] nuBm] : s_ U < m. rewrite /m; have [->|s0oo] := eqVneq (s_ U) -oo. by rewrite max_r ?ltNye// gt0_mulNye// leNye. rewrite -(@fineK _ (s_ U)); last by rewrite lt0_fin_numE// ltNye. rewrite -EFinM -fine_max// lte_fin lt_maxr; apply/orP; left. - by rewrite ltr_pdivl_mulr// gtr_nmulr ?ltr1n// fine_lt0// s_lt0/= ltNye andbT. + by rewrite ltr_pdivlMr// gtr_nMr ?ltr1n// fine_lt0// s_lt0/= ltNye andbT. have [C [CB nsC nuCB]] := hahn_decomposition_lemma nu mB. exists C; split => //; first exact: (subset_trans CB). by rewrite (le_trans nuCB)// (le_trans (ltW nuBm)). @@ -807,22 +819,22 @@ have znuD n : z_ (v n) <= nu D. exact: bigsetU_bigcup. have max_le0 n : maxe (z_ (v n) * 2^-1%:E) (- 1%E) <= 0. by rewrite le_maxl leeN10 andbT pmule_lle0. -have not_s_cvg_0 : ~ z_ \o v --> 0. - move/fine_cvgP => -[zfin] /(@cvgrPdist_lt _ [normedModType R of R^o]). +have not_s_cvg_0 : ~ (z_ \o v) n @[n --> \oo] --> 0. + move/fine_cvgP => -[zfin] /cvgrPdist_lt. have /[swap] /[apply] -[M _ hM] : (0 < `|fine (nu D)|)%R. by rewrite normr_gt0// fine_eq0// ?lt_eqF// fin_num_measure. near \oo => n. have /hM : (M <= n)%N by near: n; exists M. rewrite sub0r normrN /= ler0_norm ?fine_le0// ltr0_norm//; last first. by rewrite fine_lt0// nuD0 andbT ltNye_eq fin_num_measure. - rewrite ltr_opp2; apply/negP; rewrite -leNgt fine_le ?fin_num_measure//. + rewrite ltrN2; apply/negP; rewrite -leNgt fine_le ?fin_num_measure//. by near: n; exact. have nuN : nu N = \sum_(n //. by apply: charge_semi_sigma_additive; [|exact: tA|exact: bigcup_measurable]. have sum_A_maxe : \sum_(n \sum_(0 <= k < n) maxe (z_ (v k) * 2^-1%:E) (- 1%E)). +have : cvg (\sum_(0 <= k < n) maxe (z_ (v k) * 2^-1%:E) (- 1%E) @[n --> \oo]). by apply: is_cvg_ereal_npos_natsum_cond => n _ _; exact: max_le0. move=> /cvg_ex[[l| |]]; first last. - move/cvg_lim => limNoo. @@ -832,14 +844,14 @@ move=> /cvg_ex[[l| |]]; first last. have := @npeseries_le0 _ (fun n => maxe (z_ (v n) * 2^-1%:E) (- 1%E)) xpredT 0. by rewrite limoo// leNgt => /(_ (fun n _ => max_le0 n))/negP; apply. move/fine_cvgP => [Hfin cvgl]. -have : cvg (series (fun n => fine (maxe (z_ (v n) * 2^-1%:E) (- 1%E)))). +have : cvg (series (fun n => fine (maxe (z_ (v n) * 2^-1%:E) (- 1%E))) n @[n --> \oo]). apply/cvg_ex; exists l; move: cvgl. rewrite (_ : _ \o _ = (fun n => \sum_(0 <= k < n) fine (maxe (z_ (v k) * 2^-1%:E)%E (- 1%E)%E))%R) //. apply/funext => n/=; rewrite sum_fine// => m _. rewrite le0_fin_numE; first by rewrite lt_maxr ltNyr orbT. by rewrite /maxe; case: ifPn => // _; rewrite mule_le0_ge0. -move/(@cvg_series_cvg_0 _ [normedModType R of R^o]) => maxe_cvg_0. +move/cvg_series_cvg_0 => maxe_cvg_0. apply: not_s_cvg_0. rewrite (_ : _ \o _ = (fun n => z_ (v n) * 2^-1%:E) \* cst 2%:E); last first. by apply/funext => n/=; rewrite -muleA -EFinM mulVr ?mule1// unitfE. @@ -851,7 +863,7 @@ apply/fine_cvgP; split. rewrite sub0r normrN ltNge => maxe_lt1; rewrite fin_numE; apply/andP; split. by apply: contra maxe_lt1 => /eqP ->; rewrite max_r ?leNye//= normrN1 lexx. by rewrite lt_eqF// (@le_lt_trans _ _ 0)// mule_le0_ge0. -apply/(@cvgrPdist_lt _ [normedModType R of R^o]) => _ /posnumP[e]. +apply/cvgrPdist_lt => _ /posnumP[e]. have : (0 < minr e%:num 1)%R by rewrite lt_minr// ltr01 andbT. move/cvgrPdist_lt : maxe_cvg_0 => /[apply] -[M _ hM]. near=> n; rewrite sub0r normrN. @@ -927,8 +939,8 @@ Proof. by rewrite /= /cscale/= EFinN mulN1e. Qed. Let positive_set_cjordan_neg E : 0 <= cjordan_neg E. Proof. -rewrite cjordan_negE /crestr0/=; case: ifPn => // /[1!inE] mE. -rewrite /crestr lee_oppr oppe0. +rewrite cjordan_negE /crestr0/=; case: ifPn; rewrite ?oppe0//. +move=> /[!inE] mE; rewrite /crestr lee_oppr oppe0. by move: nuPN => [_ [_ +] _ _] => -> //; exact: measurableI. Qed. @@ -1100,11 +1112,11 @@ Proof. by apply/bigmax_geP; right => /=; exists ord_max. Qed. Lemma max_approxRN_seq_nd x : nondecreasing_seq (F_ ^~ x). Proof. by move=> a b ab; rewrite (le_bigmax_ord xpredT (g_ ^~ x)). Qed. -Lemma is_cvg_max_approxRN_seq n : cvg (F_ ^~ n). +Lemma is_cvg_max_approxRN_seq n : cvg (F_ ^~ n @ \oo). Proof. by apply: ereal_nondecreasing_is_cvgn; exact: max_approxRN_seq_nd. Qed. Lemma is_cvg_int_max_approxRN_seq A : - measurable A -> cvg (fun n => \int[mu]_(x in A) F_ n x). + measurable A -> cvg ((fun n => \int[mu]_(x in A) F_ n x) @ \oo). Proof. move=> mA; apply: ereal_nondecreasing_is_cvgn => a b ab. apply: ge0_le_integral => //. @@ -1189,7 +1201,7 @@ Import approxRN_seq. Let g := approxRN_seq mu nu. Let F := max_approxRN_seq mu nu. -Definition fRN := fun x => lim (F ^~ x). +Definition fRN := fun x => lim (F ^~ x @ \oo). Lemma measurable_fun_fRN : measurable_fun [set: T] fRN. Proof. @@ -1207,7 +1219,7 @@ by apply: nearW => ?; exact: max_approxRN_seq_ge0. Qed. Let int_fRN_lim A : measurable A -> - \int[mu]_(x in A) fRN x = lim (fun n => \int[mu]_(x in A) F n x). + \int[mu]_(x in A) fRN x = lim (\int[mu]_(x in A) F n x @[n --> \oo]). Proof. move=> mA; rewrite monotone_convergence// => n. - exact: measurable_funS (measurable_max_approxRN_seq mu nu n). @@ -1295,7 +1307,7 @@ apply/eqP; rewrite eq_le; apply/andP; split. rewrite int_fRN_lim// lime_le//; first exact: is_cvg_int_max_approxRN_seq. by apply: nearW => n; have [_ /andP[_]] := M_g_F n. rewrite int_fRN_lim//. -have cvgM : (fun m => M - m.+1%:R^-1%:E) --> M. +have cvgM : (M - m.+1%:R^-1%:E) @[m --> \oo] --> M. rewrite -[X in _ --> X]sube0; apply: cvgeB. + by rewrite fin_num_adde_defl. + exact: cvg_cst. @@ -1305,7 +1317,7 @@ have cvgM : (fun m => M - m.+1%:R^-1%:E) --> M. apply/cvgrnyP. rewrite [X in X @ _](_ : _ = fun n => n + 1)%N; first exact: cvg_addnr. by apply/funext => n; rewrite addn1. -apply: (@le_trans _ _ (lim (fun m => M - m.+1%:R^-1%:E))). +apply: (@le_trans _ _ (lim (M - m.+1%:R^-1%:E @[m --> \oo]))). by move/cvg_lim : cvgM => ->. apply: lee_lim; [by apply/cvg_ex; exists M|exact: is_cvg_int_max_approxRN_seq|]. apply: nearW => m. @@ -1347,7 +1359,7 @@ rewrite -EFinM -mulrA mulVr ?mulr1; last first. by rewrite unitfE gt_eqF// fine_gt0// muA_gt0/= ltey_eq fin_num_measure. rewrite lte_subr_addl// addeC -lte_subr_addl//; last first. rewrite -(@fineK _ (nu A))// ?fin_num_measure// -[X in _ - X](@fineK _)//. -rewrite -EFinB lte_fin /mid ltr_pdivr_mulr// ltr_pmulr// ?ltr1n// subr_gt0. +rewrite -EFinB lte_fin /mid ltr_pdivrMr// ltr_pMr// ?ltr1n// subr_gt0. by rewrite fine_lt// fin_num_measure. Qed. @@ -1387,7 +1399,7 @@ Qed. Let sigmaRN_sigma_additive : semi_sigma_additive sigmaRN. Proof. move=> H mH tH mUH. -rewrite [X in X --> _](_ : _ = (fun n => \sum_(0 <= i < n) nu (H i) - +rewrite [X in X @ _ --> _](_ : _ = (fun n => \sum_(0 <= i < n) nu (H i) - \sum_(0 <= i < n) \int[mu]_(x in H i) (fRN x + epsRN%:num%:E))); last first. apply/funext => n; rewrite big_split/= fin_num_sumeN// => i _. by rewrite fin_num_int_fRN_eps. @@ -1395,14 +1407,14 @@ apply: cvgeB. - by rewrite adde_defC fin_num_adde_defl// fin_num_measure. - exact: measure_semi_sigma_additive. - rewrite (ge0_integral_bigcup mH _ _ tH). - + have /cvg_ex[/= l hl] : cvg (fun x => - \sum_(0 <= i < x) \int[mu]_(y in H i) (fRN y + epsRN%:num%:E)). + + have /cvg_ex[/= l hl] : cvg ((fun n => + \sum_(0 <= i < n) \int[mu]_(y in H i) (fRN y + epsRN%:num%:E)) @ \oo). apply: is_cvg_ereal_nneg_natsum => n _. by apply: integral_ge0 => x _; rewrite adde_ge0//; exact: fRN_ge0. by rewrite (@cvg_lim _ _ _ _ _ _ l). + apply: integrableD => //=. * apply: (integrableS measurableT) => //. - by apply/integrableP; split; [exact: measurable_fun_fRN|exact: int_fRN_lty]. + by apply/integrableP; split; [exact:measurable_fun_fRN|exact:int_fRN_lty]. * apply/integrableP; split => //. by rewrite integral_cst// lte_mul_pinfty// ltey_eq fin_num_measure. + by move=> x _; rewrite adde_ge0//; exact: fRN_ge0. diff --git a/theories/constructive_ereal.v b/theories/constructive_ereal.v index 6b6d0e1e7..6c3c0643b 100644 --- a/theories/constructive_ereal.v +++ b/theories/constructive_ereal.v @@ -9,6 +9,7 @@ (c.f. https://github.com/math-comp/real-closed/pull/29 ) and incorporate it into mathcomp proper where it could then be used for bounds of intervals*) +From HB Require Import structures. From mathcomp Require Import all_ssreflect all_algebra finmap. From mathcomp Require Import mathcomp_extra. Require Import signed. @@ -75,9 +76,11 @@ Unset Strict Implicit. Unset Printing Implicit Defensive. Reserved Notation "x %:E" (at level 2, format "x %:E"). +Reserved Notation "x %:dE" (at level 2, format "x %:dE"). Reserved Notation "x +? y" (at level 50, format "x +? y"). Reserved Notation "x *? y" (at level 50, format "x *? y"). Reserved Notation "'\bar' x" (at level 2, format "'\bar' x"). +Reserved Notation "'\bar' '^d' x" (at level 2, format "'\bar' '^d' x"). Reserved Notation "{ 'posnum' '\bar' R }" (at level 0, format "{ 'posnum' '\bar' R }"). Reserved Notation "{ 'nonneg' '\bar' R }" (at level 0, @@ -98,6 +101,8 @@ Proof. by move=> a b; case. Qed. Definition dual_extended := extended. +Definition dEFin : forall {R}, R -> dual_extended R := @EFin. + (* Notations in ereal_dual_scope should be kept *before* the corresponding notation in ereal_scope, otherwise when none of the scope is open (lte x y) would be displayed as (x < y)%dE, instead @@ -106,10 +111,13 @@ Notation "+oo" := (@EPInf _ : dual_extended _) : ereal_dual_scope. Notation "+oo" := (@EPInf _) : ereal_scope. Notation "-oo" := (@ENInf _ : dual_extended _) : ereal_dual_scope. Notation "-oo" := (@ENInf _) : ereal_scope. +Notation "r %:dE" := (@EFin _ r%R : dual_extended _) : ereal_dual_scope. +Notation "r %:E" := (@EFin _ r%R : dual_extended _) : ereal_dual_scope. Notation "r %:E" := (@EFin _ r%R). Notation "'\bar' R" := (extended R) : type_scope. -Notation "0" := (0%R%:E : dual_extended _) : ereal_dual_scope. -Notation "0" := (0%R%:E) : ereal_scope. +Notation "'\bar' '^d' R" := (dual_extended R) : type_scope. +Notation "0" := (@GRing.zero (\bar^d _)) : ereal_dual_scope. +Notation "0" := (@GRing.zero (\bar _)) : ereal_scope. Notation "1" := (1%R%:E : dual_extended _) : ereal_dual_scope. Notation "1" := (1%R%:E) : ereal_scope. @@ -146,8 +154,7 @@ Definition eq_ereal (x y : \bar R) := Lemma ereal_eqP : Equality.axiom eq_ereal. Proof. by case=> [?||][?||]; apply: (iffP idP) => //= [/eqP|[]] ->. Qed. -Definition ereal_eqMixin := Equality.Mixin ereal_eqP. -Canonical ereal_eqType := Equality.Pack ereal_eqMixin. +HB.instance Definition _ := hasDecEq.Build (\bar R) ereal_eqP. Lemma eqe (r1 r2 : R) : (r1%:E == r2%:E) = (r1 == r2). Proof. by []. Qed. @@ -173,16 +180,14 @@ Definition decode (x : GenTree.tree R) : option (\bar R) := Lemma codeK : pcancel code decode. Proof. by case. Qed. -Definition ereal_choiceMixin := PcanChoiceMixin codeK. -Canonical ereal_choiceType := ChoiceType (extended R) ereal_choiceMixin. +HB.instance Definition _ := Choice.copy (\bar R) (pcan_type codeK). End ERealChoice. Section ERealCount. Variable (R : countType). -Definition ereal_countMixin := PcanCountMixin (@codeK R). -Canonical ereal_countType := CountType (extended R) ereal_countMixin. +HB.instance Definition _ := PCanIsCountable (@codeK R). End ERealCount. @@ -225,11 +230,8 @@ Qed. Fact ereal_display : unit. Proof. by []. Qed. -Definition ereal_porderMixin := - LePOrderMixin lt_def_ereal le_refl_ereal le_anti_ereal le_trans_ereal. - -Canonical ereal_porderType := - POrderType ereal_display (extended R) ereal_porderMixin. +HB.instance Definition _ := Order.isPOrder.Build ereal_display (\bar R) + lt_def_ereal le_refl_ereal le_anti_ereal le_trans_ereal. Lemma leEereal x y : (x <= y)%O = le_ereal x y. Proof. by []. Qed. Lemma ltEereal x y : (x < y)%O = lt_ereal x y. Proof. by []. Qed. @@ -284,6 +286,63 @@ Notation "x < y < z" := ((x < y) && (y < z)) : ereal_scope. Notation "x <= y :> T" := ((x : T) <= (y : T)) (only parsing) : ereal_scope. Notation "x < y :> T" := ((x : T) < (y : T)) (only parsing) : ereal_scope. +Section ERealZsemimodule. +Context {R : nmodType}. +Implicit Types x y z : \bar R. + +Definition adde_subdef x y := + match x, y with + | x%:E , y%:E => (x + y)%:E + | -oo, _ => -oo + | _ , -oo => -oo + | +oo, _ => +oo + | _ , +oo => +oo + end. + +Definition adde := nosimpl adde_subdef. + +Definition dual_adde_subdef x y := + match x, y with + | x%:E , y%:E => (x + y)%R%:E + | +oo, _ => +oo + | _ , +oo => +oo + | -oo, _ => -oo + | _ , -oo => -oo + end. + +Definition dual_adde := nosimpl dual_adde_subdef. + +Lemma addeA_subproof : associative (S := \bar R) adde. +Proof. by case=> [x||] [y||] [z||] //; rewrite /adde /= addrA. Qed. + +Lemma addeC_subproof : commutative (S := \bar R) adde. +Proof. by case=> [x||] [y||] //; rewrite /adde /= addrC. Qed. + +Lemma add0e_subproof : left_id (0%:E : \bar R) adde. +Proof. by case=> // r; rewrite /adde /= add0r. Qed. + +HB.instance Definition _ := GRing.isNmodule.Build (\bar R) + addeA_subproof addeC_subproof add0e_subproof. + +Lemma daddeA_subproof : associative (S := \bar^d R) dual_adde. +Proof. by case=> [x||] [y||] [z||] //; rewrite /dual_adde /= addrA. Qed. + +Lemma daddeC_subproof : commutative (S := \bar^d R) dual_adde. +Proof. by case=> [x||] [y||] //; rewrite /dual_adde /= addrC. Qed. + +Lemma dadd0e_subproof : left_id (0%:dE%dE : \bar^d R) dual_adde. +Proof. by case=> // r; rewrite /dual_adde /= add0r. Qed. + +HB.instance Definition _ := Choice.on (\bar^d R). +HB.instance Definition _ := GRing.isNmodule.Build (\bar^d R) + daddeA_subproof daddeC_subproof dadd0e_subproof. + +Definition enatmul x n : \bar R := iterop n +%R x 0. + +Definition ednatmul (x : \bar^d R) n : \bar^d R := iterop n +%R x 0. + +End ERealZsemimodule. + Section ERealOrder_numDomainType. Context {R : numDomainType}. Implicit Types (x y : \bar R) (r : R). @@ -370,53 +429,23 @@ move=> ndf. by move=> [r| |] [l| |]//=; rewrite ?leey ?leNye// !lee_fin; exact: ndf. Qed. -Lemma le_total_ereal : totalPOrderMixin [porderType of \bar R]. +Lemma le_total_ereal : total (Order.le : rel (\bar R)). Proof. by move=> [?||][?||]//=; rewrite (ltEereal, leEereal)/= ?num_real ?le_total. Qed. -Canonical ereal_latticeType := LatticeType (extended R) le_total_ereal. -Canonical ereal_distrLatticeType := DistrLatticeType (extended R) le_total_ereal. -Canonical ereal_orderType := OrderType (extended R) le_total_ereal. - -Lemma ereal_blatticeMixin : - Order.BLattice.mixin_of (Order.POrder.class (@ereal_porderType R)). -Proof. by exists -oo; exact leNye. Qed. -Canonical ereal_blatticeType := BLatticeType (extended R) ereal_blatticeMixin. +HB.instance Definition _ := Order.POrder_isTotal.Build ereal_display (\bar R) + le_total_ereal. -Lemma ereal_tblatticeMixin : - Order.TBLattice.mixin_of (Order.POrder.class ereal_blatticeType). -Proof. by exists +oo; exact leey. Qed. -Canonical ereal_tblatticeType := TBLatticeType (extended R) ereal_tblatticeMixin. +HB.instance Definition _ := Order.hasBottom.Build ereal_display (\bar R) leNye. +HB.instance Definition _ := Order.hasTop.Build ereal_display (\bar R) leey. End ERealOrder_realDomainType. -Section ERealArith. -Context {R : numDomainType}. +Section ERealZmodule. +Context {R : zmodType}. Implicit Types x y z : \bar R. -Definition adde_subdef x y := - match x, y with - | x%:E , y%:E => (x + y)%:E - | -oo, _ => -oo - | _ , -oo => -oo - | +oo, _ => +oo - | _ , +oo => +oo - end. - -Definition adde := nosimpl adde_subdef. - -Definition dual_adde_subdef x y := - match x, y with - | x%:E , y%:E => (x + y)%R%:E - | +oo, _ => +oo - | _ , +oo => +oo - | -oo, _ => -oo - | _ , -oo => -oo - end. - -Definition dual_adde := nosimpl dual_adde_subdef. - Definition oppe x := match x with | r%:E => (- r)%:E @@ -424,6 +453,12 @@ Definition oppe x := | +oo => -oo end. +End ERealZmodule. + +Section ERealArith. +Context {R : numDomainType}. +Implicit Types x y z : \bar R. + Definition mule_subdef x y := match x, y with | x%:E , y%:E => (x * y)%:E @@ -433,35 +468,31 @@ Definition mule_subdef x y := Definition mule := nosimpl mule_subdef. -Definition abse x := if x is r%:E then `|r|%:E else +oo. +Definition abse x : \bar R := if x is r%:E then `|r|%:E else +oo. Definition expe x n := iterop n mule x 1. -Definition enatmul x n := iterop n adde x 0. - -Definition ednatmul x n := iterop n dual_adde x 0. - End ERealArith. -Notation "+%dE" := dual_adde. -Notation "+%E" := adde. +Notation "+%dE" := (@GRing.add (\bar^d _)). +Notation "+%E" := (@GRing.add (\bar _)). Notation "-%E" := oppe. -Notation "x + y" := (dual_adde x%dE y%dE) : ereal_dual_scope. -Notation "x + y" := (adde x y) : ereal_scope. -Notation "x - y" := (dual_adde x%dE (oppe y%dE)) : ereal_dual_scope. -Notation "x - y" := (adde x (oppe y)) : ereal_scope. -Notation "- x" := (oppe (x%dE : dual_extended _)) : ereal_dual_scope. -Notation "- x" := (oppe x) : ereal_scope. +Notation "x + y" := (GRing.add (x%dE : \bar^d _) y%dE) : ereal_dual_scope. +Notation "x + y" := (GRing.add x%E y%E) : ereal_scope. +Notation "x - y" := ((x%dE : \bar^d _) + oppe y%dE) : ereal_dual_scope. +Notation "x - y" := (x%E + (oppe y%E)) : ereal_scope. +Notation "- x" := (oppe x%dE : \bar^d _) : ereal_dual_scope. +Notation "- x" := (oppe x%E) : ereal_scope. Notation "*%E" := mule. -Notation "x * y" := (mule (x%dE : dual_extended _) (y%dE : dual_extended _)) : ereal_dual_scope. -Notation "x * y" := (mule x y) : ereal_scope. -Notation "`| x |" := (abse (x%dE : dual_extended _)) : ereal_dual_scope. -Notation "`| x |" := (abse x) : ereal_scope. +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. Arguments abse {R}. -Notation "x ^+ n" := (expe x%dE n) : ereal_dual_scope. -Notation "x ^+ n" := (expe x n) : ereal_scope. +Notation "x ^+ n" := (expe x%dE n : \bar^d _) : ereal_dual_scope. +Notation "x ^+ n" := (expe x%E n) : ereal_scope. Notation "x *+ n" := (ednatmul x%dE n) : ereal_dual_scope. -Notation "x *+ n" := (enatmul x n) : ereal_scope. +Notation "x *+ n" := (enatmul x%E n) : ereal_scope. Notation "\- f" := (fun x => - f x)%dE : ereal_dual_scope. Notation "\- f" := (fun x => - f x)%E : ereal_scope. @@ -473,53 +504,53 @@ Notation "f \- g" := (fun x => f x - g x)%dE : ereal_dual_scope. Notation "f \- g" := (fun x => f x - g x)%E : ereal_scope. Notation "\sum_ ( i <- r | P ) F" := - (\big[+%dE/0%:E]_(i <- r | P%B) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i <- r | P%B) F%dE) : ereal_dual_scope. Notation "\sum_ ( i <- r | P ) F" := - (\big[+%E/0%:E]_(i <- r | P%B) F%E) : ereal_scope. + (\big[+%E/0%E]_(i <- r | P%B) F%E) : ereal_scope. Notation "\sum_ ( i <- r ) F" := - (\big[+%dE/0%:E]_(i <- r) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i <- r) F%dE) : ereal_dual_scope. Notation "\sum_ ( i <- r ) F" := - (\big[+%E/0%:E]_(i <- r) F%E) : ereal_scope. + (\big[+%E/0%E]_(i <- r) F%E) : ereal_scope. Notation "\sum_ ( m <= i < n | P ) F" := - (\big[+%dE/0%:E]_(m <= i < n | P%B) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(m <= i < n | P%B) F%dE) : ereal_dual_scope. Notation "\sum_ ( m <= i < n | P ) F" := - (\big[+%E/0%:E]_(m <= i < n | P%B) F%E) : ereal_scope. + (\big[+%E/0%E]_(m <= i < n | P%B) F%E) : ereal_scope. Notation "\sum_ ( m <= i < n ) F" := - (\big[+%dE/0%:E]_(m <= i < n) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(m <= i < n) F%dE) : ereal_dual_scope. Notation "\sum_ ( m <= i < n ) F" := - (\big[+%E/0%:E]_(m <= i < n) F%E) : ereal_scope. + (\big[+%E/0%E]_(m <= i < n) F%E) : ereal_scope. Notation "\sum_ ( i | P ) F" := - (\big[+%dE/0%:E]_(i | P%B) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i | P%B) F%dE) : ereal_dual_scope. Notation "\sum_ ( i | P ) F" := - (\big[+%E/0%:E]_(i | P%B) F%E) : ereal_scope. + (\big[+%E/0%E]_(i | P%B) F%E) : ereal_scope. Notation "\sum_ i F" := - (\big[+%dE/0%:E]_i F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_i F%dE) : ereal_dual_scope. Notation "\sum_ i F" := - (\big[+%E/0%:E]_i F%E) : ereal_scope. + (\big[+%E/0%E]_i F%E) : ereal_scope. Notation "\sum_ ( i : t | P ) F" := - (\big[+%dE/0%:E]_(i : t | P%B) F%dE) (only parsing) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i : t | P%B) F%dE) (only parsing) : ereal_dual_scope. Notation "\sum_ ( i : t | P ) F" := - (\big[+%E/0%:E]_(i : t | P%B) F%E) (only parsing) : ereal_scope. + (\big[+%E/0%E]_(i : t | P%B) F%E) (only parsing) : ereal_scope. Notation "\sum_ ( i : t ) F" := - (\big[+%dE/0%:E]_(i : t) F%dE) (only parsing) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i : t) F%dE) (only parsing) : ereal_dual_scope. Notation "\sum_ ( i : t ) F" := - (\big[+%E/0%:E]_(i : t) F%E) (only parsing) : ereal_scope. + (\big[+%E/0%E]_(i : t) F%E) (only parsing) : ereal_scope. Notation "\sum_ ( i < n | P ) F" := - (\big[+%dE/0%:E]_(i < n | P%B) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i < n | P%B) F%dE) : ereal_dual_scope. Notation "\sum_ ( i < n | P ) F" := - (\big[+%E/0%:E]_(i < n | P%B) F%E) : ereal_scope. + (\big[+%E/0%E]_(i < n | P%B) F%E) : ereal_scope. Notation "\sum_ ( i < n ) F" := - (\big[+%dE/0%:E]_(i < n) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i < n) F%dE) : ereal_dual_scope. Notation "\sum_ ( i < n ) F" := - (\big[+%E/0%:E]_(i < n) F%E) : ereal_scope. + (\big[+%E/0%E]_(i < n) F%E) : ereal_scope. Notation "\sum_ ( i 'in' A | P ) F" := - (\big[+%dE/0%:E]_(i in A | P%B) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i in A | P%B) F%dE) : ereal_dual_scope. Notation "\sum_ ( i 'in' A | P ) F" := - (\big[+%E/0%:E]_(i in A | P%B) F%E) : ereal_scope. + (\big[+%E/0%E]_(i in A | P%B) F%E) : ereal_scope. Notation "\sum_ ( i 'in' A ) F" := - (\big[+%dE/0%:E]_(i in A) F%dE) : ereal_dual_scope. + (\big[+%dE/0%dE]_(i in A) F%dE) : ereal_dual_scope. Notation "\sum_ ( i 'in' A ) F" := - (\big[+%E/0%:E]_(i in A) F%E) : ereal_scope. + (\big[+%E/0%E]_(i in A) F%E) : ereal_scope. Section ERealOrderTheory. Context {R : numDomainType}. @@ -646,6 +677,10 @@ Proof. by case: x => //=; rewrite oppr0. Qed. Lemma EFinD r r' : (r + r')%:E = r%:E + r'%:E. Proof. by []. Qed. +Lemma EFin_semi_additive : @semi_additive _ (\bar R) EFin. Proof. by split. Qed. +HB.instance Definition _ := GRing.isSemiAdditive.Build R (\bar R) EFin + EFin_semi_additive. + 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. @@ -680,20 +715,13 @@ Proof. by case: x. Qed. Lemma ge0_adde_def : {in [pred x | x >= 0] &, forall x y, x +? y}. Proof. by move=> [x| |] [y| |]. Qed. -Lemma addeC : commutative (S := \bar R) +%E. -Proof. by case=> [x||] [y||] //; rewrite /adde /= addrC. Qed. +Lemma addeC : commutative (S := \bar R) +%E. Proof. exact: addrC. Qed. -Lemma adde0 : right_id (0 : \bar R) +%E. -Proof. by case=> // r; rewrite /adde /= addr0. Qed. +Lemma adde0 : right_id (0 : \bar R) +%E. Proof. exact: addr0. Qed. -Lemma add0e : left_id (0 : \bar R) +%E. -Proof. by move=> x; rewrite addeC adde0. Qed. +Lemma add0e : left_id (0 : \bar R) +%E. Proof. exact: add0r. Qed. -Lemma addeA : associative (S := \bar R) +%E. -Proof. by case=> [x||] [y||] [z||] //; rewrite /adde /= addrA. Qed. - -Canonical adde_monoid := Monoid.Law addeA add0e adde0. -Canonical adde_comoid := Monoid.ComLaw addeC. +Lemma addeA : associative (S := \bar R) +%E. Proof. exact: addrA. Qed. Lemma adde_def_sum I h t (P : pred I) (f : I -> \bar R) : {in P, forall i : I, f h +? f i} -> @@ -779,7 +807,7 @@ Proof. by move: x => [r| |] //=; rewrite /mule/= ?mulr0// eqxx. Qed. Lemma mul0e x : 0 * x = 0. Proof. by move: x => [r| |]/=; rewrite /mule/= ?mul0r// eqxx. Qed. -Canonical mule_mulmonoid := @Monoid.MulLaw _ _ mule mul0e mule0. +HB.instance Definition _ := Monoid.isMulLaw.Build (\bar R) 0 mule mul0e mule0. Lemma expeS x n : x ^+ n.+1 = x * x ^+ n. Proof. by case: n => //=; rewrite mule1. Qed. @@ -825,7 +853,7 @@ Proof. by move=> [x| |] [y| |]. Qed. Lemma abse_eq0 x : (`|x| == 0) = (x == 0). Proof. by move: x => [| |] //= r; rewrite !eqe normr_eq0. Qed. -Lemma abse0 : `|0| = 0 :> \bar R. Proof. by rewrite /abse normr0. Qed. +Lemma abse0 : `|0| = 0 :> \bar R. Proof. by rewrite /abse/= normr0. Qed. Lemma abse1 : `|1| = 1 :> \bar R. Proof. by rewrite /abse normr1. Qed. @@ -1037,7 +1065,7 @@ Proof. by move: x y => [r0| |] [r1| |] // ? ?; rewrite !lee_fin addr_ge0. Qed. Lemma adde_le0 x y : x <= 0 -> y <= 0 -> x + y <= 0. Proof. -move: x y => [r0||] [r1||]// ? ?; rewrite !lee_fin -(addr0 0%R); exact: ler_add. +move: x y => [r0||] [r1||]// ? ?; rewrite !lee_fin -(addr0 0%R); exact: lerD. Qed. Lemma oppe_gt0 x : (0 < - x) = (x < 0). @@ -1164,7 +1192,7 @@ Lemma mule_lt0_gt0 x y : x < 0 -> 0 < y -> x * y < 0. Proof. by move=> x0 y0; rewrite muleC mule_gt0_lt0. Qed. Lemma gte_opp x : 0 < x -> - x < x. -Proof. by case: x => //= r; rewrite !lte_fin; apply: gtr_opp. Qed. +Proof. by case: x => //= r; rewrite !lte_fin; apply: gtrN. Qed. Lemma realMe x y : (0%E >=< x)%O -> (0%E >=< y)%O -> (0%E >=< x * y)%O. Proof. @@ -1210,11 +1238,11 @@ Notation "x *? y" := (mule_def x y) : ereal_scope. Notation maxe := (@Order.max ereal_display _). Notation "@ 'maxe' R" := (@Order.max ereal_display R) - (at level 10, R at level 8, only parsing) : fun_scope. + (at level 10, R at level 8, only parsing) : function_scope. Notation mine := (@Order.min ereal_display _). Notation "@ 'mine' R" := (@Order.min ereal_display R) - (at level 10, R at level 8, only parsing) : fun_scope. + (at level 10, R at level 8, only parsing) : function_scope. Module DualAddTheoryNumDomain. @@ -1224,12 +1252,12 @@ Local Open Scope ereal_dual_scope. Context {R : numDomainType}. -Implicit Types x y z : \bar R. +Implicit Types x y z : \bar^d R. Lemma dual_addeE x y : (x + y)%dE = - ((- x) + (- y))%E. Proof. by case: x => [x| |]; case: y => [y| |] //=; rewrite opprD !opprK. Qed. -Lemma dual_sumeE I (r : seq I) (P : pred I) (F : I -> \bar R) : +Lemma dual_sumeE I (r : seq I) (P : pred I) (F : I -> \bar^d R) : (\sum_(i <- r | P i) F i)%dE = - (\sum_(i <- r | P i) (- F i)%E)%E. Proof. apply: (big_ind2 (fun x y => x = - y)%E) => [|_ x _ y -> ->|i _]. @@ -1244,6 +1272,14 @@ Proof. by case: x => [x| |]; case: y. Qed. Lemma dEFinD (r r' : R) : (r + r')%R%:E = r%:E + r'%:E. Proof. by []. Qed. +Lemma dEFinE (r : R) : dEFin r = r%:E. Proof. by []. Qed. + +Lemma dEFin_semi_additive : @semi_additive _ (\bar^d R) dEFin. +Proof. by split. Qed. +#[export] +HB.instance Definition _ := GRing.isSemiAdditive.Build R (\bar^d R) dEFin + dEFin_semi_additive. + Lemma dEFinB (r r' : R) : (r - r')%R%:E = r%:E - r'%:E. Proof. by []. Qed. @@ -1251,31 +1287,24 @@ Lemma dsumEFin I r P (F : I -> R) : \sum_(i <- r | P i) (F i)%:E = (\sum_(i <- r | P i) F i)%R%:E. Proof. by rewrite dual_sumeE fin_num_sumeN// oppeK sumEFin. Qed. -Lemma daddeC : commutative (S := \bar R) +%dE. -Proof. by move=> x y; rewrite !dual_addeE addeC. Qed. +Lemma daddeC : commutative (S := \bar^d R) +%dE. Proof. exact: addrC. Qed. -Lemma dadde0 : right_id (0 : \bar R) +%dE. -Proof. by move=> x; rewrite dual_addeE eqe_oppLRP oppe0 adde0. Qed. +Lemma dadde0 : right_id (0 : \bar^d R) +%dE. Proof. exact: addr0. Qed. -Lemma dadd0e : left_id (0 : \bar R) +%dE. -Proof. by move=> x;rewrite dual_addeE eqe_oppLRP oppe0 add0e. Qed. +Lemma dadd0e : left_id (0 : \bar^d R) +%dE. Proof. exact: add0r. Qed. -Lemma daddeA : associative (S := \bar R) +%dE. -Proof. by move=> x y z; rewrite !dual_addeE !oppeK addeA. Qed. +Lemma daddeA : associative (S := \bar^d R) +%dE. Proof. exact: addrA. Qed. -Canonical dadde_monoid := Monoid.Law daddeA dadd0e dadde0. -Canonical dadde_comoid := Monoid.ComLaw daddeC. - -Lemma daddeAC : right_commutative (S := \bar R) +%dE. +Lemma daddeAC : right_commutative (S := \bar^d R) +%dE. Proof. exact: Monoid.mulmAC. Qed. -Lemma daddeCA : left_commutative (S := \bar R) +%dE. +Lemma daddeCA : left_commutative (S := \bar^d R) +%dE. Proof. exact: Monoid.mulmCA. Qed. -Lemma daddeACA : @interchange (\bar R) +%dE +%dE. +Lemma daddeACA : @interchange (\bar^d R) +%dE +%dE. Proof. exact: Monoid.mulmACA. Qed. -Lemma realDed x y : (0%E >=< x)%O -> (0%E >=< y)%O -> (0%E >=< x + y)%O. +Lemma realDed x y : (0%dE >=< x)%O -> (0%dE >=< y)%O -> (0%dE >=< x + y)%O. Proof. case: x y => [x||] [y||] //; exact: realD. Qed. Lemma doppeD x y : x +? y -> - (x + y) = - x - y. @@ -1367,7 +1396,7 @@ Lemma dadde_ss_eq0 x y : (0 <= x) && (0 <= y) || (x <= 0) && (y <= 0) -> x + y == 0 = (x == 0) && (y == 0). Proof. move=> /orP[|] /andP[]; [exact: pdadde_eq0|exact: ndadde_eq0]. Qed. -Lemma desum_eqyP (T : eqType) (s : seq T) (P : pred T) (f : T -> \bar R) : +Lemma desum_eqyP (T : eqType) (s : seq T) (P : pred T) (f : T -> \bar^d R) : \sum_(i <- s | P i) f i = +oo <-> exists i, [/\ i \in s, P i & f i = +oo]. Proof. rewrite dual_sumeE eqe_oppLRP /= esum_eqNyP. @@ -1382,7 +1411,7 @@ by under eq_existsb => i do rewrite eqe_oppLR. Qed. Lemma desum_eqNyP - (T : eqType) (s : seq T) (P : pred T) (f : T -> \bar R) : + (T : eqType) (s : seq T) (P : pred T) (f : T -> \bar^d R) : (forall i, P i -> f i != +oo) -> \sum_(i <- s | P i) f i = -oo <-> exists i, [/\ i \in s, P i & f i = -oo]. Proof. @@ -1392,7 +1421,7 @@ rewrite dual_sumeE eqe_oppLRP /= esum_eqyP => [|i Pi]; last first. by split=> -[i + /ltac:(exists i)] => [|] []; [|split]; rewrite // eqe_oppLRP. Qed. -Lemma desum_eqNy (I : finType) (f : I -> \bar R) (P : {pred I}) : +Lemma desum_eqNy (I : finType) (f : I -> \bar^d R) (P : {pred I}) : (forall i, f i != +oo) -> (\sum_(i | P i) f i == -oo) = [exists i in P, f i == -oo]. Proof. @@ -1416,27 +1445,27 @@ Proof. rewrite dual_addeE oppe_ge0 -!oppe_le0; exact: adde_le0. Qed. Lemma dadde_le0 x y : x <= 0 -> y <= 0 -> x + y <= 0. Proof. rewrite dual_addeE oppe_le0 -!oppe_ge0; exact: adde_ge0. Qed. -Lemma dsume_ge0 T (f : T -> \bar R) (P : pred T) : +Lemma dsume_ge0 T (f : T -> \bar^d R) (P : pred T) : (forall n, P n -> 0 <= f n) -> forall l, 0 <= \sum_(i <- l | P i) f i. Proof. move=> u0 l; rewrite dual_sumeE oppe_ge0 sume_le0 // => t Pt. rewrite oppe_le0; exact: u0. Qed. -Lemma dsume_le0 T (f : T -> \bar R) (P : pred T) : +Lemma dsume_le0 T (f : T -> \bar^d R) (P : pred T) : (forall n, P n -> f n <= 0) -> forall l, \sum_(i <- l | P i) f i <= 0. Proof. move=> u0 l; rewrite dual_sumeE oppe_le0 sume_ge0 // => t Pt. rewrite oppe_ge0; exact: u0. Qed. -Lemma gte_dopp (r : \bar R) : (0 < r)%E -> (- r < r)%E. -Proof. by case: r => //= r; rewrite !lte_fin; apply: gtr_opp. Qed. +Lemma gte_dopp (r : \bar^d R) : (0 < r)%E -> (- r < r)%E. +Proof. by case: r => //= r; rewrite !lte_fin; apply: gtrN. Qed. -Lemma ednatmul_pinfty n : +oo *+ n.+1 = +oo :> \bar R. +Lemma ednatmul_pinfty n : +oo *+ n.+1 = +oo :> \bar^d R. Proof. by elim: n => //= n ->. Qed. -Lemma ednatmul_ninfty n : -oo *+ n.+1 = -oo :> \bar R. +Lemma ednatmul_ninfty n : -oo *+ n.+1 = -oo :> \bar^d R. Proof. by elim: n => //= n ->. Qed. Lemma EFin_dnatmul (r : R) n : (r *+ n.+1)%:E = r%:E *+ n.+1. @@ -1497,8 +1526,8 @@ split=> [-> // A A0|Ax]; first by rewrite leey. apply/eqP; rewrite eq_le leey /= leNgt; apply/negP. case: x Ax => [x Ax _|//|/(_ _ ltr01)//]. suff: ~ x%:E < (Order.max 0 x + 1)%:E. - by apply; rewrite lte_fin ltr_spaddr// le_maxr lexx orbT. -by apply/negP; rewrite -leNgt; apply/Ax/ltr_spaddr; rewrite // le_maxr lexx. + by apply; rewrite lte_fin ltr_pwDr// le_maxr lexx orbT. +by apply/negP; rewrite -leNgt; apply/Ax/ltr_pwDr; rewrite // le_maxr lexx. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed `eqyP`")] @@ -1567,22 +1596,22 @@ Proof. by move=> /orP[?|?]; [rewrite suber_ge0|rewrite subre_ge0]. Qed. Lemma lte_oppl x y : (- x < y) = (- y < x). Proof. -by move: x y => [r| |] [r'| |] //=; rewrite ?(ltry, ltNyr)// !lte_fin ltr_oppl. +by move: x y => [r| |] [r'| |] //=; rewrite ?(ltry, ltNyr)// !lte_fin ltrNl. Qed. Lemma lte_oppr x y : (x < - y) = (y < - x). Proof. -by move: x y => [r| |] [r'| |] //=; rewrite ?(ltry, ltNyr)// !lte_fin ltr_oppr. +by move: x y => [r| |] [r'| |] //=; rewrite ?(ltry, ltNyr)// !lte_fin ltrNr. Qed. Lemma lee_oppr x y : (x <= - y) = (y <= - x). Proof. -by move: x y => [r0| |] [r1| |] //=; rewrite ?(leey, leNye)// !lee_fin ler_oppr. +by move: x y => [r0| |] [r1| |] //=; rewrite ?(leey, leNye)// !lee_fin lerNr. Qed. Lemma lee_oppl x y : (- x <= y) = (- y <= x). Proof. -by move: x y => [r0| |] [r1| |] //=; rewrite ?(leey, leNye)// !lee_fin ler_oppl. +by move: x y => [r0| |] [r1| |] //=; rewrite ?(leey, leNye)// !lee_fin lerNl. Qed. Lemma muleN x y : x * - y = - (x * y). @@ -1704,13 +1733,13 @@ Proof. by rewrite lte_oppl oppeK. Qed. Lemma lte_add a b x y : a < b -> x < y -> a + x < b + y. Proof. move: a b x y=> [a| |] [b| |] [x| |] [y| |]; rewrite ?(ltry,ltNyr)//. -by rewrite !lte_fin; exact: ltr_add. +by rewrite !lte_fin; exact: ltrD. Qed. Lemma lee_addl x y : 0 <= y -> x <= x + y. Proof. move: x y => -[ x [y| |]//= | [| |]// | [| | ]//]; - by [rewrite !lee_fin ler_addl | move=> _; exact: leey]. + by [rewrite !lee_fin lerDl | move=> _; exact: leey]. Qed. Lemma lee_addr x y : 0 <= y -> x <= y + x. @@ -1719,7 +1748,7 @@ Proof. by rewrite addeC; exact: lee_addl. Qed. Lemma gee_addl x y : y <= 0 -> x + y <= x. Proof. move: x y => -[ x [y| |]//= | [| |]// | [| | ]//]; - by [rewrite !lee_fin ger_addl | move=> _; exact: leNye]. + by [rewrite !lee_fin gerDl | move=> _; exact: leNye]. Qed. Lemma gee_addr x y : y <= 0 -> y + x <= x. @@ -1727,7 +1756,7 @@ Proof. rewrite addeC; exact: gee_addl. Qed. Lemma lte_addl y x : y \is a fin_num -> (y < y + x) = (0 < x). Proof. -by move: x y => [x| |] [y| |] _ //; rewrite ?ltry ?ltNyr // !lte_fin ltr_addl. +by move: x y => [x| |] [y| |] _ //; rewrite ?ltry ?ltNyr // !lte_fin ltrDl. Qed. Lemma lte_addr y x : y \is a fin_num -> (y < x + y) = (0 < x). @@ -1736,7 +1765,7 @@ Proof. rewrite addeC; exact: lte_addl. Qed. Lemma gte_subl y x : y \is a fin_num -> (y - x < y) = (0 < x). Proof. move: y x => [x| |] [y| |] _ //; rewrite addeC /= ?ltNyr ?ltry//. -by rewrite !lte_fin gtr_addr ltr_oppl oppr0. +by rewrite !lte_fin gtrDr ltrNl oppr0. Qed. Lemma gte_subr y x : y \is a fin_num -> (- x + y < y) = (0 < x). @@ -1744,7 +1773,7 @@ Proof. by rewrite addeC; exact: gte_subl. Qed. Lemma gte_addl x y : x \is a fin_num -> (x + y < x) = (y < 0). Proof. -by move: x y => [r| |] [s| |]// _; [rewrite !lte_fin gtr_addl|rewrite !ltNyr]. +by move: x y => [r| |] [s| |]// _; [rewrite !lte_fin gtrDl|rewrite !ltNyr]. Qed. Lemma gte_addr x y : x \is a fin_num -> (y + x < x) = (y < 0). @@ -1753,13 +1782,13 @@ Proof. by rewrite addeC; exact: gte_addl. Qed. Lemma lte_add2lE x a b : x \is a fin_num -> (x + a < x + b) = (a < b). Proof. move: a b x => [a| |] [b| |] [x| |] _ //; rewrite ?(ltry, ltNyr)//. -by rewrite !lte_fin ltr_add2l. +by rewrite !lte_fin ltrD2l. Qed. Lemma lee_add2l x a b : a <= b -> x + a <= x + b. Proof. move: a b x => -[a [b [x /=|//|//] | []// |//] | []// | ]. -- by rewrite !lee_fin ler_add2l. +- by rewrite !lee_fin lerD2l. - by move=> r _; exact: leey. - by move=> -[b [| |]// | []// | //] r oob; exact: leNye. Qed. @@ -1767,7 +1796,7 @@ Qed. Lemma lee_add2lE x a b : x \is a fin_num -> (x + a <= x + b) = (a <= b). Proof. move: a b x => [a| |] [b| |] [x| |] _ //; rewrite ?(leey, leNye)//. -by rewrite !lee_fin ler_add2l. +by rewrite !lee_fin lerD2l. Qed. Lemma lee_add2r x a b : a <= b -> a + x <= b + x. @@ -1776,13 +1805,13 @@ Proof. rewrite addeC (addeC b); exact: lee_add2l. Qed. Lemma lee_add a b x y : a <= b -> x <= y -> a + x <= b + y. Proof. move: a b x y => [a| |] [b| |] [x| |] [y| |]; rewrite ?(leey, leNye)//. -by rewrite !lee_fin; exact: ler_add. +by rewrite !lee_fin; exact: lerD. Qed. Lemma lte_le_add a b x y : b \is a fin_num -> a < x -> b <= y -> a + b < x + y. Proof. move: x y a b => [x| |] [y| |] [a| |] [b| |] _ //=; rewrite ?(ltry, ltNyr)//. -by rewrite !lte_fin; exact: ltr_le_add. +by rewrite !lte_fin; exact: ltr_leD. Qed. Lemma lee_lt_add a b x y : a \is a fin_num -> a <= x -> b < y -> a + b < x + y. @@ -1791,20 +1820,20 @@ Proof. by move=> afin xa yb; rewrite (addeC a) (addeC x) lte_le_add. Qed. Lemma lee_sub x y z u : x <= y -> u <= z -> x - z <= y - u. Proof. move: x y z u => -[x| |] -[y| |] -[z| |] -[u| |] //=; rewrite ?(leey,leNye)//. -by rewrite !lee_fin; exact: ler_sub. +by rewrite !lee_fin; exact: lerB. Qed. Lemma lte_le_sub z u x y : u \is a fin_num -> x < z -> u <= y -> x - y < z - u. Proof. move: z u x y => [z| |] [u| |] [x| |] [y| |] _ //=; rewrite ?(ltry, ltNyr)//. -by rewrite !lte_fin => xltr tley; apply: ltr_le_add; rewrite // ler_oppl opprK. +by rewrite !lte_fin => xltr tley; apply: ltr_leD; rewrite // lerNl opprK. Qed. Lemma lte_pmul2r z : z \is a fin_num -> 0 < z -> {mono *%E^~ z : x y / x < y}. Proof. move: z => [z| |] _ // z0 [x| |] [y| |] //. -- by rewrite !lte_fin ltr_pmul2r. +- by rewrite !lte_fin ltr_pM2r. - by rewrite mulr_infty gtr0_sg// mul1e 2!ltry. - by rewrite mulr_infty gtr0_sg// mul1e ltNge leNye ltNge leNye. - by rewrite mulr_infty gtr0_sg// mul1e ltNge leey ltNge leey. @@ -1955,7 +1984,7 @@ Qed. Lemma lte_subl_addr x y z : y \is a fin_num -> (x - y < z) = (x < z + y). Proof. move: x y z => [x| |] [y| |] [z| |] _ //=; rewrite ?ltry ?ltNyr //. -by rewrite !lte_fin ltr_subl_addr. +by rewrite !lte_fin ltrBlDr. Qed. Lemma lte_subl_addl x y z : y \is a fin_num -> (x - y < z) = (x < y + z). @@ -1964,7 +1993,7 @@ Proof. by move=> ?; rewrite lte_subl_addr// addeC. Qed. Lemma lte_subr_addr x y z : z \is a fin_num -> (x < y - z) = (x + z < y). Proof. move: x y z => [x| |] [y| |] [z| |] _ //=; rewrite ?ltNyr ?ltry //. -by rewrite !lte_fin ltr_subr_addr. +by rewrite !lte_fin ltrBrDr. Qed. Lemma lte_subr_addl x y z : z \is a fin_num -> (x < y - z) = (z + x < y). @@ -1973,7 +2002,7 @@ Proof. by move=> ?; rewrite lte_subr_addr// addeC. Qed. Lemma lte_subel_addr x y z : x \is a fin_num -> (x - y < z) = (x < z + y). Proof. move: x y z => [x| |] [y| |] [z| |] _ //=; rewrite ?ltNyr ?ltry //. -by rewrite !lte_fin ltr_subl_addr. +by rewrite !lte_fin ltrBlDr. Qed. Lemma lte_subel_addl x y z : x \is a fin_num -> (x - y < z) = (x < y + z). @@ -1982,7 +2011,7 @@ Proof. by move=> ?; rewrite lte_subel_addr// addeC. Qed. Lemma lte_suber_addr x y z : x \is a fin_num -> (x < y - z) = (x + z < y). Proof. move: x y z => [x| |] [y| |] [z| |] _ //=; rewrite ?ltNyr ?ltry //. -by rewrite !lte_fin ltr_subr_addr. +by rewrite !lte_fin ltrBrDr. Qed. Lemma lte_suber_addl x y z : x \is a fin_num -> (x < y - z) = (z + x < y). @@ -1991,7 +2020,7 @@ Proof. by move=> ?; rewrite lte_suber_addr// addeC. Qed. Lemma lee_subl_addr x y z : y \is a fin_num -> (x - y <= z) = (x <= z + y). Proof. move: x y z => [x| |] [y| |] [z| |] _ //=; rewrite ?leey ?leNye //. -by rewrite !lee_fin ler_subl_addr. +by rewrite !lee_fin lerBlDr. Qed. Lemma lee_subl_addl x y z : y \is a fin_num -> (x - y <= z) = (x <= y + z). @@ -2000,7 +2029,7 @@ Proof. by move=> ?; rewrite lee_subl_addr// addeC. Qed. Lemma lee_subr_addr x y z : z \is a fin_num -> (x <= y - z) = (x + z <= y). Proof. move: y x z => [y| |] [x| |] [z| |] _ //=; rewrite ?leNye ?leey //. -by rewrite !lee_fin ler_subr_addr. +by rewrite !lee_fin lerBrDr. Qed. Lemma lee_subr_addl x y z : z \is a fin_num -> (x <= y - z) = (z + x <= y). @@ -2009,7 +2038,7 @@ Proof. by move=> ?; rewrite lee_subr_addr// addeC. Qed. Lemma lee_subel_addr x y z : z \is a fin_num -> (x - y <= z) = (x <= z + y). Proof. move: x y z => [x| |] [y| |] [z| |] _ //=; rewrite ?leey ?leNye //. -by rewrite !lee_fin ler_subl_addr. +by rewrite !lee_fin lerBlDr. Qed. Lemma lee_subel_addl x y z : z \is a fin_num -> (x - y <= z) = (x <= y + z). @@ -2018,7 +2047,7 @@ Proof. by move=> ?; rewrite lee_subel_addr// addeC. Qed. Lemma lee_suber_addr x y z : y \is a fin_num -> (x <= y - z) = (x + z <= y). Proof. move: y x z => [y| |] [x| |] [z| |] _ //=; rewrite ?leNye ?leey //. -by rewrite !lee_fin ler_subr_addr. +by rewrite !lee_fin lerBrDr. Qed. Lemma lee_suber_addl x y z : y \is a fin_num -> (x <= y - z) = (z + x <= y). @@ -2112,8 +2141,8 @@ Qed. Local Open Scope ereal_scope. -Canonical mule_monoid := Monoid.Law muleA mul1e mule1. -Canonical mule_comoid := Monoid.ComLaw muleC. +HB.instance Definition _ := Monoid.isComLaw.Build (\bar R) 1%E mule + muleA muleC mul1e. Lemma muleCA : left_commutative ( *%E : \bar R -> \bar R -> \bar R ). Proof. exact: Monoid.mulmCA. Qed. @@ -2150,7 +2179,7 @@ rewrite /mule/=; move: x y z => [r| |] [s| |] [t| |] //= s0 t0. - by case: ltgtP => //; rewrite adde0. - 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_le_add // lte_fin s0. + + 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. @@ -2158,7 +2187,7 @@ rewrite /mule/=; move: x y z => [r| |] [s| |] [t| |] //= s0 t0. - by rewrite ltry. - 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_le_add // lte_fin s0. + + 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. @@ -2178,7 +2207,7 @@ rewrite /mule/=; move: x y z => [r| |] [s| |] [t| |] //= s0 t0. - by case: ltgtP => //; rewrite adde0. - 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 ler_add // ?ltW //=. + + 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. @@ -2186,7 +2215,7 @@ rewrite /mule/=; move: x y z => [r| |] [s| |] [t| |] //= s0 t0. - by rewrite ltry. - 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 ler_add // ?ltW //=. + + rewrite !lte_fin -[in LHS](addr0 0%R) ltNge lerD // ?ltW //=. by rewrite !ltNge ltW // -lee_fin t0; case: eqP. + by case: (ltgtP t). - by rewrite ltNge s0 /=; case: eqP. @@ -2199,7 +2228,7 @@ Proof. by move=> y0 z0; rewrite !(muleC x) le0_muleDl. Qed. Lemma gee_pmull y x : y \is a fin_num -> 0 < x -> y <= 1 -> y * x <= x. Proof. move: x y => [x| |] [y| |] _ //=. -- by rewrite lte_fin => x0 r0; rewrite /mule/= lee_fin ger_pmull. +- by rewrite lte_fin => x0 r0; rewrite /mule/= lee_fin ger_pMl. - by move=> _; rewrite /mule/= eqe => r1; rewrite leey. Qed. @@ -2207,7 +2236,7 @@ Lemma lee_wpmul2r x : 0 <= x -> {homo *%E^~ x : y z / y <= z}. Proof. move: x => [x|_|//]. rewrite lee_fin le_eqVlt => /predU1P[<- y z|x0]; first by rewrite 2!mule0. - move=> [y| |] [z| |]//; first by rewrite !lee_fin// ler_pmul2r. + move=> [y| |] [z| |]//; first by rewrite !lee_fin// ler_pM2r. - by move=> _; rewrite mulr_infty gtr0_sg// mul1e leey. - by move=> _; rewrite mulr_infty gtr0_sg// mul1e leNye. - by move=> _; rewrite 2!mulr_infty gtr0_sg// 2!mul1e. @@ -2302,7 +2331,7 @@ Qed. Lemma lee_abs_add x y : `|x + y| <= `|x| + `|y|. Proof. -by move: x y => [x| |] [y| |] //; rewrite /abse -EFinD lee_fin ler_norm_add. +by move: x y => [x| |] [y| |] //; rewrite /abse -EFinD lee_fin ler_normD. Qed. Lemma lee_abs_sum (I : Type) (s : seq I) (F : I -> \bar R) (P : pred I) : @@ -2314,7 +2343,7 @@ Qed. Lemma lee_abs_sub x y : `|x - y| <= `|x| + `|y|. Proof. -by move: x y => [x| |] [y| |] //; rewrite /abse -EFinD lee_fin ler_norm_sub. +by move: x y => [x| |] [y| |] //; rewrite /abse -EFinD lee_fin ler_normB. Qed. Lemma abseM : {morph @abse R : x y / x * y}. @@ -2354,14 +2383,14 @@ Qed. Lemma EFin_min : {morph (@EFin R) : r s / Num.min r s >-> mine r s}. Proof. by move=> a b /=; rewrite -fine_min. Qed. -Lemma adde_maxl : left_distributive (@adde R) maxe. +Lemma adde_maxl : left_distributive (@GRing.add (\bar R)) maxe. Proof. move=> x y z; have [xy|yx] := leP x y. by apply/esym/max_idPr; rewrite lee_add2r. by apply/esym/max_idPl; rewrite lee_add2r// ltW. Qed. -Lemma adde_maxr : right_distributive (@adde R) maxe. +Lemma adde_maxr : right_distributive (@GRing.add (\bar R)) maxe. Proof. move=> x y z; have [yz|zy] := leP y z. by apply/esym/max_idPr; rewrite lee_add2l. @@ -2380,8 +2409,8 @@ Proof. by move=> x; have [//|] := leP -oo x; rewrite ltNge leNye. Qed. Lemma maxeNy : right_id (-oo : \bar R) maxe. Proof. by move=> x; rewrite maxC maxNye. Qed. -Canonical maxe_monoid := Monoid.Law maxA maxNye maxeNy. -Canonical maxe_comoid := Monoid.ComLaw maxC. +HB.instance Definition _ := + Monoid.isLaw.Build (\bar R) -oo maxe maxA maxNye maxeNy. Lemma minNye : left_zero (-oo : \bar R) mine. Proof. by move=> x; have [|//] := leP x -oo; rewrite leeNy_eq => /eqP. Qed. @@ -2395,8 +2424,6 @@ Proof. by move=> x; have [//|] := leP x +oo; rewrite ltNge leey. Qed. Lemma miney : right_id (+oo : \bar R) mine. Proof. by move=> x; rewrite minC minye. Qed. -Canonical mine_monoid := Monoid.Law minA minye miney. -Canonical mine_comoid := Monoid.ComLaw minC. Lemma oppe_max : {morph -%E : x y / maxe x y >-> mine x y : \bar R}. Proof. @@ -2426,7 +2453,8 @@ Proof. by move=> zfin z0; rewrite muleC maxeMr// !(muleC z). Qed. Lemma mineMr z x y : z \is a fin_num -> 0 < z -> z * mine x y = mine (z * x) (z * y). Proof. -by move=> ? ?; rewrite -eqe_oppP -muleN oppe_min maxeMr// !muleN -oppe_min. +move=> fz zgt0. +by rewrite -eqe_oppP -muleN [in LHS]oppe_min maxeMr// !muleN -oppe_min. Qed. Lemma mineMl z x y : z \is a fin_num -> 0 < z -> @@ -2446,7 +2474,7 @@ Qed. Lemma lee_pemull x y : 0 <= y -> 1 <= x -> y <= x * y. Proof. move: x y => [x| |] [y| |] //; last by rewrite mulyy. -- by rewrite -EFinM 3!lee_fin; exact: ler_pemull. +- 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). - rewrite lee_fin le_eqVlt => /predU1P[<- _|y0 _]; first by rewrite mule0. @@ -2456,7 +2484,7 @@ Qed. Lemma lee_nemull x y : y <= 0 -> 1 <= x -> x * y <= y. Proof. move: x y => [x| |] [y| |] //; last by rewrite mulyNy. -- by rewrite -EFinM 3!lee_fin; exact: ler_nemull. +- 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). - rewrite lee_fin le_eqVlt => /predU1P[-> _|y0 _]; first by rewrite mule0. @@ -2483,7 +2511,7 @@ Lemma lte_pmul x1 y1 x2 y2 : Proof. move: x1 y1 x2 y2 => [x1| |] [y1| |] [x2| |] [y2| |] //; rewrite !(lte_fin,lee_fin). -- by move=> *; rewrite ltr_pmul. +- by move=> *; rewrite ltr_pM. - move=> x10 x20 xy1 xy2. by rewrite mulry gtr0_sg ?mul1e -?EFinM ?ltry// (le_lt_trans _ xy1). - move=> x10 x20 xy1 xy2. @@ -2495,7 +2523,7 @@ Lemma lee_pmul x1 y1 x2 y2 : 0 <= x1 -> 0 <= x2 -> x1 <= y1 -> x2 <= y2 -> x1 * x2 <= y1 * y2. Proof. move: x1 y1 x2 y2 => [x1| |] [y1| |] [x2| |] [y2| |] //; rewrite !lee_fin. -- exact: ler_pmul. +- exact: ler_pM. - rewrite le_eqVlt => /predU1P[<- x20 y10 _|x10 x20 xy1 _]. by rewrite mul0e mule_ge0// leey. by rewrite mulr_infty gtr0_sg// ?mul1e ?leey// (lt_le_trans x10). @@ -2522,7 +2550,7 @@ Qed. Lemma lee_pmul2l x : x \is a fin_num -> 0 < x -> {mono *%E x : x y / x <= y}. Proof. move: x => [x _|//|//] /[!(@lte_fin R)] x0 [y| |] [z| |]. -- by rewrite -2!EFinM 2!lee_fin ler_pmul2l. +- by rewrite -2!EFinM 2!lee_fin ler_pM2l. - by rewrite mulry gtr0_sg// mul1e 2!leey. - by rewrite mulrNy gtr0_sg// mul1e 2!leeNy_eq. - by rewrite mulry gtr0_sg// mul1e 2!leye_eq. @@ -2582,13 +2610,13 @@ Proof. by move=> *; rewrite addeC lte_paddl. Qed. Lemma lte_spaddre z x y : z \is a fin_num -> 0 < y -> z <= x -> z < x + y. Proof. move: z y x => [z| |] [y| |] [x| |] _ //=; rewrite ?(lte_fin,ltry)//. -exact: ltr_spaddr. +exact: ltr_pwDr. Qed. Lemma lte_spadder z x y : x \is a fin_num -> 0 < y -> z <= x -> z < x + y. Proof. move: z y x => [z| |] [y| |] [x| |] _ //=; rewrite ?(lte_fin,ltry,ltNyr)//. -exact: ltr_spaddr. +exact: ltr_pwDr. Qed. End ERealArithTh_realDomainType. @@ -2616,7 +2644,7 @@ Import DualAddTheoryNumDomain. Local Open Scope ereal_dual_scope. Context {R : realDomainType}. -Implicit Types x y z a b : \bar R. +Implicit Types x y z a b : \bar^d R. Lemma dsube_lt0 x y : (x - y < 0) = (x < y). Proof. by rewrite dual_addeE oppe_lt0 sube_gt0 lteN2. Qed. @@ -2667,7 +2695,7 @@ Proof. by rewrite -fin_numN dual_addeE lte_oppl oppeK; exact: lte_addr. Qed. Lemma gte_daddl x y : x \is a fin_num -> (x + y < x) = (y < 0). Proof. -by rewrite -fin_numN dual_addeE lte_oppl -oppe0 lte_oppr; exact: lte_addl. +by rewrite -fin_numN dual_addeE lte_oppl -[0]oppe0 lte_oppr; exact: lte_addl. Qed. Lemma gte_daddr x y : x \is a fin_num -> (y + x < x) = (y < 0). @@ -2700,7 +2728,7 @@ Proof. rewrite !dual_addeE lee_oppl oppeK -leeN2 !oppeK; exact: lee_add. Qed. Lemma lte_le_dsub z u x y : u \is a fin_num -> x < z -> u <= y -> x - y < z - u. Proof. by rewrite !dual_addeE lteN2 !oppeK -lteN2; exact: lte_le_add. Qed. -Lemma lee_dsum I (f g : I -> \bar R) s (P : pred I) : +Lemma lee_dsum I (f g : I -> \bar^d R) s (P : pred I) : (forall i, P i -> f i <= g i) -> \sum_(i <- s | P i) f i <= \sum_(i <- s | P i) g i. Proof. @@ -2708,7 +2736,7 @@ move=> Pfg; rewrite !dual_sumeE leeN2. apply: lee_sum => i Pi; rewrite leeN2; exact: Pfg. Qed. -Lemma lee_dsum_nneg_subset I (s : seq I) (P Q : {pred I}) (f : I -> \bar R) : +Lemma lee_dsum_nneg_subset I (s : seq I) (P Q : {pred I}) (f : I -> \bar^d R) : {subset Q <= P} -> {in [predD P & Q], forall i, 0 <= f i} -> \sum_(i <- s | Q i) f i <= \sum_(i <- s | P i) f i. Proof. @@ -2716,7 +2744,7 @@ move=> QP PQf; rewrite !dual_sumeE leeN2. apply: lee_sum_npos_subset => [//|i iPQ]; rewrite oppe_le0; exact: PQf. Qed. -Lemma lee_dsum_npos_subset I (s : seq I) (P Q : {pred I}) (f : I -> \bar R) : +Lemma lee_dsum_npos_subset I (s : seq I) (P Q : {pred I}) (f : I -> \bar^d R) : {subset Q <= P} -> {in [predD P & Q], forall i, f i <= 0} -> \sum_(i <- s | P i) f i <= \sum_(i <- s | Q i) f i. Proof. @@ -2725,7 +2753,7 @@ apply: lee_sum_nneg_subset => [//|i iPQ]; rewrite oppe_ge0; exact: PQf. Qed. Lemma lee_dsum_nneg (I : eqType) (s : seq I) (P Q : pred I) - (f : I -> \bar R) : (forall i, P i -> ~~ Q i -> 0 <= f i) -> + (f : I -> \bar^d R) : (forall i, P i -> ~~ Q i -> 0 <= f i) -> \sum_(i <- s | P i && Q i) f i <= \sum_(i <- s | P i) f i. Proof. move=> PQf; rewrite !dual_sumeE leeN2. @@ -2733,14 +2761,14 @@ apply: lee_sum_npos => i Pi nQi; rewrite oppe_le0; exact: PQf. Qed. Lemma lee_dsum_npos (I : eqType) (s : seq I) (P Q : pred I) - (f : I -> \bar R) : (forall i, P i -> ~~ Q i -> f i <= 0) -> + (f : I -> \bar^d R) : (forall i, P i -> ~~ Q i -> f i <= 0) -> \sum_(i <- s | P i) f i <= \sum_(i <- s | P i && Q i) f i. Proof. move=> PQf; rewrite !dual_sumeE leeN2. apply: lee_sum_nneg => i Pi nQi; rewrite oppe_ge0; exact: PQf. Qed. -Lemma lee_dsum_nneg_ord (f : nat -> \bar R) (P : pred nat) : +Lemma lee_dsum_nneg_ord (f : nat -> \bar^d R) (P : pred nat) : (forall n, P n -> 0 <= f n)%E -> {homo (fun n => \sum_(i < n | P i) (f i)) : i j / (i <= j)%N >-> i <= j}. Proof. @@ -2749,7 +2777,7 @@ apply: (lee_sum_npos_ord (fun i => - f i)%E) => [i Pi|//]. rewrite oppe_le0; exact: f0. Qed. -Lemma lee_dsum_npos_ord (f : nat -> \bar R) (P : pred nat) : +Lemma lee_dsum_npos_ord (f : nat -> \bar^d R) (P : pred nat) : (forall n, P n -> f n <= 0)%E -> {homo (fun n => \sum_(i < n | P i) (f i)) : i j / (i <= j)%N >-> j <= i}. Proof. @@ -2758,7 +2786,7 @@ apply: (lee_sum_nneg_ord (fun i => - f i)%E) => [i Pi|//]. rewrite oppe_ge0; exact: f0. Qed. -Lemma lee_dsum_nneg_natr (f : nat -> \bar R) (P : pred nat) m : +Lemma lee_dsum_nneg_natr (f : nat -> \bar^d R) (P : pred nat) m : (forall n, (m <= n)%N -> P n -> 0 <= f n) -> {homo (fun n => \sum_(m <= i < n | P i) (f i)) : i j / (i <= j)%N >-> i <= j}. Proof. @@ -2766,7 +2794,7 @@ move=> f0 i j le_ij; rewrite !dual_sumeE leeN2. apply: lee_sum_npos_natr => [n ? ?|//]; rewrite oppe_le0; exact: f0. Qed. -Lemma lee_dsum_npos_natr (f : nat -> \bar R) (P : pred nat) m : +Lemma lee_dsum_npos_natr (f : nat -> \bar^d R) (P : pred nat) m : (forall n, (m <= n)%N -> P n -> f n <= 0) -> {homo (fun n => \sum_(m <= i < n | P i) (f i)) : i j / (i <= j)%N >-> j <= i}. Proof. @@ -2774,7 +2802,7 @@ move=> f0 i j le_ij; rewrite !dual_sumeE leeN2. apply: lee_sum_nneg_natr => [n ? ?|//]; rewrite oppe_ge0; exact: f0. Qed. -Lemma lee_dsum_nneg_natl (f : nat -> \bar R) (P : pred nat) n : +Lemma lee_dsum_nneg_natl (f : nat -> \bar^d R) (P : pred nat) n : (forall m, (m < n)%N -> P m -> 0 <= f m) -> {homo (fun m => \sum_(m <= i < n | P i) (f i)) : i j / (i <= j)%N >-> j <= i}. Proof. @@ -2782,7 +2810,7 @@ move=> f0 i j le_ij; rewrite !dual_sumeE leeN2. apply: lee_sum_npos_natl => [m ? ?|//]; rewrite oppe_le0; exact: f0. Qed. -Lemma lee_dsum_npos_natl (f : nat -> \bar R) (P : pred nat) n : +Lemma lee_dsum_npos_natl (f : nat -> \bar^d R) (P : pred nat) n : (forall m, (m < n)%N -> P m -> f m <= 0) -> {homo (fun m => \sum_(m <= i < n | P i) (f i)) : i j / (i <= j)%N >-> i <= j}. Proof. @@ -2791,7 +2819,7 @@ apply: lee_sum_nneg_natl => [m ? ?|//]; rewrite oppe_ge0; exact: f0. Qed. Lemma lee_dsum_nneg_subfset (T : choiceType) (A B : {fset T}%fset) (P : pred T) - (f : T -> \bar R) : {subset A <= B} -> + (f : T -> \bar^d R) : {subset A <= B} -> {in [predD B & A], forall t, P t -> 0 <= f t} -> \sum_(t <- A | P t) f t <= \sum_(t <- B | P t) f t. Proof. @@ -2800,7 +2828,7 @@ apply: lee_sum_npos_subfset => [//|? ? ?]; rewrite oppe_le0; exact: f0. Qed. Lemma lee_dsum_npos_subfset (T : choiceType) (A B : {fset T}%fset) (P : pred T) - (f : T -> \bar R) : {subset A <= B} -> + (f : T -> \bar^d R) : {subset A <= B} -> {in [predD B & A], forall t, P t -> f t <= 0} -> \sum_(t <- B | P t) f t <= \sum_(t <- A | P t) f t. Proof. @@ -2899,7 +2927,9 @@ Lemma dsube_gt0 x y : (x \is a fin_num) || (y \is a fin_num) -> Proof. by move=> /orP[?|?]; [rewrite dsuber_gt0|rewrite dsubre_gt0]. Qed. Lemma dmuleDr x y z : x \is a fin_num -> y +? z -> x * (y + z) = x * y + x * z. -Proof. by move=> *; rewrite !dual_addeE muleN muleDr ?adde_defNN// !muleN. Qed. +Proof. +by move=> *; rewrite !dual_addeE/= muleN muleDr ?adde_defNN// !muleN. +Qed. Lemma dmuleDl x y z : x \is a fin_num -> y +? z -> (y + z) * x = y * x + z * x. Proof. by move=> *; rewrite -!(muleC x) dmuleDr. Qed. @@ -2916,7 +2946,8 @@ Proof. by move=> *; rewrite !dual_addeE mulNe ge0_muleDl ?oppe_ge0 ?mulNe. Qed. Lemma dle0_muleDr x y z : y <= 0 -> z <= 0 -> x * (y + z) = x * y + x * z. Proof. by move=> *; rewrite !dual_addeE muleN ge0_muleDr ?oppe_ge0 ?muleN. Qed. -Lemma ge0_dsume_distrl (I : Type) (s : seq I) x (P : pred I) (F : I -> \bar R) : +Lemma ge0_dsume_distrl (I : Type) (s : seq I) x (P : pred I) + (F : I -> \bar^d R) : (forall i, P i -> 0 <= F i) -> (\sum_(i <- s | P i) F i) * x = \sum_(i <- s | P i) (F i * x). Proof. @@ -2925,14 +2956,16 @@ move=> F0; rewrite !dual_sumeE !mulNe le0_sume_distrl => [|i Pi]. - by rewrite oppe_le0 F0. Qed. -Lemma ge0_dsume_distrr (I : Type) (s : seq I) x (P : pred I) (F : I -> \bar R) : +Lemma ge0_dsume_distrr (I : Type) (s : seq I) x (P : pred I) + (F : I -> \bar^d R) : (forall i, P i -> 0 <= F i) -> x * (\sum_(i <- s | P i) F i) = \sum_(i <- s | P i) (x * F i). Proof. by move=> F0; rewrite muleC ge0_dsume_distrl//; under eq_bigr do rewrite muleC. Qed. -Lemma le0_dsume_distrl (I : Type) (s : seq I) x (P : pred I) (F : I -> \bar R) : +Lemma le0_dsume_distrl (I : Type) (s : seq I) x (P : pred I) + (F : I -> \bar^d R) : (forall i, P i -> F i <= 0) -> (\sum_(i <- s | P i) F i) * x = \sum_(i <- s | P i) (F i * x). Proof. @@ -2941,7 +2974,8 @@ move=> F0; rewrite !dual_sumeE mulNe ge0_sume_distrl => [|i Pi]. - by rewrite oppe_ge0 F0. Qed. -Lemma le0_dsume_distrr (I : Type) (s : seq I) x (P : pred I) (F : I -> \bar R) : +Lemma le0_dsume_distrr (I : Type) (s : seq I) x (P : pred I) + (F : I -> \bar^d R) : (forall i, P i -> F i <= 0) -> x * (\sum_(i <- s | P i) F i) = \sum_(i <- s | P i) (x * F i). Proof. @@ -2950,10 +2984,10 @@ Qed. Lemma lee_abs_dadd x y : `|x + y| <= `|x| + `|y|. Proof. -by move: x y => [x| |] [y| |] //; rewrite /abse -dEFinD lee_fin ler_norm_add. +by move: x y => [x| |] [y| |] //; rewrite /abse -dEFinD lee_fin ler_normD. Qed. -Lemma lee_abs_dsum (I : Type) (s : seq I) (F : I -> \bar R) (P : pred I) : +Lemma lee_abs_dsum (I : Type) (s : seq I) (F : I -> \bar^d R) (P : pred I) : `|\sum_(i <- s | P i) F i| <= \sum_(i <- s | P i) `|F i|. Proof. elim/big_ind2 : _ => //; first by rewrite abse0. @@ -2962,13 +2996,13 @@ Qed. Lemma lee_abs_dsub x y : `|x - y| <= `|x| + `|y|. Proof. -by move: x y => [x| |] [y| |] //; rewrite /abse -dEFinD lee_fin ler_norm_sub. +by move: x y => [x| |] [y| |] //; rewrite /abse -dEFinD lee_fin ler_normB. Qed. -Lemma dadde_minl : left_distributive (@dual_adde R) mine. +Lemma dadde_minl : left_distributive (@GRing.add (\bar^d R)) mine. Proof. by move=> x y z; rewrite !dual_addeE oppe_min adde_maxl oppe_max. Qed. -Lemma dadde_minr : right_distributive (@dual_adde R) mine. +Lemma dadde_minr : right_distributive (@GRing.add (\bar^d R)) mine. Proof. by move=> x y z; rewrite !dual_addeE oppe_min adde_maxr oppe_max. Qed. Lemma dmule_natl x n : n%:R%:E * x = x *+ n. @@ -2989,13 +3023,13 @@ Proof. by move=> *; rewrite daddeC lte_pdaddl. Qed. Lemma lte_spdaddre z x y : z \is a fin_num -> 0 < y -> z <= x -> z < x + y. Proof. move: z y x => [z| |] [y| |] [x| |] _ //=; rewrite ?(lte_fin,ltry,ltNyr)//. -exact: ltr_spaddr. +exact: ltr_pwDr. Qed. Lemma lte_spdadder z x y : x \is a fin_num -> 0 < y -> z <= x -> z < x + y. Proof. move: z y x => [z| |] [y| |] [x| |] _ //=; rewrite ?(lte_fin,ltry,ltNyr)//. -exact: ltr_spaddr. +exact: ltr_pwDr. Qed. End DualERealArithTh_realDomainType. @@ -3010,14 +3044,14 @@ End DualAddTheoryRealDomain. Lemma lee_opp2 {R : numDomainType} : {mono @oppe R : x y /~ x <= y}. Proof. -move=> x y; case: x y => [?||] [?||] //; first by rewrite !lee_fin !ler_opp2. +move=> x y; case: x y => [?||] [?||] //; first by rewrite !lee_fin !lerN2. by rewrite /Order.le/= realN. by rewrite /Order.le/= realN. Qed. Lemma lte_opp2 {R : numDomainType} : {mono @oppe R : x y /~ x < y}. Proof. -move=> x y; case: x y => [?||] [?||] //; first by rewrite !lte_fin !ltr_opp2. +move=> x y; case: x y => [?||] [?||] //; first by rewrite !lte_fin !ltrN2. by rewrite /Order.lt/= realN. by rewrite /Order.lt/= realN. Qed. @@ -3032,7 +3066,7 @@ Lemma lee_addgt0Pr x y : Proof. apply/(iffP idP) => [|]. - move: x y => [x| |] [y| |]//. - + by rewrite lee_fin => xy e e0; rewrite -EFinD lee_fin ler_paddr// ltW. + + by rewrite lee_fin => xy e e0; rewrite -EFinD lee_fin ler_wpDr// ltW. + by move=> _ e e0; rewrite leNye. - move: x y => [x| |] [y| |]// xy; rewrite ?leey ?leNye//; [|by move: xy => /(_ _ lte01)..]. @@ -3062,7 +3096,7 @@ move: x y => [x||] [y||] // in x0 h *. 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_pdivr_mulr ?mulr_gt0// mul1r mulr_natl mulr2n ltr_add2r. + by rewrite ltr_pdivrMr ?mulr_gt0// mul1r mulr_natl mulr2n ltrD2r. 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. @@ -3074,7 +3108,7 @@ Qed. Lemma lte_pdivr_mull r x y : (0 < r)%R -> (r^-1%:E * y < x) = (y < r%:E * x). Proof. move=> r0; move: x y => [x| |] [y| |] //=. -- by rewrite 2!lte_fin ltr_pdivr_mull. +- by rewrite 2!lte_fin ltr_pdivrMl. - by rewrite mulr_infty sgrV gtr0_sg// mul1e 2!ltNge 2!leey. - by rewrite mulr_infty sgrV gtr0_sg// mul1e -EFinM 2!ltNyr. - by rewrite mulr_infty gtr0_sg// mul1e 2!ltry. @@ -3091,7 +3125,7 @@ Proof. by move=> r0; rewrite muleC lte_pdivr_mull// muleC. Qed. Lemma lte_pdivl_mull r y x : (0 < r)%R -> (x < r^-1%:E * y) = (r%:E * x < y). Proof. move=> r0; move: x y => [x| |] [y| |] //=. -- by rewrite 2!lte_fin ltr_pdivl_mull. +- by rewrite 2!lte_fin ltr_pdivlMl. - by rewrite mulr_infty sgrV gtr0_sg// mul1e 2!ltry. - by rewrite mulr_infty sgrV gtr0_sg// mul1e. - by rewrite mulr_infty gtr0_sg// mul1e. @@ -3107,7 +3141,7 @@ Proof. by move=> r0; rewrite muleC lte_pdivl_mull// muleC. Qed. Lemma lte_ndivl_mulr r x y : (r < 0)%R -> (x < y * r^-1%:E) = (y < x * r%:E). Proof. -rewrite -oppr0 ltr_oppr => r0; rewrite -{1}(opprK r) invrN. +rewrite -oppr0 ltrNr => r0; rewrite -{1}(opprK r) invrN. by rewrite EFinN muleN lte_oppr lte_pdivr_mulr// EFinN muleNN. Qed. @@ -3116,7 +3150,7 @@ Proof. by move=> r0; rewrite muleC lte_ndivl_mulr// muleC. Qed. Lemma lte_ndivr_mull r x y : (r < 0)%R -> (r^-1%:E * y < x) = (r%:E * x < y). Proof. -rewrite -oppr0 ltr_oppr => r0; rewrite -{1}(opprK r) invrN. +rewrite -oppr0 ltrNr => r0; rewrite -{1}(opprK r) invrN. by rewrite EFinN mulNe lte_oppl lte_pdivl_mull// EFinN muleNN. Qed. @@ -3149,7 +3183,7 @@ Proof. by move=> r0; rewrite muleC lee_pdivl_mull// muleC. Qed. Lemma lee_ndivl_mulr r x y : (r < 0)%R -> (x <= y * r^-1%:E) = (y <= x * r%:E). Proof. -rewrite -oppr0 ltr_oppr => r0; rewrite -{1}(opprK r) invrN. +rewrite -oppr0 ltrNr => r0; rewrite -{1}(opprK r) invrN. by rewrite EFinN muleN lee_oppr lee_pdivr_mulr// EFinN muleNN. Qed. @@ -3158,7 +3192,7 @@ Proof. by move=> r0; rewrite muleC lee_ndivl_mulr// muleC. Qed. Lemma lee_ndivr_mull r x y : (r < 0)%R -> (r^-1%:E * y <= x) = (r%:E * x <= y). Proof. -rewrite -oppr0 ltr_oppr => r0; rewrite -{1}(opprK r) invrN. +rewrite -oppr0 ltrNr => r0; rewrite -{1}(opprK r) invrN. by rewrite EFinN mulNe lee_oppl lee_pdivl_mull// EFinN muleNN. Qed. @@ -3182,7 +3216,7 @@ Import DualAddTheoryNumDomain DualAddTheoryRealDomain. Section DualRealFieldType_lemmas. Local Open Scope ereal_dual_scope. Variable R : realFieldType. -Implicit Types x y : \bar R. +Implicit Types x y : \bar^d R. Lemma lee_daddgt0Pr x y : reflect (forall e, (0 < e)%R -> x <= y + e%:E) (x <= y). @@ -3255,9 +3289,9 @@ Export DualAddTheory. End ConstructiveDualAddTheory. Definition posnume (R : numDomainType) of phant R := {> 0 : \bar R}. -Notation "{ 'posnum' '\bar' R }" := (@posnume _ (Phant R)) : type_scope. +Notation "{ 'posnum' '\bar' R }" := (@posnume _ (Phant R)) : type_scope. Definition nonnege (R : numDomainType) of phant R := {>= 0 : \bar R}. -Notation "{ 'nonneg' '\bar' R }" := (@nonnege _ (Phant R)) : type_scope. +Notation "{ 'nonneg' '\bar' R }" := (@nonnege _ (Phant R)) : type_scope. Notation "x %:pos" := (widen_signed x%:sgn : {posnum \bar _}) (only parsing) : ereal_dual_scope. @@ -3353,7 +3387,7 @@ Lemma adde_snum_subproof (xnz ynz : KnownSign.nullity) (y : {compare (0 : \bar R) & ynz & yr}) (rnz := add_nonzero_subdef xnz ynz xr yr) (rrl := add_reality_subdef xnz ynz xr yr) : - Signed.spec 0 rnz rrl (x%:num + y%:num). + Signed.spec 0 rnz rrl (adde x%:num y%:num). Proof. rewrite {}/rnz {}/rrl; apply/andP; split. move: xr yr xnz ynz x y => [[[]|]|] [[[]|]|] [] []//= x y; @@ -3361,7 +3395,7 @@ rewrite {}/rnz {}/rrl; apply/andP; split. move: xr yr xnz ynz x y => [[[]|]|] [[[]|]|] [] []//= x y; do ?[by case: (bottom x)|by case: (bottom y) |by rewrite adde_ge0|by rewrite adde_le0 - |exact: realDe|by rewrite 2!eq0 add0e]. + |exact: realDe|by rewrite 2!eq0 /adde/= addr0]. Qed. Canonical adde_snum (xnz ynz : KnownSign.nullity) @@ -3372,13 +3406,20 @@ Canonical adde_snum (xnz ynz : KnownSign.nullity) Import DualAddTheory. +Lemma dEFin_snum_subproof nz cond (x : {num R & nz & cond}) : + Signed.spec 0 nz cond (dEFin x%:num). +Proof. exact: EFin_snum_subproof. Qed. + +Canonical dEFin_snum nz cond (x : {num R & nz & cond}) := + Signed.mk (dEFin_snum_subproof x). + Lemma dadde_snum_subproof (xnz ynz : KnownSign.nullity) (xr yr : KnownSign.reality) (x : {compare (0 : \bar R) & xnz & xr}) (y : {compare (0 : \bar R) & ynz & yr}) (rnz := add_nonzero_subdef xnz ynz xr yr) (rrl := add_reality_subdef xnz ynz xr yr) : - Signed.spec 0 rnz rrl (x%:num + y%:num)%dE. + Signed.spec 0 rnz rrl (dual_adde x%:num y%:num)%dE. Proof. rewrite {}/rnz {}/rrl; apply/andP; split. move: xr yr xnz ynz x y => [[[]|]|] [[[]|]|] [] []//= x y; @@ -3386,7 +3427,7 @@ rewrite {}/rnz {}/rrl; apply/andP; split. move: xr yr xnz ynz x y => [[[]|]|] [[[]|]|] [] []//= x y; do ?[by case: (bottom x)|by case: (bottom y) |by rewrite dadde_ge0|by rewrite dadde_le0 - |exact: realDed|by rewrite 2!eq0 dadd0e]. + |exact: realDed|by rewrite 2!eq0 /dual_adde/= addr0]. Qed. Canonical dadde_snum (xnz ynz : KnownSign.nullity) @@ -3444,7 +3485,7 @@ Context {R : numDomainType} {nz : KnownSign.nullity} {cond : KnownSign.reality}. Local Notation nR := {compare (0 : \bar R) & nz & cond}. Implicit Types (a : \bar R). -Lemma num_abse_eq0 a : (`|a|%:nng == 0%:nng) = (a == 0). +Lemma num_abse_eq0 a : (`|a|%:nng == 0%:E%:nng) = (a == 0). Proof. by rewrite -abse_eq0. Qed. End MorphNum. @@ -3543,8 +3584,8 @@ Definition contract x : R := Lemma contract_lt1 r : (`|contract r%:E| < 1)%R. Proof. rewrite normrM normrV ?unitfE //. -rewrite ltr_pdivr_mulr // ?mul1r//; last by rewrite gtr0_norm. -by rewrite [ltRHS]gtr0_norm ?ltr_addr// ltr_spaddl. +rewrite ltr_pdivrMr // ?mul1r//; last by rewrite gtr0_norm. +by rewrite [ltRHS]gtr0_norm ?ltrDr// ltr_pwDl. Qed. Lemma contract_le1 x : (`|contract x| <= 1)%R. @@ -3553,7 +3594,7 @@ by case: x => [r| |] /=; rewrite ?normrN1 ?normr1 // (ltW (contract_lt1 _)). Qed. Lemma contract0 : contract 0 = 0%R. -Proof. by rewrite /contract mul0r. Qed. +Proof. by rewrite /contract/= mul0r. Qed. Lemma contractN x : contract (- x) = (- contract x)%R. Proof. by case: x => //= [r|]; [ rewrite normrN mulNr | rewrite opprK]. Qed. @@ -3570,15 +3611,15 @@ Proof. by move=> r1; rewrite /expand r1. Qed. Lemma expandN r : expand (- r)%R = - expand r. Proof. rewrite /expand; case: ifPn => [r1|]. - rewrite ifF; [by rewrite ifT // -ler_oppr|apply/negbTE]. - by rewrite -ltNge -(opprK r) -ltr_oppl (lt_le_trans _ r1) // -subr_gt0 opprK. -rewrite -ltNge => r1; case: ifPn; rewrite ler_oppl opprK; [by move=> ->|]. -by rewrite -ltNge leNgt => ->; rewrite leNgt -ltr_oppl r1 /= mulNr normrN. + rewrite ifF; [by rewrite ifT // -lerNr|apply/negbTE]. + by rewrite -ltNge -(opprK r) -ltrNl (lt_le_trans _ r1) // -subr_gt0 opprK. +rewrite -ltNge => r1; case: ifPn; rewrite lerNl opprK; [by move=> ->|]. +by rewrite -ltNge leNgt => ->; rewrite leNgt -ltrNl r1 /= mulNr normrN. Qed. Lemma expandN1 r : (r <= -1)%R -> expand r = -oo. Proof. -by rewrite ler_oppr => /expand1/eqP; rewrite expandN eqe_oppLR => /eqP. +by rewrite lerNr => /expand1/eqP; rewrite expandN eqe_oppLR => /eqP. Qed. Lemma expand0 : expand 0%R = 0. @@ -3589,7 +3630,7 @@ Proof. move=> r; rewrite inE le_eqVlt => /orP[|r1]. rewrite eqr_norml => /andP[/orP[]/eqP->{r}] _; by [rewrite expand1|rewrite expandN1]. -rewrite /expand 2!leNgt ltr_oppl; case/ltr_normlP : (r1) => -> -> /=. +rewrite /expand 2!leNgt ltrNl; case/ltr_normlP : (r1) => -> -> /=. have r_pneq0 : (1 + r / (1 - r) != 0)%R. rewrite -[X in (X + _)%R](@divrr _ (1 - r)%R) -?mulrDl; last first. by rewrite unitfE subr_eq0 eq_sym lt_eqF // ltr_normlW. @@ -3615,16 +3656,16 @@ Qed. Lemma le_contract : {mono contract : x y / (x <= y)%O}. Proof. apply: le_mono; move=> -[r0 | | ] [r1 | _ | _] //=. -- rewrite lte_fin => r0r1; rewrite ltr_pdivr_mulr ?ltr_paddr//. - rewrite mulrAC ltr_pdivl_mulr ?ltr_paddr// 2?mulrDr 2?mulr1. +- rewrite lte_fin => r0r1; rewrite ltr_pdivrMr ?ltr_wpDr//. + rewrite mulrAC ltr_pdivlMr ?ltr_wpDr// 2?mulrDr 2?mulr1. have [r10|?] := ler0P r1; last first. - rewrite ltr_le_add // mulrC; have [r00|//] := ler0P r0. - by rewrite (@le_trans _ _ 0%R) // ?pmulr_lle0// mulr_ge0// ?oppr_ge0// ltW. - have [?|r00] := ler0P r0; first by rewrite ltr_le_add // 2!mulrN mulrC. + rewrite ltr_leD // mulrC; have [r00|//] := ler0P r0. + by rewrite (@le_trans _ _ 0%R) // ?pmulr_rle0// mulr_ge0// ?oppr_ge0// ltW. + have [?|r00] := ler0P r0; first by rewrite ltr_leD // 2!mulrN mulrC. by move: (le_lt_trans r10 (lt_trans r00 r0r1)); rewrite ltxx. -- by rewrite ltr_pdivr_mulr ?ltr_paddr// mul1r ltr_spaddl // ler_norm. -- rewrite ltr_pdivl_mulr ?mulN1r ?ltr_paddr// => _. - by rewrite ltr_oppl ltr_spaddl // ler_normr lexx orbT. +- by rewrite ltr_pdivrMr ?ltr_wpDr// mul1r ltr_pwDl // ler_norm. +- rewrite ltr_pdivlMr ?mulN1r ?ltr_wpDr// => _. + by rewrite ltrNl ltr_pwDl // ler_normr lexx orbT. - by rewrite -subr_gt0 opprK. Qed. @@ -3641,7 +3682,7 @@ Definition expand_inj := mono_inj_in lexx le_anti le_expand_in. Lemma fine_expand r : (`|r| < 1)%R -> (fine (expand r))%:E = expand r. Proof. -by move=> r1; rewrite /expand 2!leNgt ltr_oppl; case/ltr_normlP : r1 => -> ->. +by move=> r1; rewrite /expand 2!leNgt ltrNl; case/ltr_normlP : r1 => -> ->. Qed. Lemma le_expand : {homo expand : x y / (x <= y)%O}. @@ -3649,9 +3690,9 @@ Proof. move=> x y xy; have [x1|] := lerP `|x| 1. have [y_le1|/ltW /expand1->] := leP y 1%R; last by rewrite leey. rewrite le_expand_in ?inE// ler_norml y_le1 (le_trans _ xy)//. - by rewrite ler_oppl (ler_normlP _ _ _). + by rewrite lerNl (ler_normlP _ _ _). rewrite ltr_normr => /orP[|] x1; last first. - by rewrite expandN1 // ?leNye // ler_oppr ltW. + by rewrite expandN1 // ?leNye // lerNr ltW. by rewrite expand1; [rewrite expand1 // (le_trans _ xy) // ltW | exact: ltW]. Qed. @@ -3667,7 +3708,7 @@ Qed. End contract_expand. Section ereal_PseudoMetric. -Variable R : realFieldType. +Context {R : realFieldType}. Implicit Types (x y : \bar R) (r : R). Definition ereal_ball x r y := (`|contract x - contract y| < r)%R. @@ -3682,7 +3723,7 @@ Lemma ereal_ball_triangle x y z r1 r2 : ereal_ball x r1 y -> ereal_ball y r2 z -> ereal_ball x (r1 + r2) z. Proof. rewrite /ereal_ball => h1 h2; rewrite -[X in (X - _)%R](subrK (contract y)). -by rewrite -addrA (le_lt_trans (ler_norm_add _ _)) // ltr_add. +by rewrite -addrA (le_lt_trans (ler_normD _ _)) // ltrD. Qed. Lemma ereal_ballN x y (e : {posnum R}) : @@ -3693,7 +3734,7 @@ Lemma ereal_ball_ninfty_oversize (e : {posnum R}) x : (2 < e%:num)%R -> ereal_ball -oo e%:num x. Proof. move=> e2; rewrite /ereal_ball /= (le_lt_trans _ e2) // -opprB normrN opprK. -rewrite (le_trans (ler_norm_add _ _)) // normr1 -ler_subr_addr. +rewrite (le_trans (ler_normD _ _)) // normr1 -lerBrDr. by rewrite (le_trans (contract_le1 _)) // (_ : 2 = 1 + 1)%R // addrK. Qed. @@ -3702,7 +3743,7 @@ Lemma contract_ereal_ball_pinfty r (e : {posnum R}) : Proof. move=> re1; rewrite /ereal_ball; rewrite [contract +oo]/= ler0_norm; last first. by rewrite subr_le0; case/ler_normlP: (contract_le1 r%:E). -by rewrite opprB ltr_subl_addl. +by rewrite opprB ltrBlDl. Qed. End ereal_PseudoMetric. @@ -3724,9 +3765,9 @@ move=> [:wlog]; case: a b => [a||] [b||] //= ltax ltxb. rewrite -subr_gt0 opprD addrA {1}[(b - r)%R]splitr addrK. by rewrite divr_gt0 ?subr_gt0. by rewrite -subr_gt0 addrAC {1}[(r - a)%R]splitr addrK divr_gt0 ?subr_gt0. -- have [//||d dP] := wlog a (r + 1)%R; rewrite ?lte_fin ?ltr_addl //. +- have [//||d dP] := wlog a (r + 1)%R; rewrite ?lte_fin ?ltrDl //. by exists d => y /dP /andP[->] /= /lt_le_trans; apply; rewrite leey. -- have [//||d dP] := wlog (r - 1)%R b; rewrite ?lte_fin ?gtr_addl ?ltrN10 //. +- have [//||d dP] := wlog (r - 1)%R b; rewrite ?lte_fin ?gtrDl ?ltrN10 //. by exists d => y /dP /andP[_ ->] /=; rewrite ltNyr. - by exists 1%:pos%R => ? ?; rewrite ltNyr ltry. Qed. diff --git a/theories/convex.v b/theories/convex.v index dea32cb4f..d9bf76a32 100644 --- a/theories/convex.v +++ b/theories/convex.v @@ -20,7 +20,9 @@ From HB Require Import structures. (* ``` *) (* *) (* E : lmodType R with R : realDomainType and R : realDomainType are shown to *) -(* be convex spaces *) +(* 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 *) (* *) (******************************************************************************) @@ -41,8 +43,7 @@ Import numFieldNormedType.Exports. Declare Scope convex_scope. Local Open Scope convex_scope. -HB.mixin Record isConvexSpace (R : realDomainType) (T : Type) := { - convexspacechoiceclass : Choice.class_of T ; +HB.mixin Record isConvexSpace (R : realDomainType) T := { conv : {i01 R} -> T -> T -> T ; conv0 : forall a b, conv 0%:i01 a b = a ; convmm : forall (p : {i01 R}) a, conv p a a = a ; @@ -54,13 +55,7 @@ HB.mixin Record isConvexSpace (R : realDomainType) (T : Type) := { #[short(type=convType)] HB.structure Definition ConvexSpace (R : realDomainType) := - {T of isConvexSpace R T }. - -Canonical conv_eqType (R : realDomainType) (T : convType R) := - Eval hnf in EqType (ConvexSpace.sort T) convexspacechoiceclass. -Canonical conv_choiceType (R : realDomainType) (T : convType R) := - Eval hnf in ChoiceType (ConvexSpace.sort T) convexspacechoiceclass. -Coercion conv_choiceType : convType >-> choiceType. + {T of isConvexSpace R T & Choice T}. Notation "a <| p |> b" := (conv p a b) : convex_scope. @@ -78,10 +73,14 @@ End convex_space_lemmas. Local Open Scope convex_scope. +Definition convex_lmodType {R : realDomainType} (E : lmodType R) : Type := E. + Section lmodType_convex_space. -Context {R : realDomainType} {E : lmodType R}. +Context {R : realDomainType} {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 avg0 a b : avg 0%:i01 a b = a. @@ -105,16 +104,22 @@ rewrite [in LHS]scalerDr [in LHS]addrA [in RHS]scalerDr; congr (_ + _ + _). - by rewrite scalerA. Qed. +HB.instance Definition _ := Choice.on E. + HB.instance Definition _ := - @isConvexSpace.Build R E (Choice.class _) avg avg0 avgI avgC avgA. + isConvexSpace.Build R E avg0 avgI avgC avgA. End lmodType_convex_space. +Definition convex_realDomainType (R : realDomainType) : Type := R^o. + Section realDomainType_convex_space. Context {R : realDomainType}. Implicit Types p q : {i01 R}. -Let avg p (a b : [the lmodType R of R^o]) := a <| p |> b. +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. @@ -131,7 +136,7 @@ Let avgA p q r (a b c : R) : Proof. by move=> h; rewrite /avg (convA _ _ r). Qed. HB.instance Definition _ := @isConvexSpace.Build R R^o - (Choice.class _) _ avg0 avgI avgC avgA. + _ avg0 avgI avgC avgA. End realDomainType_convex_space. diff --git a/theories/derive.v b/theories/derive.v index 1ee9cf8d5..e26f43103 100644 --- a/theories/derive.v +++ b/theories/derive.v @@ -1,4 +1,5 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +From HB Require Import structures. From mathcomp Require Import all_ssreflect ssralg ssrnum matrix interval. From mathcomp Require Import mathcomp_extra boolp classical_sets functions. Require Import reals signed topology prodnormedzmodule normedtype landau forms. @@ -55,7 +56,7 @@ Definition diff (F : filter_on V) (_ : phantom (set (set V)) F) (f : V -> W) := (get (fun (df : {linear V -> W}) => continuous df /\ forall x, f x = f (lim F) + df (x - lim F) +o_(x \near F) (x - lim F))). -Local Notation "''d' f x" := (@diff _ (Phantom _ [filter of x]) f). +Local Notation "''d' f x" := (@diff _ (Phantom _ (nbhs x)) f). Fact diff_key : forall T, T -> unit. Proof. by constructor. Qed. CoInductive differentiable_def (f : V -> W) (x : filter_on V) @@ -63,7 +64,8 @@ CoInductive differentiable_def (f : V -> W) (x : filter_on V) (continuous ('d f x) /\ f = cst (f (lim x)) + 'd f x \o center (lim x) +o_x (center (lim x))). -Local Notation differentiable f F := (@differentiable_def f _ (Phantom _ [filter of F])). +Local Notation differentiable f F := + (@differentiable_def f _ (Phantom _ (nbhs F))). Class is_diff_def (x : filter_on V) (Fph : phantom (set (set V)) x) (f : V -> W) (df : V -> W) := DiffDef { @@ -106,8 +108,9 @@ Section Differential_numFieldType. Context {K : numFieldType (*TODO: to numDomainType?*)} {V W : normedModType K}. (* duplicate from Section Differential *) -Local Notation differentiable f F := (@differentiable_def _ _ _ f _ (Phantom _ [filter of F])). -Local Notation "''d' f x" := (@diff _ _ _ _ (Phantom _ [filter of x]) f). +Local Notation differentiable f F := + (@differentiable_def _ _ _ f _ (Phantom _ (nbhs F))). +Local Notation "''d' f x" := (@diff _ _ _ _ (Phantom _ (nbhs x)) f). Hint Extern 0 (continuous _) => exact: diff_continuous : core. Lemma diff_locallyxP (x : V) (f : V -> W) : @@ -143,10 +146,10 @@ Proof. by move=> /diff_locallyP []. Qed. End Differential_numFieldType. -Notation "''d' f F" := (@diff _ _ _ _ (Phantom _ [filter of F]) f). -Notation differentiable f F := (@differentiable_def _ _ _ f _ (Phantom _ [filter of F])). +Notation "''d' f F" := (@diff _ _ _ _ (Phantom _ (nbhs F)) f). +Notation differentiable f F := (@differentiable_def _ _ _ f _ (Phantom _ (nbhs F))). -Notation "'is_diff' F" := (is_diff_def (Phantom _ [filter of F])). +Notation "'is_diff' F" := (is_diff_def (Phantom _ (nbhs F))). #[global] Hint Extern 0 (differentiable _ _) => solve[apply: ex_diff] : core. #[global] Hint Extern 0 ({for _, continuous _}) => exact: diff_continuous : core. @@ -188,7 +191,7 @@ Variables (X Y Z : normedModType R). Lemma normm_littleo x (f : X -> Y) : `| [o_(x \near x) (1 : R) of f x]| = 0. Proof. rewrite /cst /=; have [e /(_ (`|e x|/2) _)/nbhs_singleton /=] := littleo. -rewrite pmulr_lgt0 // [`|1|]normr1 mulr1 [leLHS]splitr ger_addr pmulr_lle0 //. +rewrite pmulr_lgt0 // [`|1|]normr1 mulr1 [leLHS]splitr gerDr pmulr_lle0 //. by move=> /implyP; case : real_ltgtP; rewrite ?realE ?normrE //= lexx. Qed. @@ -240,14 +243,14 @@ move=> df; apply/eqaddoP => _/posnumP[e]. rewrite -nbhs_nearE nbhs_simpl /= dnbhsE; split; last first. rewrite /at_point opprD -![(_ + _ : _ -> _) _]/(_ + _) scale0r add0r. by rewrite addrA subrr add0r normrN scale0r !normr0 mulr0. -have /eqolimP := df; rewrite -[lim _]/(derive _ _ _). +have /eqolimP := df. move=> /eqaddoP /(_ e%:num) /(_ [gt0 of e%:num]). apply: filter_app; rewrite /= !near_simpl near_withinE; near=> h => hN0. rewrite /= opprD -![(_ + _ : _ -> _) _]/(_ + _) -![(- _ : _ -> _) _]/(- _). rewrite /cst /= [`|1|]normr1 mulr1 => dfv. rewrite addrA -[X in X + _]scale1r -(@mulVf _ h) //. rewrite mulrC -scalerA -scalerBr normrZ. -rewrite -ler_pdivl_mull; last by rewrite normr_gt0. +rewrite -ler_pdivlMl; last by rewrite normr_gt0. by rewrite mulrCA mulVf ?mulr1; last by rewrite normr_eq0. Unshelve. all: by end_near. Qed. @@ -264,7 +267,7 @@ rewrite /= !(near_simpl, near_withinE); apply: filter_app; near=> h. rewrite /= opprD -![(_ + _ : _ -> _) _]/(_ + _) -![(- _ : _ -> _) _]/(- _). rewrite /cst /= [`|1|]normr1 mulr1 addrA => dfv hN0. rewrite -[X in _ - X]scale1r -(@mulVf _ h) //. -rewrite -scalerA -scalerBr normrZ normfV ler_pdivr_mull ?normr_gt0 //. +rewrite -scalerA -scalerBr normrZ normfV ler_pdivrMl ?normr_gt0 //. by rewrite mulrC. Unshelve. all: by end_near. Qed. @@ -319,15 +322,15 @@ have /(littleoP [littleo of k]) /nbhs_ballP[i i0 Hi] : 0 < e / (2 * `|v|). by rewrite divr_gt0 // pmulr_rgt0 // normr_gt0. exists (i / `|v|); first by rewrite /= divr_gt0 // normr_gt0. move=> /= j; rewrite /ball /= /ball_ add0r normrN. -rewrite ltr_pdivl_mulr ?normr_gt0 // => jvi j0. -rewrite add0r normrN normrZ -ltr_pdivl_mull ?normr_gt0 ?invr_neq0 //. +rewrite ltr_pdivlMr ?normr_gt0 // => jvi j0. +rewrite add0r normrN normrZ -ltr_pdivlMl ?normr_gt0 ?invr_neq0 //. have /Hi/le_lt_trans -> // : ball 0 i (j *: v). by rewrite -ball_normE/= add0r normrN (le_lt_trans _ jvi) // normrZ. -rewrite -(mulrC e) -mulrA -ltr_pdivl_mull // mulrA mulVr ?unitfE ?gt_eqF //. -rewrite normrV ?unitfE // div1r invrK ltr_pdivr_mull; last first. +rewrite -(mulrC e) -mulrA -ltr_pdivlMl // mulrA mulVr ?unitfE ?gt_eqF //. +rewrite normrV ?unitfE // div1r invrK ltr_pdivrMl; last first. by rewrite pmulr_rgt0 // normr_gt0. rewrite normrZ mulrC -mulrA. -by rewrite ltr_pmull ?ltr1n // pmulr_rgt0 ?normm_gt0 // normr_gt0. +by rewrite ltr_pMl ?ltr1n // pmulr_rgt0 ?normm_gt0 // normr_gt0. Qed. End DifferentialR_numFieldType. @@ -453,9 +456,9 @@ have /bigO_exP [_ /posnumP[k]] := bigOP [bigO of [O_ (0 : U) id of f]]. have := littleoP [littleo of [o_ (0 : V') id of g]]. move=> /(_ (e%:num / k%:num)) /(_ _) /nbhs_ballP [//|_ /posnumP[d] hd]. apply: filter_app; near=> x => leOxkx; apply: le_trans (hd _ _) _; last first. - rewrite -ler_pdivl_mull //; apply: le_trans leOxkx _. + rewrite -ler_pdivlMl //; apply: le_trans leOxkx _. by rewrite invf_div mulrA -[_ / _ * _]mulrA mulVf // mulr1. -by rewrite -ball_normE /= distrC subr0 (le_lt_trans leOxkx) // -ltr_pdivl_mull. +by rewrite -ball_normE /= distrC subr0 (le_lt_trans leOxkx) // -ltr_pdivlMl. Unshelve. all: by end_near. Qed. Lemma compoO_eqox (U V' W' : normedModType R) (f : U -> V') @@ -474,8 +477,8 @@ move=> /nbhs_ballP [_ /posnumP[d] hd]. have ekgt0 : e%:num / k%:num > 0 by []. have /(_ _ ekgt0) := littleoP [littleo of [o_ (0 : U) id of f]]. apply: filter_app; near=> x => leoxekx; apply: le_trans (hd _ _) _; last first. - by rewrite -ler_pdivl_mull // mulrA [_^-1 * _]mulrC. -by rewrite -ball_normE /= distrC subr0 (le_lt_trans leoxekx)// -ltr_pdivl_mull //. + by rewrite -ler_pdivlMl // mulrA [_^-1 * _]mulrC. +by rewrite -ball_normE /= distrC subr0 (le_lt_trans leoxekx)// -ltr_pdivlMl //. Unshelve. all: by end_near. Qed. End DifferentialR3. @@ -489,17 +492,17 @@ Proof. move/eqoP => oid. rewrite funeqE => x; apply/eqP; have [|xn0] := real_le0P (normr_real x). by rewrite normr_le0 => /eqP ->; rewrite linear0. -rewrite -normr_le0 -(mul0r `|x|) -ler_pdivr_mulr //. -apply/ler_gtP => _ /posnumP[e]; rewrite ler_pdivr_mulr //. +rewrite -normr_le0 -(mul0r `|x|) -ler_pdivrMr //. +apply/ler_gtP => _ /posnumP[e]; rewrite ler_pdivrMr //. have /oid /nbhs_ballP [_ /posnumP[d] dfe] := !! gt0 e. set k := ((d%:num / 2) / (PosNum xn0)%:num)^-1. rewrite -{1}(@scalerKV _ _ k _ x) /k // linearZZ normrZ. -rewrite -ler_pdivl_mull; last by rewrite gtr0_norm. +rewrite -ler_pdivlMl; last by rewrite gtr0_norm. rewrite mulrCA (@le_trans _ _ (e%:num * `|k^-1 *: x|)) //; last first. - by rewrite ler_pmul // normrZ normfV. + by rewrite ler_pM // normrZ normfV. apply: dfe; rewrite -ball_normE /= sub0r normrN normrZ. -rewrite invrK -ltr_pdivl_mulr // ger0_norm // ltr_pdivr_mulr //. -by rewrite -mulrA mulVf ?lt0r_neq0 // mulr1 [ltRHS]splitr ltr_addl. +rewrite invrK -ltr_pdivlMr // ger0_norm // ltr_pdivrMr //. +by rewrite -mulrA mulVf ?lt0r_neq0 // mulr1 [ltRHS]splitr ltrDl. Qed. Lemma diff_unique (V W : normedModType R) (f : V -> W) @@ -513,14 +516,16 @@ have hdf h : (f \o shift x = cst (f x) + h +o_ (0 : V) id) -> h = f \o shift x - cst (f x) +o_ (0 : V) id. move=> hdf; apply: eqaddoE. - rewrite hdf addrAC (addrC _ h) addrK. + rewrite hdf addrAC -!addrA addrC !addrA subrK. rewrite -[LHS]addr0 -addrA; congr (_ + _). by apply/eqP; rewrite eq_sym addrC addr_eq0 oppo. rewrite (hdf _ dxf). suff /diff_locally /hdf -> : differentiable f x. by rewrite opprD addrCA -(addrA (_ - _)) addKr oppox addox. -apply/diffP; apply: (@getPex _ (fun (df : {linear V -> W}) => continuous df /\ - forall y, f y = f (lim x) + df (y - lim x) +o_(y \near x) (y - lim x))). +apply/diffP => /=. +apply: (@getPex _ (fun (df : {linear V -> W}) => continuous df /\ + forall y, f y = f (lim (nbhs x)) + df (y - lim (nbhs x)) + +o_(y \near x) (y - lim (nbhs x)))). exists df; split=> //; apply: eqaddoEx => z. rewrite (hdf _ dxf) !addrA lim_id // /(_ \o _) /= subrK [f _ + _]addrC addrK. rewrite -addrA -[LHS]addr0; congr (_ + _). @@ -619,7 +624,9 @@ Lemma diffZl (k : V -> R) (f : W) x : differentiable k x -> Proof. move=> df; set g := RHS; have glin : linear g. by move=> a u v; rewrite /g linearP /= scalerDl -scalerA. -by apply:(@diff_unique _ _ _ (Linear glin)); have [] := dscalel f df. +pose glM := GRing.isLinear.Build _ _ _ _ _ glin. +pose gL : {linear _ -> _} := HB.pack g glM. +by apply:(@diff_unique _ _ _ gL); have [] := dscalel f df. Qed. Lemma differentiableZl (k : V -> R) (f : W) x : @@ -641,8 +648,8 @@ Qed. Global Instance is_diff_id (x : V) : is_diff x id id. Proof. apply: DiffDef. - by apply: (@linear_differentiable _ _ [linear of idfun]) => ? //. -by rewrite (@diff_lin _ _ [linear of idfun]) // => ? //. + by apply: (@linear_differentiable _ _ idfun) => ? //. +by rewrite (@diff_lin _ _ idfun) // => ? //. Qed. Global Instance is_diff_scaler (k : R) (x : V) : is_diff x ( *:%R k) ( *:%R k). @@ -654,37 +661,41 @@ Qed. Global Instance is_diff_scalel (k : R) (x : V) : is_diff k ( *:%R ^~ x) ( *:%R ^~ x). Proof. -have sx_lin : linear ( *:%R ^~ x) by move=> u y z; rewrite scalerDl scalerA. -have -> : *:%R ^~ x = Linear sx_lin by rewrite funeqE. +have sx_lin : linear ( *:%R ^~ x : [the lmodType R of R : Type] -> _). + by move=> u y z; rewrite scalerDl scalerA. +pose sxlM := GRing.isLinear.Build _ _ _ _ _ sx_lin. +pose sxL : {linear _ -> _} := HB.pack ( *:%R ^~ x) sxlM. +have -> : *:%R ^~ x = sxL by rewrite funeqE. apply: DiffDef; first exact/linear_differentiable/scalel_continuous. -by rewrite diff_lin//; apply: scalel_continuous. +by rewrite diff_lin //; apply: scalel_continuous. Qed. Lemma differentiable_coord m n (M : 'M[R]_(m.+1, n.+1)) i j : differentiable (fun N : 'M[R]_(m.+1, n.+1) => N i j : R ) M. Proof. have @f : {linear 'M[R]_(m.+1, n.+1) -> R}. - by exists (fun N : 'M[R]_(_, _) => N i j); eexists; move=> ? ?; rewrite !mxE. + by exists (fun N : 'M[R]_(_, _) => N i j); do 2![eexists]; do ?[constructor]; + rewrite ?mxE// => ? *; rewrite ?mxE//; move=> ?; rewrite !mxE. rewrite (_ : (fun _ => _) = f) //; exact/linear_differentiable/coord_continuous. Qed. Lemma linear_lipschitz (V' W' : normedModType R) (f : {linear V' -> W'}) : continuous f -> exists2 k, k > 0 & forall x, `|f x| <= k * `|x|. Proof. -move=> /(_ 0); rewrite linear0 => /(_ _ (nbhsx_ballx _ _ ltr01)). +move=> /(_ 0); rewrite /continuous_at linear0 => /(_ _ (nbhsx_ballx _ _ ltr01)). move=> /nbhs_ballP [_ /posnumP[e] he]; exists (2 / e%:num) => // x. have [|xn0] := real_le0P (normr_real x). by rewrite normr_le0 => /eqP->; rewrite linear0 !normr0 mulr0. set k := 2 / e%:num * (PosNum xn0)%:num. have kn0 : k != 0 by rewrite /k. have abskgt0 : `|k| > 0 by rewrite normr_gt0. -rewrite -[x in leLHS](scalerKV kn0) linearZZ normrZ -ler_pdivl_mull //. +rewrite -[x in leLHS](scalerKV kn0) linearZZ normrZ -ler_pdivlMl //. suff /he : ball 0 e%:num (k^-1 *: x). rewrite -ball_normE /= distrC subr0 => /ltW /le_trans; apply. by rewrite ger0_norm /k // mulVf. rewrite -ball_normE /= distrC subr0 normrZ. rewrite normfV ger0_norm /k // invrM ?unitfE // mulrAC mulVf //. -by rewrite invf_div mul1r [ltRHS]splitr; apply: ltr_spaddr. +by rewrite invf_div mul1r [ltRHS]splitr; apply: ltr_pwDr. Qed. Lemma linear_eqO (V' W' : normedModType R) (f : {linear V' -> W'}) : @@ -740,7 +751,7 @@ Lemma bilinear_schwarz (U V' W' : normedModType R) (f : {bilinear U -> V' -> W'}) : continuous (fun p => f p.1 p.2) -> exists2 k, k > 0 & forall u v, `|f u v| <= k * `|u| * `|v|. Proof. -move=> /(_ 0); rewrite linear0r => /(_ _ (nbhsx_ballx _ _ ltr01)). +move=> /(_ 0); rewrite /continuous_at linear0r => /(_ _ (nbhsx_ballx _ _ ltr01)). move=> /nbhs_ballP [_ /posnumP[e] he]; exists ((2 / e%:num) ^+2) => // u v. have [|un0] := real_le0P (normr_real u). by rewrite normr_le0 => /eqP->; rewrite linear0l !normr0 mulr0 mul0r. @@ -750,12 +761,12 @@ rewrite -[`|u|]/((PosNum un0)%:num) -[`|v|]/((PosNum vn0)%:num). set ku := 2 / e%:num * (PosNum un0)%:num. set kv := 2 / e%:num * (PosNum vn0)%:num. rewrite -[X in f X](@scalerKV _ _ ku) /ku // linearZl_LR normrZ. -rewrite gtr0_norm // -ler_pdivl_mull //. +rewrite gtr0_norm // -ler_pdivlMl //. rewrite -[X in f _ X](@scalerKV _ _ kv) /kv // linearZr_LR normrZ. -rewrite gtr0_norm // -ler_pdivl_mull //. +rewrite gtr0_norm // -ler_pdivlMl //. suff /he : ball 0 e%:num (ku^-1 *: u, kv^-1 *: v). rewrite -ball_normE /= distrC subr0 => /ltW /le_trans; apply. - rewrite ler_pdivl_mull 1?pmulr_lgt0// mulr1 ler_pdivl_mull 1?pmulr_lgt0//. + rewrite ler_pdivlMl 1?pmulr_lgt0// mulr1 ler_pdivlMl 1?pmulr_lgt0//. by rewrite mulrA [ku * _]mulrAC expr2. rewrite -ball_normE /= distrC subr0. have -> : (ku^-1 *: u, kv^-1 *: v) = @@ -763,7 +774,7 @@ have -> : (ku^-1 *: u, kv^-1 *: v) = rewrite invrM ?unitfE // [kv ^-1]invrM ?unitfE //. rewrite mulrC -[_ *: u]scalerA [X in X *: v]mulrC -[_ *: v]scalerA. by rewrite invf_div. -rewrite normrZ ger0_norm // -mulrA gtr_pmulr // ltr_pdivr_mull // mulr1. +rewrite normrZ ger0_norm // -mulrA gtr_pMr // ltr_pdivrMl // mulr1. by rewrite prod_normE/= !normrZ !normfV !normr_id !mulVf ?gt_eqF// maxxx ltr1n. Qed. @@ -772,8 +783,8 @@ Lemma bilinear_eqo (U V' W' : normedModType R) (f : {bilinear U -> V' -> W'}) : Proof. move=> fc; have [_ /posnumP[k] fschwarz] := bilinear_schwarz fc. apply/eqoP=> _ /posnumP[e]; near=> x; rewrite (le_trans (fschwarz _ _))//. -rewrite ler_pmul ?pmulr_rge0 //; last by rewrite num_le_maxr /= lexx orbT. -rewrite -ler_pdivl_mull //. +rewrite ler_pM ?pmulr_rge0 //; last by rewrite num_le_maxr /= lexx orbT. +rewrite -ler_pdivlMl //. suff : `|x| <= k%:num ^-1 * e%:num by apply: le_trans; rewrite num_le_maxr /= lexx. near: x; rewrite !near_simpl; apply/nbhs_le_nbhs_norm. by exists (k%:num ^-1 * e%:num) => //= ? /=; rewrite /= distrC subr0 => /ltW. @@ -799,9 +810,12 @@ Lemma diff_bilin (U V' W' : normedModType R) (f : {bilinear U -> V' -> W'}) p : continuous (fun p => f p.1 p.2) -> 'd (fun q => f q.1 q.2) p = (fun q => f p.1 q.2 + f q.1 p.2) :> (U * V' -> W'). Proof. -move=> fc; have lind : linear (fun q => f p.1 q.2 + f q.1 p.2). - by move=> ???; rewrite linearPr linearPl scalerDr addrACA. -have -> : (fun q => f p.1 q.2 + f q.1 p.2) = Linear lind by []. +pose d q := f p.1 q.2 + f q.1 p.2. +move=> fc; have lind : linear d. + by move=> ???; rewrite /d linearPr linearPl scalerDr addrACA. +pose dlM := GRing.isLinear.Build _ _ _ _ _ lind. +pose dL : {linear _ -> _} := HB.pack d dlM. +rewrite -/d -[d]/(dL : _ -> _). by apply/diff_unique; have [] := dbilin p fc. Qed. @@ -813,19 +827,29 @@ by move=> fc; apply/diff_locallyP; rewrite diff_bilin //; apply: dbilin p fc. Qed. Definition mulr_rev (y x : R) := x * y. -Canonical rev_mulr := @RevOp _ _ _ mulr_rev (@GRing.mul [ringType of R]) - (fun _ _ => erefl). +Canonical rev_mulr := @RevOp _ _ _ mulr_rev (@GRing.mul R) (fun _ _ => erefl). -Lemma mulr_is_linear x : linear (@GRing.mul [ringType of R] x : R -> R). +Lemma mulr_is_linear x : linear (@GRing.mul R x : R -> R). Proof. by move=> ???; rewrite mulrDr scalerAr. Qed. -Canonical mulr_linear x := Linear (mulr_is_linear x). +HB.instance Definition _ x := GRing.isLinear.Build R R R _ ( *%R x) + (mulr_is_linear x). Lemma mulr_rev_is_linear y : linear (mulr_rev y : R -> R). Proof. by move=> ???; rewrite /mulr_rev mulrDl scalerAl. Qed. -Canonical mulr_rev_linear y := Linear (mulr_rev_is_linear y). +HB.instance Definition _ y := GRing.isLinear.Build R R R _ (mulr_rev y) + (mulr_rev_is_linear y). -Canonical mulr_bilinear := - [bilinear of @GRing.mul [ringType of [lmodType R of R]]]. +Lemma mulr_is_bilinear : + bilinear_for + (GRing.Scale.Law.clone _ _ *:%R _) (GRing.Scale.Law.clone _ _ *:%R _) + (@GRing.mul R). +Proof. +split=> [u'|u] a x y /=. +- by rewrite mulrDl scalerAl. +- by rewrite mulrDr scalerAr. +Qed. +HB.instance Definition _ := bilinear_isBilinear.Build R R R R _ _ (@GRing.mul R) + mulr_is_bilinear. Global Instance is_diff_mulr (p : R * R) : is_diff p (fun q => q.1 * q.2) (fun q => p.1 * q.2 + q.1 * p.2). @@ -864,9 +888,11 @@ Lemma diff_pair (U V' W' : normedModType R) (f : U -> V') (g : U -> W') x : (fun y => ('d f x y, 'd g x y)) :> (U -> V' * W'). Proof. move=> df dg. -have lin_pair : linear (fun y => ('d f x y, 'd g x y)). - by move=> ???; rewrite !linearPZ. -have -> : (fun y => ('d f x y, 'd g x y)) = Linear lin_pair by []. +pose d y := ('d f x y, 'd g x y). +have lin_pair : linear d by move=> ???; rewrite /d !linearPZ. +pose pairlM := GRing.isLinear.Build _ _ _ _ _ lin_pair. +pose pairL : {linear _ -> _} := HB.pack d pairlM. +rewrite -/d -[d]/(pairL : _ -> _). by apply: diff_unique; have [] := dpair df dg. Qed. @@ -935,31 +961,29 @@ have hDx_neq0 : h + x != 0. rewrite addrC -[X in X * _]mulr1 -{2}[1](@mulfVK _ (h + x)) //. rewrite mulrA expr_div_n expr1n mulf_div mulr1 [_ ^+ 2 * _]mulrC -mulrA. rewrite -mulrDr mulrBr [1 / _ * _]mulrC normrM. -rewrite mulrDl mulrDl opprD addrACA addrA [x * _]mulrC expr2. -do 2 ?[rewrite -addrA [- _ + _]addrC subrr addr0]. +rewrite mulrDl mulrDl opprD addrACA addrA [x * _]mulrC expr2 2!subrK. rewrite div1r normfV [X in _ / X]normrM invfM [X in _ * X]mulrC. -rewrite mulrA mulrAC ler_pdivr_mulr ?normr_gt0 ?mulf_neq0 //. -rewrite mulrAC ler_pdivr_mulr ?normr_gt0 //. +rewrite mulrA mulrAC ler_pdivrMr ?normr_gt0 ?mulf_neq0 //. +rewrite mulrAC ler_pdivrMr ?normr_gt0 //. have : `|h * h| <= `|x / 2| * (e%:num * `|x * x| * `|h|). rewrite !mulrA; near: h; exists (`|x / 2| * e%:num * `|x * x|). by rewrite /= !pmulr_rgt0 // normr_gt0 mulf_neq0. - by move=> h /ltW; rewrite distrC subr0 [`|h * _|]normrM => /ler_pmul; apply. -move=> /le_trans-> //; rewrite [leLHS]mulrC ler_pmul ?mulr_ge0 //. + by move=> h /ltW; rewrite distrC subr0 [`|h * _|]normrM => /ler_pM; apply. +move=> /le_trans -> //; rewrite [leLHS]mulrC ler_pM ?mulr_ge0 //. near: h; exists (`|x| / 2); first by rewrite /= divr_gt0 ?normr_gt0. move=> h; rewrite /= distrC subr0 => lthhx; rewrite addrC -[h]opprK. apply: le_trans (@ler_dist_dist _ R _ _). rewrite normrN [leRHS]ger0_norm; last first. rewrite subr_ge0; apply: ltW; apply: lt_le_trans lthhx _. - by rewrite ler_pdivr_mulr // -{1}(mulr1 `|x|) ler_pmul // ler1n. -rewrite ler_subr_addr -ler_subr_addl (splitr `|x|). + by rewrite ler_pdivrMr // -{1}(mulr1 `|x|) ler_pM // ler1n. +rewrite lerBrDr -lerBrDl (splitr `|x|). by rewrite normrM normfV (@ger0_norm _ 2) // -addrA subrr addr0; apply: ltW. Unshelve. all: by end_near. Qed. Lemma diff_Rinv (x : R) : x != 0 -> 'd GRing.inv x = (fun h : R => - x ^- 2 *: h) :> (R -> R). Proof. -move=> xn0; have -> : (fun h : R => - x ^- 2 *: h) = - GRing.scale_linear _ (- x ^- 2) by []. +move=> xn0; have -> : (fun h : R => - x ^- 2 *: h) = ( *:%R (- x ^- 2)) by []. by apply: diff_unique; have [] := dinv xn0. Qed. @@ -1017,19 +1041,22 @@ Qed. Lemma deriv1E f x : derivable f x 1 -> 'd f x = ( *:%R^~ (f^`() x)) :> (R -> U). Proof. -move=> df; have lin_scal : linear (fun h : R => h *: f^`() x). - by move=> ? ? ?; rewrite scalerDl scalerA. -have -> : (fun h => h *: f^`() x) = Linear lin_scal by []. +pose d (h : R) := h *: f^`() x. +move=> df; have lin_scal : linear d by move=> ???; rewrite /d scalerDl scalerA. +pose scallM := GRing.isLinear.Build _ _ _ _ _ lin_scal. +pose scalL : {linear _ -> _} := HB.pack d scallM. +rewrite -/d -[d]/(scalL : _ -> _). by apply: diff_unique; [apply: scalel_continuous|apply: der1]. Qed. Lemma diff1E f x : differentiable f x -> 'd f x = (fun h => h *: f^`() x) :> (R -> U). Proof. -move=> df; have lin_scal : linear (fun h : R => h *: 'd f x 1). - by move=> ? ? ?; rewrite scalerDl scalerA. -have -> : (fun h => h *: f^`() x) = Linear lin_scal. - by rewrite derive1E'. +pose d (h : R) := h *: 'd f x 1. +move=> df; have lin_scal : linear d by move=> ???; rewrite /d scalerDl scalerA. +pose scallM := GRing.isLinear.Build _ _ _ _ _ lin_scal. +pose scalL : {linear _ -> _} := HB.pack d scallM. +have -> : (fun h => h *: f^`() x) = scalL by rewrite derive1E'. apply: diff_unique; first exact: scalel_continuous. apply/eqaddoE; have /diff_locally -> := df; congr (_ + _ + _). by rewrite funeqE => h /=; rewrite -{1}[h]mulr1 linearZ. @@ -1324,7 +1351,7 @@ have imf_sup : has_sup imf. have [M [Mreal imfltM]] : bounded_set (f @` `[a, b]). by apply/compact_bounded/continuous_compact => //; exact: segment_compact. exists (M + 1) => y /imfltM yleM. - by rewrite (le_trans _ (yleM _ _)) ?ler_norm ?ltr_addl. + by rewrite (le_trans _ (yleM _ _)) ?ler_norm ?ltrDl. have [|imf_ltsup] := pselect (exists2 c, c \in `[a, b]%R & f c = sup imf). move=> [c cab fceqsup]; exists c => // t tab; rewrite fceqsup. by apply/sup_upper_bound => //; exact/imageP. @@ -1342,9 +1369,9 @@ have /ex_strict_bound_gt0 [k k_gt0 /= imVfltk] : bounded_set (g @` `[a, b]). exact: invf_continuous. have [_ [t tab <-]] : exists2 y, imf y & sup imf - k^-1 < y. by apply: sup_adherent => //; rewrite invr_gt0. -rewrite ltr_subl_addr -ltr_subl_addl. +rewrite ltrBlDr -ltrBlDl. suff : sup imf - f t > k^-1 by move=> /ltW; rewrite leNgt => /negbTE ->. -rewrite -[ltRHS]invrK ltf_pinv// ?qualifE ?invr_gt0 ?subr_gt0 ?imf_ltsup//. +rewrite -[ltRHS]invrK ltf_pV2// ?qualifE/= ?invr_gt0 ?subr_gt0 ?imf_ltsup//. by rewrite (le_lt_trans (ler_norm _) _) ?imVfltk//; exact: imageP. Qed. @@ -1355,27 +1382,46 @@ Proof. move=> leab fcont. have /(EVT_max leab) [c clr fcmax] : {within `[a, b], continuous (- f)}. by move=> ?; apply: continuousN => ?; exact: fcont. -by exists c => // ? /fcmax; rewrite ler_opp2. +by exists c => // ? /fcmax; rewrite lerN2. +Qed. + +Lemma cvg_at_rightE (R : numFieldType) (V : normedModType R) (f : R -> V) x : + cvg (f @ x^') -> lim (f @ x^') = lim (f @ at_right x). +Proof. +move=> cvfx; apply/Logic.eq_sym. +apply: (@cvg_lim _ _ _ (at_right _)) => // A /cvfx /nbhs_ballP [_ /posnumP[e] xe_A]. +by exists e%:num => //= y xe_y; rewrite lt_def => /andP [xney _]; apply: xe_A. +Qed. +Arguments cvg_at_rightE {R V} f x. + +Lemma cvg_at_leftE (R : numFieldType) (V : normedModType R) (f : R -> V) x : + cvg (f @ x^') -> lim (f @ x^') = lim (f @ at_left x). +Proof. +move=> cvfx; apply/Logic.eq_sym. +apply: (@cvg_lim _ _ _ (at_left _)) => // A /cvfx /nbhs_ballP [_ /posnumP[e] xe_A]. +exists e%:num => //= y xe_y; rewrite lt_def => /andP [xney _]. +by apply: xe_A => //; rewrite eq_sym. Qed. +Arguments cvg_at_leftE {R V} f x. -Lemma __deprecated__le0r_cvg_map (R : realFieldType) (T : topologicalType) (F : set (set T)) - (FF : ProperFilter F) (f : T -> R) : +Lemma __deprecated__le0r_cvg_map (R : realFieldType) (T : topologicalType) + (F : set_system T) (FF : ProperFilter F) (f : T -> R) : (\forall x \near F, 0 <= f x) -> cvg (f @ F) -> 0 <= lim (f @ F). Proof. by move=> ? ?; rewrite limr_ge. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="generalized by `limr_ge`")] Notation le0r_cvg_map := __deprecated__le0r_cvg_map (only parsing). -Lemma __deprecated__ler0_cvg_map (R : realFieldType) (T : topologicalType) (F : set (set T)) - (FF : ProperFilter F) (f : T -> R) : +Lemma __deprecated__ler0_cvg_map (R : realFieldType) (T : topologicalType) + (F : set_system T) (FF : ProperFilter F) (f : T -> R) : (\forall x \near F, f x <= 0) -> cvg (f @ F) -> lim (f @ F) <= 0. Proof. by move=> ? ?; rewrite limr_le. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="generalized by `limr_le`")] Notation ler0_cvg_map := __deprecated__ler0_cvg_map (only parsing). -Lemma __deprecated__ler_cvg_map (R : realFieldType) (T : topologicalType) (F : set (set T)) - (FF : ProperFilter F) (f g : T -> R) : +Lemma __deprecated__ler_cvg_map (R : realFieldType) (T : topologicalType) + (F : set_system T) (FF : ProperFilter F) (f g : T -> R) : (\forall x \near F, f x <= g x) -> cvg (f @ F) -> cvg (g @ F) -> lim (f @ F) <= lim (g @ F). Proof. by move=> ? ? ?; rewrite ler_lim. Qed. @@ -1400,8 +1446,8 @@ apply/eqP; rewrite eq_le; apply/andP; split. by rewrite invr_ge0; apply: ltW; near: h; exists 1 => /=. rewrite subr_le0 [_%:A]mulr1; apply: cmax; near: h. exists (b - c); first by rewrite /= subr_gt0 (itvP cab). - move=> h; rewrite /= distrC subr0 /= in_itv /= -ltr_subr_addr. - move=> /(le_lt_trans (ler_norm _)) -> /ltr_spsaddl -> //. + move=> h; rewrite /= distrC subr0 /= in_itv /= -ltrBrDr. + move=> /(le_lt_trans (ler_norm _)) -> /ltr_pDl -> //. by rewrite (itvP cab). rewrite ['D_1 f c]cvg_at_leftE; last exact: fdrvbl. apply: limr_ge. @@ -1414,8 +1460,8 @@ near=> h; apply: mulr_le0. rewrite subr_le0 [_%:A]mulr1; apply: cmax; near: h. exists (c - a); first by rewrite /= subr_gt0 (itvP cab). move=> h; rewrite /= distrC subr0. -move=> /ltr_normlP []; rewrite ltr_subr_addl ltr_subl_addl in_itv /= => -> _. -by move=> /ltr_snsaddl -> //; rewrite (itvP cab). +move=> /ltr_normlP []; rewrite ltrBrDl ltrBlDl in_itv /= => -> _. +by move=> /ltr_nDl -> //; rewrite (itvP cab). Unshelve. all: by end_near. Qed. Lemma derive1_at_min (R : realFieldType) (f : R -> R) (a b c : R) : @@ -1427,7 +1473,7 @@ apply/eqP; rewrite -oppr_eq0; apply/eqP. rewrite -deriveN; last exact: fdrvbl. suff df : is_derive c 1 (- f) 0 by rewrite derive_val. apply: derive1_at_max leab _ (cab) _ => t tab; first exact/derivableN/fdrvbl. -by rewrite ler_opp2; apply: cmin. +by rewrite lerN2; apply: cmin. Qed. Lemma Rolle (R : realType) (f : R -> R) (a b : R) : @@ -1527,7 +1573,7 @@ Lemma le0r_derive1_ndecr (R : realType) (f : R -> R) (a b : R) : {within `[a,b], continuous f} -> forall x y, a <= x -> x <= y -> y <= b -> f x <= f y. Proof. -move=> fdrvbl dfge0 fcont x y; rewrite -[f _ <= _]ler_opp2. +move=> fdrvbl dfge0 fcont x y; rewrite -[f _ <= _]lerN2. apply (@ler0_derive1_nincr _ (- f)) => t tab; first exact/derivableN/fdrvbl. rewrite derive1E deriveN; last exact: fdrvbl. by rewrite oppr_le0 -derive1E; apply: dfge0. @@ -1547,7 +1593,7 @@ Qed. Section is_derive_instances. Variables (R : numFieldType) (V : normedModType R). -Lemma derivable_cst (x : V) : derivable (fun=> x) 0 1. +Lemma derivable_cst (x : V) : derivable (fun=> x) 0 (1 : R). Proof. exact/diff_derivable. Qed. Lemma derivable_id (x v : V) : derivable id x v. @@ -1556,7 +1602,8 @@ Proof. exact/diff_derivable. Qed. Global Instance is_derive_id (x v : V) : is_derive x v id v. Proof. apply: (DeriveDef (@derivable_id _ _)). -by rewrite deriveE// (@diff_lin _ _ _ [linear of idfun]). +rewrite deriveE// (@diff_lin _ _ _ idfun)//=. +by rewrite /continuous_at. Qed. Global Instance is_deriveNid (x v : V) : is_derive x v -%R (- v). @@ -1566,5 +1613,5 @@ End is_derive_instances. (* Trick to trigger type class resolution *) Lemma trigger_derive (R : realType) (f : R -> R) x x1 y1 : - is_derive x 1 f x1 -> x1 = y1 -> is_derive x 1 f y1. + is_derive x (1 : R) f x1 -> x1 = y1 -> is_derive x 1 f y1. Proof. by move=> Hi <-. Qed. diff --git a/theories/ereal.v b/theories/ereal.v index 198cb31ae..1201c4ea3 100644 --- a/theories/ereal.v +++ b/theories/ereal.v @@ -4,7 +4,7 @@ (* Copyright (c) - 2015--2018 - Inria *) (* Copyright (c) - 2016--2018 - Polytechnique *) (* -------------------------------------------------------------------- *) - +From HB Require Import structures. From mathcomp Require Import all_ssreflect all_algebra finmap. From mathcomp Require Import mathcomp_extra boolp classical_sets functions. From mathcomp Require Import fsbigop cardinality set_interval. @@ -82,7 +82,7 @@ Qed. Local Close Scope classical_set_scope. -Notation "\sum_ ( i '\in' A ) F" := (\big[+%dE/0%E]_(i \in A) F%dE) : +Notation "\sum_ ( i '\in' A ) F" := (\big[+%dE/0%dE]_(i \in A) F%dE) : ereal_dual_scope. Notation "\sum_ ( i '\in' A ) F" := (\big[+%E/0%E]_(i \in A) F%E) : ereal_scope. @@ -270,7 +270,7 @@ apply: (big_ind2 (fun x y => x = - y)%E) => [|_ x _ y -> ->|i _]. - by rewrite oppeK. Qed. -Lemma dfsume_ge0 (I : choiceType) (P : set I) (F : I -> \bar R) : +Lemma dfsume_ge0 (I : choiceType) (P : set I) (F : I -> \bar^d R) : (forall i, P i -> 0 <= F i) -> 0 <= \sum_(i \in P) F i. Proof. move=> PF; case: finite_supportP; rewrite ?big_nil// => X XP F0 _. @@ -293,23 +293,23 @@ Import DualAddTheory. Local Open Scope ereal_dual_scope. Context {R : realDomainType}. -Implicit Types x y z a b : \bar R. +Implicit Types x y z a b : \bar^d R. -Lemma dfsume_gt0 (I : choiceType) (P : set I) (F : I -> \bar R) : +Lemma dfsume_gt0 (I : choiceType) (P : set I) (F : I -> \bar^d R) : 0 < \sum_(i \in P) F i -> exists2 i, P i & 0 < F i. Proof. rewrite dual_fsumeE oppe_gt0 => /fsume_lt0[i Pi]. by rewrite oppe_lt0 => ?; exists i. Qed. -Lemma dfsume_lt0 (I : choiceType) (P : set I) (F : I -> \bar R) : +Lemma dfsume_lt0 (I : choiceType) (P : set I) (F : I -> \bar^d R) : \sum_(i \in P) F i < 0 -> exists2 i, P i & F i < 0. Proof. rewrite dual_fsumeE oppe_lt0 => /fsume_gt0[i Pi]. by rewrite oppe_gt0 => ?; exists i. Qed. -Lemma pdfsume_eq0 (I : choiceType) (P : set I) (F : I -> \bar R) : +Lemma pdfsume_eq0 (I : choiceType) (P : set I) (F : I -> \bar^d R) : finite_set P -> (forall i, P i -> 0 <= F i) -> \sum_(i \in P) F i = 0 -> forall i, P i -> F i = 0. @@ -319,7 +319,7 @@ rewrite (fsbigD1 i)//= pdadde_eq0 ?F0 ?negb_and ?Fi0//. by rewrite dfsume_ge0// => j [/F0->]. Qed. -Lemma le0_mule_dfsumr (T : choiceType) x (F : T -> \bar R) (P : set T) : +Lemma le0_mule_dfsumr (T : choiceType) x (F : T -> \bar^d R) (P : set T) : (forall i : T, F i <= 0) -> x * (\sum_(i \in P) F i) = \sum_(i \in P) x * F i. Proof. move=> Fge0. @@ -328,7 +328,7 @@ rewrite (eq_bigr _ (fun _ _ => muleN _ _)). by rewrite (eq_finite_support _ (fun i _ => muleN _ _)). Qed. -Lemma le0_mule_dfsuml (T : choiceType) x (F : T -> \bar R) (P : set T) : +Lemma le0_mule_dfsuml (T : choiceType) x (F : T -> \bar^d R) (P : set T) : (forall i : T, F i <= 0) -> (\sum_(i \in P) F i) * x = \sum_(i \in P) F i * x. Proof. move=> F0; rewrite muleC le0_mule_dfsumr//. @@ -344,7 +344,7 @@ Export ConstructiveDualAddTheory. Export DualAddTheoryNumDomain. End DualAddTheory. -Canonical ereal_pointed (R : numDomainType) := PointedType (extended R) 0%E. +HB.instance Definition _ (R : numDomainType) := isPointed.Build (\bar R) 0%E. Section ereal_supremum. Variable R : realFieldType. @@ -640,20 +640,19 @@ Context {R : numFieldType}. Local Open Scope ereal_scope. Local Open Scope classical_set_scope. -Definition ereal_dnbhs (x : \bar R) (P : \bar R -> Prop) : Prop := - match x with +Definition ereal_dnbhs (x : \bar R) : set_system (\bar R) := + [set P | match x with | r%:E => r^' (fun r => P r%:E) | +oo => exists M, M \is Num.real /\ forall y, M%:E < y -> P y | -oo => exists M, M \is Num.real /\ forall y, y < M%:E -> P y - end. -Definition ereal_nbhs (x : \bar R) (P : \bar R -> Prop) : Prop := - match x with + end]. +Definition ereal_nbhs (x : \bar R) : set_system (\bar R) := + [set P | match x with | x%:E => nbhs x (fun r => P r%:E) | +oo => exists M, M \is Num.real /\ forall y, M%:E < y -> P y | -oo => exists M, M \is Num.real /\ forall y, y < M%:E -> P y - end. -Canonical ereal_ereal_filter := - FilteredType (extended R) (extended R) (ereal_nbhs). + end]. +HB.instance Definition _ := hasNbhs.Build (\bar R) ereal_nbhs. End ereal_nbhs. Section ereal_nbhs_instances. @@ -669,7 +668,7 @@ case=> [x||]. by move=> P Q PQ /xS; apply => y /PQ. - apply Build_ProperFilter. move=> P [x [xr xP]] //; exists (x + 1)%:E; apply xP => /=. - by rewrite lte_fin ltr_addl. + by rewrite lte_fin ltrDl. split=> /= [|P Q [MP [MPr gtMP]] [MQ [MQr gtMQ]] |P Q sPQ [M [Mr gtM]]]. + by exists 0%R. + have [MP0|MP0] := eqVneq MP 0%R. @@ -695,7 +694,7 @@ case=> [x||]. + by exists M; split => // ? /gtM /sPQ. - apply Build_ProperFilter. + move=> P [M [Mr ltMP]]; exists (M - 1)%:E. - by apply: ltMP; rewrite lte_fin gtr_addl oppr_lt0. + by apply: ltMP; rewrite lte_fin gtrDl oppr_lt0. + split=> /= [|P Q [MP [MPr ltMP]] [MQ [MQr ltMQ]] |P Q sPQ [M [Mr ltM]]]. * by exists 0%R. * have [MP0|MP0] := eqVneq MP 0%R. @@ -704,25 +703,25 @@ case=> [x||]. [apply/ltMP; rewrite MP0 | apply/ltMQ; rewrite MQ0]. exists (- `|MQ|)%R; rewrite realN realE normr_ge0; split => // x xMQ. split. - by apply ltMP; rewrite (lt_le_trans xMQ)// lee_fin MP0 ler_oppl oppr0. - apply ltMQ; rewrite (lt_le_trans xMQ) // lee_fin ler_oppl -normrN. + by apply ltMP; rewrite (lt_le_trans xMQ)// lee_fin MP0 lerNl oppr0. + apply ltMQ; rewrite (lt_le_trans xMQ) // lee_fin lerNl -normrN. by rewrite real_ler_normr ?realN // lexx. * have [MQ0|MQ0] := eqVneq MQ 0%R. exists (- `|MP|)%R; rewrite realN realE normr_ge0; split => // x MPx. split. - apply ltMP; rewrite (lt_le_trans MPx) // lee_fin ler_oppl -normrN. + apply ltMP; rewrite (lt_le_trans MPx) // lee_fin lerNl -normrN. by rewrite real_ler_normr ?realN // lexx. - by apply ltMQ; rewrite (lt_le_trans MPx) // lee_fin MQ0 ler_oppl oppr0. + by apply ltMQ; rewrite (lt_le_trans MPx) // lee_fin MQ0 lerNl oppr0. have {}MP0 : (0 < `|MP|)%R by rewrite normr_gt0. have {}MQ0 : (0 < `|MQ|)%R by rewrite normr_gt0. exists (- (Num.max (PosNum MP0) (PosNum MQ0))%:num)%R. rewrite realN realE /= ge0 /=; split => //. case=> [r|//|]. - - rewrite lte_fin ltr_oppr num_max num_lt_maxl => /andP[]. - rewrite ltr_oppr => MPx; rewrite ltr_oppr => MQx; split. - apply/ltMP; rewrite lte_fin (lt_le_trans MPx) //= ler_oppl -normrN. + - rewrite lte_fin ltrNr num_max num_lt_maxl => /andP[]. + rewrite ltrNr => MPx; rewrite ltrNr => MQx; split. + apply/ltMP; rewrite lte_fin (lt_le_trans MPx) //= lerNl -normrN. by rewrite real_ler_normr ?realN // lexx. - apply/ltMQ; rewrite lte_fin (lt_le_trans MQx) //= ler_oppl -normrN. + apply/ltMQ; rewrite lte_fin (lt_le_trans MQx) //= lerNl -normrN. by rewrite real_ler_normr ?realN // lexx. - by move=> _; split; [apply/ltMP | apply/ltMQ]. * by exists M; split => // x /ltM /sPQ. @@ -795,10 +794,10 @@ move: p => -[p| [M [Mreal MA]] | [M [Mreal MA]]] //=. rewrite lte_fin => M'x /=. apply/nbhs_ballP; exists 1%R => //= y x1y. apply MA; rewrite lte_fin. - rewrite addrC -ltr_subr_addl in M'x. - rewrite (lt_le_trans M'x) // ler_subl_addl addrC -ler_subl_addl. + rewrite addrC -ltrBrDl in M'x. + rewrite (lt_le_trans M'x) // lerBlDl addrC -lerBlDl. rewrite (le_trans _ (ltW x1y)) // real_ler_norm // realB //. - rewrite ltr_subr_addr in M'x. + rewrite ltrBrDr in M'x. rewrite -comparabler0 (@comparabler_trans _ (M + 1)%R) //. by rewrite /Order.comparable (ltW M'x) orbT. by rewrite comparabler0 realD. @@ -808,20 +807,16 @@ move: p => -[p| [M [Mreal MA]] | [M [Mreal MA]]] //=. rewrite lte_fin => M'x /=. apply/nbhs_ballP; exists 1%R => //= y x1y. apply MA; rewrite lte_fin. - rewrite ltr_subr_addl in M'x. - rewrite (le_lt_trans _ M'x) // addrC -ler_subl_addl. + rewrite ltrBrDl in M'x. + rewrite (le_lt_trans _ M'x) // addrC -lerBlDl. rewrite (le_trans _ (ltW x1y)) // distrC real_ler_norm // realB //. by rewrite num_real. (* where we really use realFieldType *) - rewrite addrC -ltr_subr_addr in M'x. + rewrite addrC -ltrBrDr in M'x. rewrite -comparabler0 (@comparabler_trans _ (M - 1)%R) //. by rewrite /Order.comparable (ltW M'x). by rewrite comparabler0 realB. Qed. -Definition ereal_topologicalMixin : Topological.mixin_of (@ereal_nbhs R) := - topologyOfFilterMixin _ ereal_nbhs_singleton ereal_nbhs_nbhs. -Canonical ereal_topologicalType := TopologicalType _ ereal_topologicalMixin. - End ereal_topologicalType. Local Open Scope classical_set_scope. @@ -875,7 +870,8 @@ have : (-%E @` A) (- x) by exists x. by move/h => [y Sy] /eqP; rewrite eqe_opp => /eqP <-. Qed. -Lemma oppe_continuous (R : realFieldType) : continuous (@oppe R). +Lemma oppe_continuous (R : realFieldType) : + continuous (-%E : \bar R -> \bar R). Proof. move=> x S /= xS; apply nbhsNKe; rewrite image_preimage //. by rewrite predeqE => y; split => // _; exists (- y) => //; rewrite oppeK. @@ -934,7 +930,7 @@ case=> x Sx; rewrite ler_norml; apply/andP; split; last first. apply sup_le_ub; first by exists (contract x), x. by move=> r [y Sy] <-; case/ler_normlP : (contract_le1 y). rewrite (@le_trans _ _ (contract x)) //. - by case/ler_normlP : (contract_le1 x); rewrite ler_oppl. + by case/ler_normlP : (contract_le1 x); rewrite lerNl. apply sup_ub; last by exists x. by exists 1%R => r [y Sy <-]; case/ler_normlP : (contract_le1 y). Qed. @@ -961,12 +957,12 @@ split => [r [y Sy <-{r}]|]. apply sup_ub; last by exists y. by exists 1%R => r [z Sz <-]; case/ler_normlP : (contract_le1 z). rewrite ler_norml; apply/andP; split; last first. - rewrite ler_pdivr_mulr // mul1r (_ : 2 = 1 + 1)%R // ler_add //. + rewrite ler_pdivrMr // mul1r (_ : 2 = 1 + 1)%R // lerD //. by case/ler_normlP : (sup_contract_le1 S0). by case/ler_normlP : (contract_le1 (ereal_sup S)). -rewrite ler_pdivl_mulr // (_ : 2 = 1 + 1)%R // mulN1r opprD ler_add //. -by case/ler_normlP : (sup_contract_le1 S0); rewrite ler_oppl. -by case/ler_normlP : (contract_le1 (ereal_sup S)); rewrite ler_oppl. +rewrite ler_pdivlMr // (_ : 2 = 1 + 1)%R // mulN1r opprD lerD //. +by case/ler_normlP : (sup_contract_le1 S0); rewrite lerNl. +by case/ler_normlP : (contract_le1 (ereal_sup S)); rewrite lerNl. Qed. Lemma contract_inf S : S !=set0 -> contract (ereal_inf S) = inf (contract @` S). @@ -989,8 +985,8 @@ Lemma expand_ereal_ball_pinfty {e : {posnum R}} r : (e%:num <= 1)%R -> Proof. move=> e1 er; rewrite /ereal_ball gtr0_norm ?subr_gt0; last first. by case/ltr_normlP : (contract_lt1 r). -rewrite ltr_subl_addl addrC -ltr_subl_addl -[ltLHS]expandK ?lt_contract//. -by rewrite inE ger0_norm ?ler_subl_addl ?ler_addr // subr_ge0. +rewrite ltrBlDl addrC -ltrBlDl -[ltLHS]expandK ?lt_contract//. +by rewrite inE ger0_norm ?lerBlDl ?lerDr // subr_ge0. Qed. Lemma contract_ereal_ball_fin_le r r' (e : {posnum R}) : (r <= r')%R -> @@ -998,7 +994,7 @@ Lemma contract_ereal_ball_fin_le r r' (e : {posnum R}) : (r <= r')%R -> Proof. rewrite le_eqVlt => /predU1P[<-{r'} _|rr' re1]; first exact: ereal_ball_center. rewrite /ereal_ball ltr0_norm; last by rewrite subr_lt0 lt_contract lte_fin. -rewrite opprB ltr_subl_addl (lt_le_trans _ re1) //. +rewrite opprB ltrBlDl (lt_le_trans _ re1) //. by case/ltr_normlP : (contract_lt1 r'). Qed. @@ -1007,7 +1003,7 @@ Lemma contract_ereal_ball_fin_lt r r' (e : {posnum R}) : (r' < r)%R -> Proof. move=> r'r reN1; rewrite /ereal_ball. rewrite gtr0_norm ?subr_gt0 ?lt_contract ?lte_fin//. -rewrite ltr_subl_addl addrC -ltr_subl_addl (le_lt_trans reN1) //. +rewrite ltrBlDl addrC -ltrBlDl (le_lt_trans reN1) //. by move: (contract_lt1 r'); rewrite ltr_norml => /andP[]. Qed. @@ -1017,7 +1013,7 @@ Lemma expand_ereal_ball_fin_lt r' r (e : {posnum R}) : (r' < r)%R -> Proof. move=> r'r ? r'e'r. rewrite /ereal_ball gtr0_norm ?subr_gt0 ?lt_contract ?lte_fin//. -by rewrite ltr_subl_addl addrC -ltr_subl_addl -lt_expandLR ?inE ?ltW. +by rewrite ltrBlDl addrC -ltrBlDl -lt_expandLR ?inE ?ltW. Qed. Lemma ball_ereal_ball_fin_lt r r' (e : {posnum R}) : @@ -1030,9 +1026,9 @@ move=> e' re'r' rr' X; rewrite /ereal_ball. rewrite gtr0_norm ?subr_gt0// ?lt_contract ?lte_fin//. move: re'r'. rewrite /ball /= gtr0_norm // ?subr_gt0// /e'. -rewrite -ltr_subl_addl addrAC subrr add0r ltr_oppl opprK -lte_fin. +rewrite -ltrBlDl addrAC subrr add0r ltrNl opprK -lte_fin. rewrite fine_expand // lt_expandLR ?inE ?ltW//. -by rewrite ltr_subl_addl addrC -ltr_subl_addl. +by rewrite ltrBlDl addrC -ltrBlDl. Qed. Lemma ball_ereal_ball_fin_le r r' (e : {posnum R}) : @@ -1046,8 +1042,8 @@ move: rr'; rewrite le_eqVlt => /predU1P[->|rr']; first by rewrite subrr normr0. rewrite /ball /= ltr0_norm ?subr_lt0// opprB in r'e'r. rewrite ltr0_norm ?subr_lt0 ?lt_contract ?lte_fin//. rewrite opprB; move: r'e'r. -rewrite /e' -ltr_subl_addr opprK subrK -lte_fin fine_expand //. -by rewrite lt_expandRL ?inE ?ltW// ltr_subl_addl. +rewrite /e' -ltrBlDr opprK subrK -lte_fin fine_expand //. +by rewrite lt_expandRL ?inE ?ltW// ltrBlDl. Qed. Lemma nbhs_oo_up_e1 (A : set (\bar R)) (e : {posnum R}) : (e%:num <= 1)%R -> @@ -1057,7 +1053,7 @@ move=> e1 ooeA. exists (fine (expand (1 - e%:num)%R)); rewrite num_real; split => //. case => [r | | //]. - rewrite fine_expand; last first. - by rewrite ger0_norm ?ltr_subl_addl ?ltr_addr // subr_ge0. + by rewrite ger0_norm ?ltrBlDl ?ltrDr // subr_ge0. by move=> ?; exact/ooeA/expand_ereal_ball_pinfty. - by move=> _; exact/ooeA/ereal_ball_center. Qed. @@ -1081,13 +1077,13 @@ move=> e1 reA; have [e2{e1}|e2] := ltrP 2 e%:num. rewrite predeqE => x; split => // _; apply reA. exact/ereal_ballN/ereal_ball_ninfty_oversize. have /andP[e10 e11] : (0 < e%:num - 1 <= 1)%R. - by rewrite subr_gt0 e1 /= ler_subl_addl. + by rewrite subr_gt0 e1 /= lerBlDl. apply nbhsNKe. have : ((PosNum e10)%:num <= 1)%R by []. move/(@nbhs_oo_down_e1 (-%E @` A) (PosNum e10)); apply. move=> y ye; exists (- y); last by rewrite oppeK. apply/reA/ereal_ballN; rewrite oppeK /=. -by apply: le_ereal_ball ye => /=; rewrite ler_subl_addl ler_addr. +by apply: le_ereal_ball ye => /=; rewrite lerBlDl lerDr. Qed. Lemma nbhs_oo_down_1e (A : set (\bar R)) (e : {posnum R}) : (1 < e%:num)%R -> @@ -1097,13 +1093,13 @@ move=> e1 reA; have [e2{e1}|e2] := ltrP 2 e%:num. suff -> : A = setT by exists 0%R. by rewrite predeqE => x; split => // _; exact/reA/ereal_ball_ninfty_oversize. have /andP[e10 e11] : (0 < e%:num - 1 <= 1)%R. - by rewrite subr_gt0 e1 /= ler_subl_addl. + by rewrite subr_gt0 e1 /= lerBlDl. apply nbhsNKe. have : ((PosNum e10)%:num <= 1)%R by []. move/(@nbhs_oo_up_e1 (-%E @` A) (PosNum e10)); apply. move=> y ye; exists (- y); last by rewrite oppeK. apply/reA/ereal_ballN; rewrite /= oppeK. -by apply: le_ereal_ball ye => /=; rewrite ler_subl_addl ler_addr. +by apply: le_ereal_ball ye => /=; rewrite lerBlDl lerDr. Qed. Lemma nbhs_fin_out_above r (e : {posnum R}) (A : set (\bar R)) : @@ -1114,13 +1110,13 @@ Lemma nbhs_fin_out_above r (e : {posnum R}) (A : set (\bar R)) : Proof. move=> reA reN1 re1. have er1 : (`|contract r%:E - e%:num| < 1)%R. - rewrite ltr_norml reN1 andTb ltr_subl_addl ltr_spaddl //. + rewrite ltr_norml reN1 andTb ltrBlDl ltr_pwDl //. by move: (contract_le1 r%:E); rewrite ler_norml => /andP[]. pose e' := (r - fine (expand (contract r%:E - e%:num)))%R. have e'0 : (0 < e')%R. rewrite subr_gt0 -lte_fin -[ltRHS](contractK r%:E). rewrite fine_expand // lt_expand ?inE ?contract_le1// ?ltW//. - by rewrite ltr_subl_addl ltr_addr. + by rewrite ltrBlDl ltrDr. apply/nbhs_ballP; exists e' => // r' re'r'; apply reA. by have [?|?] := lerP r r'; [exact: contract_ereal_ball_fin_le | exact: ball_ereal_ball_fin_lt]. @@ -1134,12 +1130,12 @@ Lemma nbhs_fin_out_below r (e : {posnum R}) (A : set (\bar R)) : Proof. move=> reA reN1 re1. have ? : (`|contract r%:E + e%:num| < 1)%R. - rewrite ltr_norml re1 andbT (@lt_le_trans _ _ (contract r%:E)) // ?ler_addl //. + rewrite ltr_norml re1 andbT (@lt_le_trans _ _ (contract r%:E)) // ?lerDl //. by move: (contract_lt1 r); rewrite ltr_norml => /andP[]. pose e' : R := (fine (expand (contract r%:E + e%:num)) - r)%R. have e'0 : (0 < e')%R. rewrite /e' subr_gt0 -lte_fin -[in ltLHS](contractK r%:E). - by rewrite fine_expand // lt_expand ?inE ?contract_le1 ?ltr_addl ?ltW. + by rewrite fine_expand // lt_expand ?inE ?contract_le1 ?ltrDl ?ltW. apply/nbhs_ballP; exists e' => // r' r'e'r; apply reA. by have [?|?] := lerP r r'; [exact: ball_ereal_ball_fin_le | exact: contract_ereal_ball_fin_lt]. @@ -1159,7 +1155,7 @@ case: x => [r'| |] //. + by apply contract_ereal_ball_fin_lt => //; exact/ltW. - exact/contract_ereal_ball_pinfty. - apply/ereal_ballN/contract_ereal_ball_pinfty. - by rewrite EFinN contractN -(opprK 1%R) ltr_oppl opprD opprK. + by rewrite EFinN contractN -(opprK 1%R) ltrNl opprD opprK. Qed. Lemma nbhs_fin_inbound r (e : {posnum R}) (A : set (\bar R)) : @@ -1178,8 +1174,8 @@ have [|reN1] := boolP (contract r%:E - e%:num == -1)%R. rewrite neq_lt => /orP[re1|re1]. by apply (@nbhs_fin_out_below _ e) => //; rewrite reN1 addrAC subrr sub0r. have e1 : (1 < e%:num)%R. - move: re1; rewrite reN1 addrAC ltr_subr_addl -!mulr2n -(mulr_natl e%:num). - by rewrite -{1}(mulr1 2%:R) => ?; rewrite -(@ltr_pmul2l _ 2). + move: re1; rewrite reN1 addrAC ltrBrDl -!mulr2n -(mulr_natl e%:num). + by rewrite -{1}(mulr1 2%:R) => ?; rewrite -(@ltr_pM2l _ 2). have Aoo : setT `\ -oo `<=` A. move=> x [_]; rewrite /set1 /= => xnoo; apply reA. case: x xnoo => [r' _ | _ |//]. @@ -1199,11 +1195,11 @@ move: reN1; rewrite eq_sym neq_lt => /orP[reN1|reN1]. by apply (@nbhs_fin_out_above _ e) => //; rewrite re1. move: re1; rewrite neq_lt => /orP[re1|re1]. have ? : (`|contract r%:E - e%:num| < 1)%R. - rewrite ltr_norml reN1 andTb ltr_subl_addl. - rewrite (@lt_le_trans _ _ 1%R) // ?ler_addr//. + rewrite ltr_norml reN1 andTb ltrBlDl. + rewrite (@lt_le_trans _ _ 1%R) // ?lerDr//. by case/ltr_normlP : (contract_lt1 r). have ? : (`|contract r%:E + e%:num| < 1)%R. - rewrite ltr_norml re1 andbT -(addr0 (-1)) ler_lt_add //. + rewrite ltr_norml re1 andbT -(addr0 (-1)) ler_ltD //. by move: (contract_le1 r%:E); rewrite ler_norml => /andP[]. pose e' : R := Num.min (r - fine (expand (contract r%:E - e%:num)))%R @@ -1212,15 +1208,15 @@ move: reN1; rewrite eq_sym neq_lt => /orP[reN1|reN1]. rewrite /e' lt_minr; apply/andP; split. rewrite subr_gt0 -lte_fin -[in ltRHS](contractK r%:E). rewrite fine_expand // lt_expand// ?inE ?contract_le1 ?ltW//. - by rewrite ltr_subl_addl ltr_addr. + by rewrite ltrBlDl ltrDr. rewrite subr_gt0 -lte_fin -[in ltLHS](contractK r%:E). - by rewrite fine_expand// lt_expand ?inE ?contract_le1 ?ltr_addl ?ltW. + by rewrite fine_expand// lt_expand ?inE ?contract_le1 ?ltrDl ?ltW. apply/nbhs_ballP; exists e' => // r' re'r'; apply reA. have [|r'r] := lerP r r'. move=> rr'; apply: ball_ereal_ball_fin_le => //. by apply: le_ball re'r'; rewrite le_minl lexx orbT. move: re'r'; rewrite /ball /= lt_minr => /andP[]. - rewrite gtr0_norm ?subr_gt0 // -ltr_subl_addl addrAC subrr add0r ltr_oppl. + rewrite gtr0_norm ?subr_gt0 // -ltrBlDl addrAC subrr add0r ltrNl. rewrite opprK -lte_fin fine_expand // => r'e'r _. exact: expand_ereal_ball_fin_lt. by apply (@nbhs_fin_out_above _ e) => //; rewrite ltW. @@ -1231,24 +1227,24 @@ move: re1; rewrite le_eqVlt => /orP[re1|re1]. by move: re1; rewrite eq_sym -subr_eq => /eqP <-. have e1 : (1 < e%:num)%R. move: reN1. - rewrite re1 -addrA -opprD ltr_subl_addl ltr_subr_addl -!mulr2n. + rewrite re1 -addrA -opprD ltrBlDl ltrBrDl -!mulr2n. rewrite -(mulr_natl e%:num) -{1}(mulr1 2%:R) => ?. - by rewrite -(@ltr_pmul2l _ 2). + by rewrite -(@ltr_pM2l _ 2). have Aoo : (setT `\ +oo `<=` A). move=> x [_]; rewrite /set1 /= => xpoo; apply reA. case: x xpoo => [r' _ | // |_]. rewrite /ereal_ball. have [rr'|r'r] := lerP (contract r%:E) (contract r'%:E). - rewrite re1 opprB addrCA -[ltRHS]addr0 ltr_add2 subr_lt0. + rewrite re1 opprB addrCA -[ltRHS]addr0 ltrD2 subr_lt0. by case/ltr_normlP : (contract_lt1 r'). rewrite /ereal_ball. - rewrite re1 addrAC ltr_subl_addl ltr_add // (lt_trans _ e1) // ltr_oppl. + rewrite re1 addrAC ltrBlDl ltrD // (lt_trans _ e1) // ltrNl. by move: (contract_lt1 r'); rewrite ltr_norml => /andP[]. rewrite /ereal_ball. rewrite [contract -oo]/= opprK gtr0_norm ?subr_gt0; last first. - rewrite -ltr_subl_addl add0r ltr_oppl. + rewrite -ltrBlDl add0r ltrNl. by move: (contract_lt1 r); rewrite ltr_norml => /andP[]. - by rewrite re1 addrAC ltr_subl_addl ltr_add. + by rewrite re1 addrAC ltrBlDl ltrD. have : nbhs r%:E (setT `\ +oo) by exists 1%R => /=. case => _/posnumP[x] /=; rewrite /ball_ => h. by exists x%:num => //= y /h; exact: Aoo. @@ -1266,8 +1262,8 @@ rewrite predeq2E => x A; split. exists (diag e'); rewrite /diag. exists e' => //. rewrite /= /e' lt_minr; apply/andP; split. - by rewrite subr_gt0 lt_contract lte_fin ltr_subl_addr ltr_addl. - by rewrite subr_gt0 lt_contract lte_fin ltr_addl. + by rewrite subr_gt0 lt_contract lte_fin ltrBlDr ltrDl. + by rewrite subr_gt0 lt_contract lte_fin ltrDl. case=> [r' /= re'r'| |]/=. * rewrite /ereal_ball in re'r'. have [r'r|rr'] := lerP (contract r'%:E) (contract r%:E). @@ -1275,35 +1271,35 @@ rewrite predeq2E => x A; split. rewrite ger0_norm ?subr_ge0// in re'r'. have : (contract (r%:E - e%:num%:E) < contract r'%:E)%R. move: re'r'; rewrite /e' lt_minr => /andP[+ _]. - rewrite /e' ltr_subr_addl addrC -ltr_subr_addl => /lt_le_trans. + rewrite /e' ltrBrDl addrC -ltrBrDl => /lt_le_trans. by apply; rewrite opprB addrCA subrr addr0. rewrite -lt_expandRL ?inE ?contract_le1 // !contractK lte_fin. - rewrite ltr_subl_addr addrC -ltr_subl_addr => ->; rewrite andbT. - rewrite (@lt_le_trans _ _ 0%R)// 1?ltr_oppl 1?oppr0// subr_ge0. + rewrite ltrBlDr addrC -ltrBlDr => ->; rewrite andbT. + rewrite (@lt_le_trans _ _ 0%R)// 1?ltrNl 1?oppr0// subr_ge0. by rewrite -lee_fin -le_contract. apply: reA; rewrite /ball /= real_ltr_norml // ?num_real //. rewrite ltr0_norm ?subr_lt0// opprB in re'r'. apply/andP; split; last first. by rewrite (@lt_trans _ _ 0%R) // subr_lt0 -lte_fin -lt_contract. - rewrite ltr_oppl opprB. + rewrite ltrNl opprB. rewrite /e' in re'r'. have r're : (contract r'%:E < contract (r%:E + e%:num%:E))%R. move: re'r'; rewrite lt_minr => /andP[_]. - by rewrite ltr_subl_addr subrK. - rewrite ltr_subl_addr -lte_fin -(contractK (_ + r)%:E)%R. + by rewrite ltrBlDr subrK. + rewrite ltrBlDr -lte_fin -(contractK (_ + r)%:E)%R. by rewrite addrC -(contractK r'%:E) // lt_expand ?inE ?contract_le1. * rewrite /ereal_ball [contract +oo]/=. rewrite lt_minr => /andP[re'1 re'2]. have [cr0|cr0] := lerP 0 (contract r%:E). move: re'2; rewrite ler0_norm; last first. by rewrite subr_le0; case/ler_normlP : (contract_le1 r%:E). - rewrite opprB ltr_subr_addl addrCA subrr addr0 => h. + rewrite opprB ltrBrDl addrCA subrr addr0 => h. exfalso. move: h; apply/negP; rewrite -leNgt. by case/ler_normlP : (contract_le1 (r%:E + e%:num%:E)). move: re'2; rewrite ler0_norm; last first. by rewrite subr_le0; case/ler_normlP : (contract_le1 r%:E). - rewrite opprB ltr_subr_addl addrCA subrr addr0 => h. + rewrite opprB ltrBrDl addrCA subrr addr0 => h. exfalso. move: h; apply/negP; rewrite -leNgt. by case/ler_normlP : (contract_le1 (r%:E + e%:num%:E)). @@ -1311,11 +1307,11 @@ rewrite predeq2E => x A; split. rewrite lt_minr => /andP[re'1 _]. move: re'1. rewrite ger0_norm; last first. - rewrite addrC -ler_subl_addl add0r. + rewrite addrC -lerBlDl add0r. by move: (contract_le1 r%:E); rewrite ler_norml => /andP[]. - rewrite ltr_add2l => h. + rewrite ltrD2l => h. exfalso. - move: h; apply/negP; rewrite -leNgt -ler_oppl. + move: h; apply/negP; rewrite -leNgt -lerNl. by move: (contract_le1 (r%:E - e%:num%:E)); rewrite ler_norml => /andP[]. + exists (diag (1 - contract M%:E))%R; rewrite /diag. exists (1 - contract M%:E)%R => //=. @@ -1325,33 +1321,33 @@ rewrite predeq2E => x A; split. apply: MA; rewrite lte_fin. rewrite ger0_norm in rM1; last first. by rewrite subr_ge0 // (le_trans _ (contract_le1 r%:E)) // ler_norm. - rewrite ltr_subl_addr addrC addrCA addrC -ltr_subl_addr subrr in rM1. + rewrite ltrBlDr addrC addrCA addrC -ltrBlDr subrr in rM1. rewrite subr_gt0 in rM1. by rewrite -lte_fin -lt_contract. * by rewrite /ereal_ball /= subrr normr0 => h; exact: MA. * rewrite /ereal_ball /= opprK => h {MA}. exfalso. move: h; apply/negP. - rewrite -leNgt [in leRHS]ger0_norm // ler_subl_addr. - rewrite -/(contract M%:E) addrC -ler_subl_addr opprD addrA subrr sub0r. + rewrite -leNgt [in leRHS]ger0_norm // lerBlDr. + rewrite -/(contract M%:E) addrC -lerBlDr opprD addrA subrr sub0r. by move: (contract_le1 M%:E); rewrite ler_norml => /andP[]. + exists (diag (1 + contract M%:E)%R); rewrite /diag. exists (1 + contract M%:E)%R => //=. - rewrite -ltr_subl_addl sub0r. + rewrite -ltrBlDl sub0r. by move: (contract_lt1 M); rewrite ltr_norml => /andP[]. case=> [r| |]. * rewrite /ereal_ball => /= rM1. apply MA. rewrite lte_fin. rewrite ler0_norm in rM1; last first. - rewrite ler_subl_addl addr0 ltW //. + rewrite lerBlDl addr0 ltW //. by move: (contract_lt1 r); rewrite ltr_norml => /andP[]. - rewrite opprB opprK -ltr_subl_addl addrK in rM1. + rewrite opprB opprK -ltrBlDl addrK in rM1. by rewrite -lte_fin -lt_contract. * rewrite /ereal_ball /= -opprD normrN => h {MA}. exfalso. move: h; apply/negP. - rewrite -leNgt [in leRHS]ger0_norm// -ler_subl_addr addrAC. + rewrite -leNgt [in leRHS]ger0_norm// -lerBlDr addrAC. rewrite subrr add0r -/(contract M%:E). by rewrite (le_trans _ (ltW (contract_lt1 M))) // ler_norm. * rewrite /ereal_ball /= => _; exact: MA. @@ -1366,18 +1362,8 @@ rewrite predeq2E => x A; split. by rewrite -ltNge => /nbhs_oo_down_1e; apply => ? ?; exact/sEA/reA. Qed. -Definition ereal_pseudoMetricType_mixin := - PseudoMetric.Mixin (@ereal_ball_center R) (@ereal_ball_sym R) - (@ereal_ball_triangle R) erefl. - -Definition ereal_uniformType_mixin : @Uniform.mixin_of (\bar R) nbhs := - uniformityOfBallMixin ereal_nbhsE ereal_pseudoMetricType_mixin. - -Canonical ereal_uniformType := - UniformType (extended R) ereal_uniformType_mixin. - -Canonical ereal_pseudoMetricType := - PseudoMetricType (extended R) ereal_pseudoMetricType_mixin. +HB.instance Definition _ := Nbhs_isPseudoMetric.Build R (\bar R) + ereal_nbhsE ereal_ball_center ereal_ball_sym ereal_ball_triangle erefl. End ereal_PseudoMetric. @@ -1413,18 +1399,18 @@ Definition ereal_loc_seq (R : numDomainType) (x : \bar R) (n : nat) := end. Lemma cvg_ereal_loc_seq (R : realType) (x : \bar R) : - ereal_loc_seq x --> ereal_dnbhs x. + ereal_loc_seq x @ \oo--> ereal_dnbhs x. Proof. move=> P; rewrite /ereal_loc_seq. case: x => /= [x [_/posnumP[d] dP] |[d [dreal dP]] |[d [dreal dP]]]; last 2 first. have /ZnatP [N Nfloor] : floor (Num.max d 0%R) \is a Znat. by rewrite Znat_def floor_ge0 le_maxr lexx orbC. - exists N.+1 => // n ltNn; apply: dP. + exists N.+1 => // n ltNn; apply: dP; rewrite lte_fin. have /le_lt_trans : (d <= Num.max d 0)%R by rewrite le_maxr lexx. by apply; rewrite (lt_le_trans (lt_succ_floor _))// Nfloor natr1 ler_nat. have /ZnatP [N Nfloor] : floor (Num.max (- d)%R 0%R) \is a Znat. by rewrite Znat_def floor_ge0 le_maxr lexx orbC. - exists N.+1 => // n ltNn; apply: dP; rewrite lte_fin ltr_oppl. + exists N.+1 => // n ltNn; apply: dP; rewrite lte_fin ltrNl. have /le_lt_trans : (- d <= Num.max (- d) 0)%R by rewrite le_maxr lexx. by apply; rewrite (lt_le_trans (lt_succ_floor _))// Nfloor natr1 ler_nat. have /ZnatP [N Nfloor] : floor (d%:num^-1) \is a Znat. @@ -1432,6 +1418,6 @@ have /ZnatP [N Nfloor] : floor (d%:num^-1) \is a Znat. exists N => // n leNn; apply: dP; last first. by rewrite eq_sym addrC -subr_eq subrr eq_sym; exact/invr_neq0/lt0r_neq0. rewrite /= opprD addrA subrr distrC subr0 gtr0_norm; last by rewrite invr_gt0. -rewrite -[ltLHS]mulr1 ltr_pdivr_mull // -ltr_pdivr_mulr // div1r. -by rewrite (lt_le_trans (lt_succ_floor _))// Nfloor ler_add// ler_nat. +rewrite -[ltLHS]mulr1 ltr_pdivrMl // -ltr_pdivrMr // div1r. +by rewrite (lt_le_trans (lt_succ_floor _))// Nfloor lerD// ler_nat. Qed. diff --git a/theories/esum.v b/theories/esum.v index 69869857b..d963a52fd 100644 --- a/theories/esum.v +++ b/theories/esum.v @@ -519,7 +519,7 @@ Qed. Lemma summable_cvg (P : pred nat) (f : (\bar R)^nat) : (forall i, P i -> 0 <= f i)%E -> summable P f -> - cvg (fun n => \sum_(0 <= k < n | P k) fine (f k))%R. + cvg ((fun n => \sum_(0 <= k < n | P k) fine (f k))%R @ \oo). Proof. move=> f0 Pf; apply: nondecreasing_is_cvgn. by apply: nondecreasing_series => n Pn; exact/fine_ge0/f0. @@ -537,11 +537,11 @@ Qed. Lemma summable_nneseries_lim (P : pred nat) (f : (\bar R)^nat) : (forall i, P i -> 0 <= f i)%E -> summable P f -> \sum_(i (\sum_(0 <= k < n | P k) fine (f k))%R))%:E. + (lim ((fun n => (\sum_(0 <= k < n | P k) fine (f k))%R) @ \oo))%:E. Proof. move=> f0 Pf; pose A_ n := (\sum_(0 <= k < n | P k) fine (f k))%R. -transitivity (lim (EFin \o A_)). - congr (lim _); apply/funext => /= n; rewrite /A_ /= -sumEFin. +transitivity (lim (EFin \o A_ @ \oo)). + apply/congr_lim/funext => /= n; rewrite /A_ /= -sumEFin. apply eq_bigr => i Pi/=; rewrite fineK//. by rewrite fin_num_abs (@summable_pinfty _ _ P). by rewrite EFin_lim//; apply: summable_cvg. @@ -555,17 +555,17 @@ move=> Pf. pose A_ n := (\sum_(0 <= k < n | P k) fine (f^\+ k))%R. pose B_ n := (\sum_(0 <= k < n | P k) fine (f^\- k))%R. pose C_ n := fine (\sum_(0 <= k < n | P k) f k). -pose A := lim A_. -pose B := lim B_. -suff: ((fun n => C_ n - (A - B)) --> (0 : R^o))%R. +pose A := lim (A_ @ \oo). +pose B := lim (B_ @ \oo). +suff: ((fun n => C_ n - (A - B)) @ \oo --> (0 : R^o))%R. move=> CAB. rewrite [X in X - _]summable_nneseries_lim//; last exact/summable_funepos. rewrite [X in _ - X]summable_nneseries_lim//; last exact/summable_funeneg. rewrite -EFinB; apply/cvg_lim => //; apply/fine_cvgP; split; last first. - apply: (@cvg_sub0 _ _ _ _ _ _ (cst (A - B)%R) _ CAB); exact: cvg_cst. + by apply: (@cvg_sub0 _ _ _ _ _ _ (cst (A - B)%R) _ CAB) => //; exact: cvg_cst. apply: nearW => n; rewrite fin_num_abs; apply: le_lt_trans Pf => /=. - by rewrite -nneseries_esum ?(le_trans (lee_abs_sum _ _ _)) ?nneseries_lim_ge. -have : ((fun x => A_ x - B_ x) --> A - B)%R. + by rewrite -nneseries_esum// (le_trans (lee_abs_sum _ _ _))// nneseries_lim_ge. +have : ((fun x => A_ x - B_ x) @ \oo --> A - B)%R. apply: cvgD. - by apply: summable_cvg => //; exact/summable_funepos. - by apply: cvgN; apply: summable_cvg => //; exact/summable_funeneg. diff --git a/theories/exp.v b/theories/exp.v index 08e524ff4..a92627b56 100644 --- a/theories/exp.v +++ b/theories/exp.v @@ -47,8 +47,9 @@ Reserved Notation "x '`^?' ( r +? s )" (* PR to mathcomp in progress *) Lemma normr_nneg (R : numDomainType) (x : R) : `|x| \is Num.nneg. -Proof. by rewrite qualifE. Qed. -#[global] Hint Resolve normr_nneg : core. +Proof. by rewrite qualifE/=. Qed. +#[global] Hint Extern 0 (is_true (@Num.norm _ _ _ \is Num.nneg)) => + solve [apply: normr_nneg] : core. (* /PR to mathcomp in progress *) Section PseriesDiff. @@ -58,7 +59,8 @@ Variable R : realType. Definition pseries f (x : R) := [series f i * x ^+ i]_i. Fact is_cvg_pseries_inside_norm f (x z : R) : - cvg (pseries f x) -> `|z| < `|x| -> cvg (pseries (fun i => `|f i|) z). + cvgn (pseries f x) -> `|z| < `|x| -> + cvgn ((pseries (fun i => `|f i|) z)). Proof. move=> Cx zLx; have [K [Kreal Kf]] := cvg_series_bounded Cx. have Kzxn n : 0 <= `|K + 1| * `|z ^+ n| / `|x ^+ n| by rewrite !mulr_ge0. @@ -67,17 +69,17 @@ apply: series_le_cvg Kzxn _ _ => [//=| /= n|]. rewrite (_ : `|_ * _| = `|f n * x ^+ n| * `|z ^+ n| / `|x ^+ n|); last first. rewrite !normrM normr_id mulrAC mulfK // normr_eq0 expf_eq0 andbC. by case: ltrgt0P zLx; rewrite //= normr_lt0. - do! (apply: ler_pmul || apply: mulr_ge0 || rewrite invr_ge0) => //. - by apply Kf => //; rewrite (lt_le_trans _ (ler_norm _))// ltr_addl. + do! (apply: ler_pM || apply: mulr_ge0 || rewrite invr_ge0) => //. + by apply Kf => //; rewrite (lt_le_trans _ (ler_norm _))// ltrDl. have F : `|z / x| < 1. - by rewrite normrM normfV ltr_pdivr_mulr ?mul1r // (le_lt_trans _ zLx). + by rewrite normrM normfV ltr_pdivrMr ?mul1r // (le_lt_trans _ zLx). rewrite (_ : (fun _ => _) = geometric `|K + 1| `|z / x|); last first. by apply/funext => i /=; rewrite normrM exprMn mulrA normfV !normrX exprVn. by apply: is_cvg_geometric_series; rewrite normr_id. Qed. Fact is_cvg_pseries_inside f (x z : R) : - cvg (pseries f x) -> `|z| < `|x| -> cvg (pseries f z). + cvgn (pseries f x) -> `|z| < `|x| -> cvgn (pseries f z). Proof. move=> Cx zLx. apply: normed_cvg; rewrite /normed_series_of /=. @@ -109,18 +111,20 @@ Qed. Lemma pseries_diffs_equiv f x : let s i := i%:R * f i * x ^+ i.-1 in - cvg (pseries (pseries_diffs f) x) -> series s --> - lim (pseries (pseries_diffs f) x). + cvgn (pseries (pseries_diffs f) x) -> + series s @ \oo --> limn (pseries (pseries_diffs f) x). Proof. -move=> s Cx; rewrite -[lim _]subr0 /pseries [X in X --> _]/series /=. -rewrite [X in X --> _](_ : _ = (fun n => \sum_(0 <= i < n) +move=> s Cx; rewrite -[lim _]subr0. +rewrite /pseries/= [X in X @ \oo --> _]/series /=. +rewrite [X in X @ \oo --> _](_ : _ = (fun n => \sum_(0 <= i < n) pseries_diffs f i * x ^+ i - n%:R * f n * x ^+ n.-1)); last first. by rewrite funeqE => n; rewrite pseries_diffs_sumE addrK. by apply: cvgB => //; rewrite -cvg_shiftS; exact: cvg_series_cvg_0. Qed. Lemma is_cvg_pseries_diffs_equiv f x : - cvg (pseries (pseries_diffs f) x) -> cvg [series i%:R * f i * x ^+ i.-1]_i. + cvgn (pseries (pseries_diffs f) x) -> + cvgn ([series i%:R * f i * x ^+ i.-1]_i). Proof. by by move=> Cx; have := pseries_diffs_equiv Cx; move/(cvg_lim _) => -> //. Qed. @@ -161,7 +165,7 @@ Let pseries_diffs_P3 (z h : R) n K : Proof. move=> hNZ zLK zhLk. rewrite pseries_diffs_P2// normrM mulrC. -rewrite ler_pmul2r ?normr_gt0//. +rewrite ler_pM2r ?normr_gt0//. rewrite (le_trans (ler_norm_sum _ _ _))//. rewrite -mulrA mulrC -mulrA mulr_natl -[X in _ *+ X]subn0 -sumr_const_nat. apply ler_sum_nat => i /=. @@ -172,81 +176,82 @@ rewrite -[(n - i)%nat]prednK ?subn_gt0// predn_sub -/d. rewrite -(subnK (_ : i <= n.-1)%nat) -/d; last first. by rewrite -ltnS prednK// (leq_ltn_trans _ ni). rewrite addnC exprD mulrAC -mulrA. -apply: ler_pmul => //. - by rewrite normrX ler_expn2r// qualifE (le_trans _ zLK). +apply: ler_pM => //. + by rewrite normrX lerXn2r// qualifE/= (le_trans _ zLK). apply: le_trans (_ : d.+1%:R * K ^+ d <= _); last first. - rewrite ler_wpmul2r //; first by rewrite exprn_ge0 // (le_trans _ zLK). + rewrite ler_wpM2r //; first by rewrite exprn_ge0 // (le_trans _ zLK). 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. -by rewrite ler_pmul// normrX ler_expn2r// qualifE (le_trans _ zLK). +by rewrite ler_pM// normrX lerXn2r// qualifE/= (le_trans _ zLK). Qed. Lemma pseries_snd_diffs (c : R^nat) K x : - cvg (pseries c K) -> - cvg (pseries (pseries_diffs c) K) -> - cvg (pseries (pseries_diffs (pseries_diffs c)) K) -> + cvgn (pseries c K) -> + cvgn (pseries (pseries_diffs c) K) -> + cvgn (pseries (pseries_diffs (pseries_diffs c)) K) -> `|x| < `|K| -> - is_derive x 1 - (fun x => lim (pseries c x)) - (lim (pseries (pseries_diffs c) x)). + is_derive x (1 : R) + (fun x => limn (pseries c x)) + (limn (pseries (pseries_diffs c) x)). Proof. move=> Ck CdK CddK xLK; rewrite /pseries. set s := (fun n : nat => _); set (f := fun x0 => _). -suff hfxs : h^-1 *: (f (h + x) - f x) @[h --> 0^'] --> lim (series s). - have F : f^`() x = lim (series s) by apply: cvg_lim hfxs. +suff hfxs : h^-1 *: (f (h + x) - f x) @[h --> 0^'] --> limn (series s). + have F : f^`() x = limn (series s) by apply: cvg_lim hfxs. have Df : derivable f x 1. - move: hfxs; rewrite /derivable [X in X @ _](_ : _ = + move: hfxs; rewrite /derivable [X in X @ 0^'](_ : _ = (fun h => h^-1 *: (f (h%:A + x) - f x))) /=; last first. by apply/funext => i //=; rewrite [i%:A]mulr1. by move=> /(cvg_lim _) -> //. by constructor; [exact: Df|rewrite -derive1E]. pose sx := fun n : nat => c n * x ^+ n. -have Csx : cvg (pseries c x) by apply: is_cvg_pseries_inside Ck _. +have Csx : cvgn (pseries c x) by apply: is_cvg_pseries_inside Ck _. pose shx := fun h (n : nat) => c n * (h + x) ^+ n. -suff Cc : lim (h^-1 *: (series (shx h - sx))) @[h --> 0^'] --> lim (series s). +suff Cc : limn (h^-1 *: (series (shx h - sx))) @[h --> 0^'] --> limn (series s). apply: cvg_sub0 Cc. apply/cvgrPdist_lt => eps eps_gt0 /=. near=> h; rewrite sub0r normrN /=. rewrite (le_lt_trans _ eps_gt0)//. rewrite normr_le0 subr_eq0 -/sx -/(shx _); apply/eqP. - have Cshx' : cvg (series (shx h)). + have Cshx' : cvgn (series (shx h)). apply: is_cvg_pseries_inside Ck _. - rewrite (le_lt_trans (ler_norm_add _ _))// -(subrK `|x| `|K|) ltr_add2r. + rewrite (le_lt_trans (ler_normD _ _))// -(subrK `|x| `|K|) ltrD2r. near: h. apply/nbhs_ballP => /=; exists ((`|K| - `|x|) /2%:R) => /=. by rewrite divr_gt0 // subr_gt0. move=> t; rewrite /ball /= sub0r normrN => H tNZ. - rewrite (lt_le_trans H)// ler_pdivr_mulr // mulr2n mulrDr mulr1. - by rewrite ler_paddr // subr_ge0 ltW. - by rewrite limZr; [rewrite lim_seriesB|exact: is_cvg_seriesB]. + rewrite (lt_le_trans H)// ler_pdivrMr // mulr2n mulrDr mulr1. + by rewrite ler_wpDr // subr_ge0 ltW. + rewrite limZr; last exact/is_cvg_seriesB/Csx. + by rewrite lim_seriesB; last exact: Csx. apply: cvg_zero => /=. -suff Cc : lim +suff Cc : limn (series (fun n => c n * (((h + x) ^+ n - x ^+ n) / h - n%:R * x ^+ n.-1))) @[h --> 0^'] --> (0 : R). apply: cvg_sub0 Cc. apply/cvgrPdist_lt => eps eps_gt0 /=. near=> h; rewrite sub0r normrN /=. rewrite (le_lt_trans _ eps_gt0)// normr_le0 subr_eq0; apply/eqP. - have Cs : cvg (series s) by apply: is_cvg_pseries_inside CdK _. + have Cs : cvgn (series s) by apply: is_cvg_pseries_inside CdK _. have Cs1 := is_cvg_pseries_diffs_equiv Cs. have Fs1 := pseries_diffs_equiv Cs. set s1 := (fun i => _) in Cs1. - have Cshx : cvg (series (shx h)). + have Cshx : cvgn (series (shx h)). apply: is_cvg_pseries_inside Ck _. - rewrite (le_lt_trans (ler_norm_add _ _))// -(subrK `|x| `|K|) ltr_add2r. + rewrite (le_lt_trans (ler_normD _ _))// -(subrK `|x| `|K|) ltrD2r. near: h. apply/nbhs_ballP => /=; exists ((`|K| - `|x|) / 2%:R) => /=. by rewrite divr_gt0 // subr_gt0. move=> t; rewrite /ball /= sub0r normrN => H tNZ. - rewrite (lt_le_trans H)// ler_pdivr_mulr // mulr2n mulrDr mulr1. - by rewrite ler_paddr // subr_ge0 ltW. + rewrite (lt_le_trans H)// ler_pdivrMr // mulr2n mulrDr mulr1. + by rewrite ler_wpDr // subr_ge0 ltW. have C1 := is_cvg_seriesB Cshx Csx. have Ckf := @is_cvg_seriesZ _ _ h^-1 C1. have Cu : (series (h^-1 *: (shx h - sx)) - series s1) x0 @[x0 --> \oo] --> - lim (series (h^-1 *: (shx h - sx))) - lim (series s). - exact: cvgB. + limn (series (h^-1 *: (shx h - sx))) - limn (series s). + exact: cvgB Ckf Fs1. set w := (fun n : nat => _ in RHS). have -> : w = h^-1 *: (shx h - sx) - s1. apply: funext => i; rewrite !fctE. @@ -260,16 +265,16 @@ suff Cc : lim have -> : h^-1 *: series (shx h - sx) = series (h^-1 *: (shx h - sx)). by apply/funext => i; rewrite /series /= -scaler_sumr. exact/esym/cvg_lim. -pose r := (`|x| + `|K|) / 2%:R. -have xLr : `|x| < r by rewrite ltr_pdivl_mulr // mulr2n mulrDr mulr1 ltr_add2l. -have rLx : r < `|K| by rewrite ltr_pdivr_mulr // mulr2n mulrDr mulr1 ltr_add2r. +pose r := (`|x| + `|K|) / 2. +have xLr : `|x| < r by rewrite ltr_pdivlMr // mulrDr mulr1 ltrD2l. +have rLx : r < `|K| by rewrite ltr_pdivrMr // mulrDr mulr1 ltrD2r. have r_gt0 : 0 < r by apply: le_lt_trans xLr. have rNZ : r != 0by case: ltrgt0P r_gt0. apply: (@lim_cvg_to_0_linear _ (fun n => `|c n| * n%:R * (n.-1)%:R * r ^+ n.-2) (fun h n => c n * (((h + x) ^+ n - x ^+ n) / h - n%:R * x ^+ n.-1)) (r - `|x|)); first by rewrite subr_gt0. -- have : cvg [series `|pseries_diffs (pseries_diffs c) n| * r ^+ n]_n. +- have : cvgn ([series `|pseries_diffs (pseries_diffs c) n| * r ^+ n]_n). apply: is_cvg_pseries_inside_norm CddK _. by rewrite ger0_norm // ltW // (le_lt_trans _ xLr). have -> : (fun n => `|pseries_diffs (pseries_diffs c) n| * r ^+ n) = @@ -295,10 +300,11 @@ apply: (@lim_cvg_to_0_linear _ rewrite mul1r !mulrA; congr (_ * _). by rewrite mulrC mulrA. - move=> h /andP[h_gt0 hLrBx] n. - rewrite normrM -!mulrA ler_wpmul2l //. + rewrite normrM -!mulrA ler_wpM2l //. rewrite (le_trans (pseries_diffs_P3 _ _ (ltW xLr) _))// ?mulrA -?normr_gt0//. - by rewrite (le_trans (ler_norm_add _ _))// -(subrK `|x| r) ler_add2r ltW. -Unshelve. all: by end_near. Qed. + by rewrite (le_trans (ler_normD _ _))// -(subrK `|x| r) lerD2r ltW. +Unshelve. all: by end_near. +Qed. End PseriesDiff. @@ -321,7 +327,7 @@ 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 = lim (series (f x)). +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. exact: is_cvg_series_exp_coeff. @@ -337,7 +343,7 @@ Import GRing.Theory. Local Open Scope ring_scope. Lemma expRE : - expR = fun x => lim (pseries (fun n => (fun n => (n`!%:R)^-1) n) x). + expR = fun x => limn (pseries (fun n => (fun n => (n`!%:R)^-1) n) x). Proof. by apply/funext => x; rewrite /pseries -exp_coeffE. Qed. Global Instance is_derive_expR x : is_derive x 1 expR (expR x). @@ -381,7 +387,7 @@ Proof. by rewrite -[X in _ X * _ = _]addr0 expRxDyMexpx expR0. Qed. Lemma pexpR_gt1 x : 0 < x -> 1 < expR x. Proof. -by move=> x_gt0; rewrite (lt_le_trans _ (expR_ge1Dx (ltW x_gt0)))// ltr_addl. +by move=> x_gt0; rewrite (lt_le_trans _ (expR_ge1Dx (ltW x_gt0)))// ltrDl. Qed. Lemma expR_gt0 x : 0 < expR x. @@ -422,14 +428,14 @@ case: ltrgt0P => [x_gt0| xN|->]; last by rewrite expR0. - by rewrite (pexpR_gt1 x_gt0). - apply/idP/negP. rewrite -[x]opprK expRN -leNgt invf_cp1 ?expR_gt0 //. - by rewrite ltW // pexpR_gt1 // lter_oppE. + by rewrite ltW // pexpR_gt1 // lterNE. Qed. Lemma expR_lt1 x : (expR x < 1) = (x < 0). Proof. case: ltrgt0P => [x_gt0|xN|->]; last by rewrite expR0. - by apply/idP/negP; rewrite -leNgt ltW // expR_gt1. -- by rewrite -[x]opprK expRN invf_cp1 ?expR_gt0 // expR_gt1 lter_oppE. +- by rewrite -[x]opprK expRN invf_cp1 ?expR_gt0 // expR_gt1 lterNE. Qed. Lemma expRB x y : expR (x - y) = expR x / expR y. @@ -438,7 +444,7 @@ Proof. by rewrite expRD expRN. Qed. Lemma ltr_expR : {mono (@expR R) : x y / x < y}. Proof. move=> x y. -by rewrite -[in LHS](subrK x y) expRD ltr_pmull ?expR_gt0 // expR_gt1 subr_gt0. +by rewrite -[in LHS](subrK x y) expRD ltr_pMl ?expR_gt0 // expR_gt1 subr_gt0. Qed. Lemma ler_expR : {mono (@expR R) : x y / x <= y}. @@ -463,10 +469,10 @@ have [x1 x1Ix| |x1 _ /eqP] := @IVT _ (fun y => expR y - x) _ _ 0 x_ge0. - apply: continuousB => // y1; last exact: cst_continuous. by apply/continuous_subspaceT=> ?; exact: continuous_expR. - rewrite expR0; have [_| |] := ltrgtP (1- x) (expR x - x). - + by rewrite subr_le0 x_ge1 subr_ge0 (le_trans _ (expR_ge1Dx _)) ?ler_addr. - + by rewrite ltr_add2r expR_lt1 ltNge x_ge0. + + by rewrite subr_le0 x_ge1 subr_ge0 (le_trans _ (expR_ge1Dx _)) ?lerDr. + + by rewrite ltrD2r expR_lt1 ltNge x_ge0. + rewrite subr_le0 x_ge1 => -> /=; rewrite subr_ge0. - by rewrite (le_trans _ (expR_ge1Dx x_ge0)) ?ler_addr. + by rewrite (le_trans _ (expR_ge1Dx x_ge0)) ?lerDr. - rewrite subr_eq0 => /eqP x1_x; exists x1; split => //. + by rewrite -ler_expR expR0 x1_x. + by rewrite -x1_x expR_ge1Dx // -ler_expR x1_x expR0. @@ -599,7 +605,7 @@ by apply/eqP/idP=> [<-|x0]; [exact: expR_gt0|rewrite lnK// in_itv/= x0]. Qed. Lemma ln1 : ln 1 = 0. -Proof. by apply/expR_inj; rewrite lnK// ?expR0// qualifE. Qed. +Proof. by apply/expR_inj; rewrite lnK// ?expR0// qualifE/=. Qed. Lemma lnM : {in Num.pos &, {morph ln : x y / x * y >-> x + y}}. Proof. @@ -613,7 +619,7 @@ Proof. by move=> x y /lnK {2}<- /lnK {2}<- ->. Qed. Lemma lnV : {in Num.pos, {morph ln : x / x ^-1 >-> - x}}. Proof. move=> x x0; apply: expR_inj; rewrite lnK// ?expRN ?lnK//. -by move: x0; rewrite !qualifE invr_gt0. +by move: x0; rewrite !qualifE/= invr_gt0. Qed. Lemma ln_div : {in Num.pos &, {morph ln : x y / x / y >-> x - y}}. @@ -631,30 +637,30 @@ Proof. by move=> x y x_gt0 y_gt0; rewrite -ler_expR !lnK. Qed. Lemma lnXn n x : 0 < x -> ln (x ^+ n) = ln x *+ n. Proof. move=> x_gt0; elim: n => [|n ih] /=; first by rewrite expr0 ln1 mulr0n. -by rewrite !exprS lnM ?qualifE// ?exprn_gt0// mulrS ih. +by rewrite !exprS lnM ?qualifE//= ?exprn_gt0// mulrS ih. Qed. Lemma le_ln1Dx x : 0 <= x -> ln (1 + x) <= x. Proof. move=> x_ge0; rewrite -ler_expR lnK ?expR_ge1Dx //. -by apply: lt_le_trans (_ : 0 < 1) _; rewrite // ler_addl. +by apply: lt_le_trans (_ : 0 < 1) _; rewrite // lerDl. Qed. Lemma ln_sublinear x : 0 < x -> ln x < x. Proof. move=> x_gt0; apply: lt_le_trans (_ : ln (1 + x) <= _). - by rewrite -ltr_expR !lnK ?qualifE ?addr_gt0 // ltr_addr. -by rewrite -ler_expR lnK ?qualifE ?addr_gt0// expR_ge1Dx // ltW. + by rewrite -ltr_expR !lnK ?qualifE/= ?addr_gt0 // ltrDr. +by rewrite -ler_expR lnK ?qualifE/= ?addr_gt0// expR_ge1Dx // ltW. Qed. Lemma ln_ge0 x : 1 <= x -> 0 <= ln x. Proof. -by move=> x_ge1; rewrite -ler_expR expR0 lnK// qualifE (lt_le_trans _ x_ge1). +by move=> x_ge1; rewrite -ler_expR expR0 lnK// qualifE/= (lt_le_trans _ x_ge1). Qed. Lemma ln_gt0 x : 1 < x -> 0 < ln x. Proof. -by move=> x_gt1; rewrite -ltr_expR expR0 lnK // qualifE (lt_trans _ x_gt1). +by move=> x_gt1; rewrite -ltr_expR expR0 lnK // qualifE/= (lt_trans _ x_gt1). Qed. Lemma ln_le0 (x : R) : x <= 1 -> ln x <= 0. @@ -741,13 +747,13 @@ Proof. by move=> /eqP; rewrite powR_eq0 => /andP[/eqP]. Qed. Lemma ger_powR a : 0 < a <= 1 -> {homo powR a : x y /~ y <= x}. Proof. move=> /andP[a0 a1] x y xy. -by rewrite /powR gt_eqF// ler_expR ler_wnmul2r// ln_le0. +by rewrite /powR gt_eqF// ler_expR ler_wnM2r// ln_le0. Qed. Lemma ler_powR a : 1 <= a -> {homo powR a : x y / x <= y}. Proof. move=> a1 x y xy. -by rewrite /powR gt_eqF ?(lt_le_trans _ a1)// ler_expR ler_wpmul2r ?ln_ge0. +by rewrite /powR gt_eqF ?(lt_le_trans _ a1)// ler_expR ler_wpM2r ?ln_ge0. Qed. Lemma powR_injective r : 0 < r -> {in Num.nneg &, injective (powR ^~ r)}. @@ -790,7 +796,7 @@ move=> a0 x y; rewrite 2!nnegrE !le_eqVlt => /predU1P[<-|x0]. by rewrite !powR0 ?(gt_eqF a0)// powR_gt0 ?orbT. move=> /predU1P[<-|y0]; first by rewrite gt_eqF//= ltNge (ltW x0). move=> /predU1P[->//|xy]; first by rewrite eqxx. -by apply/orP; right; rewrite /powR !gt_eqF// ltr_expR ltr_pmul2l// ltr_ln. +by apply/orP; right; rewrite /powR !gt_eqF// ltr_expR ltr_pM2l// ltr_ln. Qed. Lemma gt0_ltr_powR r : 0 < r -> @@ -813,14 +819,14 @@ Lemma ge1r_powRZ x y r : 0 < x <= 1 -> 0 <= y -> 1 <= r -> (x * y) `^ r <= x * (y `^ r). Proof. move=> /andP[x0 x1] y0 r1. -by rewrite (powRM _ (ltW _))// ler_wpmul2r ?powR_ge0// ge1r_powR// x0. +by rewrite (powRM _ (ltW _))// ler_wpM2r ?powR_ge0// ge1r_powR// x0. Qed. Lemma le1r_powRZ x y r : x >= 1 -> 0 <= y -> 1 <= r -> (x * y) `^ r >= x * (y `^ r). Proof. move=> x1 y0 r1. -by rewrite (powRM _ (le_trans _ x1))// ler_wpmul2r ?powR_ge0// le1r_powR// x0. +by rewrite (powRM _ (le_trans _ x1))// ler_wpM2r ?powR_ge0// le1r_powR// x0. Qed. Lemma powRrM x y z : x `^ (y * z) = (x `^ y) `^ z. @@ -915,7 +921,7 @@ rewrite le_eqVlt => /predU1P[<- b0 p0 q0 _|a0]. rewrite le_eqVlt => /predU1P[<-|b0] p0 q0 pq. by rewrite mulr0 powR0 ?gt_eqF// mul0r addr0 divr_ge0 ?powR_ge0 ?ltW. have q01 : (q^-1 \in `[0, 1])%R. - by rewrite in_itv/= invr_ge0 (ltW q0)/= -pq ler_paddl// invr_ge0 ltW. + by rewrite in_itv/= invr_ge0 (ltW q0)/= -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 _ (@Itv.mk _ `[0, 1] _ q01)%R _ _ ap0 bq0. @@ -1124,12 +1130,12 @@ Arguments riemannR a n /. Lemma riemannR_gt0 a i : 0 <= a -> 0 < riemannR a i. Proof. by move=> ?; rewrite /riemannR invr_gt0 powR_gt0. Qed. -Lemma dvg_riemannR a : 0 <= a <= 1 -> ~ cvg (series (riemannR a)). +Lemma dvg_riemannR a : 0 <= a <= 1 -> ~ cvgn (series (riemannR a)). Proof. move=> /andP[a0 a1]. have : forall n, harmonic n <= riemannR a n. move=> [/=|n]; first by rewrite powR1 invr1. - rewrite -[leRHS]div1r ler_pdivl_mulr ?powR_gt0// mulrC ler_pdivr_mulr//. + rewrite -[leRHS]div1r ler_pdivlMr ?powR_gt0// mulrC ler_pdivrMr//. by rewrite mul1r -[leRHS]powRr1// (ler_powR)// ler1n. move/(series_le_cvg harmonic_ge0 (fun i => ltW (riemannR_gt0 i a0))). by move/contra_not; apply; exact: dvg_harmonic. diff --git a/theories/forms.v b/theories/forms.v index da347889f..fb8f7956f 100644 --- a/theories/forms.v +++ b/theories/forms.v @@ -1,3 +1,4 @@ +From HB Require Import structures. From mathcomp Require Import all_ssreflect ssralg fingroup zmodp poly ssrnum. From mathcomp @@ -30,7 +31,7 @@ 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"). -Notation "u '``_' i" := (u (GRing.zero (Zp_zmodType O)) i) : ring_scope. +Notation "u '``_' i" := (u (GRing.zero [the zmodType of 'I_1]) i) : ring_scope. Notation "''e_' i" := (delta_mx 0 i) (format "''e_' i", at level 3) : ring_scope. @@ -46,112 +47,69 @@ Lemma eq_map_mx_id (R : ringType) m n (M : 'M[R]_(m,n)) (f : R -> R) : f =1 id -> M ^ f = M. Proof. by move=> /eq_map_mx->; rewrite map_mx_id. Qed. -Module Bilinear. - -Section ClassDef. - -Variables (R : ringType) (U U' : lmodType R) (V : zmodType) (s s' : R -> V -> V). -Implicit Type phUU'V : phant (U -> U' -> V). - -Local Coercion GRing.Scale.op : GRing.Scale.law >-> Funclass. -Definition axiom (f : U -> U' -> V) (s_law : GRing.Scale.law s) (eqs : s = s_law) - (s'_law : GRing.Scale.law s') (eqs' : s' = s'_law) := - ((forall u', GRing.Linear.axiom (f^~ u') eqs) - * (forall u, GRing.Linear.axiom (f u) eqs'))%type. - -Record class_of (f : U -> U' -> V) : Prop := Class { - basel : forall u', GRing.Linear.class_of s (f^~ u'); - baser : forall u, GRing.Linear.class_of s' (f u) +HB.mixin Record isBilinear (R : ringType) (U U' : lmodType R) (V : zmodType) + (s : R -> V -> V) (s' : R -> V -> V) (f : U -> U' -> V) := { + additivel_subproof : forall u', additive (f^~ u'); + additiver_subproof : forall u, additive (f u); + linearl_subproof : forall u', scalable_for s (f^~ u'); + linearr_subproof : forall u, scalable_for s' (f u); }. -Lemma class_of_axiom f s_law s'_law Ds Ds' : - @axiom f s_law Ds s'_law Ds' -> class_of f. -Proof. -by pose coa := GRing.Linear.class_of_axiom; move=> [/(_ _) /coa ? /(_ _) /coa]. -Qed. +HB.structure Definition Bilinear (R : ringType) (U U' : lmodType R) (V : zmodType) + (s : R -> V -> V) (s' : R -> V -> V) := + {f of isBilinear R U U' V s s' f}. -Structure map phUU'V := Pack {apply; _ : class_of apply}. -Local Coercion apply : map >-> Funclass. +Definition bilinear_for (R : ringType) (U U' : lmodType R) (V : zmodType) + (s : GRing.Scale.law R V) (s' : GRing.Scale.law R V) (f : U -> U' -> V) := + ((forall u', GRing.linear_for (s : R -> V -> V) (f^~ u')) + * (forall u, GRing.linear_for s' (f u)))%type. -Definition class (phUU'V : _) (cF : map phUU'V) := - let: Pack _ c as cF' := cF return class_of cF' in c. +HB.factory Record bilinear_isBilinear (R : ringType) (U U' : lmodType R) (V : zmodType) + (s : GRing.Scale.law R V) (s' : GRing.Scale.law R V) (f : U -> U' -> V) := { + bilinear_subproof : bilinear_for s s' f; +}. -Canonical additiver phU'V phUU'V (u : U) cF := GRing.Additive.Pack phU'V - (baser (@class phUU'V cF) u). -Canonical linearr phU'V phUU'V (u : U) cF := GRing.Linear.Pack phU'V - (baser (@class phUU'V cF) u). +HB.builders Context R U U' V s s' f of bilinear_isBilinear R U U' V s s' f. +HB.instance Definition _ := isBilinear.Build R U U' V s s' f + (fun u' => additive_linear (bilinear_subproof.1 u')) + (fun u => additive_linear (bilinear_subproof.2 u)) + (fun u' => scalable_linear (bilinear_subproof.1 u')) + (fun u => scalable_linear (bilinear_subproof.2 u)). +HB.end. -(* Fact applyr_key : unit. Proof. exact. Qed. *) -Definition applyr_head t (f : U -> U' -> V) u v := let: tt := t in f v u. -Notation applyr := (@applyr_head tt). - -Canonical additivel phUV phUU'V (u' : U') (cF : map _) := - @GRing.Additive.Pack _ _ phUV (applyr cF u') (basel (@class phUU'V cF) u'). -Canonical linearl phUV phUU'V (u' : U') (cF : map _) := - @GRing.Linear.Pack _ _ _ _ phUV (applyr cF u') (basel (@class phUU'V cF) u'). - -Definition pack (phUV : phant (U -> V)) (phU'V : phant (U' -> V)) - (revf : U' -> U -> V) (rf : revop revf) f (g : U -> U' -> V) of (g = fun_of_revop rf) := - fun (bFl : U' -> GRing.Linear.map s phUV) flc of (forall u', revf u' = bFl u') & - (forall u', phant_id (GRing.Linear.class (bFl u')) (flc u')) => - fun (bFr : U -> GRing.Linear.map s' phU'V) frc of (forall u, g u = bFr u) & - (forall u, phant_id (GRing.Linear.class (bFr u)) (frc u)) => - @Pack (Phant _) f (Class flc frc). - - -(* (* Support for right-to-left rewriting with the generic linearZ rule. *) *) -(* Notation mapUV := (map (Phant (U -> U' -> V))). *) -(* Definition map_class := mapUV. *) -(* Definition map_at (a : R) := mapUV. *) -(* Structure map_for a s_a := MapFor {map_for_map : mapUV; _ : s a = s_a}. *) -(* Definition unify_map_at a (f : map_at a) := MapFor f (erefl (s a)). *) -(* Structure wrapped := Wrap {unwrap : mapUV}. *) -(* Definition wrap (f : map_class) := Wrap f. *) - -End ClassDef. - -Module Exports. -Delimit Scope linear_ring_scope with linR. -Notation bilinear_for s s' f := (axiom f (erefl s) (erefl s')). +Module BilinearExports. Notation bilinear f := (bilinear_for *:%R *:%R f). Notation biscalar f := (bilinear_for *%R *%R f). -Notation bilmorphism_for s s' f := (class_of s s' f). -Notation bilmorphism f := (bilmorphism_for *:%R *:%R f). -Coercion class_of_axiom : axiom >-> bilmorphism_for. -Coercion baser : bilmorphism_for >-> Funclass. -Coercion apply : map >-> Funclass. -Notation "{ 'bilinear' fUV | s & s' }" := (map s s' (Phant fUV)) +Module Bilinear. +Definition map (R : ringType) (U U' : lmodType R) (V : zmodType) + (s : R -> V -> V) (s' : R -> V -> V) + (phUU'V : phant (U -> U' -> V)) := Bilinear.type U U' s s'. +End Bilinear. +Notation "{ 'bilinear' fUV | s & s' }" := (Bilinear.map s s' (Phant fUV)) (at level 0, format "{ 'bilinear' fUV | s & s' }") : ring_scope. -Notation "{ 'bilinear' fUV | s }" := (map s.1 s.2 (Phant fUV)) +Notation "{ 'bilinear' fUV | s }" := (Bilinear.map s.1 s.2 (Phant fUV)) (at level 0, format "{ 'bilinear' fUV | s }") : ring_scope. Notation "{ 'bilinear' fUV }" := {bilinear fUV | *:%R & *:%R} (at level 0, format "{ 'bilinear' fUV }") : ring_scope. Notation "{ 'biscalar' U }" := {bilinear U -> U -> _ | *%R & *%R} (at level 0, format "{ 'biscalar' U }") : ring_scope. -Notation "[ 'bilinear' 'of' f 'as' g ]" := - (@pack _ _ _ _ _ _ _ _ _ _ f g erefl _ _ - (fun=> erefl) (fun=> idfun) _ _ (fun=> erefl) (fun=> idfun)). -Notation "[ 'bilinear' 'of' f ]" := [bilinear of f as f] +Notation "[ 'bilinear' 'of' f 'as' g ]" := (Bilinear.clone _ _ _ _ _ _ f g) + (at level 0, format "[ 'bilinear' 'of' f 'as' g ]") : form_scope. +Notation "[ 'bilinear' 'of' f ]" := (Bilinear.clone _ _ _ _ _ _ f _) (at level 0, format "[ 'bilinear' 'of' f ]") : form_scope. -Coercion additiver : map >-> GRing.Additive.map. -Coercion linearr : map >-> GRing.Linear.map. -Canonical additiver. -Canonical linearr. -Canonical additivel. -Canonical linearl. -Notation applyr := (@applyr_head _ _ _ _ tt). -(* Canonical additive. *) -(* (* Support for right-to-left rewriting with the generic linearZ rule. *) *) -(* Coercion map_for_map : map_for >-> map. *) -(* Coercion unify_map_at : map_at >-> map_for. *) -(* Canonical unify_map_at. *) -(* Coercion unwrap : wrapped >-> map. *) -(* Coercion wrap : map_class >-> wrapped. *) -(* Canonical wrap. *) -End Exports. +End BilinearExports. +Export BilinearExports. -End Bilinear. -Include Bilinear.Exports. +Section applyr. + +Variables (R : ringType) (U U' : lmodType R) (V : zmodType) (s s' : R -> V -> V). + +(* Fact applyr_key : unit. Proof. exact. Qed. *) +Definition applyr_head t (f : U -> U' -> V) u v := let: tt := t in f v u. + +End applyr. + +Notation applyr := (applyr_head tt). Section BilinearTheory. @@ -162,48 +120,74 @@ Section GenericProperties. Variables (U U' : lmodType R) (V : zmodType) (s : R -> V -> V) (s' : R -> V -> V). Variable f : {bilinear U -> U' -> V | s & s'}. -Lemma linear0r z : f z 0 = 0. Proof. by rewrite raddf0. Qed. -Lemma linearNr z : {morph f z : x / - x}. Proof. exact: raddfN. Qed. -Lemma linearDr z : {morph f z : x y / x + y}. Proof. exact: raddfD. Qed. -Lemma linearBr z : {morph f z : x y / x - y}. Proof. exact: raddfB. Qed. -Lemma linearMnr z n : {morph f z : x / x *+ n}. Proof. exact: raddfMn. Qed. -Lemma linearMNnr z n : {morph f z : x / x *- n}. Proof. exact: raddfMNn. Qed. -Lemma linear_sumr z I r (P : pred I) E : +Section GenericPropertiesr. + +Variable z : U. + +#[local, non_forgetful_inheritance] +HB.instance Definition _ := + GRing.isAdditive.Build _ _ (f z) (@additiver_subproof _ _ _ _ _ _ f z). +#[local, non_forgetful_inheritance] +HB.instance Definition _ := + GRing.isScalable.Build _ _ _ _ (f z) (@linearr_subproof _ _ _ _ _ _ f z). + +Lemma linear0r : f z 0 = 0. Proof. by rewrite raddf0. Qed. +Lemma linearNr : {morph f z : x / - x}. Proof. exact: raddfN. Qed. +Lemma linearDr : {morph f z : x y / x + y}. Proof. exact: raddfD. Qed. +Lemma linearBr : {morph f z : x y / x - y}. Proof. exact: raddfB. Qed. +Lemma linearMnr n : {morph f z : x / x *+ n}. Proof. exact: raddfMn. Qed. +Lemma linearMNnr n : {morph f z : x / x *- n}. Proof. exact: raddfMNn. Qed. +Lemma linear_sumr I r (P : pred I) E : f z (\sum_(i <- r | P i) E i) = \sum_(i <- r | P i) f z (E i). Proof. exact: raddf_sum. Qed. -Lemma linearZr_LR z : scalable_for s' (f z). Proof. exact: linearZ_LR. Qed. -Lemma linearPr z a : {morph f z : u v / a *: u + v >-> s' a u + v}. +Lemma linearZr_LR : scalable_for s' (f z). Proof. exact: linearZ_LR. Qed. +Lemma linearPr a : {morph f z : u v / a *: u + v >-> s' a u + v}. Proof. exact: linearP. Qed. +End GenericPropertiesr. + Lemma applyrE x : applyr f x =1 f^~ x. Proof. by []. Qed. -Lemma linear0l z : f 0 z = 0. Proof. by rewrite -applyrE raddf0. Qed. -Lemma linearNl z : {morph f^~ z : x / - x}. +Section GenericPropertiesl. + +Variable z : U'. + +#[local, non_forgetful_inheritance] +HB.instance Definition _ := + GRing.isAdditive.Build _ _ (applyr f z) (@additivel_subproof _ _ _ _ _ _ f z). +#[local, non_forgetful_inheritance] +HB.instance Definition _ := + GRing.isScalable.Build _ _ _ _ (applyr f z) (@linearl_subproof _ _ _ _ _ _ f z). + +Lemma linear0l : f 0 z = 0. Proof. by rewrite -applyrE raddf0. Qed. +Lemma linearNl : {morph f^~ z : x / - x}. Proof. by move=> ?; rewrite -applyrE raddfN. Qed. -Lemma linearDl z : {morph f^~ z : x y / x + y}. +Lemma linearDl : {morph f^~ z : x y / x + y}. Proof. by move=> ??; rewrite -applyrE raddfD. Qed. -Lemma linearBl z : {morph f^~ z : x y / x - y}. +Lemma linearBl : {morph f^~ z : x y / x - y}. Proof. by move=> ??; rewrite -applyrE raddfB. Qed. -Lemma linearMnl z n : {morph f^~ z : x / x *+ n}. +Lemma linearMnl n : {morph f^~ z : x / x *+ n}. Proof. by move=> ?; rewrite -applyrE raddfMn. Qed. -Lemma linearMNnl z n : {morph f^~ z : x / x *- n}. +Lemma linearMNnl n : {morph f^~ z : x / x *- n}. Proof. by move=> ?; rewrite -applyrE raddfMNn. Qed. -Lemma linear_suml z I r (P : pred I) E : +Lemma linear_suml I r (P : pred I) E : f (\sum_(i <- r | P i) E i) z = \sum_(i <- r | P i) f (E i) z. Proof. by rewrite -applyrE raddf_sum. Qed. -Lemma linearZl_LR z : scalable_for s (f^~ z). +Lemma linearZl_LR : scalable_for s (f^~ z). Proof. by move=> ??; rewrite -applyrE linearZ_LR. Qed. -Lemma linearPl z a : {morph f^~ z : u v / a *: u + v >-> s a u + v}. +Lemma linearPl a : {morph f^~ z : u v / a *: u + v >-> s a u + v}. Proof. by move=> ??; rewrite -applyrE linearP. Qed. +End GenericPropertiesl. + End GenericProperties. Section BidirectionalLinearZ. Variables (U : lmodType R) (V : zmodType) (s : R -> V -> V). -Variables (S : ringType) (h : S -> V -> V) (h_law : GRing.Scale.law h). +Variables (S : ringType) (h : GRing.Scale.law S V). (* Lemma linearZr z c a (h_c := GRing.Scale.op h_law c) (f : GRing.Linear.map_for U s a h_c) u : *) (* f z (a *: u) = h_c (GRing.Linear.wrap (f z) u). *) @@ -216,7 +200,21 @@ End BilinearTheory. Canonical rev_mulmx (R : ringType) m n p := @RevOp _ _ _ (@mulmxr R m n p) (@mulmx R m n p) (fun _ _ => erefl). -Canonical mulmx_bilinear (R : comRingType) m n p := [bilinear of @mulmx R m n p]. +Lemma mulmx_is_bilinear (R : comRingType) m n p : + bilinear_for + (GRing.Scale.Law.clone _ _ *:%R _) (GRing.Scale.Law.clone _ _ *:%R _) + (@mulmx R m n p). +Proof. +split=> [u'|u] a x y /=. +- by rewrite mulmxDl scalemxAl. +- by rewrite mulmxDr scalemxAr. +Qed. + +HB.instance Definition _ (R : comRingType) m n p := + bilinear_isBilinear.Build R + [the lmodType R of 'M[R]_(m, n)] [the lmodType R of 'M[R]_(n, p)] + [the zmodType of 'M[R]_(m, p)] _ _ (@mulmx R m n p) + (mulmx_is_bilinear R m n p). (* Section classfun. *) (* Import mathcomp.character.classfun. *) @@ -336,7 +334,7 @@ Proof. rewrite /form [M in LHS](sesquiP _) // -mulmxA !mxE rmorph_sum mulr_sumr. apply: eq_bigr => /= i _; rewrite !(mxE, mulr_sumr, mulr_suml, rmorph_sum). apply: eq_bigr => /= j _; rewrite !mxE !rmorphM mulrCA -!mulrA. -by congr (_ * _); rewrite mulrA mulrC thetaK. +by congr (_ * _); rewrite mulrA mulrC /= thetaK. Qed. Lemma form_eq0C u v : ('[u, v] == 0) = ('[v, u] == 0). @@ -479,9 +477,9 @@ End Sesquilinear. Notation "eps_theta .-sesqui" := (sesqui _ eps_theta) : ring_scope. -Notation symmetric_form := (false, [rmorphism of idfun]).-sesqui. -Notation skew := (true, [rmorphism of idfun]).-sesqui. -Notation hermitian := (false, @conjC _).-sesqui. +Notation symmetric_form := (false, idfun).-sesqui. +Notation skew := (true, idfun).-sesqui. +Notation hermitian := (false, @Num.conj_op _).-sesqui. (* Section ClassificationForm. *) diff --git a/theories/hoelder.v b/theories/hoelder.v index 86308c02e..2385f9e1f 100644 --- a/theories/hoelder.v +++ b/theories/hoelder.v @@ -308,7 +308,7 @@ have [->|p_neq1] := eqVneq p 1. by rewrite !powRr1// addr_ge0// mulr_ge0// /w2 ?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_pdivl_mulr// ?mul1r ?gerBl// subr_gt0. +have q1 : 1 <= q by rewrite /q ler_pdivlMr// ?mul1r ?gerBl// subr_gt0. have q0 : 0 < q by rewrite (lt_le_trans _ q1). have pq1 : p^-1 + q^-1 = 1. rewrite /q invf_div -{1}(div1r p) -mulrDl addrCA subrr addr0. @@ -348,7 +348,7 @@ Let convex_powR_abs_half f g p x : 1 <= p -> 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_norm_add _ _))// 2!normrM ger0_norm. + 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 (@Itv.mk _ _ _ _)) ?inE/= ?in_itv/= ?normr_ge0//. by rewrite /Itv.itv_cond/= in_itv/= invr_ge0 ler0n invf_le1 ?ler1n. @@ -368,8 +368,9 @@ move=> mf mg. rewrite !Lnorm1 -ge0_integralD//; [|by do 2 apply: measurableT_comp..]. rewrite ge0_le_integral//. - by do 2 apply: measurableT_comp => //; exact: measurable_funD. +- by move=> x _; rewrite lee_fin. - by apply/measurableT_comp/measurable_funD; exact/measurableT_comp. -- by move=> x _; rewrite lee_fin ler_norm_add. +- by move=> x _; rewrite lee_fin ler_normD. Qed. Let minkowski_lty f g p : @@ -449,7 +450,7 @@ apply: (@le_trans _ _ - apply/measurableT_comp => //; apply: measurable_funM. by apply/measurable_funD => //; exact: measurableT_comp. exact/measurableT_comp_powR/measurableT_comp/measurable_funD. - - by move=> ? _; rewrite lee_fin ler_wpmul2r// ?powR_ge0// ler_norm_add. + - by move=> ? _; rewrite lee_fin ler_wpM2r// ?powR_ge0// ler_normD. under eq_integral=> ? _ do rewrite mulrDl EFinD. rewrite ge0_integralD//; last 4 first. - by move=> x _; rewrite lee_fin mulr_ge0// powR_ge0. diff --git a/theories/itv.v b/theories/itv.v index 49b9e852a..2911b9299 100644 --- a/theories/itv.v +++ b/theories/itv.v @@ -1,5 +1,6 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) -From Coq Require Import ssreflect ssrfun ssrbool. +From HB Require Import structures. +From mathcomp Require Import ssreflect ssrfun ssrbool. From mathcomp Require Import ssrnat eqtype choice order ssralg ssrnum ssrint. From mathcomp Require Import interval. From mathcomp Require Import mathcomp_extra boolp. @@ -162,13 +163,10 @@ Export Itv.Exports. Section POrder. Variables (R : numDomainType) (i : interval int). Local Notation nR := {itv R & i}. -Canonical itv_subType := [subType for @Itv.r R i]. -Definition itv_eqMixin := [eqMixin of nR by <:]. -Canonical itv_eqType := EqType nR itv_eqMixin. -Definition itv_choiceMixin := [choiceMixin of nR by <:]. -Canonical itv_choiceType := ChoiceType nR itv_choiceMixin. -Definition itv_porderMixin := [porderMixin of nR by <:]. -Canonical itv_porderType := POrderType ring_display nR itv_porderMixin. +HB.instance Definition _ := [isSub for @Itv.r R i]. +HB.instance Definition _ := [Choice of nR by <:]. +HB.instance Definition _ := [SubChoice_isSubPOrder of nR by <: + with ring_display]. End POrder. (* TODO: numDomainType on sT ? *) @@ -357,7 +355,7 @@ Lemma opp_itv_boundr_subproof (x : R) b : (BRight (- x)%R <= Itv.map_itv_bound intr (opp_itv_bound_subdef b))%O = (Itv.map_itv_bound intr b <= BLeft x)%O. Proof. -by case: b => [[] b | []//]; rewrite /= !bnd_simp mulrNz ?ler_opp2 // ltr_opp2. +by case: b => [[] b | []//]; rewrite /= !bnd_simp mulrNz ?lerN2 // ltrN2. Qed. Lemma opp_itv_le0_subproof b : @@ -374,7 +372,7 @@ Lemma opp_itv_boundl_subproof (x : R) b : (Itv.map_itv_bound intr (opp_itv_bound_subdef b) <= BLeft (- x)%R)%O = (BRight x <= Itv.map_itv_bound intr b)%O. Proof. -by case: b => [[] b | []//]; rewrite /= !bnd_simp mulrNz ?ler_opp2 // ltr_opp2. +by case: b => [[] b | []//]; rewrite /= !bnd_simp mulrNz ?lerN2 // ltrN2. Qed. Definition opp_itv_subdef (i : interval int) : interval int := @@ -388,9 +386,9 @@ Lemma opp_inum_subproof (i : interval int) Proof. rewrite {}/r; move: i x => [l u] [x /= /andP[xl xu]]; apply/andP; split. - by case: u xu => [[] b i | [] //] /=; rewrite /Order.le/= mulrNz; - do ?[by rewrite ler_oppl opprK|by rewrite ltr_oppl opprK]. + do ?[by rewrite lerNl opprK|by rewrite ltrNl opprK]. - by case: l xl => [[] b i | [] //] /=; rewrite /Order.le/= mulrNz; - do ?[by rewrite ltr_oppl opprK|by rewrite ler_oppl opprK]. + do ?[by rewrite ltrNl opprK|by rewrite lerNl opprK]. Qed. Canonical opp_inum (i : interval int) (x : {itv R & i}) := @@ -426,10 +424,10 @@ move: xi x yi y => [lx ux] [x /= /andP[xl xu]] [ly uy] [y /= /andP[yl yu]]. rewrite /Itv.itv_cond in_itv; apply/andP; split. - move: lx ly xl yl => [xb lx | //] [yb ly | //]. by move: xb yb => [] []; rewrite /Order.le/= rmorphD/=; - do ?[exact: ler_add|exact: ler_lt_add|exact: ltr_le_add|exact: ltr_add]. + do ?[exact: lerD|exact: ler_ltD|exact: ltr_leD|exact: ltrD]. - move: ux uy xu yu => [xb ux | //] [yb uy | //]. by move: xb yb => [] []; rewrite /Order.le/= rmorphD/=; - do ?[exact: ler_add|exact: ler_lt_add|exact: ltr_le_add|exact: ltr_add]. + do ?[exact: lerD|exact: ler_ltD|exact: ltr_leD|exact: ltrD]. Qed. Canonical add_inum (xi yi : interval int) @@ -523,19 +521,19 @@ move: b1 b2 => [[] b1 | []//] [[] b2 | []//] /=; rewrite 4!bnd_simp. have -> : bl = BLeft (b1 * b2). rewrite {}/bl; move: b1 b2 => [[|p1]|p1] [[|p2]|p2]; congr BLeft. by rewrite mulr0. - rewrite -2!(ler0z R) bnd_simp intrM; exact: ler_pmul. + rewrite -2!(ler0z R) bnd_simp intrM; exact: ler_pM. - case: b1 => [[|p1]|//]; rewrite -2!(ler0z R) !bnd_simp ?intrM. by move=> _ geb2 ? ?; apply: mulr_ge0 => //; apply/(le_trans geb2)/ltW. move=> p1gt0 b2ge0 lep1x1 ltb2x2. have: (Posz p1.+1)%:~R * x2 <= x1 * x2. - by rewrite ler_pmul2r //; apply: le_lt_trans ltb2x2. - by apply: lt_le_trans; rewrite ltr_pmul2l // ltr0z. + by rewrite ler_pM2r //; apply: le_lt_trans ltb2x2. + by apply: lt_le_trans; rewrite ltr_pM2l // ltr0z. - case: b2 => [[|p2]|//]; rewrite -2!(ler0z R) !bnd_simp ?intrM. by move=> geb1 _ ? ?; apply: mulr_ge0 => //; apply/(le_trans geb1)/ltW. move=> b1ge0 p2gt0 ltb1x1 lep2x2. - have: b1%:~R * x2 < x1 * x2; last exact/le_lt_trans/ler_pmul. - by rewrite ltr_pmul2r //; apply: lt_le_trans lep2x2; rewrite ltr0z. -- rewrite -2!(ler0z R) bnd_simp intrM; exact: ltr_pmul. + have: b1%:~R * x2 < x1 * x2; last exact/le_lt_trans/ler_pM. + by rewrite ltr_pM2r //; apply: lt_le_trans lep2x2; rewrite ltr0z. +- rewrite -2!(ler0z R) bnd_simp intrM; exact: ltr_pM. Qed. Lemma mul_itv_boundrC_subproof b1 b2 : @@ -570,16 +568,16 @@ case: b1 => [[|p1]|p1]. by move: (conj l l') => /andP/le_anti <-; rewrite mulr0. + move: b1b b2b => [] []; rewrite !bnd_simp; rewrite -[intRing.mulz ?[a] ?[b]]/((Posz ?[a]) * ?[b])%R intrM. - * exact: ltr_pmul. + * exact: ltr_pM. * move=> x1ge0 x2ge0 ltx1p1 lex2p2. have: x1 * p2.+1%:~R < p1.+1%:~R * p2.+1%:~R. - by rewrite ltr_pmul2r // ltr0z. - exact/le_lt_trans/ler_pmul. + by rewrite ltr_pM2r // ltr0z. + exact/le_lt_trans/ler_pM. * move=> x1ge0 x2ge0 lex1p1 ltx2p2. have: p1.+1%:~R * x2 < p1.+1%:~R * p2.+1%:~R. - by rewrite ltr_pmul2l // ltr0z. - exact/le_lt_trans/ler_pmul. - * exact: ler_pmul. + by rewrite ltr_pM2l // ltr0z. + exact/le_lt_trans/ler_pM. + * exact: ler_pM. + case: b2b => _ + _; rewrite 2!bnd_simp => l l'. by move: (le_lt_trans l l'); rewrite ltr0z. by move: (le_trans l l'); rewrite ler0z. diff --git a/theories/kernel.v b/theories/kernel.v index 1d4fefa3e..e4b3e25e3 100644 --- a/theories/kernel.v +++ b/theories/kernel.v @@ -512,7 +512,7 @@ Lemma measurable_fun_xsection_integral (l : X -> {measure set Y -> \bar R}) (k_ : ({nnsfun [the measurableType _ of X * Y] >-> R})^nat) (ndk_ : nondecreasing_seq (k_ : (X * Y -> R)^nat)) - (k_k : forall z, EFin \o (k_ ^~ z) --> k z) : + (k_k : forall z, (k_ n z)%:E @[n --> \oo] --> k z) : (forall n r, measurable_fun [set: X] (fun x => l x (xsection (k_ n @^-1` [set r]) x))) -> measurable_fun [set: X] (fun x => \int[l x]_y k (x, y)). @@ -521,7 +521,7 @@ move=> h. rewrite (_ : (fun x => _) = (fun x => limn_esup (fun n => \int[l x]_y (k_ n (x, y))%:E))); last first. apply/funext => x. - transitivity (lim (fun n => \int[l x]_y (k_ n (x, y))%:E)); last first. + transitivity (lim (\int[l x]_y (k_ n (x, y))%:E @[n --> \oo])); last first. rewrite is_cvg_limn_esupE//. apply: ereal_nondecreasing_is_cvgn => m n mn. apply: ge0_le_integral => //. @@ -632,12 +632,9 @@ Context d (T : measurableType d) (R : realType). Let p0 : probability T R := [the probability _ _ of dirac point]. -Definition prob_pointed := Pointed.Class - (Choice.Class gen_eqMixin (Choice.Class gen_eqMixin gen_choiceMixin)) p0. - -Canonical probability_eqType := EqType (probability T R) prob_pointed. -Canonical probability_choiceType := ChoiceType (probability T R) prob_pointed. -Canonical probability_ptType := PointedType (probability T R) prob_pointed. +HB.instance Definition _ := gen_eqMixin (probability T R). +HB.instance Definition _ := gen_choiceMixin (probability T R). +HB.instance Definition _ := isPointed.Build (probability T R) p0. Definition mset (U : set T) (r : R) := [set mu : probability T R | mu U < r%:E]. @@ -906,7 +903,7 @@ Context d d' d3 (X : measurableType d) (Y : measurableType d') Variable l : R.-fker X ~> Y. Variable k : R.-fker [the measurableType _ of X * Y] ~> Z. -Let mkcomp_finite : measure_fam_uub (mkcomp l k). +Let mkcomp_finite : measure_fam_uub (kcomp l k). Proof. have /measure_fam_uubP[r hr] := measure_uub k. have /measure_fam_uubP[s hs] := measure_uub l. @@ -992,7 +989,7 @@ Context d d' (X : measurableType d) (Y : measurableType d') (R : realType). Variables (k : Y -> \bar R) (k_ : ({nnsfun Y >-> R}) ^nat) (ndk_ : nondecreasing_seq (k_ : (Y -> R)^nat)) - (k_k : forall z, [set: Y] z -> EFin \o (k_ ^~ z) --> k z). + (k_k : forall z, [set: Y] z -> (k_ n z)%:E @[n --> \oo] --> k z). Let k_2 : (X * Y -> R)^nat := fun n => k_ n \o snd. @@ -1116,7 +1113,7 @@ rewrite monotone_convergence//; last 3 first. rewrite (_ : (fun _ => _) = (fun n => \int[l x]_y (\int[k (x, y)]_z (f_ n z)%:E)))//; last first. by apply/funext => n; rewrite integral_kcomp_nnsfun. -transitivity (\int[l x]_y lim (fun n => \int[k (x, y)]_z (f_ n z)%:E)). +transitivity (\int[l x]_y lim ((\int[k (x, y)]_z (f_ n z)%:E) @[n --> \oo])). rewrite -monotone_convergence//; last 3 first. - move=> n; apply: measurable_fun_integral_kernel => //. + by move=> U mU; exact: measurableT_comp (measurable_kernel k _ mU) _. diff --git a/theories/landau.v b/theories/landau.v index 1b19ad84d..c9fb5b13a 100644 --- a/theories/landau.v +++ b/theories/landau.v @@ -1,4 +1,5 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +From HB Require Import structures. From mathcomp Require Import all_ssreflect ssralg ssrnum. From mathcomp Require Import mathcomp_extra boolp classical_sets functions. Require Import ereal reals signed topology normedtype prodnormedzmodule. @@ -300,24 +301,24 @@ Lemma showo : (gen_tag = tt) * (the_tag = tt) * (a_tag = tt). Proof. by []. Qed. Section Domination. Context {K : numDomainType} {T : Type} {V W : normedModType K}. -Let littleo_def (F : set (set T)) (f : T -> V) (g : T -> W) := +Let littleo_def (F : set_system T) (f : T -> V) (g : T -> W) := forall eps, 0 < eps -> \forall x \near F, `|f x| <= eps * `|g x|. -Structure littleo_type (F : set (set T)) (g : T -> W) := Littleo { +Structure littleo_type (F : set_system T) (g : T -> W) := Littleo { littleo_fun :> T -> V; _ : `[< littleo_def F littleo_fun g >] }. Notation "{o_ F f }" := (littleo_type F f). -Canonical littleo_subtype (F : set (set T)) (g : T -> W) := - [subType for (@littleo_fun F g)]. +HB.instance Definition _ (F : set_system T) (g : T -> W) := + [isSub for @littleo_fun F g]. -Lemma littleo_class (F : set (set T)) (g : T -> W) (f : {o_F g}) : +Lemma littleo_class (F : set_system T) (g : T -> W) (f : {o_F g}) : `[< littleo_def F f g >]. Proof. by case: f => ?. Qed. Hint Resolve littleo_class : core. -Definition littleo_clone (F : set (set T)) (g : T -> W) (f : T -> V) (fT : {o_F g}) c +Definition littleo_clone (F : set_system T) (g : T -> W) (f : T -> V) (fT : {o_F g}) c of phant_id (littleo_class fT) c := @Littleo F g f c. Notation "[littleo 'of' f 'for' fT ]" := (@littleo_clone _ _ f fT _ idfun). Notation "[littleo 'of' f ]" := (@littleo_clone _ _ f _ _ idfun). @@ -333,8 +334,8 @@ Canonical littleo0 (F : filter_on T) g := Littleo (asboolT (@littleo0_subproof F g _)). Definition the_littleo (_ : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := littleo_fun (insubd (littleo0 F h) f). -Notation PhantomF := (Phantom (set (set T))). + (phF : phantom (set_system T) F) f h := littleo_fun (insubd (littleo0 F h) f). +Notation PhantomF := (Phantom (set_system T)). Arguments the_littleo : simpl never, clear implicits. Notation mklittleo tag x := (the_littleo tag _ (PhantomF x)). @@ -377,7 +378,7 @@ Notation "fx == gx '+o_(' x \near F ')' hx" := Notation "fx '==o_(' x \near F ')' hx" := (fx == (mklittleo the_tag F (fun x => fx) (fun x => hx) x)). -Lemma littleoP (F : set (set T)) (g : T -> W) (f : {o_F g}) : littleo_def F f g. +Lemma littleoP (F : set_system T) (g : T -> W) (f : {o_F g}) : littleo_def F f g. Proof. exact/asboolP. Qed. Hint Extern 0 (littleo_def _ _ _) => solve[apply: littleoP] : core. Hint Extern 0 (nbhs _ _) => solve[apply: littleoP] : core. @@ -385,17 +386,17 @@ Hint Extern 0 (prop_near1 _) => solve[apply: littleoP] : core. Hint Extern 0 (prop_near2 _) => solve[apply: littleoP] : core. Lemma littleoE (tag : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h : + (phF : phantom (set_system T) F) f h : littleo_def F f h -> the_littleo tag F phF f h = f. Proof. by move=> /asboolP?; rewrite /the_littleo /insubd insubT. Qed. Canonical the_littleo_littleo (tag : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := [littleo of the_littleo tag F phF f h]. + (phF : phantom (set_system T) F) f h := [littleo of the_littleo tag F phF f h]. -Variant littleo_spec (F : set (set T)) (g : T -> W) : (T -> V) -> Type := +Variant littleo_spec (F : set_system T) (g : T -> W) : (T -> V) -> Type := LittleoSpec f of littleo_def F f g : littleo_spec F g f. -Lemma littleo (F : set (set T)) (g : T -> W) (f : {o_F g}) : littleo_spec F g f. +Lemma littleo (F : set_system T) (g : T -> W) (f : {o_F g}) : littleo_spec F g f. Proof. by constructor; apply/(@littleoP F). Qed. Lemma opp_littleo_subproof (F : filter_on T) e (df : {o_F e}) : @@ -466,39 +467,39 @@ End Domination. Section Domination_numFieldType. Context {K : numFieldType} {T : Type} {V W : normedModType K}. -Let bigO_def (F : set (set T)) (f : T -> V) (g : T -> W) := +Let bigO_def (F : set_system T) (f : T -> V) (g : T -> W) := \forall k \near +oo, \forall x \near F, `|f x| <= k * `|g x|. -Let bigO_ex_def (F : set (set T)) (f : T -> V) (g : T -> W) := +Let bigO_ex_def (F : set_system T) (f : T -> V) (g : T -> W) := exists2 k, k > 0 & \forall x \near F, `|f x| <= k * `|g x|. -Lemma bigO_exP (F : set (set T)) (f : T -> V) (g : T -> W) : +Lemma bigO_exP (F : set_system T) (f : T -> V) (g : T -> W) : Filter F -> bigO_ex_def F f g <-> bigO_def F f g. Proof. split=> [[k k0 fOg] | [k [kreal fOg]]]. exists k; rewrite realE (ltW k0) /=; split=> // l ltkl; move: fOg. - by apply: filter_app; near=> x => /le_trans; apply; rewrite ler_wpmul2r // ltW. + by apply: filter_app; near=> x => /le_trans; apply; rewrite ler_wpM2r // ltW. exists (Num.max 1 `|k + 1|) => //. apply: fOg; rewrite (@lt_le_trans _ _ `|k + 1|) //. - by rewrite (@lt_le_trans _ _ (k + 1)) ?ltr_addl // real_ler_norm ?realD. + by rewrite (@lt_le_trans _ _ (k + 1)) ?ltrDl // real_ler_norm ?realD. by rewrite comparable_le_maxr ?real_comparable// lexx orbT. Unshelve. end_near. Qed. -Structure bigO_type (F : set (set T)) (g : T -> W) := BigO { +Structure bigO_type (F : set_system T) (g : T -> W) := BigO { bigO_fun :> T -> V; _ : `[< bigO_def F bigO_fun g >] }. Notation "{O_ F f }" := (bigO_type F f). -Canonical bigO_subtype (F : set (set T)) (g : T -> W) := - [subType for (@bigO_fun F g)]. +HB.instance Definition _ (F : set_system T) (g : T -> W) := + [isSub for @bigO_fun F g]. -Lemma bigO_class (F : set (set T)) (g : T -> W) (f : {O_F g}) : +Lemma bigO_class (F : set_system T) (g : T -> W) (f : {O_F g}) : `[< bigO_def F f g >]. Proof. by case: f => ?. Qed. Hint Resolve bigO_class : core. -Definition bigO_clone (F : set (set T)) (g : T -> W) (f : T -> V) (fT : {O_F g}) c +Definition bigO_clone (F : set_system T) (g : T -> W) (f : T -> V) (fT : {O_F g}) c of phant_id (bigO_class fT) c := @BigO F g f c. Notation "[bigO 'of' f 'for' fT ]" := (@bigO_clone _ _ f fT _ idfun). Notation "[bigO 'of' f ]" := (@bigO_clone _ _ f _ _ idfun). @@ -512,11 +513,11 @@ Unshelve. all: by end_near. Qed. Canonical bigO0 (F : filter_on T) g := BigO (asboolT (@bigO0_subproof F g _)). Definition the_bigO (u : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := bigO_fun (insubd (bigO0 F h) f). + (phF : phantom (set_system T) F) f h := bigO_fun (insubd (bigO0 F h) f). Arguments the_bigO : simpl never, clear implicits. (* duplicate from Section Domination *) -Notation PhantomF := (Phantom (set (set T))). +Notation PhantomF := (Phantom (set_system T)). Notation mkbigO tag x := (the_bigO tag _ (PhantomF x)). (* Parsing *) Notation "[O_ x e 'of' f ]" := (mkbigO gen_tag x f e). @@ -557,21 +558,21 @@ Notation "fx == gx '+O_(' x \near F ')' hx" := Notation "fx '==O_(' x \near F ')' hx" := (fx == (mkbigO the_tag F (fun x => fx) (fun x => hx) x)). -Lemma bigOP (F : set (set T)) (g : T -> W) (f : {O_F g}) : bigO_def F f g. +Lemma bigOP (F : set_system T) (g : T -> W) (f : {O_F g}) : bigO_def F f g. Proof. exact/asboolP. Qed. Hint Extern 0 (bigO_def _ _ _) => solve[apply: bigOP] : core. Hint Extern 0 (nbhs _ _) => solve[apply: bigOP] : core. Hint Extern 0 (prop_near1 _) => solve[apply: bigOP] : core. Hint Extern 0 (prop_near2 _) => solve[apply: bigOP] : core. -Lemma bigOE (tag : unit) (F : filter_on T) (phF : phantom (set (set T)) F) f h : +Lemma bigOE (tag : unit) (F : filter_on T) (phF : phantom (set_system T) F) f h : bigO_def F f h -> the_bigO tag F phF f h = f. Proof. by move=> /asboolP?; rewrite /the_bigO /insubd insubT. Qed. Canonical the_bigO_bigO (tag : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := [bigO of the_bigO tag F phF f h]. + (phF : phantom (set_system T) F) f h := [bigO of the_bigO tag F phF f h]. -Variant bigO_spec (F : set (set T)) (g : T -> W) : (T -> V) -> Prop := +Variant bigO_spec (F : set_system T) (g : T -> W) : (T -> V) -> Prop := BigOSpec f (k : {posnum K}) of (\forall x \near F, `|f x| <= k%:num * `|g x|) : bigO_spec F g f. @@ -599,8 +600,8 @@ Proof. by move: x; rewrite -/(- _ =1 _) {1}oppO. Qed. Lemma add_bigO_subproof (F : filter_on T) e (df dg : {O_F e}) : bigO_def F (df \+ dg) e. Proof. -near=> k; near=> x; apply: le_trans (ler_norm_add _ _) _. -by rewrite (splitr k) mulrDl ler_add //; near: x; near: k; +near=> k; near=> x; apply: le_trans (ler_normD _ _) _. +by rewrite (splitr k) mulrDl lerD //; near: x; near: k; [apply: near_pinfty_div2 (bigOP df)|apply: near_pinfty_div2 (bigOP dg)]. Unshelve. all: by end_near. Qed. @@ -693,7 +694,7 @@ Proof. by apply: eqOE; rewrite littleo_eqo. Qed. Canonical littleo_is_bigO (F : filter_on T) (e : T -> W) (f : {o_F e}) := BigO (asboolT (eqO_bigO (littleo_eqO f))). Canonical the_littleo_bigO (tag : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := [bigO of the_littleo tag phF f h]. + (phF : phantom (set_system T) F) f h := [bigO of the_littleo tag phF f h]. End Domination_numFieldType. @@ -709,7 +710,7 @@ Notation "[bigO 'of' f ]" := (@bigO_clone _ _ _ _ _ _ f _ _ idfun). Arguments the_littleo {_ _ _ _} _ _ _ _ _ : simpl never. Arguments the_bigO {_ _ _ _} _ _ _ _ _ : simpl never. -Local Notation PhantomF x := (Phantom _ [filter of x]). +Local Notation PhantomF x := (Phantom _ (nbhs x)). Notation mklittleo tag x := (the_littleo tag _ (PhantomF x)). (* Parsing *) @@ -823,14 +824,14 @@ Section Domination_numFieldType. Context {K : numFieldType} {T : Type} {V W : normedModType K}. (* duplicate from Section Domination *) -Let littleo_def (F : set (set T)) (f : T -> V) (g : T -> W) := +Let littleo_def (F : set_system T) (f : T -> V) (g : T -> W) := forall eps, 0 < eps -> \forall x \near F, `|f x| <= eps * `|g x|. Lemma add_littleo_subproof (F : filter_on T) e (df dg : {o_F e}) : littleo_def F (df \+ dg) e. Proof. by move=> _/posnumP[eps]; near do [ - rewrite [eps%:num]splitr mulrDl (le_trans (ler_norm_add _ _)) // ler_add //]; + rewrite [eps%:num]splitr mulrDl (le_trans (ler_normD _ _)) // lerD //]; apply: littleoP. Unshelve. all: by end_near. Qed. @@ -856,7 +857,7 @@ Lemma scale_littleo_subproof (F : filter_on T) e (df : {o_F e}) a : Proof. have [->|a0] := eqVneq a 0; first by rewrite scale0r. move=> _ /posnumP[eps]; have aa := normr_eq0 a; near=> x => /=. -rewrite normrZ -ler_pdivl_mull ?lt_def ?aa ?a0 //= mulrA; near: x. +rewrite normrZ -ler_pdivlMl ?lt_def ?aa ?a0 //= mulrA; near: x. by apply: littleoP; rewrite mulr_gt0 // invr_gt0 ?lt_def ?aa ?a0 /=. Unshelve. all: by end_near. Qed. @@ -884,7 +885,7 @@ have [->|a0] := eqVneq a 0. move=> _/posnumP[eps]. have ea : 0 < eps%:num / `| a | by rewrite divr_gt0 // normr_gt0. have [g /(_ _ ea) ?] := littleo; near=> y. -rewrite normrZ -ler_pdivl_mulr; first by rewrite mulrAC; near: y. +rewrite normrZ -ler_pdivlMr; first by rewrite mulrAC; near: y. by rewrite lt_def normr_eq0 a0 normr_ge0. Unshelve. all: by end_near. Qed. @@ -900,9 +901,9 @@ split=> fFl. apply/cvgrPdist_lt=> _/posnumP[eps]. have lt_eps x : x <= (eps%:num / 2%:R) * `|1 : K^o|%real -> x < eps%:num. rewrite normr1 mulr1 => /le_lt_trans; apply. - by rewrite ltr_pdivr_mulr // ltr_pmulr // ltr1n. + by rewrite ltr_pdivrMr // ltr_pMr // ltr1n. near=> x do rewrite [X in X x]fFl opprD addNKr normrN lt_eps //. -by rewrite /= !near_simpl; apply: littleoP; rewrite divr_gt0. +by apply: littleoP; rewrite divr_gt0. Unshelve. all: by end_near. Qed. Lemma eqolim (F : filter_on T) (f : T -> V) (l : V) e : @@ -927,7 +928,7 @@ Lemma littleo_bigO_eqo {F : filter_on T} Proof. move->; apply/eqoP => _/posnumP[e]; have [k c] := bigO _ g. apply: filter_app; near=> x do [ - rewrite -!ler_pdivr_mull//; apply: le_trans; rewrite ler_pdivr_mull// mulrA]. + rewrite -!ler_pdivrMl//; apply: le_trans; rewrite ler_pdivrMl// mulrA]. exact: littleoP. Unshelve. all: by end_near. Qed. Arguments littleo_bigO_eqo {F}. @@ -937,7 +938,7 @@ Lemma bigO_littleo_eqo {F : filter_on T} (g : T -> W) (f : T -> V) (h : T -> X) Proof. move->; apply/eqoP => _/posnumP[e]; have [k c] := bigO. apply: filter_app; near=> x => /le_trans; apply. -by rewrite -ler_pdivl_mull // mulrA; near: x; apply: littleoP. +by rewrite -ler_pdivlMl // mulrA; near: x; apply: littleoP. Unshelve. all: by end_near. Qed. Arguments bigO_littleo_eqo {F}. @@ -985,8 +986,8 @@ Lemma bigO_bigO_eqO {F : filter_on T} (g : T -> W) (f : T -> V) (h : T -> X) : Proof. move->; apply/eqOP; have [k c1 kOg] := bigO _ g. have [k' c2 k'Ok] := bigO _ k. near=> c; move: k'Ok kOg; apply: filter_app2; near=> x => lek'c2k. -rewrite -(@ler_pmul2l _ c2%:num) // mulrA => /(le_trans lek'c2k) /le_trans. -by apply; rewrite ler_pmul//; near: c; exact: nbhs_pinfty_ge. +rewrite -(@ler_pM2l _ c2%:num) // mulrA => /(le_trans lek'c2k) /le_trans. +by apply; rewrite ler_pM//; near: c; exact: nbhs_pinfty_ge. Unshelve. all: by end_near. Qed. Arguments bigO_bigO_eqO {F}. @@ -1052,7 +1053,7 @@ Lemma mulo (F : filter_on pT) (h1 h2 f g : pT -> R^o) : Proof. rewrite [in RHS]littleoE // => _/posnumP[e]; near=> x. rewrite [`|_|]normrM -(sqr_sqrtr (ge0 e)) expr2. -rewrite (@normrM _ (h1 x) (h2 x)) mulrACA ler_pmul //; near: x; +rewrite (@normrM _ (h1 x) (h2 x)) mulrACA ler_pM //; near: x; by have [/= h] := littleo; apply. Unshelve. all: by end_near. Qed. @@ -1061,8 +1062,8 @@ Lemma mulO (F : filter_on pT) (h1 h2 f g : pT -> R^o) : Proof. rewrite [RHS]bigOE//; have [ O1 k1 Oh1] := bigO; have [ O2 k2 Oh2] := bigO. near=> k; move: Oh1 Oh2; apply: filter_app2; near=> x => leOh1 leOh2. -rewrite [`|_|]normrM (le_trans (ler_pmul _ _ leOh1 leOh2)) //. -by rewrite mulrACA [`|_| in leRHS]normrM ler_wpmul2r // ?mulr_ge0. +rewrite [`|_|]normrM (le_trans (ler_pM _ _ leOh1 leOh2)) //. +by rewrite mulrACA [`|_| in leRHS]normrM ler_wpM2r // ?mulr_ge0. Unshelve. all: by end_near. Qed. End rule_of_products_rcfType. @@ -1076,8 +1077,8 @@ Lemma mulo_numClosedFieldType (F : filter_on pT) (h1 h2 f g : pT -> R^o) : [o_F h1 of f] * [o_F h2 of g] =o_F (h1 * h2). Proof. rewrite [in RHS]littleoE // => _/posnumP[e]; near=> x. -rewrite [`|_|]normrM -(sqrCK (ge0 e)) expr2 sqrtCM ?qualifE//. -rewrite (@normrM _ (h1 x) (h2 x)) mulrACA ler_pmul //; near: x; +rewrite [`|_|]normrM -(sqrCK (ge0 e)) expr2 sqrtCM ?qualifE//=. +rewrite (@normrM _ (h1 x) (h2 x)) mulrACA ler_pM //; near: x; by have [/= h] := littleo; apply. Unshelve. all: by end_near. Qed. @@ -1086,15 +1087,15 @@ Lemma mulO_numClosedFieldType (F : filter_on pT) (h1 h2 f g : pT -> R^o) : Proof. rewrite [RHS]bigOE//; have [ O1 k1 Oh1] := bigO; have [ O2 k2 Oh2] := bigO. near=> k; move: Oh1 Oh2; apply: filter_app2; near=> x => leOh1 leOh2. -rewrite [`|_|]normrM (le_trans (ler_pmul _ _ leOh1 leOh2)) //. -by rewrite mulrACA [`|_| in leRHS]normrM ler_wpmul2r // ?mulr_ge0. +rewrite [`|_|]normrM (le_trans (ler_pM _ _ leOh1 leOh2)) //. +by rewrite mulrACA [`|_| in leRHS]normrM ler_wpM2r // ?mulr_ge0. Unshelve. all: by end_near. Qed. End rule_of_products_numClosedFieldType. Section Linear3. Context (R : realFieldType) (U : normedModType R) (V : normedModType R) - (s : R -> V -> V) (s_law : GRing.Scale.law s). + (s : GRing.Scale.law R V). Hypothesis (normm_s : forall k x, `|s k x| = `|k| * `|x|). (* Split in multiple bits *) @@ -1105,7 +1106,7 @@ Hypothesis (normm_s : forall k x, `|s k x| = `|k| * `|x|). Local Notation "'+oo'" := (@pinfty_nbhs R). -Lemma linear_for_continuous (f : {linear U -> V | GRing.Scale.op s_law}) : +Lemma linear_for_continuous (f : {linear U -> V | GRing.Scale.Law.sort s}) : (f : _ -> _) =O_ (0 : U) (cst (1 : R^o)) -> continuous f. Proof. move=> /eqO_exP [_/posnumP[k0] Of1] x. @@ -1114,7 +1115,7 @@ rewrite (near_shift 0) /= subr0; near=> y => /=. rewrite -linearB opprD addrC addrNK linearN normrN; near: y. suff flip : \forall k \near +oo, forall x, `|f x| <= k * `|x|. near +oo => k; near=> y. - rewrite (le_lt_trans (near flip k _ _)) // -ltr_pdivl_mull; last first. + rewrite (le_lt_trans (near flip k _ _)) // -ltr_pdivlMl; last first. by near: k; exists 0. near: y; apply/nbhs_normP. eexists; last by move=> ?; rewrite /= sub0r normrN; apply. @@ -1125,18 +1126,17 @@ case: (ler0P `|y|) => [|y0]. by rewrite normr_le0 => /eqP->; rewrite linear0 !normr0 mulr0. have ky0 : 0 <= k0%:num / (k * `|y|). by rewrite pmulr_rge0 // invr_ge0 mulr_ge0 // ltW //; near: k; exists 0. -rewrite -[leRHS]mulr1 -ler_pdivr_mull ?pmulr_rgt0 //. -rewrite -(ler_pmul2l [gt0 of k0%:num]) mulr1 mulrA -[_ / _]ger0_norm //. +rewrite -[leRHS]mulr1 -ler_pdivrMl ?pmulr_rgt0 //. +rewrite -(ler_pM2l [gt0 of k0%:num]) mulr1 mulrA -[_ / _]ger0_norm //. rewrite -normm_s. -have <- : GRing.Scale.op s_law =2 s by rewrite GRing.Scale.opE. -rewrite -linearZ fk //= distrC subr0 normrZ ger0_norm //. -rewrite invfM mulrA mulfVK ?lt0r_neq0 // ltr_pdivr_mulr //. -by rewrite -ltr_pdivr_mull//. +rewrite -linearZ fk //= /= distrC subr0 normrZ ger0_norm //. +rewrite invfM mulrA mulfVK ?lt0r_neq0 // ltr_pdivrMr //. +by rewrite -ltr_pdivrMl//. Unshelve. all: by end_near. Qed. End Linear3. -Arguments linear_for_continuous {R U V s s_law normm_s} f _. +Arguments linear_for_continuous {R U V s normm_s} f _. Lemma linear_continuous (R : realFieldType) (U : normedModType R) (V : normedModType R) (f : {linear U -> V}) : @@ -1144,7 +1144,7 @@ Lemma linear_continuous (R : realFieldType) (U : normedModType R) Proof. by apply: linear_for_continuous => ? ?; rewrite normrZ. Qed. Lemma linear_for_mul_continuous (R : realFieldType) (U : normedModType R) - (f : {linear U -> R | (@GRing.mul [ringType of R^o])}) : + (f : {linear U -> R^o | @GRing.mul R^o}) : (f : _ -> _) =O_ (0 : U) (cst (1 : R^o)) -> continuous f. Proof. by apply: linear_for_continuous => ? ?; rewrite normrZ. Qed. @@ -1166,12 +1166,12 @@ Lemma equivoRL (W' : normedModType K) F (f g : T -> V) (h : T -> W') : f ~_F g -> [o_F g of h] =o_F f. Proof. move=> ->; apply/eqoP; move=> _/posnumP[eps]; near=> x. -rewrite -ler_pdivr_mull // -[X in g + X]opprK oppo. +rewrite -ler_pdivrMl // -[X in g + X]opprK oppo. rewrite (le_trans _ (ler_dist_dist _ _)) //. -rewrite [leRHS]ger0_norm ?ler_subr_addr ?add0r; last first. +rewrite [leRHS]ger0_norm ?lerBrDr ?add0r; last first. by rewrite -[leRHS]mul1r; near: x; apply: littleoP. rewrite [leRHS]splitr [_ / 2]mulrC. -by rewrite ler_add ?ler_pdivr_mull ?mulrA //; near: x; apply: littleoP. +by rewrite lerD ?ler_pdivrMl ?mulrA //; near: x; apply: littleoP. Unshelve. all: by end_near. Qed. Lemma equiv_sym F (f g : T -> V) : f ~_F g -> g ~_F f. @@ -1208,25 +1208,25 @@ Section big_omega. Context {K : realFieldType} {T : Type} {V : normedModType K}. Implicit Types W : normedModType K. -Let bigOmega_def W (F : set (set T)) (f : T -> V) (g : T -> W) := +Let bigOmega_def W (F : set_system T) (f : T -> V) (g : T -> W) := exists2 k, k > 0 & \forall x \near F, `|f x| >= k * `|g x|. -Structure bigOmega_type {W} (F : set (set T)) (g : T -> W) := BigOmega { +Structure bigOmega_type {W} (F : set_system T) (g : T -> W) := BigOmega { bigOmega_fun :> T -> V; _ : `[< bigOmega_def F bigOmega_fun g >] }. Notation "{Omega_ F g }" := (@bigOmega_type _ F g). -Canonical bigOmega_subtype {W} (F : set (set T)) (g : T -> W) := - [subType for (@bigOmega_fun W F g)]. +HB.instance Definition _ {W} (F : set_system T) (g : T -> W) := + [isSub for @bigOmega_fun W F g]. -Lemma bigOmega_class {W} (F : set (set T)) (g : T -> W) (f : {Omega_F g}) : +Lemma bigOmega_class {W} (F : set_system T) (g : T -> W) (f : {Omega_F g}) : `[< bigOmega_def F f g >]. Proof. by case: f => ?. Qed. Hint Resolve bigOmega_class : core. -Definition bigOmega_clone {W} (F : set (set T)) (g : T -> W) (f : T -> V) +Definition bigOmega_clone {W} (F : set_system T) (g : T -> W) (f : T -> V) (fT : {Omega_F g}) c of phant_id (bigOmega_class fT) c := @BigOmega W F g f c. Notation "[bigOmega 'of' f 'for' fT ]" := (@bigOmega_clone _ _ _ f fT _ idfun). Notation "[bigOmega 'of' f ]" := (@bigOmega_clone _ _ _ f _ _ idfun). @@ -1240,7 +1240,7 @@ Definition bigOmega_refl (F : filter_on T) g := BigOmega (asboolT (@bigOmega_refl_subproof F g _)). Definition the_bigOmega (u : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f g := + (phF : phantom (set_system T) F) f g := bigOmega_fun (insubd (bigOmega_refl F g) f). Arguments the_bigOmega : simpl never, clear implicits. @@ -1248,15 +1248,15 @@ Notation mkbigOmega tag x := (the_bigOmega tag _ (PhantomF x)). Notation "[Omega_ x e 'of' f ]" := (mkbigOmega gen_tag x f e). (* parsing *) Notation "[Omega '_' x e 'of' f ]" := (the_bigOmega _ _ (PhantomF x) f e). -Definition is_bigOmega {W} (F : set (set T)) (g : T -> W) := +Definition is_bigOmega {W} (F : set_system T) (g : T -> W) := [qualify f : T -> V | `[< bigOmega_def F f g >] ]. -Fact is_bigOmega_key {W} (F : set (set T)) (g : T -> W) : pred_key (is_bigOmega F g). +Fact is_bigOmega_key {W} (F : set_system T) (g : T -> W) : pred_key (is_bigOmega F g). Proof. by []. Qed. -Canonical is_bigOmega_keyed {W} (F : set (set T)) (g : T -> W) := +Canonical is_bigOmega_keyed {W} (F : set_system T) (g : T -> W) := KeyedQualifier (is_bigOmega_key F g). Notation "'Omega_ F g" := (is_bigOmega F g). -Lemma bigOmegaP {W} (F : set (set T)) (g : T -> W) (f : {Omega_F g}) : +Lemma bigOmegaP {W} (F : set_system T) (g : T -> W) (f : {Omega_F g}) : bigOmega_def F f g. Proof. exact/asboolP. Qed. Hint Extern 0 (bigOmega_def _ _ _) => solve[apply: bigOmegaP] : core. @@ -1267,9 +1267,9 @@ Hint Extern 0 (prop_near2 _) => solve[apply: bigOmegaP] : core. Notation "f '=Omega_' F h" := (f%function = mkbigOmega the_tag F f h). Canonical the_bigOmega_bigOmega (tag : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := [bigOmega of the_bigOmega tag F phF f h]. + (phF : phantom (set_system T) F) f h := [bigOmega of the_bigOmega tag F phF f h]. -Variant bigOmega_spec {W} (F : set (set T)) (g : T -> W) : (T -> V) -> Prop := +Variant bigOmega_spec {W} (F : set_system T) (g : T -> W) : (T -> V) -> Prop := BigOmegaSpec f (k : {posnum K}) of (\forall x \near F, `|f x| >= k%:num * `|g x|) : bigOmega_spec F g f. @@ -1287,8 +1287,8 @@ rewrite propeqE; split => [| /eqO_exP[x x0 Hx] ]; [rewrite qualifE => /asboolP[x x0 Hx]; apply/eqO_exP | rewrite qualifE; apply/asboolP]; exists x^-1; rewrite ?invr_gt0 //; near=> y. - by rewrite ler_pdivl_mull //; near: y. -by rewrite ler_pdivr_mull //; near: y. + by rewrite ler_pdivlMl //; near: y. +by rewrite ler_pdivrMl //; near: y. Unshelve. all: by end_near. Qed. Lemma eqOmegaE (F : filter_on T) (f e : T -> V) : @@ -1324,7 +1324,7 @@ Lemma addOmega (R : realFieldType) (F : filter_on pT) (f g h : _ -> R^o) Proof. rewrite 2!eqOmegaE !eqOmegaO => /eqOP hOf; apply/eqOP. apply: filter_app hOf; near=> k; apply: filter_app; near=> x => /le_trans. -by apply; rewrite ler_pmul2l // !ger0_norm // ?addr_ge0 // ler_addl. +by apply; rewrite ler_pM2l // !ger0_norm // ?addr_ge0 // lerDl. Unshelve. all: by end_near. Qed. Lemma mulOmega (R : realFieldType) (F : filter_on pT) (h1 h2 f g : pT -> R^o) : @@ -1334,10 +1334,10 @@ rewrite eqOmegaE eqOmegaO [in RHS]bigOE //. have [W1 k1 ?] := bigOmega; have [W2 k2 ?] := bigOmega. near=> k; near=> x; rewrite [`|_|]normrM. rewrite (@le_trans _ _ ((k2%:num * k1%:num)^-1 * `|(W1 * W2) x|)) //. - rewrite invrM ?unitfE ?gtr_eqF // -mulrA ler_pdivl_mull //. - rewrite ler_pdivl_mull // (mulrA k1%:num) mulrCA (@normrM _ (W1 x)). - by rewrite ler_pmul ?mulr_ge0 //; near: x. -by rewrite ler_wpmul2r // ltW //. + rewrite invrM ?unitfE ?gtr_eqF // -mulrA ler_pdivlMl //. + rewrite ler_pdivlMl // (mulrA k1%:num) mulrCA (@normrM _ (W1 x)). + by rewrite ler_pM ?mulr_ge0 //; near: x. +by rewrite ler_wpM2r // ltW //. Unshelve. all: by end_near. Qed. End big_omega_in_R. @@ -1347,26 +1347,26 @@ Section big_theta. Context {K : realFieldType} {T : Type} {V : normedModType K}. Implicit Types W : normedModType K. -Let bigTheta_def W (F : set (set T)) (f : T -> V) (g : T -> W) := +Let bigTheta_def W (F : set_system T) (f : T -> V) (g : T -> W) := exists2 k, (k.1 > 0) && (k.2 > 0) & \forall x \near F, k.1 * `|g x| <= `|f x| /\ `|f x| <= k.2 * `|g x|. -Structure bigTheta_type {W} (F : set (set T)) (g : T -> W) := BigTheta { +Structure bigTheta_type {W} (F : set_system T) (g : T -> W) := BigTheta { bigTheta_fun :> T -> V; _ : `[< bigTheta_def F bigTheta_fun g >] }. Notation "{Theta_ F g }" := (@bigTheta_type _ F g). -Canonical bigTheta_subtype {W} (F : set (set T)) (g : T -> W) := - [subType for (@bigTheta_fun W F g)]. +HB.instance Definition _ {W} (F : set_system T) (g : T -> W) := + [isSub for @bigTheta_fun W F g]. -Lemma bigTheta_class {W} (F : set (set T)) (g : T -> W) (f : {Theta_F g}) : +Lemma bigTheta_class {W} (F : set_system T) (g : T -> W) (f : {Theta_F g}) : `[< bigTheta_def F f g >]. Proof. by case: f => ?. Qed. Hint Resolve bigTheta_class : core. -Definition bigTheta_clone {W} (F : set (set T)) (g : T -> W) (f : T -> V) +Definition bigTheta_clone {W} (F : set_system T) (g : T -> W) (f : T -> V) (fT : {Theta_F g}) c of phant_id (bigTheta_class fT) c := @BigTheta W F g f c. Notation "[bigTheta 'of' f 'for' fT ]" := (@bigTheta_clone _ _ _ f fT _ idfun). Notation "[bigTheta 'of' f ]" := (@bigTheta_clone _ _ _ f _ _ idfun). @@ -1380,7 +1380,7 @@ Definition bigTheta_refl (F : filter_on T) g := BigTheta (asboolT (@bigTheta_refl_subproof F g _)). Definition the_bigTheta (u : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f g := + (phF : phantom (set_system T) F) f g := bigTheta_fun (insubd (bigTheta_refl F g) f). Arguments the_bigOmega : simpl never, clear implicits. @@ -1388,15 +1388,15 @@ Notation mkbigTheta tag x := (@the_bigTheta tag _ (PhantomF x)). Notation "[Theta_ x e 'of' f ]" := (mkbigTheta gen_tag x f e). (* parsing *) Notation "[Theta '_' x e 'of' f ]" := (the_bigTheta _ _ (PhantomF x) f e). -Definition is_bigTheta {W} (F : set (set T)) (g : T -> W) := +Definition is_bigTheta {W} (F : set_system T) (g : T -> W) := [qualify f : T -> V | `[< bigTheta_def F f g >] ]. -Fact is_bigTheta_key {W} (F : set (set T)) (g : T -> W) : pred_key (is_bigTheta F g). +Fact is_bigTheta_key {W} (F : set_system T) (g : T -> W) : pred_key (is_bigTheta F g). Proof. by []. Qed. -Canonical is_bigTheta_keyed {W} (F : set (set T)) (g : T -> W) := +Canonical is_bigTheta_keyed {W} (F : set_system T) (g : T -> W) := KeyedQualifier (is_bigTheta_key F g). Notation "'Theta_ F g" := (@is_bigTheta _ F g). -Lemma bigThetaP {W} (F : set (set T)) (g : T -> W) (f : {Theta_F g}) : +Lemma bigThetaP {W} (F : set_system T) (g : T -> W) (f : {Theta_F g}) : bigTheta_def F f g. Proof. exact/asboolP. Qed. Hint Extern 0 (bigTheta_def _ _ _) => solve[apply: bigThetaP] : core. @@ -1405,9 +1405,9 @@ Hint Extern 0 (prop_near1 _) => solve[apply: bigThetaP] : core. Hint Extern 0 (prop_near2 _) => solve[apply: bigThetaP] : core. Canonical the_bigTheta_bigTheta (tag : unit) (F : filter_on T) - (phF : phantom (set (set T)) F) f h := [bigTheta of @the_bigTheta tag F phF f h]. + (phF : phantom (set_system T) F) f h := [bigTheta of @the_bigTheta tag F phF f h]. -Variant bigTheta_spec {W} (F : set (set T)) (g : T -> W) : (T -> V) -> Prop := +Variant bigTheta_spec {W} (F : set_system T) (g : T -> W) : (T -> V) -> Prop := BigThetaSpec f (k1 : {posnum K}) (k2 : {posnum K}) of (\forall x \near F, k1%:num * `|g x| <= `|f x|) & (\forall x \near F, `|f x| <= k2%:num * `|g x|) : @@ -1484,7 +1484,7 @@ rewrite -eqOmegaE; apply: addOmega. - by move=> ?; rewrite /the_bigO val_insubd /=; case: ifP. - rewrite eqOmegaE eqOmegaO; have [T1 k1 k2 ? ?] := bigTheta. rewrite bigOE //; apply/bigO_exP; exists k1%:num^-1 => //. - by near do rewrite ler_pdivl_mull //. + by near do rewrite ler_pdivlMl //. Unshelve. all: by end_near. Qed. Lemma mulTheta (F : filter_on pT) (h1 h2 f g : pT -> R^o) : @@ -1496,10 +1496,10 @@ rewrite eqOmegaO [in RHS]bigOE //. have [T1 k1 l1 P1 ?] := bigTheta; have [T2 k2 l2 P2 ?] := bigTheta. near=> k; first near=> x. rewrite [`|_|]normrM (@le_trans _ _ ((k2%:num * k1%:num)^-1 * `|(T1 * T2) x|)) //. - rewrite invrM ?unitfE ?gtr_eqF // -mulrA ler_pdivl_mull //. - rewrite ler_pdivl_mull // (mulrA k1%:num) mulrCA (@normrM _ (T1 x)) ler_pmul //; + rewrite invrM ?unitfE ?gtr_eqF // -mulrA ler_pdivlMl //. + rewrite ler_pdivlMl // (mulrA k1%:num) mulrCA (@normrM _ (T1 x)) ler_pM //; by [rewrite mulr_ge0 //|near: x]. -by rewrite ler_wpmul2r // ltW //. +by rewrite ler_wpM2r // ltW //. Unshelve. all: by end_near. Qed. End big_theta_in_R. diff --git a/theories/lebesgue_integral.v b/theories/lebesgue_integral.v index 362f7dc41..8b0893855 100644 --- a/theories/lebesgue_integral.v +++ b/theories/lebesgue_integral.v @@ -91,6 +91,13 @@ HB.mixin Record isMeasurableFun d (aT : measurableType d) (rT : realType) }. HB.structure Definition MeasurableFun d aT rT := {f of @isMeasurableFun d aT rT f}. + +(* HB.mixin Record isMeasurableFun d (aT : measurableType d) (rT : realType) (f : aT -> rT) := { *) +(* measurable_funP : measurable_fun setT f *) +(* }. *) +(* #[global] Hint Resolve fimfun_inP : core. *) + +(* HB.structure Definition MeasurableFun d aT rT := {f of @isMeasurableFun d aT rT f}. *) Reserved Notation "{ 'mfun' aT >-> T }" (at level 0, format "{ 'mfun' aT >-> T }"). Reserved Notation "[ 'mfun' 'of' f ]" @@ -100,6 +107,7 @@ Notation "[ 'mfun' 'of' f ]" := [the {mfun _ >-> _} of f] : form_scope. #[global] Hint Resolve measurable_funP : core. HB.structure Definition SimpleFun d (aT : measurableType d) (rT : realType) := +(* HB.structure Definition SimpleFun d (aT (*rT*) : measurableType d) (rT : realType) := *) {f of @isMeasurableFun d aT rT f & @FiniteImage aT rT f}. Reserved Notation "{ 'sfun' aT >-> T }" (at level 0, format "{ 'sfun' aT >-> T }"). @@ -112,6 +120,21 @@ Lemma measurable_sfunP {d} {aT : measurableType d} {rT : realType} (f : {mfun aT >-> rT}) (Y : set rT) : measurable Y -> measurable (f @^-1` Y). Proof. by move=> mY; rewrite -[f @^-1` _]setTI; exact: measurable_funP. Qed. + +HB.mixin Record isNonNegFun (aT : Type) (rT : numDomainType) (f : aT -> rT) := { + fun_ge0 : forall x, 0 <= f x +}. +HB.structure Definition NonNegFun aT rT := {f of @isNonNegFun aT rT f}. +Reserved Notation "{ 'nnfun' aT >-> T }" + (at level 0, format "{ 'nnfun' aT >-> T }"). +Reserved Notation "[ 'nnfun' 'of' f ]" + (at level 0, format "[ 'nnfun' 'of' f ]"). +Notation "{ 'nnfun' aT >-> T }" := (@NonNegFun.type aT T) : form_scope. +Notation "[ 'nnfun' 'of' f ]" := [the {nnfun _ >-> _} of f] : form_scope. +#[global] Hint Extern 0 (is_true (0 <= _)) => solve [apply: fun_ge0] : core. + +(* HB.structure Definition NonNegSimpleFun d (aT : measurableType d) (rT : realType) := *) + HB.structure Definition NonNegSimpleFun d (aT : measurableType d) (rT : realType) := {f of @SimpleFun d _ _ f & @NonNegFun aT rT f}. @@ -122,6 +145,97 @@ Reserved Notation "[ 'nnsfun' 'of' f ]" Notation "{ 'nnsfun' aT >-> T }" := (@NonNegSimpleFun.type _ aT%type T) : form_scope. Notation "[ 'nnsfun' 'of' f ]" := [the {nnsfun _ >-> _} of f] : form_scope. +Section ring. +Context (aT : pointedType) (rT : ringType). + +Lemma fimfun_mulr_closed : mulr_closed (@fimfun aT rT). +Proof. +split=> [|f g]; rewrite !inE/=; first exact: finite_image_cst. +by move=> fA gA; apply: (finite_image11 (fun x y => x * y)). +Qed. +HB.instance Definition _ := GRing.isMulClosed.Build _ fimfun fimfun_mulr_closed. +HB.instance Definition _ := [SubZmodule_isSubRing of {fimfun aT >-> rT} by <:]. + +Implicit Types (f g : {fimfun aT >-> rT}). + +Lemma fimfunM f g : f * g = f \* g :> (_ -> _). Proof. by []. Qed. +Lemma fimfun1 : (1 : {fimfun aT >-> rT}) = cst 1 :> (_ -> _). Proof. by []. Qed. +Lemma fimfun_prod I r (P : {pred I}) (f : I -> {fimfun aT >-> rT}) (x : aT) : + (\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. +Lemma fimfunX f n : f ^+ n = (fun x => f x ^+ n) :> (_ -> _). +Proof. +by apply/funext => x; elim: n => [|n IHn]//; rewrite !exprS fimfunM/= IHn. +Qed. + +Lemma indic_fimfun_subproof X : @FiniteImage aT rT \1_X. +Proof. +split; apply: (finite_subfset [fset 0; 1]%fset) => x [tt /=]. +by rewrite !inE indicE; case: (_ \in _) => _ <-; rewrite ?eqxx ?orbT. +Qed. +HB.instance Definition _ X := indic_fimfun_subproof X. +Definition indic_fimfun (X : set aT) := [the {fimfun aT >-> rT} of \1_X]. + +HB.instance Definition _ k f := FImFun.copy (k \o* f) (f * cst_fimfun k). +Definition scale_fimfun k f := [the {fimfun aT >-> rT} of k \o* f]. + +End ring. +Arguments indic_fimfun {aT rT} _. + +Section comring. +Context (aT : pointedType) (rT : comRingType). +HB.instance Definition _ := [SubRing_isSubComRing of {fimfun aT >-> rT} by <:]. + +Implicit Types (f g : {fimfun aT >-> rT}). +HB.instance Definition _ f g := FImFun.copy (f \* g) (f * g). +End comring. + +Lemma fimfunE T (R : ringType) (f : {fimfun T >-> R}) x : + f x = \sum_(y \in range f) (y * \1_(f @^-1` [set y]) x). +Proof. +rewrite (fsbigD1 (f x))// /= indicE mem_set// mulr1 fsbig1 ?addr0//. +by move=> y [fy /= /nesym yfx]; rewrite indicE memNset ?mulr0. +Qed. + +Lemma fimfunEord T (R : ringType) (f : {fimfun T >-> R}) + (s := fset_set (f @` setT)) : + forall x, f x = \sum_(i < #|`s|) (s`_i * \1_(f @^-1` [set s`_i]) x). +Proof. +move=> x; rewrite fimfunE fsbig_finite//= (big_nth 0)/= big_mkord. +exact: eq_bigr. +Qed. + +Lemma trivIset_preimage1 {aT rT} D (f : aT -> rT) : + trivIset D (fun x => f @^-1` [set x]). +Proof. by move=> y z _ _ [x [<- <-]]. Qed. + +Lemma trivIset_preimage1_in {aT} {rT : choiceType} (D : set rT) (A : set aT) + (f : aT -> rT) : trivIset D (fun x => A `&` f @^-1` [set x]). +Proof. by move=> y z _ _ [x [[_ <-] [_ <-]]]. Qed. + +Section fimfun_bin. +Variables (d : measure_display) (T : measurableType d). +Variables (R : numDomainType) (f g : {fimfun T >-> R}). + +Lemma max_fimfun_subproof : @FiniteImage T R (f \max g). +Proof. by split; apply: (finite_image11 maxr). Qed. +HB.instance Definition _ := max_fimfun_subproof. + +End fimfun_bin. + +HB.factory Record FiniteDecomp (T : pointedType) (R : ringType) (f : T -> R) := + { fimfunE : exists (r : seq R) (A_ : R -> set T), + forall x, f x = \sum_(y <- r) (y * \1_(A_ y) x) }. +HB.builders Context T R f of @FiniteDecomp T R f. + Lemma finite_subproof: @FiniteImage T R f. + Proof. + split; have [r [A_ fE]] := fimfunE. + suff -> : f = \sum_(y <- r) cst_fimfun y * indic_fimfun (A_ y) by []. + by apply/funext=> x; rewrite fE fimfun_sum. + Qed. + HB.instance Definition _ := finite_subproof. +HB.end. + Section mfun_pred. Context {d} {aT : measurableType d} {rT : realType}. Definition mfun : {pred aT -> rT} := mem [set f | measurable_fun setT f]. @@ -150,15 +264,12 @@ Qed. Lemma mfun_valP f (Pf : f \in mfun) : mfun_Sub Pf = f :> (_ -> _). Proof. by []. Qed. -Canonical mfun_subType := SubType T _ _ mfun_rect mfun_valP. +HB.instance Definition _ := isSub.Build _ _ T mfun_rect mfun_valP. Lemma mfuneqP (f g : {mfun aT >-> rT}) : f = g <-> f =1 g. Proof. by split=> [->//|fg]; apply/val_inj/funext. Qed. -Definition mfuneqMixin := [eqMixin of {mfun aT >-> rT} by <:]. -Canonical mfuneqType := EqType {mfun aT >-> rT} mfuneqMixin. -Definition mfunchoiceMixin := [choiceMixin of {mfun aT >-> rT} by <:]. -Canonical mfunchoiceType := ChoiceType {mfun aT >-> rT} mfunchoiceMixin. +HB.instance Definition _ := [Choice of {mfun aT >-> rT} by <:]. Lemma cst_mfun_subproof x : @isMeasurableFun d aT rT (cst x). Proof. by split. Qed. @@ -192,16 +303,9 @@ split=> [|f g|f g]; rewrite !inE/=. - exact: measurable_funB. - exact: measurable_funM. Qed. -Canonical mfun_add := AddrPred mfun_subring_closed. -Canonical mfun_zmod := ZmodPred mfun_subring_closed. -Canonical mfun_mul := MulrPred mfun_subring_closed. -Canonical mfun_subring := SubringPred mfun_subring_closed. -Definition mfun_zmodMixin := [zmodMixin of {mfun aT >-> rT} by <:]. -Canonical mfun_zmodType := ZmodType {mfun aT >-> rT} mfun_zmodMixin. -Definition mfun_ringMixin := [ringMixin of {mfun aT >-> rT} by <:]. -Canonical mfun_ringType := RingType {mfun aT >-> rT} mfun_ringMixin. -Definition mfun_comRingMixin := [comRingMixin of {mfun aT >-> rT} by <:]. -Canonical mfun_comRingType := ComRingType {mfun aT >-> rT} mfun_comRingMixin. +HB.instance Definition _ := GRing.isSubringClosed.Build _ mfun + mfun_subring_closed. +HB.instance Definition _ := [SubChoice_isSubComRing of {mfun aT >-> rT} by <:]. Implicit Types (f g : {mfun aT >-> rT}). @@ -304,15 +408,12 @@ Qed. Lemma sfun_valP f (Pf : f \in sfun) : sfun_Sub Pf = f :> (_ -> _). Proof. by []. Qed. -Canonical sfun_subType := SubType T _ _ sfun_rect sfun_valP. +HB.instance Definition _ := isSub.Build _ _ T sfun_rect sfun_valP. Lemma sfuneqP (f g : {sfun aT >-> rT}) : f = g <-> f =1 g. Proof. by split=> [->//|fg]; apply/val_inj/funext. Qed. -Definition sfuneqMixin := [eqMixin of {sfun aT >-> rT} by <:]. -Canonical sfuneqType := EqType {sfun aT >-> rT} sfuneqMixin. -Definition sfunchoiceMixin := [choiceMixin of {sfun aT >-> rT} by <:]. -Canonical sfunchoiceType := ChoiceType {sfun aT >-> rT} sfunchoiceMixin. +HB.instance Definition _ := [Choice of {sfun aT >-> rT} by <:]. (* TODO: BUG: HB *) (* HB.instance Definition _ (x : rT) := @cst_mfun_subproof aT rT x. *) @@ -344,16 +445,9 @@ by split=> [|f g|f g]; rewrite ?inE/= ?rpred1//; move=> /andP[/= mf ff] /andP[/= mg fg]; rewrite !(rpredB, rpredM). Qed. -Canonical sfun_add := AddrPred sfun_subring_closed. -Canonical sfun_zmod := ZmodPred sfun_subring_closed. -Canonical sfun_mul := MulrPred sfun_subring_closed. -Canonical sfun_subring := SubringPred sfun_subring_closed. -Definition sfun_zmodMixin := [zmodMixin of {sfun aT >-> rT} by <:]. -Canonical sfun_zmodType := ZmodType {sfun aT >-> rT} sfun_zmodMixin. -Definition sfun_ringMixin := [ringMixin of {sfun aT >-> rT} by <:]. -Canonical sfun_ringType := RingType {sfun aT >-> rT} sfun_ringMixin. -Definition sfun_comRingMixin := [comRingMixin of {sfun aT >-> rT} by <:]. -Canonical sfun_comRingType := ComRingType {sfun aT >-> rT} sfun_comRingMixin. +HB.instance Definition _ := GRing.isSubringClosed.Build _ sfun + sfun_subring_closed. +HB.instance Definition _ := [SubChoice_isSubComRing of {sfun aT >-> rT} by <:]. Implicit Types (f g : {sfun aT >-> rT}). @@ -428,8 +522,7 @@ Qed. Section simple_bounded. Context d (T : measurableType d) (R : realType). -Lemma simple_bounded (f : {sfun T >-> R}) : - bounded_fun (f : T -> [normedModType R of R^o]). +Lemma simple_bounded (f : {sfun T >-> R}) : bounded_fun f. Proof. have /finite_seqP[r fr] := fimfunP f. exists (fine (\big[maxe/-oo%E]_(i <- r) `|i|%:E)). @@ -754,7 +847,7 @@ End le_sintegral. Lemma is_cvg_sintegral d (T : measurableType d) (R : realType) (m : {measure set T -> \bar R}) (f : {nnsfun T >-> R}^nat) : - (forall x, nondecreasing_seq (f ^~ x)) -> cvg (sintegral m \o f). + (forall x, nondecreasing_seq (f ^~ x)) -> cvgn (sintegral m \o f). Proof. move=> nd_f; apply/cvg_ex; eexists; apply/ereal_nondecreasing_cvgn => a b ab. by apply: le_sintegral => // => x; exact/nd_f. @@ -780,7 +873,7 @@ Context d (T : measurableType d) (R : realType). Variable mu : {measure set T -> \bar R}. Variables (g : {nnsfun T >-> R}^nat) (f : {nnsfun T >-> R}). Hypothesis nd_g : forall x, nondecreasing_seq (g^~ x). -Hypothesis gf : forall x, cvg (g^~ x) -> f x <= lim (g^~ x). +Hypothesis gf : forall x, cvgn (g^~ x) -> f x <= limn (g^~ x). Let fleg c : (set T)^nat := fun n => [set x | c * f x <= g n x]. @@ -810,7 +903,7 @@ Let g1 c n : {nnsfun T >-> R} := proj_nnsfun f (mfleg c n). Let le_ffleg c : {homo (fun p x => g1 c p x): m n / (m <= n)%N >-> (m <= n)%O}. Proof. -move=> m n mn; apply/asboolP => t; rewrite /g1/= ler_pmul// 2!mindicE/= ler_nat. +move=> m n mn; apply/asboolP => t; rewrite /g1/= ler_pM// 2!mindicE/= ler_nat. have [|//] := boolP (t \in fleg c m); rewrite inE => cnt. by have := nd_fleg c mn => /subsetPset/(_ _ cnt) cmt; rewrite mem_set. Qed. @@ -820,9 +913,9 @@ Proof. move=> c1; rewrite predeqE => x; split=> // _. have := @fun_ge0 _ _ f x; rewrite le_eqVlt => /predU1P[|] gx0. by exists O => //; rewrite /fleg /=; rewrite -gx0 mulr0 fun_ge0. -have [cf|df] := pselect (cvg (g^~ x)). - have cfg : lim (g^~ x) > c * f x. - by rewrite (lt_le_trans _ (gf cf)) // gtr_pmull. +have [cf|df] := pselect (cvgn (g^~ x)). + have cfg : limn (g^~ x) > c * f x. + by rewrite (lt_le_trans _ (gf cf)) // gtr_pMl. suff [n cfgn] : exists n, g n x >= c * f x by exists n. move/(@lt_lim _ _ _ (nd_g x) cf) : cfg => [n _ nf]. by exists n; apply: nf => /=. @@ -832,10 +925,10 @@ Qed. Local Open Scope ereal_scope. -Lemma nd_sintegral_lim_lemma : sintegral mu f <= lim (sintegral mu \o g). +Lemma nd_sintegral_lim_lemma : sintegral mu f <= limn (sintegral mu \o g). Proof. suff ? : forall c, (0 < c < 1)%R -> - c%:E * sintegral mu f <= lim (sintegral mu \o g). + c%:E * sintegral mu f <= limn (sintegral mu \o g). by apply/lee_mul01Pr => //; exact: sintegral_ge0. move=> c /andP[c0 c1]. have cg1g n : c%:E * sintegral mu (g1 c n) <= sintegral mu (g n). @@ -844,14 +937,14 @@ have cg1g n : c%:E * sintegral mu (g1 c n) <= sintegral mu (g n). suff : forall m x, (c * g1 c m x <= g m x)%R by move=> /(_ n t). move=> m x; rewrite /g1 /proj_nnsfun/= mindicE. by have [|] := boolP (_ \in _); [rewrite inE mulr1|rewrite 2!mulr0 fun_ge0]. -suff {cg1g}<- : lim (fun n => sintegral mu (g1 c n)) = sintegral mu f. - have is_cvg_g1 : cvg (fun n => sintegral mu (g1 c n)). +suff {cg1g}<- : limn (fun n => sintegral mu (g1 c n)) = sintegral mu f. + have is_cvg_g1 : cvgn (fun n => sintegral mu (g1 c n)). by apply: is_cvg_sintegral => //= x m n /(le_ffleg c)/lefP/(_ x). rewrite -limeMl // lee_lim//; first exact: is_cvgeMl. - by apply: is_cvg_sintegral => // m n mn; apply/lefP => t; apply: nd_g. - by apply: nearW; exact: cg1g. -suff : (fun n => sintegral mu (g1 c n)) --> sintegral mu f by apply/cvg_lim. -rewrite [X in X --> _](_ : _ = fun n => \sum_(x <- fset_set (range f)) +suff : sintegral mu (g1 c n) @[n \oo] --> sintegral mu f by apply/cvg_lim. +rewrite [X in X @ \oo --> _](_ : _ = fun n => \sum_(x <- fset_set (range f)) x%:E * mu (f @^-1` [set x] `&` fleg c n)); last first. rewrite funeqE => n; rewrite sintegralE. transitivity (\sum_(x \in range f) x%:E * mu (g1 c n @^-1` [set x])). @@ -895,12 +988,12 @@ Context d (T : measurableType d) (R : realType). Variable mu : {measure set T -> \bar R}. Variables (g : {nnsfun T >-> R}^nat) (f : {nnsfun T >-> R}). Hypothesis nd_g : forall x, nondecreasing_seq (g^~ x). -Hypothesis gf : forall x, g ^~ x --> f x. +Hypothesis gf : forall x, g ^~ x @ \oo --> f x. -Let limg x : lim (g^~x) = f x. -Proof. by apply/cvg_lim; [exact: Rhausdorff| exact: gf]. Qed. +Let limg x : limn (g^~ x) = f x. +Proof. by apply/cvg_lim => //; exact: gf. Qed. -Lemma nd_sintegral_lim : sintegral mu f = lim (sintegral mu \o g). +Lemma nd_sintegral_lim : sintegral mu f = limn (sintegral mu \o g). Proof. apply/eqP; rewrite eq_le; apply/andP; split. by apply: nd_sintegral_lim_lemma => // x; rewrite -limg. @@ -1099,17 +1192,17 @@ Variables (mu : {measure set T -> \bar R}) (f : T -> \bar R) Hypothesis f0 : forall x, 0 <= f x. Hypothesis mf : measurable_fun setT f. Hypothesis nd_g : forall x, nondecreasing_seq (g^~x). -Hypothesis gf : forall x, EFin \o g^~x --> f x. +Hypothesis gf : forall x, EFin \o g^~ x @ \oo --> f x. Local Open Scope ereal_scope. -Lemma nd_ge0_integral_lim : \int[mu]_x f x = lim (sintegral mu \o g). +Lemma nd_ge0_integral_lim : \int[mu]_x f x = limn (sintegral mu \o g). Proof. rewrite ge0_integralTE//. apply/eqP; rewrite eq_le; apply/andP; split; last first. apply: lime_le; first exact: is_cvg_sintegral. near=> n; apply: ereal_sup_ub; exists (g n) => //= => x. - have <- : lim (EFin \o g ^~ x) = f x by apply/cvg_lim => //; exact: gf. - have : (EFin \o g ^~ x) --> ereal_sup (range (EFin \o g ^~ x)). + have <- : limn (EFin \o g ^~ x) = f x by apply/cvg_lim => //; exact: gf. + have : EFin \o g ^~ x @ \oo --> ereal_sup (range (EFin \o g ^~ x)). by apply: ereal_nondecreasing_cvgn => p q pq /=; rewrite lee_fin; exact/nd_g. by move/cvg_lim => -> //; apply: ereal_sup_ub; exists n. have := leey (\int[mu]_x (f x)). @@ -1119,22 +1212,22 @@ rewrite le_eqVlt => /predU1P[|] mufoo; last first. apply/lee_addgt0Pr => _/posnumP[e]. have {h} [/= _ [G Gf <-]] := h _ [gt0 of e%:num]. rewrite EFinN lte_subl_addr// => fGe. - have : forall x, cvg (g^~ x) -> (G x <= lim (g ^~ x))%R. + have : forall x, cvgn (g^~ x) -> (G x <= limn (g ^~ x))%R. move=> x cg; rewrite -lee_fin -(EFin_lim cg). by have /cvg_lim gxfx := @gf x; rewrite (le_trans (Gf _))// gxfx. move=> /(nd_sintegral_lim_lemma mu nd_g)/(lee_add2r e%:num%:E). by apply: le_trans; exact: ltW. -suff : lim (sintegral mu \o g) = +oo. +suff : limn (sintegral mu \o g) = +oo. by move=> ->; rewrite -ge0_integralTE// mufoo. apply/eqyP => r r0. have [G [Gf rG]] : exists h : {nnsfun T >-> R}, (forall x, (h x)%:E <= f x) /\ (r%:E <= sintegral mu h). have : r%:E < \int[mu]_x (f x). move: (mufoo) => /eqyP/(_ _ (addr_gt0 r0 r0)). - by apply: lt_le_trans => //; rewrite lte_fin ltr_addr. + by apply: lt_le_trans => //; rewrite lte_fin ltrDr. rewrite ge0_integralTE// => /ereal_sup_gt[x [/= G Gf Gx rx]]. by exists G; split => //; rewrite (le_trans (ltW rx)) // Gx. -have : forall x, cvg (g^~ x) -> (G x <= lim (g^~ x))%R. +have : forall x, cvgn (g^~ x) -> (G x <= limn (g^~ x))%R. move=> x cg; rewrite -lee_fin -(EFin_lim cg). by have /cvg_lim gxfx := @gf x; rewrite (le_trans (Gf _)) // gxfx. by move/(nd_sintegral_lim_lemma mu nd_g) => Gg; rewrite (le_trans rG). @@ -1172,22 +1265,22 @@ rewrite predeqE => r; split => [/= /[!in_itv]/= /andP[nr rn1]|]. rewrite -ltez_nat gez0_abs ?floor_ge0; last first. by rewrite mulr_ge0// (le_trans _ nr). apply: (@le_trans _ _ (floor (n * 2 ^ n.+1)%:R)); last first. - by apply: le_floor; rewrite natrM natrX ler_pmul2r. + by apply: le_floor; rewrite natrM natrX ler_pM2r. by rewrite floor_natz intz. rewrite -ltz_nat gez0_abs; last first. by rewrite floor_ge0 mulr_ge0// (le_trans _ nr). rewrite -(@ltr_int R) (le_lt_trans (floor_le _))//. - by rewrite PoszM intrM -natrX ltr_pmul2r. + by rewrite PoszM intrM -natrX ltr_pM2r. rewrite /= in_itv /=; apply/andP; split. - rewrite ler_pdivr_mulr// (le_trans _ (floor_le _))//. + rewrite ler_pdivrMr// (le_trans _ (floor_le _))//. by rewrite -(@gez0_abs (floor _))// floor_ge0 mulr_ge0// (le_trans _ nr). - rewrite ltr_pdivl_mulr// (lt_le_trans (lt_succ_floor _))//. - rewrite -[in leRHS]natr1 ler_add2r// -(@gez0_abs (floor _))// floor_ge0. + rewrite ltr_pdivlMr// (lt_le_trans (lt_succ_floor _))//. + rewrite -[in leRHS]natr1 lerD2r// -(@gez0_abs (floor _))// floor_ge0. by rewrite mulr_ge0// (le_trans _ nr). - rewrite -bigcup_seq => -[/= k] /[!mem_index_iota] /andP[nk kn]. rewrite in_itv /= => /andP[knr rkn]; rewrite in_itv /=; apply/andP; split. - by rewrite (le_trans _ knr)// ler_pdivl_mulr// -natrX -natrM ler_nat. - by rewrite (lt_le_trans rkn)// ler_pdivr_mulr// -natrX -natrM ler_nat. + by rewrite (le_trans _ knr)// ler_pdivlMr// -natrX -natrM ler_nat. + by rewrite (lt_le_trans rkn)// ler_pdivrMr// -natrX -natrM ler_nat. Qed. Lemma dyadic_itv_image n T (f : T -> \bar R) x : @@ -1243,7 +1336,7 @@ rewrite predeqE => t; split => // -[/=] [_]. rewrite inE => -[r /=]; rewrite in_itv /= => /andP[r1 r2] rft [_]. rewrite inE => -[s /=]; rewrite in_itv /= => /andP[s1 s2]. rewrite -rft => -[sr]; rewrite {}sr {s} in s1 s2. -by have := le_lt_trans s1 r2; rewrite ltr_pmul2r// ltr_nat ltnS leqNgt ij. +by have := le_lt_trans s1 r2; rewrite ltr_pM2r// ltr_nat ltnS leqNgt ij. Qed. Let f0_A0 n (i : 'I_(n * 2 ^ n)) x : f x = 0%:E -> i != O :> nat -> @@ -1251,7 +1344,7 @@ Let f0_A0 n (i : 'I_(n * 2 ^ n)) x : f x = 0%:E -> i != O :> nat -> Proof. move=> fx0 i0; rewrite indicE memNset// /A ltn_ord => -[Dx/=] /[1!inE]/= -[r]. rewrite in_itv/= fx0 => + r0; move/eqP : r0 => /[1!eqe] /eqP -> /andP[+ _]. -by rewrite ler_pdivr_mulr// mul0r lern0 (negbTE i0). +by rewrite ler_pdivrMr// mul0r lern0 (negbTE i0). Qed. Let fgen_A0 n x (i : 'I_(n * 2 ^ n)) : (n%:R%:E <= f x)%E -> @@ -1259,7 +1352,7 @@ Let fgen_A0 n x (i : 'I_(n * 2 ^ n)) : (n%:R%:E <= f x)%E -> Proof. move=> fxn; rewrite indicE /A ltn_ord memNset// => -[Dx/=] /[1!inE]/= -[r]. rewrite in_itv/= => /andP[_ h] rfx; move: fxn; rewrite -rfx lee_fin; apply/negP. -rewrite -ltNge (lt_le_trans h)// -natrX ler_pdivr_mulr// -natrM ler_nat. +rewrite -ltNge (lt_le_trans h)// -natrX ler_pdivrMr// -natrM ler_nat. by rewrite (leq_trans (ltn_ord i)). Qed. @@ -1306,21 +1399,24 @@ rewrite /approx paddr_eq0//; last 2 first. rewrite psumr_eq0//; last by move=> i _; rewrite mulr_ge0. apply/negP => /andP[/allP An0]; rewrite mulf_eq0 => /orP[|]. by apply/negP; near: n; exists 1%N => //= m /=; rewrite lt0n pnatr_eq0. -rewrite indicE mem_set ?oner_eq0// /B /= leNgt; split=> //; apply/negP => fxn. +rewrite pnatr_eq0 => /eqP. +have [//|] := boolP (x \in B n). +rewrite notin_set /B /setI /= => /not_andP[] // /negP. +rewrite -ltNge => fxn _. have K : (`|floor (fine (f x) * 2 ^+ n)| < n * 2 ^ n)%N. rewrite -ltz_nat gez0_abs; last by rewrite floor_ge0 mulr_ge0// ltW. rewrite -(@ltr_int R); rewrite (le_lt_trans (floor_le _))// PoszM intrM. - by rewrite -natrX ltr_pmul2r// -lte_fin (fineK fxfin). + by rewrite -natrX ltr_pM2r// -lte_fin (fineK fxfin). have /[!mem_index_enum]/(_ isT) := An0 (Ordinal K). rewrite implyTb indicE mem_set ?mulr1; last first. rewrite /A K /= inE; split=> //=; exists (fine (f x)); last by rewrite fineK. rewrite in_itv /=; apply/andP; split. - rewrite ler_pdivr_mulr// (le_trans _ (floor_le _))//. + rewrite ler_pdivrMr// (le_trans _ (floor_le _))//. by rewrite -(@gez0_abs (floor _))// floor_ge0 mulr_ge0// ltW. - rewrite ltr_pdivl_mulr// (lt_le_trans (lt_succ_floor _))// -[in leRHS]natr1. - by rewrite ler_add2r// -{1}(@gez0_abs (floor _))// floor_ge0// mulr_ge0// ltW. + rewrite ltr_pdivlMr// (lt_le_trans (lt_succ_floor _))// -[in leRHS]natr1. + by rewrite lerD2r// -{1}(@gez0_abs (floor _))// floor_ge0// mulr_ge0// ltW. rewrite mulf_eq0// -exprVn; apply/negP; rewrite negb_or expf_neq0//= andbT. -rewrite pnatr_eq0 -lt0n absz_gt0 floor_neq0// -ler_pdivr_mulr//. +rewrite pnatr_eq0 -lt0n absz_gt0 floor_neq0// -ler_pdivrMr//. apply/orP; right; apply/ltW; near: n. exact: near_infty_natSinv_expn_lt (PosNum fx_gt0). Unshelve. all: by end_near. Qed. @@ -1380,7 +1476,7 @@ have [fxn|fxn] := ltP (f x) n%:R%:E. rewrite xAn1k mulr1 big1 ?addr0; last first. by move=> i ik2n; rewrite (disj_A0 (Ordinal k2n)) // mulr0. rewrite -(@natr1 _ k.*2) mulrDl exprS -mul2n natrM -mulf_div divrr ?unitfE//. - by rewrite !mul1r ler_addl. + by rewrite !mul1r lerDl. have /orP[{}fxn|{}fxn] : ((n%:R%:E <= f x < n.+1%:R%:E) || (n.+1%:R%:E <= f x))%E. - by move: fxn; case: leP => /= [_ _|_ ->//]; rewrite orbT. @@ -1394,7 +1490,7 @@ have /orP[{}fxn|{}fxn] : have xAn1k : x \in A n.+1 k by rewrite inE /A kn2. rewrite indicE xAn1k mulr1 big1 ?addr0; last first. by move=> i /= ikn2; rewrite (disj_A0 (Ordinal kn2)) // mulr0. - by rewrite -natrX ler_pdivl_mulr// mulrC -natrM ler_nat; case/andP : k1. + by rewrite -natrX ler_pdivlMr// mulrC -natrM ler_nat; case/andP : k1. - have xBn : x \in B n by rewrite /B inE /= (le_trans _ fxn) // lee_fin ler_nat. rewrite /approx indicE xBn mulr1. have xBn1 : x \in B n.+1 by rewrite /B /= inE. @@ -1404,10 +1500,10 @@ have /orP[{}fxn|{}fxn] : Qed. Lemma cvg_approx x (f0 : forall x, D x -> (0 <= f x)%E) : D x -> - (f x < +oo)%E -> (approx^~ x) --> fine (f x). + (f x < +oo)%E -> approx^~ x @ \oo --> fine (f x). Proof. move=> Dx fxoo; have fxfin : f x \is a fin_num by rewrite ge0_fin_numE// f0. -apply/(@cvgrPdist_lt _ [normedModType R of R^o]) => _/posnumP[e]. +apply/(@cvgrPdist_lt _ [the normedModType R of R^o]) => _/posnumP[e]. have [fx0|fx0] := eqVneq (f x) 0%E. by near=> n; rewrite f0_approx0 // fx0 /= subrr normr0. have /(fpos_approx_neq0 Dx)[m _ Hm] : (0 < f x < +oo)%E by rewrite lt0e fx0 f0. @@ -1426,9 +1522,9 @@ have [approx_nx0|[k [/andP[k0 kn2n] ? ->]]] := f_ub_approx fxn. rewrite inE /= => -[r /=]; rewrite in_itv /= => /andP[k1 k2] rfx. rewrite (@le_lt_trans _ _ (1 / 2 ^+ n)) //. rewrite ler_norml; apply/andP; split. - rewrite ler_subr_addl -mulrBl -lee_fin (fineK fxfin) -rfx lee_fin. - by rewrite (le_trans _ k1)// ler_pmul2r// ler_subl_addl ler_addr. - by rewrite ler_subl_addr -mulrDl -lee_fin nat1r fineK// ltW// -rfx lte_fin. + rewrite lerBrDl -mulrBl -lee_fin (fineK fxfin) -rfx lee_fin. + by rewrite (le_trans _ k1)// ler_pM2r// lerBlDl lerDr. + by rewrite lerBlDr -mulrDl -lee_fin nat1r fineK// ltW// -rfx lte_fin. by near: n; exact: near_infty_natSinv_expn_lt. Unshelve. all: by end_near. Qed. @@ -1441,14 +1537,14 @@ have nd_ag : {homo approx ^~ x : n m / (n <= m)%N >-> n <= m}. by move=> m n mn; exact/lefP/nd_approx. have fi0 y : D y -> (0 <= f y)%E by move=> ?; exact: f0. have cvg_af := cvg_approx fi0 Dx fixoo. -have is_cvg_af : cvg (approx ^~ x) by apply/cvg_ex; eexists; exact: cvg_af. +have is_cvg_af : cvgn (approx ^~ x) by apply/cvg_ex; eexists; exact: cvg_af. have {is_cvg_af} := nondecreasing_cvgn_le nd_ag is_cvg_af k. rewrite -lee_fin => /le_trans; apply. rewrite -(@fineK _ (f x)); last by rewrite ge0_fin_numE// f0. by move/(cvg_lim (@Rhausdorff R)) : cvg_af => ->. Qed. -Lemma dvg_approx x : D x -> f x = +oo%E -> ~ cvg (approx^~ x : _ -> R^o). +Lemma dvg_approx x : D x -> f x = +oo%E -> ~ cvgn (approx^~ x : _ -> R^o). Proof. move=> Dx fxoo; have approx_x n : approx n x = n%:R. rewrite /approx foo_B1// mulr1 big1 ?add0r// => /= i _. @@ -1457,23 +1553,23 @@ case/cvg_ex => /= l; have [l0|l0] := leP 0%R l. - move=> /cvgrPdist_lt/(_ _ ltr01) -[n _]. move=> /(_ (`|ceil l|.+1 + n)%N) /= /(_ (leq_addl _ _)). rewrite approx_x. - apply/negP; rewrite -leNgt distrC (le_trans _ (ler_sub_norm_add _ _)) //. - rewrite normrN ler_subr_addl addSnnS [leRHS]ger0_norm ?ler0n//. - rewrite natrD ler_add// ?ler1n// ger0_norm // (le_trans (ceil_ge _)) //. + apply/negP; rewrite -leNgt distrC (le_trans _ (lerB_normD _ _)) //. + rewrite normrN lerBrDl addSnnS [leRHS]ger0_norm ?ler0n//. + rewrite natrD lerD// ?ler1n// ger0_norm // (le_trans (ceil_ge _)) //. by rewrite -(@gez0_abs (ceil _)) // ceil_ge0. - move/cvgrPdist_lt => /(_ _ ltr01) -[n _]. move=> /(_ (`|floor l|.+1 + n)%N) /= /(_ (leq_addl _ _)). rewrite approx_x. - apply/negP; rewrite -leNgt distrC (le_trans _ (ler_sub_norm_add _ _)) //. - rewrite normrN ler_subr_addl addSnnS [leRHS]ger0_norm ?ler0n//. - rewrite natrD ler_add// ?ler1n// ler0_norm //; last by rewrite ltW. + apply/negP; rewrite -leNgt distrC (le_trans _ (lerB_normD _ _)) //. + rewrite normrN lerBrDl addSnnS [leRHS]ger0_norm ?ler0n//. + rewrite natrD lerD// ?ler1n// ler0_norm //; last by rewrite ltW. rewrite (@le_trans _ _ (- floor l)%:~R) //. - by rewrite mulrNz ler_oppl opprK floor_le. + by rewrite mulrNz lerNl opprK floor_le. by rewrite -(@lez0_abs (floor _)) // floor_le0 // ltW. Qed. Lemma ecvg_approx (f0 : forall x, D x -> (0 <= f x)%E) x : - D x -> EFin \o approx^~x --> f x. + D x -> EFin \o approx^~x @ \oo --> f x. Proof. move=> Dx; have := leey (f x); rewrite le_eqVlt => /predU1P[|] fxoo. have dvg_approx := dvg_approx Dx fxoo. @@ -1504,7 +1600,7 @@ by apply: eq_bigr => i _; case: Bool.bool_dec => [h|/negP]; [|rewrite ltn_ord]. Qed. Lemma cvg_nnsfun_approx (f0 : forall x, D x -> (0 <= f x)%E) x : - D x -> EFin \o nnsfun_approx^~x --> f x. + D x -> EFin \o nnsfun_approx^~x @ \oo --> f x. Proof. by move=> Dx; under eq_fun do rewrite nnsfun_approxE; exact: ecvg_approx. Qed. @@ -1517,7 +1613,7 @@ Qed. Lemma approximation : (forall t, D t -> (0 <= f t)%E) -> exists g : {nnsfun T >-> R}^nat, nondecreasing_seq (g : (T -> R)^nat) /\ - (forall x, D x -> EFin \o g^~x --> f x). + (forall x, D x -> EFin \o g^~ x @ \oo --> f x). Proof. exists nnsfun_approx; split; [exact: nd_nnsfun_approx|]. by move=> x Dx; exact: cvg_nnsfun_approx. @@ -1552,9 +1648,9 @@ rewrite (@nd_ge0_integral_lim _ _ _ mu (fun x => k%:E * h1 x) kg). [exact/(lef_at x nd_g)|exact: gh1]. by under eq_fun do rewrite (sintegralrM mu k (g _)). - by move=> t; rewrite mule_ge0. -- by move=> x m n mn; rewrite /kg ler_pmul//; exact/lefP/nd_g. +- by move=> x m n mn; rewrite /kg ler_pM//; exact/lefP/nd_g. - move=> x. - rewrite [X in X --> _](_ : _ = (fun n => k%:E * (g n x)%:E)) ?funeqE//. + rewrite [X in X @ \oo --> _](_ : _ = (fun n => k%:E * (g n x)%:E)) ?funeqE//. by apply: cvgeMl => //; exact: gh1. Qed. @@ -1631,7 +1727,7 @@ have h1tfin : h1 t \is a fin_num. have := gh1 t. rewrite -(fineK h1tfin) => /fine_cvgP[ft_near]. set u_ := (X in X --> _) => u_h1 g1h1. -have <- : lim u_ = fine (h1 t) by apply/cvg_lim => //; exact: Rhausdorff. +have <- : lim u_ = fine (h1 t) by exact/cvg_lim. rewrite lee_fin; apply: nondecreasing_cvgn_le. by move=> // a b ab; rewrite /u_ /=; exact/lefP/nd_g1. by apply/cvg_ex; eexists; exact: u_h1. @@ -1644,14 +1740,14 @@ Context d (T : measurableType d) (R : realType) (f : T -> \bar R). Variables (D : set T) (mD : measurable D) (mf : measurable_fun D f). Lemma approximation_sfun : - exists g : {sfun T >-> R}^nat, (forall x, D x -> EFin \o g^~x --> f x). + exists g : {sfun T >-> R}^nat, (forall x, D x -> EFin \o g^~ x @ \oo --> f x). Proof. have [fp_ [fp_nd fp_cvg]] := approximation mD (measurable_funepos mf) (fun=> ltac:(by [])). have [fn_ [fn_nd fn_cvg]] := approximation mD (measurable_funeneg mf) (fun=> ltac:(by [])). exists (fun n => [the {sfun T >-> R} of fp_ n \+ cst (-1) \* fn_ n]) => x /=. -rewrite [X in X --> _](_ : _ = +rewrite [X in X @ \oo --> _](_ : _ = EFin \o fp_^~ x \+ (-%E \o EFin \o fn_^~ x))%E; last first. by apply/funext => n/=; rewrite EFinD mulN1r. by move=> Dx; rewrite (funeposneg f); apply: cvgeD; @@ -1701,7 +1797,7 @@ exists (\bigcup_(i in range f) dK i); split. apply: (@lee_fsum _ _ _ _ (fun=> (eps%:num / N.+1%:R)%:E * 1%:E)) => //. by move=> i ?; rewrite mule1; apply: ltW; have [_ _] := dkP i. rewrite /=-ge0_mule_fsumr // -esum_fset // finite_card_sum // -EFinM lte_fin. - by rewrite rfN -mulrA gtr_pmulr // mulrC ltr_pdivr_mulr // mul1r ltr_nat. + by rewrite rfN -mulrA gtr_pMr // mulrC ltr_pdivrMr // mul1r ltr_nat. - suff : closed (\bigcup_(i in range f) dK i) /\ {within \bigcup_(i in range f) dK i, continuous f} by case. rewrite -bigsetU_fset_set //. @@ -2011,7 +2107,7 @@ Variables (D : set T) (mD : measurable D) (g' : (T -> \bar R)^nat). Hypothesis mg' : forall n, measurable_fun D (g' n). Hypothesis g'0 : forall n x, D x -> 0 <= g' n x. Hypothesis nd_g' : forall x, D x -> nondecreasing_seq (g'^~ x). -Let f' := fun x => lim (g'^~ x). +Let f' := fun x => limn (g'^~ x). Let g n := (g' n \_ D). @@ -2025,11 +2121,11 @@ Proof. by move=> m n mn; rewrite /g/patch; case: ifP => // /set_mem /nd_g' ->. Qed. -Let f := fun x => lim (g^~ x). +Let f := fun x => limn (g^~ x). -Let is_cvg_g t : cvg (g^~ t). +Let is_cvg_g t : cvgn (g^~ t). Proof. -by move=> ?; apply: ereal_nondecreasing_is_cvgn => m n ?; apply/nd_g. +by move=> ?; apply: ereal_nondecreasing_is_cvgn => m n ?; exact/nd_g. Qed. Local Definition g2' n : (T -> R)^nat := approx setT (g n). @@ -2040,7 +2136,7 @@ Local Definition max_g2' : (T -> R)^nat := Local Definition max_g2 : {nnsfun T >-> R}^nat := fun k => bigmax_nnsfun (g2^~ k) k. -Let is_cvg_g2 n t : cvg (EFin \o (g2 n ^~ t)). +Let is_cvg_g2 n t : cvgn (EFin \o (g2 n ^~ t)). Proof. apply: ereal_nondecreasing_is_cvgn => a b ab. by rewrite lee_fin 2!nnsfun_approxE; exact/lefP/nd_approx. @@ -2059,7 +2155,7 @@ move=> i /=; rewrite neq_lt; apply/orP/idP => [[//|]|]; last by left. by move=> /(leq_trans (ltn_ord i)); rewrite ltnn. Qed. -Let is_cvg_max_g2 t : cvg (EFin \o max_g2 ^~ t). +Let is_cvg_max_g2 t : cvgn (EFin \o max_g2 ^~ t). Proof. apply: ereal_nondecreasing_is_cvgn => m n mn; rewrite lee_fin. exact/lefP/nd_max_g2. @@ -2075,44 +2171,42 @@ apply: le_bigmax2 => i _; rewrite nnsfun_approxE /=. by rewrite (le_trans (le_approx _ _ _)) => //; exact/nd_g/ltnW. Qed. -Let lim_max_g2_f t : lim (EFin \o max_g2 ^~ t) <= f t. -Proof. -apply: lee_lim => //=; [apply: is_cvg_max_g2|apply: is_cvg_g|]. -by near=> n; exact/max_g2_g. +Let lim_max_g2_f t : limn (EFin \o max_g2 ^~ t) <= f t. +Proof. by apply: lee_lim => //=; near=> n; exact/max_g2_g. Unshelve. all: by end_near. Qed. -Let lim_g2_max_g2 t n : lim (EFin\o g2 n ^~ t) <= lim (EFin \o max_g2 ^~ t). +Let lim_g2_max_g2 t n : limn (EFin \o g2 n ^~ t) <= limn (EFin \o max_g2 ^~ t). Proof. -apply: lee_lim => //; [apply: is_cvg_g2|apply: is_cvg_max_g2|]. +apply: lee_lim => //. near=> k; rewrite /= bigmax_nnsfunE lee_fin. have nk : (n < k)%N by near: k; exists n.+1. exact: (bigmax_sup (Ordinal nk)). Unshelve. all: by end_near. Qed. -Let cvg_max_g2_f t : EFin \o max_g2 ^~ t --> f t. +Let cvg_max_g2_f t : EFin \o max_g2 ^~ t @ \oo --> f t. Proof. have /cvg_ex[l g_l] := @is_cvg_max_g2 t. suff : l == f t by move=> /eqP <-. rewrite eq_le; apply/andP; split. by rewrite /f (le_trans _ (lim_max_g2_f _)) // (cvg_lim _ g_l). have := leey l; rewrite le_eqVlt => /predU1P[->|loo]; first by rewrite leey. -rewrite -(cvg_lim _ g_l) //= lime_le => //; first exact: is_cvg_g. +rewrite -(cvg_lim _ g_l) //= lime_le => //. near=> n. have := leey (g n t); rewrite le_eqVlt => /predU1P[|] fntoo. have h := @dvg_approx _ _ _ setT _ t Logic.I fntoo. - have g2oo : lim (EFin \o g2 n ^~ t) = +oo. + have g2oo : limn (EFin \o g2 n ^~ t) = +oo. apply/cvg_lim => //; apply/cvgeryP. under [in X in X --> _]eq_fun do rewrite nnsfun_approxE. have : {homo (approx setT (g n))^~ t : n0 m / (n0 <= m)%N >-> (n0 <= m)%R}. exact/lef_at/nd_approx. by move/nondecreasing_dvgn_lt => /(_ h). - have -> : lim (EFin \o max_g2 ^~ t) = +oo. + have -> : limn (EFin \o max_g2 ^~ t) = +oo. by have := lim_g2_max_g2 t n; rewrite g2oo leye_eq => /eqP. by rewrite leey. - have approx_g_g := @cvg_approx _ _ _ setT _ t (fun t _ => g0 n t) Logic.I fntoo. - suff : lim (EFin \o g2 n ^~ t) = g n t. + suff : limn (EFin \o g2 n ^~ t) = g n t. by move=> <-; exact: (le_trans _ (lim_g2_max_g2 t n)). - have /cvg_lim <- // : EFin \o (approx setT (g n)) ^~ t --> g n t. + have /cvg_lim <- // : EFin \o (approx setT (g n)) ^~ t @ \oo --> g n t. move/cvg_comp : approx_g_g; apply. by rewrite -(@fineK _ (g n t))// ge0_fin_numE// g0. rewrite (_ : _ \o _ = EFin \o approx setT (g n) ^~ t)// funeqE => m. @@ -2120,7 +2214,7 @@ have := leey (g n t); rewrite le_eqVlt => /predU1P[|] fntoo. Unshelve. all: by end_near. Qed. Lemma monotone_convergence : - \int[mu]_(x in D) (f' x) = lim (fun n => \int[mu]_(x in D) (g' n x)). + \int[mu]_(x in D) (f' x) = limn (fun n => \int[mu]_(x in D) (g' n x)). Proof. rewrite integral_mkcond. under [in RHS]eq_fun do rewrite integral_mkcond -/(g _). @@ -2133,16 +2227,16 @@ apply/eqP; rewrite eq_le; apply/andP; split; last first. by move=> *; exact: nd_g. have ub n : \int[mu]_x g n x <= \int[mu]_x f x. apply: ge0_le_integral => //. - - move=> x _; apply: lime_ge => //; first exact: is_cvg_g. + - move=> x _; apply: lime_ge => //. by apply: nearW => k; exact/g0. - apply: emeasurable_fun_cvg mg _ => x _. exact: ereal_nondecreasing_is_cvgn. - - move=> x Dx; apply: lime_ge => //; first exact: is_cvg_g. + - move=> x Dx; apply: lime_ge => //. near=> m; have nm : (n <= m)%N by near: m; exists n. exact/nd_g. by apply: lime_le => //; [exact:ereal_nondecreasing_is_cvgn|exact:nearW]. rewrite (@nd_ge0_integral_lim _ _ _ mu _ max_g2) //; last 2 first. - - move=> t; apply: lime_ge => //; first exact: is_cvg_g. + - move=> t; apply: lime_ge => //. by apply: nearW => n; exact: g0. - by move=> t m n mn; exact/lefP/nd_max_g2. apply: lee_lim. @@ -2154,7 +2248,7 @@ apply: lee_lim. Unshelve. all: by end_near. Qed. Lemma cvg_monotone_convergence : - (fun n => \int[mu]_(x in D) g' n x) --> \int[mu]_(x in D) f' x. + \int[mu]_(x in D) g' n x @[n \oo] --> \int[mu]_(x in D) f' x. Proof. rewrite monotone_convergence; apply: ereal_nondecreasing_is_cvgn => m n mn. by apply: ge0_le_integral => // t Dt; [exact: g'0|exact: g'0|exact: nd_g']. @@ -2201,8 +2295,8 @@ have g0 n x : D x -> 0 <= g n x. by move=> Dx; apply: mule_ge0; [rewrite lee_fin|exact:f0]. have nd_g x : D x -> nondecreasing_seq (g^~x). by move=> Dx m n mn; rewrite lee_wpmul2r ?f0// lee_fin ler_nat. -pose h := fun x => lim (g^~ x). -transitivity (\int[mu]_(x in D) lim (g^~ x)). +pose h := fun x => limn (g^~ x). +transitivity (\int[mu]_(x in D) limn (g^~ x)). apply: eq_integral => x Dx; apply/esym/cvg_lim => //. have [fx0|fx0|fx0] := ltgtP 0 (f x). - rewrite gt0_mulye//; apply/cvgeyPgey; near=> M. @@ -2210,7 +2304,7 @@ transitivity (\int[mu]_(x in D) lim (g^~ x)). rewrite /g; case: (f x) fx0 => [r r0|_|//]; last first. exists 1%N => // m /= m0. by rewrite mulry gtr0_sg// ?mul1e ?leey// ltr0n. - near=> n; rewrite lee_fin -ler_pdivr_mulr//. + near=> n; rewrite lee_fin -ler_pdivrMr//. near: n; exists `|ceil (M / r)|%N => // m /=. rewrite -(ler_nat R); apply: le_trans. by rewrite natr_absz ger0_norm ?ceil_ge// ceil_ge0// divr_ge0// ?ltW. @@ -2219,11 +2313,11 @@ transitivity (\int[mu]_(x in D) lim (g^~ x)). rewrite /g; case: (f x) fx0 => [r r0|//|_]; last first. exists 1%N => // m /= m0. by rewrite mulrNy gtr0_sg// ?ltr0n// mul1e ?leNye. - near=> n; rewrite lee_fin -ler_ndivr_mulr//. + near=> n; rewrite lee_fin -ler_ndivrMr//. near: n; exists `|ceil (M / r)|%N => // m /=. rewrite -(ler_nat R); apply: le_trans. rewrite natr_absz ger0_norm ?ceil_ge// ceil_ge0// -mulrNN. - by rewrite mulr_ge0// ler_oppr oppr0// ltW// invr_lt0. + by rewrite mulr_ge0// lerNr oppr0// ltW// invr_lt0. - rewrite -fx0 mule0 /g -fx0 [X in X @ _ --> _](_ : _ = cst 0). exact: cvg_cst. by rewrite funeqE => n /=; rewrite mule0. @@ -2338,21 +2432,21 @@ Lemma ge0_integral_mscale (mf : measurable_fun D f) : \int[mscale k m]_(x in D) f x = k%:num%:E * \int[m]_(x in D) f x. Proof. move=> f0; have [f_ [ndf_ f_f]] := approximation mD mf f0. -transitivity (lim (fun n => \int[mscale k m]_(x in D) (f_ n x)%:E)). +transitivity (limn (fun n => \int[mscale k m]_(x in D) (f_ n x)%:E)). rewrite -monotone_convergence//=. - by apply: eq_integral => x /[!inE] xD; apply/esym/cvg_lim => //=; exact: f_f. - by move=> n; exact/EFin_measurable_fun/measurable_funTS. - by move=> n x _; rewrite lee_fin. - by move=> x _ a b /ndf_ /lefP; rewrite lee_fin. rewrite (_ : \int[m]_(x in D) _ = - lim (fun n => \int[m]_(x in D) (f_ n x)%:E)); last first. + limn (fun n => \int[m]_(x in D) (f_ n x)%:E)); last first. rewrite -monotone_convergence//=. - by apply: eq_integral => x /[!inE] xD; apply/esym/cvg_lim => //; exact: f_f. - by move=> n; exact/EFin_measurable_fun/measurable_funTS. - by move=> n x _; rewrite lee_fin. - by move=> x _ a b /ndf_ /lefP; rewrite lee_fin. rewrite -limeMl//. - by congr (lim _); apply/funext => n /=; rewrite integral_mscale_nnsfun. + by congr (limn _); apply/funext => n /=; rewrite integral_mscale_nnsfun. apply/ereal_nondecreasing_is_cvgn => a b ab; apply: ge0_le_integral => //. - by move=> x _; rewrite lee_fin. - exact/EFin_measurable_fun/measurable_funTS. @@ -2417,8 +2511,8 @@ rewrite fin_numE negb_and 2!negbK => /orP[nfoo|/eqP nfoo]. exfalso; move/negP : nfoo; apply; rewrite -leeNy_eq; apply/negP. by rewrite -ltNge (lt_le_trans _ (integral_ge0 _ _)). rewrite nfoo adde_defEninfty -leye_eq -ltNge ltey_eq => /orP[f_fin|/eqP pfoo]. - rewrite integralE// [in RHS]integralE// nfoo [in RHS]addeC fin_num_oppeD//. - by rewrite funenegN. + rewrite integralE [in RHS]integralE nfoo [in RHS]addeC/= funenegN. + by rewrite addye// eqe_oppLR/= (andP (eqbLR (fin_numE _) f_fin)).2. by rewrite integralE// [in RHS]integralE// funeposN funenegN nfoo pfoo. Qed. @@ -2464,7 +2558,7 @@ Qed. Local Lemma integral_csty : mu D != 0 -> \int[mu]_(x in D) (cst +oo) x = +oo. Proof. move=> muD0; pose g : (T -> \bar R)^nat := fun n => cst n%:R%:E. -have <- : (fun t => lim (g^~ t)) = cst +oo. +have <- : (fun t => limn (g^~ t)) = cst +oo. rewrite funeqE => t; apply/cvg_lim => //=. apply/cvgeryP/cvgryPge => M; exists `|ceil M|%N => //= m. rewrite /= -(ler_nat R); apply: le_trans. @@ -2504,7 +2598,7 @@ Lemma integral_pushforward (f : Y -> \bar R) : Proof. move=> mf f0. have [f_ [ndf_ f_f]] := approximation measurableT mf (fun t _ => f0 t). -transitivity (lim (fun n => \int[pushforward mu mphi]_x (f_ n x)%:E)). +transitivity (limn (fun n => \int[pushforward mu mphi]_x (f_ n x)%:E)). rewrite -monotone_convergence//. - by apply: eq_integral => y _; apply/esym/cvg_lim => //; exact: f_f. - by move=> n; exact/EFin_measurable_fun. @@ -2548,7 +2642,7 @@ Let ge0_integral_dirac (f : T -> \bar R) (mf : measurable_fun D f) D a -> \int[\d_a]_(x in D) (f x) = f a. Proof. move=> Da; have [f_ [ndf_ f_f]] := approximation mD mf f0. -transitivity (lim (fun n => \int[\d_ a]_(x in D) (f_ n x)%:E)). +transitivity (limn (fun n => \int[\d_ a]_(x in D) (f_ n x)%:E)). rewrite -monotone_convergence//. - apply: eq_integral => x Dx; apply/esym/cvg_lim => //; apply: f_f. by rewrite inE in Dx. @@ -2660,18 +2754,19 @@ rewrite (_ : _ m_ N.+1 = measure_add [the measure _ _ of msum m_ N] (m_ N)); las have mf_ n : measurable_fun D (fun x => (f_ n x)%:E). exact/measurable_funTS/EFin_measurable_fun. have f_ge0 n x : D x -> 0 <= (f_ n x)%:E by move=> Dx; rewrite lee_fin. -have cvg_f_ (m : {measure set T -> \bar R}) : cvg (fun x => \int[m]_(x0 in D) (f_ x x0)%:E). +have cvg_f_ (m : {measure set T -> \bar R}) : + cvgn (fun x => \int[m]_(x0 in D) (f_ x x0)%:E). apply: ereal_nondecreasing_is_cvgn => a b ab. apply: ge0_le_integral => //; [exact: f_ge0|exact: f_ge0|]. by move=> t Dt; rewrite lee_fin; apply/lefP/f_nd. -transitivity (lim (fun n => - \int[measure_add [the measure _ _ of msum m_ N] (m_ N)]_(x in D) (f_ n x)%:E)). +transitivity (limn (fun n => + \int[measure_add (msum m_ N) (m_ N)]_(x in D) (f_ n x)%:E)). rewrite -monotone_convergence//; last first. by move=> t Dt a b ab; rewrite lee_fin; exact/lefP/f_nd. by apply: eq_integral => t /[!inE] Dt; apply/esym/cvg_lim => //; exact: f_f. -transitivity (lim (fun n => +transitivity (limn (fun n => \int[msum m_ N]_(x in D) (f_ n x)%:E + \int[m_ N]_(x in D) (f_ n x)%:E)). - by congr (lim _); apply/funext => n; by rewrite integral_measure_add_nnsfun. + by congr (limn _); apply/funext => n; by rewrite integral_measure_add_nnsfun. rewrite limeD//; do?[exact: cvg_f_]; last first. by apply: ge0_adde_def; rewrite inE; apply: lime_ge => //; do?[exact: cvg_f_]; apply: nearW => n; apply: integral_ge0 => //; exact: f_ge0. @@ -2723,7 +2818,8 @@ rewrite fsbig_finite//= -nneseries_sum; last first. move=> r j _. have [r0|r0] := leP 0%R r. by rewrite mule_ge0//; apply: integral_ge0 => // t _; rewrite lee_fin. - by rewrite integral0_eq// => x _; rewrite preimage_nnfun0// indicE in_set0. + rewrite integral0_eq ?mule0// => x _. + by rewrite preimage_nnfun0// indicE in_set0. apply: eq_eseriesr => k _. rewrite integralT_nnsfun sintegralE fsbig_finite//=; apply: eq_bigr => r _. by congr (_ * _); rewrite integral_indic// setIT. @@ -2947,6 +3043,7 @@ move=> /integrableP[mf foo] /integrableP[mg goo]; apply/integrableP; split. apply: (@le_lt_trans _ _ (\int[mu]_(x in D) (`|f x| + `|g x|))). apply: ge0_le_integral => //. - by apply: measurableT_comp => //; exact: emeasurable_funD. + - by move=> ? ?; apply: adde_ge0. - by apply: emeasurable_funD; apply: measurableT_comp. - by move=> *; exact: lee_abs_add. by rewrite ge0_integralD //; [exact: lte_add_pinfty| @@ -3127,7 +3224,7 @@ Lemma ge0_integral_bigcup (F : (set _)^nat) (f : T -> \bar R) : Proof. move=> mF D /integrableP fi f0 tF. pose f_ N := f \_ (\big[setU/set0]_(0 <= i < N) F i). -have lim_f_ t : f_ ^~ t --> (f \_ D) t. +have lim_f_ t : f_ ^~ t @ \oo --> (f \_ D) t. rewrite [X in _ --> X](_ : _ = ereal_sup (range (f_ ^~ t))); last first. apply/eqP; rewrite eq_le; apply/andP; split. rewrite /restrict; case: ifPn => [|_]. @@ -3140,7 +3237,7 @@ have lim_f_ t : f_ ^~ t --> (f \_ D) t. apply: ereal_nondecreasing_cvgn => a b ab. rewrite /f_ !big_mkord restrict_lee //; last exact: subset_bigsetU. by move=> x Dx; apply: f0 => //; exact: bigsetU_bigcup Dx. -transitivity (\int[mu]_x lim (f_ ^~ x)). +transitivity (\int[mu]_x limn (f_ ^~ x)). rewrite integral_mkcond; apply: eq_integral => x _. by apply/esym/cvg_lim => //; exact: lim_f_. rewrite monotone_convergence//; last 3 first. @@ -3153,10 +3250,9 @@ rewrite monotone_convergence//; last 3 first. - move=> x _ a b ab; apply: restrict_lee. by move=> y; rewrite big_mkord => Dy; apply: f0; exact: bigsetU_bigcup Dy. by rewrite 2!big_mkord; apply: subset_bigsetU. -transitivity (lim (fun N => \int[mu]_(x in \big[setU/set0]_(i < N) F i) f x)). - congr (lim _); rewrite funeqE => n. - by rewrite /f_ [in RHS]integral_mkcond big_mkord. -congr (lim _); rewrite funeqE => /= n. +transitivity (limn (fun N => \int[mu]_(x in \big[setU/set0]_(i < N) F i) f x)). + by apply/congr_lim/funext => n; rewrite /f_ [in RHS]integral_mkcond big_mkord. +apply/congr_lim/funext => /= n. rewrite -(big_mkord xpredT) ge0_integral_bigsetU ?big_mkord//. - exact: iota_uniq. - exact: sub_trivIset tF. @@ -3202,7 +3298,7 @@ have [k0|k0] := leP 0 k. exact: fin_num_measure. - under eq_integral do rewrite /= ltr0_norm//. rewrite integral_cstr//= lte_mul_pinfty//. - by rewrite lee_fin ler_oppr oppr0 ltW. + by rewrite lee_fin lerNr oppr0 ltW. by rewrite fin_num_fun_lty//; exact: fin_num_measure. Qed. @@ -3255,9 +3351,9 @@ exists `|ceil (M * (fine (mu (E `&` D)))^-1)|%N.+1. apply/negP; rewrite -ltNge. rewrite -[X in _ * X](@fineK _ (mu (E `&` D))); last first. by rewrite fin_numElt muEDoo (lt_le_trans _ (measure_ge0 _ _)). -rewrite lte_fin -ltr_pdivr_mulr. +rewrite lte_fin -ltr_pdivrMr. rewrite -natr1 natr_absz ger0_norm. - by rewrite (le_lt_trans (ceil_ge _))// ltr_addl. + by rewrite (le_lt_trans (ceil_ge _))// ltrDl. by rewrite ceil_ge0// divr_ge0//; apply/le0R/measure_ge0; exact: measurableI. rewrite -lte_fin fineK. rewrite lt0e measure_ge0 andbT. @@ -3292,10 +3388,10 @@ have [r0|r0|->] := ltgtP r 0%R; last first. - rewrite [in LHS]integralE// lt0_funeposM// lt0_funenegM//. rewrite ge0_integralZl_EFin //; last 2 first. + exact: measurable_funeneg. - + by rewrite -ler_oppr oppr0 ltW. + + by rewrite -lerNr oppr0 ltW. rewrite ge0_integralZl_EFin //; last 2 first. + exact: measurable_funepos. - + by rewrite -ler_oppr oppr0 ltW. + + by rewrite -lerNr oppr0 ltW. rewrite -mulNe -EFinN opprK addeC EFinN mulNe -muleBr //; last first. exact: integrable_add_def. by rewrite [in RHS]integralE. @@ -3347,14 +3443,13 @@ suff: \int[mu]_(x in D) ((g1 \+ g2)^\+ x) + \int[mu]_(x in D) (g1^\- x) + by rewrite adde_ge0// integral_ge0. - by rewrite fin_num_adde_defr. rewrite -(addeA (\int[mu]_(x in D) (g1 \+ g2)^\+ x)). - rewrite (addeC (\int[mu]_(x in D) (g1 \+ g2)^\+ x)). - rewrite -addeA (addeC (\int[mu]_(x in D) g1^\- x + \int[mu]_(x in D) g2^\- x)). + rewrite (addeC (\int[mu]_(x in D) (g1 \+ g2)^\+ x)) -[eqbLHS]addeA. + rewrite (addeC (\int[mu]_(x in D) g1^\- x + \int[mu]_(x in D) g2^\- x)). rewrite eq_sym -(sube_eq g12pos) ?fin_num_adde_defl// => /eqP <-. rewrite fin_num_oppeD; last first. rewrite ge0_fin_numE; first exact: integral_funeneg_lt_pinfty if2. exact: integral_ge0. - rewrite -addeA (addeCA (\int[mu]_(x in D) (g2^\+ x) )). - by rewrite addeA -(integralE _ _ g1) -(integralE _ _ g2). + by rewrite addeACA (integralE _ _ g1) (integralE _ _ g2). have : (g1 \+ g2)^\+ \+ g1^\- \+ g2^\- = (g1 \+ g2)^\- \+ g1^\+ \+ g2^\+. rewrite funeqE => x. apply/eqP; rewrite -2!addeA [in eqRHS]addeC -sube_eq; last 2 first. @@ -3503,25 +3598,25 @@ move=> mf; split=> [iDf0|Df0]. pose m := `|ceil (fine `|f t|)^-1|%N. have ftfin : `|f t|%E \is a fin_num by rewrite ge0_fin_numE// ltey. exists m => //; split => //=. - rewrite -(@fineK _ `|f t|) // lee_fin -ler_pinv; last 2 first. + rewrite -(@fineK _ `|f t|) // lee_fin -ler_pV2; last 2 first. - rewrite inE unitfE fine_eq0// abse_eq0 ft0/= fine_gt0//. by rewrite lt0e abse_ge0 abse_eq0 ft0 ltey. - by rewrite inE unitfE invr_eq0 pnatr_eq0 /= invr_gt0. rewrite invrK /m -natr1 natr_absz ger0_norm ?ceil_ge0//. - rewrite (@le_trans _ _ ((fine `|f t|)^-1 + 1)%R) ?ler_addl//. - by rewrite ler_add2r// ceil_ge. + rewrite (@le_trans _ _ ((fine `|f t|)^-1 + 1)%R) ?lerDl//. + by rewrite lerD2r// ceil_ge. by split => //; apply: contraTN nft => /eqP ->; rewrite abse0 -ltNge. - transitivity (lim (fun n => mu (D `&` [set x | `|f x| >= n.+1%:R^-1%:E]))). + transitivity (limn (fun n => mu (D `&` [set x | `|f x| >= n.+1%:R^-1%:E]))). apply/esym/cvg_lim => //; apply: nondecreasing_cvg_mu. - move=> i; apply: emeasurable_fun_c_infty => //. exact: measurableT_comp. - apply: bigcupT_measurable => i. by apply: emeasurable_fun_c_infty => //; exact: measurableT_comp. - move=> m n mn; apply/subsetPset; apply: setIS => t /=. - by apply: le_trans; rewrite lee_fin lef_pinv // ?ler_nat // posrE. + by apply: le_trans; rewrite lee_fin lef_pV2 // ?ler_nat // posrE. by rewrite (_ : (fun _ => _) = cst 0) ?lim_cst//= funeqE => n /=; rewrite muDf. pose f_ := fun n x => mine `|f x| n%:R%:E. -have -> : (fun x => `|f x|) = (fun x => lim (f_^~ x)). +have -> : (fun x => `|f x|) = (fun x => limn (f_^~ x)). rewrite funeqE => x; apply/esym/cvg_lim => //; apply/cvg_ballP => _/posnumP[e]. near=> n; rewrite /ball /= /ereal_ball /= /f_. have [->|fxoo] := eqVneq `|f x|%E +oo. @@ -3533,7 +3628,7 @@ have -> : (fun x => `|f x|) = (fun x => lim (f_^~ x)). rewrite lee_fin; near: n; exists (Num.bound (fine `|f x|)) => //= n/=. by rewrite -(ler_nat R); apply: le_trans; exact/ltW/archi_boundP. by rewrite min_l// subrr normr0. -transitivity (lim (fun n => \int[mu]_(x in D) (f_ n x) )). +transitivity (limn (fun n => \int[mu]_(x in D) (f_ n x) )). apply/esym/cvg_lim => //; apply: cvg_monotone_convergence => //. - by move=> n; apply: measurable_mine => //; exact: measurableT_comp. - by move=> n t Dt; rewrite /f_ lexI abse_ge0 //= lee_fin. @@ -3621,6 +3716,7 @@ have h1 : mu.-integrable D f <-> mu.-integrable D (fun x => f x * (oneCN x)%:E). (\int[mu]_(x in D) (`|f x * (oneCN x)%:E| + `|f x * (oneN x)%:E|))). apply: ge0_le_integral => //. - by apply: measurableT_comp => //; exact: emeasurable_funD. + - by move=> ? ?; apply: adde_ge0. - by apply: emeasurable_funD; exact: measurableT_comp. - by move=> *; rewrite lee_abs_add. rewrite ge0_integralD//; [|exact: measurableT_comp|exact: measurableT_comp]. @@ -4038,7 +4134,7 @@ Context d (T : measurableType d) (R : realType). Variables (mu : {measure set T -> \bar R}) (D : set T) (mD : measurable D). Variables (f_ : (T -> \bar R)^nat) (f : T -> \bar R) (g : T -> \bar R). Hypothesis mf_ : forall n, measurable_fun D (f_ n). -Hypothesis f_f : forall x, D x -> f_ ^~ x --> f x. +Hypothesis f_f : forall x, D x -> f_ ^~ x @ \oo --> f x. Hypothesis fing : forall x, D x -> g x \is a fin_num. Hypothesis ig : mu.-integrable D g. Hypothesis absfg : forall n x, D x -> `|f_ n x| <= g x. @@ -4065,7 +4161,7 @@ Qed. Let g_ n x := `|f_ n x - f x|. -Let cvg_g_ x : D x -> g_ ^~ x --> 0. +Let cvg_g_ x : D x -> g_ ^~ x @ \oo --> 0. Proof. move=> Dx; rewrite -abse0; apply: cvg_abse. move: (f_f Dx); case: (f x) => [r|/=|/=]. @@ -4102,7 +4198,7 @@ Qed. Let gg_ge0 n x : D x -> 0 <= 2%:E * g x - g_ n x. Proof. by move=> Dx; rewrite gg_. Qed. -Local Lemma dominated_cvg0 : [sequence \int[mu]_(x in D) g_ n x]_n --> 0. +Local Lemma dominated_cvg0 : [sequence \int[mu]_(x in D) g_ n x]_n @ \oo --> 0. Proof. have := fatou mu mD mgg gg_ge0. rewrite [X in X <= _ -> _](_ : _ = \int[mu]_(x in D) (2%:E * g x) ); last first. @@ -4144,14 +4240,14 @@ by apply/limn_esup_le_cvg => // n; rewrite integral_ge0// => x _; rewrite /g_. Qed. Local Lemma dominated_cvg : - (fun n => \int[mu]_(x in D) f_ n x) --> \int[mu]_(x in D) f x. + \int[mu]_(x in D) f_ n x @[n \oo] --> \int[mu]_(x in D) f x. Proof. have h n : `| \int[mu]_(x in D) f_ n x - \int[mu]_(x in D) f x | <= \int[mu]_(x in D) g_ n x. rewrite -(integralB _ _ dominated_integrable)//; last first. by apply: le_integrable ig => // x Dx /=; rewrite (gee0_abs (g0 Dx)) absfg. by apply: le_abse_integral => //; exact: emeasurable_funB. -suff: (fun n => `| \int[mu]_(x in D) f_ n x - \int[mu]_(x in D) f x |) --> 0. +suff: `| \int[mu]_(x in D) f_ n x - \int[mu]_(x in D) f x | @[n \oo] --> 0. move/cvg_abse0P/cvge_sub0; apply. rewrite fin_numElt (_ : -oo = - +oo)// -lte_absl. move: dominated_integrable => /integrableP[?]; apply: le_lt_trans. @@ -4172,15 +4268,15 @@ Variables (mu : {measure set T -> \bar R}) (D : set T) (mD : measurable D). Variables (f_ : (T -> \bar R)^nat) (f : T -> \bar R) (g : T -> \bar R). Hypothesis mf_ : forall n, measurable_fun D (f_ n). Hypothesis mf : measurable_fun D f. -Hypothesis f_f : {ae mu, forall x, D x -> f_ ^~ x --> f x}. +Hypothesis f_f : {ae mu, forall x, D x -> f_ ^~ x @ \oo --> f x}. Hypothesis ig : mu.-integrable D g. Hypothesis f_g : {ae mu, forall x n, D x -> `|f_ n x| <= g x}. Let g_ n x := `|f_ n x - f x|. Theorem dominated_convergence : [/\ mu.-integrable D f, - [sequence \int[mu]_(x in D) (g_ n x)]_n --> 0 & - [sequence \int[mu]_(x in D) (f_ n x)]_n --> \int[mu]_(x in D) (f x) ]. + [sequence \int[mu]_(x in D) (g_ n x)]_n @ \oo --> 0 & + [sequence \int[mu]_(x in D) (f_ n x)]_n @ \oo --> \int[mu]_(x in D) (f x) ]. Proof. have [N1 [mN1 N10 subN1]] := f_f. have [N2 [mN2 N20 subN2]] := f_g. @@ -4191,7 +4287,7 @@ have N0 : mu N = 0. by rewrite null_set_setU// ?null_set_setU//; exact: measurableU. pose f' := f \_ (D `\` N); pose g' := g \_ (D `\` N). pose f_' := fun n => f_ n \_ (D `\` N). -have f_f' x : D x -> f_' ^~ x --> f' x. +have f_f' x : D x -> f_' ^~ x @ \oo --> f' x. move=> Dx; rewrite /f_' /f' /restrict in_setD mem_set//=. have [/= xN|/= xN] := boolP (x \in N); first exact: cvg_cst. apply: contraPP (xN) => h; apply/negP; rewrite negbK inE; left; left. @@ -4223,7 +4319,8 @@ split. exists N; split => //; rewrite -(setCK N); apply: subsetC => x Nx Dx. by rewrite /f' /restrict mem_set. - have := @dominated_cvg0 _ _ _ _ _ mD _ _ _ mu_ f_f' finv ig' f_g'. - set X := (X in _ -> X --> _); rewrite [X in X --> _ -> _](_ : _ = X) //. + set X := (X in _ -> X @ \oo --> _). + rewrite [X in X @ \oo --> _ -> _](_ : _ = X) //. apply/funext => n; apply: ae_eq_integral => //. + apply: measurableT_comp => //; apply: emeasurable_funB => //. apply/(measurable_restrict _ (measurableD _ _) _ _).1 => //. @@ -4232,7 +4329,8 @@ split. + exists N; split => //; rewrite -(setCK N); apply: subsetC => x /= Nx Dx. by rewrite /f_' /f' /restrict mem_set. - have := @dominated_cvg _ _ _ _ _ mD _ _ _ mu_ f_f' finv ig' f_g'. - set X := (X in _ -> X --> _); rewrite [X in X --> _ -> _](_ : _ = X) //; last first. + set X := (X in _ -> X @ \oo --> _). + rewrite [X in X @ \oo --> _ -> _](_ : _ = X) //; last first. apply/funext => n; apply: ae_eq_integral => //. exists N; split => //; rewrite -(setCK N); apply: subsetC => x /= Nx Dx. by rewrite /f_' /restrict mem_set. @@ -4328,9 +4426,10 @@ have muE j : mu (E j) = 0. + by apply: measurable_funS msg => //; exact: subIsetl. have nd_E : {homo E : n0 m / (n0 <= m)%N >-> (n0 <= m)%O}. move=> i j ij; apply/subsetPset => x [Dx /= ifg]; split => //. - by move: ifg; apply: le_trans; rewrite lee_fin lef_pinv// ?posrE// ler_nat. -rewrite real_interval.set_lte_bigcup. -have /cvg_lim h1 : mu \o E --> 0 by apply: cvg_near_cst; exact: nearW. + by move: ifg; apply: le_trans; rewrite lee_fin lef_pV2// ?posrE// ler_nat. +rewrite set_lte_bigcup. +have /cvg_lim h1 : (mu \o E) x @[x --> \oo]--> 0. + by apply: cvg_near_cst; exact: nearW. have := @nondecreasing_cvg_mu _ _ _ mu E mE (bigcupT_measurable E mE) nd_E. by move/cvg_lim => h2; rewrite setI_bigcupr -h2// h1. Qed. @@ -4399,7 +4498,7 @@ Lemma xsection_ndseq_closed : ndseq_closed B. Proof. move=> F ndF; rewrite /B /= => BF; split. by apply: bigcupT_measurable => n; have [] := BF n. -have phiF x : (fun i => phi (F i) x) --> phi (\bigcup_i F i) x. +have phiF x : phi (F i) x @[i \oo] --> phi (\bigcup_i F i) x. rewrite /phi /= xsection_bigcup; apply: nondecreasing_cvg_mu. - by move=> n; apply: measurable_xsection; case: (BF n). - by apply: bigcupT_measurable => i; apply: measurable_xsection; case: (BF i). @@ -4419,7 +4518,7 @@ Lemma ysection_ndseq_closed : ndseq_closed B. Proof. move=> F ndF; rewrite /B /= => BF; split. by apply: bigcupT_measurable => n; have [] := BF n. -have psiF x : (fun i => psi (F i) x) --> psi (\bigcup_i F i) x. +have psiF x : psi (F i) x @[i \oo] --> psi (\bigcup_i F i) x. rewrite /psi /= ysection_bigcup; apply: nondecreasing_cvg_mu. - by move=> n; apply: measurable_ysection; case: (BF n). - by apply: bigcupT_measurable => i; apply: measurable_ysection; case: (BF i). @@ -4785,7 +4884,7 @@ Proof. move=> Afin mfA bdA; apply/integrableP; split; first exact/EFin_measurable_fun. have [M [_ mrt]] := bdA; apply: le_lt_trans. apply: (integral_le_bound (`|M| + 1)%:E) => //; first exact: measurableT_comp. - by apply: aeW => z Az; rewrite lee_fin mrt// ltr_spaddr// ler_norm. + by apply: aeW => z Az; rewrite lee_fin mrt// ltr_pwDr// ler_norm. by rewrite lte_mul_pinfty. Qed. @@ -4794,7 +4893,7 @@ Let sfun_dense_L1_pos (f : T -> \bar R) : exists g_ : {sfun T >-> R}^nat, [/\ forall n, mu.-integrable E (EFin \o g_ n), forall x, E x -> EFin \o g_^~ x @ \oo --> f x & - (fun n => \int[mu]_(z in E) `|f z - (g_ n z)%:E|) --> 0]. + (fun n => \int[mu]_(z in E) `|f z - (g_ n z)%:E|) @ \oo --> 0]. Proof. move=> intf fpos; case/integrableP: (intf) => mfE _. pose g_ n := nnsfun_approx mE mfE n. @@ -4819,7 +4918,7 @@ Lemma approximation_sfun_integrable (f : T -> \bar R): exists g_ : {sfun T >-> R}^nat, [/\ forall n, mu.-integrable E (EFin \o g_ n), forall x, E x -> EFin \o g_^~ x @ \oo --> f x & - (fun n => \int[mu]_(z in E) `|f z - (g_ n z)%:E|) --> 0]. + (fun n => \int[mu]_(z in E) `|f z - (g_ n z)%:E|) @ \oo --> 0]. Proof. move=> intf. have [//|p_ [intp pf pl1]] := sfun_dense_L1_pos (integrable_funepos mE intf). @@ -4847,7 +4946,7 @@ case/fine_cvgP: pl1 => + /cvg_ballP/(_ _ e2p); apply: filter_app2. case/fine_cvgP: nl1 => + /cvg_ballP/(_ _ e2p); apply: filter_app2. near=> n; rewrite /ball /=; do 3 rewrite distrC subr0. move=> finfn ne2 finfp pe2; rewrite [_%:num]splitr. -rewrite (le_lt_trans _ (ltr_add pe2 ne2))// (le_trans _ (ler_norm_add _ _))//. +rewrite (le_lt_trans _ (ltrD pe2 ne2))// (le_trans _ (ler_normD _ _))//. under [fun z => _ (f^\+ z + _)]eq_fun => ? do rewrite EFinN. under [fun z => _ (f^\- z + _)]eq_fun => ? do rewrite EFinN. have mfp : mu.-integrable E (fun z => `|f^\+ z - (p_ n z)%:E|). @@ -4862,8 +4961,10 @@ rewrite !ger0_norm ?fine_ge0 ?integral_ge0 ?fine_le//. - by apply: integral_fune_fin_num => //; exact: integrableD. - apply: ge0_le_integral => //. + by apply: measurableT_comp => //; case/integrableP: (mfpn n). + + by move=> x Ex; rewrite adde_ge0. + by apply: emeasurable_funD; [move: mfp | move: mfn]; case/integrableP. + by move=> ? ?; rewrite fpn; exact: lee_abs_sub. + + by move=> x Ex; rewrite adde_ge0. Unshelve. all: by end_near. Qed. End simple_density_L1. @@ -4877,9 +4978,9 @@ Lemma compact_finite_measure (A : set R^o) : compact A -> mu A < +oo. Proof. move=> /[dup]/compact_measurable => mA /compact_bounded[N [_ N1x]]. have AN1 : (A `<=` `[- (`|N| + 1), `|N| + 1])%R. - by move=> z Az; rewrite set_itvcc /= -ler_norml N1x// ltr_spaddr// ler_norm. + by move=> z Az; rewrite set_itvcc /= -ler_norml N1x// ltr_pwDr// ler_norm. rewrite (le_lt_trans (le_measure _ _ _ AN1)) ?inE//=. -by rewrite lebesgue_measure_itv/= lte_fin gtr_opp// EFinD ltry. +by rewrite lebesgue_measure_itv/= lte_fin gtrN// EFinD ltry. Qed. Lemma continuous_compact_integrable (f : R -> R^o) (A : set R^o) : @@ -4898,7 +4999,7 @@ Lemma approximation_continuous_integrable (E : set R) (f : R -> R^o): exists g_ : (rT -> rT)^nat, [/\ forall n, continuous (g_ n), forall n, mu.-integrable E (EFin \o g_ n) & - (fun n => \int[mu]_(z in E) `|(f z - g_ n z)%:E|) --> 0]. + \int[mu]_(z in E) `|(f z - g_ n z)%:E| @[n --> \oo] --> 0]. Proof. move=> mE Efin intf. have mf : measurable_fun E f by case/integrableP : intf => /EFin_measurable_fun. @@ -4935,8 +5036,8 @@ have mg : measurable_fun E g. by apply: (measurable_funS measurableT) => //; exact: measurable_funP. have [M Mpos Mbd] : (exists2 M, 0 < M & forall x, `|g x| <= M)%R. have [M [_ /= bdM]] := simple_bounded g. - exists (`|M| + 1)%R; first exact: ltr_spaddr. - by move=> x; rewrite bdM// ltr_spaddr// ler_norm. + exists (`|M| + 1)%R; first exact: ltr_pwDr. + by move=> x; rewrite bdM// ltr_pwDr// ler_norm. have [] // := @measurable_almost_continuous _ _ mE _ g (eps%:num / 2 / (M *+ 2)). by rewrite divr_gt0// mulrn_wgt0. move=> A [cptA AE /= muAE ctsAF]. @@ -4956,12 +5057,12 @@ exists h; split => //; rewrite [eps%:num]splitr; apply: le_lt_trans. apply: (@ge0_le_integral _ _ _ mu _ mE _ fgh) => //. - apply: (measurable_funS mE) => //; do 2 apply: measurableT_comp => //. exact: measurable_funB. - - by move=> z _; rewrite /fgh. + - by move=> z _; rewrite adde_ge0. - apply: measurableT_comp => //; apply: measurable_funD => //; apply: (measurable_funS mE) => //; (apply: measurableT_comp => //); exact: measurable_funB. - move=> x _; rewrite -(subrK (g x) (f x)) -(addrA (_ + _)%R) lee_fin. - by rewrite ler_norm_add. + by rewrite ler_normD. rewrite integralD//; first last. - by apply: integrable_abse; under eq_fun do rewrite EFinB; apply: integrableB. - by apply: integrable_abse; under eq_fun do rewrite EFinB; apply: integrableB. @@ -4981,7 +5082,7 @@ apply: (le_lt_trans (integral_le_bound (M *+ 2)%:E _ _ _ _)) => //. exact: measurable_funB. - by rewrite lee_fin mulrn_wge0// ltW. - apply: aeW => z [Ez _]; rewrite /= lee_fin mulr2n. - by rewrite (le_trans (ler_norm_sub _ _))// ler_add. + by rewrite (le_trans (ler_normB _ _))// lerD. by rewrite -lte_pdivl_mull ?mulrn_wgt0// muleC -EFinM. Qed. @@ -5139,7 +5240,8 @@ rewrite -ge0_integral_fsum //; last 2 first. - move=> r x _; rewrite /fubini_F. have [r0|r0] := leP 0%R r. by rewrite mule_ge0//; exact: indic_fubini_tonelli_F_ge0. - by rewrite integral0_eq// => y _; rewrite preimage_nnfun0//= indicE in_set0. + rewrite integral0_eq ?mule0// => y _. + by rewrite preimage_nnfun0//= indicE in_set0. apply: eq_integral => x _; rewrite sfun_fubini_tonelli_FE. by under eq_fsbigr do rewrite indic_fubini_tonelli_FE//. Qed. @@ -5166,7 +5268,8 @@ rewrite -ge0_integral_fsum //; last 2 first. - move=> r y _; rewrite /fubini_G. have [r0|r0] := leP 0%R r. by rewrite mule_ge0//; exact: indic_fubini_tonelli_G_ge0. - by rewrite integral0_eq// => x _; rewrite preimage_nnfun0//= indicE in_set0. + rewrite integral0_eq ?mule0// => x _. + by rewrite preimage_nnfun0//= indicE in_set0. apply: eq_integral => x _; rewrite sfun_fubini_tonelli_GE. by under eq_fsbigr do rewrite indic_fubini_tonelli_GE//. Qed. @@ -5199,7 +5302,7 @@ apply: (emeasurable_fun_cvg (F_ g)) => //. - by move=> n; exact: sfun_measurable_fun_fubini_tonelli_F. - move=> x _. rewrite /F_ /F /fubini_F [in X in _ --> X](_ : (fun _ => _) = - fun y => lim (EFin \o g ^~ (x, y))); last first. + fun y => limn (EFin \o g ^~ (x, y))); last first. by rewrite funeqE => y; apply/esym/cvg_lim => //; exact: g_f. apply: cvg_monotone_convergence => //. - by move=> n; apply/EFin_measurable_fun => //; exact/measurableT_comp. @@ -5213,7 +5316,7 @@ have [g [g_nd /= g_f]] := approximation measurableT mf (fun x _ => f0 x). apply: (emeasurable_fun_cvg (G_ g)) => //. - by move=> n; exact: sfun_measurable_fun_fubini_tonelli_G. - move=> y _; rewrite /G_ /G /fubini_G [in X in _ --> X](_ : (fun _ => _) = - fun x => lim (EFin \o g ^~ (x, y))); last first. + fun x => limn (EFin \o g ^~ (x, y))); last first. by rewrite funeqE => x; apply/esym/cvg_lim => //; exact: g_f. apply: cvg_monotone_convergence => //. - by move=> n; apply/EFin_measurable_fun => //; exact/measurableT_comp. @@ -5224,23 +5327,24 @@ Qed. Lemma fubini_tonelli1 : \int[m1 \x m2]_z f z = \int[m1]_x F x. Proof. have [g [g_nd /= g_f]] := approximation measurableT mf (fun x _ => f0 x). -have F_F x : F x = lim (F_ g ^~ x). - rewrite [RHS](_ : _ = lim (fun n => \int[m2]_y (EFin \o g n) (x, y)))//. +have F_F x : F x = limn (F_ g ^~ x). + rewrite [RHS](_ : _ = limn (fun n => \int[m2]_y (EFin \o g n) (x, y)))//. rewrite -monotone_convergence//; last 3 first. - by move=> n; exact/EFin_measurable_fun/measurableT_comp. - by move=> n /= y _; rewrite lee_fin; exact: fun_ge0. - by move=> y /= _ a b; rewrite lee_fin => /g_nd/lefP; exact. by apply: eq_integral => y _; apply/esym/cvg_lim => //; exact: g_f. -rewrite [RHS](_ : _ = lim (fun n => \int[m1 \x m2]_z (EFin \o g n) z)). +rewrite [RHS](_ : _ = limn (fun n => \int[m1 \x m2]_z (EFin \o g n) z)). rewrite -monotone_convergence //; last 3 first. - by move=> n; exact/EFin_measurable_fun. - by move=> n /= x _; rewrite lee_fin; exact: fun_ge0. - by move=> y /= _ a b; rewrite lee_fin => /g_nd/lefP; exact. by apply: eq_integral => /= x _; apply/esym/cvg_lim => //; exact: g_f. rewrite [LHS](_ : _ = - lim (fun n => \int[m1]_x (\int[m2]_y (EFin \o g n) (x, y)))). - by congr (lim _); rewrite funeqE => n; rewrite sfun_fubini_tonelli1. -rewrite [RHS](_ : _ = lim (fun n => \int[m1]_x F_ g n x))//. + limn (fun n => \int[m1]_x (\int[m2]_y (EFin \o g n) (x, y)))). + set r := fun _ => _; set l := fun _ => _; have -> // : l = r. + by apply/funext => n; rewrite /l /r sfun_fubini_tonelli1. +rewrite [RHS](_ : _ = limn (fun n => \int[m1]_x F_ g n x))//. rewrite -monotone_convergence //; first exact: eq_integral. - by move=> n; exact: sfun_measurable_fun_fubini_tonelli_F. - move=> n x _; apply: integral_ge0 => // y _ /=; rewrite lee_fin. @@ -5256,25 +5360,25 @@ Qed. Lemma fubini_tonelli2 : \int[m1 \x m2]_z f z = \int[m2]_y G y. Proof. have [g [g_nd /= g_f]] := approximation measurableT mf (fun x _ => f0 x). -have G_G y : G y = lim (G_ g ^~ y). +have G_G y : G y = limn (G_ g ^~ y). rewrite /G /fubini_G. - rewrite [RHS](_ : _ = lim (fun n => \int[m1]_x (EFin \o g n) (x, y)))//. + rewrite [RHS](_ : _ = limn (fun n => \int[m1]_x (EFin \o g n) (x, y)))//. rewrite -monotone_convergence//; last 3 first. - by move=> n; exact/EFin_measurable_fun/measurableT_comp. - by move=> n /= x _; rewrite lee_fin; exact: fun_ge0. - by move=> x /= _ a b; rewrite lee_fin => /g_nd/lefP; exact. by apply: eq_integral => x _; apply/esym/cvg_lim => //; exact: g_f. -rewrite [RHS](_ : _ = lim (fun n => \int[m1 \x m2]_z (EFin \o g n) z)). +rewrite [RHS](_ : _ = limn (fun n => \int[m1 \x m2]_z (EFin \o g n) z)). rewrite -monotone_convergence //; last 3 first. - by move=> n; exact/EFin_measurable_fun. - by move=> n /= x _; rewrite lee_fin; exact: fun_ge0. - by move=> y /= _ a b; rewrite lee_fin => /g_nd/lefP; exact. by apply: eq_integral => /= x _; apply/esym/cvg_lim => //; exact: g_f. -rewrite [LHS](_ : _ = lim +rewrite [LHS](_ : _ = limn (fun n => \int[m2]_y (\int[m1]_x (EFin \o g n) (x, y)))). - congr (lim _); rewrite funeqE => n. - by rewrite sfun_fubini_tonelli sfun_fubini_tonelli2. -rewrite [RHS](_ : _ = lim (fun n => \int[m2]_y G_ g n y))//. + set r := fun _ => _; set l := fun _ => _; have -> // : l = r. + by apply/funext => n; rewrite /l /r sfun_fubini_tonelli sfun_fubini_tonelli2. +rewrite [RHS](_ : _ = limn (fun n => \int[m2]_y G_ g n y))//. rewrite -monotone_convergence //; first exact: eq_integral. - by move=> n; exact: sfun_measurable_fun_fubini_tonelli_G. - by move=> n y _; apply: integral_ge0 => // x _ /=; rewrite lee_fin fun_ge0. @@ -5561,7 +5665,7 @@ Let R := [the measurableType _ of measurableTypeR rT]. Let ballE (x : R) (r : {posnum rT}) : ball x r%:num = `](x - r%:num), (x + r%:num)[%classic :> set rT. Proof. -rewrite -(@ball_normE rT [normedModType rT of R^o]) /ball_ set_itvoo. +rewrite -ball_normE /ball_ set_itvoo. by under eq_set => ? do rewrite ltr_distlC. Qed. @@ -5572,8 +5676,8 @@ Lemma lebesgue_differentiation_continuous (f : R -> rT^o) (A : set R) (x : R) : Proof. have ball_itvr r : 0 < r -> `[x - r, x + r] `\` ball x r = [set x + r; x - r]. move: r => _/posnumP[r]. - rewrite -setU1itv ?bnd_simp ?ler_subl_addr -?addrA ?ler_paddr//. - rewrite -setUitv1 ?bnd_simp ?ltr_subl_addr -?addrA ?ltr_spaddr//. + rewrite -setU1itv ?bnd_simp ?lerBlDr -?addrA ?ler_wpDr//. + rewrite -setUitv1 ?bnd_simp ?ltrBlDr -?addrA ?ltr_pwDr//. rewrite setUA setUC setUA setDUl !ballE setDv setU0 setDidl// -subset0. by move=> z /= [[]] ->; rewrite in_itv/= ltxx// andbF. have ball_itv2 r : 0 < r -> ball x r = `[x - r, x + r] `\` [set x + r; x - r]. @@ -5582,10 +5686,10 @@ have ball_itv2 r : 0 < r -> ball x r = `[x - r, x + r] `\` [set x + r; x - r]. by rewrite ballE set_itvcc => ?/=; rewrite in_itv => /andP [/ltW -> /ltW ->]. have ritv r : 0 < r -> mu `[x - r, x + r]%classic = (r *+ 2)%:E. move=> /gt0_cp rE; rewrite /= lebesgue_measure_itv/= lte_fin. - rewrite ler_lt_add // ?rE // -EFinD; congr (_ _). + rewrite ler_ltD // ?rE // -EFinD; congr (_ _). by rewrite opprB addrAC [_ - _]addrC addrA subrr add0r. move=> oA intf ctsfx Ax. -apply: (@cvg_zero rT [normedModType R of rT^o]). +apply: cvg_zero. apply/cvgrPdist_le => eps epos; apply: filter_app (@nbhs_right_gt rT 0). move/cvgrPdist_le/(_ eps epos)/at_right_in_segment : ctsfx; apply: filter_app. apply: filter_app (open_itvcc_subset oA Ax). @@ -5610,7 +5714,7 @@ rewrite /= -mulrBr -fineB; first last. - by rewrite integral_fune_fin_num. rewrite -integralB_EFin //; first last. by apply: continuous_compact_integrable => // ?; exact: cvg_cst. -under [fun _ => adde _ _ ]eq_fun => ? do rewrite -EFinD. +under [fun _ => _ + _ ]eq_fun => ? do rewrite -EFinD. have int_fx : mu.-integrable `[x - r, x + r] (fun z => (f z - f x)%:E). under [fun z => (f z - _)%:E]eq_fun => ? do rewrite EFinB. rewrite integrableB// continuous_compact_integrable// => ?. @@ -5620,12 +5724,12 @@ rewrite normrM [ `|_/_| ]ger0_norm // -fine_abse //; first last. suff : (\int[mu]_(z in `[(x - r)%R, (x + r)%R]) `|f z - f x|%:E <= (r *+ 2 * eps)%:E)%E. move=> intfeps; apply: le_trans. - apply: (ler_pmul r20 _ (le_refl _)); first exact: fine_ge0. + apply: (ler_pM r20 _ (le_refl _)); first exact: fine_ge0. apply: fine_le; last apply: le_abse_integral => //. - by rewrite abse_fin_num integral_fune_fin_num. - by rewrite integral_fune_fin_num// integrable_abse. - by case/integrableP : int_fx. - rewrite div1r ler_pdivr_mull ?mulrn_wgt0 // -[_ * _]/(fine (_%:E)). + rewrite div1r ler_pdivrMl ?mulrn_wgt0 // -[_ * _]/(fine (_%:E)). by rewrite fine_le// integral_fune_fin_num// integrable_abse. apply: le_trans. - apply: (@integral_le_bound _ _ _ _ _ (fun z => (f z - f x)%:E) eps%:E) => //. @@ -5728,9 +5832,10 @@ rewrite lee_pmul2l//; last first. 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 apply: measurableT_comp => //; apply: measurable_funD => //; exact: measurableT_comp. -- by move=> /= b axb; exact: ler_norm_add. +- by move=> /= x _; exact: ler_normD. Qed. End iavg. @@ -5797,11 +5902,11 @@ move: a0; rewrite le_eqVlt => /predU1P[a0|a0]. 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 _ [normedModType R of R^o])|exact: ballxx]. + 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). - by rewrite (le_lt_trans (ler_norm_add _ _))// addrC ltr_add// distrC. + by rewrite (le_lt_trans (ler_normD _ _))// addrC ltrD// distrC. have ? : k <= \int[mu]_(y in ball y (r + d)) `|(f y)%:E|. apply: subset_integral =>//; [exact:measurable_ball|exact:measurable_ball|]. apply: measurable_funTS; apply: measurableT_comp => //=. @@ -5821,24 +5926,24 @@ have kar : (0 < 2^-1 * (fine k / a) - r)%R. move: afxr; rewrite -{1}(fineK k_fin_num) -lte_pdivr_mulr; 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_pinv ?posrE ?pmulrn_lgt0//. - rewrite /= -[in X in X -> _]mulr_natl -ltr_pdivl_mull//. + rewrite -!EFinM !lte_fin -invf_div 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. rewrite lebesgue_measure_ball//; last by rewrite addr_ge0// ltW. rewrite -(fineK k_fin_num) -lte_pdivr_mulr; last first. by rewrite fine_gt0// k_gt0/= locally_integrable_ltbally. - rewrite -!EFinM !lte_fin -invf_div ltf_pinv//; last first. + rewrite -!EFinM !lte_fin -invf_div ltf_pV2//; last first. by rewrite posrE fine_gt0// ltry andbT lte_fin pmulrn_lgt0// addr_gt0. - rewrite -mulr_natl -ltr_pdivl_mull// -ltr_subr_addl. + rewrite -mulr_natl -ltr_pdivlMl// -ltrBrDl. by near: d; exact: nbhs_right_lt. exists (ball x d). - by split; [exact: (@ball_open _ [normedModType R of R^o])|exact: ballxx]. + 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). - by rewrite (le_lt_trans (ler_norm_add _ _))// addrC ltr_add// distrC. + by rewrite (le_lt_trans (ler_normD _ _))// addrC ltrD// distrC. have ? : k <= \int[mu]_(z in ball y (r + d)) `|(f z)%:E|. apply: subset_integral => //; [exact: measurable_ball|exact: measurable_ball|]. by apply: measurable_funTS; do 2 apply: measurableT_comp => //. @@ -5846,7 +5951,7 @@ have afxrdi : a%:E < (fine (mu (ball x (r + d))))^-1%:E * \int[mu]_(z in ball y (r + d)) `|(f z)%:E|. by rewrite (lt_le_trans axrdk)// lee_wpmul2l// lee_fin invr_ge0// fine_ge0. have /lt_le_trans : a%:E < iavg f (ball y (r + d)). - rewrite (lt_le_trans afxrdi)// /iavg. + apply: (lt_le_trans afxrdi); 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. @@ -5894,7 +5999,7 @@ have {}Kcmf : K `<=` cover [set i | HL f i > c%:E] (fun i => ball i (r_ i)). have {Kcmf}[D Dsub Kcover] : finite_subset_cover [set i | c%:E < HL f i] (fun i => ball i (r_ i)) K. move: cK; rewrite compact_cover => /(_ _ _ _ _ Kcmf); apply. - by move=> /= x cMfx; exact/(@ball_open _ [normedModType R of R^o])/r_pos. + by move=> /= x cMfx; exact/ball_open/r_pos. have KDB : K `<=` cover [set` D] B. by apply: (subset_trans Kcover) => /= x [r Dr] rx; exists r. have is_ballB i : is_ball (B i) by exact: is_ball_ball. @@ -5914,7 +6019,7 @@ rewrite (@le_trans _ _ (3%:R%:E * \sum_(i <- E) mu (B i)))//. rewrite !EFinM -muleA lee_wpmul2l//=. apply: (@le_trans _ _ (\sum_(i <- E) c^-1%:E * \int[mu]_(y in B i) `|(f y)|%:E)). - rewrite big_seq [in leRHS]big_seq; apply: lee_sum => r /ED /Dsub /[!inE] rD. + rewrite [in leLHS]big_seq [in leRHS]big_seq; apply: lee_sum => r /ED /Dsub /[!inE] rD. by rewrite -lee_pdivr_mull ?invr_gt0// invrK /B/=; exact/ltW/cMfx_int. rewrite -ge0_sume_distrr//; last by move=> x _; rewrite integral_ge0. rewrite lee_wpmul2l//; first by rewrite lee_fin invr_ge0 ltW. diff --git a/theories/lebesgue_measure.v b/theories/lebesgue_measure.v index 0de7bf9e0..a670be30e 100644 --- a/theories/lebesgue_measure.v +++ b/theories/lebesgue_measure.v @@ -67,7 +67,7 @@ Local Open Scope ereal_scope. Implicit Types i j : interval R. Definition hlength (A : set (ocitv_type R)) : \bar R := - let i := Rhull A in i.2 - i.1. + let i := Rhull A in (i.2 : \bar R) - i.1. Lemma hlength0 : hlength (set0 : set R) = 0. Proof. by rewrite /hlength Rhull0 /= subee. Qed. @@ -81,7 +81,8 @@ Qed. Lemma hlength_setT : hlength setT = +oo%E :> \bar R. Proof. by rewrite /hlength RhullT. Qed. -Lemma hlength_itv i : hlength [set` i] = if i.2 > i.1 then i.2 - i.1 else 0. +Lemma hlength_itv i : + hlength [set` i] = if i.2 > i.1 then (i.2 : \bar R) - i.1 else 0. Proof. case: ltP => [/lt_ereal_bnd/neitvP i12|]; first by rewrite /hlength set_itvK. rewrite le_eqVlt => /orP[|/lt_ereal_bnd i12]; last first. @@ -137,7 +138,7 @@ Proof. rewrite hlength_itv; case: ifPn => //; case: (i.1 : \bar _) => [r| |]. - by rewrite suber_ge0//; exact: ltW. - by rewrite ltNge leey. -- by case: (i.2 : \bar _) => //= [r _]; rewrite leey. +- by move=> i2gtNy; rewrite addey//; case: (i.2 : \bar R) i2gtNy. Qed. Lemma hlength_Rhull (A : set R) : hlength [set` Rhull A] = hlength A. @@ -158,7 +159,7 @@ move=> /subset_itvP ij; apply: lee_sub => /=. have [lj /=|lj] := asboolP (has_lbound J); last by rewrite leNye. have [li /=|li] := asboolP (has_lbound I); last first. by move: li; have := subset_has_lbound ij lj. -rewrite lee_fin ler_oppl opprK le_sup// ?has_inf_supN//; last exact/nonemptyN. +rewrite lee_fin lerNl opprK le_sup// ?has_inf_supN//; last exact/nonemptyN. move=> r [r' Ir' <-{r}]; exists (- r')%R. by split => //; exists r' => //; apply: ij. Qed. @@ -173,7 +174,8 @@ Lemma hlength_ge0 I : (0 <= hlength I)%E. Proof. by rewrite -hlength0 le_hlength. Qed. End hlength. -#[local] Hint Extern 0 (0%:E <= hlength _) => solve[apply: hlength_ge0] : core. +#[local] Hint Extern 0 (is_true (0%R <= hlength _)) => + solve[apply: hlength_ge0] : core. (* Unused *) (* Lemma hlength_semi_additive2 : semi_additive2 hlength. *) @@ -211,7 +213,7 @@ Context {R : realType}. Notation hlength := (@hlength R). -Lemma hlength_semi_additive : semi_additive hlength. +Lemma hlength_semi_additive : measure.semi_additive hlength. Proof. move=> /= I n /(_ _)/cid2-/all_sig[b]/all_and2[_]/(_ _)/esym-/funext {I}->. move=> Itriv [[/= a1 a2] _] /esym /[dup] + ->. @@ -300,10 +302,10 @@ pose Aoc i : set (ocitv_type R) := have: `[a.1 + e%:num / 2, a.2] `<=` \bigcup_i Aoo i. apply: (@subset_trans _ `]a.1, a.2]). move=> x; rewrite /= !in_itv /= => /andP[+ -> //]. - by move=> /lt_le_trans-> //; rewrite ltr_addl. + by move=> /lt_le_trans-> //; rewrite ltrDl. apply: (subset_trans lebig); apply: subset_bigcup => i _; rewrite AE /Aoo/=. move=> x /=; rewrite !in_itv /= => /andP[-> /le_lt_trans->]//=. - by rewrite ltr_addl. + by rewrite ltrDl. have := @segment_compact _ (a.1 + e%:num / 2) a.2; rewrite compact_cover. move=> /[apply]-[i _|X _ Xc]; first exact: interval_open. have: `](a.1 + e%:num / 2), a.2] `<=` \bigcup_(i in [set` X]) Aoc i. @@ -320,7 +322,7 @@ rewrite fsbig_finite//= set_fsetK//. rewrite lee_sum // => i _; rewrite ?AE// !hlength_itv/= ?lte_fin -?EFinD/=. do !case: ifPn => //= ?; do ?by rewrite ?adde_ge0 ?lee_fin// ?subr_ge0// ?ltW. by rewrite addrAC. -by rewrite addrAC lee_fin ler_add// subr_le0 leNgt. +by rewrite addrAC lee_fin lerD// subr_le0 leNgt. Qed. HB.instance Definition _ := Content_SubSigmaAdditive_isMeasure.Build _ _ _ @@ -332,7 +334,7 @@ exists (fun k : nat => `] (- k%:R)%R, k%:R]%classic); first by rewrite bigcup_it by move=> k; split => //; rewrite hlength_itv/= -EFinB; case: ifP; rewrite ltry. Qed. -Definition lebesgue_measure := measure_extension [the measure _ _ of hlength]. +Definition lebesgue_measure := measure_extension hlength. HB.instance Definition _ := Measure.on lebesgue_measure. Let sigmaT_finite_lebesgue_measure : sigma_finite setT lebesgue_measure. @@ -430,9 +432,8 @@ rewrite predeqE => i /=; split=> [[r [n _ fn1r <-{i}]]|[n _ [r fn1r <-{i}]]]; by [exists n => //; exists r | exists r => //; exists n]. Qed. -Definition ereal_isMeasurable : - isMeasurable default_measure_display (\bar R) := - isMeasurable.Build _ _ (Pointed.class _) +Definition ereal_isMeasurable : isMeasurable default_measure_display (\bar R) := + isMeasurable.Build _ _ emeasurable0 emeasurableC bigcupT_emeasurable. End salgebra_ereal. @@ -485,9 +486,10 @@ Definition measurableTypeR := salgebraType (R.-ocitv.-measurable). Definition measurableR : set (set R) := (R.-ocitv.-measurable).-sigma.-measurable. +HB.instance Definition _ := Pointed.on R. HB.instance Definition R_isMeasurable : isMeasurable default_measure_display R := - @isMeasurable.Build _ measurableTypeR (Pointed.class R) measurableR + @isMeasurable.Build _ measurableTypeR measurableR measurable0 (@measurableC _ _) (@bigcupT_measurable _ _). (*HB.instance (Real.sort R) R_isMeasurable.*) @@ -640,7 +642,7 @@ rewrite [X in lebesgue_measure X](_ : _ = rewrite predeqE => r; split. by move=> [x [[n _ Fnx xoo <-]]]; exists n => //; exists x. by move=> [n _ [x [Fnx xoo <-{r}]]]; exists x => //; split => //; exists n. -apply: (@measure_semi_sigma_additive _ _ _ [the measure _ _ of (@lebesgue_measure R)] +apply: (@measure_semi_sigma_additive _ _ _ (@lebesgue_measure R) (fun n => fine @` (F n `\` [set -oo; +oo]%E))). - move=> n; have := mF n. move=> [X mX [X' mX']] XX'Fn. @@ -744,22 +746,23 @@ Qed. Let lebesgue_measure_itvoo_subr1 (a : R) : lebesgue_measure (`]a - 1, a[%classic : set R) = 1%E. Proof. -rewrite itv_bnd_open_bigcup//; transitivity (lim (lebesgue_measure \o +rewrite itv_bnd_open_bigcup//; transitivity (limn (lebesgue_measure \o (fun k => `]a - 1, a - k.+1%:R^-1]%classic : set R))). apply/esym/cvg_lim => //; apply: nondecreasing_cvg_mu. - by move=> ?; exact: measurable_itv. - by apply: bigcup_measurable => k _; exact: measurable_itv. - move=> n m nm; apply/subsetPset => x /=; rewrite !in_itv/= => /andP[->/=]. - by move/le_trans; apply; rewrite ler_sub// ler_pinv ?ler_nat//; + by move/le_trans; apply; rewrite lerB// ler_pV2 ?ler_nat//; rewrite inE ltr0n andbT unitfE. rewrite (_ : _ \o _ = (fun n => (1 - n.+1%:R^-1)%:E)); last first. apply/funext => n /=; rewrite lebesgue_measure_itvoc. - have [->|n0] := eqVneq n 0%N; first by rewrite invr1 subrr set_itvoc0. + have [->|n0] := eqVneq n 0%N. + by rewrite invr1 subrr set_itvoc0 wlength0. rewrite wlength_itv/= lte_fin ifT; last first. - by rewrite ler_lt_sub// invr_lt1 ?unitfE// ltr1n ltnS lt0n. + by rewrite ler_ltB// invr_lt1 ?unitfE// ltr1n ltnS lt0n. by rewrite !(EFinB,EFinN) fin_num_oppeB// addeAC addeA subee// add0e. apply/cvg_lim => //=; apply/fine_cvgP; split => /=; first exact: nearW. -apply/(@cvgrPdist_lt _ [pseudoMetricNormedZmodType R of R^o]) => _/posnumP[e]. +apply/(@cvgrPdist_lt _ [the pseudoMetricNormedZmodType R of R^o]) => _/posnumP[e]. near=> n; rewrite opprB addrCA subrr addr0 ger0_norm//. by near: n; exact: near_infty_natSinv_lt. Unshelve. all: by end_near. Qed. @@ -770,10 +773,10 @@ suff : (lebesgue_measure (`]a - 1, a]%classic%R : set R) = lebesgue_measure (`]a - 1, a[%classic%R : set R) + lebesgue_measure [set a])%E. rewrite lebesgue_measure_itvoo_subr1 lebesgue_measure_itvoc => /eqP. - rewrite wlength_itv lte_fin ltr_subl_addr ltr_addl ltr01. + rewrite wlength_itv lte_fin ltrBlDr ltrDl ltr01. rewrite [in X in X == _]/= EFinN EFinB fin_num_oppeB// addeA subee// add0e. by rewrite addeC -sube_eq ?fin_num_adde_defl// subee// => /eqP. -rewrite -setUitv1// ?bnd_simp; last by rewrite ltr_subl_addr ltr_addl. +rewrite -setUitv1// ?bnd_simp; last by rewrite ltrBlDr ltrDl. rewrite measureU //; apply/seteqP; split => // x []/=. by rewrite in_itv/= => + xa; rewrite xa ltxx andbF. Qed. @@ -820,39 +823,39 @@ by move: x y => [|] [|]; [exact: lebesgue_measure_itvco | exact: lebesgue_measure_itvoc]. Qed. -Let limnatR : lim (fun k => (k%:R)%:E : \bar R) = +oo%E. +Let limnatR : lim (((k%:R)%:E : \bar R) @[k --> \oo]) = +oo%E. Proof. by apply/cvg_lim => //; apply/cvgenyP. Qed. Let lebesgue_measure_itv_bnd_infty x (a : R) : lebesgue_measure ([set` Interval (BSide x a) +oo%O] : set R) = +oo%E. Proof. -rewrite itv_bnd_infty_bigcup; transitivity (lim (lebesgue_measure \o +rewrite itv_bnd_infty_bigcup; transitivity (limn (lebesgue_measure \o (fun k => [set` Interval (BSide x a) (BRight (a + k%:R))] : set R))). apply/esym/cvg_lim => //; apply: nondecreasing_cvg_mu. + by move=> k; exact: measurable_itv. + by apply: bigcup_measurable => k _; exact: measurable_itv. + move=> m n mn; apply/subsetPset => r/=; rewrite !in_itv/= => /andP[->/=]. - by move=> /le_trans; apply; rewrite ler_add// ler_nat. + by move=> /le_trans; apply; rewrite lerD// ler_nat. rewrite (_ : _ \o _ = (fun k => k%:R%:E))//. apply/funext => n /=; rewrite lebesgue_measure_itv_bnd wlength_itv/=. rewrite lte_fin; have [->|n0] := eqVneq n 0%N; first by rewrite addr0 ltxx. -by rewrite ltr_addl ltr0n lt0n n0 EFinD addeAC EFinN subee ?add0e. +by rewrite ltrDl ltr0n lt0n n0 EFinD addeAC EFinN subee ?add0e. Qed. Let lebesgue_measure_itv_infty_bnd y (b : R) : lebesgue_measure ([set` Interval -oo%O (BSide y b)] : set R) = +oo%E. Proof. -rewrite itv_infty_bnd_bigcup; transitivity (lim (lebesgue_measure \o +rewrite itv_infty_bnd_bigcup; transitivity (limn (lebesgue_measure \o (fun k => [set` Interval (BLeft (b - k%:R)) (BSide y b)] : set R))). apply/esym/cvg_lim => //; apply: nondecreasing_cvg_mu. + by move=> k; exact: measurable_itv. + by apply: bigcup_measurable => k _; exact: measurable_itv. + move=> m n mn; apply/subsetPset => r/=; rewrite !in_itv/= => /andP[+ ->]. - by rewrite andbT; apply: le_trans; rewrite ler_sub// ler_nat. + by rewrite andbT; apply: le_trans; rewrite lerB// ler_nat. rewrite (_ : _ \o _ = (fun k : nat => k%:R%:E))//. apply/funext => n /=; rewrite lebesgue_measure_itv_bnd wlength_itv/= lte_fin. have [->|n0] := eqVneq n 0%N; first by rewrite subr0 ltxx. -rewrite ltr_subl_addr ltr_addl ltr0n lt0n n0 EFinN EFinB fin_num_oppeB// addeA. +rewrite ltrBlDr ltrDl ltr0n lt0n n0 EFinN EFinB fin_num_oppeB// addeA. by rewrite subee// add0e. Qed. @@ -868,7 +871,8 @@ by rewrite [X in (_ + X)%E]lebesgue_measure_itv_bnd_infty. Qed. Lemma lebesgue_measure_itv (i : interval R) : - lebesgue_measure ([set` i] : set R) = (if i.1 < i.2 then i.2 - i.1 else 0)%E. + lebesgue_measure ([set` i] : set R) = + (if i.1 < i.2 then (i.2 : \bar R) - i.1 else 0)%E. Proof. move: i => [[x a|[|]]] [y b|[|]]. by rewrite lebesgue_measure_itv_bnd wlength_itv. @@ -893,9 +897,9 @@ Proof. by rewrite ball_itv; exact: measurable_itv. Qed. Lemma lebesgue_measure_ball (x r : R) : (0 <= r)%R -> lebesgue_measure (ball x r) = (r *+ 2)%:E. Proof. -rewrite le_eqVlt => /orP[/eqP <-|r0]. +rewrite le_eqVlt => /predU1P[ <-|r0]. by rewrite (ball0 _ _).2// measure0 mul0rn. -rewrite ball_itv lebesgue_measure_itv/= lte_fin ltr_subl_addr -addrA ltr_addl. +rewrite ball_itv lebesgue_measure_itv/= lte_fin ltrBlDr -addrA ltrDl. by rewrite addr_gt0 // -EFinD addrAC opprD opprK addrA subrr add0r -mulr2n. Qed. @@ -908,9 +912,9 @@ Qed. Lemma lebesgue_measure_closed_ball (x r : R) : 0 <= r -> lebesgue_measure (closed_ball x r) = (r *+ 2)%:E. Proof. -rewrite le_eqVlt => /predU1P[<-|r0]; first by rewrite mul0rn closed_ball0. -rewrite closed_ball_itv// lebesgue_measure_itv/= lte_fin -ltr_subl_addl addrAC. -rewrite subrr add0r gtr_opp// ?mulr_gt0// -EFinD; congr (_%:E). +rewrite le_eqVlt => /predU1P[<-|r0]; first by rewrite mul0rn closed_ball0// measure0. +rewrite closed_ball_itv// lebesgue_measure_itv/= lte_fin -ltrBlDl addrAC. +rewrite subrr add0r gtrN// ?mulr_gt0// -EFinD; congr (_%:E). by rewrite opprB addrAC addrCA subrr addr0 -mulr2n. Qed. @@ -961,7 +965,7 @@ rewrite [X in measurable X](_ : _ = rewrite predeqE => t; split => [/= [Dt ft]|]. have [ft0|ft0] := leP 0%R (fine (f t)). exists `|ceil (fine (f t))|%N => //=; split => //; split. - by rewrite -{2}(fineK ft)// lee_fin (le_trans _ ft0)// ler_oppl oppr0. + by rewrite -{2}(fineK ft)// lee_fin (le_trans _ ft0)// lerNl oppr0. by rewrite natr_absz ger0_norm ?ceil_ge0// -(fineK ft) lee_fin ceil_ge. exists `|floor (fine (f t))|%N => //=; split => //; split. rewrite natr_absz ltr0_norm ?floor_lt0// EFinN. @@ -1174,15 +1178,15 @@ rewrite predeqE => x; split=> [|]. - move: x => [s /=| _ n _|//]. + rewrite in_itv /= andbT lee_fin => rs n _ /=; rewrite in_itv/= andbT. case: b => /=. - * by rewrite lee_fin ler_subl_addl (le_trans rs)// ler_addr. - * by rewrite lte_fin ltr_subl_addl (le_lt_trans rs)// ltr_addr. + * by rewrite lee_fin lerBlDl (le_trans rs)// lerDr. + * by rewrite lte_fin ltrBlDl (le_lt_trans rs)// ltrDr. + by rewrite /= in_itv /= andbT; case: b => /=; rewrite lteey. - move: x => [s| |/(_ 0%N Logic.I)] /=; rewrite ?in_itv/= ?leey//; last first. by case: b. move=> h; rewrite lee_fin leNgt andbT; apply/negP => /ltr_add_invr[k skr]. have {h} := h k Logic.I; rewrite /= in_itv /= andbT; case: b => /=. - + by rewrite lee_fin ler_subl_addr leNgt skr. - + by rewrite lte_fin ltr_subl_addr ltNge (ltW skr). + + by rewrite lee_fin lerBlDr leNgt skr. + + by rewrite lte_fin ltrBlDr ltNge (ltW skr). Qed. Lemma eitv_infty_bnd b r : `]-oo, r%:E]%classic = @@ -1192,8 +1196,8 @@ rewrite predeqE => x; split=> [|]. - move: x => [s /=|//|_ n _]. + rewrite in_itv /= lee_fin => sr n _; rewrite /= in_itv /= -EFinD. case: b => /=. - * by rewrite lte_fin (le_lt_trans sr)// ltr_addl. - * by rewrite lee_fin (le_trans sr)// ler_addl. + * by rewrite lte_fin (le_lt_trans sr)// ltrDl. + * by rewrite lee_fin (le_trans sr)// lerDl. + by rewrite /= in_itv /= -EFinD; case: b => //=; rewrite lteNye. - move: x => [s|/(_ 0%N Logic.I)|]/=; rewrite !in_itv/= ?leNye//; last first. by case: b. @@ -1210,10 +1214,10 @@ rewrite eqEsubset; split=> [_ -> i _ |]; first by rewrite /= in_itv /= ltNyr. move=> [r|/(_ O Logic.I)|]//. move=> /(_ `|floor r|%N Logic.I); rewrite /= in_itv/= ltNge. rewrite lee_fin; have [r0|r0] := leP 0%R r. - by rewrite (le_trans _ r0) // ler_oppl oppr0 ler0n. -rewrite ler_oppl -abszN natr_absz gtr0_norm; last first. - by rewrite ltr_oppr oppr0 floor_lt0. -by rewrite mulrNz ler_oppl opprK floor_le. + by rewrite (le_trans _ r0) // lerNl oppr0 ler0n. +rewrite lerNl -abszN natr_absz gtr0_norm; last first. + by rewrite ltrNr oppr0 floor_lt0. +by rewrite mulrNz lerNl opprK floor_le. Qed. Lemma eset1y : [set +oo] = \bigcap_k `]k%:R%:E, +oo[%classic :> set (\bar R). @@ -1468,9 +1472,9 @@ have [x0|x0] := leP 0 x. - have [r0|r0] := leP 0 r; [rewrite ger0_norm|rewrite ltr0_norm] => // xr; rewrite 2!in_itv/=. + by right; rewrite xr. - + by left; rewrite ltr_oppr. + + by left; rewrite ltrNr. - move=> rx /=. - by rewrite ler0_norm 1?ltr_oppr// (le_trans (ltW rx))// ler_oppl oppr0. + by rewrite ler0_norm 1?ltrNr// (le_trans (ltW rx))// lerNl oppr0. - by rewrite in_itv /= andbT => xr; rewrite (lt_le_trans _ (ler_norm _)). rewrite [X in measurable X](_ : _ = setT)// predeqE => r. by split => // _; rewrite /= in_itv /= andbT (lt_le_trans x0). @@ -1531,11 +1535,11 @@ rewrite [X in measurable X](_ : _ = \bigcup_(q : rat) - by rewrite -preimage_itv_o_infty; apply: mf => //; apply: measurable_itv. - by rewrite -preimage_itv_o_infty; apply: mg => //; apply: measurable_itv. rewrite predeqE => x; split => [|[r _] []/= [Dx rfx]] /= => [[Dx]|[_]]. - rewrite -ltr_subl_addr => /rat_in_itvoo[r]; rewrite inE /= => /itvP h. + rewrite -ltrBlDr => /rat_in_itvoo[r]; rewrite inE /= => /itvP h. exists r => //; rewrite setIACA setIid; split => //; split => /=. by rewrite h. - by rewrite ltr_subl_addr addrC -ltr_subl_addr h. -by rewrite ltr_subl_addr=> afg; rewrite (lt_le_trans afg)// addrC ler_add2r ltW. + by rewrite ltrBlDr addrC -ltrBlDr h. +by rewrite ltrBlDr=> afg; rewrite (lt_le_trans afg)// addrC lerD2r ltW. Qed. Lemma measurable_funB D f g : measurable_fun D f -> @@ -1616,7 +1620,7 @@ Proof. move=> f_ub f_lb mf. have : {in D, (fun x => inf [set sups (h ^~ x) n | n in [set n | 0 <= n]%N]) =1 (fun x => limn_sup (h^~ x))}. - move=> t; rewrite inE => Dt; apply/esym/cvg_lim; first exact: Rhausdorff. + move=> t; rewrite inE => Dt; apply/esym/cvg_lim => //. rewrite [X in _ --> X](_ : _ = inf (range (sups (h^~t)))). by apply: cvg_sups_inf; [exact: f_ub|exact: f_lb]. by congr (inf [set _ | _ in _]); rewrite predeqE. @@ -1628,19 +1632,16 @@ by move=> k; exact: measurable_fun_sups. Qed. Lemma measurable_fun_cvg D (h : (T -> R)^nat) f : - (forall m, measurable_fun D (h m)) -> (forall x, D x -> h ^~ x --> f x) -> + (forall m, measurable_fun D (h m)) -> (forall x, D x -> h ^~ x @ \oo --> f x) -> measurable_fun D f. Proof. move=> mf_ f_f; have fE x : D x -> f x = limn_sup (h ^~ x). move=> Dx; have /cvg_lim <-// := @cvg_sups _ (h ^~ x) (f x) (f_f _ Dx). - exact: Rhausdorff. apply: (@eq_measurable_fun _ _ _ _ D (fun x => limn_sup (h ^~ x))). by move=> x; rewrite inE => Dx; rewrite -fE. apply: (@measurable_fun_limn_sup _ h) => // t Dt. -- apply/bounded_fun_has_ubound/(@cvg_seq_bounded _ [normedModType R of R^o]). - by apply/cvg_ex; eexists; exact: f_f. -- apply/bounded_fun_has_lbound/(@cvg_seq_bounded _ [normedModType R of R^o]). - by apply/cvg_ex; eexists; exact: f_f. +- by apply/bounded_fun_has_ubound/cvg_seq_bounded/cvg_ex; eexists; exact: f_f. +- by apply/bounded_fun_has_lbound/cvg_seq_bounded/cvg_ex; eexists; exact: f_f. Qed. End measurable_fun_realType. @@ -1839,7 +1840,7 @@ Qed. Lemma emeasurable_fun_cvg D (f_ : (T -> \bar R)^nat) (f : T -> \bar R) : (forall m, measurable_fun D (f_ m)) -> - (forall x, D x -> f_ ^~ x --> f x) -> measurable_fun D f. + (forall x, D x -> f_ ^~ x @ \oo --> f x) -> measurable_fun D f. Proof. move=> mf_ f_f; have fE x : D x -> f x = limn_esup (f_^~ x). rewrite limn_esup_lim. @@ -1890,9 +1891,9 @@ have muM n : mu (M n) <= mu (M' n) + (e2 n)%:E. have -> : (`]a, (b + e2 n)%R[ = `]a, b] `|` `]b, (b + e2 n)%R[ )%classic. apply: funext=> r /=; rewrite (@itv_splitU _ _ (BRight b)). by rewrite propeqE; split=> /orP. - by rewrite !bnd_simp (ltW alb)/= ltr_spaddr. + by rewrite !bnd_simp (ltW alb)/= ltr_pwDr. rewrite measureU/=. - - rewrite !lebesgue_measure_itv/= !lte_fin alb ltr_spaddr//=. + - rewrite !lebesgue_measure_itv/= !lte_fin alb ltr_pwDr//=. by rewrite -(EFinD (b + e2 n)) (addrC b) addrK. - by apply: sub_sigma_algebra; exact: is_ocitv. - by apply: open_measurable; exact: interval_open. @@ -1905,7 +1906,7 @@ exists U; have DU : D `<=` U. have /ocitvP [-> //| [[/= a b alb -> mn]]] : ocitv (M' n). by case: covDM => /(_ n). rewrite /= !in_itv/= => /andP[ax xb]; rewrite ?inf_itv ?sup_itv//. - by rewrite ax/= (le_lt_trans xb)// ltr_spaddr. + by rewrite ax/= (le_lt_trans xb)// ltr_pwDr. have mM n : measurable (M n). rewrite /M; case: pselect; first by move=> /= _; exact: measurable0. by move=> /= _; apply: open_measurable; apply: interval_open. @@ -1938,12 +1939,12 @@ Lemma lebesgue_nearly_bounded (D : set R) (eps : R) : Proof. move=> mD Dfin epspos; pose Dn n := D `&` [set` `[-(n%:R), n%:R]]%R. have mDn n : measurable (Dn n) by exact: measurableI. -have : mu \o Dn --> mu (\bigcup_n Dn n). +have : mu \o Dn @ \oo --> mu (\bigcup_n Dn n). apply: nondecreasing_cvg_mu => //. - by apply: bigcup_measurable => // ? _; exact: mDn. - move=> n m nm; apply/subsetPset; apply: setIS => z /=; rewrite !in_itv/=. move=> /andP[nz zn]; rewrite (le_trans _ nz)/= ?(le_trans zn) ?ler_nat//. - by rewrite ler_oppl opprK ler_nat. + by rewrite lerNl opprK ler_nat. rewrite -setI_bigcupr; rewrite bigcup_itvT setIT. have finDn n : mu (Dn n) \is a fin_num. rewrite ge0_fin_numE// (le_lt_trans _ Dfin)//. @@ -1994,7 +1995,7 @@ have mD' : measurable D' by exact: measurableD. have [] := lebesgue_regularity_outer mD' _ epspos. rewrite (@le_lt_trans _ _ (mu `[a,b]%classic))//. by rewrite le_measure ?inE//; exact: subIsetl. - by rewrite /= lebesgue_measure_itv //= -EFinD -fun_if ltry. + by rewrite /= lebesgue_measure_itv/= -EFinD -(fun_if EFin) ltry. move=> U [oU /subsetC + mDeps]; rewrite setCI setCK => nCD'. exists (`[a, b] `&` ~` U); split. - apply: (subclosed_compact _ (@segment_compact _ a b)) => //. @@ -2069,9 +2070,9 @@ Local Open Scope ereal_scope. Lemma pointwise_almost_uniform (f_ : (T -> R)^nat) (g : T -> R) (A : set T) (eps : R): (forall n, measurable_fun A (f_ n)) -> measurable_fun A g -> - measurable A -> mu A < +oo -> (forall x, A x -> f_ ^~ x --> g x) -> + measurable A -> mu A < +oo -> (forall x, A x -> f_ ^~ x @\oo --> g x) -> (0 < eps)%R -> exists B, [/\ measurable B, mu B < eps%:E & - {uniform A `\` B, f_ --> g}]. + {uniform A `\` B, f_ @\oo --> g}]. Proof. move=> mf mg mA finA fptwsg epspos; pose h q (z : T) : R := `|f_ q z - g z|%R. have mfunh q : measurable_fun A (h q). @@ -2099,29 +2100,30 @@ have Ek0 k : (\bigcap_n (E k n)) = set0. by have [N /(_ Az) ?] := nEcvg z k; exists N. by exists O; rewrite // /E setC_bigcup => n ? []. have badn' : forall k, exists n, mu (E k n) < ((eps/2) / (2 ^ k.+1)%:R)%:E. - move=> k; pose ek :R := eps/2 / (2 ^ k.+1)%:R; have : mu \o E k --> (0%R)%:E. - rewrite -(measure0 mu) -(Ek0 k); apply: nonincreasing_cvg_mu => //. + move=> k; pose ek :R := eps/2 / (2 ^ k.+1)%:R. + have : mu \o E k @\oo --> mu set0. + rewrite -(Ek0 k); apply: nonincreasing_cvg_mu => //. - apply: (le_lt_trans _ finA); apply: le_measure; rewrite ?inE //. by move=> ? [? _ []]. - by apply: bigcap_measurable => ?. - case/fine_cvg/(_ (interior (ball (0:R) ek))%R). + rewrite measure0; case/fine_cvg/(_ (interior (ball (0:R) ek))%R). apply: open_nbhs_nbhs; split; first exact: open_interior. by apply: nbhsx_ballx; rewrite !divr_gt0. move=> N _ /(_ N (leqnn _))/interior_subset muEN; exists N; move: muEN. rewrite /ball /= distrC subr0 ger0_norm // -[x in x < _]fineK ?ge0_fin_numE//. - by apply:(le_lt_trans _ finA); apply le_measure; rewrite ?inE// => ? [? _ []]. + by apply:(le_lt_trans _ finA); apply: le_measure; rewrite ?inE// => ? [? _ []]. pose badn k := projT1 (cid (badn' k)); exists (\bigcup_k (E k (badn k))); split. - exact: bigcup_measurable. - apply: (@le_lt_trans _ _ (eps/2)%R%:E); first last. - by rewrite lte_fin ltr_pdivr_mulr // ltr_pmulr // Rint_ltr_addr1 // ?Rint1. + by rewrite lte_fin ltr_pdivrMr // ltr_pMr // Rint_ltr_addr1 // ?Rint1. apply: le_trans. apply: (measure_sigma_sub_additive _ (fun k => mE k (badn k)) _ _) => //. exact: bigcup_measurable. apply: le_trans; first last. by apply: (@epsilon_trick0 R _ xpredT); rewrite divr_ge0 //; exact: ltW. by rewrite lee_nneseries // => n _; exact/ltW/(projT2 (cid (badn' _))). -apply/uniform_restrict_cvg => /= U /=; rewrite ?uniform_nbhsT. -case/nbhs_ex => del /filterS; apply. +apply/uniform_restrict_cvg => /= U /=; rewrite !uniform_nbhsT. +case/nbhs_ex => del /= ballU; apply: filterS; first by move=> ?; exact: ballU. have [N _ /(_ N)/(_ (leqnn _)) Ndel] := near_infty_natSinv_lt del. exists (badn N) => // r badNr x. rewrite /patch; case xAB: (x \in A `\` _) => //; apply: (lt_trans _ Ndel). @@ -2133,13 +2135,14 @@ Qed. Lemma ae_pointwise_almost_uniform (f_ : (T -> R)^nat) (g : T -> R) (A : set T) (eps : R): (forall n, measurable_fun A (f_ n)) -> measurable_fun A g -> - measurable A -> mu A < +oo -> {ae mu, (forall x, A x -> f_ ^~ x --> g x)} -> + measurable A -> mu A < +oo -> + {ae mu, (forall x, A x -> f_ ^~ x @\oo --> g x)} -> (0 < eps)%R -> exists B, [/\ measurable B, mu B < eps%:E & - {uniform A `\` B, (fun n => (f_ n : T -> R)) --> g}]. + {uniform A `\` B, f_ @\oo --> g}]. Proof. move=> mf mg mA Afin [C [mC C0 nC] epspos]. have [B [mB Beps Bunif]] : exists B, [/\ d.-measurable B, mu B < eps%:E & - {uniform (A `\` C) `\` B, f_ --> g}]. + {uniform (A `\` C) `\` B, f_ @\oo --> g}]. apply: pointwise_almost_uniform => //. - by move=> n; apply : (measurable_funS mA _ (mf n)) => ? []. - by apply : (measurable_funS mA _ (mg)) => ? []. @@ -2208,9 +2211,9 @@ have E_partition : E = \bigcup_n (F n). have EBr2 n : E n -> closure (B n) `<=` (ball (0:R) (r%:num + 2))%R. move=> [Dn] [x] => -[Bnx rx] y /= Bny. move: rx; rewrite /ball /= !sub0r !normrN => rx. - rewrite -(subrK x y) (le_lt_trans (ler_norm_add _ _))//. - rewrite addrC ltr_le_add// -(subrK (cpoint (B n)) y) -(addrA (y - _)%R). - rewrite (le_trans (ler_norm_add _ _))// (_ : 2 = 1 + 1)%R// ler_add//. + rewrite -(subrK x y) (le_lt_trans (ler_normD _ _))//. + rewrite addrC ltr_leD// -(subrK (cpoint (B n)) y) -(addrA (y - _)%R). + rewrite (le_trans (ler_normD _ _))// (_ : 2 = 1 + 1)%R// lerD//. rewrite distrC; have := is_ball_closureP (ABV.1 n) Bny. by move=> /le_trans; apply; rewrite VB1//; exact: DV. have := is_ball_closureP (ABV.1 n) Bnx. @@ -2244,7 +2247,7 @@ have finite_set_F i : finite_set (F i). move=> /CsubFi[_ /andP[+ _]]. rewrite -lte_fin => /ltW/le_trans; apply. rewrite (is_ball_closure (is_ballB _))// lebesgue_measure_closed_ball//. - by rewrite lee_fin mulr2n ler_addr. + by rewrite lee_fin mulr2n lerDr. have CFi : mu (\bigcup_(j in [set` C]) closure (B j)) <= mu (\bigcup_(j in F i) closure (B j)). apply: le_measure => //; rewrite ?inE. @@ -2267,8 +2270,8 @@ have finite_set_F i : finite_set (F i). - by move=> /= x [n Fni Bnx]; exists n => //; exists i. have {CFi Fir2} := le_trans MC (le_trans CFi Fir2). apply/negP; rewrite -ltNge lebesgue_measure_ball// lte_fin. - rewrite -(@natr1 _ `| _ |%N) natr_absz ger0_norm ?ceil_ge0// -ltr_pdivr_mulr//. - by rewrite -ltr_subl_addr (lt_le_trans _ (ceil_ge _))// ltr_subl_addr ltr_addl. + rewrite -(@natr1 _ `| _ |%N) natr_absz ger0_norm ?ceil_ge0// -ltr_pdivrMr//. + by rewrite -ltrBlDr (lt_le_trans _ (ceil_ge _))// ltrBlDr ltrDl. have mur2_fin_num_ : mu (ball (0:R) (r%:num + 2))%R < +oo. by rewrite lebesgue_measure_ball// ltry. have FE : \sum_(n // x []. have : \sum_(N <= k \oo] --> 0. exact: nneseries_tail_cvg. - rewrite /f /= => /fine_fcvg /=. - move/(@cvgrPdist_lt _ [pseudoMetricNormedZmodType R of R^o]). + rewrite /f /= => /fine_fcvg /= /cvgrPdist_lt /=. have : (0 < 5%:R^-1 * e%:num)%R by rewrite mulr_gt0// invr_gt0// ltr0n. move=> /[swap] /[apply]. rewrite near_map => -[N _]/(_ _ (leqnn N)) h; exists N; move: h. @@ -2344,35 +2346,34 @@ have ZNF5 : Z r%:num `<=` case: Zz => -[Az notDBz]; rewrite /ball/= sub0r normrN => rz. have [d dzr zdK0] : exists2 d : {posnum R}, (d%:num < r%:num - `|z|)%R & closed_ball z d%:num `&` K = set0. - have [d/= d0 dzK] := (@closed_disjoint_closed_ball _ - [normedModType R of R^o] _ _ closedK Kz). + have [d/= d0 dzK] := closed_disjoint_closed_ball closedK Kz. have rz0 : (0 < minr ((r%:num - `|z|) / 2) (d / 2))%R. by rewrite lt_minr (divr_gt0 d0)//= andbT divr_gt0// subr_gt0. exists (PosNum rz0) => /=. - by rewrite lt_minl ltr_pdivr_mulr// ltr_pmulr ?subr_gt0// ltr1n. + by rewrite lt_minl ltr_pdivrMr// ltr_pMr ?subr_gt0// ltr1n. apply: dzK => //=. - rewrite sub0r normrN gtr0_norm// lt_minl (ltr_pdivr_mulr d d)//. - by rewrite ltr_pmulr// ltr1n orbT. + rewrite sub0r normrN gtr0_norm// lt_minl (ltr_pdivrMr d d)//. + by rewrite ltr_pMr// ltr1n orbT. have N0_gt0 : (0 < d%:num / 2)%R by rewrite divr_gt0. have [i [Vi Biz BiN0]] := ABV _ Az _ N0_gt0. exists i; split => //. exact: subset_closure. move=> y Biy; rewrite /ball/= sub0r normrN -(@subrK _ (cpoint (B i)) y). - rewrite (le_lt_trans (ler_norm_add _ _))//. + rewrite (le_lt_trans (ler_normD _ _))//. rewrite (@le_lt_trans _ _ (d%:num / 2 + `|cpoint (B i)|)%R)//. - rewrite ler_add2r// distrC. + rewrite lerD2r// distrC. by rewrite (le_trans (is_ball_closureP (is_ballB i) Biy))// ltW. rewrite -(@subrK _ z (cpoint (B i))). rewrite (@le_lt_trans _ _ (d%:num / 2 + `|cpoint (B i) - z| + `|z|)%R)//. - by rewrite -[leRHS]addrA ler_add2l//; exact: ler_norm_add. + by rewrite -[leRHS]addrA lerD2l//; exact: ler_normD. rewrite (@le_lt_trans _ _ (d%:num + `|z|)%R)//. - rewrite [in leRHS](splitr d%:num) -!addrA ler_add2l// ler_add2r//. + rewrite [in leRHS](splitr d%:num) -!addrA lerD2l// lerD2r//. by rewrite (le_trans (ltW (is_ballP (is_ballB i) Biz)))// ltW. - by move: dzr; rewrite -ltr_subr_addr. + by move: dzr; rewrite -ltrBrDr. apply: subsetI_eq0 zdK0 => // y Biy. - rewrite (@closed_ballE _ [normedModType R of R^o])//= /closed_ball_/=. + rewrite closed_ballE//= /closed_ball_/=. rewrite -(@subrK _ (cpoint (B i)) z) -(addrA (z - _)%R). - rewrite (le_trans (ler_norm_add _ _))// [in leRHS](splitr d%:num) ler_add//. + rewrite (le_trans (ler_normD _ _))// [in leRHS](splitr d%:num) lerD//. by rewrite distrC (le_trans (ltW (is_ballP (is_ballB i) Biz)))// ltW. by rewrite (le_trans (is_ball_closureP (is_ballB i) Biy))// ltW. have [j [Ej Bij0 Bij5]] : exists j, [/\ E j, @@ -2404,7 +2405,7 @@ have {}ZNF5 : mu (Z r%:num) <= rewrite -[in leRHS](set_mem_set (F n)) -nneseries_esum// bigcup_mkcond. rewrite eseries_mkcond [leRHS](_ : _ = \sum_(i x. + congr (limn _); apply/funext => x. by under [RHS]eq_bigr do rewrite (fun_if mu) measure0. apply: measure_sigma_sub_additive => //. + move=> m; case: ifPn => // _. diff --git a/theories/lebesgue_stieltjes_measure.v b/theories/lebesgue_stieltjes_measure.v index d8c9a0445..b25548a94 100644 --- a/theories/lebesgue_stieltjes_measure.v +++ b/theories/lebesgue_stieltjes_measure.v @@ -72,16 +72,16 @@ Lemma nondecreasing_right_continuousP (R : numFieldType) (a : R) (e : R) e > 0 -> exists d : {posnum R}, f (a + d%:num) <= f a + e. Proof. move=> e0; move: (cumulative_is_right_continuous f). -move=> /(_ a)/(@cvgr_dist_lt _ [normedModType R of R^o]). +move=> /(_ a)/(@cvgr_dist_lt _ [the normedModType R of R^o]). move=> /(_ _ e0)[] _ /posnumP[d] => h. exists (PosNum [gt0 of (d%:num / 2)]) => //=. move: h => /(_ (a + d%:num / 2)) /=. rewrite opprD addrA subrr distrC subr0 ger0_norm //. -rewrite ltr_pdivr_mulr// ltr_pmulr// ltr1n => /(_ erefl). -rewrite ltr_addl divr_gt0// => /(_ erefl). +rewrite ltr_pdivrMr// ltr_pMr// ltr1n => /(_ erefl). +rewrite ltrDl divr_gt0// => /(_ erefl). rewrite ler0_norm; last first. - by rewrite subr_le0 (cumulative_is_nondecreasing f)// ler_addl. -by rewrite opprB ltr_subl_addl => fa; exact: ltW. + by rewrite subr_le0 (cumulative_is_nondecreasing f)// lerDl. +by rewrite opprB ltrBlDl => fa; exact: ltW. Qed. Section id_is_cumulative. @@ -156,9 +156,10 @@ Qed. Definition ocitv_display : Type -> measure_display. Proof. exact. Qed. +HB.instance Definition _ := Pointed.on ocitv_type. HB.instance Definition _ := @isSemiRingOfSets.Build (ocitv_display R) - ocitv_type (Pointed.class R) ocitv ocitv0 ocitvI ocitvD. + ocitv_type ocitv ocitv0 ocitvI ocitvD. End itv_semiRingOfSets. @@ -259,7 +260,8 @@ Proof. rewrite wlength_itv; case: ifPn => //; case: (i.1 : \bar _) => [r| |]. - by rewrite suber_ge0// => /ltW /(le_er_map ndf). - by rewrite ltNge leey. -- by case: (i.2 : \bar _) => //= [r _]; rewrite leey. +- case: (i.2 : \bar _) => //=; last by rewrite leey. + by move=> r _; rewrite leey. Qed. Lemma wlength_Rhull (A : set R) : wlength [set` Rhull A] = wlength A. @@ -299,7 +301,7 @@ End wlength. Section wlength_extension. Context {R : realType}. -Lemma wlength_semi_additive (f : R -> R) : semi_additive (wlength f). +Lemma wlength_semi_additive (f : R -> R) : measure.semi_additive (wlength f). Proof. move=> /= I n /(_ _)/cid2-/all_sig[b]/all_and2[_]/(_ _)/esym-/funext {I}->. move=> Itriv [[/= a1 a2] _] /esym /[dup] + ->. @@ -436,10 +438,10 @@ have acbd : `[ a.1 + c%:num / 2, a.2] `<=` \bigcup_i `](b i).1, (b i).2 + (D i)%:num[%classic. apply: (@subset_trans _ `]a.1, a.2]). move=> r; rewrite /= !in_itv/= => /andP [+ ->]. - by rewrite andbT; apply: lt_le_trans; rewrite ltr_addl. + by rewrite andbT; apply: lt_le_trans; rewrite ltrDl. apply: (subset_trans lebig) => r [n _ Anr]; exists n => //. move: Anr; rewrite AE /= !in_itv/= => /andP [->]/= /le_lt_trans. - by apply; rewrite ltr_addl. + by apply; rewrite ltrDl. have := @segment_compact _ (a.1 + c%:num / 2) a.2; rewrite compact_cover. have obd k : [set: nat] k -> open `](b k).1, ((b k).2 + (D k)%:num)[%classic. by move=> _; exact: interval_open. @@ -450,13 +452,13 @@ rewrite -EFinD. apply: (@le_trans _ _ (\sum_(i <- X) (wlength f `](b i).1, (b i).2]%classic) + \sum_(i <- X) (f ((b i).2 + (D i)%:num)%R - f (b i).2)%:E)%E). apply: (@le_trans _ _ (f a.2 - f (a.1 + c%:num / 2))%:E). - rewrite lee_fin -addrA -opprD ler_sub// (le_trans _ ce)//. + rewrite lee_fin -addrA -opprD lerB// (le_trans _ ce)//. rewrite cumulative_is_nondecreasing//. - by rewrite ler_add2l ler_pdivr_mulr// ler_pmulr// ler1n. + by rewrite lerD2l ler_pdivrMr// ler_pMr// ler1n. apply: (@le_trans _ _ (\sum_(i <- X) (f ((b i).2 + (D i)%:num) - f (b i).1)%:E)%E). rewrite sumEFin lee_fin cumulative_content_sub_fsum//. - by move=> k kX; rewrite (@le_trans _ _ (b k).2)// ler_addl. + by move=> k kX; rewrite (@le_trans _ _ (b k).2)// lerDl. apply: subset_trans. exact/(subset_trans _ acXbd)/subset_itv_oc_cc. move=> x [k kX] kx; rewrite -bigcup_fset; exists k => //. @@ -466,7 +468,7 @@ apply: (@le_trans _ _ (\sum_(i <- X) (wlength f `](b i).1, (b i).2]%classic) + rewrite -big_split/= nneseries_esum//; last by move=> k _; rewrite adde_ge0. rewrite esum_ge//; exists [set` X] => //; rewrite fsbig_finite//= set_fsetK. rewrite big_seq [in X in (_ <= X)%E]big_seq; apply: lee_sum => k kX. -by rewrite AE lee_add2l// lee_fin ler_subl_addl natrX De. +by rewrite AE lee_add2l// lee_fin lerBlDl natrX De. Qed. HB.instance Definition _ (f : cumulative R) := diff --git a/theories/measure.v b/theories/measure.v index ca1a15e64..3aacd9130 100644 --- a/theories/measure.v +++ b/theories/measure.v @@ -749,24 +749,18 @@ Qed. End dynkin_lemmas. HB.mixin Record isSemiRingOfSets (d : measure_display) T := { - ptclass : Pointed.class_of T; measurable : set (set T) ; measurable0 : measurable set0 ; measurableI : setI_closed measurable; semi_measurableD : semi_setD_closed measurable; }. -#[short(type=semiRingOfSetsType)] -HB.structure Definition SemiRingOfSets d := {T of isSemiRingOfSets d T}. +#[short(type="semiRingOfSetsType")] +HB.structure Definition SemiRingOfSets d := + {T of Pointed T & isSemiRingOfSets d T}. Arguments measurable {d}%measure_display_scope {s} _%classical_set_scope. -Canonical semiRingOfSets_eqType d (T : semiRingOfSetsType d) := EqType T ptclass. -Canonical semiRingOfSets_choiceType d (T : semiRingOfSetsType d) := - ChoiceType T ptclass. -Canonical semiRingOfSets_ptType d (T : semiRingOfSetsType d) := - PointedType T ptclass. - Lemma measurable_curry (T1 T2 : Type) d (T : semiRingOfSetsType d) (G : T1 * T2 -> set T) (x : T1 * T2) : measurable (G x) <-> measurable (curry G x.1 x.2). @@ -776,46 +770,32 @@ Notation "d .-measurable" := (@measurable d%mdisp) : classical_set_scope. Notation "'measurable" := (@measurable default_measure_display) : classical_set_scope. -HB.mixin Record SemiRingOfSets_isRingOfSets d T of isSemiRingOfSets d T := { - measurableU : setU_closed (@measurable d [the semiRingOfSetsType d of T]) }. +HB.mixin Record SemiRingOfSets_isRingOfSets d T of SemiRingOfSets d T := { + measurableU : @setU_closed T measurable +}. -#[short(type=ringOfSetsType)] +#[short(type="ringOfSetsType")] HB.structure Definition RingOfSets d := {T of SemiRingOfSets_isRingOfSets d T & SemiRingOfSets d T}. -Canonical ringOfSets_eqType d (T : ringOfSetsType d) := EqType T ptclass. -Canonical ringOfSets_choiceType d (T : ringOfSetsType d) := ChoiceType T ptclass. -Canonical ringOfSets_ptType d (T : ringOfSetsType d) := PointedType T ptclass. - HB.mixin Record RingOfSets_isAlgebraOfSets d T of RingOfSets d T := { measurableT : measurable [set: T] }. -#[short(type=algebraOfSetsType)] +#[short(type="algebraOfSetsType")] HB.structure Definition AlgebraOfSets d := {T of RingOfSets_isAlgebraOfSets d T & RingOfSets d T}. -Canonical algebraOfSets_eqType d (T : algebraOfSetsType d) := EqType T ptclass. -Canonical algebraOfSets_choiceType d (T : algebraOfSetsType d) := - ChoiceType T ptclass. -Canonical algebraOfSets_ptType d (T : algebraOfSetsType d) := - PointedType T ptclass. - HB.mixin Record AlgebraOfSets_isMeasurable d T of AlgebraOfSets d T := { bigcupT_measurable : forall F : (set T)^nat, (forall i, measurable (F i)) -> measurable (\bigcup_i (F i)) }. -#[short(type=measurableType)] +#[short(type="measurableType")] HB.structure Definition Measurable d := {T of AlgebraOfSets_isMeasurable d T & AlgebraOfSets d T}. -Canonical measurable_eqType d (T : measurableType d) := EqType T ptclass. -Canonical measurable_choiceType d (T : measurableType d) := ChoiceType T ptclass. -Canonical measurable_ptType d (T : measurableType d) := PointedType T ptclass. - -HB.factory Record isRingOfSets (d : measure_display) T := { - ptclass : Pointed.class_of T; +HB.factory Record isRingOfSets (d : measure_display) T of Pointed T := { measurable : set (set T) ; measurable0 : measurable set0 ; measurableU : setU_closed measurable; @@ -836,14 +816,13 @@ by move=> X Y -> ->. Qed. HB.instance Definition _ := - @isSemiRingOfSets.Build d T ptclass measurable measurable0 mI mD. + @isSemiRingOfSets.Build d T measurable measurable0 mI mD. HB.instance Definition _ := SemiRingOfSets_isRingOfSets.Build d T measurableU. HB.end. -HB.factory Record isAlgebraOfSets (d : measure_display) T := { - ptclass : Pointed.class_of T; +HB.factory Record isAlgebraOfSets (d : measure_display) T of Pointed T := { measurable : set (set T) ; measurable0 : measurable set0 ; measurableU : setU_closed measurable; @@ -858,8 +837,8 @@ move=> A B mA mB; rewrite setDE -[A]setCK -setCU. by do ?[apply: measurableU | apply: measurableC]. Qed. -HB.instance Definition _ := - @isRingOfSets.Build d T ptclass measurable measurable0 measurableU mD. +HB.instance Definition T_isRingOfSets := @isRingOfSets.Build d T + measurable measurable0 measurableU mD. Lemma measurableT : measurable [set: T]. Proof. by rewrite -setC0; apply: measurableC; exact: measurable0. Qed. @@ -868,8 +847,7 @@ HB.instance Definition _ := RingOfSets_isAlgebraOfSets.Build d T measurableT. HB.end. -HB.factory Record isMeasurable (d : measure_display) T := { - ptclass : Pointed.class_of T; +HB.factory Record isMeasurable (d : measure_display) T of Pointed T := { measurable : set (set T) ; measurable0 : measurable set0 ; measurableC : forall A, measurable A -> measurable (~` A) ; @@ -889,8 +867,8 @@ Qed. Lemma mC : setC_closed measurable. Proof. by move=> *; apply: measurableC. Qed. -HB.instance Definition _ := - @isAlgebraOfSets.Build d T ptclass measurable measurable0 mU mC. +HB.instance Definition _ := @isAlgebraOfSets.Build d T + measurable measurable0 mU mC. HB.instance Definition _ := @AlgebraOfSets_isMeasurable.Build d T measurable_bigcup. @@ -1003,8 +981,10 @@ Let discrete_measurableU (F : (set unit)^nat) : discrete_measurable_unit (\bigcup_i F i). Proof. by []. Qed. +HB.instance Definition _ := isPointed.Build unit tt. + HB.instance Definition _ := @isMeasurable.Build default_measure_display unit - (Pointed.class _) discrete_measurable_unit discrete_measurable0 + discrete_measurable_unit discrete_measurable0 discrete_measurableC discrete_measurableU. End discrete_measurable_unit. @@ -1025,7 +1005,7 @@ Let discrete_measurableU (F : (set bool)^nat) : Proof. by []. Qed. HB.instance Definition _ := @isMeasurable.Build default_measure_display bool - (Pointed.class _) discrete_measurable_bool discrete_measurable0 + discrete_measurable_bool discrete_measurable0 discrete_measurableC discrete_measurableU. End discrete_measurable_bool. @@ -1045,9 +1025,8 @@ Let discrete_measurable_natU (F : (set nat)^nat) : discrete_measurable_nat (\bigcup_i F i). Proof. by []. Qed. -HB.instance Definition _ := @isMeasurable.Build default_measure_display nat - (Pointed.class _) discrete_measurable_nat discrete_measurable_nat0 - discrete_measurable_natC discrete_measurable_natU. +HB.instance Definition _ := isMeasurable.Build default_measure_display nat + discrete_measurable_nat0 discrete_measurable_natC discrete_measurable_natU. End discrete_measurable_nat. @@ -1062,11 +1041,9 @@ Variables (T : pointedType) (G : set (set T)). Lemma sigma_algebraC (A : set T) : <> A -> <> (~` A). Proof. by move=> sGA; rewrite -setTD; exact: sigma_algebraCD. Qed. -Canonical salgebraType_eqType := EqType (salgebraType G) (Equality.class T). -Canonical salgebraType_choiceType := ChoiceType (salgebraType G) (Choice.class T). -Canonical salgebraType_ptType := PointedType (salgebraType G) (Pointed.class T). +HB.instance Definition _ := Pointed.on (salgebraType G). HB.instance Definition _ := @isMeasurable.Build (sigma_display G) - (salgebraType G) (Pointed.class T) + (salgebraType G) <> (@sigma_algebra0 _ setT G) (@sigma_algebraC) (@sigma_algebra_bigcup _ setT G). @@ -1341,7 +1318,7 @@ Definition semi_additive := forall F n, Definition semi_sigma_additive := forall F, (forall i : nat, measurable (F i)) -> trivIset setT F -> measurable (\bigcup_n F n) -> - (fun n => \sum_(0 <= i < n) mu (F i)) --> mu (\bigcup_n F n). + (fun n => \sum_(0 <= i < n) mu (F i)) @ \oo --> mu (\bigcup_n F n). Definition additive2 := forall A B, measurable A -> measurable B -> A `&` B = set0 -> mu (A `|` B) = mu A + mu B. @@ -1352,7 +1329,7 @@ Definition additive := Definition sigma_additive := forall F, (forall i : nat, measurable (F i)) -> trivIset setT F -> - (fun n => \sum_(0 <= i < n) mu (F i)) --> mu (\bigcup_n F n). + (fun n => \sum_(0 <= i < n) mu (F i)) @ \oo --> mu (\bigcup_n F n). Definition sub_additive := forall (A : set T) (F : nat -> set T) n, (forall k, `I_n k -> measurable (F k)) -> measurable A -> @@ -1539,11 +1516,15 @@ End content_on_semiring_of_sets. Arguments measure0 {d T R} _. #[global] Hint Extern 0 - (is_true (0 <= (_ : {content set _ -> \bar _}) _)%E) => + (is_true (0%R <= (_ : {content set _ -> \bar _}) _)%E) => solve [apply: measure_ge0] : core. +#[global] Hint Extern 0 + ((_ : {content set _ -> \bar _}) set0 = 0%R)%E => + solve [apply: measure0] : core. + #[global] -Hint Resolve measure0 measure_semi_additive2 measure_semi_additive : core. +Hint Resolve measure_semi_additive2 measure_semi_additive : core. Section content_on_ring_of_sets. Context d (R : realFieldType)(T : ringOfSetsType d) @@ -1663,8 +1644,8 @@ Proof. by move=> Am Atriv /measure_semi_sigma_additive/cvg_lim<-//. Qed. End measure_lemmas. -#[global] Hint Extern 0 (_ set0 = 0) => solve [apply: measure0] : core. -#[global] Hint Extern 0 (is_true (0 <= _)) => solve [apply: measure_ge0] : core. +#[global] Hint Extern 0 (_ set0 = 0%R) => solve [apply: measure0] : core. +#[global] Hint Extern 0 (is_true (0%:E <= _)) => solve [apply: measure_ge0] : core. Section measure_lemmas. Context d (R : realFieldType) (T : measurableType d). @@ -1747,7 +1728,7 @@ move=> F mF tF mUF; rewrite /dirac indicE; have [|aFn] /= := boolP (a \in _). rewrite big_mkord (bigID (xpred1 (Ordinal mn)))//= big_pred1_eq/= big1/=. by rewrite adde0 indicE mem_set//; exact: ballxx. by move=> j ij; rewrite indicE (negbTE (naF _ _)). -rewrite [X in X --> _](_ : _ = cst 0); first exact: cvg_cst. +rewrite [X in X @ \oo --> _](_ : _ = cst 0); first exact: cvg_cst. apply/funext => n; rewrite big1// => i _; rewrite indicE; apply/eqP. by rewrite eqe pnatr_eq0 eqb0; apply: contra aFn => /[!inE] aFn; exists i. Unshelve. all: by end_near. Qed. @@ -1823,7 +1804,7 @@ Let msum_ge0 B : 0 <= msum B. Proof. by rewrite /msum; apply: sume_ge0. Qed. Let msum_sigma_additive : semi_sigma_additive msum. Proof. move=> F mF tF mUF; rewrite [X in _ --> X](_ : _ = - lim (fun n => \sum_(0 <= i < n) msum (F i))). + lim ((fun n => \sum_(0 <= i < n) msum (F i)) @ \oo)). by apply: is_cvg_ereal_nneg_natsum => k _; exact: sume_ge0. rewrite nneseries_sum//; apply: eq_bigr => /= i _. exact: measure_semi_bigcup. @@ -1847,7 +1828,7 @@ Let mzero_ge0 B : 0 <= mzero B. Proof. by []. Qed. Let mzero_sigma_additive : semi_sigma_additive mzero. Proof. -move=> F mF tF mUF; rewrite [X in X --> _](_ : _ = cst 0); first exact: cvg_cst. +move=> F mF tF mUF; rewrite [X in X @ \oo--> _](_ : _ = cst 0); first exact: cvg_cst. by apply/funext => n; rewrite big1. Qed. @@ -1888,11 +1869,11 @@ Proof. by rewrite /mscale mule_ge0. Qed. Let mscale_sigma_additive : semi_sigma_additive mscale. Proof. -move=> F mF tF mUF; rewrite [X in X --> _](_ : _ = +move=> F mF tF mUF; rewrite [X in X @ \oo --> _](_ : _ = (fun n => (r%:num)%:E * \sum_(0 <= i < n) m (F i))); last first. by apply/funext => k; rewrite ge0_sume_distrr. rewrite /mscale; have [->|r0] := eqVneq r%:num 0%R. - rewrite mul0e [X in X --> _](_ : _ = (fun=> 0)); first exact: cvg_cst. + rewrite mul0e [X in X @ \oo --> _](_ : _ = (fun=> 0)); first exact: cvg_cst. by under eq_fun do rewrite mul0e. by apply: cvgeMl => //; exact: measure_semi_sigma_additive. Qed. @@ -1921,7 +1902,7 @@ Qed. Let mseries_sigma_additive : semi_sigma_additive mseries. Proof. move=> F mF tF mUF; rewrite [X in _ --> X](_ : _ = - lim (fun n => \sum_(0 <= i < n) mseries (F i))); last first. + lim ((fun n => \sum_(0 <= i < n) mseries (F i)) @ \oo)); last first. rewrite [in LHS]/mseries. transitivity (\sum_(n <= k \bar R}) (D : set T) (mD : measurable D). Local Notation restr := (mrestr mu mD). -Let restr0 : restr set0 = 0%E. Proof. by rewrite /mrestr set0I measure0. Qed. +Let restr0 : restr set0 = 0%E. Proof. by rewrite /mrestr set0I. Qed. Let restr_ge0 (A : set _) : (0 <= restr A)%E. Proof. by rewrite /restr; apply: measure_ge0; exact: measurableI. Qed. @@ -1979,7 +1960,7 @@ Section measure_count. Context d (T : measurableType d) (R : realType). Variables (D : set T) (mD : measurable D). -Local Notation counting := (@counting [choiceType of T] R). +Local Notation counting := (@counting T R). Let counting0 : counting set0 = 0. Proof. by rewrite /counting asboolT// fset_set0. Qed. @@ -2005,7 +1986,7 @@ have sumFE n : \sum_(i < n) counting (F i) = #|` fset_set (\big[setU/set0]_(k < n) F k) |%:R%:E. rewrite -trivIset_sum_card// natr_sum -sumEFin. by apply: eq_bigr => // i _; rewrite /counting asboolT. -have [cvg_u|dvg_u] := pselect (cvg (nseries u)). +have [cvg_u|dvg_u] := pselect (cvg (nseries u @ \oo)). have [N _ Nu] : \forall n \near \oo, u n = 0%N by apply: cvg_nseries_near. rewrite [X in _ --> X](_ : _ = \sum_(i < N) counting (F i)); last first. have -> : \bigcup_i (F i) = \big[setU/set0]_(i < N) F i. @@ -2021,7 +2002,7 @@ have [cvg_u|dvg_u] := pselect (cvg (nseries u)). by rewrite -{1}(subn0 N) big_mkord. rewrite add0n big_seq big1// => i /[!mem_iota] => /andP[NI iNn]. by rewrite /counting asboolT//= -/(u _) Nu. -have {dvg_u}cvg_F : (fun n => \sum_(i < n) counting (F i)) --> +oo. +have {dvg_u}cvg_F : (fun n => \sum_(i < n) counting (F i)) @ \oo --> +oo. rewrite (_ : (fun n => _) = [sequence (\sum_(0 <= i < n) (u i))%:R%:E]_n). exact/cvgenyP/dvg_nseries. apply/funext => n /=; under eq_bigr. @@ -2140,11 +2121,10 @@ Section SetRing. Context d {T : semiRingOfSetsType d}. Notation rT := (type T). -Canonical ring_eqType := EqType rT ptclass. -Canonical ring_choiceType := ChoiceType rT ptclass. -Canonical ring_ptType := PointedType rT ptclass. #[export] -HB.instance Definition _ := isRingOfSets.Build (display d) rT ptclass +HB.instance Definition _ := Pointed.on rT. +#[export] +HB.instance Definition _ := isRingOfSets.Build (display d) rT (@setring0 T measurable) (@setringU T measurable) (@setringDI T measurable). Local Notation "d .-ring" := (display d) (at level 1, format "d .-ring"). @@ -2363,9 +2343,7 @@ End content. End SetRing. Module Exports. -Canonical ring_eqType. -Canonical ring_choiceType. -Canonical ring_ptType. +HB.reexport. HB.reexport SetRing. End Exports. End SetRing. @@ -3030,7 +3008,7 @@ Let mnormalize_sigma_additive : semi_sigma_additive mnormalize. Proof. move=> F mF tF mUF; rewrite /mnormalize/=. case: ifPn => [_|_]; first exact: measure_semi_sigma_additive. -rewrite [X in X --> _](_ : _ = (fun n => \sum_(0 <= i < n) mu (F i)) \* +rewrite [X in X @ _ --> _](_ : _ = (fun n => \sum_(0 <= i < n) mu (F i)) \* cst (fine (mu setT))^-1%:E); last first. by apply/funext => n; rewrite -ge0_sume_distrl. by apply: cvgeMr => //; exact: measure_semi_sigma_additive. @@ -3177,7 +3155,7 @@ Lemma nondecreasing_cvg_mu d (T : ringOfSetsType d) (R : realFieldType) (mu : {measure set T -> \bar R}) (F : (set T) ^nat) : (forall i, measurable (F i)) -> measurable (\bigcup_n F n) -> nondecreasing_seq F -> - mu \o F --> mu (\bigcup_n F n). + mu \o F @ \oo --> mu (\bigcup_n F n). Proof. move=> mF mbigcupF ndF. have Binter : trivIset setT (seqD F) := trivIset_seqD ndF. @@ -3187,8 +3165,8 @@ rewrite eq_bigcup_seqD. have mB i : measurable (seqD F i) by elim: i => * //=; apply: measurableD. apply: cvg_trans (measure_semi_sigma_additive _ mB Binter _); last first. by rewrite -eq_bigcup_seqD. -apply: (@cvg_trans _ [filter of (fun n => \sum_(i < n.+1) mu (seqD F i))]). - rewrite [X in _ --> X](_ : _ = mu \o F) // funeqE => n. +apply: (@cvg_trans _ ((fun n => \sum_(i < n.+1) mu (seqD F i)) @ \oo)). + rewrite [X in _ --> X @ \oo](_ : _ = mu \o F) // funeqE => n. by rewrite -measure_semi_additive // -?FE// => -[|k]. move=> S [n _] nS; exists n => // m nm. under eq_fun do rewrite -(big_mkord predT (mu \o seqD F)). @@ -3199,7 +3177,7 @@ Lemma nonincreasing_cvg_mu d (T : algebraOfSetsType d) (R : realFieldType) (mu : {measure set T -> \bar R}) (F : (set T) ^nat) : mu (F 0%N) < +oo -> (forall i, measurable (F i)) -> measurable (\bigcap_n F n) -> - nonincreasing_seq F -> mu \o F --> mu (\bigcap_n F n). + nonincreasing_seq F -> mu \o F @ \oo --> mu (\bigcap_n F n). Proof. move=> F0pos mF mbigcapF niF; pose G n := F O `\` F n. have ? : mu (F 0%N) \is a fin_num by rewrite ge0_fin_numE. @@ -3507,7 +3485,7 @@ Notation "{ 'outer_measure' 'set' T '->' '\bar' R }" := (outer_measure R T) (at level 36, T, R at next level, format "{ 'outer_measure' 'set' T '->' '\bar' R }") : ring_scope. -#[global] Hint Extern 0 (_ set0 = 0) => solve [apply: outer_measure0] : core. +#[global] Hint Extern 0 (_ set0 = 0%R) => solve [apply: outer_measure0] : core. #[global] Hint Extern 0 (sigma_subadditive _) => solve [apply: outer_measure_sigma_subadditive] : core. @@ -3566,9 +3544,9 @@ Lemma le_outer_measureIC (R : realFieldType) T mu X <= mu (X `&` A) + mu (X `&` ~` A). Proof. pose B : (set T) ^nat := bigcup2 (X `&` A) (X `&` ~` A). -have cvg_mu : (fun n => \sum_(i < n) mu (B i)) --> mu (B 0%N) + mu (B 1%N). +have cvg_mu : (fun n => \sum_(i < n) mu (B i)) @ \oo --> mu (B 0%N) + mu (B 1%N). rewrite -2!cvg_shiftS /=. - rewrite [X in X --> _](_ : _ = (fun=> mu (B 0%N) + mu (B 1%N))); last first. + rewrite [X in X @ \oo --> _](_ : _ = (fun=> mu (B 0%N) + mu (B 1%N))); last first. rewrite funeqE => i; rewrite 2!big_ord_recl /= big1 ?adde0 // => j _. by rewrite /B /bigcup2 /=. exact: cvg_cst. @@ -3720,7 +3698,7 @@ Proof. move=> MA tA X. set A' := \bigcup_k A k; set B := fun n => \big[setU/set0]_(k < n) (A k). suff : forall n, \sum_(k < n) mu (X `&` A k) + mu (X `&` ~` A') <= mu X. - move=> XA; rewrite (_ : lim _ = ereal_sup + move=> XA; rewrite (_ : limn _ = ereal_sup ((fun n => \sum_(k < n) mu (X `&` A k)) @` setT)); last first. under eq_fun do rewrite big_mkord. apply/cvg_lim => //; apply: ereal_nondecreasing_cvgn. @@ -3771,8 +3749,9 @@ Proof. exact. Qed. Section caratheodory_sigma_algebra. Variables (R : realType) (T : pointedType) (mu : {outer_measure set T -> \bar R}). +HB.instance Definition _ := Pointed.on (caratheodory_type mu). HB.instance Definition _ := @isMeasurable.Build (caratheodory_display mu) - (caratheodory_type mu) (Pointed.class T) mu.-caratheodory + (caratheodory_type mu) mu.-caratheodory (caratheodory_measurable_set0 mu) (@caratheodory_measurable_setC _ _ mu) (@caratheodory_measurable_bigcup _ _ mu). @@ -3841,8 +3820,8 @@ Lemma epsilon_trick (R : realType) (A : (\bar R)^nat) e \sum_(i A0 /nonnegP[{}e]. -rewrite (@le_trans _ _ (lim (fun n => (\sum_(0 <= i < n | P i) A i) + - \sum_(0 <= i < n) (e%:num / (2 ^ i.+1)%:R)%:E))) //. +rewrite (@le_trans _ _ (lim ((fun n => (\sum_(0 <= i < n | P i) A i) + + \sum_(0 <= i < n) (e%:num / (2 ^ i.+1)%:R)%:E) @ \oo))) //. rewrite nneseriesD // limeD //. - rewrite lee_add2l //; apply: lee_lim => //. + exact: is_cvg_nneseries. @@ -3851,7 +3830,7 @@ rewrite (@le_trans _ _ (lim (fun n => (\sum_(0 <= i < n | P i) A i) + - exact: is_cvg_nneseries. - exact: is_cvg_nneseries. - exact: adde_def_nneseries. -suff cvggeo : (fun n => \sum_(0 <= i < n) (e%:num / (2 ^ i.+1)%:R)%:E) --> +suff cvggeo : (fun n => \sum_(0 <= i < n) (e%:num / (2 ^ i.+1)%:R)%:E) @ \oo --> e%:num%:E. rewrite limeD //. - by rewrite lee_add2l // (cvg_lim _ cvggeo). @@ -4029,11 +4008,11 @@ have setDE : setD_closed E. have ndE : ndseq_closed E. move=> A ndA EA; split; have mA n : measurable (A n) by have [] := EA n. - exact: bigcupT_measurable. - - transitivity (lim (m1 \o A)). + - transitivity (limn (m1 \o A)). apply/esym/cvg_lim=>//. exact/(nondecreasing_cvg_mu mA _ ndA)/bigcupT_measurable. - transitivity (lim (m2 \o A)). - by congr (lim _); rewrite funeqE => n; have [] := EA n. + transitivity (limn (m2 \o A)). + by apply/congr_lim/funext => n; have [] := EA n. apply/cvg_lim => //. exact/(nondecreasing_cvg_mu mA _ ndA)/bigcupT_measurable. - by apply: bigcup_sub => n; have [] := EA n. @@ -4079,13 +4058,13 @@ have nd_g' : nondecreasing_seq g'. exact: leq_trans lemn. move=> A gA. have -> : A = \bigcup_n (g' n `&` A) by rewrite -setI_bigcupl g'_cover setTI. -transitivity (lim (fun n => m1 (g' n `&` A))). +transitivity (lim (m1 (g' n `&` A) @[n --> \oo])). apply/esym/cvg_lim => //; apply: nondecreasing_cvg_mu. - by move=> n; apply: measurableI; exact/sGm. - by apply: bigcupT_measurable => k; apply: measurableI; exact/sGm. - by move=> ? ? ?; apply/subsetPset; apply: setSI; exact/subsetPset/nd_g'. -transitivity (lim (fun n => m2 (g' n `&` A))). - by congr (lim _); rewrite funeqE => x; apply: sG'm1m2 => //; exact/sGm. +transitivity (lim (m2 (g' n `&` A) @[n --> \oo])). + by apply/congr_lim/funext => x; apply: sG'm1m2 => //; exact/sGm. apply/cvg_lim => //; apply: nondecreasing_cvg_mu. - by move=> k; apply: measurableI => //; exact/sGm. - by apply: bigcupT_measurable => k; apply: measurableI; exact/sGm. @@ -4221,7 +4200,7 @@ rewrite -(eq_eseriesr (fun _ _ => SetRing.RmuE _ (mB _))) => //. have RmB i : measurable (B i : set rT) by exact: sub_gen_smallest. set BA := eseries (fun n => Rmu (B n `&` A)). set BNA := eseries (fun n => Rmu (B n `&` ~` A)). -apply: (@le_trans _ _ (lim BA + lim BNA)); [apply: lee_add|]. +apply: (@le_trans _ _ (limn BA + limn BNA)); [apply: lee_add|]. - rewrite (_ : BA = eseries (fun n => mu_ext mu (B n `&` A))); last first. rewrite funeqE => n; apply: eq_bigr => k _. by rewrite /= measurable_Rmu_extE //; exact: measurableI. @@ -4234,16 +4213,16 @@ apply: (@le_trans _ _ (lim BA + lim BNA)); [apply: lee_add|]. apply: (@le_trans _ _ (mu_ext mu (\bigcup_k (B k `\` A)))). by apply: le_mu_ext; rewrite -setI_bigcupl; exact: setISS. exact: outer_measure_sigma_subadditive. -have ? : cvg BNA by exact: is_cvg_nneseries. -have ? : cvg BA by exact: is_cvg_nneseries. -have ? : cvg (eseries (Rmu \o B)) by exact: is_cvg_nneseries. -have [def|] := boolP (lim BA +? lim BNA); last first. +have ? : cvg (BNA @ \oo) by exact: is_cvg_nneseries. +have ? : cvg (BA @ \oo) by exact: is_cvg_nneseries. +have ? : cvg (eseries (Rmu \o B) @ \oo) by exact: is_cvg_nneseries. +have [def|] := boolP (lim (BA @ \oo) +? lim (BNA @ \oo)); last first. rewrite /adde_def negb_and !negbK=> /orP[/andP[BAoo BNAoo]|/andP[BAoo BNAoo]]. - - suff -> : lim (eseries (Rmu \o B)) = +oo by rewrite leey. + - suff -> : limn (eseries (Rmu \o B)) = +oo by rewrite leey. apply/eqP; rewrite -leye_eq -(eqP BAoo); apply/lee_lim => //. near=> n; apply: lee_sum => m _; apply: le_measure; rewrite /mkset; by [rewrite inE; exact: measurableI | rewrite inE | apply: subIset; left]. - - suff -> : lim (eseries (Rmu \o B)) = +oo by rewrite leey. + - suff -> : limn (eseries (Rmu \o B)) = +oo by rewrite leey. apply/eqP; rewrite -leye_eq -(eqP BNAoo); apply/lee_lim => //. by near=> n; apply: lee_sum => m _; rewrite -setDE; apply: le_measure; rewrite /mkset ?inE//; apply: measurableD. @@ -4360,9 +4339,10 @@ Lemma prod_salgebra_bigcup (F : _^nat) : (forall i, preimage_classes f1 f2 (F i) preimage_classes f1 f2 (\bigcup_i (F i)). Proof. exact: sigma_algebra_bigcup. Qed. +HB.instance Definition _ := Pointed.on (T1 * T2)%type. HB.instance Definition prod_salgebra_mixin := @isMeasurable.Build (measure_prod_display (d1, d2)) - (T1 * T2)%type (Pointed.class _) (preimage_classes f1 f2) + (T1 * T2)%type (preimage_classes f1 f2) (prod_salgebra_set0) (prod_salgebra_setC) (prod_salgebra_bigcup). End product_salgebra_instance. diff --git a/theories/misc/uniform_bigO.v b/theories/misc/uniform_bigO.v index d8624a9fd..52d8e4fea 100644 --- a/theories/misc/uniform_bigO.v +++ b/theories/misc/uniform_bigO.v @@ -38,7 +38,7 @@ Definition OuP (f : A -> R * R -> R) (g : R * R -> R) := (* first we replace sig with ex and the l^2 norm with the l^oo norm *) -Let normedR2 := [normedModType _ of (R^o * R^o)]. +Let normedR2 := [the normedModType _ of (R^o * R^o)%type]. Definition OuPex (f : A -> R * R -> R^o) (g : R * R -> R^o) := exists2 alp, 0 < alp & exists2 C, 0 < C & @@ -51,23 +51,23 @@ Proof. rewrite RsqrtE; last by rewrite addr_ge0 //; apply/RleP/Rle_0_sqr. rewrite !Rsqr_pow2 !RpowE; apply/andP; split. by rewrite le_maxl; apply/andP; split; - rewrite -[`|_|]sqrtr_sqr ler_wsqrtr // (ler_addl, ler_addr) sqr_ge0. + rewrite -[`|_|]sqrtr_sqr ler_wsqrtr // (lerDl, lerDr) sqr_ge0. wlog lex12 : x / (`|x.1| <= `|x.2|). move=> ler_norm; case: (lerP `|x.1| `|x.2|) => [/ler_norm|] //. rewrite lt_leAnge => /andP [lex21 _]. rewrite RplusE. by rewrite addrC [`|_|]maxC (ler_norm (x.2, x.1)). rewrite [`|_|]max_r // -[X in X * _]ger0_norm // -normrM. -rewrite -sqrtr_sqr ler_wsqrtr // exprMn sqr_sqrtr // mulr_natl mulr2n ler_add2r. +rewrite -sqrtr_sqr ler_wsqrtr // exprMn sqr_sqrtr // mulr_natl mulr2n lerD2r. rewrite -[_ ^+ 2]ger0_norm ?sqr_ge0 // -[X in _ <=X]ger0_norm ?sqr_ge0 //. -by rewrite !normrX ler_expn2r // nnegrE normr_ge0. +by rewrite !normrX lerXn2r // nnegrE normr_ge0. Qed. Lemma OuP_to_ex f g : OuP f g -> OuPex f g. Proof. move=> [_ [_ [/posnumP[a] [/posnumP[C] fOg]]]]. exists (a%:num / Num.sqrt 2) => //; exists C%:num => // x dx ltdxa Pdx. -apply: fOg; move: ltdxa; rewrite ltr_pdivl_mulr //; apply: le_lt_trans. +apply: fOg; move: ltdxa; rewrite ltr_pdivlMr //; apply: le_lt_trans. by rewrite mulrC; have /andP[] := ler_norm2 dx. Qed. @@ -83,17 +83,17 @@ Qed. (* then we replace the epsilon/delta definition with bigO *) Definition OuO (f : A -> R * R -> R^o) (g : R * R -> R^o) := - (fun x => f x.1 x.2) =O_ (filter_prod [set setT] - (within P [filter of 0 : R^o * R^o])) (fun x => g x.2). + (fun x => f x.1 x.2) =O_ (filter_prod [set setT]%classic + (within P (nbhs (0%R:R^o,0%R:R^o))(*[filter of 0 : R^o * R^o]*))) (fun x => g x.2). Lemma OuP_to_O f g : OuP f g -> OuO f g. Proof. move=> /OuP_to_ex [_/posnumP[a] [_/posnumP[C] fOg]]. apply/eqOP; near=> k; near=> x; apply: le_trans (fOg _ _ _ _) _; last 2 first. - by near: x; exists (setT, P); [split=> //=; apply: withinT|move=> ? []]. -- by rewrite ler_pmul. +- by rewrite ler_pM. - near: x; exists (setT, ball (0 : R^o * R^o) a%:num). - by split=> //=; rewrite /within; near=> x =>_; near: x; apply: nbhsx_ballx. + by split=> //=; rewrite /within /=; near=> x =>_; near: x; apply: nbhsx_ballx. move=> x [_ [/=]]; rewrite -ball_normE /= distrC subr0 distrC subr0. by move=> ??; rewrite lt_maxl; apply/andP. Unshelve. all: by end_near. Qed. @@ -101,7 +101,7 @@ Unshelve. all: by end_near. Qed. Lemma OuO_to_P f g : OuO f g -> OuP f g. Proof. move=> fOg; apply/Ouex_to_P; move: fOg => /eqOP [k [kreal hk]]. -have /hk [Q [->]] : k < maxr 1 (k + 1) by rewrite lt_maxr ltr_addl orbC ltr01. +have /hk [Q [->]] : k < maxr 1 (k + 1) by rewrite lt_maxr ltrDl orbC ltr01. move=> [R [[_/posnumP[e1] Re1] [_/posnumP[e2] Re2]] sRQ] fOg. exists (minr e1%:num e2%:num) => //. exists (maxr 1 (k + 1)); first by rewrite lt_maxr ltr01. diff --git a/theories/normedtype.v b/theories/normedtype.v index 4ec620e77..63bd2b213 100644 --- a/theories/normedtype.v +++ b/theories/normedtype.v @@ -1,4 +1,5 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +From HB Require Import structures. 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 mathcomp_extra boolp classical_sets functions. @@ -191,40 +192,6 @@ Proof. by rewrite /limf_einf; under eq_fun do rewrite oppeK. Qed. End limf_esup_einf. -Definition pointed_of_zmodule (R : zmodType) : pointedType := PointedType R 0. - -Definition filtered_of_normedZmod (K : numDomainType) (R : normedZmodType K) - : filteredType R := Filtered.Pack (Filtered.Class - (@Pointed.class (pointed_of_zmodule R)) - (nbhs_ball_ (ball_ (fun x => `|x|)))). - -Section pseudoMetric_of_normedDomain. -Variables (K : numDomainType) (R : normedZmodType K). -Lemma ball_norm_center (x : R) (e : K) : 0 < e -> ball_ normr x e x. -Proof. by move=> ? /=; rewrite subrr normr0. Qed. -Lemma ball_norm_symmetric (x y : R) (e : K) : - ball_ normr x e y -> ball_ normr y e x. -Proof. by rewrite /= distrC. Qed. -Lemma ball_norm_triangle (x y z : R) (e1 e2 : K) : - ball_ normr x e1 y -> ball_ normr y e2 z -> ball_ normr x (e1 + e2) z. -Proof. -move=> /= ? ?; rewrite -(subr0 x) -(subrr y) opprD opprK (addrA x _ y) -addrA. -by rewrite (le_lt_trans (ler_norm_add _ _)) // ltr_add. -Qed. -Definition pseudoMetric_of_normedDomain - : PseudoMetric.mixin_of K (@entourage_ K R R (ball_ (fun x => `|x|))) - := PseudoMetricMixin ball_norm_center ball_norm_symmetric ball_norm_triangle erefl. - -Lemma nbhs_ball_normE : - @nbhs_ball_ K R R (ball_ normr) = nbhs_ (entourage_ (ball_ normr)). -Proof. -rewrite /nbhs_ entourage_E predeq2E => x A; split. - move=> [e egt0 sbeA]. - by exists [set xy | ball_ normr xy.1 e xy.2] => //; exists e. -by move=> [E [e egt0 sbeE] sEA]; exists e => // ??; apply/sEA/sbeE. -Qed. -End pseudoMetric_of_normedDomain. - Lemma nbhsN (R : numFieldType) (x : R) : nbhs (- x) = -%R @ x. Proof. rewrite predeqE => A; split=> //= -[] e e_gt0 xeA; exists e => //= y /=. @@ -275,125 +242,15 @@ exists (- x)%R; rewrite ?opprK//; apply: reA; rewrite ?eqr_oppLR//=. by rewrite opprK. Qed. -Module PseudoMetricNormedZmodule. -Section ClassDef. -Variable R : numDomainType. -Record mixin_of (T : normedZmodType R) (ent : set (set (T * T))) - (m : PseudoMetric.mixin_of R ent) := Mixin { - _ : PseudoMetric.ball m = ball_ (fun x => `| x |) }. - -Record class_of (T : Type) := Class { - base : Num.NormedZmodule.class_of R T; - pointed_mixin : Pointed.point_of T ; - nbhs_mixin : Filtered.nbhs_of T T ; - topological_mixin : @Topological.mixin_of T nbhs_mixin ; - uniform_mixin : @Uniform.mixin_of T nbhs_mixin ; - pseudoMetric_mixin : - @PseudoMetric.mixin_of R T (Uniform.entourage uniform_mixin) ; - mixin : @mixin_of (Num.NormedZmodule.Pack _ base) _ pseudoMetric_mixin +HB.mixin Record NormedZmod_PseudoMetric_eq (R : numDomainType) T + of Num.NormedZmodule R T & PseudoMetric R T := { + pseudo_metric_ball_norm : ball = ball_ (fun x : T => `| x |) }. -Local Coercion base : class_of >-> Num.NormedZmodule.class_of. -Definition base2 T c := @PseudoMetric.Class _ _ - (@Uniform.Class _ - (@Topological.Class _ - (Filtered.Class - (Pointed.Class (@base T c) (pointed_mixin c)) - (nbhs_mixin c)) - (topological_mixin c)) - (uniform_mixin c)) - (pseudoMetric_mixin c). -Local Coercion base2 : class_of >-> PseudoMetric.class_of. -(* TODO: base3? *) - -Structure type (phR : phant R) := - Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. - -Variables (phR : phant R) (T : Type) (cT : type phR). - -Definition class := let: Pack _ c := cT return class_of cT in c. -Definition clone c of phant_id class c := @Pack phR T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). -Definition pack (b0 : Num.NormedZmodule.class_of R T) lm0 um0 - (m0 : @mixin_of (@Num.NormedZmodule.Pack R (Phant R) T b0) lm0 um0) := - fun bT (b : Num.NormedZmodule.class_of R T) - & phant_id (@Num.NormedZmodule.class R (Phant R) bT) b => - fun uT (u : PseudoMetric.class_of R T) & phant_id (@PseudoMetric.class R uT) u => - fun (m : @mixin_of (Num.NormedZmodule.Pack _ b) _ u) & phant_id m m0 => - @Pack phR T (@Class T b u u u u u m). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition zmodType := @GRing.Zmodule.Pack cT xclass. -Definition normedZmodType := @Num.NormedZmodule.Pack R phR cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. -Definition uniformType := @Uniform.Pack cT xclass. -Definition pseudoMetricType := @PseudoMetric.Pack R cT xclass. -Definition pointed_zmodType := @GRing.Zmodule.Pack pointedType xclass. -Definition filtered_zmodType := @GRing.Zmodule.Pack filteredType xclass. -Definition topological_zmodType := @GRing.Zmodule.Pack topologicalType xclass. -Definition uniform_zmodType := @GRing.Zmodule.Pack uniformType xclass. -Definition pseudoMetric_zmodType := @GRing.Zmodule.Pack pseudoMetricType xclass. -Definition pointed_normedZmodType := @Num.NormedZmodule.Pack R phR pointedType xclass. -Definition filtered_normedZmodType := @Num.NormedZmodule.Pack R phR filteredType xclass. -Definition topological_normedZmodType := @Num.NormedZmodule.Pack R phR topologicalType xclass. -Definition uniform_normedZmodType := @Num.NormedZmodule.Pack R phR uniformType xclass. -Definition pseudoMetric_normedZmodType := @Num.NormedZmodule.Pack R phR pseudoMetricType xclass. - -End ClassDef. - -(*Definition numDomain_normedDomainType (R : numDomainType) : type (Phant R) := - Pack (Phant R) (@Class R _ _ (NumDomain.normed_mixin (NumDomain.class R))).*) - -Module Exports. -Coercion base : class_of >-> Num.NormedZmodule.class_of. -Coercion base2 : class_of >-> PseudoMetric.class_of. -Coercion sort : type >-> Sortclass. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion zmodType : type >-> GRing.Zmodule.type. -Canonical zmodType. -Coercion normedZmodType : type >-> Num.NormedZmodule.type. -Canonical normedZmodType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Coercion uniformType : type >-> Uniform.type. -Canonical uniformType. -Coercion pseudoMetricType : type >-> PseudoMetric.type. -Canonical pseudoMetricType. -Canonical pointed_zmodType. -Canonical filtered_zmodType. -Canonical topological_zmodType. -Canonical uniform_zmodType. -Canonical pseudoMetric_zmodType. -Canonical pointed_normedZmodType. -Canonical filtered_normedZmodType. -Canonical topological_normedZmodType. -Canonical uniform_normedZmodType. -Canonical pseudoMetric_normedZmodType. -Notation pseudoMetricNormedZmodType R := (type (Phant R)). -Notation PseudoMetricNormedZmodType R T m := - (@pack _ (Phant R) T _ _ _ m _ _ idfun _ _ idfun _ idfun). -Notation "[ 'pseudoMetricNormedZmodType' R 'of' T 'for' cT ]" := - (@clone _ (Phant R) T cT _ idfun) - (at level 0, format "[ 'pseudoMetricNormedZmodType' R 'of' T 'for' cT ]") : - form_scope. -Notation "[ 'pseudoMetricNormedZmodType' R 'of' T ]" := - (@clone _ (Phant R) T _ _ idfun) - (at level 0, format "[ 'pseudoMetricNormedZmodType' R 'of' T ]") : form_scope. -End Exports. - -End PseudoMetricNormedZmodule. -Export PseudoMetricNormedZmodule.Exports. + +#[short(type="pseudoMetricNormedZmodType")] +HB.structure Definition PseudoMetricNormedZmod (R : numDomainType) := + {T of Num.NormedZmodule R T & PseudoMetric R T + & NormedZmod_PseudoMetric_eq R T}. Section pseudoMetricnormedzmodule_lemmas. Context {K : numDomainType} {V : pseudoMetricNormedZmodType K}. @@ -401,7 +258,7 @@ Context {K : numDomainType} {V : pseudoMetricNormedZmodType K}. Local Notation ball_norm := (ball_ (@normr K V)). Lemma ball_normE : ball_norm = ball. -Proof. by case: V => ? [? ? ? ? ? ? []]. Qed. +Proof. by rewrite pseudo_metric_ball_norm. Qed. End pseudoMetricnormedzmodule_lemmas. @@ -490,22 +347,24 @@ apply: Build_ProperFilter => A /nbhs_ballP[_/posnumP[e] Ae]. exists (x + e%:num / 2); apply: Ae; last first. by rewrite eq_sym addrC -subr_eq subrr eq_sym. rewrite /ball /= opprD addrA subrr distrC subr0 ger0_norm //. -by rewrite {2}(splitr e%:num) ltr_spaddl. +by rewrite {2}(splitr e%:num) ltr_pwDl. Qed. #[global] Hint Extern 0 (ProperFilter _^') => (apply: Proper_dnbhs_numFieldType) : typeclass_instances. -Definition pinfty_nbhs (R : numFieldType) : set (set R) := +(** Some Topology on extended real numbers *) + +Definition pinfty_nbhs (R : numFieldType) : set_system R := fun P => exists M, M \is Num.real /\ forall x, M < x -> P x. Arguments pinfty_nbhs R : clear implicits. -Definition ninfty_nbhs (R : numFieldType) : set (set R) := +Definition ninfty_nbhs (R : numFieldType) : set_system R := fun P => exists M, M \is Num.real /\ forall x, x < M -> P x. Arguments ninfty_nbhs R : clear implicits. -Notation "+oo_ R" := (pinfty_nbhs [numFieldType of R]) +Notation "+oo_ R" := (pinfty_nbhs R) (only parsing) : ring_scope. -Notation "-oo_ R" := (ninfty_nbhs [numFieldType of R]) +Notation "-oo_ R" := (ninfty_nbhs R) (only parsing) : ring_scope. Notation "+oo" := (pinfty_nbhs _) : ring_scope. @@ -513,13 +372,12 @@ Notation "-oo" := (ninfty_nbhs _) : ring_scope. Section infty_nbhs_instances. Context {R : numFieldType}. -Let R_topologicalType := [topologicalType of R]. Implicit Types r : R. Global Instance proper_pinfty_nbhs : ProperFilter (pinfty_nbhs R). Proof. apply Build_ProperFilter. - by move=> P [M [Mreal MP]]; exists (M + 1); apply MP; rewrite ltr_addl. + by move=> P [M [Mreal MP]]; exists (M + 1); apply MP; rewrite ltrDl. split=> /= [|P Q [MP [MPr gtMP]] [MQ [MQr gtMQ]] |P Q sPQ [M [Mr gtM]]]. - by exists 0. - exists (maxr MP MQ); split=> [|x]; first exact: max_real. @@ -531,7 +389,7 @@ Global Instance proper_ninfty_nbhs : ProperFilter (ninfty_nbhs R). Proof. apply Build_ProperFilter. move=> P [M [Mr ltMP]]; exists (M - 1). - by apply: ltMP; rewrite gtr_addl oppr_lt0. + by apply: ltMP; rewrite gtrDl oppr_lt0. split=> /= [|P Q [MP [MPr ltMP]] [MQ [MQr ltMQ]] |P Q sPQ [M [Mr ltM]]]. - by exists 0. - exists (Num.min MP MQ); split=> [|x]; first exact: min_real. @@ -579,7 +437,7 @@ Lemma near_pinfty_div2 (A : set R) : (\forall k \near +oo, A k) -> (\forall k \near +oo, A (k / 2)). Proof. move=> [M [Mreal AM]]; exists (M * 2); split; first by rewrite realM. -by move=> x; rewrite -ltr_pdivl_mulr //; exact: AM. +by move=> x; rewrite -ltr_pdivlMr //; exact: AM. Qed. End infty_nbhs_instances. @@ -613,7 +471,7 @@ End infty_nbhs_instances. Section cvg_infty_numField. Context {R : numFieldType}. -Let cvgryPnum {F : set (set R)} {FF : Filter F} : [<-> +Let cvgryPnum {F : set_system R} {FF : Filter F} : [<-> (* 0 *) F --> +oo; (* 1 *) forall A, A \is Num.real -> \forall x \near F, A <= x; (* 2 *) forall A, A \is Num.real -> \forall x \near F, A < x; @@ -629,7 +487,7 @@ case=> [A [AR AF]] P [x [xR Px]]; near +oo_R => B. by near do [apply: Px; apply: (@lt_le_trans _ _ B) => //]; apply: AF. Unshelve. all: by end_near. Qed. -Let cvgrNyPnum {F : set (set R)} {FF : Filter F} : [<-> +Let cvgrNyPnum {F : set_system R} {FF : Filter F} : [<-> (* 0 *) F --> -oo; (* 1 *) forall A, A \is Num.real -> \forall x \near F, A >= x; (* 2 *) forall A, A \is Num.real -> \forall x \near F, A > x; @@ -645,7 +503,7 @@ case=> [A [AR AF]] P [x [xR Px]]; near -oo_R => B. by near do [apply: Px; apply: (@le_lt_trans _ _ B) => //]; apply: AF. Unshelve. all: end_near. Qed. -Context {T} {F : set (set T)} {FF : Filter F}. +Context {T} {F : set_system T} {FF : Filter F}. Implicit Types f : T -> R. Lemma cvgryPger f : @@ -699,7 +557,7 @@ Proof. by rewrite cvgrNyPltr. Qed. Lemma cvgNry f : (- f @ F --> +oo) <-> (f @ F --> -oo). Proof. rewrite cvgrNyPler cvgryPger; split=> Foo A Areal; -by near do rewrite -ler_opp2 ?opprK; apply: Foo; rewrite rpredN. +by near do rewrite -lerN2 ?opprK; apply: Foo; rewrite rpredN. Unshelve. all: end_near. Qed. Lemma cvgNrNy f : (- f @ F --> -oo) <-> (f @ F --> +oo). @@ -709,7 +567,7 @@ End cvg_infty_numField. Section cvg_infty_realField. Context {R : realFieldType}. -Context {T} {F : set (set T)} {FF : Filter F} (f : T -> R). +Context {T} {F : set_system T} {FF : Filter F} (f : T -> R). Lemma cvgryPge : f @ F --> +oo <-> forall A, \forall x \near F, A <= f x. Proof. @@ -745,7 +603,7 @@ Proof. by rewrite cvgrNyPlt. Qed. End cvg_infty_realField. -Lemma cvgrnyP {R : realType} {T} {F : set (set T)} {FF : Filter F} (f : T -> nat) : +Lemma cvgrnyP {R : realType} {T} {F : set_system T} {FF : Filter F} (f : T -> nat) : (((f n)%:R : R) @[n --> F] --> +oo) <-> (f @ F --> \oo). Proof. split=> [/cvgryPge|/cvgnyPge] Foo. @@ -760,7 +618,7 @@ Local Open Scope ereal_scope. Context {R : numFieldType}. -Let cvgeyPnum {F : set (set \bar R)} {FF : Filter F} : [<-> +Let cvgeyPnum {F : set_system \bar R} {FF : Filter F} : [<-> (* 0 *) F --> +oo; (* 1 *) forall A, A \is Num.real -> \forall x \near F, A%:E <= x; (* 2 *) forall A, A \is Num.real -> \forall x \near F, A%:E < x; @@ -776,7 +634,7 @@ case=> [A [AR AF]] P [x [xR Px]]; near +oo_R => B. by near do [apply: Px; rewrite (@lt_le_trans _ _ B%:E) ?lte_fin//]; apply: AF. Unshelve. all: end_near. Qed. -Let cvgeNyPnum {F : set (set \bar R)} {FF : Filter F} : [<-> +Let cvgeNyPnum {F : set_system \bar R} {FF : Filter F} : [<-> (* 0 *) F --> -oo; (* 1 *) forall A, A \is Num.real -> \forall x \near F, A%:E >= x; (* 2 *) forall A, A \is Num.real -> \forall x \near F, A%:E > x; @@ -792,7 +650,7 @@ case=> [A [AR AF]] P [x [xR Px]]; near -oo_R => B. by near do [apply: Px; rewrite (@le_lt_trans _ _ B%:E) ?lte_fin//]; apply: AF. Unshelve. all: end_near. Qed. -Context {T} {F : set (set T)} {FF : Filter F}. +Context {T} {F : set_system T} {FF : Filter F}. Implicit Types (f : T -> \bar R) (u : T -> R). Lemma cvgeyPger f : @@ -873,7 +731,7 @@ End ecvg_infty_numField. Section ecvg_infty_realField. Local Open Scope ereal_scope. Context {R : realFieldType}. -Context {T} {F : set (set T)} {FF : Filter F} (f : T -> \bar R). +Context {T} {F : set_system T} {FF : Filter F} (f : T -> \bar R). Lemma cvgeyPge : f @ F --> +oo <-> forall A, \forall x \near F, A%:E <= f x. Proof. @@ -909,781 +767,102 @@ Proof. by rewrite cvgeNyPlt. Qed. End ecvg_infty_realField. -Lemma cvgenyP {R : realType} {T} {F : set (set T)} {FF : Filter F} (f : T -> nat) : +Lemma cvgenyP {R : realType} {T} {F : set_system T} {FF : Filter F} (f : T -> nat) : (((f n)%:R : R)%:E @[n --> F] --> +oo%E) <-> (f @ F --> \oo). Proof. by rewrite cvgeryP cvgrnyP. Qed. (** Modules with a norm *) -Module NormedModule. - -Record mixin_of (K : numDomainType) - (V : pseudoMetricNormedZmodType K) (scale : K -> V -> V) := Mixin { - _ : forall (l : K) (x : V), `| scale l x | = `| l | * `| x |; +HB.mixin Record PseudoMetricNormedZmod_Lmodule_isNormedModule K V + of PseudoMetricNormedZmod K V & GRing.Lmodule K V := { + normrZ : forall (l : K) (x : V), `| l *: x | = `| l | * `| x |; }. -Section ClassDef. - -Variable K : numDomainType. - -Record class_of (T : Type) := Class { - base : PseudoMetricNormedZmodule.class_of K T ; - lmodmixin : GRing.Lmodule.mixin_of K (GRing.Zmodule.Pack base) ; - mixin : @mixin_of K (PseudoMetricNormedZmodule.Pack (Phant K) base) - (GRing.Lmodule.scale lmodmixin) -}. -Local Coercion base : class_of >-> PseudoMetricNormedZmodule.class_of. -Local Coercion base2 T (c : class_of T) : GRing.Lmodule.class_of K T := - @GRing.Lmodule.Class K T (base c) (lmodmixin c). -Local Coercion mixin : class_of >-> mixin_of. - -Structure type (phK : phant K) := - Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. - -Variables (phK : phant K) (T : Type) (cT : type phK). - -Definition class := let: Pack _ c := cT return class_of cT in c. -Definition clone c of phant_id class c := @Pack phK T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). - -Definition pack b0 l0 - (m0 : @mixin_of K (@PseudoMetricNormedZmodule.Pack K (Phant K) T b0) - (GRing.Lmodule.scale l0)) := - fun bT b & phant_id (@PseudoMetricNormedZmodule.class K (Phant K) bT) b => - fun l & phant_id l0 l => - fun m & phant_id m0 m => Pack phK (@Class T b l m). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition zmodType := @GRing.Zmodule.Pack cT xclass. -Definition normedZmodType := @Num.NormedZmodule.Pack K phK cT xclass. -Definition lmodType := @GRing.Lmodule.Pack K phK cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. -Definition uniformType := @Uniform.Pack cT xclass. -Definition pseudoMetricType := @PseudoMetric.Pack K cT xclass. -Definition pseudoMetricNormedZmodType := @PseudoMetricNormedZmodule.Pack K phK cT xclass. -Definition pointed_lmodType := @GRing.Lmodule.Pack K phK pointedType xclass. -Definition filtered_lmodType := @GRing.Lmodule.Pack K phK filteredType xclass. -Definition topological_lmodType := @GRing.Lmodule.Pack K phK topologicalType xclass. -Definition uniform_lmodType := @GRing.Lmodule.Pack K phK uniformType xclass. -Definition pseudoMetric_lmodType := @GRing.Lmodule.Pack K phK pseudoMetricType xclass. -Definition normedZmod_lmodType := @GRing.Lmodule.Pack K phK normedZmodType xclass. -Definition pseudoMetricNormedZmod_lmodType := @GRing.Lmodule.Pack K phK pseudoMetricNormedZmodType xclass. -End ClassDef. - -Module Exports. - -Coercion base : class_of >-> PseudoMetricNormedZmodule.class_of. -Coercion base2 : class_of >-> GRing.Lmodule.class_of. -Coercion mixin : class_of >-> mixin_of. -Coercion sort : type >-> Sortclass. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion zmodType : type >-> GRing.Zmodule.type. -Canonical zmodType. -Coercion normedZmodType : type >-> Num.NormedZmodule.type. -Canonical normedZmodType. -Coercion lmodType : type >-> GRing.Lmodule.type. -Canonical lmodType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Coercion uniformType : type >-> Uniform.type. -Canonical uniformType. -Coercion pseudoMetricType : type >-> PseudoMetric.type. -Canonical pseudoMetricType. -Coercion pseudoMetricNormedZmodType : type >-> PseudoMetricNormedZmodule.type. -Canonical pseudoMetricNormedZmodType. -Canonical pointed_lmodType. -Canonical filtered_lmodType. -Canonical topological_lmodType. -Canonical uniform_lmodType. -Canonical pseudoMetric_lmodType. -Canonical normedZmod_lmodType. -Canonical pseudoMetricNormedZmod_lmodType. -Notation normedModType K := (type (Phant K)). -Notation NormedModType K T m := (@pack _ (Phant K) T _ _ m _ _ idfun _ idfun _ idfun). -Notation NormedModMixin := Mixin. -Notation "[ 'normedModType' K 'of' T 'for' cT ]" := (@clone _ (Phant K) T cT _ idfun) - (at level 0, format "[ 'normedModType' K 'of' T 'for' cT ]") : form_scope. -Notation "[ 'normedModType' K 'of' T ]" := (@clone _ (Phant K) T _ _ id) - (at level 0, format "[ 'normedModType' K 'of' T ]") : form_scope. -End Exports. - -End NormedModule. - -Export NormedModule.Exports. - -Module regular_topology. +#[short(type="normedModType")] +HB.structure Definition NormedModule (K : numDomainType) := + {T of PseudoMetricNormedZmod K T & GRing.Lmodule K T + & PseudoMetricNormedZmod_Lmodule_isNormedModule K T}. Section regular_topology. -Local Canonical pseudoMetricNormedZmodType (R : numFieldType) := - @PseudoMetricNormedZmodType - R R^o - (PseudoMetricNormedZmodule.Mixin (erefl : @ball _ R = ball_ Num.norm)). -Local Canonical normedModType (R : numFieldType) := - NormedModType R R^o (@NormedModMixin _ _ ( *:%R : R -> R^o -> _) (@normrM _)). -End regular_topology. -Module Exports. -Canonical pseudoMetricNormedZmodType. -Canonical normedModType. -End Exports. +Variable R : numFieldType. + +HB.instance Definition _ := Num.NormedZmodule.on R^o. +HB.instance Definition _ := NormedZmod_PseudoMetric_eq.Build R R^o erefl. +HB.instance Definition _ := + PseudoMetricNormedZmod_Lmodule_isNormedModule.Build R R^o (@normrM _). End regular_topology. -Export regular_topology.Exports. Module numFieldNormedType. Section realType. Variable (R : realType). -Local Canonical real_lmodType := [lmodType R of R for [lmodType R of R^o]]. -Local Canonical real_lalgType := [lalgType R of R for [lalgType R of R^o]]. -Local Canonical real_algType := [algType R of R for [algType R of R^o]]. -Local Canonical real_comAlgType := [comAlgType R of R]. -Local Canonical real_unitAlgType := [unitAlgType R of R]. -Local Canonical real_comUnitAlgType := [comUnitAlgType R of R]. -Local Canonical real_vectType := [vectType R of R for [vectType R of R^o]]. -Local Canonical real_FalgType := [FalgType R of R]. -Local Canonical real_fieldExtType := - [fieldExtType R of R for [fieldExtType R of R^o]]. -Local Canonical real_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of R for [pseudoMetricNormedZmodType R of R^o]]. -Local Canonical real_normedModType := - [normedModType R of R for [normedModType R of R^o]]. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := GRing.ComAlgebra.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Vector.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := NormedModule.copy R R^o. End realType. Section rcfType. Variable (R : rcfType). -Local Canonical rcf_lmodType := [lmodType R of R for [lmodType R of R^o]]. -Local Canonical rcf_lalgType := [lalgType R of R for [lalgType R of R^o]]. -Local Canonical rcf_algType := [algType R of R for [algType R of R^o]]. -Local Canonical rcf_comAlgType := [comAlgType R of R]. -Local Canonical rcf_unitAlgType := [unitAlgType R of R]. -Local Canonical rcf_comUnitAlgType := [comUnitAlgType R of R]. -Local Canonical rcf_vectType := [vectType R of R for [vectType R of R^o]]. -Local Canonical rcf_FalgType := [FalgType R of R]. -Local Canonical rcf_fieldExtType := - [fieldExtType R of R for [fieldExtType R of R^o]]. -Local Canonical rcf_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of R for [pseudoMetricNormedZmodType R of R^o]]. -Local Canonical rcf_normedModType := - [normedModType R of R for [normedModType R of R^o]]. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := GRing.ComAlgebra.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Vector.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := NormedModule.copy R R^o. End rcfType. Section archiFieldType. Variable (R : archiFieldType). -Local Canonical archiField_lmodType := - [lmodType R of R for [lmodType R of R^o]]. -Local Canonical archiField_lalgType := - [lalgType R of R for [lalgType R of R^o]]. -Local Canonical archiField_algType := [algType R of R for [algType R of R^o]]. -Local Canonical archiField_comAlgType := [comAlgType R of R]. -Local Canonical archiField_unitAlgType := [unitAlgType R of R]. -Local Canonical archiField_comUnitAlgType := [comUnitAlgType R of R]. -Local Canonical archiField_vectType := - [vectType R of R for [vectType R of R^o]]. -Local Canonical archiField_FalgType := [FalgType R of R]. -Local Canonical archiField_fieldExtType := - [fieldExtType R of R for [fieldExtType R of R^o]]. -Local Canonical archiField_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of R for [pseudoMetricNormedZmodType R of R^o]]. -Local Canonical archiField_normedModType := - [normedModType R of R for [normedModType R of R^o]]. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := GRing.ComAlgebra.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Vector.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := NormedModule.copy R R^o. End archiFieldType. Section realFieldType. Variable (R : realFieldType). -Local Canonical realField_lmodType := [lmodType R of R for [lmodType R of R^o]]. -Local Canonical realField_lalgType := [lalgType R of R for [lalgType R of R^o]]. -Local Canonical realField_algType := [algType R of R for [algType R of R^o]]. -Local Canonical realField_comAlgType := [comAlgType R of R]. -Local Canonical realField_unitAlgType := [unitAlgType R of R]. -Local Canonical realField_comUnitAlgType := [comUnitAlgType R of R]. -Local Canonical realField_vectType := [vectType R of R for [vectType R of R^o]]. -Local Canonical realField_FalgType := [FalgType R of R]. -Local Canonical realField_fieldExtType := - [fieldExtType R of R for [fieldExtType R of R^o]]. -Local Canonical realField_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of R for [pseudoMetricNormedZmodType R of R^o]]. -Local Canonical realField_normedModType := - [normedModType R of R for [normedModType R of R^o]]. -Definition lmod_latticeType := [latticeType of realField_lmodType]. -Definition lmod_distrLatticeType := [distrLatticeType of realField_lmodType]. -Definition lmod_orderType := [orderType of realField_lmodType]. -Definition lmod_realDomainType := [realDomainType of realField_lmodType]. -Definition lalg_latticeType := [latticeType of realField_lalgType]. -Definition lalg_distrLatticeType := [distrLatticeType of realField_lalgType]. -Definition lalg_orderType := [orderType of realField_lalgType]. -Definition lalg_realDomainType := [realDomainType of realField_lalgType]. -Definition alg_latticeType := [latticeType of realField_algType]. -Definition alg_distrLatticeType := [distrLatticeType of realField_algType]. -Definition alg_orderType := [orderType of realField_algType]. -Definition alg_realDomainType := [realDomainType of realField_algType]. -Definition comAlg_latticeType := [latticeType of realField_comAlgType]. -Definition comAlg_distrLatticeType := - [distrLatticeType of realField_comAlgType]. -Definition comAlg_orderType := [orderType of realField_comAlgType]. -Definition comAlg_realDomainType := [realDomainType of realField_comAlgType]. -Definition unitAlg_latticeType := [latticeType of realField_unitAlgType]. -Definition unitAlg_distrLatticeType := - [distrLatticeType of realField_unitAlgType]. -Definition unitAlg_orderType := [orderType of realField_unitAlgType]. -Definition unitAlg_realDomainType := [realDomainType of realField_unitAlgType]. -Definition comUnitAlg_latticeType := [latticeType of realField_comUnitAlgType]. -Definition comUnitAlg_distrLatticeType := - [distrLatticeType of realField_comUnitAlgType]. -Definition comUnitAlg_orderType := [orderType of realField_comUnitAlgType]. -Definition comUnitAlg_realDomainType := - [realDomainType of realField_comUnitAlgType]. -Definition vect_latticeType := [latticeType of realField_vectType]. -Definition vect_distrLatticeType := [distrLatticeType of realField_vectType]. -Definition vect_orderType := [orderType of realField_vectType]. -Definition vect_realDomainType := [realDomainType of realField_vectType]. -Definition Falg_latticeType := [latticeType of realField_FalgType]. -Definition Falg_distrLatticeType := [distrLatticeType of realField_FalgType]. -Definition Falg_orderType := [orderType of realField_FalgType]. -Definition Falg_realDomainType := [realDomainType of realField_FalgType]. -Definition fieldExt_latticeType := [latticeType of realField_fieldExtType]. -Definition fieldExt_distrLatticeType := - [distrLatticeType of realField_fieldExtType]. -Definition fieldExt_orderType := [orderType of realField_fieldExtType]. -Definition fieldExt_realDomainType := - [realDomainType of realField_fieldExtType]. -Definition pseudoMetricNormedZmod_latticeType := - [latticeType of realField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_distrLatticeType := - [distrLatticeType of realField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_orderType := - [orderType of realField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_realDomainType := - [realDomainType of realField_pseudoMetricNormedZmodType]. -Definition normedMod_latticeType := [latticeType of realField_normedModType]. -Definition normedMod_distrLatticeType := - [distrLatticeType of realField_normedModType]. -Definition normedMod_orderType := [orderType of realField_normedModType]. -Definition normedMod_realDomainType := - [realDomainType of realField_normedModType]. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := GRing.ComAlgebra.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Vector.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := NormedModule.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Num.RealField.on R. End realFieldType. Section numClosedFieldType. Variable (R : numClosedFieldType). -Local Canonical numClosedField_lmodType := - [lmodType R of R for [lmodType R of R^o]]. -Local Canonical numClosedField_lalgType := - [lalgType R of R for [lalgType R of R^o]]. -Local Canonical numClosedField_algType := - [algType R of R for [algType R of R^o]]. -Local Canonical numClosedField_comAlgType := [comAlgType R of R]. -Local Canonical numClosedField_unitAlgType := [unitAlgType R of R]. -Local Canonical numClosedField_comUnitAlgType := [comUnitAlgType R of R]. -Local Canonical numClosedField_vectType := - [vectType R of R for [vectType R of R^o]]. -Local Canonical numClosedField_FalgType := [FalgType R of R]. -Local Canonical numClosedField_fieldExtType := - [fieldExtType R of R for [fieldExtType R of R^o]]. -Local Canonical numClosedField_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of R for [pseudoMetricNormedZmodType R of R^o]]. -Local Canonical numClosedField_normedModType := - [normedModType R of R for [normedModType R of R^o]]. -Definition lmod_decFieldType := [decFieldType of numClosedField_lmodType]. -Definition lmod_closedFieldType := [closedFieldType of numClosedField_lmodType]. -Definition lalg_decFieldType := [decFieldType of numClosedField_lalgType]. -Definition lalg_closedFieldType := [closedFieldType of numClosedField_lalgType]. -Definition alg_decFieldType := [decFieldType of numClosedField_algType]. -Definition alg_closedFieldType := [closedFieldType of numClosedField_algType]. -Definition comAlg_decFieldType := [decFieldType of numClosedField_comAlgType]. -Definition comAlg_closedFieldType := - [closedFieldType of numClosedField_comAlgType]. -Definition unitAlg_decFieldType := [decFieldType of numClosedField_unitAlgType]. -Definition unitAlg_closedFieldType := - [closedFieldType of numClosedField_unitAlgType]. -Definition comUnitAlg_decFieldType := - [decFieldType of numClosedField_comUnitAlgType]. -Definition comUnitAlg_closedFieldType := - [closedFieldType of numClosedField_comUnitAlgType]. -Definition vect_decFieldType := [decFieldType of numClosedField_vectType]. -Definition vect_closedFieldType := [closedFieldType of numClosedField_vectType]. -Definition Falg_decFieldType := [decFieldType of numClosedField_FalgType]. -Definition Falg_closedFieldType := [closedFieldType of numClosedField_FalgType]. -Definition fieldExt_decFieldType := - [decFieldType of numClosedField_fieldExtType]. -Definition fieldExt_closedFieldType := - [closedFieldType of numClosedField_fieldExtType]. -Definition pseudoMetricNormedZmod_decFieldType := - [decFieldType of numClosedField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_closedFieldType := - [closedFieldType of numClosedField_pseudoMetricNormedZmodType]. -Definition normedMod_decFieldType := - [decFieldType of numClosedField_normedModType]. -Definition normedMod_closedFieldType := - [closedFieldType of numClosedField_normedModType]. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := GRing.ComAlgebra.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Vector.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := NormedModule.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Num.ClosedField.on R. End numClosedFieldType. Section numFieldType. Variable (R : numFieldType). -Local Canonical numField_lmodType := [lmodType R of R for [lmodType R of R^o]]. -Local Canonical numField_lalgType := [lalgType R of R for [lalgType R of R^o]]. -Local Canonical numField_algType := [algType R of R for [algType R of R^o]]. -Local Canonical numField_comAlgType := [comAlgType R of R]. -Local Canonical numField_unitAlgType := [unitAlgType R of R]. -Local Canonical numField_comUnitAlgType := [comUnitAlgType R of R]. -Local Canonical numField_vectType := [vectType R of R for [vectType R of R^o]]. -Local Canonical numField_FalgType := [FalgType R of R]. -Local Canonical numField_fieldExtType := - [fieldExtType R of R for [fieldExtType R of R^o]]. -Local Canonical numField_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of R for [pseudoMetricNormedZmodType R of R^o]]. -Local Canonical numField_normedModType := - [normedModType R of R for [normedModType R of R^o]]. -Definition lmod_porderType := [porderType of numField_lmodType]. -Definition lmod_numDomainType := [numDomainType of numField_lmodType]. -Definition lalg_pointedType := [pointedType of numField_lalgType]. -Definition lalg_filteredType := [filteredType R of numField_lalgType]. -Definition lalg_topologicalType := [topologicalType of numField_lalgType]. -Definition lalg_uniformType := [uniformType of numField_lalgType]. -Definition lalg_pseudoMetricType := [pseudoMetricType R of numField_lalgType]. -Definition lalg_normedZmodType := [normedZmodType R of numField_lalgType]. -Definition lalg_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_lalgType]. -Definition lalg_normedModType := [normedModType R of numField_lalgType]. -Definition lalg_porderType := [porderType of numField_lalgType]. -Definition lalg_numDomainType := [numDomainType of numField_lalgType]. -Definition alg_pointedType := [pointedType of numField_algType]. -Definition alg_filteredType := [filteredType R of numField_algType]. -Definition alg_topologicalType := [topologicalType of numField_algType]. -Definition alg_uniformType := [uniformType of numField_algType]. -Definition alg_pseudoMetricType := [pseudoMetricType R of numField_algType]. -Definition alg_normedZmodType := [normedZmodType R of numField_algType]. -Definition alg_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_algType]. -Definition alg_normedModType := [normedModType R of numField_algType]. -Definition alg_porderType := [porderType of numField_algType]. -Definition alg_numDomainType := [numDomainType of numField_algType]. -Definition comAlg_pointedType := [pointedType of numField_comAlgType]. -Definition comAlg_filteredType := [filteredType R of numField_comAlgType]. -Definition comAlg_topologicalType := [topologicalType of numField_comAlgType]. -Definition comAlg_uniformType := [uniformType of numField_comAlgType]. -Definition comAlg_pseudoMetricType := - [pseudoMetricType R of numField_comAlgType]. -Definition comAlg_normedZmodType := [normedZmodType R of numField_comAlgType]. -Definition comAlg_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_comAlgType]. -Definition comAlg_normedModType := [normedModType R of numField_comAlgType]. -Definition comAlg_porderType := [porderType of numField_comAlgType]. -Definition comAlg_numDomainType := [numDomainType of numField_comAlgType]. -Definition unitAlg_pointedType := [pointedType of numField_unitAlgType]. -Definition unitAlg_filteredType := [filteredType R of numField_unitAlgType]. -Definition unitAlg_topologicalType := [topologicalType of numField_unitAlgType]. -Definition unitAlg_uniformType := [uniformType of numField_unitAlgType]. -Definition unitAlg_pseudoMetricType := - [pseudoMetricType R of numField_unitAlgType]. -Definition unitAlg_normedZmodType := [normedZmodType R of numField_unitAlgType]. -Definition unitAlg_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_unitAlgType]. -Definition unitAlg_normedModType := [normedModType R of numField_unitAlgType]. -Definition unitAlg_porderType := [porderType of numField_unitAlgType]. -Definition unitAlg_numDomainType := [numDomainType of numField_unitAlgType]. -Definition comUnitAlg_pointedType := [pointedType of numField_comUnitAlgType]. -Definition comUnitAlg_filteredType := - [filteredType R of numField_comUnitAlgType]. -Definition comUnitAlg_topologicalType := - [topologicalType of numField_comUnitAlgType]. -Definition comUnitAlg_uniformType := [uniformType of numField_comUnitAlgType]. -Definition comUnitAlg_pseudoMetricType := - [pseudoMetricType R of numField_comUnitAlgType]. -Definition comUnitAlg_normedZmodType := - [normedZmodType R of numField_comUnitAlgType]. -Definition comUnitAlg_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_comUnitAlgType]. -Definition comUnitAlg_normedModType := - [normedModType R of numField_comUnitAlgType]. -Definition comUnitAlg_porderType := [porderType of numField_comUnitAlgType]. -Definition comUnitAlg_numDomainType := - [numDomainType of numField_comUnitAlgType]. -Definition vect_pointedType := [pointedType of numField_vectType]. -Definition vect_filteredType := [filteredType R of numField_vectType]. -Definition vect_topologicalType := [topologicalType of numField_vectType]. -Definition vect_uniformType := [uniformType of numField_vectType]. -Definition vect_pseudoMetricType := [pseudoMetricType R of numField_vectType]. -Definition vect_normedZmodType := [normedZmodType R of numField_vectType]. -Definition vect_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_vectType]. -Definition vect_normedModType := [normedModType R of numField_vectType]. -Definition vect_porderType := [porderType of numField_vectType]. -Definition vect_numDomainType := [numDomainType of numField_vectType]. -Definition Falg_pointedType := [pointedType of numField_FalgType]. -Definition Falg_filteredType := [filteredType R of numField_FalgType]. -Definition Falg_topologicalType := [topologicalType of numField_FalgType]. -Definition Falg_uniformType := [uniformType of numField_FalgType]. -Definition Falg_pseudoMetricType := [pseudoMetricType R of numField_FalgType]. -Definition Falg_normedZmodType := [normedZmodType R of numField_FalgType]. -Definition Falg_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_FalgType]. -Definition Falg_normedModType := [normedModType R of numField_FalgType]. -Definition Falg_porderType := [porderType of numField_FalgType]. -Definition Falg_numDomainType := [numDomainType of numField_FalgType]. -Definition fieldExt_pointedType := [pointedType of numField_fieldExtType]. -Definition fieldExt_filteredType := [filteredType R of numField_fieldExtType]. -Definition fieldExt_topologicalType := - [topologicalType of numField_fieldExtType]. -Definition fieldExt_uniformType := [uniformType of numField_fieldExtType]. -Definition fieldExt_pseudoMetricType := - [pseudoMetricType R of numField_fieldExtType]. -Definition fieldExt_normedZmodType := - [normedZmodType R of numField_fieldExtType]. -Definition fieldExt_pseudoMetricNormedZmodType := - [pseudoMetricNormedZmodType R of numField_fieldExtType]. -Definition fieldExt_normedModType := [normedModType R of numField_fieldExtType]. -Definition fieldExt_porderType := [porderType of numField_fieldExtType]. -Definition fieldExt_numDomainType := [numDomainType of numField_fieldExtType]. -Definition pseudoMetricNormedZmod_ringType := - [ringType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_comRingType := - [comRingType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_unitRingType := - [unitRingType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_comUnitRingType := - [comUnitRingType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_idomainType := - [idomainType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_fieldType := - [fieldType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_porderType := - [porderType of numField_pseudoMetricNormedZmodType]. -Definition pseudoMetricNormedZmod_numDomainType := - [numDomainType of numField_pseudoMetricNormedZmodType]. -Definition normedMod_ringType := [ringType of numField_normedModType]. -Definition normedMod_comRingType := [comRingType of numField_normedModType]. -Definition normedMod_unitRingType := [unitRingType of numField_normedModType]. -Definition normedMod_comUnitRingType := - [comUnitRingType of numField_normedModType]. -Definition normedMod_idomainType := [idomainType of numField_normedModType]. -Definition normedMod_fieldType := [fieldType of numField_normedModType]. -Definition normedMod_porderType := [porderType of numField_normedModType]. -Definition normedMod_numDomainType := [numDomainType of numField_normedModType]. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := GRing.ComAlgebra.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Vector.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := NormedModule.copy R R^o. +#[export, non_forgetful_inheritance] +HB.instance Definition _ := Num.NumField.on R. End numFieldType. -Module Exports. -Export topology.numFieldTopology.Exports. -(* realType *) -Canonical real_lmodType. -Canonical real_lalgType. -Canonical real_algType. -Canonical real_comAlgType. -Canonical real_unitAlgType. -Canonical real_comUnitAlgType. -Canonical real_vectType. -Canonical real_FalgType. -Canonical real_fieldExtType. -Canonical real_pseudoMetricNormedZmodType. -Canonical real_normedModType. -Coercion real_lmodType : realType >-> lmodType. -Coercion real_lalgType : realType >-> lalgType. -Coercion real_algType : realType >-> algType. -Coercion real_comAlgType : realType >-> comAlgType. -Coercion real_unitAlgType : realType >-> unitAlgType. -Coercion real_comUnitAlgType : realType >-> comUnitAlgType. -Coercion real_vectType : realType >-> vectType. -Coercion real_FalgType : realType >-> FalgType. -Coercion real_fieldExtType : realType >-> fieldExtType. -Coercion real_pseudoMetricNormedZmodType : - realType >-> pseudoMetricNormedZmodType. -Coercion real_normedModType : realType >-> normedModType. -(* rcfType *) -Canonical rcf_lmodType. -Canonical rcf_lalgType. -Canonical rcf_algType. -Canonical rcf_comAlgType. -Canonical rcf_unitAlgType. -Canonical rcf_comUnitAlgType. -Canonical rcf_vectType. -Canonical rcf_FalgType. -Canonical rcf_fieldExtType. -Canonical rcf_pseudoMetricNormedZmodType. -Canonical rcf_normedModType. -Coercion rcf_lmodType : rcfType >-> lmodType. -Coercion rcf_lalgType : rcfType >-> lalgType. -Coercion rcf_algType : rcfType >-> algType. -Coercion rcf_comAlgType : rcfType >-> comAlgType. -Coercion rcf_unitAlgType : rcfType >-> unitAlgType. -Coercion rcf_comUnitAlgType : rcfType >-> comUnitAlgType. -Coercion rcf_vectType : rcfType >-> vectType. -Coercion rcf_FalgType : rcfType >-> FalgType. -Coercion rcf_fieldExtType : rcfType >-> fieldExtType. -Coercion rcf_pseudoMetricNormedZmodType : - rcfType >-> pseudoMetricNormedZmodType. -Coercion rcf_normedModType : rcfType >-> normedModType. -(* archiFieldType *) -Canonical archiField_lmodType. -Canonical archiField_lalgType. -Canonical archiField_algType. -Canonical archiField_comAlgType. -Canonical archiField_unitAlgType. -Canonical archiField_comUnitAlgType. -Canonical archiField_vectType. -Canonical archiField_FalgType. -Canonical archiField_fieldExtType. -Canonical archiField_pseudoMetricNormedZmodType. -Canonical archiField_normedModType. -Coercion archiField_lmodType : archiFieldType >-> lmodType. -Coercion archiField_lalgType : archiFieldType >-> lalgType. -Coercion archiField_algType : archiFieldType >-> algType. -Coercion archiField_comAlgType : archiFieldType >-> comAlgType. -Coercion archiField_unitAlgType : archiFieldType >-> unitAlgType. -Coercion archiField_comUnitAlgType : archiFieldType >-> comUnitAlgType. -Coercion archiField_vectType : archiFieldType >-> vectType. -Coercion archiField_FalgType : archiFieldType >-> FalgType. -Coercion archiField_fieldExtType : archiFieldType >-> fieldExtType. -Coercion archiField_pseudoMetricNormedZmodType : - archiFieldType >-> pseudoMetricNormedZmodType. -Coercion archiField_normedModType : archiFieldType >-> normedModType. -(* realFieldType *) -Canonical realField_lmodType. -Canonical realField_lalgType. -Canonical realField_algType. -Canonical realField_comAlgType. -Canonical realField_unitAlgType. -Canonical realField_comUnitAlgType. -Canonical realField_vectType. -Canonical realField_FalgType. -Canonical realField_fieldExtType. -Canonical realField_pseudoMetricNormedZmodType. -Canonical realField_normedModType. -Canonical lmod_latticeType. -Canonical lmod_distrLatticeType. -Canonical lmod_orderType. -Canonical lmod_realDomainType. -Canonical lalg_latticeType. -Canonical lalg_distrLatticeType. -Canonical lalg_orderType. -Canonical lalg_realDomainType. -Canonical alg_latticeType. -Canonical alg_distrLatticeType. -Canonical alg_orderType. -Canonical alg_realDomainType. -Canonical comAlg_latticeType. -Canonical comAlg_distrLatticeType. -Canonical comAlg_orderType. -Canonical comAlg_realDomainType. -Canonical unitAlg_latticeType. -Canonical unitAlg_distrLatticeType. -Canonical unitAlg_orderType. -Canonical unitAlg_realDomainType. -Canonical comUnitAlg_latticeType. -Canonical comUnitAlg_distrLatticeType. -Canonical comUnitAlg_orderType. -Canonical comUnitAlg_realDomainType. -Canonical vect_latticeType. -Canonical vect_distrLatticeType. -Canonical vect_orderType. -Canonical vect_realDomainType. -Canonical Falg_latticeType. -Canonical Falg_distrLatticeType. -Canonical Falg_orderType. -Canonical Falg_realDomainType. -Canonical fieldExt_latticeType. -Canonical fieldExt_distrLatticeType. -Canonical fieldExt_orderType. -Canonical fieldExt_realDomainType. -Canonical pseudoMetricNormedZmod_latticeType. -Canonical pseudoMetricNormedZmod_distrLatticeType. -Canonical pseudoMetricNormedZmod_orderType. -Canonical pseudoMetricNormedZmod_realDomainType. -Canonical normedMod_latticeType. -Canonical normedMod_distrLatticeType. -Canonical normedMod_orderType. -Canonical normedMod_realDomainType. -Coercion realField_lmodType : realFieldType >-> lmodType. -Coercion realField_lalgType : realFieldType >-> lalgType. -Coercion realField_algType : realFieldType >-> algType. -Coercion realField_comAlgType : realFieldType >-> comAlgType. -Coercion realField_unitAlgType : realFieldType >-> unitAlgType. -Coercion realField_comUnitAlgType : realFieldType >-> comUnitAlgType. -Coercion realField_vectType : realFieldType >-> vectType. -Coercion realField_FalgType : realFieldType >-> FalgType. -Coercion realField_fieldExtType : realFieldType >-> fieldExtType. -Coercion realField_pseudoMetricNormedZmodType : - Num.RealField.type >-> PseudoMetricNormedZmodule.type. -Coercion realField_normedModType : Num.RealField.type >-> NormedModule.type. -(* numClosedFieldType *) -Canonical numClosedField_lmodType. -Canonical numClosedField_lalgType. -Canonical numClosedField_algType. -Canonical numClosedField_comAlgType. -Canonical numClosedField_unitAlgType. -Canonical numClosedField_comUnitAlgType. -Canonical numClosedField_vectType. -Canonical numClosedField_FalgType. -Canonical numClosedField_fieldExtType. -Canonical numClosedField_pseudoMetricNormedZmodType. -Canonical numClosedField_normedModType. -Canonical lmod_decFieldType. -Canonical lmod_closedFieldType. -Canonical lalg_decFieldType. -Canonical lalg_closedFieldType. -Canonical alg_decFieldType. -Canonical alg_closedFieldType. -Canonical comAlg_decFieldType. -Canonical comAlg_closedFieldType. -Canonical unitAlg_decFieldType. -Canonical unitAlg_closedFieldType. -Canonical comUnitAlg_decFieldType. -Canonical comUnitAlg_closedFieldType. -Canonical vect_decFieldType. -Canonical vect_closedFieldType. -Canonical Falg_decFieldType. -Canonical Falg_closedFieldType. -Canonical fieldExt_decFieldType. -Canonical fieldExt_closedFieldType. -Canonical pseudoMetricNormedZmod_decFieldType. -Canonical pseudoMetricNormedZmod_closedFieldType. -Canonical normedMod_decFieldType. -Canonical normedMod_closedFieldType. -Coercion numClosedField_lmodType : numClosedFieldType >-> lmodType. -Coercion numClosedField_lalgType : numClosedFieldType >-> lalgType. -Coercion numClosedField_algType : numClosedFieldType >-> algType. -Coercion numClosedField_comAlgType : numClosedFieldType >-> comAlgType. -Coercion numClosedField_unitAlgType : numClosedFieldType >-> unitAlgType. -Coercion numClosedField_comUnitAlgType : numClosedFieldType >-> comUnitAlgType. -Coercion numClosedField_vectType : numClosedFieldType >-> vectType. -Coercion numClosedField_FalgType : numClosedFieldType >-> FalgType. -Coercion numClosedField_fieldExtType : numClosedFieldType >-> fieldExtType. -Coercion numClosedField_pseudoMetricNormedZmodType : - numClosedFieldType >-> pseudoMetricNormedZmodType. -Coercion numClosedField_normedModType : numClosedFieldType >-> normedModType. -(* numFieldType *) -Canonical numField_lmodType. -Canonical numField_lalgType. -Canonical numField_algType. -Canonical numField_comAlgType. -Canonical numField_unitAlgType. -Canonical numField_comUnitAlgType. -Canonical numField_vectType. -Canonical numField_FalgType. -Canonical numField_fieldExtType. -Canonical numField_pseudoMetricNormedZmodType. -Canonical numField_normedModType. -Canonical lmod_porderType. -Canonical lmod_numDomainType. -Canonical lalg_pointedType. -Canonical lalg_filteredType. -Canonical lalg_topologicalType. -Canonical lalg_uniformType. -Canonical lalg_pseudoMetricType. -Canonical lalg_normedZmodType. -Canonical lalg_pseudoMetricNormedZmodType. -Canonical lalg_normedModType. -Canonical lalg_porderType. -Canonical lalg_numDomainType. -Canonical alg_pointedType. -Canonical alg_filteredType. -Canonical alg_topologicalType. -Canonical alg_uniformType. -Canonical alg_pseudoMetricType. -Canonical alg_normedZmodType. -Canonical alg_pseudoMetricNormedZmodType. -Canonical alg_normedModType. -Canonical alg_porderType. -Canonical alg_numDomainType. -Canonical comAlg_pointedType. -Canonical comAlg_filteredType. -Canonical comAlg_topologicalType. -Canonical comAlg_uniformType. -Canonical comAlg_pseudoMetricType. -Canonical comAlg_normedZmodType. -Canonical comAlg_pseudoMetricNormedZmodType. -Canonical comAlg_normedModType. -Canonical comAlg_porderType. -Canonical comAlg_numDomainType. -Canonical unitAlg_pointedType. -Canonical unitAlg_filteredType. -Canonical unitAlg_topologicalType. -Canonical unitAlg_uniformType. -Canonical unitAlg_pseudoMetricType. -Canonical unitAlg_normedZmodType. -Canonical unitAlg_pseudoMetricNormedZmodType. -Canonical unitAlg_normedModType. -Canonical unitAlg_porderType. -Canonical unitAlg_numDomainType. -Canonical comUnitAlg_pointedType. -Canonical comUnitAlg_filteredType. -Canonical comUnitAlg_topologicalType. -Canonical comUnitAlg_uniformType. -Canonical comUnitAlg_pseudoMetricType. -Canonical comUnitAlg_normedZmodType. -Canonical comUnitAlg_pseudoMetricNormedZmodType. -Canonical comUnitAlg_normedModType. -Canonical comUnitAlg_porderType. -Canonical comUnitAlg_numDomainType. -Canonical vect_pointedType. -Canonical vect_filteredType. -Canonical vect_topologicalType. -Canonical vect_uniformType. -Canonical vect_pseudoMetricType. -Canonical vect_normedZmodType. -Canonical vect_pseudoMetricNormedZmodType. -Canonical vect_normedModType. -Canonical vect_porderType. -Canonical vect_numDomainType. -Canonical Falg_pointedType. -Canonical Falg_filteredType. -Canonical Falg_topologicalType. -Canonical Falg_uniformType. -Canonical Falg_pseudoMetricType. -Canonical Falg_normedZmodType. -Canonical Falg_pseudoMetricNormedZmodType. -Canonical Falg_normedModType. -Canonical Falg_porderType. -Canonical Falg_numDomainType. -Canonical fieldExt_pointedType. -Canonical fieldExt_filteredType. -Canonical fieldExt_topologicalType. -Canonical fieldExt_uniformType. -Canonical fieldExt_pseudoMetricType. -Canonical fieldExt_normedZmodType. -Canonical fieldExt_pseudoMetricNormedZmodType. -Canonical fieldExt_normedModType. -Canonical fieldExt_porderType. -Canonical fieldExt_numDomainType. -Canonical pseudoMetricNormedZmod_ringType. -Canonical pseudoMetricNormedZmod_comRingType. -Canonical pseudoMetricNormedZmod_unitRingType. -Canonical pseudoMetricNormedZmod_comUnitRingType. -Canonical pseudoMetricNormedZmod_idomainType. -Canonical pseudoMetricNormedZmod_fieldType. -Canonical pseudoMetricNormedZmod_porderType. -Canonical pseudoMetricNormedZmod_numDomainType. -Canonical normedMod_ringType. -Canonical normedMod_comRingType. -Canonical normedMod_unitRingType. -Canonical normedMod_comUnitRingType. -Canonical normedMod_idomainType. -Canonical normedMod_fieldType. -Canonical normedMod_porderType. -Canonical normedMod_numDomainType. -Coercion numField_lmodType : numFieldType >-> lmodType. -Coercion numField_lalgType : numFieldType >-> lalgType. -Coercion numField_algType : numFieldType >-> algType. -Coercion numField_comAlgType : numFieldType >-> comAlgType. -Coercion numField_unitAlgType : numFieldType >-> unitAlgType. -Coercion numField_comUnitAlgType : numFieldType >-> comUnitAlgType. -Coercion numField_vectType : numFieldType >-> vectType. -Coercion numField_FalgType : numFieldType >-> FalgType. -Coercion numField_fieldExtType : numFieldType >-> fieldExtType. -Coercion numField_pseudoMetricNormedZmodType : - numFieldType >-> pseudoMetricNormedZmodType. -Coercion numField_normedModType : numFieldType >-> normedModType. -End Exports. +Module Exports. Export numFieldTopology.Exports. HB.reexport. End Exports. End numFieldNormedType. Import numFieldNormedType.Exports. @@ -1700,9 +879,6 @@ Qed. Section NormedModule_numDomainType. Variables (R : numDomainType) (V : normedModType R). -Lemma normrZ l (x : V) : `| l *: x | = `| l | * `| x |. -Proof. by case: V x => V0 [a b [c]] //= v; rewrite c. Qed. - Lemma normrZV (x : V) : `|x| \in GRing.unit -> `| `| x |^-1 *: x | = 1. Proof. by move=> nxu; rewrite normrZ normrV// normr_id mulVr. Qed. @@ -1779,42 +955,42 @@ Proof. by move=> e1e2 y /lt_le_trans; apply. Qed. Let nbhs_simpl := (nbhs_simpl,@nbhs_nbhs_norm,@filter_from_norm_nbhs). -Lemma fcvgrPdist_lt {F : set (set V)} {FF : Filter F} (y : V) : +Lemma fcvgrPdist_lt {F : set_system V} {FF : Filter F} (y : V) : F --> y <-> forall eps, 0 < eps -> \forall y' \near F, `|y - y'| < eps. Proof. by rewrite -filter_fromP /= !nbhs_simpl. Qed. -Lemma cvgrPdist_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdist_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> forall eps, 0 < eps -> \forall t \near F, `|y - f t| < eps. Proof. exact: fcvgrPdist_lt. Qed. -Lemma cvgrPdistC_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdistC_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> forall eps, 0 < eps -> \forall t \near F, `|f t - y| < eps. Proof. by rewrite cvgrPdist_lt; under eq_forall do under eq_near do rewrite distrC. Qed. -Lemma cvgr_dist_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_dist_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall eps, eps > 0 -> \forall t \near F, `|y - f t| < eps. Proof. by move=> /cvgrPdist_lt. Qed. -Lemma __deprecated__cvg_dist {F : set (set V)} {FF : Filter F} (y : V) : +Lemma __deprecated__cvg_dist {F : set_system V} {FF : Filter F} (y : V) : F --> y -> forall eps, eps > 0 -> \forall y' \near F, `|y - y'| < eps. Proof. exact: cvgr_dist_lt. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="use `cvgr_dist_lt` or a variation instead")] Notation cvg_dist := __deprecated__cvg_dist (only parsing). -Lemma cvgr_distC_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_distC_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall eps, eps > 0 -> \forall t \near F, `|f t - y| < eps. Proof. by move=> /cvgrPdistC_lt. Qed. -Lemma cvgr_dist_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_dist_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall eps, eps > 0 -> \forall t \near F, `|y - f t| <= eps. Proof. by move=> ? ? ?; near do rewrite ltW//; apply: cvgr_dist_lt. Unshelve. all: by end_near. Qed. -Lemma cvgr_distC_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_distC_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall eps, eps > 0 -> \forall t \near F, `|f t - y| <= eps. Proof. by move=> ? ? ?; near do rewrite ltW//; apply: cvgr_distC_lt. @@ -1828,17 +1004,17 @@ rewrite nbhs_normP; split=> -[/= e e0 Pe]; by exists e => // y /=; have /= := Pe y; rewrite distrC subr0. Qed. -Lemma cvgr0Pnorm_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) : +Lemma cvgr0Pnorm_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) : f @ F --> 0 <-> forall eps, 0 < eps -> \forall t \near F, `|f t| < eps. Proof. by rewrite cvgrPdistC_lt; under eq_forall do under eq_near do rewrite subr0. Qed. -Lemma cvgr0_norm_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) : +Lemma cvgr0_norm_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) : f @ F --> 0 -> forall eps, eps > 0 -> \forall t \near F, `|f t| < eps. Proof. by move=> /cvgr0Pnorm_lt. Qed. -Lemma cvgr0_norm_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) : +Lemma cvgr0_norm_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) : f @ F --> 0 -> forall eps, eps > 0 -> \forall t \near F, `|f t| <= eps. Proof. by move=> ? ? ?; near do rewrite ltW//; apply: cvgr0_norm_lt. @@ -1908,21 +1084,6 @@ Section analysis_struct. Import Rdefinitions. Import Rstruct. -Canonical R_pointedType := [pointedType of R for pointed_of_zmodule R_ringType]. -Canonical R_filteredType := - [filteredType R of R for filtered_of_normedZmod R_normedZmodType]. -Canonical R_topologicalType : topologicalType := TopologicalType R - (topologyOfEntourageMixin - (uniformityOfBallMixin - (@nbhs_ball_normE _ R_normedZmodType) - (pseudoMetric_of_normedDomain R_normedZmodType))). -Canonical R_uniformType : uniformType := - UniformType R - (uniformityOfBallMixin (@nbhs_ball_normE _ R_normedZmodType) - (pseudoMetric_of_normedDomain R_normedZmodType)). -Canonical R_pseudoMetricType : pseudoMetricType R_numDomainType := - PseudoMetricType R (pseudoMetric_of_normedDomain R_normedZmodType). - (* TODO: express using ball?*) Lemma continuity_pt_nbhs (f : R -> R) x : Ranalysis1.continuity_pt f x <-> @@ -1973,7 +1134,7 @@ Lemma continuity_pt_dnbhs f x : Ranalysis1.continuity_pt f x <-> forall eps, 0 < eps -> x^' (fun u => `|f x - f u| < eps). Proof. -rewrite continuity_pt_cvg' (@cvgrPdist_lt _ [normedModType _ of R^o]). +rewrite continuity_pt_cvg' (@cvgrPdist_lt _ [the normedModType _ of R^o]). exact. Qed. @@ -2077,33 +1238,33 @@ Local Notation "x ^'+" := (at_right x) : classical_set_scope. Global Instance at_right_proper_filter (x : R) : ProperFilter x^'+. Proof. apply: Build_ProperFilter' => -[_/posnumP[d] /(_ (x + d%:num / 2))]. -apply; last (by rewrite ltr_addl); rewrite /=. +apply; last (by rewrite ltrDl); rewrite /=. rewrite opprD !addrA subrr add0r normrN normf_div !ger0_norm //. -by rewrite ltr_pdivr_mulr // ltr_pmulr // (_ : 1 = 1%:R) // ltr_nat. +by rewrite ltr_pdivrMr // ltr_pMr // (_ : 1 = 1%:R) // ltr_nat. Qed. Global Instance at_left_proper_filter (x : R) : ProperFilter x^'-. Proof. apply: Build_ProperFilter' => -[_ /posnumP[d] /(_ (x - d%:num / 2))]. -apply; last (by rewrite ltr_subl_addl ltr_addr); rewrite /=. +apply; last (by rewrite ltrBlDl ltrDr); rewrite /=. rewrite opprD !addrA subrr add0r opprK normf_div !ger0_norm //. -by rewrite ltr_pdivr_mulr // ltr_pmulr // (_ : 1 = 1%:R) // ltr_nat. +by rewrite ltr_pdivrMr // ltr_pMr // (_ : 1 = 1%:R) // ltr_nat. Qed. Lemma nbhs_right0P x (P : set R) : (\forall y \near x^'+, P y) <-> \forall e \near 0^'+, P (x + e). Proof. rewrite !near_withinE !near_simpl nbhs0P -propeqE. -by apply: (@eq_near _ (nbhs (0 : R))) => y; rewrite ltr_addl. +by apply: (@eq_near _ (nbhs (0 : R))) => y; rewrite ltrDl. Qed. Lemma nbhs_left0P x (P : set R) : (\forall y \near x^'-, P y) <-> \forall e \near 0^'+, P (x - e). Proof. rewrite !near_withinE !near_simpl nbhs0P; split=> Px. - rewrite -oppr0 nearN; near=> e; rewrite ltr_opp2 opprK => e_lt0. - by apply: (near Px) => //; rewrite gtr_addl. -by rewrite -oppr0 nearN; near=> e; rewrite gtr_addl oppr_lt0; apply: (near Px). + rewrite -oppr0 nearN; near=> e; rewrite ltrN2 opprK => e_lt0. + by apply: (near Px) => //; rewrite gtrDl. +by rewrite -oppr0 nearN; near=> e; rewrite gtrDl oppr_lt0; apply: (near Px). Unshelve. all: by end_near. Qed. Lemma nbhs_right_gt x : \forall y \near x^'+, x < y. @@ -2127,7 +1288,7 @@ Proof. by rewrite near_withinE; apply: nearW => ?; apply/ltW. Qed. Lemma nbhs_right_lt x z : x < z -> \forall y \near x^'+, y < z. Proof. move=> xz; exists (z - x) => //=; first by rewrite subr_gt0. -by move=> y /= + xy; rewrite distrC ?ger0_norm ?subr_ge0 1?ltW// ltr_add2r. +by move=> y /= + xy; rewrite distrC ?ger0_norm ?subr_ge0 1?ltW// ltrD2r. Qed. Lemma nbhs_right_le x z : x < z -> \forall y \near x^'+, y <= z. @@ -2136,7 +1297,7 @@ Unshelve. all: by end_near. Qed. Lemma nbhs_left_gt x z : z < x -> \forall y \near x^'-, z < y. Proof. -move=> xz; rewrite nbhs_left0P; near do rewrite -ltr_opp2 opprB ltr_subl_addl. +move=> xz; rewrite nbhs_left0P; near do rewrite -ltrN2 opprB ltrBlDl. by apply: nbhs_right_lt; rewrite subr_gt0. Unshelve. all: by end_near. Qed. @@ -2220,7 +1381,7 @@ Proof. move=> /[apply] -[] _/posnumP[r] /subset_ball_prop_in_itv xrA. exists r%:num => //= k; rewrite /= distrC subr0 set_itvoo => /ltr_normlW kr k0. by apply/(subset_trans _ xrA)/subset_itvW; - [rewrite ler_sub//; exact: ltW | rewrite ler_add//; exact: ltW]. + [rewrite lerB//; exact: ltW | rewrite lerD//; exact: ltW]. Qed. Lemma open_itvcc_subset : @@ -2231,8 +1392,8 @@ have -> : r%:num = 2 * (r%:num / 2) by rewrite mulrCA divff// mulr1. move/subset_ball_prop_in_itvcc => /= xrA; exists (r%:num / 2) => //= k. rewrite /= distrC subr0 set_itvcc => /ltr_normlW kr k0. move=> z /andP [xkz zxk]; apply: xrA => //; rewrite in_itv/=; apply/andP; split. - by rewrite (le_trans _ xkz)// ler_sub// ltW. -by rewrite (le_trans zxk)// ler_add// ltW. + by rewrite (le_trans _ xkz)// lerB// ltW. +by rewrite (le_trans zxk)// lerD// ltW. Qed. End open_itv_subset. @@ -2274,11 +1435,11 @@ split=> /nbhs_norm0P[/= _/posnumP[e] /(_ _) Px]; apply/nbhs_norm0P. exists e%:num => //= r /= re yr y xyr; rewrite -[y](addrNK x) addrC. by apply: Px; rewrite /= distrC (le_lt_trans _ re)// gtr0_norm. exists (e%:num / 2) => //= r /= re; apply: (Px (e%:num / 2)) => //=. - by rewrite gtr0_norm// ltr_pdivr_mulr// ltr_pmulr// ?(ltr_nat _ 1 2). + by rewrite gtr0_norm// ltr_pdivrMr// ltr_pMr// ?(ltr_nat _ 1 2). by rewrite opprD addNKr normrN ltW. Qed. -Let cvgrP {F : set (set V)} {FF : Filter F} (y : V) : [<-> +Let cvgrP {F : set_system V} {FF : Filter F} (y : V) : [<-> F --> y; forall eps, 0 < eps -> \forall t \near F, `|y - t| <= eps; \forall eps \near 0^'+, \forall t \near F, `|y - t| <= eps; @@ -2294,90 +1455,90 @@ tfae; first by move=> *; apply: cvgr_dist_le. by near: d; apply: nbhs_right_le. Unshelve. all: by end_near. Qed. -Lemma cvgrPdist_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdist_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> forall eps, 0 < eps -> \forall t \near F, `|y - f t| <= eps. Proof. exact: (cvgrP _ 0 1)%N. Qed. -Lemma cvgrPdist_ltp {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdist_ltp {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> \forall eps \near 0^'+, \forall t \near F, `|y - f t| < eps. Proof. exact: (cvgrP _ 0 3)%N. Qed. -Lemma cvgrPdist_lep {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdist_lep {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> \forall eps \near 0^'+, \forall t \near F, `|y - f t| <= eps. Proof. exact: (cvgrP _ 0 2)%N. Qed. -Lemma cvgrPdistC_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdistC_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> forall eps, 0 < eps -> \forall t \near F, `|f t - y| <= eps. Proof. rewrite cvgrPdist_le. by under [X in X <-> _]eq_forall do under eq_near do rewrite distrC. Qed. -Lemma cvgrPdistC_ltp {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdistC_ltp {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> \forall eps \near 0^'+, \forall t \near F, `|f t - y| < eps. Proof. by rewrite cvgrPdist_ltp; under eq_near do under eq_near do rewrite distrC. Qed. -Lemma cvgrPdistC_lep {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgrPdistC_lep {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y <-> \forall eps \near 0^'+, \forall t \near F, `|f t - y| <= eps. Proof. by rewrite cvgrPdist_lep; under eq_near do under eq_near do rewrite distrC. Qed. -Lemma cvgr0Pnorm_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) : +Lemma cvgr0Pnorm_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) : f @ F --> 0 <-> forall eps, 0 < eps -> \forall t \near F, `|f t| <= eps. Proof. rewrite cvgrPdistC_le. by under [X in X <-> _]eq_forall do under eq_near do rewrite subr0. Qed. -Lemma cvgr0Pnorm_ltp {T} {F : set (set T)} {FF : Filter F} (f : T -> V) : +Lemma cvgr0Pnorm_ltp {T} {F : set_system T} {FF : Filter F} (f : T -> V) : f @ F --> 0 <-> \forall eps \near 0^'+, \forall t \near F, `|f t| < eps. Proof. by rewrite cvgrPdistC_ltp; under eq_near do under eq_near do rewrite subr0. Qed. -Lemma cvgr0Pnorm_lep {T} {F : set (set T)} {FF : Filter F} (f : T -> V) : +Lemma cvgr0Pnorm_lep {T} {F : set_system T} {FF : Filter F} (f : T -> V) : f @ F --> 0 <-> \forall eps \near 0^'+, \forall t \near F, `|f t| <= eps. Proof. by rewrite cvgrPdistC_lep; under eq_near do under eq_near do rewrite subr0. Qed. -Lemma cvgr_norm_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_norm_lt {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall u, `|y| < u -> \forall t \near F, `|f t| < u. Proof. move=> Fy z zy; near (0:R)^'+ => k; near=> x; have : `|f x - y| < k. by near: x; apply: cvgr_distC_lt => //; near: k; apply: nbhs_right_gt. move=> /(le_lt_trans (ler_dist_dist _ _)) /real_ltr_normlW. -rewrite realB// ltr_subl_addl => /(_ _)/lt_le_trans; apply => //. -by rewrite -ler_subr_addl; near: k; apply: nbhs_right_le; rewrite subr_gt0. +rewrite realB// ltrBlDl => /(_ _)/lt_le_trans; apply => //. +by rewrite -lerBrDl; near: k; apply: nbhs_right_le; rewrite subr_gt0. Unshelve. all: by end_near. Qed. -Lemma cvgr_norm_le {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_norm_le {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall u, `|y| < u -> \forall t \near F, `|f t| <= u. Proof. by move=> fy u yu; near do apply/ltW; apply: cvgr_norm_lt yu. Unshelve. all: by end_near. Qed. -Lemma cvgr_norm_gt {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_norm_gt {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall u, `|y| > u -> \forall t \near F, `|f t| > u. Proof. move=> Fy z zy; near (0:R)^'+ => k; near=> x; have: `|f x - y| < k. by near: x; apply: cvgr_distC_lt => //; near: k; apply: nbhs_right_gt. move=> /(le_lt_trans (ler_dist_dist _ _)); rewrite distrC => /real_ltr_normlW. -rewrite realB// ltr_subl_addl -ltr_subl_addr => /(_ isT); apply: le_lt_trans. -rewrite ler_subr_addl -ler_subr_addr; near: k; apply: nbhs_right_le. +rewrite realB// ltrBlDl -ltrBlDr => /(_ isT); apply: le_lt_trans. +rewrite lerBrDl -lerBrDr; near: k; apply: nbhs_right_le. by rewrite subr_gt0. Unshelve. all: by end_near. Qed. -Lemma cvgr_norm_ge {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_norm_ge {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> forall u, `|y| > u -> \forall t \near F, `|f t| >= u. Proof. by move=> fy u yu; near do apply/ltW; apply: cvgr_norm_gt yu. Unshelve. all: by end_near. Qed. -Lemma cvgr_neq0 {T} {F : set (set T)} {FF : Filter F} (f : T -> V) (y : V) : +Lemma cvgr_neq0 {T} {F : set_system T} {FF : Filter F} (f : T -> V) (y : V) : f @ F --> y -> y != 0 -> \forall t \near F, f t != 0. Proof. move=> Fy z; near do rewrite -normr_gt0. @@ -2434,16 +1595,16 @@ Arguments cvgr_neq0 {R V T F FF f}. Section at_left_rightR. Variable (R : numFieldType). -Lemma real_cvgr_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma real_cvgr_lt {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : y \is Num.real -> f @ F --> y -> forall z, z > y -> \forall t \near F, f t \is Num.real -> f t < z. Proof. move=> yr Fy z zy; near=> x => fxr. -rewrite -(ltr_add2r (- y)) real_ltr_normlW// ?rpredB//. +rewrite -(ltrD2r (- y)) real_ltr_normlW// ?rpredB//. by near: x; apply: cvgr_distC_lt => //; rewrite subr_gt0. Unshelve. all: by end_near. Qed. -Lemma real_cvgr_le {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma real_cvgr_le {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : y \is Num.real -> f @ F --> y -> forall z, z > y -> \forall t \near F, f t \is Num.real -> f t <= z. Proof. @@ -2451,16 +1612,16 @@ move=> /real_cvgr_lt/[apply] + ? z0 => /(_ _ z0). by apply: filterS => ? /[apply]/ltW. Qed. -Lemma real_cvgr_gt {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma real_cvgr_gt {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : y \is Num.real -> f @ F --> y -> forall z, y > z -> \forall t \near F, f t \is Num.real -> f t > z. Proof. move=> yr Fy z zy; near=> x => fxr. -rewrite -ltr_opp2 -(ltr_add2l y) real_ltr_normlW// ?rpredB//. +rewrite -ltrN2 -(ltrD2l y) real_ltr_normlW// ?rpredB//. by near: x; apply: cvgr_dist_lt => //; rewrite subr_gt0. Unshelve. all: by end_near. Qed. -Lemma real_cvgr_ge {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma real_cvgr_ge {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : y \is Num.real -> f @ F --> y -> forall z, z < y -> \forall t \near F, f t \is Num.real -> f t >= z. Proof. @@ -2484,27 +1645,27 @@ rewrite nbhsr0P -propeqE; apply: eq_near => y /=. by rewrite -propeqE; apply: eq_forall => z; rewrite ler_distlC. Qed. -Lemma cvgr_lt {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma cvgr_lt {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : f @ F --> y -> forall z, z > y -> \forall t \near F, f t < z. Proof. -move=> Fy z zy; near=> x; rewrite -(ltr_add2r (- y)) ltr_normlW//. +move=> Fy z zy; near=> x; rewrite -(ltrD2r (- y)) ltr_normlW//. by near: x; apply: cvgr_distC_lt => //; rewrite subr_gt0. Unshelve. all: by end_near. Qed. -Lemma cvgr_le {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma cvgr_le {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : f @ F --> y -> forall z, z > y -> \forall t \near F, f t <= z. Proof. by move=> /cvgr_lt + ? z0 => /(_ _ z0); apply: filterS => ?; apply/ltW. Qed. -Lemma cvgr_gt {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma cvgr_gt {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : f @ F --> y -> forall z, y > z -> \forall t \near F, f t > z. Proof. -move=> Fy z zy; near=> x; rewrite -ltr_opp2 -(ltr_add2l y) ltr_normlW//. +move=> Fy z zy; near=> x; rewrite -ltrN2 -(ltrD2l y) ltr_normlW//. by near: x; apply: cvgr_dist_lt => //; rewrite subr_gt0. Unshelve. all: by end_near. Qed. -Lemma cvgr_ge {T} {F : set (set T)} {FF : Filter F} (f : T -> R) (y : R) : +Lemma cvgr_ge {T} {F : set_system T} {FF : Filter F} (f : T -> R) (y : R) : f @ F --> y -> forall z, z < y -> \forall t \near F, f t >= z. Proof. by move=> /cvgr_gt + ? z0 => /(_ _ z0); apply: filterS => ?; apply/ltW. @@ -2524,20 +1685,20 @@ Definition fun1 {T : Type} {K : numFieldType} : T -> K := fun=> 1. Arguments fun1 {T K} x /. Definition dominated_by {T : Type} {K : numDomainType} {V W : pseudoMetricNormedZmodType K} - (h : T -> V) (k : K) (f : T -> W) (F : set (set T)) := + (h : T -> V) (k : K) (f : T -> W) (F : set_system T) := F [set x | `|f x| <= k * `|h x|]. Definition strictly_dominated_by {T : Type} {K : numDomainType} {V W : pseudoMetricNormedZmodType K} - (h : T -> V) (k : K) (f : T -> W) (F : set (set T)) := + (h : T -> V) (k : K) (f : T -> W) (F : set_system T) := F [set x | `|f x| < k * `|h x|]. Lemma sub_dominatedl (T : Type) (K : numDomainType) (V W : pseudoMetricNormedZmodType K) - (h : T -> V) (k : K) (F G : set (set T)) : F `=>` G -> + (h : T -> V) (k : K) (F G : set_system T) : F `=>` G -> (@dominated_by T K V W h k)^~ G `<=` (dominated_by h k)^~ F. Proof. by move=> FG f; exact: FG. Qed. Lemma sub_dominatedr (T : Type) (K : numDomainType) (V : pseudoMetricNormedZmodType K) - (h : T -> V) (k : K) (f g : T -> V) (F : set (set T)) (FF : Filter F) : + (h : T -> V) (k : K) (f g : T -> V) (F : set_system T) (FF : Filter F) : (\forall x \near F, `|f x| <= `|g x|) -> dominated_by h k g F -> dominated_by h k f F. Proof. by move=> le_fg; apply: filterS2 le_fg => x; apply: le_trans. Qed. @@ -2558,7 +1719,7 @@ by congr F; rewrite funeqE => x/=; rewrite normr1 mulr1. Qed. Lemma ex_dom_bound {T : Type} {K : numFieldType} {V W : pseudoMetricNormedZmodType K} - (h : T -> V) (f : T -> W) (F : set (set T)) {PF : ProperFilter F}: + (h : T -> V) (f : T -> W) (F : set_system T) {PF : ProperFilter F}: (\forall M \near +oo, dominated_by h M f F) <-> exists M, dominated_by h M f F. Proof. @@ -2572,12 +1733,12 @@ have [] := pselect (exists x, (h x != 0) && (`|f x| <= M * `|h x|)); last first. case => x0 /andP[hx0_neq0] /(le_trans (normr_ge0 _)) /ger0_real. rewrite realrM // ?normr_eq0// => M_real. exists M; split => // k Mk; apply: filterS FM => x /le_trans/= ->//. -by rewrite ler_wpmul2r// ltW. +by rewrite ler_wpM2r// ltW. Qed. Lemma ex_strict_dom_bound {T : Type} {K : numFieldType} {V W : pseudoMetricNormedZmodType K} - (h : T -> V) (f : T -> W) (F : set (set T)) {PF : ProperFilter F} : + (h : T -> V) (f : T -> W) (F : set_system T) {PF : ProperFilter F} : (\forall x \near F, h x != 0) -> (\forall M \near +oo, dominated_by h M f F) <-> exists M, strictly_dominated_by h M f F. @@ -2585,12 +1746,12 @@ Proof. move=> hN0; rewrite ex_dom_bound /dominated_by /strictly_dominated_by. split => -[] M FM; last by exists M; apply: filterS FM => x /ltW. exists (M + 1); apply: filterS2 hN0 FM => x hN0 /le_lt_trans/= ->//. -by rewrite ltr_pmul2r ?normr_gt0// ltr_addl. +by rewrite ltr_pM2r ?normr_gt0// ltrDl. Qed. Definition bounded_near {T : Type} {K : numFieldType} {V : pseudoMetricNormedZmodType K} - (f : T -> V) (F : set (set T)) := + (f : T -> V) (F : set_system T) := \forall M \near +oo, F [set x | `|f x| <= M]. Lemma boundedE {T : Type} {K : numFieldType} {V : pseudoMetricNormedZmodType K} : @@ -2598,12 +1759,12 @@ Lemma boundedE {T : Type} {K : numFieldType} {V : pseudoMetricNormedZmodType K} Proof. by rewrite dominated_by1. Qed. Lemma sub_boundedr (T : Type) (K : numFieldType) (V : pseudoMetricNormedZmodType K) - (F G : set (set T)) : F `=>` G -> + (F G : set_system T) : F `=>` G -> (@bounded_near T K V)^~ G `<=` bounded_near^~ F. Proof. by move=> FG f; rewrite /bounded_near; apply: filterS=> M; apply: FG. Qed. Lemma sub_boundedl (T : Type) (K : numFieldType) (V : pseudoMetricNormedZmodType K) - (f g : T -> V) (F : set (set T)) (FF : Filter F) : + (f g : T -> V) (F : set_system T) (FF : Filter F) : (\forall x \near F, `|f x| <= `|g x|) -> bounded_near g F -> bounded_near f F. Proof. move=> le_fg; rewrite /bounded_near; apply: filterS => M. @@ -2611,12 +1772,12 @@ by apply: filterS2 le_fg => x; apply: le_trans. Qed. Lemma ex_bound {T : Type} {K : numFieldType} {V : pseudoMetricNormedZmodType K} - (f : T -> V) (F : set (set T)) {PF : ProperFilter F}: + (f : T -> V) (F : set_system T) {PF : ProperFilter F}: bounded_near f F <-> exists M, F [set x | `|f x| <= M]. Proof. by rewrite boundedE ex_dom_bound dominated_by1. Qed. Lemma ex_strict_bound {T : Type} {K : numFieldType} {V : pseudoMetricNormedZmodType K} - (f : T -> V) (F : set (set T)) {PF : ProperFilter F}: + (f : T -> V) (F : set_system T) {PF : ProperFilter F}: bounded_near f F <-> exists M, F [set x | `|f x| < M]. Proof. rewrite boundedE ex_strict_dom_bound ?strictly_dominated_by1//. @@ -2624,11 +1785,11 @@ by near=> x; rewrite oner_eq0. Unshelve. all: by end_near. Qed. Lemma ex_strict_bound_gt0 {T : Type} {K : numFieldType} {V : pseudoMetricNormedZmodType K} - (f : T -> V) (F : set (set T)) {PF : Filter F}: + (f : T -> V) (F : set_system T) {PF : Filter F}: bounded_near f F -> exists2 M, M > 0 & F [set x | `|f x| < M]. Proof. move=> /pinfty_ex_gt0[M M_gt0 FM]; exists (M + 1); rewrite ?addr_gt0//. -by apply: filterS FM => x /le_lt_trans/= ->//; rewrite ltr_addl. +by apply: filterS FM => x /le_lt_trans/= ->//; rewrite ltrDl. Qed. Notation "[ 'bounded' E | x 'in' A ]" := @@ -2640,7 +1801,7 @@ Lemma bounded_fun_has_ubound (T : Type) (R : realFieldType) (a : T -> R) : bounded_fun a -> has_ubound (range a). Proof. move=> [M [Mreal]]/(_ (`|M| + 1)). -rewrite (le_lt_trans (ler_norm _)) ?ltr_addl// => /(_ erefl) aM. +rewrite (le_lt_trans (ler_norm _)) ?ltrDl// => /(_ erefl) aM. by exists (`|M| + 1) => _ [n _ <-]; rewrite (le_trans (ler_norm _))// aM. Qed. @@ -2663,8 +1824,8 @@ Lemma bounded_funD (T : Type) (R : realFieldType) (a b : T -> R) : Proof. move=> [M [Mreal Ma]] [N [Nreal Nb]]. rewrite /bounded_fun/bounded_near; near=> x => y /= _. -rewrite (le_trans (ler_norm_add _ _))// [x]splitr. -by rewrite ler_add// (Ma, Nb)// ltr_pdivl_mulr//; +rewrite (le_trans (ler_normD _ _))// [x]splitr. +by rewrite lerD// (Ma, Nb)// ltr_pdivlMr//; near: x; apply: nbhs_pinfty_gt; rewrite ?rpredM ?rpred_nat. Unshelve. all: by end_near. Qed. @@ -2677,21 +1838,21 @@ Notation "k .-lipschitz_on f" := (dominated_by (self_sub id) k (self_sub f)) : type_scope. Definition sub_klipschitz (K : numFieldType) (V W : normedModType K) (k : K) - (f : V -> W) (F G : set (set (V * V))) : + (f : V -> W) (F G : set_system (V * V)) : F `=>` G -> k.-lipschitz_on f G -> k.-lipschitz_on f F. Proof. exact. Qed. Definition lipschitz_on (K : numFieldType) (V W : normedModType K) - (f : V -> W) (F : set (set (V * V))) := + (f : V -> W) (F : set_system (V * V)) := \forall M \near +oo, M.-lipschitz_on f F. Definition sub_lipschitz (K : numFieldType) (V W : normedModType K) - (f : V -> W) (F G : set (set (V * V))) : + (f : V -> W) (F G : set_system (V * V)) : F `=>` G -> lipschitz_on f G -> lipschitz_on f F. Proof. by move=> FG; rewrite /lipschitz_on; apply: filterS => M; apply: FG. Qed. Lemma klipschitzW (K : numFieldType) (V W : normedModType K) (k : K) - (f : V -> W) (F : set (set (V * V))) {PF : ProperFilter F} : + (f : V -> W) (F : set_system (V * V)) {PF : ProperFilter F} : k.-lipschitz_on f F -> lipschitz_on f F. Proof. by move=> f_lip; apply/ex_dom_bound; exists k. Qed. @@ -2746,7 +1907,7 @@ Proof. case => q [q1 ctrfq] Ux Uy fixx fixy; apply/subr0_eq/normr0_eq0/eqP. have [->|xyneq] := eqVneq x y; first by rewrite subrr normr0. have xypos : 0 < `|x - y| by rewrite normr_gt0 subr_eq0. -suff : `|x - y| <= q%:num * `|x - y| by rewrite ler_pmull // leNgt q1. +suff : `|x - y| <= q%:num * `|x - y| by rewrite ler_pMl // leNgt q1. by rewrite [in leLHS]fixx [in leLHS]fixy; exact: (ctrfq (_, _)). Qed. @@ -2765,8 +1926,8 @@ set r := PosNum ab2; exists (r, r) => /=. apply/negPn/negP => /set0P[c] []; rewrite -ball_normE /ball_ => acr bcr. have r22 : r%:num * 2 = r%:num + r%:num. by rewrite (_ : 2 = 1 + 1) // mulrDr mulr1. -move: (ltr_add acr bcr); rewrite -r22 (distrC b c). -move/(le_lt_trans (ler_dist_add c a b)). +move: (ltrD acr bcr); rewrite -r22 (distrC b c). +move/(le_lt_trans (ler_distD c a b)). by rewrite -mulrA mulVr ?mulr1 ?ltxx // unitfE. Qed. Hint Extern 0 (hausdorff_space _) => solve[apply: norm_hausdorff] : core. @@ -2782,7 +1943,7 @@ Lemma norm_cvg_unique {F} {FF : ProperFilter F} : is_subset1 [set x : V | F --> Proof. exact: cvg_unique. Qed. Lemma norm_cvg_eq (x y : V) : x --> y -> x = y. Proof. exact: (@cvg_eq V). Qed. -Lemma norm_lim_id (x : V) : lim x = x. Proof. exact: lim_id. Qed. +Lemma norm_lim_id (x : V) : lim (nbhs x) = x. Proof. exact: lim_id. Qed. Lemma norm_cvg_lim {F} {FF : ProperFilter F} (l : V) : F --> l -> lim F = l. Proof. exact: (@cvg_lim V). Qed. @@ -2818,7 +1979,7 @@ Proof. by have := @ball_splitl _ _ z x y e; rewrite -ball_normE. Qed. Lemma normm_leW (x : V) (e : R) : e > 0 -> `|x| <= e / 2 -> `|x| < e. Proof. -by move=> /posnumP[{}e] /le_lt_trans ->//; rewrite [ltRHS]splitr ltr_spaddl. +by move=> /posnumP[{}e] /le_lt_trans ->//; rewrite [ltRHS]splitr ltr_pwDl. Qed. Lemma normm_lt_split (x y : V) (e : R) : @@ -2827,7 +1988,7 @@ Proof. by move=> xlt ylt; rewrite -[y]opprK (@distm_lt_split 0) ?subr0 ?opprK ?add0r. Qed. -Lemma __deprecated__cvg_distW {F : set (set V)} {FF : Filter F} (y : V) : +Lemma __deprecated__cvg_distW {F : set_system V} {FF : Filter F} (y : V) : (forall eps, 0 < eps -> \forall y' \near F, `|y - y'| <= eps) -> F --> y. Proof. by move=> /cvgrPdist_le. Qed. @@ -2844,7 +2005,7 @@ Section NormedModule_numFieldType. Variables (R : numFieldType) (V : normedModType R). Section cvgr_norm_infty. -Variables (I : Type) (F : set (set I)) (FF : Filter F) (f : I -> V) (y : V). +Variables (I : Type) (F : set_system I) (FF : Filter F) (f : I -> V) (y : V). Lemma cvgr_norm_lty : f @ F --> y -> \forall M \near +oo, \forall y' \near F, `|f y'| < M. @@ -2871,11 +2032,11 @@ Unshelve. all: by end_near. Qed. End cvgr_norm_infty. -Lemma __deprecated__cvg_bounded_real {F : set (set V)} {FF : Filter F} (y : V) : +Lemma __deprecated__cvg_bounded_real {F : set_system V} {FF : Filter F} (y : V) : F --> y -> \forall M \near +oo, \forall y' \near F, `|y'| < M. Proof. exact: cvgr_norm_lty. Qed. -Lemma cvg_bounded {I} {F : set (set I)} {FF : Filter F} (f : I -> V) (y : V) : +Lemma cvg_bounded {I} {F : set_system I} {FF : Filter F} (f : I -> V) (y : V) : f @ F --> y -> bounded_near f F. Proof. exact: cvgr_norm_ley. Qed. @@ -3007,8 +2168,8 @@ Lemma ler_mx_norm_add x y : mx_norm (x + y) <= mx_norm x + mx_norm y. Proof. rewrite !mx_normE [_ <= _%:num]num_le; apply/bigmax_leP. split=> [|ij _]; first exact: addr_ge0. -rewrite mxE; apply: le_trans (ler_norm_add _ _) _. -by rewrite ler_add// -[leLHS]nngE num_le; exact: le_bigmax. +rewrite mxE; apply: le_trans (ler_normD _ _) _. +by rewrite lerD// -[leLHS]nngE num_le; exact: le_bigmax. Qed. Lemma mx_norm_eq0 x : mx_norm x = 0 -> x = 0. @@ -3066,12 +2227,10 @@ elim/big_ind2 : _ => //= a a' b b' ->{a'} ->{b'}. by have [ab|ab] := leP a b; [rewrite max_r | rewrite max_l // ltW]. Qed. -Definition matrix_normedZmodMixin (K : numDomainType) (m n : nat) := - @Num.NormedMixin _ _ _ (@mx_norm K m.+1 n.+1) (@ler_mx_norm_add _ _ _) - (@mx_norm_eq0 _ _ _) (@mx_norm_natmul _ _ _) (@mx_normN _ _ _). - -Canonical matrix_normedZmodType (K : numDomainType) (m n : nat) := - NormedZmodType K 'M[K]_(m.+1, n.+1) (matrix_normedZmodMixin K m n). +HB.instance Definition _ (K : numDomainType) (m n : nat) := + Num.Zmodule_isNormed.Build K 'M[K]_(m, n) + (@ler_mx_norm_add _ _ _) (@mx_norm_eq0 _ _ _) + (@mx_norm_natmul _ _ _) (@mx_normN _ _ _). Section matrix_NormedModule. Variables (K : numFieldType) (m n : nat). @@ -3080,7 +2239,7 @@ Local Lemma ball_gt0 (x y : 'M[K]_(m.+1, n.+1)) e : ball x e y -> 0 < e. Proof. by move/(_ ord0 ord0); apply: le_lt_trans. Qed. Lemma mx_norm_ball : - @ball _ [pseudoMetricType K of 'M[K]_(m.+1, n.+1)] = ball_ (fun x => `| x |). + @ball _ [the pseudoMetricType K of 'M[K]_(m.+1, n.+1)] = ball_ (fun x => `| x |). Proof. rewrite /normr /ball_ predeq3E => x e y /=; rewrite mx_normE; split => xey. - have e_gt0 : 0 < e := ball_gt0 xey. @@ -3093,10 +2252,8 @@ rewrite /normr /ball_ predeq3E => x e y /=; rewrite mx_normE; split => xey. by move: (xey (i, j)); rewrite !mxE; exact. Qed. -Definition matrix_PseudoMetricNormedZmodMixin := - PseudoMetricNormedZmodule.Mixin mx_norm_ball. -Canonical matrix_pseudoMetricNormedZmodType := - PseudoMetricNormedZmodType K 'M[K]_(m.+1, n.+1) matrix_PseudoMetricNormedZmodMixin. +HB.instance Definition _ := + NormedZmod_PseudoMetric_eq.Build K 'M[K]_(m.+1, n.+1) mx_norm_ball. Lemma mx_normZ (l : K) (x : 'M[K]_(m.+1, n.+1)) : `| l *: x | = `| l | * `| x |. Proof. @@ -3104,12 +2261,12 @@ rewrite {1 3}/normr /= !mx_normE (eq_bigr (fun i => (`|l| * `|x i.1 i.2|)%:nng)); last first. by move=> i _; rewrite mxE //=; apply/eqP; rewrite -num_eq /= normrM. elim/big_ind2 : _ => // [|a b c d bE dE]; first by rewrite mulr0. -by rewrite !num_max bE dE maxr_pmulr. +by rewrite !num_max bE dE maxr_pMr. Qed. -Definition matrix_NormedModMixin := NormedModMixin mx_normZ. -Canonical matrix_normedModType := - NormedModType K 'M[K]_(m.+1, n.+1) matrix_NormedModMixin. +HB.instance Definition _ := + PseudoMetricNormedZmod_Lmodule_isNormedModule.Build K 'M[K]_(m.+1, n.+1) + mx_normZ. End matrix_NormedModule. @@ -3124,13 +2281,12 @@ rewrite /ball /= /prod_ball -!ball_normE /ball_ /=. by rewrite comparable_lt_maxl// ?real_comparable//; split=> /andP. Qed. -Lemma prod_norm_ball : @ball _ [pseudoMetricType K of U * V] = ball_ (fun x => `|x|). +Lemma prod_norm_ball : + @ball _ [the pseudoMetricType K of (U * V)%type] = ball_ (fun x => `|x|). Proof. by rewrite /= - ball_prod_normE. Qed. -Definition prod_pseudoMetricNormedZmodMixin := - PseudoMetricNormedZmodule.Mixin prod_norm_ball. -Canonical prod_pseudoMetricNormedZmodType := - PseudoMetricNormedZmodType K (U * V) prod_pseudoMetricNormedZmodMixin. +HB.instance Definition _ := NormedZmod_PseudoMetric_eq.Build K (U * V)%type + prod_norm_ball. End prod_PseudoMetricNormedZmodule. @@ -3138,11 +2294,11 @@ Section prod_NormedModule. Context {K : numDomainType} {U V : normedModType K}. Lemma prod_norm_scale (l : K) (x : U * V) : `| l *: x | = `|l| * `| x |. -Proof. by rewrite prod_normE /= !normrZ maxr_pmulr. Qed. +Proof. by rewrite prod_normE /= !normrZ maxr_pMr. Qed. -Definition prod_NormedModMixin := NormedModMixin prod_norm_scale. -Canonical prod_normedModType := - NormedModType K (U * V) prod_NormedModMixin. +HB.instance Definition _ := + PseudoMetricNormedZmod_Lmodule_isNormedModule.Build K (U * V)%type + prod_norm_scale. End prod_NormedModule. @@ -3151,10 +2307,10 @@ Variables (K : numDomainType). Example matrix_triangke m n (M N : 'M[K]_(m.+1, n.+1)) : `|M + N| <= `|M| + `|N|. -Proof. apply ler_norm_add. Qed. +Proof. apply ler_normD. Qed. Example pair_triangle (x y : K * K) : `|x + y| <= `|x| + `|y|. -Proof. apply ler_norm_add. Qed. +Proof. apply ler_normD. Qed. End example_of_sharing. @@ -3162,14 +2318,14 @@ Section prod_NormedModule_lemmas. Context {T : Type} {K : numDomainType} {U V : normedModType K}. -Lemma fcvgr2dist_ltP {F : set (set U)} {G : set (set V)} +Lemma fcvgr2dist_ltP {F : set_system U} {G : set_system V} {FF : Filter F} {FG : Filter G} (y : U) (z : V) : (F, G) --> (y, z) <-> forall eps, 0 < eps -> \forall y' \near F & z' \near G, `| (y, z) - (y', z') | < eps. Proof. exact: fcvgrPdist_lt. Qed. -Lemma cvgr2dist_ltP {I J} {F : set (set I)} {G : set (set J)} +Lemma cvgr2dist_ltP {I J} {F : set_system I} {G : set_system J} {FF : Filter F} {FG : Filter G} (f : I -> U) (g : J -> V) (y : U) (z : V) : (f @ F, g @ G) --> (y, z) <-> forall eps, 0 < eps -> @@ -3179,14 +2335,14 @@ rewrite fcvgr2dist_ltP; split=> + e e0 => /(_ e e0); by rewrite !near_simpl// => ?; rewrite !near_simpl. Qed. -Lemma cvgr2dist_lt {I J} {F : set (set I)} {G : set (set J)} +Lemma cvgr2dist_lt {I J} {F : set_system I} {G : set_system J} {FF : Filter F} {FG : Filter G} (f : I -> U) (g : J -> V) (y : U) (z : V) : (f @ F, g @ G) --> (y, z) -> forall eps, 0 < eps -> \forall i \near F & j \near G, `| (y, z) - (f i, g j) | < eps. Proof. by rewrite cvgr2dist_ltP. Qed. -Lemma __deprecated__cvg_dist2 {F : set (set U)} {G : set (set V)} +Lemma __deprecated__cvg_dist2 {F : set_system U} {G : set_system V} {FF : Filter F} {FG : Filter G} (y : U) (z : V): (F, G) --> (y, z) -> forall eps, 0 < eps -> @@ -3225,7 +2381,7 @@ Lemma natmul_continuous n : continuous (fun x : V => x *+ n). Proof. case: n => [|n] x; first exact: cvg_cst. apply/cvgrPdist_lt=> _/posnumP[e]; near=> a. -by rewrite -mulrnBl normrMn -mulr_natr -ltr_pdivl_mulr. +by rewrite -mulrnBl normrMn -mulr_natr -ltr_pdivlMr. Unshelve. all: by end_near. Qed. Lemma norm_continuous : continuous (normr : V -> K). @@ -3244,9 +2400,9 @@ Proof. move=> [/= k x]; apply/cvgrPdist_lt => _/posnumP[e]; near +oo_K => M. near=> l z => /=; have M0 : 0 < M by []. rewrite (@distm_lt_split _ _ (k *: z)) // -?(scalerBr, scalerBl) normrZ. - rewrite (@le_lt_trans _ _ (M * `|x - z|)) ?ler_wpmul2r -?ltr_pdivl_mull//. + rewrite (@le_lt_trans _ _ (M * `|x - z|)) ?ler_wpM2r -?ltr_pdivlMl//. by near: z; apply: cvgr_dist_lt; rewrite // mulr_gt0 ?invr_gt0. -rewrite (@le_lt_trans _ _ (`|k - l| * M)) ?ler_wpmul2l -?ltr_pdivl_mulr//. +rewrite (@le_lt_trans _ _ (`|k - l| * M)) ?ler_wpM2l -?ltr_pdivlMr//. by near: z; near: M; apply: cvg_bounded (@cvg_refl _ _). by near: l; apply: cvgr_dist_lt; rewrite // divr_gt0. Unshelve. all: by end_near. Qed. @@ -3276,19 +2432,19 @@ Proof. exact: scale_continuous. Qed. Lemma mulrl_continuous (x : K) : continuous ( *%R x). Proof. exact: scaler_continuous. Qed. -Lemma mulrr_continuous (y : K) : continuous ( *%R^~ y). +Lemma mulrr_continuous (y : K) : continuous ( *%R^~ y : K -> K). Proof. exact: scalel_continuous. Qed. -Lemma inv_continuous (x : K) : x != 0 -> {for x, continuous GRing.inv}. +Lemma inv_continuous (x : K) : x != 0 -> {for x, continuous (@GRing.inv K)}. Proof. move=> x_neq0; have nx_gt0 : `|x| > 0 by rewrite normr_gt0. apply/(@cvgrPdist_ltp _ _ _ (nbhs x)); near (0 : K)^'+ => d. near=> e. near=> y; have y_neq0 : y != 0 by near: y; apply: (cvgr_neq0 x). rewrite /= -div1r -[y^-1]div1r -mulNr addf_div// mul1r mulN1r normrM normfV. -rewrite ltr_pdivr_mulr ?normr_gt0 ?mulf_neq0// (@lt_le_trans _ _ (e * d))//. +rewrite ltr_pdivrMr ?normr_gt0 ?mulf_neq0// (@lt_le_trans _ _ (e * d))//. by near: y; apply: cvgr_distC_lt => //; rewrite mulr_gt0. -rewrite ler_pmul2l => //=; rewrite normrM -ler_pdivr_mull//. -near: y; apply: (cvgr_norm_ge x) => //; rewrite ltr_pdivr_mull//. +rewrite ler_pM2l => //=; rewrite normrM -ler_pdivrMl//. +near: y; apply: (cvgr_norm_ge x) => //; rewrite ltr_pdivrMl//. by near: d; apply: nbhs_right_lt; rewrite mulr_gt0. Unshelve. all: by end_near. Qed. @@ -3297,7 +2453,7 @@ End NVS_continuity_mul. Section cvg_composition_pseudometric. Context {K : numFieldType} {V : pseudoMetricNormedZmodType K} {T : Type}. -Context (F : set (set T)) {FF : Filter F}. +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. @@ -3319,7 +2475,7 @@ Lemma is_cvgMn f n : cvg (f @ F) -> cvg (((@GRing.natmul _)^~n \o f) @ F). Proof. by move=> /cvgMn /cvgP. Qed. Lemma cvgD f g a b : f @ F --> a -> g @ F --> b -> (f + g) @ F --> a + b. -Proof. by move=> ? ?; apply: continuous2_cvg => //; exact: add_continuous. Qed. +Proof. by move=> ? ?; apply: continuous2_cvg => //; apply add_continuous. Qed. Lemma is_cvgD f g : cvg (f @ F) -> cvg (g @ F) -> cvg (f + g @ F). Proof. by have := cvgP _ (cvgD _ _); apply. Qed. @@ -3366,7 +2522,7 @@ Proof. by rewrite norm_cvg0P. Qed. End cvg_composition_pseudometric. Lemma __deprecated__cvg_dist0 {U} {K : numFieldType} {V : normedModType K} - {F : set (set U)} {FF : Filter F} (f : U -> V) : + {F : set_system U} {FF : Filter F} (f : U -> V) : (fun x => `|f x|) @ F --> (0 : K) -> f @ F --> (0 : V). Proof. exact: norm_cvg0. Qed. @@ -3376,12 +2532,12 @@ Notation cvg_dist0 := __deprecated__cvg_dist0 (only parsing). Section cvg_composition_normed. Context {K : numFieldType} {V : normedModType K} {T : Type}. -Context (F : set (set T)) {FF : Filter F}. +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 cvgZ s f k a : s @ F --> k -> f @ F --> a -> s x *: f x @[x --> F] --> k *: a. -Proof. move=> ? ?; apply: continuous2_cvg => //; exact: scale_continuous. Qed. +Proof. by move=> ? ?; apply: continuous2_cvg => //; apply scale_continuous. Qed. Lemma is_cvgZ s f : cvg (s @ F) -> cvg (f @ F) -> cvg ((fun x => s x *: f x) @ F). @@ -3409,7 +2565,7 @@ End cvg_composition_normed. Section cvg_composition_field. Context {K : numFieldType} {T : Type}. -Context (F : set (set T)) {FF : Filter F}. +Context (F : set_system T) {FF : Filter F}. Implicit Types (f g : T -> K) (a b : K). Lemma cvgV f a : a != 0 -> f @ F --> a -> f\^-1 @ F --> a^-1. @@ -3461,7 +2617,7 @@ End cvg_composition_field. Section limit_composition_pseudometric. Context {K : numFieldType} {V : pseudoMetricNormedZmodType K} {T : Type}. -Context (F : set (set T)) {FF : ProperFilter F}. +Context (F : set_system T) {FF : ProperFilter F}. Implicit Types (f g : T -> V) (s : T -> K) (k : K) (x : T) (a : V). Lemma limN f : cvg (f @ F) -> lim (- f @ F) = - lim (f @ F). @@ -3483,7 +2639,7 @@ End limit_composition_pseudometric. Section limit_composition_normed. Context {K : numFieldType} {V : normedModType K} {T : Type}. -Context (F : set (set T)) {FF : ProperFilter F}. +Context (F : set_system T) {FF : ProperFilter F}. Implicit Types (f g : T -> V) (s : T -> K) (k : K) (x : T) (a : V). Lemma limZ s f : cvg (s @ F) -> cvg (f @ F) -> @@ -3502,7 +2658,7 @@ End limit_composition_normed. Section limit_composition_field. Context {K : numFieldType} {T : Type}. -Context (F : set (set T)) {FF : ProperFilter F}. +Context (F : set_system T) {FF : ProperFilter F}. Implicit Types (f g : T -> K). Lemma limM f g : cvg (f @ F) -> cvg (g @ F) -> @@ -3514,7 +2670,7 @@ End limit_composition_field. Section cvg_composition_field_proper. Context {K : numFieldType} {T : Type}. -Context (F : set (set T)) {FF : ProperFilter F}. +Context (F : set_system T) {FF : ProperFilter F}. Implicit Types (f g : T -> K) (a b : K). Lemma limV f : lim (f @ F) != 0 -> lim (f\^-1 @ F) = (lim (f @ F))^-1. @@ -3531,7 +2687,7 @@ Qed. End cvg_composition_field_proper. Section ProperFilterRealType. -Context {T : Type} {F : set (set T)} {FF : ProperFilter F} {R : realFieldType}. +Context {T : Type} {F : set_system T} {FF : ProperFilter F} {R : realFieldType}. Implicit Types (f g h : T -> R) (a b : R). Lemma cvgr_to_ge f a b : f @ F --> a -> (\near F, b <= f F) -> b <= a. @@ -3630,7 +2786,7 @@ Section cvg_fin. Context {R : numFieldType}. Section filter. -Context {F : set (set \bar R)} {FF : Filter F}. +Context {F : set_system \bar R} {FF : Filter F}. Lemma fine_fcvg a : F --> a%:E -> fine @ F --> a. Proof. @@ -3646,7 +2802,7 @@ Proof. by apply; apply/nbhs_EFin; near=> x. Unshelve. all: by end_near. Qed. End filter. Section limit. -Context {I : Type} {F : set (set I)} {FF : Filter F} (f : I -> \bar R). +Context {I : Type} {F : set_system I} {FF : Filter F} (f : I -> \bar R). Lemma fine_cvg a : f @ F --> a%:E -> fine \o f @ F --> a. Proof. exact: fine_fcvg. Qed. @@ -3680,16 +2836,8 @@ End limit. End cvg_fin. -Lemma eq_cvg (T T' : Type) (F : set (set T)) (f g : T -> T') (x : set (set T')) : - f =1 g -> (f @ F --> x) = (g @ F --> x). -Proof. by move=> /funext->. Qed. - -Lemma eq_is_cvg (T T' : Type) (fT : filteredType T') (F : set (set T)) (f g : T -> T') : - f =1 g -> [cvg (f @ F) in fT] = [cvg (g @ F) in fT]. -Proof. by move=> /funext->. Qed. - Section ecvg_realFieldType. -Context {I} {F : set (set I)} {FF : Filter F} {R : realFieldType}. +Context {I} {F : set_system I} {FF : Filter F} {R : realFieldType}. Implicit Types f g u v : I -> \bar R. Local Open Scope ereal_scope. @@ -3701,13 +2849,13 @@ have yE u v x : u @ F --> +oo -> v @ F --> x%:E -> u \+ v @ F --> +oo. near=> A; near=> n; have /(_ _)/wrap[//|Fgn] := near Fg n. rewrite -lee_subl_addr// (@le_trans _ _ (A - (x - 1))%:E)//; last by near: n. rewrite ?EFinB lee_sub// lee_subl_addr// -[v n]fineK// -EFinD lee_fin. - by rewrite ler_distl_addr// ltW//; near: n; apply: cvgr_dist_lt. + by rewrite ler_distlDr// ltW//; near: n; apply: cvgr_dist_lt. have NyE u v x : u @ F --> -oo -> v @ F --> x%:E -> u \+ v @ F --> -oo. move=> /cvgeNyPle/= foo /fine_cvgP -[Fg gb]; apply/cvgeNyPleNy. near=> A; near=> n; have /(_ _)/wrap[//|Fgn] := near Fg n. rewrite -lee_subr_addr// (@le_trans _ _ (A - (x + 1))%:E)//; first by near: n. rewrite ?EFinB ?EFinD lee_sub// -[v n]fineK// -EFinD lee_fin. - by rewrite ler_distlC_addr// ltW//; near: n; apply: cvgr_dist_lt. + by rewrite ler_distlCDr// ltW//; near: n; apply: cvgr_dist_lt. have yyE u v : u @ F --> +oo -> v @ F --> +oo -> u \+ v @ F --> +oo. move=> /cvgeyPge foo /cvgeyPge goo; apply/cvgeyPge => A; near=> y. by rewrite -[leLHS]adde0 lee_add//; near: y; [apply: foo|apply: goo]. @@ -3752,7 +2900,7 @@ Qed. Lemma abse_continuous : continuous (@abse R). Proof. case=> [r|A /= [r [rreal rA]]|A /= [r [rreal rA]]]/=. -- exact/(cvg_comp (@norm_continuous _ [normedModType R of R^o] r)). +- exact/(cvg_comp (@norm_continuous _ [the normedModType R of R^o] r)). - by exists r; split => // y ry; apply: rA; rewrite (lt_le_trans ry)// lee_abs. - exists (- r)%R; rewrite realN; split => // y; rewrite EFinN -lte_oppr => yr. by apply: rA; rewrite (lt_le_trans yr)// -abseN lee_abs. @@ -3775,7 +2923,7 @@ Qed. Lemma mule_continuous (r : R) : continuous (mule r%:E). Proof. -wlog r0 : r / (r > 0)%R => [hwlog|]. +rewrite /continuous_at; wlog r0 : r / (r > 0)%R => [hwlog|]. have [r0|r0|->] := ltrgtP r 0; do ?exact: hwlog; last first. by move=> x; rewrite mul0e; apply: cvg_near_cst; near=> y; rewrite mul0e. have -> : *%E r%:E = \- ( *%E (- r)%:E ). @@ -4075,7 +3223,7 @@ move=> [x y]; have [pE U /= Upinf|] := eqVneq (edist (x, y)) +oo%E. by move=> z /= ->; apply: nbhs_singleton; move: pE Upinf => ->. by apply: open_nbhs_nbhs; split => //; exact: edist_pinfty_open. rewrite -ltey -ge0_fin_numE// => efin. -rewrite -[edist (x, y)]fineK//; apply: cvg_EFin. +rewrite /continuous_at -[edist (x, y)]fineK//; apply: cvg_EFin. by have := edist_fin_open efin; apply: filter_app; near=> w. apply/cvgrPdist_le => _/posnumP[eps]. suff: \forall t \near (nbhs x, nbhs y), @@ -4132,7 +3280,7 @@ Qed. End pseudoMetricDist. #[global] -Hint Extern 0 (is_true (0 <= edist _)%E) => solve [apply: edist_ge0] : core. +Hint Extern 0 (is_true (0%R <= edist _)%E) => solve [apply: edist_ge0] : core. #[global] Hint Extern 0 (is_true (edist _ != -oo%E)) => solve [apply: edist_neqNy] : core. @@ -4142,7 +3290,7 @@ Context {R : realType} {T : pseudoMetricType R} (A : set T). Definition edist_inf z := ereal_inf [set edist (z, a) | a in A]. Lemma edist_inf_ge0 w : (0 <= edist_inf w)%E. -Proof. by apply: lb_ereal_inf => ? /= [? ? <-]; exact: edist_ge0. Qed. +Proof. by apply: lb_ereal_inf => ? /= [? ? <-]. Qed. Hint Resolve edist_inf_ge0 : core. Lemma edist_inf_neqNy w : (edist_inf w != -oo)%E. @@ -4154,7 +3302,7 @@ Proof. have [A0|/set0P[a0 Aa0]] := eqVneq A set0. by rewrite /edist_inf A0 ?image_set0 ?ereal_inf0 addey. have [fyn|] := boolP (edist_inf y \is a fin_num); first last. - by rewrite ge0_fin_numE// ?ltey// negbK => /eqP->; rewrite addey ?leey. + by rewrite ge0_fin_numE// ?ltey negbK => /eqP->; rewrite addey ?leey. have [xyfin|] := boolP (edist (x, y) \is a fin_num); first last. by rewrite ge0_fin_numE// ?ltey // negbK => /eqP->; rewrite addye ?leey. apply/lee_addgt0Pr => _/posnumP[eps]. @@ -4167,8 +3315,9 @@ Qed. Lemma edist_inf_continuous : continuous edist_inf. Proof. move=> z; have [A0|/= /set0P[a0 Aa0]] := eqVneq A set0. - rewrite /edist_inf A0 image_set0 ereal_inf0. - by under eq_fun => ? do rewrite image_set0 ereal_inf0; apply: cvg_cst. + rewrite /edist_inf A0. + under eq_fun do rewrite image_set0 ereal_inf0. + exact: cvg_cst. have [] := eqVneq (edist_inf z) +oo%E. move=> /[dup] fzp /ereal_inf_pinfty => zAp U /= Ufz. have : nbhs z (ball z 1) by exact: nbhsx_ballx. @@ -4181,7 +3330,7 @@ have [] := eqVneq (edist_inf z) +oo%E. rewrite (@le_lt_trans _ _ (1 + r'%:E)%E) ?lee_add2r ?edist_fin//. by rewrite -EFinD [edist (z, a)]zAp ?ltey //; exists a. rewrite -ltey -ge0_fin_numE ?edist_inf_ge0 // => fz_fin. -rewrite // -[edist_inf z]fineK //; apply/fine_cvgP. +rewrite /continuous_at -[edist_inf z]fineK //; apply/fine_cvgP. have fwfin : \forall w \near z, edist_inf w \is a fin_num. (have : nbhs z (ball z 1) by exact: nbhsx_ballx); apply: filter_app. near=> t => bz1; rewrite ge0_fin_numE ?edist_inf_ge0 //. @@ -4197,10 +3346,10 @@ have ztfin : edist (z, t) \is a fin_num by apply/edist_finP; exists eps%:num. move=> /(@edist_fin _ _ _ (z, t)) - /(_ trivial). rewrite -[edist (z, t)]fineK ?lee_fin //; apply: le_trans. rewrite ler_norml; apply/andP; split. - rewrite ler_subr_addr addrC ler_subl_addr addrC -fineD //. + rewrite lerBrDr addrC lerBlDr addrC -fineD //. rewrite -lee_fin ?fineK // ?fin_numD ?ztfin ?fz_fin // edist_sym. exact: edist_inf_triangle. -rewrite ler_subl_addr -fineD // -lee_fin ?fineK // ?fin_numD ?tfin ?ztfin //. +rewrite lerBlDr -fineD // -lee_fin ?fineK // ?fin_numD ?tfin ?ztfin //. exact: edist_inf_triangle. Unshelve. all: by end_near. Qed. @@ -4224,7 +3373,7 @@ Context (A B : set T) (E : set (T * T)). Hypothesis entE : entourage E. Hypothesis AB0 : A `*` B `&` E = set0. -Local Notation T' := (@gauge_pseudoMetricType _ _ entE R). +Local Notation T' := [the pseudoMetricType R of gauge.type entE]. Local Lemma urysohn_separation : exists (f : T -> R), [/\ continuous f, range f `<=` `[0, 1], @@ -4245,20 +3394,20 @@ have dfin x : @edist_inf R T' A x \is a fin_num. rewrite ge0_fin_numE ?edist_inf_ge0 //; apply: le_lt_trans. by apply: ereal_inf_lb; exists a. rewrite -ge0_fin_numE ?edist_ge0 //; apply/edist_finP => /=; exists 2 => //. - exact: countable_uniform_bounded. + exact: countable_uniform.countable_uniform_bounded. pose f' := (fun z => fine (@edist_inf R T' A z)) \min (fun=> eps%:num). pose f z := (f' z)/eps%:num; exists f; split. - move=> x; rewrite /f; apply: (@cvgM R T (nbhs x)); last exact: cvg_cst. suff : {for x, continuous (f' : T' -> R)}. move=> Q U; rewrite nbhs_simpl /= => f'U. - have [J /(gauge_ent entE) entJ/filterS] := Q _ f'U; apply. + have [J /(gauge.gauge_ent entE) entJ/filterS] := Q _ f'U; apply. by rewrite nbhs_simpl /= -nbhs_entourageE /=; exists J. apply: continuous_min; last by apply: cvg_cst; exact: nbhs_filter. apply: fine_cvg; first exact: nbhs_filter. rewrite fineK //; first exact: edist_inf_continuous. - move=> _ [x _ <-]; rewrite set_itvE /=; apply/andP; split. - by rewrite /f divr_ge0 // /f' /= /minr; case: ltP; rewrite ?fine_ge0. - by rewrite /f ler_pdivr_mulr // mul1r /f' /= /minr; case: ltP => // /ltW. + by rewrite /f divr_ge0 // /f' /= le_minr fine_ge0//= edist_inf_ge0. + by rewrite /f ler_pdivrMr // mul1r /f' /= /minr; case: ltP => // /ltW. - by move=> ? [z Az] <-; rewrite /f/f' /= edist_inf0 // /minr fine0 ifT ?mul0r. - move=> ? [b Bb] <-; rewrite /f /f'/= /minr/=. case: ltP => //; rewrite ?divrr // ?unitf_gt0 // -lte_fin fineK//. @@ -4272,7 +3421,7 @@ Section topological_urysohn_separator. Context {T : topologicalType} {R : realType}. Definition uniform_separator (A B : set T) := - exists (uT : @Uniform.class_of T^o) (E : set (T * T)), + exists (uT : @Uniform.axioms_ T^o) (E : set (T * T)), let UT := Uniform.Pack uT in [/\ @entourage UT E, A `*` B `&` E = set0 & (forall x, @nbhs UT UT x `<=` @nbhs T T x)]. @@ -4465,17 +3614,13 @@ elim: n G sG. by move=> n IH G [R] /IH AAR [M] /IH AAM <- z; split; [exact: AAR | exact: AAM]. Qed. -Let urysohn_uniformType_mixin := - UniformMixin ury_unif_filter ury_unif_refl ury_unif_inv ury_unif_split erefl. +Definition urysohnType : Type := T. -Let urysohn_topologicalTypeMixin := - topologyOfEntourageMixin urysohn_uniformType_mixin. +HB.instance Definition _ := Pointed.on urysohnType. -Let urysohn_filtered := FilteredType T T (nbhs_ ury_unif). -Let urysohn_topologicalType := - TopologicalType urysohn_filtered urysohn_topologicalTypeMixin. -Let urysohn_uniformType := UniformType - urysohn_topologicalType urysohn_uniformType_mixin. +HB.instance Definition _ := + isUniform.Build urysohnType ury_unif_filter ury_unif_refl ury_unif_inv + ury_unif_split. Lemma normal_uniform_separator (B : set T) : closed A -> closed B -> A `&` B = set0 -> uniform_separator A B. @@ -4484,15 +3629,15 @@ move=> clA clB AB0; have /(_ (~`B))[x Ax|] := normalT clA. apply: open_nbhs_nbhs; split => //. - exact/closed_openC. - by move: x Ax; apply/ disjoints_subset. -move=> V /set_nbhsP [U [oU AU UV]] cVcb. -exists (Uniform.class urysohn_uniformType), (apxU (U, ~` B)); split => //. +move=> V /set_nbhsP [U [oU AU UV]] cVcb. +exists (Uniform.class urysohnType), (apxU (U, ~` B)); split => //. - move=> ?; apply:sub_gen_smallest; exists (U, ~`B) => //; split => //=. exact/closed_openC. by move: UV => /closure_subset/subset_trans; apply. - rewrite eqEsubset; split; case=> // a b [/=[Aa Bb] [[//]|]]. by have /subset_closure ? := AU _ Aa; case. move=> x ? [E gE] /(@filterS T); apply; move: gE. -rewrite /ury_unif filterI_iterE; case => K /= [i _] /= uiK KE. +rewrite /= /ury_unif filterI_iterE; case => K /= [i _] /= uiK KE. suff : @nbhs T T x to_set K (x) by apply: filterS => y /KE. elim: i K uiK {E KE}; last by move=> ? H ? [N] /H ? [M] /H ? <-; apply: filterI. move=> K [->|]; first exact: filterT. @@ -4525,7 +3670,8 @@ split; first do [move=> ?; exists (Urysohn A B); split]. - exact: Urysohn_range. - exact: Urysohn_sub0. - exact: Urysohn_sub1. -case=> f [ctsf f01 fA0 fB1]; pose T' := weak_pseudoMetricType f. +case=> f [ctsf f01 fA0 fB1]. +pose T' := weak_topology f. exists (Uniform.class T'), ([set xy | ball (f xy.1) 1 (f xy.2)]); split. - exists [set xy | ball xy.1 1 xy.2]; last by case. by rewrite -entourage_ballE; exists 1 => //=. @@ -4545,7 +3691,7 @@ Let normal_spaceP : [<-> (* 2 *) forall (A B : set T), closed A -> closed B -> A `&` B = set0 -> exists U V, [/\ open U, open V, A `<=` U, B `<=` V & U `&` V = set0] ]. Proof. -pose R := Rstruct.real_realType. +pose R := Rdefinitions.R. tfae; first by move=> ?; exact: normal_uniform_separator. - move=> + A B clA clB AB0 => /(_ _ _ clA clB AB0) /(@uniform_separatorP _ R). case=> f [cf f01 /imsub1P/subset_trans fa0 /imsub1P/subset_trans fb1]. @@ -4553,7 +3699,7 @@ tfae; first by move=> ?; exact: normal_uniform_separator. + by apply: open_comp; [|exact: interval_open]. + by apply: open_comp; [|exact: interval_open]. + by apply: fa0 => x/= ->; rewrite (@in_itv _ R)/=; apply/andP; split. - + apply: fb1 => x/= ->; rewrite (@in_itv _ R)/= ltr_pdivr_mulr// mul1r. + + apply: fb1 => x/= ->; rewrite (@in_itv _ R)/= ltr_pdivrMr// mul1r. by rewrite ltr1n. + rewrite -preimage_setI ?set_itvoo -subset0 => t [] /andP [_ +] /andP [+ _]. by move=> /lt_trans /[apply]; rewrite ltxx. @@ -4691,31 +3837,32 @@ Qed. Lemma open_ereal_lt_ereal x : open [set y | y < x]. Proof. -have openr r : open [set x | x < r%:E]. - case => [? | // | ?]; [rewrite /= lte_fin => xy | by exists r]. +have openr r : open [set x : \bar R | x < r%:E]. + (* BUG: why doesn't case work? *) + move=> [? | // | ?]; [rewrite /= lte_fin => xy | by exists r]. by move: (@open_ereal_lt r%:E); rewrite openE; apply; rewrite /= lte_fin. -case: x => [ // | | [] // ]. +move: x => [ // | | ]; last by move=> []. (* same BUG *) suff -> : [set y | y < +oo] = \bigcup_r [set y : \bar R | y < r%:E]. exact: bigcup_open. rewrite predeqE => -[r | | ]/=. - rewrite ltry; split => // _. - by exists (r + 1)%R => //=; rewrite lte_fin ltr_addl. + by exists (r + 1)%R => //=; rewrite lte_fin ltrDl. - by rewrite ltxx; split => // -[] x /=; rewrite ltNge leey. -- by split => // _; exists 0%R => //=. +- by split => // _; exists 0%R => //=; rewrite ltNye. Qed. Lemma open_ereal_gt_ereal x : open [set y | x < y]. Proof. have openr r : open [set x | r%:E < x]. - case => [? | ? | //]; [rewrite /= lte_fin => xy | by exists r]. + move=> [? | ? | //]; [rewrite /= lte_fin => xy | by exists r]. by move: (@open_ereal_gt r%:E); rewrite openE; apply; rewrite /= lte_fin. -case: x => [ // | [] // | ]. +case: x => [ // | | ]; first by move=> []. suff -> : [set y | -oo < y] = \bigcup_r [set y : \bar R | r%:E < y]. exact: bigcup_open. rewrite predeqE => -[r | | ]/=. - rewrite ltNyr; split => // _. - by exists (r - 1)%R => //=; rewrite lte_fin ltr_subl_addr ltr_addl. -- by split => // _; exists 0%R => //=. + by exists (r - 1)%R => //=; rewrite lte_fin ltrBlDr ltrDl. +- by split => // _; exists 0%R => //=; rewrite ltey. - by rewrite ltxx; split => // -[] x _ /=; rewrite ltNge leNye. Qed. @@ -4746,7 +3893,7 @@ rewrite eqEsubset; split. move=> v; rewrite /mkset le_eqVlt => /predU1P[<-{v}|]; last first. by move=> ?; exact: subset_closure. move=> B [e /= e0 zB]; near (0 : R)^'+ => d. -exists (z + d); split; rewrite /= ?ltr_addl//; apply: zB => /=. +exists (z + d); split; rewrite /= ?ltrDl//; apply: zB => /=. by rewrite opprD addNKr normrN gtr0_norm//. Unshelve. all: by end_near. Qed. @@ -4757,7 +3904,7 @@ rewrite eqEsubset; split. move=> v; rewrite /mkset le_eqVlt => /predU1P[<-{z}|]; last first. by move=> ?; exact: subset_closure. move=> B [e /= e0 vB]; near (0 : R)^'+ => d. -exists (v - d); split; rewrite /= ?gtr_addl ?oppr_lt0//; apply: vB => /=. +exists (v - d); split; rewrite /= ?gtrDl ?oppr_lt0//; apply: vB => /=. by rewrite opprB addrC addrNK gtr0_norm//; near: d. Unshelve. all: by end_near. Qed. @@ -4765,129 +3912,14 @@ End closure_left_right_open. (** ** Complete Normed Modules *) -Module CompleteNormedModule. - -Section ClassDef. - -Variable K : numFieldType. - -Record class_of (T : Type) := Class { - base : NormedModule.class_of K T ; - mixin : Complete.axiom (PseudoMetric.Pack base) -}. -Local Coercion base : class_of >-> NormedModule.class_of. -Definition base2 T (cT : class_of T) : CompletePseudoMetric.class_of K T := - @CompletePseudoMetric.Class _ _ (@base T cT) (@mixin T cT). -Local Coercion base2 : class_of >-> CompletePseudoMetric.class_of. - -Structure type (phK : phant K) := Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. - -Variables (phK : phant K) (cT : type phK) (T : Type). - -Definition class := let: Pack _ c := cT return class_of cT in c. - -Definition pack := - fun bT (b : NormedModule.class_of K T) & phant_id (@NormedModule.class K phK bT) b => - fun mT m & phant_id (@Complete.class mT) (@Complete.Class T b m) => - Pack phK (@Class T b m). -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition zmodType := @GRing.Zmodule.Pack cT xclass. -Definition normedZmodType := @Num.NormedZmodule.Pack K phK cT xclass. -Definition lmodType := @GRing.Lmodule.Pack K phK cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. -Definition uniformType := @Uniform.Pack cT xclass. -Definition pseudoMetricType := @PseudoMetric.Pack K cT xclass. -Definition pseudoMetricNormedZmodType := - @PseudoMetricNormedZmodule.Pack K phK cT xclass. -Definition normedModType := @NormedModule.Pack K phK cT xclass. -Definition completeType := @Complete.Pack cT xclass. -Definition completePseudoMetricType := @CompletePseudoMetric.Pack K cT xclass. -Definition complete_zmodType := @GRing.Zmodule.Pack completeType xclass. -Definition complete_lmodType := @GRing.Lmodule.Pack K phK completeType xclass. -Definition complete_normedZmodType := @Num.NormedZmodule.Pack K phK completeType xclass. -Definition complete_pseudoMetricNormedZmodType := - @PseudoMetricNormedZmodule.Pack K phK completeType xclass. -Definition complete_normedModType := @NormedModule.Pack K phK completeType xclass. -Definition completePseudoMetric_lmodType : GRing.Lmodule.type phK := - @GRing.Lmodule.Pack K phK (CompletePseudoMetric.sort completePseudoMetricType) - xclass. -Definition completePseudoMetric_zmodType : GRing.Zmodule.type := - @GRing.Zmodule.Pack (CompletePseudoMetric.sort completePseudoMetricType) - xclass. -Definition completePseudoMetric_normedModType : NormedModule.type phK := - @NormedModule.Pack K phK (CompletePseudoMetric.sort completePseudoMetricType) - xclass. -Definition completePseudoMetric_normedZmodType : Num.NormedZmodule.type phK := - @Num.NormedZmodule.Pack K phK - (CompletePseudoMetric.sort completePseudoMetricType) xclass. -Definition completePseudoMetric_pseudoMetricNormedZmodType : - PseudoMetricNormedZmodule.type phK := - @PseudoMetricNormedZmodule.Pack K phK - (CompletePseudoMetric.sort completePseudoMetricType) xclass. -End ClassDef. - -Module Exports. - -Coercion base : class_of >-> NormedModule.class_of. -Coercion base2 : class_of >-> CompletePseudoMetric.class_of. -Coercion sort : type >-> Sortclass. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion zmodType : type >-> GRing.Zmodule.type. -Canonical zmodType. -Coercion pseudoMetricNormedZmodType : type >-> PseudoMetricNormedZmodule.type. -Canonical pseudoMetricNormedZmodType. -Coercion normedZmodType : type >-> Num.NormedZmodule.type. -Canonical normedZmodType. -Coercion lmodType : type >-> GRing.Lmodule.type. -Canonical lmodType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Coercion uniformType : type >-> Uniform.type. -Canonical uniformType. -Coercion pseudoMetricType : type >-> PseudoMetric.type. -Canonical pseudoMetricType. -Coercion normedModType : type >-> NormedModule.type. -Canonical normedModType. -Coercion completeType : type >-> Complete.type. -Canonical completeType. -Coercion completePseudoMetricType : type >-> CompletePseudoMetric.type. -Canonical completePseudoMetricType. -Canonical complete_zmodType. -Canonical complete_lmodType. -Canonical complete_normedZmodType. -Canonical complete_pseudoMetricNormedZmodType. -Canonical complete_normedModType. -Canonical completePseudoMetric_lmodType. -Canonical completePseudoMetric_zmodType. -Canonical completePseudoMetric_normedModType. -Canonical completePseudoMetric_normedZmodType. -Canonical completePseudoMetric_pseudoMetricNormedZmodType. -Notation completeNormedModType K := (type (Phant K)). -Notation "[ 'completeNormedModType' K 'of' T ]" := (@pack _ (Phant K) T _ _ idfun _ _ idfun) - (at level 0, format "[ 'completeNormedModType' K 'of' T ]") : form_scope. -End Exports. - -End CompleteNormedModule. - -Export CompleteNormedModule.Exports. +#[short(type="completeNormedModType")] +HB.structure Definition CompleteNormedModule (K : numFieldType) := + {T of NormedModule K T & Complete T}. (** The topology on real numbers *) -Lemma R_complete (R : realType) (F : set (set R)) : ProperFilter F -> cauchy F -> cvg F. +Lemma R_complete (R : realType) (F : set_system R) : + ProperFilter F -> cauchy F -> cvg F. Proof. move=> FF /cauchy_ballP F_cauchy; apply/cvg_ex. pose D := \bigcap_(A in F) (down A). @@ -4896,9 +3928,9 @@ have D_has_sup : has_sup D; first split. - exists (x0 - 1) => A FA. near F => x. apply/downP; exists x; first by near: x. - by rewrite ler_distl_subl // ltW //; near: x. + by rewrite ler_distlBl // ltW //; near: x. - exists (x0 + 1); apply/ubP => x /(_ _ x01) /downP [y]. - rewrite -[ball _ _ _]/(_ (_ < _)) ltr_distl ltr_subl_addr => /andP[/ltW]. + rewrite -[ball _ _ _]/(_ (_ < _)) ltr_distl ltrBlDr => /andP[/ltW]. by move=> /(le_trans _) yx01 _ /yx01. exists (sup D). apply/cvgrPdist_le => /= _ /posnumP[eps]; near=> x. @@ -4907,25 +3939,21 @@ rewrite ler_distl; move/ubP: (sup_upper_bound D_has_sup) => -> //=. have Fxeps : F (ball_ [eta normr] x eps%:num). by near: x; apply: nearP_dep; apply: F_cauchy. apply/ubP => y /(_ _ Fxeps) /downP[z]. - rewrite /ball_/= ltr_distl ltr_subl_addr. + rewrite /ball_/= ltr_distl ltrBlDr. by move=> /andP [/ltW /(le_trans _) le_xeps _ /le_xeps]. rewrite /D /= => A FA; near F => y. apply/downP; exists y. by near: y. -rewrite ler_subl_addl -ler_subl_addr ltW //. +rewrite lerBlDl -lerBlDr ltW //. suff: `|x - y| < eps%:num by rewrite ltr_norml => /andP[_]. by near: y; near: x; apply: nearP_dep; apply: F_cauchy. Unshelve. all: by end_near. Qed. -Canonical R_regular_completeType (R : realType) := - CompleteType R^o (@R_complete R). (*todo : delete*) -Canonical R_regular_CompleteNormedModule (R : realType) := - [completeNormedModType R of R^o]. (*todo : delete*) +HB.instance Definition _ (R : realType) := Uniform_isComplete.Build R^o + (@R_complete R). (* todo : delete *) -Canonical R_completeType (R : realType) := - [completeType of R for [completeType of R^o]]. -Canonical R_CompleteNormedModule (R : realType) := - [completeNormedModType R of R]. +HB.instance Definition _ (R : realType) := Complete.copy R + [the completeType of R^o]. (* new *) Section cvg_seq_bounded. @@ -4933,7 +3961,7 @@ Context {K : numFieldType}. Local Notation "'+oo'" := (@pinfty_nbhs K). Lemma cvg_seq_bounded {V : normedModType K} (a : nat -> V) : - cvg a -> bounded_fun a. + cvgn a -> bounded_fun a. Proof. move=> /cvg_bounded/ex_bound => -[/= Moo] => -[N _ /(_ _) aM]. have Moo_real : Moo \is Num.real by rewrite ger0_real ?(le_trans _ (aM N _))/=. @@ -4952,11 +3980,11 @@ move=> A0 ?; have [|AsupA] := pselect (A (sup A)); first exact: subset_closure. rewrite closure_limit_point; right => U /nbhs_ballP[_ /posnumP[e]] supAeU. suff [x [Ax /andP[sAex xsA]]] : exists x, A x /\ sup A - e%:num < x < sup A. exists x; split => //; first by rewrite lt_eqF. - apply supAeU; rewrite /ball /= ltr_distl (addrC x e%:num) -ltr_subl_addl sAex. - by rewrite andbT (le_lt_trans _ xsA) // ler_subl_addl ler_addr. + apply supAeU; rewrite /ball /= ltr_distl (addrC x e%:num) -ltrBlDl sAex. + by rewrite andbT (le_lt_trans _ xsA) // lerBlDl lerDr. apply: contrapT => /forallNP Ax. suff /(sup_le_ub A0) : ubound A (sup A - e%:num). - by rewrite leNgt => /negP; apply; rewrite ltr_subl_addl ltr_addr. + by rewrite leNgt => /negP; apply; rewrite ltrBlDl ltrDr. move=> y Ay; have /not_andP[//|/negP] := Ax y. rewrite negb_and leNgt => /orP[//|]; apply: contra => sAey. rewrite lt_neqAle sup_upper_bound // andbT. @@ -4966,8 +3994,8 @@ Qed. Lemma near_infty_natSinv_lt (R : archiFieldType) (e : {posnum R}) : \forall n \near \oo, n.+1%:R^-1 < e%:num. Proof. -near=> n; rewrite -(@ltr_pmul2r _ n.+1%:R) // mulVr ?unitfE //. -rewrite -(@ltr_pmul2l _ e%:num^-1) // mulr1 mulrA mulVr ?unitfE // mul1r. +near=> n; rewrite -(@ltr_pM2r _ n.+1%:R) // mulVr ?unitfE //. +rewrite -(@ltr_pM2l _ e%:num^-1) // mulr1 mulrA mulVr ?unitfE // mul1r. rewrite (lt_trans (archi_boundP _)) // ltr_nat. by near: n; exists (Num.bound e%:num^-1). Unshelve. all: by end_near. Qed. @@ -4976,9 +4004,9 @@ Lemma near_infty_natSinv_expn_lt (R : archiFieldType) (e : {posnum R}) : \forall n \near \oo, 1 / 2 ^+ n < e%:num. Proof. near=> n. -rewrite -(@ltr_pmul2r _ (2 ^+ n)) // -?natrX ?ltr0n ?expn_gt0//. +rewrite -(@ltr_pM2r _ (2 ^+ n)) // -?natrX ?ltr0n ?expn_gt0//. rewrite mul1r mulVr ?unitfE ?gt_eqF// ?ltr0n ?expn_gt0//. -rewrite -(@ltr_pmul2l _ e%:num^-1) // mulr1 mulrA mulVr ?unitfE // mul1r. +rewrite -(@ltr_pM2l _ e%:num^-1) // mulr1 mulrA mulVr ?unitfE // mul1r. rewrite (lt_trans (archi_boundP _)) // natrX upper_nthrootP //. near: n; eexists; last by move=> m; exact. by []. @@ -4986,7 +4014,7 @@ Unshelve. all: by end_near. Qed. Lemma limit_pointP (T : archiFieldType) (A : set T) (x : T) : limit_point A x <-> exists a_ : nat -> T, - [/\ a_ @` setT `<=` A, forall n, a_ n != x & a_ --> x]. + [/\ a_ @` setT `<=` A, forall n, a_ n != x & a_ @ \oo --> x]. Proof. split=> [Ax|[a_ [aTA a_x] ax]]; last first. move=> U /ax[m _ a_U]; near \oo => n; exists (a_ n); split => //. @@ -5065,7 +4093,7 @@ rewrite nbhsE /=; eexists; last by move=> y; exact. by split; [apply open_ereal_lt_ereal | rewrite /= ltNyr]. Qed. -Lemma ereal_hausdorff : hausdorff_space (ereal_topologicalType R). +Lemma ereal_hausdorff : hausdorff_space (\bar R). Proof. move=> -[r| |] // [r' | |] //=. - move=> rr'; congr (_%:E); apply Rhausdorff => /= A B rA r'B. @@ -5073,21 +4101,21 @@ move=> -[r| |] // [r' | |] //=. rr' _ _ (nbhs_image_EFin rA) (nbhs_image_EFin r'B). by rewrite -r0z => -[r1r0]; exists r0; split => //; rewrite -r1r0. - have /(@nbhs_open_ereal_lt _ (fun x => x + 1)) loc_r : r < r + 1. - by rewrite ltr_addl. + by rewrite ltrDl. move/(_ _ _ loc_r (nbhs_open_ereal_pinfty (r + 1))) => -[z [zr rz]]. by move: (lt_trans rz zr); rewrite lte_fin ltxx. - have /(@nbhs_open_ereal_gt _ (fun x => x - 1)) loc_r : r - 1 < r. - by rewrite ltr_subl_addr ltr_addl. + by rewrite ltrBlDr ltrDl. move/(_ _ _ loc_r (nbhs_open_ereal_ninfty (r - 1))) => -[z [rz zr]]. by move: (lt_trans zr rz); rewrite ltxx. - have /(@nbhs_open_ereal_lt _ (fun x => x + 1)) loc_r' : r' < r' + 1. - by rewrite ltr_addl. + by rewrite ltrDl. move/(_ _ _ (nbhs_open_ereal_pinfty (r' + 1)) loc_r') => -[z [r'z zr']]. by move: (lt_trans zr' r'z); rewrite ltxx. - move/(_ _ _ (nbhs_open_ereal_pinfty 0) (nbhs_open_ereal_ninfty 0)). by move=> -[z [zx xz]]; move: (lt_trans xz zx); rewrite ltxx. - have /(@nbhs_open_ereal_gt _ (fun x => x - 1)) yB : r' - 1 < r'. - by rewrite ltr_subl_addr ltr_addl. + by rewrite ltrBlDr ltrDl. move/(_ _ _ (nbhs_open_ereal_ninfty (r' - 1)) yB) => -[z [zr' r'z]]. by move: (lt_trans r'z zr'); rewrite ltxx. - move/(_ _ _ (nbhs_open_ereal_ninfty 0) (nbhs_open_ereal_pinfty 0)). @@ -5103,15 +4131,15 @@ Hint Extern 0 (hausdorff_space _) => solve[apply: ereal_hausdorff] : core. note="renamed to `nbhs_image_EFin`")] Notation nbhs_image_ERFin := nbhs_image_EFin (only parsing). -Lemma EFin_lim (R : realFieldType) (f : nat -> R) : cvg f -> - lim (EFin \o f) = (lim f)%:E. +Lemma EFin_lim (R : realFieldType) (f : nat -> R) : cvgn f -> + limn (EFin \o f) = (limn f)%:E. Proof. move=> cf; apply: cvg_lim => //; move/cvg_ex : cf => [l fl]. by apply: (cvg_comp fl); rewrite (cvg_lim _ fl). Qed. Section ProperFilterERealType. -Context {T : Type} {a : set (set T)} {Fa : ProperFilter a} {R : realFieldType}. +Context {T : Type} {a : set_system T} {Fa : ProperFilter a} {R : realFieldType}. Local Open Scope ereal_scope. Implicit Types f g h : T -> \bar R. @@ -5134,7 +4162,7 @@ Proof. exact: cvge_to_le. Qed. End ProperFilterERealType. Section ecvg_realFieldType_proper. -Context {I} {F : set (set I)} {FF : ProperFilter F} {R : realFieldType}. +Context {I} {F : set_system I} {FF : ProperFilter F} {R : realFieldType}. Implicit Types (f g : I -> \bar R) (u v : I -> R) (x : \bar R) (r : R). Local Open Scope ereal_scope. @@ -5205,18 +4233,18 @@ Notation ereal_limMr := limeMr (only parsing). Notation ereal_limN := limeN (only parsing). Section cvg_0_pinfty. -Context {R : realFieldType} {I : Type} {a : set (set I)} {FF : Filter a}. +Context {R : realFieldType} {I : Type} {a : set_system I} {FF : Filter a}. Implicit Types f : I -> R. Lemma gtr0_cvgV0 f : (\near a, 0 < f a) -> f\^-1 @ a --> 0 <-> f @ a --> +oo. Proof. move=> f_gt0; split; last first. move=> /cvgryPgt cvg_f_oo; apply/cvgr0Pnorm_lt => _/posnumP[e]. - near=> i; rewrite gtr0_norm ?invr_gt0//; last by near: i. - by rewrite -ltf_pinv ?qualifE ?invr_gt0 ?invrK//=; near: i. + near=> i; rewrite gtr0_norm ?invr_gt0//=; last by near: i. + by rewrite -ltf_pV2 ?qualifE/= ?invr_gt0 ?invrK//=; near: i. move=> /cvgr0Pnorm_lt uB; apply/cvgryPgty. near=> M; near=> i; suff: `|(f i)^-1| < M^-1. - by rewrite gtr0_norm ?ltf_pinv ?qualifE ?invr_gt0//; near: i. + by rewrite gtr0_norm ?ltf_pV2 ?qualifE ?invr_gt0//=; near: i. by near: i; apply: uB; rewrite ?invr_gt0. Unshelve. all: by end_near. Qed. @@ -5240,7 +4268,7 @@ Unshelve. all: by end_near. Qed. End cvg_0_pinfty. Section FilterRealType. -Context {T : Type} {a : set (set T)} {Fa : Filter a} {R : realFieldType}. +Context {T : Type} {a : set_system T} {Fa : Filter a} {R : realFieldType}. Implicit Types f g h : T -> R. Lemma squeeze_cvgr f h g : (\near a, f a <= g a <= h a) -> @@ -5249,8 +4277,8 @@ Proof. move=> fgh l lfa lga; apply/cvgrPdist_lt => e e_gt0. near=> x; have /(_ _)/andP[//|fg gh] := near fgh x. rewrite distrC ltr_distl (lt_le_trans _ fg) ?(le_lt_trans gh)//=. - by near: x; apply: (cvgr_lt l); rewrite // ltr_addl. -by near: x; apply: (cvgr_gt l); rewrite // gtr_addl oppr_lt0. + by near: x; apply: (cvgr_lt l); rewrite // ltrDl. +by near: x; apply: (cvgr_gt l); rewrite // gtrDl oppr_lt0. Unshelve. all: end_near. Qed. Lemma ger_cvgy f g : (\near a, f a <= g a) -> @@ -5270,11 +4298,11 @@ Unshelve. all: end_near. Qed. End FilterRealType. Section TopoProperFilterRealType. -Context {T : topologicalType} {a : set (set T)} {Fa : ProperFilter a}. +Context {T : topologicalType} {a : set_system T} {Fa : ProperFilter a}. Context {R : realFieldType}. Implicit Types f g h : T -> R. -Lemma ler_cvg_to f g l l' : f @ a --> l -> g @ a --> l' -> +Lemma ler_cvg_to f g (l l' : R) : f @ a --> l -> g @ a --> l' -> (\near a, f a <= g a) -> l <= l'. Proof. move=> fl gl; under eq_near do rewrite -subr_ge0; rewrite -subr_ge0. @@ -5288,7 +4316,7 @@ Proof. exact: ler_cvg_to. Qed. End TopoProperFilterRealType. Section FilterERealType. -Context {T : Type} {a : set (set T)} {Fa : Filter a} {R : realFieldType}. +Context {T : Type} {a : set_system T} {Fa : Filter a} {R : realFieldType}. Local Open Scope ereal_scope. Implicit Types f g h : T -> \bar R. @@ -5330,7 +4358,7 @@ Unshelve. all: end_near. Qed. End FilterERealType. Section TopoProperFilterERealType. -Context {T : topologicalType} {a : set (set T)} {Fa : ProperFilter a}. +Context {T : topologicalType} {a : set_system T} {Fa : ProperFilter a}. Context {R : realFieldType}. Local Open Scope ereal_scope. Implicit Types f g h : T -> \bar R. @@ -5395,14 +4423,14 @@ suff [q Iqx] : exists q, bigcup_ointsub U q x. have : nbhs x U by rewrite nbhsE /=; exists U. rewrite -nbhs_ballE /nbhs_ball /nbhs_ball_ => -[_/posnumP[r] xrU]. have /rat_in_itvoo[q qxxr] : (x - r%:num < x + r%:num)%R. - by rewrite ltr_subl_addr -addrA ltr_addl. + by rewrite ltrBlDr -addrA ltrDl. exists q, `](x - r%:num)%R, (x + r%:num)%R[%classic; last first. - by rewrite /= in_itv/= ltr_subl_addl ltr_addr// ltr_addl//; apply/andP. + by rewrite /= in_itv/= ltrBlDl ltrDr// ltrDl//; apply/andP. split=> //; split; [exact: interval_open|exact: interval_is_interval|]. move=> y /=; rewrite in_itv/= => /andP[xy yxr]; apply xrU => /=. rewrite /ball /= /ball_ /= in xrU *; have [yx|yx] := leP x y. - by rewrite ler0_norm ?subr_le0// opprB ltr_subl_addl. -by rewrite gtr0_norm ?subr_gt0// ltr_subl_addr -ltr_subl_addl. + by rewrite ler0_norm ?subr_le0// opprB ltrBlDl. +by rewrite gtr0_norm ?subr_gt0// ltrBlDr -ltrBlDl. Qed. End open_union_rat. @@ -5417,9 +4445,9 @@ 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 addrA subrr. - by rewrite sub0r normrN gtr0_norm // ltr_pdivr_mulr // ltr_pmulr // ltr1n. + by rewrite sub0r normrN gtr0_norm // ltr_pdivrMr // ltr_pMr // ltr1n. have : sup X + f%:num <= sup X by apply sup_ub. -by apply/negP; rewrite -ltNge; rewrite ltr_addl. +by apply/negP; rewrite -ltNge; rewrite ltrDl. Qed. Lemma left_bounded_interior (R : realType) (X : set R) : @@ -5432,9 +4460,9 @@ 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 addrCA subrr. - by rewrite addr0 gtr0_norm // ltr_pdivr_mulr // ltr_pmulr // ltr1n. + by rewrite addr0 gtr0_norm // ltr_pdivrMr // ltr_pMr // ltr1n. have : inf X <= inf X - f%:num by apply inf_lb. -by apply/negP; rewrite -ltNge; rewrite ltr_subl_addr ltr_addl. +by apply/negP; rewrite -ltNge; rewrite ltrBlDr ltrDl. Qed. Section interval_realType. @@ -5522,27 +4550,27 @@ case: (asboolP (has_lbound _)) => ?; case: (asboolP (has_ubound _)) => ? //=. rewrite !(lteifF, lteifT). + move=> /andP[]; rewrite le_eqVlt => /orP[/eqP <- //|infXx]. rewrite le_eqVlt => /orP[/eqP -> //|xsupX]. - apply: (@interior_subset R). + apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_bounded_interior // /mkset infXx. + move=> /andP[]; rewrite le_eqVlt => /orP[/eqP <- //|infXx supXx]. - apply: (@interior_subset R). + apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_bounded_interior // /mkset infXx. + move=> /andP[infXx]; rewrite le_eqVlt => /orP[/eqP -> //|xsupX]. - apply: (@interior_subset R). + apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_bounded_interior // /mkset infXx. - + move=> ?; apply: (@interior_subset R). + + move=> ?; apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_bounded_interior // /mkset infXx. - case: asboolP => XinfX; rewrite !(lteifF, lteifT, andbT). + rewrite le_eqVlt => /orP[/eqP<-//|infXx]. - apply: (@interior_subset R). + apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_right_unbounded_interior. - + move=> infXx; apply: (@interior_subset R). + + move=> infXx; apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_right_unbounded_interior. - case: asboolP => XsupX /=. + rewrite le_eqVlt => /orP[/eqP->//|xsupX]. - apply: (@interior_subset R). + apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_left_unbounded_interior. - + move=> xsupX; apply: (@interior_subset R). + + move=> xsupX; apply: (@interior_subset [the topologicalType of R : Type]). by rewrite interval_left_unbounded_interior. - by move=> _; rewrite (interval_unbounded_setT iX). Qed. @@ -5601,18 +4629,18 @@ split => [cE x y Ex Ey z /andP[xz zy]|]. have z1y : z1 <= y. rewrite leNgt; apply/negP => yz1. suff : (~` closure (A true)) y by apply; exact: subset_closure. - apply zcA1; rewrite /ball /= ltr_distl (lt_le_trans zy) // ?ler_addl //. - rewrite andbT ltr_subl_addl addrC (lt_trans yz1) // ltr_add2l. - by rewrite ltr_pdivr_mulr // ltr_pmulr // ltr1n. - rewrite z1y andbT ler_addl; split => //. + apply zcA1; rewrite /ball /= ltr_distl (lt_le_trans zy) // ?lerDl //. + rewrite andbT ltrBlDl addrC (lt_trans yz1) // ltrD2l. + by rewrite ltr_pdivrMr // ltr_pMr // ltr1n. + rewrite z1y andbT lerDl; split => //. have ncA1z1 : (~` closure (A true)) z1. apply zcA1; rewrite /ball /= /z1 opprD addrA subrr add0r normrN. - by rewrite ger0_norm // ltr_pdivr_mulr // ltr_pmulr // ltr1n. + by rewrite ger0_norm // ltr_pdivrMr // ltr_pMr // ltr1n. have nA0z1 : ~ (A false) z1. - move=> A0z1; have : z < z1 by rewrite /z1 ltr_addl. + move=> A0z1; have : z < z1 by rewrite /z1 ltrDl. apply/negP; rewrite -leNgt. apply: sup_ub; first by exists y => u [_] /andP[]. - by split => //; rewrite /mkset /z1 (le_trans xz) /= ?ler_addl // (ltW z1y). + by split => //; rewrite /mkset /z1 (le_trans xz) /= ?lerDl // (ltW z1y). by rewrite EU => -[//|]; apply: contra_not ncA1z1; exact: subset_closure. Qed. End interval_realType. @@ -5651,8 +4679,8 @@ apply: segment_connected. by apply/saxUf; rewrite /= in_itv/= (itvP ayz) lezx. exists i => //; apply/xe_fi; rewrite /ball_/= distrC ger0_norm. have lezy : z <= y by rewrite (itvP ayz). - rewrite ltr_subl_addl; apply: le_lt_trans lezy _; rewrite -ltr_subl_addr. - by have := xe_y; rewrite /ball_ => /ltr_distlC_subl. + rewrite ltrBlDl; apply: le_lt_trans lezy _; rewrite -ltrBlDr. + by have := xe_y; rewrite /ball_ => /ltr_distlCBl. by rewrite subr_ge0; apply/ltW. exists A; last by rewrite predeqE => x; split=> [[] | []]. move=> x clAx; have abx : x \in `[a, b]. @@ -5670,8 +4698,8 @@ have [lezy|ltyz] := lerP z y. by exists j => //=; rewrite inE orbC Dj. exists i; first by rewrite /= !inE eq_refl. apply/xe_fi; rewrite /ball_/= ger0_norm; last by rewrite subr_ge0 (itvP axz). -rewrite ltr_subl_addl -ltr_subl_addr; apply: lt_trans ltyz. -by apply: ltr_distlC_subl; rewrite distrC. +rewrite ltrBlDl -ltrBlDr; apply: lt_trans ltyz. +by apply: ltr_distlCBl; rewrite distrC. Qed. End segment. @@ -5690,11 +4718,11 @@ Lemma IVT (R : realType) (f : R -> R) (a b v : R) : Proof. move=> leab fcont; gen have ivt : f v fcont / f a <= v <= f b -> exists2 c, c \in `[a, b] & f c = v; last first. - case: (leP (f a) (f b)) => [] _ fabv; first exact: ivt. + case: (leP (f a) (f b)) => [] _ fabv /=; first exact: ivt. have [| |c cab /oppr_inj] := ivt (- f) (- v); last by exists c. - - by move=> x; apply: continuousN; apply: fcont. - - by rewrite ler_oppr opprK ler_oppr opprK andbC. -move=> favfb; suff: is_interval (f @` `[a, b]). + - by move=> x /=; apply/continuousN/fcont. + - by rewrite lerNr opprK lerNr opprK andbC. +move=> favfb; suff: is_interval (f @` `[a,b]). apply; last exact: favfb. - by exists a => //=; rewrite in_itv/= lexx. - by exists b => //=; rewrite in_itv/= leab lexx. @@ -5861,8 +4889,8 @@ have covA : A `<=` \bigcup_(n : int) [set p | `|p| < n%:~R]. have /Aco [] := covA. move=> n _; rewrite openE => p; rewrite /= -subr_gt0 => ltpn. apply/nbhs_ballP; exists (n%:~R - `|p|) => // q. - rewrite -ball_normE /= ltr_subr_addr distrC; apply: le_lt_trans. - by rewrite -{1}(subrK p q) ler_norm_add. + rewrite -ball_normE /= ltrBrDr distrC; apply: le_lt_trans. + by rewrite -{1}(subrK p q) ler_normD. move=> D _ DcovA. exists (\big[maxr/0]_(i : D) (fsval i)%:~R). rewrite bigmax_real//; last by move=> ? _; rewrite realz. @@ -5877,7 +4905,7 @@ Lemma rV_compact (T : topologicalType) n (A : 'I_n.+1 -> set T) : compact [ set v : 'rV[T]_n.+1 | forall i, A i (v ord0 i)]. Proof. move=> Aico. -have : @compact (product_topologicalType _) [set f | forall i, A i (f i)]. +have : @compact (prod_topology _) [set f | forall i, A i (f i)]. by apply: tychonoff. move=> Aco F FF FA. set G := [set [set f : 'I_n.+1 -> T | B (\row_j f j)] | B in F]. @@ -5886,7 +4914,7 @@ have row_simpl (v : 'rV[T]_n.+1) : \row_j (v ord0 j) = v. have row_simpl' (f : 'I_n.+1 -> T) : (\row_j f j) ord0 = f. by rewrite funeqE=> ?; rewrite mxE. have [f [Af clGf]] : [set f | forall i, A i (f i)] `&` - @cluster (product_topologicalType _) G !=set0. + @cluster (prod_topology _) G !=set0. suff GF : ProperFilter G. apply: Aco; exists [set v : 'rV[T]_n.+1 | forall i, A i (v ord0 i)] => //. by rewrite predeqE => f; split => Af i; [have := Af i|]; rewrite row_simpl'. @@ -5901,7 +4929,7 @@ have [f [Af clGf]] : [set f | forall i, A i (f i)] `&` by rewrite predeqE => ? /=; rewrite row_simpl'. exists (\row_j f j); split; first by move=> i; rewrite mxE; apply: Af. move=> C D FC f_D; have {}f_D : - nbhs (f : product_topologicalType _) [set g | D (\row_j g j)]. + nbhs (f : prod_topology _) [set g | D (\row_j g j)]. have [E f_E sED] := f_D; rewrite nbhsE. set Pj := fun j Bj => open_nbhs (f j) Bj /\ Bj `<=` E ord0 j. have exPj : forall j, exists Bj, open_nbhs (f j) Bj /\ Bj `<=` E ord0 j. @@ -5939,7 +4967,7 @@ have Mnco : compact by move=> _; apply: segment_compact. apply: subclosed_compact Acl Mnco _ => v /normAltM normvleM i. suff : `|v ord0 i : R| <= M + 1 by rewrite ler_norml. -apply: le_trans (normvleM _ _); last by rewrite ltr_addl. +apply: le_trans (normvleM _ _); last by rewrite ltrDl. have /mapP[j Hj ->] : `|v ord0 i| \in [seq `|v x.1 x.2| | x : 'I_1 * 'I_n.+1]. by apply/mapP; exists (ord0, i) => //=; rewrite mem_enum. by rewrite [leRHS]/normr /= mx_normrE; apply/bigmax_geP; right => /=; exists j. @@ -5975,8 +5003,14 @@ Lemma near_shift {K : numDomainType} {R : normedModType K} (y x : R) (P : set R) : (\near x, P x) = (\forall z \near y, (P \o shift (x - y)) z). Proof. -rewrite propeqE nbhs0P [X in _ <-> X]nbhs0P/= -propeqE. -by apply: eq_near => e; rewrite ![_ + e]addrC addrACA subrr addr0. +(* rewrite propeqE nbhs0P [X in _ <-> X]nbhs0P/= -propeqE. *) +(* by apply: eq_near => e; rewrite ![_ + e]addrC addrACA subrr addr0. *) +rewrite propeqE; split=> /= /nbhs_normP [_/posnumP[e] ye]; +apply/nbhs_normP; exists e%:num => //= t et. + apply: ye; rewrite /= !opprD addrA addrACA subrr add0r. + by rewrite opprK addrC. +have /= := ye (t - (x - y)); rewrite addrNK; apply. +by rewrite /= opprB addrCA addrA subrK. Qed. Lemma cvg_comp_shift {T : Type} {K : numDomainType} {R : normedModType K} @@ -5992,7 +5026,9 @@ Variables (K : numFieldType) (U V : normedModType K). Lemma continuous_shift (f : U -> V) u : {for u, continuous f} = {for 0, continuous (f \o shift u)}. -Proof. by rewrite [in RHS]forE /= add0r cvg_comp_shift add0r. Qed. +Proof. +by rewrite [in RHS]forE /continuous_at/= add0r cvg_comp_shift add0r. +Qed. Lemma continuous_withinNshiftx (f : U -> V) u : f \o shift u @ 0^' --> f u <-> {for u, continuous f}. @@ -6029,7 +5065,7 @@ Lemma ball_open (R : numDomainType) (V : normedModType R) (x : V) (r : R) : 0 < r -> open (ball x r). Proof. rewrite openE -ball_normE /interior => r0 y /= Bxy; near=> z. -rewrite /= (le_lt_trans (ler_dist_add y _ _)) // addrC -ltr_subr_addr. +rewrite /= (le_lt_trans (ler_distD y _ _)) // addrC -ltrBrDr. by near: z; apply: cvgr_dist_lt; rewrite // subr_gt0. Unshelve. all: by end_near. Qed. @@ -6077,11 +5113,11 @@ exists (y + (s / 2) *: (`|x - y|^-1 *: (x - y))); split; [apply: Be|apply: B0y]. rewrite /= opprD addrA -[X in `|X - _|](scale1r (x - y)) scalerA -scalerBl. rewrite -[X in X - _](@divrr _ `|x - y|) ?unitfE ?normr_eq0 ?subr_eq0//. rewrite -mulrBl -scalerA normrZ normfZV ?subr_eq0// mulr1. - rewrite gtr0_norm; first by rewrite ltr_subl_addl xye ltr_addr mulr_gt0. - by rewrite subr_gt0 xye ltr_pdivr_mulr // mulr_natr mulr2n ltr_spaddl. + rewrite gtr0_norm; first by rewrite ltrBlDl xye ltrDr mulr_gt0. + by rewrite subr_gt0 xye ltr_pdivrMr // mulr_natr mulr2n ltr_pwDl. rewrite -ball_normE /ball_ /= opprD addrA addrN add0r normrN normrZ. rewrite normfZV ?subr_eq0// mulr1 normrM (gtr0_norm s0) gtr0_norm //. -by rewrite ltr_pdivr_mulr // ltr_pmulr // ltr1n. +by rewrite ltr_pdivrMr // ltr_pMr // ltr1n. Qed. Lemma closed_ball_closed (R : realFieldType) (V : pseudoMetricType R) (x : V) @@ -6117,7 +5153,7 @@ split=> [/nbhs_ballP[_/posnumP[r] xrB]|[e xeB]]; last first. exact: (subset_trans (@subset_closure _ _) xeB). exists (r%:num / 2)%:sgn. apply: (subset_trans (closed_ball_subset _ _) xrB) => //=. -by rewrite lter_pdivr_mulr // ltr_pmulr // ltr1n. +by rewrite lter_pdivrMr // ltr_pMr // ltr1n. Qed. Lemma subset_closed_ball (R : realFieldType) (V : pseudoMetricType R) (x : V) @@ -6140,7 +5176,7 @@ Lemma closed_disjoint_closed_ball {R : realFieldType} {M : normedModType R} Proof. rewrite -openC => /open_subball /[apply]; move=> [e /= e0]. move=> /(_ (e / 2)) /= ; rewrite sub0r normrN gtr0_norm ?divr_gt0//. -rewrite ltr_pdivr_mulr// ltr_pmulr// ltr1n => /(_ erefl isT). +rewrite ltr_pdivrMr// ltr_pMr// ltr1n => /(_ erefl isT). move/subsets_disjoint; rewrite setCK => ze2K0. exists (e / 2); first by rewrite /= divr_gt0. move=> x /= + x0; rewrite sub0r normrN gtr0_norm// => xe. @@ -6174,11 +5210,11 @@ have [-> _|nxt] := eqVneq t x; first exact: ballxx. near ((0 : R^o)^') => e; rewrite -ball_normE /closed_ball_ => tsxr. pose z := t + `|e| *: (t - x); have /tsxr /= : `|t - z| < s. rewrite distrC addrAC subrr add0r normrZ normr_id. - rewrite -ltr_pdivl_mulr ?(normr_gt0, subr_eq0) //. + rewrite -ltr_pdivlMr ?(normr_gt0,subr_eq0) //. by near: e; apply/dnbhs0_lt; rewrite divr_gt0 // normr_gt0 subr_eq0. rewrite /z opprD addrA -scalerN -{1}(scale1r (x - t)) opprB -scalerDl normrZ. -apply lt_le_trans; rewrite ltr_pmull; last by rewrite normr_gt0 subr_eq0 eq_sym. -by rewrite ger0_norm // ltr_addl normr_gt0; near: e; exists 1 => /=. +apply lt_le_trans; rewrite ltr_pMl; last by rewrite normr_gt0 subr_eq0 eq_sym. +by rewrite ger0_norm // ltrDl normr_gt0; near: e; exists 1 => /=. Unshelve. all: by end_near. Qed. Lemma open_nbhs_closed_ball (R : realType) (V : normedModType R) (x : V) @@ -6309,23 +5345,24 @@ Lemma linear_boundedP (f : {linear V -> W}) : bounded_near f (nbhs 0) <-> Proof. split=> [|/pinfty_ex_gt0 [r r0 Bf]]; last first. apply/ex_bound; exists r; apply/nbhs_norm0P; exists 1 => //= x /=. - by rewrite -(gtr_pmulr _ r0) => /ltW; exact/le_trans/Bf. + by rewrite -(gtr_pMr _ r0) => /ltW; exact/le_trans/Bf. rewrite /bounded_near => /pinfty_ex_gt0 [M M0 /nbhs_norm0P [_/posnumP[e] efM]]. near (0 : R)^'+ => d; near=> r => x. have[->|x0] := eqVneq x 0; first by rewrite raddf0 !normr0 mulr0. have nd0 : d / `|x| > 0 by rewrite divr_gt0 ?normr_gt0. have: `|f (d / `|x| *: x)| <= M. by apply: efM => /=; rewrite normrZ gtr0_norm// divfK ?normr_eq0//. -rewrite linearZ/= normrZ gtr0_norm// -ler_pdivl_mull//; move/le_trans; apply. -rewrite invfM invrK mulrAC ler_wpmul2r//; near: r; apply: nbhs_pinfty_ge. +rewrite linearZ/= normrZ gtr0_norm// -ler_pdivlMl//; move/le_trans; apply. +rewrite invfM invrK mulrAC ler_wpM2r//; near: r; apply: nbhs_pinfty_ge. by rewrite rpredM// ?rpredV ?gtr0_real. Unshelve. all: by end_near. Qed. Lemma continuous_linear_bounded (x : V) (f : {linear V -> W}) : {for 0, continuous f} -> bounded_near f (nbhs x). Proof. -rewrite /prop_for linear0 /bounded_near => f0; near=> M; apply/nbhs0P. -near do rewrite /= linearD (le_trans (ler_norm_add _ _))// -ler_subr_addl. +rewrite /prop_for/continuous_at linear0 /bounded_near => f0. +near=> M; apply/nbhs0P. +near do rewrite /= linearD (le_trans (ler_normD _ _))// -lerBrDl. by apply: cvgr0_norm_le; rewrite // subr_gt0. Unshelve. all: by end_near. Qed. @@ -6338,7 +5375,7 @@ Lemma bounded_linear_continuous (f : {linear V -> W}) : Proof. move=> /linear_boundedP [y [yreal fr]] x; near +oo_R => r. apply/(@cvgrPdist_lt _ _ _ (nbhs x)) => e e_gt0; near=> z; rewrite -linearB. -rewrite (le_lt_trans (fr r _ _))// -?ltr_pdivl_mull//. +rewrite (le_lt_trans (fr r _ _))// -?ltr_pdivlMl//. by near: z; apply: cvgr_dist_lt => //; rewrite mulrC divr_gt0. Unshelve. all: by end_near. Qed. @@ -6366,7 +5403,7 @@ split => [/(_ 1) [M Bf]|/linear_boundedP fr y]. by rewrite sub0r normrN => x1; exact/Bf/ltW. near +oo_R => r; exists (r * y) => x xe. rewrite (@le_trans _ _ (r * `|x|)) //; first by move: {xe} x; near: r. -by rewrite ler_pmul //. +by rewrite ler_pM //. Unshelve. all: by end_near. Qed. End LinearContinuousBounded. @@ -6397,7 +5434,7 @@ Local Notation "k *` B" := (scale_ball k B). Lemma sub_scale_ball A k l : k <= l -> k *` A `<=` l *` A. Proof. move=> kl; rewrite /scale_ball; case: ifPn=> [Aball|_]; last exact: subset_refl. -by apply: le_ball; rewrite ler_wpmul2r. +by apply: le_ball; rewrite ler_wpM2r. Qed. Lemma scale_ball1 A : is_ball A -> 1 *` A = A. @@ -6437,22 +5474,22 @@ wlog : x y r s xrys r0 s0 xy / x < y. by move/esym : xrys => /[swap] /[apply]; apply => //; rewrite lt_eqF. move=> {}xy; have [rs|sr] := ltP r s. - suff : ~ ball x r (y + r). - by apply; rewrite xrys /ball/= ltr_distlC !ltr_add2l -ltr_norml gtr0_norm. - by rewrite /ball/= ltr_distlC ltr_add2r (ltNge y) (ltW xy) andbF. + by apply; rewrite xrys /ball/= ltr_distlC !ltrD2l -ltr_norml gtr0_norm. + by rewrite /ball/= ltr_distlC ltrD2r (ltNge y) (ltW xy) andbF. - suff : ~ ball y s (x - r + minr ((y - x) / 2) r). - apply; rewrite -xrys /ball/= ltr_distlC ltr_addl lt_minr r0 andbT. - rewrite divr_gt0 ?subr_gt0//= addrAC ltr_subl_addl addrCA ler_lt_add//. - by rewrite lt_minl ltr_addl r0 orbT. + apply; rewrite -xrys /ball/= ltr_distlC ltrDl lt_minr r0 andbT. + rewrite divr_gt0 ?subr_gt0//= addrAC ltrBlDl addrCA ler_ltD//. + by rewrite lt_minl ltrDl r0 orbT. have [yx2r|ryx2] := ltP ((y - x) / 2) r. - rewrite /ball/= ltr_distlC => /andP[+ _]; rewrite -(@ltr_pmul2l _ 2)//. + rewrite /ball/= ltr_distlC => /andP[+ _]; rewrite -(@ltr_pM2l _ 2)//. rewrite !mulrDr mulrCA divff// mulr1 ltNge => /negP; apply. rewrite addrAC !addrA (addrC _ y) mulr_natl mulr2n addrA addrK. - rewrite (mulr_natl y) mulr2n -!addrA ler_add2l (ler_add (ltW _))//. - by rewrite ler_wpmul2l// ler_oppl opprK. + rewrite (mulr_natl y) mulr2n -!addrA lerD2l (lerD (ltW _))//. + by rewrite ler_wpM2l// lerNl opprK. rewrite subrK /ball/= ltr_distlC => /andP[]. - rewrite ltr_subl_addl addrC -ltr_subl_addl -(@ltr_pmul2r _ (2^-1))//. + rewrite ltrBlDl addrC -ltrBlDl -(@ltr_pM2r _ (2^-1))//. move=> /le_lt_trans => /(_ _ ryx2) /le_lt_trans => /(_ _ sr). - by rewrite ltr_pmulr// invf_gt1// ltNge ler1n. + by rewrite ltr_pMr// invf_gt1// ltNge ler1n. Qed. Let ball_inj_radius x y r s : 0 < r -> ball x r = ball y s -> r = s. @@ -6461,11 +5498,11 @@ move=> r0 xrys; have s0 := ball_inj_radius_gt0 r0 xrys. move: (xrys); rewrite (ball_inj_center r0 xrys) => {}xrys. apply/eqP/negPn/negP; rewrite neq_lt => /orP[rs|sr]. - suff : ball y s (y + r) by rewrite -xrys /ball/= ltr_distlC ltxx andbF. - rewrite /ball/= ltr_distlC !ltr_add2l rs andbT (lt_trans _ r0)//. - by rewrite ltr_oppl oppr0 (lt_trans r0). + rewrite /ball/= ltr_distlC !ltrD2l rs andbT (lt_trans _ r0)//. + by rewrite ltrNl oppr0 (lt_trans r0). - suff : ball y r (y + s) by rewrite xrys /ball/= ltr_distlC ltxx andbF. - rewrite /ball/= ltr_distlC !ltr_add2l sr andbT (lt_trans _ s0)//. - by rewrite ltr_oppl oppr0 (lt_trans s0). + rewrite /ball/= ltr_distlC !ltrD2l sr andbT (lt_trans _ s0)//. + by rewrite ltrNl oppr0 (lt_trans s0). Qed. Lemma ball_inj x y r s : 0 < r -> ball x r = ball y s -> x = y /\ r = s. @@ -6639,15 +5676,15 @@ move=> _ /[1!inE] /predU1P[->|/H//]; exists k; split; [exact: ku| | |]. - case: ki0 => x [Bkx Bix] y => iy. rewrite (ballE (is_ballB k)) scale_ballE// /ball/=. rewrite -(subrK x y) -(addrC x) opprD addrA opprB. - rewrite (le_lt_trans (ler_norm_add _ _))// -nat1r mulrDl mul1r mulr_natl. - rewrite (ltr_add (is_ballP (is_ballB k) _))// -(subrK (cpoint (B i)) y). + rewrite (le_lt_trans (ler_normD _ _))// -nat1r mulrDl mul1r mulr_natl. + rewrite (ltrD (is_ballP (is_ballB k) _))// -(subrK (cpoint (B i)) y). rewrite -(addrC (cpoint (B i))) opprD addrA opprB. - rewrite (le_lt_trans (ler_norm_add _ _))//. + rewrite (le_lt_trans (ler_normD _ _))//. apply (@lt_le_trans _ _ ((radius (B j))%:num *+ 2)); last first. - apply: ler_wmuln2r; move/ujt : ku; rewrite inE => /predU1P[<-|kt]. + apply: ler_wMn2r; move/ujt : ku; rewrite inE => /predU1P[<-|kt]. exact: lexx. by have /allP := order_path_min LE_trans jt; apply; exact: kt. - rewrite mulr2n ltr_add//. + rewrite mulr2n ltrD//. by rewrite distrC (lt_le_trans (is_ballP (is_ballB i) _)). by rewrite (lt_le_trans (is_ballP (is_ballB i) _)). Qed. @@ -6688,15 +5725,14 @@ have f_ge0 : 0 <= f by rewrite floor_ge0// divr_ge0// ltW// (r_gt0 Vi). have [m /andP[mf fm]] := leq_ltn_expn `|f|.-1. exists m; split => //; apply/andP; split => [{mf}|{fm}]. rewrite -(@ler_nat R) in fm. - rewrite ltr_pdivr_mulr// mulrC -ltr_pdivr_mulr//. - rewrite (lt_le_trans _ fm)// (lt_le_trans (lt_succ_floor _))//= -/f. - rewrite -natr1 ler_add2r//. + rewrite ltr_pdivrMr// mulrC -ltr_pdivrMr// (lt_le_trans _ fm)//. + rewrite (lt_le_trans (lt_succ_floor _))//= -/f -natr1 lerD2r//. have [<-|f0] := eqVneq 0 f; first by rewrite /= ler0n. rewrite prednK//; last by rewrite absz_gt0 eq_sym. by rewrite natr_absz// ger0_norm. move: m => [|m] in mf *; first by rewrite expn0 divr1 VBr. rewrite -(@ler_nat R) in mf. -rewrite ler_pdivl_mulr// mulrC -ler_pdivl_mulr//. +rewrite ler_pdivlMr// mulrC -ler_pdivlMr//. have [f0|f0] := eqVneq 0 f. by move: mf; rewrite -f0 absz0 leNgt expnS ltr_nat leq_pmulr// expn_gt0. rewrite (le_trans mf)// prednK//; last by rewrite absz_gt0 eq_sym. @@ -6719,8 +5755,8 @@ move=> nm; wlog : n m nm / (n < m)%N. by rewrite wlg// lt_eqF. by rewrite setIC wlg// lt_eqF. move=> {}nm; apply/seteqP; split => // i [] [Vi] /andP[rnB _] [_ /andP[_]]. -move/(lt_le_trans rnB); rewrite ltr_pmul2l//; last by rewrite (r_gt0 Vi). -rewrite ltf_pinv ?posrE ?ltr0n ?expn_gt0// ltr_nat. +move/(lt_le_trans rnB); rewrite ltr_pM2l//; last by rewrite (r_gt0 Vi). +rewrite ltf_pV2 ?posrE ?ltr0n ?expn_gt0// ltr_nat. by move/ltn_pexp2l => /(_ isT); rewrite ltnNge => /negP; apply. Qed. @@ -6864,11 +5900,11 @@ have Bjrn : (radius (B j))%:num > r / (2 ^ n.+1)%:R. by move/(_ _ Dmk) => -[Bmk] _; exists m. move/(_ _ Dj) => [m/= mn1] [_] /andP[+ _]. apply: le_lt_trans. - rewrite ler_pmul2l ?(vitali_collection_partition_ub_gt0 Bset0 VBr Vi)//. - by rewrite lef_pinv// ?posrE ?ltr0n ?expn_gt0// ler_nat leq_pexp2l. + rewrite ler_pM2l ?(vitali_collection_partition_ub_gt0 Bset0 VBr Vi)//. + by rewrite lef_pV2// ?posrE ?ltr0n ?expn_gt0// ler_nat leq_pexp2l. exists j; split => //. - by case: Dj => m /= mn Dm; exists m. -- rewrite (le_trans _ (ltW Bjrn))// ler_pdivr_mulr// expnSr natrM. +- rewrite (le_trans _ (ltW Bjrn))// ler_pdivrMr// expnSr natrM. by rewrite invrM ?unitfE// mulrAC -mulrA (mulrA 2) divff// div1r. - move=> x Bix. rewrite is_ball_closure//; last first. @@ -6880,16 +5916,16 @@ exists j; split => //. rewrite radius_scale_ball//. apply: (@le_trans _ _ (2 * (radius (B i))%:num + (radius (B j))%:num)). case: BiBj => y [Biy Bjy]. - rewrite (le_trans (ler_dist_add y _ _))// [in leRHS]addrC ler_add//. + rewrite (le_trans (ler_distD y _ _))// [in leRHS]addrC lerD//. exact: is_ball_closureP. - rewrite (le_trans (ler_dist_add (cpoint (B i)) _ _))//. + rewrite (le_trans (ler_distD (cpoint (B i)) _ _))//. rewrite (_ : 2 = 1 + 1); last by []. - rewrite mulrDl !mul1r// ler_add; [by []| |exact: is_ball_closureP]. + rewrite mulrDl !mul1r// lerD; [by []| |exact: is_ball_closureP]. by rewrite distrC; exact: is_ball_closureP. - rewrite -ler_subr_addr// -(@natr1 _ 4). - rewrite (mulrDl 4%:R) mul1r addrK (natrM _ 2 2) -mulrA ler_pmul2l//. - rewrite (le_trans Birn)// [in leRHS]mulrC -ler_pdivr_mulr//. - by rewrite -mulrA -invfM -natrM-expnSr ltW. + rewrite -lerBrDr// -(@natr1 _ 4). + rewrite (mulrDl 4%:R) mul1r addrK (natrM _ 2 2) -mulrA ler_pM2l//. + rewrite (le_trans Birn)// [in leRHS]mulrC -ler_pdivrMr//. + by rewrite -mulrA -invfM -natrM -expnSr ltW. Qed. Lemma vitali_lemma_infinite_cover : { D : set I | [/\ countable D, diff --git a/theories/numfun.v b/theories/numfun.v index 03e423e5e..7774ff3f0 100644 --- a/theories/numfun.v +++ b/theories/numfun.v @@ -190,14 +190,14 @@ Lemma lt0_funeposM r f : (r < 0)%R -> (fun x => r%:E * f x)^\+ = (fun x => - r%:E * (f^\- x)). Proof. move=> r0; rewrite -[in LHS](opprK r); under eq_fun do rewrite EFinN mulNe. -by rewrite funeposN gt0_funenegM -1?ltr_oppr ?oppr0. +by rewrite funeposN gt0_funenegM -1?ltrNr ?oppr0. Qed. Lemma lt0_funenegM r f : (r < 0)%R -> (fun x => r%:E * f x)^\- = (fun x => - r%:E * (f^\+ x)). Proof. move=> r0; rewrite -[in LHS](opprK r); under eq_fun do rewrite EFinN mulNe. -by rewrite funenegN gt0_funeposM -1?ltr_oppr ?oppr0. +by rewrite funenegN gt0_funeposM -1?ltrNr ?oppr0. Qed. Lemma fune_abse f : abse \o f = f^\+ \+ f^\-. @@ -205,9 +205,9 @@ Proof. rewrite funeqE => x /=; have [fx0|/ltW fx0] := leP (f x) 0. - rewrite lee0_abs// /funepos /funeneg. move/max_idPr : (fx0) => ->; rewrite add0e. - by move: fx0; rewrite -{1}oppr0 EFinN lee_oppr => /max_idPl ->. + by move: fx0; rewrite -{1}oppe0 lee_oppr => /max_idPl ->. - rewrite gee0_abs// /funepos /funeneg; move/max_idPl : (fx0) => ->. - by move: fx0; rewrite -{1}oppr0 EFinN lee_oppl => /max_idPr ->; rewrite adde0. + by move: fx0; rewrite -{1}oppe0 lee_oppl => /max_idPr ->; rewrite adde0. Qed. Lemma funeposneg f : f = (fun x => f^\+ x - f^\- x). @@ -248,9 +248,9 @@ Qed. End funposneg_lemmas. #[global] -Hint Extern 0 (is_true (0 <= _ ^\+ _)%E) => solve [apply: funepos_ge0] : core. +Hint Extern 0 (is_true (0%R <= _ ^\+ _)%E) => solve [apply: funepos_ge0] : core. #[global] -Hint Extern 0 (is_true (0 <= _ ^\- _)%E) => solve [apply: funeneg_ge0] : core. +Hint Extern 0 (is_true (0%R <= _ ^\- _)%E) => solve [apply: funeneg_ge0] : core. Definition indic {T} {R : ringType} (A : set T) (x : T) : R := (x \in A)%:R. Reserved Notation "'\1_' A" (at level 8, A at level 2, format "'\1_' A") . @@ -268,7 +268,18 @@ Proof. by apply/funext=> x; rewrite indicE in_setT. Qed. Lemma indic0 : \1_(@set0 T) = cst (0 : R). Proof. by apply/funext=> x; rewrite indicE in_set0. Qed. -Lemma preimage_indic D (B : set R) : +Lemma image_indic D A : + \1_D @` A = (if A `\` D != set0 then [set 0] else set0) `|` + (if A `&` D != set0 then [set 1 : R] else set0). +Proof. +rewrite /indic; apply/predeqP => x; split => [[t At /= <-]|]. + by rewrite /indic; case: (boolP (t \in D)); rewrite ?(inE, notin_set) => Dt; + [right|left]; rewrite ifT//=; apply/set0P; exists t. +by move=> []; case: ifPn; rewrite ?negbK// => /set0P[t [At Dt]] ->; + exists t => //; case: (boolP (t \in D)); rewrite ?(inE, notin_set). +Qed. + +Lemma preimage_indic (D : set T) (B : set R) : \1_D @^-1` B = if 1 \in B then (if 0 \in B then setT else D) else (if 0 \in B then ~` D else set0). Proof. @@ -287,17 +298,6 @@ rewrite /preimage/= /indic; apply/seteqP; split => x; by rewrite inE in B0. Qed. -Lemma image_indic D A : - \1_D @` A = (if A `\` D != set0 then [set 0] else set0) `|` - (if A `&` D != set0 then [set 1 : R] else set0). -Proof. -rewrite /indic; apply/predeqP => x; split => [[t At /= <-]|]. - by rewrite /indic; case: (boolP (t \in D)); rewrite ?(inE, notin_set) => Dt; - [right|left]; rewrite ifT//=; apply/set0P; exists t. -by move=> []; case: ifPn; rewrite ?negbK// => /set0P[t [At Dt]] ->; - exists t => //; case: (boolP (t \in D)); rewrite ?(inE, notin_set). -Qed. - Lemma image_indic_sub D A : \1_D @` A `<=` ([set 0; 1] : set R). Proof. by rewrite image_indic; do ![case: ifP=> //= _] => // t []//= ->; [left|right]. @@ -336,11 +336,11 @@ by rewrite /ysection/=; case: (_ \in _) => //= /esym/eqP /[!oner_eq0]. Qed. Lemma indic_restrict {T : pointedType} {R : numFieldType} (A : set T) : - \1_A = 1 \_ A :> (T -> R). + \1_A = (1 : T -> R) \_ A. Proof. by apply/funext => x; rewrite indicE /patch; case: ifP. Qed. Lemma restrict_indic T (R : numFieldType) (E A : set T) : - (\1_E \_ A) = \1_(E `&` A) :> (T -> R). + ((\1_E : T -> R) \_ A) = \1_(E `&` A). Proof. apply/funext => x; rewrite /restrict 2!indicE. case: ifPn => [|] xA; first by rewrite in_setI xA andbT. @@ -355,10 +355,10 @@ Proof. split=> [|f g]; rewrite !inE/=; first exact: finite_image_cst. by move=> fA gA; apply: (finite_image11 (fun x y => x * y)). Qed. -Canonical fimfun_mul := MulrPred fimfun_mulr_closed. -Canonical fimfun_ring := SubringPred fimfun_mulr_closed. -Definition fimfun_ringMixin := [ringMixin of {fimfun aT >-> rT} by <:]. -Canonical fimfun_ringType := RingType {fimfun aT >-> rT} fimfun_ringMixin. + +HB.instance Definition _ := + @GRing.isMulClosed.Build _ (@fimfun aT rT) fimfun_mulr_closed. +HB.instance Definition _ := [SubZmodule_isSubRing of {fimfun aT >-> rT} by <:]. Implicit Types (f g : {fimfun aT >-> rT}). @@ -388,9 +388,7 @@ Arguments indic_fimfun {aT rT} _. Section comring. Context (aT : pointedType) (rT : comRingType). -Definition fimfun_comRingMixin := [comRingMixin of {fimfun aT >-> rT} by <:]. -Canonical fimfun_comRingType := - ComRingType {fimfun aT >-> rT} fimfun_comRingMixin. +HB.instance Definition _ := [SubRing_isSubComRing of {fimfun aT >-> rT} by <:]. Implicit Types (f g : {fimfun aT >-> rT}). HB.instance Definition _ f g := FImFun.copy (f \* g) (f * g). @@ -424,10 +422,10 @@ Proof. move=> cA cB A0 xy; move/normal_separatorP : normalX => urysohn_ext. have /(@uniform_separatorP _ R)[f [cf f01 f0 f1]] := urysohn_ext _ _ cA cB A0. pose g : X -> R := line_path x y \o f; exists g; split; rewrite /g /=. -- move=> t; apply: continuous_comp; first exact: cf. - apply: (@continuousD R [normedModType R of R^o]). + move=> t; apply: continuous_comp; first exact: cf. + apply: (@continuousD R R^o). apply: continuousM; last exact: cvg_cst. - by apply: (@continuousB R [normedModType R of R^o]) => //; exact: cvg_cst. + by apply: (@continuousB R R^o) => //; exact: cvg_cst. by apply: continuousM; [exact: cvg_id|exact: cvg_cst]. - by rewrite -image_comp => z /= [? /f0 -> <-]; rewrite line_path0. - by rewrite -image_comp => z /= [? /f1 -> <-]; rewrite line_path1. @@ -450,33 +448,33 @@ Proof. move: M => _/posnumP[M] ctsf fA1. have [] := @urysohn_ext_itv (A `&` f @^-1` `]-oo, -(1/3) * M%:num]) (A `&` f @^-1` `[1/3 * M%:num,+oo[) (-(1/3) * M%:num) (1/3 * M%:num). -- by rewrite closed_setSI; exact: closed_comp. -- by rewrite closed_setSI; apply: closed_comp => //; exact: interval_closed. +- by rewrite closed_setSI//; exact: closed_comp. +- by rewrite closed_setSI//; apply: closed_comp => //; exact: interval_closed. - rewrite setIACA -preimage_setI eqEsubset; split => z // [_ []]. rewrite !set_itvE/= => /[swap] /le_trans /[apply]. - by rewrite leNgt mulNr gtr_opp// mulr_gt0// divr_gt0. -- by rewrite mulNr gtr_opp// mulr_gt0. + by rewrite leNgt mulNr gtrN// mulr_gt0// divr_gt0. +- by rewrite mulNr gtrN// mulr_gt0//. move=> g [ctsg gL3 gR3 grng]; exists g; split => //; first last. by move=> x; rewrite ler_norml -mulNr; apply: grng; exists x. move=> x Ax; have := fA1 _ Ax; rewrite 2!ler_norml => /andP[Mfx fxM]. have [xL|xL] := leP (f x) (-(1/3) * M%:num). have: [set g x | x in A `&` f@^-1` `]-oo, -(1/3) * M%:num]] (g x) by exists x. move/gL3=> ->; rewrite !mulNr opprK; apply/andP; split. - by rewrite -ler_subl_addr -opprD -2!mulrDl natr1 divrr ?unitfE// mul1r. - rewrite -ler_subr_addr -2!mulrBl -(@natrB _ 2 1)// (le_trans xL)//. - by rewrite ler_pmul2r// ltW// gtr_opp// divr_gt0. + by rewrite -lerBlDr -opprD -2!mulrDl natr1 divrr ?unitfE// mul1r. + rewrite -lerBrDr -2!mulrBl -(@natrB _ 2 1)// (le_trans xL)//. + by rewrite ler_pM2r// ltW// gtrN// divr_gt0. have [xR|xR] := lerP (1/3 * M%:num) (f x). have : [set g x | x in A `&` f@^-1` `[1/3 * M%:num, +oo[] (g x). by exists x => //; split => //; rewrite /= in_itv //= xR. move/gR3 => ->; apply/andP; split. - rewrite ler_subr_addl -2!mulrBl (le_trans _ xR)// ler_pmul2r//. - by rewrite ler_wpmul2r ?invr_ge0 ?ler0n// ler_subl_addl natr1 ler1n. - by rewrite ler_subl_addl -2!mulrDl nat1r divrr ?mul1r// unitfE. + rewrite lerBrDl -2!mulrBl (le_trans _ xR)// ler_pM2r//. + by rewrite ler_wpM2r ?invr_ge0 ?ler0n// lerBlDl natr1 ler1n. + by rewrite lerBlDl -2!mulrDl nat1r divrr ?mul1r// unitfE. have /andP[ng3 pg3] : -(1/3) * M%:num <= g x <= 1/3 * M%:num. by apply: grng; exists x. rewrite ?(intrD _ 1 1) !mulrDl; apply/andP; split. - by rewrite opprD ler_sub// -mulNr ltW. -by rewrite (ler_add (ltW _))// ler_oppl -mulNr. + by rewrite opprD lerB// -mulNr ltW. +by rewrite (lerD (ltW _))// lerNl -mulNr. Qed. Let tietze_step (f : X -> R) M : @@ -506,7 +504,7 @@ pose f_ := fix F n := pose g_ n := projT1 (tietze_step (f_ n) (M2d3 n)). have fgE n : f_ n - f_ n.+1 = g_ n by rewrite /= opprB addrC subrK. have twothirds1 : `|2/3| < 1 :> R. - by rewrite gtr0_norm //= ltr_pdivr_mulr// mul1r ltr_nat. + by rewrite gtr0_norm //= ltr_pdivrMr// mul1r ltr_nat. have f_geo n : {within A, continuous f_ n} /\ (forall x, A x -> `|f_ n x| <= geometric M%:num (2/3) n). elim: n => [|n [ctsN bdN]]; first by split=> //= x ?; rewrite expr0 mulr1 fbd. @@ -518,8 +516,8 @@ have g_cts n : continuous (g_ n). have g_bd n : forall x, `|g_ n x| <= geometric ((1/3) * M%:num) (2/3) n. have [ctsN bdfN] := f_geo n; rewrite /geometric /= -[_ * M%:num * _]mulrA. by have [_ _] := projT2 (tietze_step (f_ n) _) ctsN (MN0 n) bdfN. -pose h_ : nat -> [completeType of {uniform X -> _}] := - @series [zmodType of {uniform X -> _}] g_. +pose h_ : nat -> [the completeType of {uniform X -> R^o}] := + @series {uniform X -> _} g_. have cvgh' : cvg (h_ @ \oo). apply/cauchy_cvgP/cauchy_ballP => eps epos; near_simpl. suff : \forall x & x' \near \oo, (x' <= x)%N -> ball (h_ x) eps (h_ x'). @@ -531,7 +529,7 @@ have cvgh' : cvg (h_ @ \oo). rewrite (le_lt_trans (ler_sum _ (fun i _ => g_bd i t)))// -mulr_sumr. rewrite -(subnKC MN) geometric_partial_tail. pose L := (1/3) * M%:num * ((2/3) ^+ m / (1 - (2/3))). - apply: (@le_lt_trans _ _ L); first by rewrite ler_pmul2l // geometric_le_lim. + apply: (@le_lt_trans _ _ L); first by rewrite ler_pM2l // geometric_le_lim. rewrite /L onem_twothirds. rewrite [_ ^+ _ * _ ^-1]mulrC mulrA -[x in x < _]ger0_norm; last by []. near: m; near_simpl; move: eps epos. @@ -542,7 +540,7 @@ exists (lim (h_ @ \oo)); split. - move=> t /set_mem At; have /pointwise_cvgP/(_ t)/(cvg_lim (@Rhausdorff _)) := !! pointwise_uniform_cvg _ cvgh. rewrite -fmap_comp /comp /h_ => <-; apply/esym/(@cvg_lim _ (@Rhausdorff R)). - apply: (@cvg_zero R [pseudoMetricNormedZmodType R of R^o]). + apply: (@cvg_zero R [the pseudoMetricNormedZmodType R of R^o]). apply: norm_cvg0; under eq_fun => n. rewrite distrC /series /cst /= -mulN1r fct_sumE mulr_sumr. under [fun _ : nat => _]eq_fun => ? do rewrite mulN1r -fgE opprB. @@ -563,12 +561,12 @@ exists (lim (h_ @ \oo)); split. !! pointwise_uniform_cvg _ cvgh. rewrite -fmap_comp /comp /h_ => <-. under [fun _ : nat => _]eq_fun => ? do rewrite /series /= fct_sumE. - have cvg_gt : cvg [normed series (g_^~ t)]. + have cvg_gt : cvgn [normed series (g_^~ t)]. apply: (series_le_cvg _ _ (g_bd ^~ t) (is_cvg_geometric_series _)) => //. by move=> n; rewrite mulr_ge0. rewrite (le_trans (lim_series_norm _))//; apply: le_trans. exact/(lim_series_le cvg_gt _ (g_bd ^~ t))/is_cvg_geometric_series. - rewrite (cvg_lim _ (cvg_geometric_series _))//. + rewrite (cvg_lim _ (cvg_geometric_series _))//; last exact: Rhausdorff. by rewrite onem_twothirds mulrAC divrr ?mul1r// unitfE. Unshelve. all: by end_near. Qed. diff --git a/theories/probability.v b/theories/probability.v index 6b332baca..6c4b8e571 100644 --- a/theories/probability.v +++ b/theories/probability.v @@ -424,7 +424,7 @@ rewrite covarianceDl//=; last 3 first. exact: integrableZl. - by rewrite mulrDr compreDr ?integrableD. - by rewrite mulrDr mulrC compreDr ?integrableD. -rewrite covarianceDr// covarianceDr ?(mulrC Y X)//. +rewrite covarianceDr// covarianceDr; [|by []..|by rewrite mulrC |exact: Y2]. rewrite (covarianceC P Y X) [LHS]addeA [LHS](ACl (1*4*(2*3)))/=. by rewrite -[2%R]/(1 + 1)%R EFinD muleDl ?mul1e// covariance_fin_num. Qed. @@ -493,11 +493,12 @@ rewrite -sqrteM ?variance_ge0//. rewrite lee_sqrE ?sqrte_ge0// sqr_sqrte ?mule_ge0 ?variance_ge0//. rewrite -(fineK (variance_fin_num X1 X2)) -(fineK (variance_fin_num Y1 Y2)). rewrite -(fineK (covariance_fin_num X1 Y1 XY1)). -rewrite -EFin_expe -EFinM lee_fin -(@ler_pmul2l _ 4%:R) ?ltr0n// [leRHS]mulrA. -rewrite [in leLHS](natrM _ 2 2) mulrACA -expr2 -subr_le0. -apply: deg_le2_ge0 => r; rewrite -lee_fin !EFinD. +rewrite -EFin_expe -EFinM lee_fin -(@ler_pM2l _ 4) ?ltr0n// [leRHS]mulrA. +rewrite [in leLHS](_ : 4 = 2 * 2)%R -natrM// [in leLHS]natrM mulrACA -expr2. +rewrite -subr_le0; apply: deg_le2_ge0 => r; rewrite -lee_fin !EFinD. rewrite EFinM fineK ?variance_fin_num// muleC -varianceZ//. -rewrite -mulrA EFinM mulrC EFinM ?fineK ?covariance_fin_num// -covarianceZl//. +rewrite 2!EFinM ?fineK ?variance_fin_num// ?covariance_fin_num//. +rewrite -muleA [_ * r%:E]muleC -covarianceZl//. rewrite addeAC -varianceD ?variance_ge0//=. - by rewrite compre_scale ?integrableZl. - rewrite [X in EFin \o X](_ : _ = r ^+2 \o* X ^+ 2)%R 1?mulrACA//. @@ -544,7 +545,7 @@ rewrite (le_trans _ (markov _ (expR_gt0 (r * a)) _ _ _))//; last first. exact: (monoW_in (@ger0_le_norm _)). rewrite ger0_norm ?expR_ge0// muleC lee_pmul2l// ?lte_fin ?expR_gt0//. rewrite [X in _ <= P X](_ : _ = [set x | a <= X x]%R)//; apply: eq_set => t/=. -by rewrite ger0_norm ?expR_ge0// lee_fin ler_expR mulrC ler_pmul2r. +by rewrite ger0_norm ?expR_ge0// lee_fin ler_expR mulrC ler_pM2r. Qed. Lemma chebyshev (X : {RV P >-> R}) (eps : R) : (0 < eps)%R -> @@ -625,11 +626,11 @@ have le (u : R) : (0 <= u)%R -> by rewrite (varianceD_cst_r _ Y1 Y2) EFinD fineK ?(variance_fin_num Y1 Y2). have le : [set x | lambda%:E <= (X x)%:E - 'E_P[X]] `<=` [set x | ((lambda + u)^2)%:E <= ((Y x + u)^+2)%:E]. - move=> x /= le; rewrite lee_fin; apply: ler_expn2r. + move=> x /= le; rewrite lee_fin; apply: lerXn2r. - exact: addr_ge0 (ltW lambda_gt0) _. - apply/(addr_ge0 _ uge0)/(le_trans (ltW lambda_gt0) _). by rewrite -lee_fin EFinB finEK. - - by rewrite ler_add2r -lee_fin EFinB finEK. + - by rewrite lerD2r -lee_fin EFinB finEK. apply: (le_trans (le_measure _ _ _ le)). - rewrite -[[set _ | _]]setTI inE; apply: emeasurable_fun_c_infty => [//|]. by apply: emeasurable_funB => //; exact: measurable_int X1. @@ -639,7 +640,7 @@ have le (u : R) : (0 <= u)%R -> apply/measurableT_comp => //; apply/measurable_funD => //. by rewrite -EFin_measurable_fun; apply: measurable_int Y1. set eps := ((lambda + u) ^ 2)%R. - have peps : (0 < eps)%R by rewrite exprz_gt0 ?ltr_paddr. + have peps : (0 < eps)%R by rewrite exprz_gt0 ?ltr_wpDr. rewrite (lee_pdivl_mulr _ _ peps) muleC. under eq_set => x. rewrite -[leRHS]gee0_abs ?lee_fin ?sqr_ge0 -?lee_fin => [|//]. @@ -653,9 +654,9 @@ pose u0 := (fine 'V_P[X] / lambda)%R. have u0ge0 : (0 <= u0)%R. by apply: divr_ge0 (ltW lambda_gt0); rewrite -lee_fin finVK variance_ge0. apply: le_trans (le _ u0ge0) _; rewrite lee_fin le_eqVlt; apply/orP; left. -rewrite GRing.eqr_div; [|apply: lt0r_neq0..]; last 2 first. -- by rewrite exprz_gt0 -1?[ltLHS]addr0 ?ltr_le_add. -- by rewrite ltr_paddl ?fine_ge0 ?variance_ge0 ?exprz_gt0. +rewrite eqr_div; [|apply: lt0r_neq0..]; last 2 first. +- by rewrite exprz_gt0 -1?[ltLHS]addr0 ?ltr_leD. +- by rewrite ltr_wpDl ?fine_ge0 ?variance_ge0 ?exprz_gt0. apply/eqP; have -> : fine 'V_P[X] = (u0 * lambda)%R. by rewrite /u0 -mulrA mulVr ?mulr1 ?unitfE ?gt_eqF. by rewrite -mulrDl -mulrDr (addrC u0) [in RHS](mulrAC u0) -exprnP expr2 !mulrA. diff --git a/theories/prodnormedzmodule.v b/theories/prodnormedzmodule.v index 6022f6a33..199cdf769 100644 --- a/theories/prodnormedzmodule.v +++ b/theories/prodnormedzmodule.v @@ -1,3 +1,4 @@ +From HB Require Import structures. From mathcomp Require Import all_ssreflect fingroup ssralg poly ssrnum. Require Import signed. @@ -23,7 +24,7 @@ Definition norm (x : U * V) : R := Num.max `|x.1| `|x.2|. Lemma normD x y : norm (x + y) <= norm x + norm y. Proof. -rewrite /norm num_le_maxl !(le_trans (ler_norm_add _ _)) ?ler_add//; +rewrite /norm num_le_maxl !(le_trans (ler_normD _ _)) ?lerD//; by rewrite comparable_le_maxr ?lexx ?orbT// real_comparable. Qed. @@ -34,24 +35,23 @@ by case/and3P => /eqP -> /eqP ->. Qed. Lemma normMn x n : norm (x *+ n) = (norm x) *+ n. -Proof. by rewrite /norm pairMnE -mulr_natl maxr_pmulr ?mulr_natl ?normrMn. Qed. +Proof. by rewrite /norm pairMnE -mulr_natl maxr_pMr ?mulr_natl ?normrMn. Qed. Lemma normrN x : norm (- x) = norm x. Proof. by rewrite /norm/= !normrN. Qed. -Definition normedZmodMixin : - @Num.normed_mixin_of R [zmodType of U * V] (Num.NumDomain.class R) := - @Num.NormedMixin _ _ _ norm normD norm_eq0 normMn normrN. +#[export] +HB.instance Definition _ := Num.Zmodule_isNormed.Build R (U * V)%type + normD norm_eq0 normMn normrN. -Canonical normedZmodType := NormedZmodType R (U * V) normedZmodMixin. - -Lemma prod_normE (x : normedZmodType) : `|x| = Num.max `|x.1| `|x.2|. +Lemma prod_normE (x : [the normedZmodType R of (U * V)%type]) : + `|x| = Num.max `|x.1| `|x.2|. Proof. by []. Qed. End ProdNormedZmodule. Module Exports. -Canonical normedZmodType. +HB.reexport. Definition prod_normE := @prod_normE. End Exports. diff --git a/theories/real_interval.v b/theories/real_interval.v index fcd074f8a..cc90e5e51 100644 --- a/theories/real_interval.v +++ b/theories/real_interval.v @@ -29,7 +29,7 @@ move: b i => [] [[]y|[]]; rewrite ?bnd_simp => xy; split=> //; do 1?[ by exists ((x + y) / 2); rewrite !set_itvE/= addrC !(midf_le,midf_lt) //; exact: ltW | by exists (x - 1); rewrite !set_itvE/= - !(ltr_subl_addr, ler_subl_addr, ltr_addl,ler_addl)]. + !(ltrBlDr, lerBlDr, ltrDl,lerDl)]. Qed. Lemma has_inf_half x b (i : itv_bound R) : (BSide b x < i)%O -> @@ -39,7 +39,7 @@ move: b i => [] [[]y|[]]; rewrite ?bnd_simp => xy; do 1?[ by split=> //; exists ((x + y) / 2); rewrite !set_itvE/= !(midf_le,midf_lt) //; exact: ltW - | by split => //; exists (x + 1); rewrite !set_itvE/= !(ltr_addl,ler_addl)]. + | by split => //; exists (x + 1); rewrite !set_itvE/= !(ltrDl,lerDl)]. Qed. End interval_has. @@ -59,7 +59,7 @@ case: b; last first. by rewrite -setUitv1// sup_setU ?sup1// => ? ? ? ->; exact/ltW. set s := sup _; apply/eqP; rewrite eq_le; apply/andP; split. - apply sup_le_ub; last by move=> ? /ltW. - by exists (x - 1); rewrite !set_itvE/= ltr_subl_addr ltr_addl. + by exists (x - 1); rewrite !set_itvE/= ltrBlDr ltrDl. - rewrite leNgt; apply/negP => sx; pose p := (s + x) / 2. suff /andP[?]: (p < x) && (s < p) by apply/negP; rewrite -leNgt sup_ub. by rewrite !midf_lt. @@ -100,7 +100,7 @@ Let inf_itv_bnd_o x y b : (BSide b x < BLeft y)%O -> Proof. case: b => xy. by rewrite -setU1itv// inf_setU ?inf1// => _ ? -> /andP[/ltW]. -by rewrite /inf opp_itv_bnd_bnd sup_itv_o_bnd ?opprK // ltr_oppl opprK. +by rewrite /inf opp_itv_bnd_bnd sup_itv_o_bnd ?opprK // ltrNl opprK. Qed. Let inf_itv_bounded x y a b : (BSide a x < BSide b y)%O -> @@ -160,12 +160,12 @@ Lemma itv_c_inftyEbigcap x : `[x, +oo[%classic = \bigcap_k `]x - k.+1%:R^-1, +oo[%classic. Proof. rewrite predeqE => y; split=> /= [|xy]. - rewrite in_itv /= andbT => xy z _ /=; rewrite in_itv /= andbT ltr_subl_addr. - by rewrite (le_lt_trans xy) // ltr_addl invr_gt0 ltr0n. + rewrite in_itv /= andbT => xy z _ /=; rewrite in_itv /= andbT ltrBlDr. + by rewrite (le_lt_trans xy) // ltrDl invr_gt0 ltr0n. rewrite in_itv /= andbT leNgt; apply/negP => yx. have {}[k ykx] := ltr_add_invr yx. have {xy}/= := xy k Logic.I. -by rewrite in_itv /= andbT; apply/negP; rewrite -leNgt ler_subr_addr ltW. +by rewrite in_itv /= andbT; apply/negP; rewrite -leNgt lerBrDr ltW. Qed. Lemma itv_bnd_inftyEbigcup b x : [set` Interval (BSide b x) +oo%O] = @@ -175,7 +175,7 @@ rewrite predeqE => y; split=> /=; last first. by move=> [n _]/=; rewrite in_itv => /andP[xy yn]; rewrite in_itv /= xy. rewrite in_itv /= andbT => xy; exists `|floor y|%N.+1 => //=. rewrite in_itv /= xy /=. -have [y0|y0] := ltP 0 y; last by rewrite (le_lt_trans y0)// ltr_spaddr. +have [y0|y0] := ltP 0 y; last by rewrite (le_lt_trans y0)// ltr_pwDr. by rewrite -natr1 natr_absz ger0_norm ?floor_ge0 1?ltW// lt_succ_floor. Qed. @@ -187,7 +187,7 @@ rewrite predeqE => y; split => [|[n _]]/=. have {}[k xky] := ltr_add_invr xy. by exists k => //=; rewrite in_itv /= (ltW xky). rewrite in_itv /= andbT => xny. -by rewrite in_itv /= andbT (lt_le_trans _ xny) // ltr_addl invr_gt0. +by rewrite in_itv /= andbT (lt_le_trans _ xny) // ltrDl invr_gt0. Qed. Lemma set_itv_setT (i : interval R) : [set` i] = setT -> i = `]-oo, +oo[. @@ -342,9 +342,9 @@ move fxE : (f x) => fx; case: fx fxE => [fx fxE gxE|fxoo gxE _|//]; last first. by exists 0%N => //; rewrite /E/= fxoo gxE// addye// leey. rewrite lte_fin -subr_gt0 => fgx; exists `|floor (fx - gx)^-1%R|%N => //. rewrite /E/= -natr1 natr_absz ger0_norm ?floor_ge0 ?invr_ge0; last exact/ltW. -rewrite fxE gxE lee_fin -[leRHS]invrK lef_pinv//. +rewrite fxE gxE lee_fin -[leRHS]invrK lef_pV2//. - by apply/ltW; rewrite lt_succ_floor. -- by rewrite posrE// ltr_spaddr// ler0z floor_ge0 invr_ge0 ltW. +- by rewrite posrE// ltr_pwDr// ler0z floor_ge0 invr_ge0 ltW. - by rewrite posrE invr_gt0. Qed. @@ -360,11 +360,11 @@ Lemma set1_bigcap_oc (R : realType) (r : R) : [set r] = \bigcap_i `]r - i.+1%:R^-1, r]%classic. Proof. apply/seteqP; split=> [x ->|]. - by move=> i _/=; rewrite in_itv/= lexx ltr_subl_addr ltr_addl invr_gt0 ltr0n. + by move=> i _/=; rewrite in_itv/= lexx ltrBlDr ltrDl invr_gt0 ltr0n. move=> x rx; apply/esym/eqP; rewrite eq_le (itvP (rx 0%N _))// andbT. -apply/ler_addgt0Pl => e e_gt0; rewrite -ler_subl_addl ltW//. +apply/ler_addgt0Pl => e e_gt0; rewrite -lerBlDl ltW//. have := rx `|floor e^-1%R|%N I; rewrite /= in_itv => /andP[/le_lt_trans->]//. -rewrite ler_add2l ler_opp2 -lef_pinv ?invrK//; last by rewrite qualifE. +rewrite lerD2l lerN2 -lef_pV2 ?invrK//; last by rewrite posrE. by rewrite -natr1 natr_absz ger0_norm ?floor_ge0 ?invr_ge0 1?ltW// lt_succ_floor. Qed. @@ -374,13 +374,13 @@ Lemma itv_bnd_open_bigcup (R : realType) b (r s : R) : Proof. apply/seteqP; split => [x/=|]; last first. move=> x [n _ /=] /[!in_itv] /andP[-> /le_lt_trans]; apply. - by rewrite ltr_subl_addr ltr_addl invr_gt0 ltr0n. + by rewrite ltrBlDr ltrDl invr_gt0 ltr0n. rewrite in_itv/= => /andP[sx xs]; exists `|ceil ((s - x)^-1)|%N => //=. -rewrite in_itv/= sx/= ler_subr_addl addrC -ler_subr_addl. -rewrite -[in X in _ <= X](invrK (s - x)) ler_pinv. +rewrite in_itv/= sx/= lerBrDl addrC -lerBrDl. +rewrite -[in X in _ <= X](invrK (s - x)) ler_pV2. - rewrite -natr1 natr_absz ger0_norm; last first. by rewrite ceil_ge0// invr_ge0 subr_ge0 ltW. - by rewrite (@le_trans _ _ (ceil (s - x)^-1)%:~R)// ?ler_addl// ceil_ge. + by rewrite (@le_trans _ _ (ceil (s - x)^-1)%:~R)// ?lerDl// ceil_ge. - by rewrite inE unitfE ltr0n andbT pnatr_eq0. - by rewrite inE invr_gt0 subr_gt0 xs andbT unitfE invr_eq0 subr_eq0 gt_eqF. Qed. @@ -402,7 +402,7 @@ Lemma itv_bnd_infty_bigcup (R : realType) b (x : R) : Proof. apply/seteqP; split=> y; rewrite /= !in_itv/= andbT; last first. by move=> [k _ /=]; move: b => [|] /=; rewrite in_itv/= => /andP[//] /ltW. -move=> xy; exists `|ceil (y - x)|%N => //=; rewrite in_itv/= xy/= -ler_subl_addl. +move=> xy; exists `|ceil (y - x)|%N => //=; rewrite in_itv/= xy/= -lerBlDl. rewrite !natr_absz/= ger0_norm ?ceil_ge0 ?subr_ge0 ?ceil_ge//. by case: b xy => //= /ltW. Qed. diff --git a/theories/realfun.v b/theories/realfun.v index 2330e55ed..283328f27 100644 --- a/theories/realfun.v +++ b/theories/realfun.v @@ -67,8 +67,8 @@ Lemma nondecreasing_funN {R : realType} a b (f : R -> R) : {in `[a, b] &, nondecreasing_fun f} <-> {in `[a, b] &, nonincreasing_fun (\- f)}. Proof. -split=> [h m n mab nab mn|h m n mab nab mn]; first by rewrite ler_oppr opprK h. -by rewrite -(opprK (f n)) -ler_oppr h. +split=> [h m n mab nab mn|h m n mab nab mn]; first by rewrite lerNr opprK h. +by rewrite -(opprK (f n)) -lerNr h. Qed. Lemma nonincreasing_funN {R : realType} a b (f : R -> R) : @@ -90,7 +90,7 @@ Lemma cvg_addrl (M : R) : M + r @[r --> +oo] --> +oo. Proof. move=> P [r [rreal rP]]; exists (r - M); split. by rewrite realB// num_real. -by move=> m; rewrite ltr_subl_addl => /rP. +by move=> m; rewrite ltrBlDl => /rP. Qed. (* NB: see cvg_addnr in topology.v *) @@ -142,11 +142,11 @@ rewrite neq_lt => /orP[tp|pt]. - apply: fpnl => //=; near: t. exists (b / 2) => //=; first by rewrite divr_gt0. move=> z/= + _ => /lt_le_trans; apply. - by rewrite ler_pdivr_mulr// ler_pmulr// ler1n. + by rewrite ler_pdivrMr// ler_pMr// ler1n. - apply: fppl =>//=; near: t. exists (a / 2) => //=; first by rewrite divr_gt0. move=> z/= + _ => /lt_le_trans; apply. - by rewrite ler_pdivr_mulr// ler_pmulr// ler1n. + by rewrite ler_pdivrMr// ler_pMr// ler1n. Unshelve. all: by end_near. Qed. End fun_cvg_realFieldType. @@ -155,7 +155,7 @@ Context {R : realType}. Lemma cvg_at_rightP (f : R -> R) (p l : R) : f x @[x --> p^'+] --> l <-> - (forall u : R^nat, (forall n, u n > p) /\ (u --> p) -> + (forall u : R^nat, (forall n, u n > p) /\ (u n @[n --> \oo] --> p) -> f (u n) @[n --> \oo] --> l). Proof. split=> [/cvgrPdist_le fpl u [up /cvgrPdist_lt ucvg]|pfl]. @@ -165,7 +165,7 @@ split=> [/cvgrPdist_le fpl u [up /cvgrPdist_lt ucvg]|pfl]. by near: t; exists s. apply: contrapT => fpl; move: pfl; apply/existsNP. suff: exists2 x : R ^nat, - (forall k, x k > p) /\ x --> p & ~ f (x n) @[n --> \oo] --> l. + (forall k, x k > p) /\ x n @[n --> \oo] --> p & ~ f (x n) @[n --> \oo] --> l. by move=> [x_] h; exists x_; exact/not_implyP. have [e He] : exists e : {posnum R}, forall d : {posnum R}, exists xn : R, [/\ xn > p, `|xn - p| < d%:num & `|f xn - l| >= e%:num]. @@ -182,7 +182,7 @@ exists (fun n => sval (cid (He (PosNum (invn n))))). split => [k|]; first by rewrite /sval/=; case: cid => x []. apply/cvgrPdist_lt => r r0; near=> t. rewrite /sval/=; case: cid => x [px xpt _]. - rewrite distrC (lt_le_trans xpt)// -(@invrK _ r) lef_pinv ?posrE ?invr_gt0//. + rewrite distrC (lt_le_trans xpt)// -(@invrK _ r) lef_pV2 ?posrE ?invr_gt0//. near: t; exists `|ceil (r^-1)|%N => // s /=. rewrite -ltnS -(@ltr_nat R) => /ltW; apply: le_trans. by rewrite natr_absz gtr0_norm ?ceil_gt0 ?invr_gt0// ceil_ge. @@ -193,16 +193,16 @@ Unshelve. all: by end_near. Qed. Lemma cvg_at_leftP (f : R -> R) (p l : R) : f x @[x --> p^'-] --> l <-> - (forall u : R^nat, (forall n, u n < p) /\ (u --> p) -> + (forall u : R^nat, (forall n, u n < p) /\ u n @[n --> \oo] --> p -> f (u n) @[n --> \oo] --> l). Proof. apply: (iff_trans (cvg_at_leftNP f p l)). apply: (iff_trans (cvg_at_rightP _ _ _)). split=> [pfl u [pu up]|pfl u [pu up]]. rewrite -(opprK u); apply: pfl. - by split; [move=> k; rewrite ltr_oppr opprK//|exact/cvgNP]. + by split; [move=> k; rewrite ltrNr opprK//|exact/cvgNP]. apply: pfl. -by split; [move=> k; rewrite ltr_oppl//|apply/cvgNP => /=; rewrite opprK]. +by split; [move=> k; rewrite ltrNl//|apply/cvgNP => /=; rewrite opprK]. Qed. End cvgr_fun_cvg_seq. @@ -212,7 +212,7 @@ Context {R : realType}. Lemma cvge_at_rightP (f : R -> \bar R) (p l : R) : f x @[x --> p^'+] --> l%:E <-> - (forall u : R^nat, (forall n, u n > p) /\ u --> p -> + (forall u : R^nat, (forall n, u n > p) /\ u n @[n --> \oo] --> p -> f (u n) @[n --> \oo] --> l%:E). Proof. split=> [/fine_cvgP [ffin_num fpl] u [pu up]|h]. @@ -226,12 +226,12 @@ apply: contrapT => /not_near_at_rightP abs. have invn n : 0 < n.+1%:R^-1 :> R by rewrite invr_gt0. pose y_ n := sval (cid2 (abs (PosNum (invn n)))). have py_ k : p < y_ k by rewrite /y_ /sval/=; case: cid2 => //= x /andP[]. -have y_p : y_ --> p. +have y_p : y_ n @[n --> \oo] --> p. apply/cvgrPdist_lt => e e0; near=> t. rewrite ltr0_norm// ?subr_lt0// opprB. rewrite /y_ /sval/=; case: cid2 => //= x /andP[_ + _]. - rewrite ltr_subl_addr => /lt_le_trans; apply. - rewrite addrC ler_add2r -(invrK e) lef_pinv// ?posrE ?invr_gt0//. + rewrite ltrBlDr => /lt_le_trans; apply. + rewrite addrC lerD2r -(invrK e) lef_pV2// ?posrE ?invr_gt0//. near: t. exists `|ceil e^-1|%N => // k /= ek. rewrite (le_trans (ceil_ge _))// (@le_trans _ _ `|ceil e^-1|%:~R)//. @@ -246,14 +246,14 @@ Unshelve. all: by end_near. Qed. Lemma cvge_at_leftP (f : R -> \bar R) (p l : R) : f x @[x --> p^'-] --> l%:E <-> - (forall u : R^nat, (forall n, u n < p) /\ u --> p -> + (forall u : R^nat, (forall n, u n < p) /\ u n @[n --> \oo] --> p -> f (u n) @[n --> \oo] --> l%:E). Proof. apply: (iff_trans (cvg_at_leftNP f p l%:E)). apply: (iff_trans (cvge_at_rightP _ _ l)); split=> h u [up pu]. - rewrite (_ : u = \- (\- u))%R; last by apply/funext => ?/=; rewrite opprK. - by apply: h; split; [by move=> n; rewrite ltr_oppl opprK|exact: cvgN]. -- by apply: h; split => [n|]; [rewrite ltr_oppl|move/cvgN : pu; rewrite opprK]. + by apply: h; split; [by move=> n; rewrite ltrNl opprK|exact: cvgN]. +- by apply: h; split => [n|]; [rewrite ltrNl|move/cvgN : pu; rewrite opprK]. Qed. End cvge_fun_cvg_seq. @@ -273,7 +273,7 @@ have [p Mefp] : exists p, M - e%:num <= f p. have [_ -[p _] <- /ltW efp] := sup_adherent (gt0 e) supf. by exists p; rewrite efp. near=> n; have pn : p <= n by near: n; apply: nbhs_pinfty_ge; rewrite num_real. -rewrite ler_distlC (le_trans Mefp (ndf _ _ _))//= (@le_trans _ _ M) ?ler_addl//. +rewrite ler_distlC (le_trans Mefp (ndf _ _ _))//= (@le_trans _ _ M) ?lerDl//. by have /ubP := sup_upper_bound supf; apply; exists n. Unshelve. all: by end_near. Qed. @@ -292,36 +292,36 @@ have supf : has_sup [set f x | x in [set` Interval (BRight a) b]]. - exists (f ((a + t) / 2)), ((a + t) / 2) => //=. by rewrite in_itv/= midf_lt// midf_le// ltW. - by exists (f (a + 1)), (a + 1). - - by exists (f (a + 1)), (a + 1) => //=; rewrite in_itv/= ltr_addl andbT. + - by exists (f (a + 1)), (a + 1) => //=; rewrite in_itv/= ltrDl andbT. apply/cvgrPdist_le => _/posnumP[e]. have {supf} [p [ap pb]] : exists p, [/\ a < p, (BLeft p < b)%O & M - e%:num <= f p]. have [_ -[p apb] <- /ltW efp] := sup_adherent (gt0 e) supf. move: apb; rewrite /= in_itv/= -[X in _ && X]/(BLeft p < b)%O => /andP[ap pb]. by exists p; split. -rewrite ler_subl_addr {}/M. +rewrite lerBlDr {}/M. move: b ab pb lef ubf => [[|] b|[//|]] ab pb lef ubf; set M := sup _ => Mefp. - near=> r; rewrite ler_distl; apply/andP; split. - + suff: f r <= M by apply: le_trans; rewrite ler_subl_addr ler_addl. + + suff: f r <= M by apply: le_trans; rewrite lerBlDr lerDl. apply: sup_ub => //=; exists r => //; rewrite in_itv/=. by apply/andP; split; near: r; [exact: nbhs_right_gt|exact: nbhs_right_lt]. - + rewrite (le_trans Mefp)// ler_add2r lef//=; last 2 first. + + rewrite (le_trans Mefp)// lerD2r lef//=; last 2 first. by rewrite in_itv/= ap. by near: r; exact: nbhs_right_le. apply/andP; split; near: r; [exact: nbhs_right_gt|exact: nbhs_right_lt]. - near=> r; rewrite ler_distl; apply/andP; split. - + suff: f r <= M by apply: le_trans; rewrite ler_subl_addr ler_addl. + + suff: f r <= M by apply: le_trans; rewrite lerBlDr lerDl. apply: sup_ub => //=; exists r => //; rewrite in_itv/=. by apply/andP; split; near: r; [exact: nbhs_right_gt|exact: nbhs_right_le]. - + rewrite (le_trans Mefp)// ler_add2r lef//=; last 2 first. + + rewrite (le_trans Mefp)// lerD2r lef//=; last 2 first. by rewrite in_itv/= ap. by near: r; exact: nbhs_right_le. by apply/andP; split; near: r; [exact: nbhs_right_gt|exact: nbhs_right_le]. - near=> r; rewrite ler_distl; apply/andP; split. - suff: f r <= M by apply: le_trans; rewrite ler_subl_addr ler_addl. + suff: f r <= M by apply: le_trans; rewrite lerBlDr lerDl. apply: sup_ub => //=; exists r => //; rewrite in_itv/= andbT. by near: r; apply: nbhs_right_gt. - rewrite (le_trans Mefp)// ler_add2r lef//. + rewrite (le_trans Mefp)// lerD2r lef//. - by rewrite in_itv/= andbT; near: r; exact: nbhs_right_gt. - by rewrite in_itv/= ap. - by near: r; exact: nbhs_right_le. @@ -344,7 +344,7 @@ Lemma nondecreasing_at_right_cvgr f a (b : itv_bound R) : (BRight a < b)%O -> Proof. move=> ab nif hlb; set M := inf _. have ndNf : {in Interval (BRight a) b &, nonincreasing_fun (\- f)}. - by move=> r s rab sab /nif; rewrite ler_opp2; exact. + by move=> r s rab sab /nif; rewrite lerN2; exact. have hub : has_ubound [set (\- f) x | x in [set` Interval (BRight a) b]]. apply/has_ub_lbN; rewrite image_comp/=. rewrite [X in has_lbound X](_ : _ = f @` [set` Interval (BRight a) b])//. @@ -385,7 +385,7 @@ have [Spoo|Spoo] := pselect (S +oo). have -> : l = +oo by rewrite /l /ereal_sup; exact: supremum_pinfty. rewrite -(cvg_shiftr `|N|); apply: cvg_near_cst. exists N; split; first by rewrite num_real. - by move=> x /ltW Nx; rewrite Nf// ler_paddr. + by move=> x /ltW Nx; rewrite Nf// ler_wpDr. have [lpoo|lpoo] := eqVneq l +oo. rewrite lpoo; apply/cvgeyPge => M. have /ereal_sup_gt[_ [n _] <- Mun] : M%:E < l by rewrite lpoo// ltry. @@ -477,14 +477,14 @@ have [Snoo|Snoo] := pselect (S -oo). by rewrite /l /ereal_inf /ereal_sup supremum_pinfty//=; exists -oo. apply: cvg_near_cst; exists (N - a)%R => /=; first by rewrite subr_gt0. move=> y /= + ay; rewrite ltr0_norm ?subr_lt0// opprB => ayNa. - by rewrite Nf// ay/= -(subrK a y) -ler_subr_addr ltW. + by rewrite Nf// ay/= -(subrK a y) -lerBrDr ltW. have [lnoo|lnoo] := eqVneq l -oo. rewrite lnoo; apply/cvgeNyPle => M. have /ereal_inf_lt[x [y]]/= : M%:E > l by rewrite lnoo ltNyr. rewrite in_itv/= -[X in _ && X]/(BLeft y < b)%O/= => /andP[ay yb] <- fyM. exists (y - a)%R => /=; first by rewrite subr_gt0. move=> z /= + az. - rewrite ltr0_norm ?subr_lt0// opprB ltr_subl_addr subrK => zy. + rewrite ltr0_norm ?subr_lt0// opprB ltrBlDr subrK => zy. rewrite (le_trans _ (ltW fyM))// ndf ?ltW//. by rewrite in_itv/= -[X in _ && X]/(BLeft z < b)%O/= az/= (lt_trans _ yb). by rewrite in_itv/= -[X in _ && X]/(BLeft y < b)%O/= (lt_trans az zy). @@ -503,7 +503,7 @@ have [fpoo|fpoo] := pselect {in Interval (BRight a) b, forall x, f x = +oo}. move: b ab ndf lnoo Snoo fpoo => [[|] s|[//|]] ab ndf lnoo Snoo fpoo /=. - by exists ((a + s) / 2)%R; rewrite ?fpoo// in_itv/= !midf_lt. - by exists ((a + s) / 2)%R; rewrite ?fpoo// in_itv/= !(midf_lt, midf_le)// ltW. - - by exists (a + 1)%R; rewrite ?fpoo// in_itv/= andbT ltr_addl. + - by exists (a + 1)%R; rewrite ?fpoo// in_itv/= andbT ltrDl. have [/ereal_inf_pinfty lpoo|lpoo] := eqVneq l +oo. by exfalso; apply/fpoo => r rab; rewrite (lpoo (f r))//; exists r. have l_fin_num : l \is a fin_num by rewrite fin_numE lpoo lnoo. @@ -528,7 +528,7 @@ have axA r : (a < r <= x)%R -> r \in A. rewrite -(@fineK _ l)//; apply/fine_cvgP; split. exists (x - a)%R => /=; first by rewrite subr_gt0. move=> z /= + az. - rewrite ltr0_norm ?subr_lt0// opprB ltr_subl_addr subrK// => zx. + rewrite ltr0_norm ?subr_lt0// opprB ltrBlDr subrK// => zx. by rewrite f_fin_num// axA// az/= ltW. set g := fun n => if (a < n < x)%R then fine (f n) else fine (f x). have <- : inf [set g x | x in [set` Interval (BRight a) b]] = fine l. @@ -556,7 +556,7 @@ have <- : inf [set g x | x in [set` Interval (BRight a) b]] = fine l. + exists (g ((a + s) / 2))%R, ((a + s) / 2)%R => //=. by rewrite /= in_itv/= !(midf_lt, midf_le)// ltW. + exists (g (a + 1)%R), (a + 1)%R => //=. - by rewrite in_itv/= andbT ltr_addl. + by rewrite in_itv/= andbT ltrDl. rewrite fineK//; apply/eqP; rewrite eq_le; apply/andP; split; last first. apply: le_ereal_inf => _ /= [_ [m _] <-] <-. rewrite /g; case: ifPn => [/andP[am mx]|]. @@ -591,8 +591,8 @@ suff: g x @[x --> a^'+] --> inf [set g x | x in [set` Interval (BRight a) b]]. suff nx : (n < x)%R by rewrite ltNge xn in nx. near: n; exists ((x - a) / 2)%R; first by rewrite /= divr_gt0// subr_gt0. move=> y /= /[swap] ay. - rewrite ltr0_norm// ?subr_lt0// opprB ltr_subl_addr => /lt_le_trans; apply. - by rewrite -ler_subr_addr ler_pdivr_mulr// ler_pmulr// ?ler1n// subr_gt0. + rewrite ltr0_norm// ?subr_lt0// opprB ltrBlDr => /lt_le_trans; apply. + by rewrite -lerBrDr ler_pdivrMr// ler_pMr// ?ler1n// subr_gt0. apply: nondecreasing_at_right_cvgr => //. - move=> m n; rewrite !in_itv/= -[X in _ && X]/(BLeft m < b)%O. rewrite -[X in _ -> _ && X -> _]/(BLeft n < b)%O. @@ -755,8 +755,8 @@ rewrite in_itv/= andbT => e0 <-{x}; rewrite -(ereal_sup1 0) ereal_sup_le //=. exists (f (a + e / 2)%R); last by rewrite ereal_sup1 f0. exists (a + e / 2)%R => //=; split. rewrite /ball/= opprD addrA subrr sub0r normrN gtr0_norm ?divr_gt0//. - by rewrite ltr_pdivr_mulr// ltr_pmulr// ltr1n. -by apply/eqP; rewrite gt_eqF// ltr_spaddr// divr_gt0. + by rewrite ltr_pdivrMr// ltr_pMr// ltr1n. +by apply/eqP; rewrite gt_eqF// ltr_pwDr// divr_gt0. Qed. Lemma lime_inf_ge0 f a : (forall x, 0 <= f x) -> 0 <= lime_inf f a. @@ -793,8 +793,8 @@ rewrite ereal_sup_le//. 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_pdivr_mulr// ltr_pmulr// ltr1n. - by apply/eqP; rewrite gt_eqF// ltr_spaddr// 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)%R) => //=; rewrite inf_ballE ereal_inf_lb. Unshelve. all: by end_near. Qed. @@ -817,8 +817,8 @@ rewrite (le_trans (ler_norm _))// distrC H// /ball_/= ltr_distlC. move: pry; rewrite /ball/= ltr_distlC => /andP[pay ypa]. have xq : (x <= q)%R by near: x; exact: nbhs_right_le. apply/andP; split. - by rewrite (le_lt_trans _ pay)// ler_sub. -by rewrite (lt_le_trans ypa)// ler_add2l. + by rewrite (le_lt_trans _ pay)// lerB. +by rewrite (lt_le_trans ypa)// lerD2l. Unshelve. all: by end_near. Qed. @@ -837,13 +837,13 @@ have ? : f y \is a fin_num. apply: fpA2. rewrite /ball_ /= (lt_le_trans pry)//. by near: x; exact: nbhs_right_le. -rewrite -(@fineK _ (f y)) // -EFinB lee_fin ler_subl_addr -ler_subl_addl. +rewrite -(@fineK _ (f y)) // -EFinB lee_fin lerBlDr -lerBlDl. rewrite (le_trans (ler_norm _))// H// /ball_/= ltr_distlC. move: pry; rewrite /ball/= ltr_distlC => /andP[pay ypa]. have xq : (x <= q)%R by near: x; exact: nbhs_right_le. apply/andP; split. - by rewrite (le_lt_trans _ pay)// ler_sub. -by rewrite (lt_le_trans ypa)// ler_add2l. + by rewrite (le_lt_trans _ pay)// lerB. +by rewrite (lt_le_trans ypa)// lerD2l. Unshelve. all: by end_near. Qed. @@ -1054,9 +1054,9 @@ have aux a c b : a \in I -> b \in I -> a < c -> c < b -> have ofC : {within [set` I], continuous (-f)}. move=> ?; apply: continuous_comp; [exact: fC | exact: continuousN]. have ofI : {in I &, injective (-f)} by move=>> ? ? /oppr_inj/fI ->. - rewrite -[X in X < _ -> _](opprK (f b)) ltr_oppl => ofaLofb. + rewrite -[X in X < _ -> _](opprK (f b)) ltrNl => ofaLofb. have := main _ c ofC ofI a b aI bI ofaLofb aLc cLb. - by (do 2 rewrite ltr_oppl opprK); rewrite and_comm. + by (do 2 rewrite ltrNl opprK); rewrite and_comm. split=> [faLfc|fcLfb]. suff L : f a < f b by have [] := main f c fC fI a b aI bI L aLc cLb. by case: ltgtP decr fanfb => // fbfa []//; case: ltgtP faLfc. @@ -1088,9 +1088,9 @@ Lemma itv_continuous_inj_ge f (I : interval R) : {in I &, {mono f : x y /~ x <= y}}. Proof. move=> [a [b [aI bI ab fbfa]]] fC fI x y xI yI. -suff : (- f) y <= (- f) x = (y <= x) by rewrite ler_oppl opprK. +suff : (- f) y <= (- f) x = (y <= x) by rewrite lerNl opprK. apply: itv_continuous_inj_le xI => // [|x1 x1I | x1 x2 x1I x2I]. -- by exists a, b; split => //; rewrite ler_oppl opprK. +- by exists a, b; split => //; rewrite lerNl opprK. - by apply/continuousN/fC. by move/oppr_inj; apply/fI. Qed. @@ -1166,9 +1166,9 @@ Lemma segment_can_ge a b f g : a <= b -> {in `[a, b], cancel f g} -> {in `[f b, f a] &, {mono g : x y /~ x <= y}}. Proof. -move=> aLb fC fK x y xfbfa yfbfa; rewrite -ler_opp2. +move=> aLb fC fK x y xfbfa yfbfa; rewrite -lerN2. apply: (@segment_can_le (- b) (- a) (f \o -%R) (- g)); - rewrite /= ?ler_opp2 ?opprK //. + 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. @@ -1279,41 +1279,41 @@ have fxab : f x \in `[f a, f b] by rewrite in_itv/= !fle. have := xabcc; rewrite in_itv //= => /andP [ax xb]. apply/cvgrPdist_lt => _ /posnumP[e]; rewrite !near_simpl; near=> y. rewrite (@le_lt_trans _ _ (e%:num / 2%:R))//; last first. - by rewrite ltr_pdivr_mulr// ltr_pmulr// ltr1n. + by rewrite ltr_pdivrMr// ltr_pMr// ltr1n. rewrite ler_distlC; near: y. pose u := minr (f x + e%:num / 2) (f b). pose l := maxr (f x - e%:num / 2) (f a). have ufab : u \in `[f a, f b]. rewrite !in_itv /= le_minl ?le_minr lexx ?fle // le_ab orbT ?andbT. - by rewrite ler_paddr // fle. + by rewrite ler_wpDr // fle. have lfab : l \in `[f a, f b]. rewrite !in_itv/= le_maxl ?le_maxr lexx ?fle// le_ab orbT ?andbT. - by rewrite ler_subl_addr ler_paddr// fle // lexx. + by rewrite lerBlDr ler_wpDr// fle // lexx. have guab : g u \in `[a, b]. rewrite !in_itv; apply/andP; split; have := ufab; rewrite in_itv => /andP. - by case; rewrite /= -gle // ?fK // bound_itvE fle. - by case => _; rewrite /= -gle // ?fK // bound_itvE fle. + by case; rewrite /= -[f _ <= _]gle // ?fK // bound_itvE fle. + by case => _; rewrite /= -[_ <= f _]gle // ?fK // bound_itvE fle. have glab : g l \in `[a, b]. rewrite !in_itv; apply/andP; split; have := lfab; rewrite in_itv /= => /andP. - by case; rewrite -gle // ?fK // bound_itvE fle. - by case => _; rewrite -gle // ?fK // bound_itvE fle. + by case; rewrite -[f _ <= _]gle // ?fK // bound_itvE fle. + by case => _; rewrite -[_ <= f _]gle // ?fK // bound_itvE fle. have faltu : f a < u. rewrite /u comparable_lt_minr ?real_comparable ?num_real// flt// aLb andbT. - by rewrite (@le_lt_trans _ _ (f x)) ?fle// ltr_addl. + by rewrite (@le_lt_trans _ _ (f x)) ?fle// ltrDl. have lltfb : l < f b. rewrite /u comparable_lt_maxl ?real_comparable ?num_real// flt// aLb andbT. - by rewrite (@lt_le_trans _ _ (f x)) ?fle// ltr_subl_addr ltr_addl. + by rewrite (@lt_le_trans _ _ (f x)) ?fle// ltrBlDr ltrDl. case: pselect => // _; rewrite near_withinE; near_simpl. have Fnbhs : Filter (nbhs x) by apply: nbhs_filter. have := ax; rewrite le_eqVlt => /orP[/eqP|] {}ax. near=> y => /[dup] yab; rewrite /= in_itv => /andP[ay yb]; apply/andP; split. - by rewrite (@le_trans _ _ (f a)) ?fle// ler_subl_addr ax ler_paddr. + by rewrite (@le_trans _ _ (f a)) ?fle// lerBlDr ax ler_wpDr. apply: ltW; suff : f y < u by rewrite lt_minr => /andP[->]. rewrite -?[f y < _]glt// ?fK//; last by rewrite in_itv /= !fle. by near: y; near_simpl; apply: open_lt; rewrite /= -flt ?gK// -ax. have := xb; rewrite le_eqVlt => /orP[/eqP {}xb {ax}|{}xb]. near=> y => /[dup] yab; rewrite /= in_itv /= => /andP[ay yb]. - apply/andP; split; last by rewrite (@le_trans _ _ (f b)) ?fle// xb ler_paddr. + apply/andP; split; last by rewrite (@le_trans _ _ (f b)) ?fle// xb ler_wpDr. apply: ltW; suff : l < f y by rewrite lt_maxl => /andP[->]. rewrite -?[_ < f y]glt// ?fK//; last by rewrite in_itv /= !fle. by near: y; near_simpl; apply: open_gt; rewrite /= -flt// gK// xb. @@ -1324,7 +1324,7 @@ have ? : y \in `[a, b] by apply: subset_itv_oo_cc; near: y; apply: near_in_itv. have fyab : f y \in `[f a, f b] by rewrite in_itv/= !fle// ?ltW. rewrite -[l <= _]gle -?[_ <= u]gle// ?fK //. apply: subset_itv_oo_cc; near: y; apply: near_in_itv; rewrite in_itv /=. -rewrite -[x]fK // !glt//= lt_minr lt_maxl ?andbT ltr_subl_addr ltr_spaddr //. +rewrite -[x]fK // !glt//= lt_minr lt_maxl ?andbT ltrBlDr ltr_pwDr //. by apply/and3P; split; rewrite // flt. Unshelve. all: by end_near. Qed. @@ -1337,7 +1337,7 @@ move=> fge f_surj; suff: {within `[a, b], continuous (- f)}. move=> contNf x xab; rewrite -[f]opprK. exact/continuous_comp/opp_continuous/contNf. apply: segment_inc_surj_continuous. - by move=> x y xab yab; rewrite ler_opp2 fge. + by move=> x y xab yab; rewrite lerN2 fge. by move=> y /=; rewrite -oppr_itvcc => /f_surj[x ? /(canLR opprK)<-]; exists x. Qed. @@ -1392,7 +1392,7 @@ Lemma near_can_continuousAcan_sym f g (x : R) : {near f x, continuous g} /\ {near f x, cancel g f}. Proof. move=> fK fct; near (0 : R)^'+ => e; have e_gt0 : 0 < e by []. -have xBeLxDe : x - e <= x + e by rewrite ler_add2l gt0_cp. +have xBeLxDe : x - e <= x + e by rewrite lerD2l gt0_cp. have fcte : {in `[x - e, x + e], continuous f}. by near: e; apply/at_right_in_segment. have fwcte : {within `[x - e, x + e], continuous f}. @@ -1434,7 +1434,7 @@ Variable R : realType. Lemma exprn_continuous n : continuous (@GRing.exp R ^~ n). Proof. move=> x; elim: n=> [|n /(continuousM cvg_id) ih]; first exact: cst_continuous. -by rewrite exprS; under eq_fun do rewrite exprS; exact: ih. +by rewrite /continuous_at exprS; under eq_fun do rewrite exprS; exact: ih. Qed. Lemma sqr_continuous : continuous (@exprz R ^~ 2). @@ -1454,7 +1454,7 @@ move=> x; case: (ltrgtP x 0) => [xlt0 | xgt0 | ->]. apply: (@segment_can_le_continuous _ _ _ (@GRing.exp _^~ _)) => //. by apply: continuous_subspaceT; exact: exprn_continuous. by move=> y y0b; rewrite sqrtr_sqr ger0_norm// (itvP y0b). -- rewrite sqrtr0; apply/cvgr0Pnorm_lt => _ /posnumP[e]; near=> y. +- rewrite /continuous_at sqrtr0; apply/cvgr0Pnorm_lt => _ /posnumP[e]; near=> y. have [ylt0|yge0] := ltrP y 0; first by rewrite ltr0_sqrtr ?normr0. rewrite ger0_norm ?sqrtr_ge0//; have: `|y| < e%:num ^+ 2 by []. by rewrite -ltr_sqrt// ger0_norm// sqrtr_sqr ger0_norm. @@ -1498,7 +1498,7 @@ by near: y; rewrite near_withinE /= near_simpl; near=> x1. Unshelve. all: by end_near. Qed. Lemma is_derive_0_is_cst (f : R -> R) x y : - (forall x, is_derive x 1 f 0) -> f x = f y. + (forall x, is_derive x (1 : R) f 0) -> f x = f y. Proof. move=> Hd. wlog xLy : x y / x <= y by move=> H; case: (leP x y) => [/H |/ltW /H]. @@ -1657,7 +1657,7 @@ Lemma nonincreasing_fun_itv_partition a b f s : let F : nat -> R := f \o nth b (a :: s) in forall k, (k < size s)%N -> F k.+1 <= F k. Proof. -move/nonincreasing_funN => ndNf abs F k ks; rewrite -(opprK (F k)) ler_oppr. +move/nonincreasing_funN => ndNf abs F k ks; rewrite -(opprK (F k)) lerNr. exact: (nondecreasing_fun_itv_partition ndNf abs). Qed. @@ -1719,7 +1719,7 @@ Proof. move=> [sa /eqP alb]; split. rewrite (_ : - b = last (- a) (map -%R s)); last by rewrite last_map alb. rewrite rev_path// path_map. - by apply: sub_path sa => x y xy/=; rewrite ltr_oppr opprK. + by apply: sub_path sa => x y xy/=; rewrite ltrNr opprK. case: s sa alb => [_ <-//|h t] /= /andP[ah ht] <-{b}. by rewrite rev_cons last_rcons. Qed. @@ -1862,8 +1862,8 @@ move: B => B. elim/last_ind : L => [|L0 L1 _]. rewrite !cat0s /=; case: B => [|B0 B1]. by rewrite big_nil big_cons/= big_nil addr0. - rewrite !big_cons/= addrA ler_add// [leRHS]addrC. - by rewrite -[in leLHS](subrK (f c) (f _)) -addrA ler_norm_add. + rewrite !big_cons/= addrA lerD// [leRHS]addrC. + by rewrite (le_trans _ (ler_normD _ _))// addrA subrK. rewrite -cats1. rewrite (_ : a :: _ ++ B = (a :: L0) ++ [:: L1] ++ B)//; last first. by rewrite -!catA -cat_cons. @@ -1871,23 +1871,22 @@ rewrite zip_cat; last by rewrite cats1 size_rcons. rewrite (_ : a :: _ ++ _ ++ B = (a :: L0) ++ [:: L1] ++ [:: c] ++ B); last first. by rewrite -!catA -cat_cons. rewrite zip_cat; last by rewrite cats1 size_rcons. -rewrite !big_cat ler_add//. +rewrite !big_cat lerD//. case: B => [|B0 B1]. by rewrite /= big_nil big_cons big_nil addr0. rewrite -cat1s zip_cat// catA. rewrite (_ : [:: L1] ++ _ ++ B1 = ([:: L1] ++ [:: c]) ++ [:: B0] ++ B1); last first. by rewrite catA. -rewrite zip_cat// !big_cat ler_add//= !big_cons !big_nil !addr0/= [leRHS]addrC. -by rewrite -[in leLHS](subrK (f c) (f B0)) -addrA ler_norm_add. +rewrite zip_cat// !big_cat lerD//= !big_cons !big_nil !addr0/= [leRHS]addrC. + by rewrite (le_trans _ (ler_normD _ _))// addrA subrK. Qed. Lemma le_variation a b f s x : variation a b f s <= variation a b f (x :: s). Proof. case: s => [|h t]. by rewrite variation_nil /variation/= big_nat_recl//= big_nil addr0. -rewrite /variation/= !big_nat_recl//= addrA ler_add2r. -rewrite -[in leLHS](subrK (f x) (f h)) -addrA (le_trans (ler_norm_add _ _))//. -by rewrite distrC addrC. +rewrite /variation/= !big_nat_recl//= addrA lerD2r. +by rewrite (le_trans _ (ler_normD _ _))// (addrC (f x - _)) addrA subrK. Qed. Lemma variation_opp_rev a b f s : itv_partition a b s -> @@ -1950,7 +1949,7 @@ case: ifPn => [|] nXA. move/eqP : nXA itvxt itvxb => -> itvat itvt /= ta. rewrite -[_ :: t]cat1s -[_ :: s]cat1s. rewrite -?(@variationD _ _ a)//; [|exact: itv_partition1..]. - by rewrite ler_add// IH. + by rewrite lerD// IH. move=> xts; rewrite -[_ :: s]cat1s -(@variationD _ _ a) => //; last first. exact: itv_partition1. have [y [s' s'E]] : exists y s', s = y :: s'. @@ -2006,7 +2005,7 @@ Lemma bounded_variationD a b f g : a < b -> Proof. move=> ab [r abfr] [s abgs]; exists (r + s) => _ [l abl] <-. apply: le_trans; first exact: variation_le. -rewrite ler_add//. +rewrite lerD//. - by apply: abfr; exact: variations_variation. - by apply: abgs; exact: variations_variation. Qed. @@ -2022,7 +2021,7 @@ move=> [x Hx]; exists x => _ [s acs] <-. rewrite (@le_trans _ _ (variation a b f (rcons s b)))//; last first. apply/Hx/variations_variation; case: acs => sa /eqP asc. by rewrite /itv_partition rcons_path last_rcons sa/= asc. -rewrite {2}/variation size_rcons -[leLHS]addr0 big_nat_recr//= ler_add//. +rewrite {2}/variation size_rcons -[leLHS]addr0 big_nat_recr//= lerD//. rewrite /variation !big_nat ler_sum// => k; rewrite leq0n /= => ks. rewrite nth_rcons// ks -cats1 -cat_cons nth_cat /= ltnS (ltnW ks). by rewrite ![in leRHS](set_nth_default c)//= ltnS ltnW. @@ -2036,7 +2035,7 @@ move=> [x Hx]; exists x => _ [s cbs] <-. rewrite (@le_trans _ _ (variation a b f (c :: s)))//; last first. apply/Hx/variations_variation; case: cbs => cs csb. by rewrite /itv_partition/= ac/= cs. -by rewrite {2}/variation/= -[leLHS]add0r big_nat_recl//= ler_add. +by rewrite {2}/variation/= -[leLHS]add0r big_nat_recl//= lerD. Qed. Lemma variations_opp a b f : @@ -2198,7 +2197,7 @@ apply: (le_trans (variation_itv_partitionLR _ ac _ _)) => //. apply: sup_ub => /=. case: bdAB => M ubdM; case: bdAC => N ubdN; exists (N + M). move=> q [?] [i pabi <-] [? [j pbcj <-]] <-. - by apply: ler_add; [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)). @@ -2345,16 +2344,19 @@ have xbfin : TV a x f \is a fin_num. by apply/bounded_variationP => //; exact: bounded_variationl bvf. apply: fine_cvg; rewrite /neg_tv fineM // ?fin_numB ?xbfin //= EFinM. under eq_fun => i do rewrite EFinN. -apply: cvg_trans; first (apply: cvgeMr => //); last exact: cvg_id. -rewrite fineD // EFinB; apply: cvgeB => //. - apply/ fine_cvgP; split; first exists (b-x). +apply: (@cvg_trans _ (((TV a n f - (f n)%:E) * 2^-1%:E)%E @[n --> x^'+])). + exact: cvg_id. +apply: cvgeMr; first by []. +rewrite fineD; [|by []..]. +rewrite EFinB; apply: cvgeB; [by []| |]. + apply/ fine_cvgP; split; first exists (b - x). - by rewrite /= subr_gt0. - move=> t /= xtbx xt; have ? : a <= t. by apply: ltW; apply: (le_lt_trans ax). apply/bounded_variationP => //. apply: bounded_variationl bvf => //. move: xtbx; rewrite distrC ger0_norm ?subr_ge0; last by exact: ltW. - by rewrite ltr_subr_addr -addrA [-_ + _]addrC subrr addr0 => /ltW. + by rewrite ltrBrDr -addrA [-_ + _]addrC subrr addr0 => /ltW. by apply: total_variation_right_continuous => //; last exact: bvf. apply: cvg_comp; first exact: fcts. apply/ fine_cvgP; split; first by near=> t => //. @@ -2373,8 +2375,8 @@ move=> ax xb fNcts bvf. apply/cvg_at_leftNP; rewrite total_variation_opp. have bvNf : BV (-b) (-a) (f \o -%R). by case: bvf => M; rewrite -variations_opp => ?; exists M. -have bx : - b <= - x by rewrite ler_oppl opprK. -have xa : - x < - a by rewrite ltr_oppl opprK. +have bx : - b <= - x by rewrite lerNl opprK. +have xa : - x < - a by rewrite ltrNl opprK. have ? : - x <= - a by exact: ltW. have ? : Filter (nbhs (-x)^'+) by exact: at_right_proper_filter. have -> : fine (TV (-x) (-a) (f \o -%R)) = @@ -2399,8 +2401,8 @@ have /near_eq_cvg/cvg_trans : {near (- x)^'+, apply. apply: cvgB; first exact: cvg_cst. apply: (total_variation_right_continuous _ _ _ bvNf). -- by rewrite ler_oppl opprK //. -- by rewrite ltr_oppl opprK //. +- by rewrite lerNl opprK //. +- by rewrite ltrNl opprK //. by apply/cvg_at_leftNP; rewrite /= opprK. Unshelve. all: by end_near. Qed. diff --git a/theories/reals.v b/theories/reals.v index a7fb89377..79e403811 100644 --- a/theories/reals.v +++ b/theories/reals.v @@ -39,6 +39,7 @@ (* *) (******************************************************************************) +From HB Require Import structures. From mathcomp Require Import all_ssreflect all_algebra. From mathcomp Require Import mathcomp_extra boolp classical_sets set_interval. @@ -80,7 +81,7 @@ Proof. by rewrite predeqE => r; split => // _. Qed. Lemma lboundT : lbound [set: R] = set0. Proof. rewrite predeqE => r; split => // /(_ (r - 1) Logic.I). -rewrite ler_subr_addl addrC -ler_subr_addl subrr. +rewrite lerBrDl addrC -lerBrDl subrr. by rewrite real_leNgt ?realE ?ler01// ?lexx// ltr01. Qed. @@ -116,166 +117,44 @@ Qed. End has_bound_lemmas. (* -------------------------------------------------------------------- *) -Module Real. -Section Mixin. -Variable (R : archiFieldType). - -Record mixin_of : Type := Mixin { - _ : - forall E : set (Num.ArchimedeanField.sort R), +HB.mixin Record ArchimedeanField_isReal R of Num.ArchimedeanField R := { + sup_upper_bound_subdef : + forall E : set [the archiFieldType of R], has_sup E -> ubound E (supremum 0 E) ; - _ : - forall (E : set (Num.ArchimedeanField.sort R)) (eps : R), 0 < eps -> + sup_adherent_subdef : + forall (E : set [the archiFieldType of R]) (eps : R), 0 < eps -> has_sup E -> exists2 e : R, E e & (supremum 0 E - eps) < e ; }. -End Mixin. - -Definition EtaMixin R sup_upper_bound sup_adherent := - let _ := @Mixin R sup_upper_bound sup_adherent in - @Mixin (Num.ArchimedeanField.Pack (Num.ArchimedeanField.class R)) - sup_upper_bound sup_adherent. -Section ClassDef. - -Record class_of (R : Type) : Type := Class { - base : Num.ArchimedeanField.class_of R; - mixin_rcf : Num.real_closed_axiom (Num.NumDomain.Pack base); - (* TODO: ajouter une structure de pseudoMetricNormedDomain *) - mixin : mixin_of (Num.ArchimedeanField.Pack base) -}. +#[short(type=realType)] +HB.structure Definition Real := {R of ArchimedeanField_isReal R + & Num.ArchimedeanField R & Num.RealClosedField R}. -Local Coercion base : class_of >-> Num.ArchimedeanField.class_of. -Local Coercion base_rcf R (c : class_of R) : Num.RealClosedField.class_of R := - @Num.RealClosedField.Class _ c (@mixin_rcf _ c). - -Structure type := Pack {sort; _ : class_of sort; _ : Type}. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c _ as cT' := cT return class_of cT' in c. -Definition clone c of phant_id class c := @Pack T c T. -Let xT := let: Pack T _ _ := cT in T. -Notation xclass := (class : class_of xT). - -Definition rcf_axiom {R} (cR : Num.RealClosedField.class_of R) : - Num.real_closed_axiom (Num.NumDomain.Pack cR) := - match cR with Num.RealClosedField.Class _ ax => ax end. -Coercion rcf_axiom : Num.RealClosedField.class_of >-> Num.real_closed_axiom. - -Definition pack b0 (m0 : mixin_of (@Num.ArchimedeanField.Pack T b0)) := - fun bT b & phant_id (Num.ArchimedeanField.class bT) b => - fun (bTr : rcfType) (br : Num.RealClosedField.class_of bTr) & - phant_id (Num.RealClosedField.class bTr) br => - fun cra & phant_id (@rcf_axiom bTr br) cra => - fun m & phant_id m0 m => Pack (@Class T b cra m) T. - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition porderType := @Order.POrder.Pack ring_display cT xclass. -Definition latticeType := @Order.Lattice.Pack ring_display cT xclass. -Definition distrLatticeType := @Order.DistrLattice.Pack ring_display cT xclass. -Definition orderType := @Order.Total.Pack ring_display cT xclass. -Definition zmodType := @GRing.Zmodule.Pack cT xclass. -Definition ringType := @GRing.Ring.Pack cT xclass. -Definition comRingType := @GRing.ComRing.Pack cT xclass. -Definition unitRingType := @GRing.UnitRing.Pack cT xclass. -Definition comUnitRingType := @GRing.ComUnitRing.Pack cT xclass. -Definition idomainType := @GRing.IntegralDomain.Pack cT xclass. -Definition numDomainType := @Num.NumDomain.Pack cT xclass. -Definition normedZmodType := NormedZmodType numDomainType cT xclass. -Definition fieldType := @GRing.Field.Pack cT xclass. -Definition realDomainType := @Num.RealDomain.Pack cT xclass. -Definition numFieldType := @Num.NumField.Pack cT xclass. -Definition realFieldType := @Num.RealField.Pack cT xclass. -Definition archimedeanFieldType := @Num.ArchimedeanField.Pack cT xclass. -Definition rcfType := @Num.RealClosedField.Pack cT xclass. -Definition join_rcfType := @Num.RealClosedField.Pack archimedeanFieldType xclass. - -End ClassDef. - -Module Exports. -Coercion base : class_of >-> Num.ArchimedeanField.class_of. -Coercion base_rcf : class_of >-> Num.RealClosedField.class_of. -Coercion mixin : class_of >-> mixin_of. -Coercion sort : type >-> Sortclass. -Bind Scope ring_scope with sort. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion porderType : type >-> Order.POrder.type. -Canonical porderType. -Coercion latticeType : type >-> Order.Lattice.type. -Canonical latticeType. -Coercion distrLatticeType : type >-> Order.DistrLattice.type. -Canonical distrLatticeType. -Coercion orderType : type >-> Order.Total.type. -Canonical orderType. -Coercion zmodType : type >-> GRing.Zmodule.type. -Canonical zmodType. -Coercion ringType : type >-> GRing.Ring.type. -Canonical ringType. -Coercion comRingType : type >-> GRing.ComRing.type. -Canonical comRingType. -Coercion unitRingType : type >-> GRing.UnitRing.type. -Canonical unitRingType. -Coercion comUnitRingType : type >-> GRing.ComUnitRing.type. -Canonical comUnitRingType. -Coercion idomainType : type >-> GRing.IntegralDomain.type. -Canonical idomainType. -Coercion numDomainType : type >-> Num.NumDomain.type. -Canonical numDomainType. -Coercion normedZmodType : type >-> Num.NormedZmodule.type. -Canonical normedZmodType. -Coercion realDomainType : type >-> Num.RealDomain.type. -Canonical realDomainType. -Coercion fieldType : type >-> GRing.Field.type. -Canonical fieldType. -Coercion numFieldType : type >-> Num.NumField.type. -Canonical numFieldType. -Coercion realFieldType : type >-> Num.RealField.type. -Canonical realFieldType. -Coercion archimedeanFieldType : type >-> Num.ArchimedeanField.type. -Canonical archimedeanFieldType. -Coercion rcfType : type >-> Num.RealClosedField.type. -Canonical rcfType. -Canonical join_rcfType. - -Notation realType := type. -Notation RealType T m := (@pack T _ m _ _ id _ _ id _ id _ id). -Notation RealMixin := EtaMixin. -Notation "[ 'realType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'realType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'realType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'realType' 'of' T ]") : form_scope. - -End Exports. -End Real. - -Export Real.Exports. +Bind Scope ring_scope with Real.sort. (* -------------------------------------------------------------------- *) Definition sup {R : realType} := @supremum _ R 0. (*Local Notation "-` E" := [pred x | - x \in E] - (at level 35, right associativity) : fun_scope.*) + (at level 35, right associativity) : function_scope.*) Definition inf {R : realType} (E : set R) := - sup (-%R @` E). (* -------------------------------------------------------------------- *) Lemma sup_upper_bound {R : realType} (E : set R): has_sup E -> ubound E (sup E). -Proof. by move=> supE; case: R E supE=> ? [? ? []]. Qed. +Proof. exact: sup_upper_bound_subdef. Qed. Lemma sup_adherent {R : realType} (E : set R) (eps : R) : 0 < eps -> has_sup E -> exists2 e : R, E e & (sup E - eps) < e. -Proof. by case: R E eps=> ? [? ? []]. Qed. +Proof. exact: sup_adherent_subdef. Qed. (* -------------------------------------------------------------------- *) Section IsInt. Context {R : realFieldType}. -Definition Rint := [qualify a x : R | `[< exists z, x == z%:~R >]]. -Fact Rint_key : pred_key Rint. Proof. by []. Qed. -Canonical Rint_keyed := KeyedQualifier Rint_key. +Definition Rint_pred := fun x : R => `[< exists z, x == z%:~R >]. +Arguments Rint_pred _ /. +Definition Rint := [qualify a x | Rint_pred x]. Lemma Rint_def x : (x \is a Rint) = (`[< exists z, x == z%:~R >]). Proof. by []. Qed. @@ -302,29 +181,25 @@ split=> // _ _ /RintP[x ->] /RintP[y ->]; apply/RintP. by exists (x - y); rewrite rmorphB. by exists (x * y); rewrite rmorphM. Qed. -Canonical Rint_opprPred := OpprPred Rint_subring_closed. -Canonical Rint_addrPred := AddrPred Rint_subring_closed. -Canonical Rint_mulrPred := MulrPred Rint_subring_closed. -Canonical Rint_zmodPred := ZmodPred Rint_subring_closed. -Canonical Rint_semiringPred := SemiringPred Rint_subring_closed. -Canonical Rint_smulrPred := SmulrPred Rint_subring_closed. -Canonical Rint_subringPred := SubringPred Rint_subring_closed. +HB.instance Definition _ := GRing.isSubringClosed.Build R Rint_pred + Rint_subring_closed. Lemma Rint_ler_addr1 (x y : R) : x \is a Rint -> y \is a Rint -> (x + 1 <= y) = (x < y). Proof. move=> /RintP[xi ->] /RintP[yi ->]; rewrite -{2}[1]mulr1z. -by rewrite -intrD !(ltr_int, ler_int) lez_addr1. +by rewrite -intrD !(ltr_int, ler_int) lezD1. Qed. Lemma Rint_ltr_addr1 (x y : R) : x \is a Rint -> y \is a Rint -> (x < y + 1) = (x <= y). Proof. move=> /RintP[xi ->] /RintP[yi ->]; rewrite -{3}[1]mulr1z. -by rewrite -intrD !(ltr_int, ler_int) ltz_addr1. +by rewrite -intrD !(ltr_int, ler_int) ltzD1. Qed. End IsInt. +Arguments Rint_pred _ _ /. (* -------------------------------------------------------------------- *) Section ToInt. @@ -422,11 +297,11 @@ have Dz: 2%:R * z = x + y. by rewrite mulrCA divff ?mulr1 // pnatr_eq0. have ubE : has_sup E by split => //; exists x. have [/downP [t Et lezt] | leyz] := sup_total z ubE. - rewrite -(ler_add2l x) -Dz -mulr2n -[leRHS]mulr_natl. - rewrite ler_pmul2l ?ltr0Sn //; apply/(le_trans lezt). + rewrite -(lerD2l x) -Dz -mulr2n -[leRHS]mulr_natl. + rewrite ler_pM2l ?ltr0Sn //; apply/(le_trans lezt). by move/ubP : leEx; exact. -rewrite -(ler_add2r y) -Dz -mulr2n -[leLHS]mulr_natl. -by rewrite ler_pmul2l ?ltr0Sn. +rewrite -(lerD2r y) -Dz -mulr2n -[leLHS]mulr_natl. +by rewrite ler_pM2l ?ltr0Sn. Qed. Lemma sup_setU (A B : set R) : has_sup B -> @@ -459,16 +334,16 @@ move=> /[dup] supA [[a Aa] ubA] /[dup] supB [[b Bb] ubB]. have ABsup : has_sup [set x + y | x in A & y in B]. split; first by exists (a + b), a => //; exists b. case: ubA ubB => p up [q uq]; exists (p + q) => ? [r Ar [s Bs] <-]. - by apply: ler_add; [exact: up | exact: uq]. + by apply: lerD; [exact: up | exact: uq]. apply: le_anti; apply/andP; split. apply: sup_le_ub; first by case: ABsup. - by move=> ? [p Ap [q Bq] <-]; apply: ler_add; exact: sup_ub. + by move=> ? [p Ap [q Bq] <-]; apply: lerD; exact: sup_ub. rewrite real_leNgt ?num_real// -subr_gt0; apply/negP. set eps := (_ + _ - _) => epos. have e2pos : 0 < eps / 2%:R by rewrite divr_gt0// ltr0n. have [r Ar supBr] := sup_adherent e2pos supA. have [s Bs supAs] := sup_adherent e2pos supB. -have := ltr_add supBr supAs. +have := ltrD supBr supAs. rewrite -addrA [-_+_]addrC -addrA -opprD -splitr addrA /= opprD opprK addrA. rewrite subrr add0r; apply/negP; rewrite -real_leNgt ?num_real//. by apply: sup_upper_bound => //; exists r => //; exists s. @@ -501,7 +376,7 @@ Implicit Types x : R. Lemma inf_lower_bound E : has_inf E -> lbound E (inf E). Proof. move=> /has_inf_supN /sup_upper_bound /ubP inflb; apply/lbP => x. -by rewrite memNE => /inflb; rewrite ler_oppl. +by rewrite memNE => /inflb; rewrite lerNl. Qed. Lemma inf_adherent E (eps : R) : 0 < eps -> @@ -509,7 +384,7 @@ Lemma inf_adherent E (eps : R) : 0 < eps -> Proof. move=> + /has_inf_supN supNE => /sup_adherent /(_ supNE)[e NEx egtsup]. exists (- e); first by case: NEx => x Ex <-{}; rewrite opprK. -by rewrite ltr_oppl -mulN1r mulrDr !mulN1r opprK. +by rewrite ltrNl -mulN1r mulrDr !mulN1r opprK. Qed. Lemma inf_out E : ~ has_inf E -> inf E = 0. @@ -536,7 +411,7 @@ Qed. Lemma lb_le_inf E x : nonempty E -> (lbound E) x -> x <= inf E. Proof. -by move=> /(nonemptyN E) En0 /lb_ubN /(sup_le_ub En0); rewrite ler_oppr. +by move=> /(nonemptyN E) En0 /lb_ubN /(sup_le_ub En0); rewrite lerNr. Qed. Lemma has_infPn E : nonempty E -> @@ -551,14 +426,14 @@ Lemma inf_setU (A B : set R) : has_inf A -> Proof. move=> hiA AB; congr (- _). rewrite image_setU setUC sup_setU //; first exact/has_inf_supN. -by move=> _ _ [] b Bb <-{} [] a Aa <-{}; rewrite ler_oppl opprK; apply AB. +by move=> _ _ [] b Bb <-{} [] a Aa <-{}; rewrite lerNl opprK; apply AB. Qed. Lemma inf_lt (S : set R) (x : R) : S !=set0 -> (inf S < x -> exists2 y, S y & y < x)%R. Proof. -move=> /nonemptyN S0; rewrite /inf ltr_oppl => /sup_gt => /(_ S0)[r [r' Sr']]. -by move=> <-; rewrite ltr_oppr opprK => r'x; exists r'. +move=> /nonemptyN S0; rewrite /inf ltrNl => /sup_gt => /(_ S0)[r [r' Sr']]. +by move=> <-; rewrite ltrNr opprK => r'x; exists r'. Qed. End InfTheory. @@ -572,7 +447,7 @@ Implicit Types x y : R. Lemma has_sup_floor_set x : has_sup (floor_set x). Proof. split; [exists (- (Num.bound (-x))%:~R) | exists (Num.bound x)%:~R]. - rewrite /floor_set/mkset rpredN rpred_int /= ler_oppl. + rewrite /floor_set/mkset rpredN rpred_int /= lerNl. case: (ger0P (-x)) => [/archi_boundP/ltW//|]. by move/ltW/le_trans; apply; rewrite ler0z. apply/ubP=> y /andP[_] /le_trans; apply. @@ -585,12 +460,12 @@ Proof. have /(sup_adherent ltr01) [y Fy] := has_sup_floor_set x. have /sup_upper_bound /ubP /(_ _ Fy) := has_sup_floor_set x. rewrite le_eqVlt=> /orP[/eqP<-//| lt_yFx]. -rewrite ltr_subl_addr -ltr_subl_addl => lt1_FxBy. +rewrite ltrBlDr -ltrBlDl => lt1_FxBy. pose e := sup (floor_set x) - y; have := has_sup_floor_set x. move/sup_adherent=> -/(_ e) []; first by rewrite subr_gt0. move=> z Fz; rewrite /e opprB addrCA subrr addr0 => lt_yz. have /sup_upper_bound /ubP /(_ _ Fz) := has_sup_floor_set x. -rewrite -(ler_add2r (-y)) => /le_lt_trans /(_ lt1_FxBy). +rewrite -(lerD2r (-y)) => /le_lt_trans /(_ lt1_FxBy). case/andP: Fy Fz lt_yz=> /RintP[yi -> _]. case/andP=> /RintP[zi -> _]; rewrite -rmorphB /= ltrz1 ltr_int. rewrite lt_neqAle => /andP[ne_yz le_yz]. @@ -612,7 +487,7 @@ have [|] := pselect ((floor_set x) (Rfloor x + 1)); last first. rewrite /floor_set => /negP. by rewrite negb_and -ltNge rpredD // ?(Rint1, isint_Rfloor). move/ubP : (sup_upper_bound (has_sup_floor_set x)) => h/h. -by rewrite ger_addl ler10. +by rewrite gerDl ler10. Qed. Lemma Rfloor_le x : Rfloor x <= x. @@ -630,12 +505,12 @@ Proof. move=> /andP[m1x x_m1] /andP[m2x x_m2]. wlog suffices: m1 m2 m1x {x_m1 m2x} x_m2 / (m1 <= m2). by move=> ih; apply/eqP; rewrite eq_le !ih. -rewrite -(ler_add2r 1) lez_addr1 -(@ltr_int R) intrD. +rewrite -(lerD2r 1) lezD1 -(@ltr_int R) intrD. exact/(le_lt_trans m1x). Qed. Lemma range1rr x : (range1 x) x. -Proof. by rewrite /range1/mkset lexx /= ltr_addl ltr01. Qed. +Proof. by rewrite /range1/mkset lexx /= ltrDl ltr01. Qed. Lemma range1zP (m : int) x : Rfloor x = m%:~R <-> (range1 m%:~R) x. Proof. @@ -717,7 +592,7 @@ Proof. by rewrite Rfloor_ge_int RfloorE ler_int. Qed. Lemma ltr_add_invr (y x : R) : y < x -> exists k, y + k.+1%:R^-1 < x. Proof. move=> yx; exists `|floor (x - y)^-1|%N. -rewrite -ltr_subr_addl -{2}(invrK (x - y)%R) ltf_pinv ?qualifE ?ltr0n//. +rewrite -ltrBrDl -{2}(invrK (x - y)%R) ltf_pV2 ?qualifE/= ?ltr0n//. by rewrite invr_gt0 subr_gt0. rewrite -natr1 natr_absz ger0_norm. by rewrite floor_ge0 invr_ge0 subr_ge0 ltW. @@ -738,10 +613,10 @@ Lemma Rceil0 : Rceil 0 = 0 :> R. Proof. by rewrite /Rceil oppr0 Rfloor0 oppr0. Qed. Lemma Rceil_ge x : x <= Rceil x. -Proof. by rewrite /Rceil ler_oppr Rfloor_le. Qed. +Proof. by rewrite /Rceil lerNr Rfloor_le. Qed. Lemma le_Rceil : {homo (@Rceil R) : x y / x <= y}. -Proof. by move=> x y ?; rewrite ler_oppl opprK le_Rfloor // ler_oppl opprK. Qed. +Proof. by move=> x y ?; rewrite lerNl opprK le_Rfloor // lerNl opprK. Qed. Lemma Rceil_ge0 x : 0 <= x -> 0 <= Rceil x. Proof. by move=> ?; rewrite -Rceil0 le_Rceil. Qed. @@ -756,16 +631,16 @@ Lemma ceil_ge0 x : 0 <= x -> 0 <= ceil x. Proof. by move/(ge_trans (ceil_ge x)); rewrite -(ler_int R). Qed. Lemma ceil_gt0 x : 0 < x -> 0 < ceil x. -Proof. by move=> ?; rewrite /ceil oppr_gt0 floor_lt0 // ltr_oppl oppr0. Qed. +Proof. by move=> ?; rewrite /ceil oppr_gt0 floor_lt0 // ltrNl oppr0. Qed. Lemma ceil_le0 x : x <= 0 -> ceil x <= 0. -Proof. by move=> x0; rewrite -ler_oppl oppr0 floor_ge0 -ler_oppr oppr0. Qed. +Proof. by move=> x0; rewrite -lerNl oppr0 floor_ge0 -lerNr oppr0. Qed. Lemma le_ceil : {homo @ceil R : x y / x <= y}. -Proof. by move=> x y xy; rewrite ler_oppl opprK le_floor // ler_oppl opprK. Qed. +Proof. by move=> x y xy; rewrite lerNl opprK le_floor // lerNl opprK. Qed. Lemma ceil_ge_int x (z : int) : (x <= z%:~R) = (ceil x <= z). -Proof. by rewrite /ceil ler_oppl -floor_ge_int// -ler_oppr mulrNz opprK. Qed. +Proof. by rewrite /ceil lerNl -floor_ge_int// -lerNr mulrNz opprK. Qed. Lemma ceil_lt_int x (z : int) : (z%:~R < x) = (z < ceil x). Proof. by rewrite ltNge ceil_ge_int -ltNge. Qed. @@ -819,7 +694,7 @@ Qed. Lemma le_inf A B : -%R @` B `<=` down (-%R @` A) -> nonempty B -> has_inf A -> inf A <= inf B. Proof. -move=> SBA AB Ai; rewrite ler_oppl opprK le_sup// ?has_inf_supN//. +move=> SBA AB Ai; rewrite lerNl opprK le_sup// ?has_inf_supN//. exact/nonemptyN. Qed. @@ -867,7 +742,7 @@ have i0i1n : i0 - (i + 1) = n by rewrite opprD addrA i0in1 -addn1 PoszD addrK. have [?|/not_forallP] := pselect (lbound B (i + 1)); first exact: (ih (i + 1)). move=> /contrapT[x /not_implyP[Bx i1x]]; exists x; split => // k Bk. rewrite (le_trans _ (lbBi _ Bk)) //. -by move/negP : i1x; rewrite -ltNge ltz_addr1. +by move/negP : i1x; rewrite -ltNge ltzD1. Qed. Section rat_in_itvoo. @@ -879,7 +754,7 @@ Let archi_bound_divP (R : archiFieldType) (x y : R) : 0 < x -> y < x *+ bound_div x y. Proof. move=> x0; have [y0|y0] := leP 0 y; last by rewrite /bound_div y0 mulr0n. -rewrite /bound_div (ltNge y 0) y0/= -mulr_natl -ltr_pdivr_mulr//. +rewrite /bound_div (ltNge y 0) y0/= -mulr_natl -ltr_pdivrMr//. by rewrite archi_boundP// (divr_ge0 _(ltW _)). Qed. @@ -902,31 +777,31 @@ have [m2 m2nx] : exists m2, m2.+1%:~R > - x *+ n. by rewrite mulrn_wge0 // oppr_ge0. have : exists m, -(m2.+1 : int) <= m <= m1.+1 /\ m%:~R - 1 <= x *+ n < m%:~R. have m2m1 : - (m2.+1 : int) < m1.+1. - by rewrite -(ltr_int R) (lt_trans _ m1nx)// rmorphN /= ltr_oppl // -mulNrn. + by rewrite -(ltr_int R) (lt_trans _ m1nx)// rmorphN /= ltrNl // -mulNrn. pose B := [set m : int | m%:~R > x *+ n]. have m1B : B m1.+1 by []. have m2B : lbound B (- m2.+1%:~R). - move=> i; rewrite /B /= -(opprK (x *+ n)) -ltr_oppl -mulNrn => nxi. - rewrite -(mulN1r m2.+1%:~R) mulN1r -ler_oppl. + move=> i; rewrite /B /= -(opprK (x *+ n)) -ltrNl -mulNrn => nxi. + rewrite -(mulN1r m2.+1%:~R) mulN1r -lerNl. by have := lt_trans nxi m2nx; rewrite intz -mulrNz ltr_int => /ltW. have [m [Bm infB]] := int_lbound_has_minimum (ex_intro _ _ m1B) m2B. have mN1B : ~ B (m - 1). - by move=> /infB; apply/negP; rewrite -ltNge ltr_subl_addr ltz_addr1. + by move=> /infB; apply/negP; rewrite -ltNge ltrBlDr ltzD1. exists m; split; [apply/andP; split|apply/andP; split] => //. - by move: m2B; rewrite /lbound /= => /(_ _ Bm); rewrite intz. - exact: infB. - by rewrite leNgt; apply/negP; rewrite /B /= intrD in mN1B. move=> [m [/andP[m2m mm1] /andP[mnx nxm]]]. have [/andP[a b] c] : x *+ n < m%:~R <= 1 + x *+ n /\ 1 + x *+ n < y *+ n. - split; [apply/andP; split|] => //; first by rewrite -ler_subl_addl. - by move: nyx; rewrite mulrnDl -ltr_subr_addr mulNrn. + split; [apply/andP; split|] => //; first by rewrite -lerBlDl. + by move: nyx; rewrite mulrnDl -ltrBrDr mulNrn. have n_gt0 : n != 0%N by apply: contraTN nyx => /eqP ->; rewrite mulr0n ltr10. exists (m%:Q / n%:Q); rewrite in_itv /=; apply/andP; split. - rewrite rmorphM (@rmorphV _ _ _ n%:~R); first by rewrite unitfE // intr_eq0. - rewrite ltr_pdivl_mulr /=; first by rewrite ltr0q ltr0z ltz_nat lt0n. + rewrite rmorphM/= (@rmorphV _ _ _ n%:~R); first by rewrite unitfE // intr_eq0. + rewrite ltr_pdivlMr /=; first by rewrite ltr0q ltr0z ltz_nat lt0n. by rewrite mulrC // !ratr_int mulr_natl. rewrite rmorphM /= (@rmorphV _ _ _ n%:~R); first by rewrite unitfE // intr_eq0. -rewrite ltr_pdivr_mulr /=; first by rewrite ltr0q ltr0z ltz_nat lt0n. +rewrite ltr_pdivrMr /=; first by rewrite ltr0q ltr0z ltz_nat lt0n. by rewrite 2!ratr_int mulr_natr (le_lt_trans _ c). Qed. diff --git a/theories/sequences.v b/theories/sequences.v index c200d896b..c79353dc7 100644 --- a/theories/sequences.v +++ b/theories/sequences.v @@ -149,19 +149,19 @@ Notation "'decreasing_seq' f" := ({mono f : n m / (n <= m)%nat >-> (n >= m)%O}) Lemma nondecreasing_opp (T : numDomainType) (u_ : T ^nat) : nondecreasing_seq (- u_) = nonincreasing_seq u_. -Proof. by rewrite propeqE; split => du x y /du; rewrite ler_opp2. Qed. +Proof. by rewrite propeqE; split => du x y /du; rewrite lerN2. Qed. Lemma nonincreasing_opp (T : numDomainType) (u_ : T ^nat) : nonincreasing_seq (- u_) = nondecreasing_seq u_. -Proof. by rewrite propeqE; split => du x y /du; rewrite ler_opp2. Qed. +Proof. by rewrite propeqE; split => du x y /du; rewrite lerN2. Qed. Lemma decreasing_opp (T : numDomainType) (u_ : T ^nat) : decreasing_seq (- u_) = increasing_seq u_. -Proof. by rewrite propeqE; split => du x y; rewrite -du ler_opp2. Qed. +Proof. by rewrite propeqE; split => du x y; rewrite -du lerN2. Qed. Lemma increasing_opp (T : numDomainType) (u_ : T ^nat) : increasing_seq (- u_) = decreasing_seq u_. -Proof. by rewrite propeqE; split => du x y; rewrite -du ler_opp2. Qed. +Proof. by rewrite propeqE; split => du x y; rewrite -du lerN2. Qed. Lemma nondecreasing_seqP (d : unit) (T : porderType d) (u_ : T ^nat) : (forall n, u_ n <= u_ n.+1)%O <-> nondecreasing_seq u_. @@ -203,7 +203,7 @@ Lemma nondecreasing_seqD T (d : unit) (R : numDomainType) (f g : (T -> R)^nat) : (forall x, nondecreasing_seq (f ^~ x)) -> (forall x, nondecreasing_seq (g ^~ x)) -> (forall x, nondecreasing_seq ((f \+ g) ^~ x)). -Proof. by move=> ndf ndg t m n mn; apply: ler_add; [exact/ndf|exact/ndg]. Qed. +Proof. by move=> ndf ndg t m n mn; apply: lerD; [exact/ndf|exact/ndg]. Qed. Local Notation eqolimn := (@eqolim _ _ _ eventually_filter). Local Notation eqolimPn := (@eqolimP _ _ _ eventually_filter). @@ -352,22 +352,23 @@ by near do [move=> /=; case: ifP => //; rewrite ltn_geF//]. Unshelve. all: by end_near. Qed. Lemma is_cvg_restrict f u_ : - cvg ([sequence if (n <= N)%nat then f n else u_ n]_n @ \oo) = - cvg (u_ @ \oo). + cvgn [sequence if (n <= N)%nat then f n else u_ n]_n = cvgn u_. Proof. by rewrite propeqE; split; [rewrite cvg_restrict|rewrite -(cvg_restrict f)] => /cvgP. Qed. -Lemma cvg_centern u_ l : ([sequence u_ (n - N)%N]_n --> l) = (u_ --> l). +Lemma cvg_centern u_ l : + ([sequence u_ (n - N)%N]_n @ \oo --> l) = (u_ @ \oo --> l). Proof. rewrite propeqE; split; last by apply: cvg_comp; apply: cvg_subnr. -gen have cD : u_ l / u_ --> l -> (fun n => u_ (n + N)%N) --> l. +gen have cD : u_ l / u_ @ \oo --> l -> (fun n => u_ (n + N)%N) @ \oo --> l. by apply: cvg_comp; apply: cvg_addnr. -by move=> /cD /=; under [X in X --> l]funext => n do rewrite addnK. +by move=> /cD /=; under [X in X @ _ --> l]funext => n do rewrite addnK. Qed. -Lemma cvg_shiftn u_ l : ([sequence u_ (n + N)%N]_n --> l) = (u_ --> l). +Lemma cvg_shiftn u_ l : + ([sequence u_ (n + N)%N]_n @ \oo --> l) = (u_ @ \oo --> l). Proof. rewrite propeqE; split; last by apply: cvg_comp; apply: cvg_addnr. rewrite -[X in X -> _]cvg_centern; apply: cvg_trans => /=. @@ -378,7 +379,8 @@ End NatShift. Variables (V : topologicalType). -Lemma cvg_shiftS u_ (l : V) : ([sequence u_ n.+1]_n --> l) = (u_ --> l). +Lemma cvg_shiftS u_ (l : V) : + ([sequence u_ n.+1]_n @ \oo --> l) = (u_ @ \oo --> l). Proof. suff -> : [sequence u_ n.+1]_n = [sequence u_(n + 1)%N]_n by rewrite cvg_shiftn. by rewrite funeqE => n/=; rewrite addn1. @@ -399,144 +401,146 @@ Proof. exact: squeeze_cvgr. Qed. Notation squeeze := __deprecated__squeeze (only parsing). Lemma __deprecated__cvgPpinfty (u_ : R ^nat) : - u_ --> +oo <-> forall A, \forall n \near \oo, A <= u_ n. + u_ @ \oo --> +oo <-> forall A, \forall n \near \oo, A <= u_ n. Proof. exact: cvgryPge. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgryPge`, and generalized to any filter")] Notation cvgPpinfty := __deprecated__cvgPpinfty (only parsing). -Lemma __deprecated__cvgNpinfty u_ : (- u_ --> +oo) = (u_ --> -oo). +Lemma __deprecated__cvgNpinfty u_ : (- u_ @ \oo --> +oo) = (u_ @ \oo --> -oo). Proof. exact/propeqP/cvgNry. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="use `cvgNry` instead")] Notation cvgNpinfty := __deprecated__cvgNpinfty (only parsing). -Lemma __deprecated__cvgNninfty u_ : (- u_ --> -oo) = (u_ --> +oo). +Lemma __deprecated__cvgNninfty u_ : (- u_ @ \oo --> -oo) = (u_ @ \oo --> +oo). Proof. exact/propeqP/cvgNrNy. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="use `cvgNrNy` instead")] Notation cvgNninfty := __deprecated__cvgNninfty (only parsing). Lemma __deprecated__cvgPninfty (u_ : R ^nat) : - u_ --> -oo <-> forall A, \forall n \near \oo, A >= u_ n. + u_ @ \oo --> -oo <-> forall A, \forall n \near \oo, A >= u_ n. Proof. exact: cvgrNyPle. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgrNyPle`, and generalized to any filter")] Notation cvgPninfty := __deprecated__cvgPninfty (only parsing). Lemma __deprecated__ger_cvg_pinfty u_ v_ : (\forall n \near \oo, u_ n <= v_ n) -> - u_ --> +oo -> v_ --> +oo. + u_ @ \oo --> +oo -> v_ @ \oo --> +oo. Proof. exact: ger_cvgy. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `ger_cvgy`, and generalized to any filter")] Notation ger_cvg_pinfty := __deprecated__ger_cvg_pinfty (only parsing). Lemma __deprecated__ler_cvg_ninfty v_ u_ : (\forall n \near \oo, u_ n <= v_ n) -> - v_ --> -oo -> u_ --> -oo. + v_ @ \oo --> -oo -> u_ @ \oo --> -oo. Proof. exact: ler_cvgNy. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `ler_cvgNy`, and generalized to any filter")] Notation ler_cvg_ninfty := __deprecated__ler_cvg_ninfty (only parsing). -Lemma __deprecated__lim_ge x u : cvg u -> (\forall n \near \oo, x <= u n) -> x <= lim u. +Lemma __deprecated__lim_ge x u : cvg (u @ \oo) -> + (\forall n \near \oo, x <= u n) -> x <= lim (u @ \oo). Proof. exact: limr_ge. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `limr_ge`, and generalized to any proper filter")] Notation lim_ge := __deprecated__lim_ge (only parsing). -Lemma __deprecated__lim_le x u : cvg u -> (\forall n \near \oo, x >= u n) -> x >= lim u. +Lemma __deprecated__lim_le x u : cvg (u @ \oo) -> + (\forall n \near \oo, x >= u n) -> x >= lim (u @ \oo). Proof. exact: limr_le. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `limr_le`, and generalized to any proper filter")] Notation lim_le := __deprecated__lim_le (only parsing). -Lemma lt_lim u (M : R) : nondecreasing_seq u -> cvg u -> M < lim u -> - \forall n \near \oo, M <= u n. +Lemma lt_lim u (M : R) : nondecreasing_seq u -> + cvgn u -> M < limn u -> \forall n \near \oo, M <= u n. Proof. move=> ndu cu Ml; have [[n Mun]|/forallNP Mu] := pselect (exists n, M <= u n). near=> m; suff : u n <= u m by exact: le_trans. by near: m; exists n.+1 => // p q; apply/ndu/ltnW. have {}Mu : forall x, M > u x by move=> x; rewrite ltNge; apply/negP. -have : lim u <= M by apply: limr_le => //; near=> m; apply/ltW/Mu. +have : limn u <= M by apply: limr_le => //; near=> m; apply/ltW/Mu. by move/(lt_le_trans Ml); rewrite ltxx. Unshelve. all: by end_near. Qed. -Lemma nonincreasing_cvgn_ge u_ : nonincreasing_seq u_ -> cvg u_ -> - forall n, lim u_ <= u_ n. +Lemma nonincreasing_cvgn_ge u_ : nonincreasing_seq u_ -> cvgn u_ -> + forall n, limn u_ <= u_ n. Proof. move=> du ul p; rewrite leNgt; apply/negP => up0. -move/cvgrPdist_lt : ul => /(_ `|u_ p - lim u_|%R). +move/cvgrPdist_lt : ul => /(_ `|u_ p - limn u_|%R). rewrite {1}ltr0_norm ?subr_lt0 // opprB subr_gt0 => /(_ up0) ul. near \oo => N. have /du uNp : (p <= N)%nat by near: N; rewrite nearE; exists p. -have : `|lim u_ - u_ N| >= `|u_ p - lim u_|%R. +have : `|limn u_ - u_ N| >= `|u_ p - limn u_|%R. rewrite ltr0_norm // ?subr_lt0 // opprB distrC. - rewrite (@le_trans _ _ (lim u_ - u_ N)) // ?ler_sub //. - rewrite (_ : `| _ | = `|u_ N - lim u_|%R) // ler0_norm // ?opprB //. + rewrite (@le_trans _ _ (limn u_ - u_ N)) // ?lerB //. + rewrite (_ : `| _ | = `|u_ N - limn u_|%R) // ler0_norm // ?opprB //. by rewrite subr_le0 (le_trans _ (ltW up0)). rewrite leNgt => /negP; apply; by near: N. Unshelve. all: by end_near. Qed. -Lemma nondecreasing_cvgn_le u_ : nondecreasing_seq u_ -> cvg u_ -> - forall n, u_ n <= lim u_. +Lemma nondecreasing_cvgn_le u_ : nondecreasing_seq u_ -> cvgn u_ -> + forall n, u_ n <= limn u_. Proof. move=> iu cu n; move: (@nonincreasing_cvgn_ge (- u_)). rewrite -nondecreasing_opp opprK => /(_ iu); rewrite is_cvgNE => /(_ cu n). -by rewrite limN // ler_oppl opprK. +by rewrite limN // lerNl opprK. Qed. -Lemma cvg_has_ub u_ : cvg u_ -> has_ubound [set `|u_ n| | n in setT]. +Lemma cvg_has_ub u_ : cvgn u_ -> has_ubound [set `|u_ n| | n in setT]. Proof. move=> /cvg_seq_bounded/pinfty_ex_gt0[M M_gt0 /= uM]. by exists M; apply/ubP => x -[n _ <-{x}]; exact: uM. Qed. -Lemma cvg_has_sup u_ : cvg u_ -> has_sup (u_ @` setT). +Lemma cvg_has_sup u_ : cvgn u_ -> has_sup (u_ @` setT). Proof. move/cvg_has_ub; rewrite -/(_ @` _) -(image_comp u_ normr setT). by move=> /has_ub_image_norm uM; split => //; exists (u_ 0%N), 0%N. Qed. -Lemma cvg_has_inf u_ : cvg u_ -> has_inf (u_ @` setT). +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. Lemma __deprecated__cvgPpinfty_lt (u_ : R ^nat) : - u_ --> +oo%R <-> forall A, \forall n \near \oo, (A < u_ n)%R. + u_ @ \oo --> +oo%R <-> forall A, \forall n \near \oo, (A < u_ n)%R. Proof. exact: cvgryPgt. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgryPgt`, and generalized to any proper filter")] Notation cvgPpinfty_lt := __deprecated__cvgPpinfty_lt (only parsing). Lemma __deprecated__cvgPninfty_lt (u_ : R ^nat) : - u_ --> -oo%R <-> forall A, \forall n \near \oo, (A > u_ n)%R. + u_ @ \oo --> -oo%R <-> forall A, \forall n \near \oo, (A > u_ n)%R. Proof. exact: cvgrNyPlt. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgrNyPlt`, and generalized to any proper filter")] Notation cvgPninfty_lt := __deprecated__cvgPninfty_lt (only parsing). Lemma __deprecated__cvgPpinfty_near (u_ : R ^nat) : - u_ --> +oo%R <-> \forall A \near +oo, \forall n \near \oo, (A <= u_ n)%R. + u_ @ \oo --> +oo%R <-> \forall A \near +oo, \forall n \near \oo, (A <= u_ n)%R. Proof. exact: cvgryPgey. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgryPgey`, and generalized to any proper filter")] Notation cvgPpinfty_near := __deprecated__cvgPpinfty_near (only parsing). Lemma __deprecated__cvgPninfty_near (u_ : R ^nat) : - u_ --> -oo%R <-> \forall A \near -oo, \forall n \near \oo, (A >= u_ n)%R. + u_ @ \oo --> -oo%R <-> \forall A \near -oo, \forall n \near \oo, (A >= u_ n)%R. Proof. exact: cvgrNyPleNy. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgrNyPleNy`, and generalized to any proper filter")] Notation cvgPninfty_near := __deprecated__cvgPninfty_near (only parsing). Lemma __deprecated__cvgPpinfty_lt_near (u_ : R ^nat) : - u_ --> +oo%R <-> \forall A \near +oo, \forall n \near \oo, (A < u_ n)%R. + u_ @ \oo --> +oo%R <-> \forall A \near +oo, \forall n \near \oo, (A < u_ n)%R. Proof. exact: cvgryPgty. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgryPgty`, and generalized to any proper filter")] Notation cvgPpinfty_lt_near := __deprecated__cvgPpinfty_lt_near (only parsing). Lemma __deprecated__cvgPninfty_lt_near (u_ : R ^nat) : - u_ --> -oo%R <-> \forall A \near -oo, \forall n \near \oo, (A > u_ n)%R. + u_ @ \oo --> -oo%R <-> \forall A \near -oo, \forall n \near \oo, (A > u_ n)%R. Proof. exact: cvgrNyPltNy. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgrNyPltNy`, and generalized to any proper filter")] @@ -551,14 +555,14 @@ Notation nonincreasing_cvg_ge := nonincreasing_cvgn_ge (only parsing). Notation nondecreasing_cvg_le := nondecreasing_cvgn_le (only parsing). Lemma __deprecated__invr_cvg0 (R : realFieldType) (u : R^nat) : - (forall i, 0 < u i) -> ((u i)^-1 @[i --> \oo] --> 0) <-> (u --> +oo). + (forall i, 0 < u i) -> ((u i)^-1 @[i --> \oo] --> 0) <-> (u @ \oo --> +oo). Proof. by move=> ?; rewrite gtr0_cvgV0//; apply: nearW. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `gtr0_cvgV0` and generalized")] Notation invr_cvg0 := __deprecated__invr_cvg0 (only parsing). Lemma __deprecated__invr_cvg_pinfty (R : realFieldType) (u : R^nat) : - (forall i, 0 < u i) -> ((u i)^-1 @[i --> \oo] --> +oo) <-> (u --> 0). + (forall i, 0 < u i) -> ((u i)^-1 @[i --> \oo] --> +oo) <-> (u @ \oo--> 0). Proof. by move=> ?; rewrite cvgrVy//; apply: nearW. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgrVy` and generalized")] @@ -620,40 +624,41 @@ Section partial_sum_numFieldType. Variables V : numFieldType. Implicit Types f g : V ^nat. -Lemma is_cvg_seriesN f : cvg (series (- f)) = cvg (series f). +Lemma is_cvg_seriesN f : cvgn (series (- f)) = cvgn (series f). Proof. by rewrite seriesN is_cvgNE. Qed. -Lemma lim_seriesN f : cvg (series f) -> lim (series (- f)) = - lim (series f). +Lemma lim_seriesN f : cvg (series f @ \oo) -> + limn (series (- f)) = - limn (series f). Proof. by move=> cf; rewrite seriesN limN. Qed. -Lemma is_cvg_seriesZ f k : cvg (series f) -> cvg (series (k *: f)). +Lemma is_cvg_seriesZ f k : cvgn (series f) -> cvgn (series (k *: f)). Proof. by move=> cf; rewrite seriesZ; exact: is_cvgZr. Qed. -Lemma lim_seriesZ f k : cvg (series f) -> - lim (series (k *: f)) = k *: lim (series f). +Lemma lim_seriesZ f k : cvgn (series f) -> + limn (series (k *: f)) = k *: limn (series f). Proof. by move=> cf; rewrite seriesZ limZr. Qed. Lemma is_cvg_seriesD f g : - cvg (series f) -> cvg (series g) -> cvg (series (f + g)). + cvgn (series f) -> cvgn (series g) -> cvgn (series (f + g)). Proof. by move=> cf cg; rewrite seriesD; exact: is_cvgD. Qed. -Lemma lim_seriesD f g : cvg (series f) -> cvg (series g) -> - lim (series (f + g)) = lim (series f) + lim (series g). +Lemma lim_seriesD f g : cvgn (series f) -> cvgn (series g) -> + limn (series (f + g)) = limn (series f) + limn (series g). Proof. by move=> cf cg; rewrite seriesD limD. Qed. Lemma is_cvg_seriesB f g : - cvg (series f) -> cvg (series g) -> cvg (series (f - g)). + cvgn (series f) -> cvgn (series g) -> cvgn (series (f - g)). Proof. by move=> cf cg; apply: is_cvg_seriesD; rewrite ?is_cvg_seriesN. Qed. -Lemma lim_seriesB f g : cvg (series f) -> cvg (series g) -> - lim (series (f - g)) = lim (series f) - lim (series g). +Lemma lim_seriesB f g : cvg (series f @ \oo) -> cvg (series g @ \oo) -> + limn (series (f - g)) = limn (series f) - limn (series g). Proof. by move=> Cf Cg; rewrite lim_seriesD ?is_cvg_seriesN// lim_seriesN. Qed. End partial_sum_numFieldType. Lemma lim_series_le (V : realFieldType) (f g : V ^nat) : - cvg (series f) -> cvg (series g) -> (forall n, f n <= g n) -> - lim (series f) <= lim (series g). + cvgn (series f) -> cvgn (series g) -> (forall n, f n <= g n) -> + limn (series f) <= limn (series g). Proof. by move=> cf cg fg; apply: (ler_lim cf cg); near=> x; rewrite ler_sum. Unshelve. all: by end_near. Qed. @@ -674,7 +679,7 @@ Variables (N : nat) (K : numFieldType) (V : normedModType K). Implicit Types (f : nat -> V) (u : V ^nat) (l : V). Lemma is_cvg_series_restrict u_ : - cvg [sequence \sum_(N <= k < n) u_ k]_n = cvg (series u_). + cvgn [sequence \sum_(N <= k < n) u_ k]_n = cvgn (series u_). Proof. suff -> : (fun n => \sum_(N <= k < n) u_ k) = fun n => if (n <= N)%N then \sum_(N <= k < n) u_ k @@ -691,7 +696,7 @@ Variable R : realType. Lemma nondecreasing_cvgn (u_ : R ^nat) : nondecreasing_seq u_ -> has_ubound (range u_) -> - u_ --> sup (range u_). + u_ @ \oo --> sup (range u_). Proof. move=> leu u_ub; set M := sup (range u_). have su_ : has_sup (range u_) by split => //; exists (u_ 0%N), 0%N. @@ -700,16 +705,16 @@ have [p Mu_p] : exists p, M - e%:num <= u_ p. have [_ -[p _] <- /ltW Mu_p] := sup_adherent (gt0 e) su_. by exists p; rewrite Mu_p. near=> n; have pn : (p <= n)%N by near: n; exact: nbhs_infty_ge. -rewrite ler_distlC (le_trans Mu_p (leu _ _ _))//= (@le_trans _ _ M) ?ler_addl//. +rewrite ler_distlC (le_trans Mu_p (leu _ _ _))//= (@le_trans _ _ M) ?lerDl//. by have /ubP := sup_upper_bound su_; apply; exists n. Unshelve. all: by end_near. Qed. Lemma nondecreasing_is_cvgn (u_ : R ^nat) : - nondecreasing_seq u_ -> has_ubound (range u_) -> cvg u_. + nondecreasing_seq u_ -> has_ubound (range u_) -> cvgn u_. Proof. by move=> u_nd u_ub; apply: cvgP; exact: nondecreasing_cvgn. Qed. Lemma nondecreasing_dvgn_lt (u_ : R ^nat) : - nondecreasing_seq u_ -> ~ cvg u_ -> u_ --> +oo. + nondecreasing_seq u_ -> ~ cvgn u_ -> u_ @ \oo --> +oo. Proof. move=> nu du; apply: contrapT => /cvgryPge/existsNP[l lu]; apply: du. apply: nondecreasing_is_cvgn => //; exists l => _ [n _ <-]. @@ -719,9 +724,10 @@ Unshelve. all: by end_near. Qed. Lemma near_nondecreasing_is_cvgn (u_ : R ^nat) (M : R) : {near \oo, nondecreasing_seq u_} -> (\forall n \near \oo, u_ n <= M) -> - cvg u_. + cvgn u_. Proof. -move=> [k _ u_nd] [k' _ u_M]; suff : cvg [sequence u_ (n + maxn k k')%N]_n. +move=> [k _ u_nd] [k' _ u_M]. +suff : cvgn [sequence u_ (n + maxn k k')%N]_n. by case/cvg_ex => /= l; rewrite cvg_shiftn => ul; apply/cvg_ex; exists l. apply: nondecreasing_is_cvgn; [move=> /= m n mn|exists M => _ [n _ <-]]. by rewrite u_nd ?leq_add2r//= (leq_trans (leq_maxl _ _) (leq_addl _ _)). @@ -730,38 +736,39 @@ Qed. Lemma nonincreasing_cvgn (u_ : R ^nat) : nonincreasing_seq u_ -> has_lbound (range u_) -> - u_ --> inf (u_ @` setT). + u_ @ \oo --> inf (u_ @` setT). Proof. -rewrite -nondecreasing_opp => u_nd u_lb; rewrite -[X in X --> _](opprK u_). +rewrite -nondecreasing_opp => u_nd u_lb; rewrite -[X in X @ _ --> _](opprK u_). apply: cvgN; rewrite image_comp; apply: nondecreasing_cvgn => //. by move/has_lb_ubN : u_lb; rewrite image_comp. Qed. Lemma nonincreasing_is_cvgn (u_ : R ^nat) : - nonincreasing_seq u_ -> has_lbound (range u_) -> cvg u_. + nonincreasing_seq u_ -> has_lbound (range u_) -> cvgn u_. Proof. by move=> u_decr u_bnd; apply: cvgP; exact: nonincreasing_cvgn. Qed. Lemma near_nonincreasing_is_cvgn (u_ : R ^nat) (m : R) : {near \oo, nonincreasing_seq u_} -> (\forall n \near \oo, m <= u_ n) -> - cvg u_. + cvgn u_. Proof. move=> u_ni u_m. rewrite -(opprK u_); apply: is_cvgN; apply/(@near_nondecreasing_is_cvgn _ (- m)). -- by apply: filterS u_ni => x u_x y xy; rewrite ler_oppl opprK u_x. -- by apply: filterS u_m => x u_x; rewrite ler_oppl opprK. +- by apply: filterS u_ni => x u_x y xy; rewrite lerNl opprK u_x. +- by apply: filterS u_m => x u_x; rewrite lerNl opprK. Qed. Lemma adjacent (u_ v_ : R ^nat) : nondecreasing_seq u_ -> nonincreasing_seq v_ -> - (v_ - u_) --> (0 : R) -> [/\ lim v_ = lim u_, cvg u_ & cvg v_]. + v_ - u_ @ \oo --> (0 : R) -> + [/\ limn v_ = limn u_, cvgn u_ & cvgn v_]. Proof. set w_ := v_ - u_ => iu dv w0; have vu n : v_ n >= u_ n. - suff : lim w_ <= w_ n by rewrite (cvg_lim _ w0)// subr_ge0. + suff : limn w_ <= w_ n by rewrite (cvg_lim _ w0)// subr_ge0. apply: (nonincreasing_cvgn_ge _ (cvgP _ w0)) => m p mp. - by rewrite ler_sub; rewrite ?iu ?dv. -have cu : cvg u_. + by rewrite lerB; rewrite ?iu ?dv. +have cu : cvgn u_. apply: nondecreasing_is_cvgn => //; exists (v_ 0%N) => _ [n _ <-]. by rewrite (le_trans (vu _)) // dv. -have cv : cvg v_. +have cv : cvgn v_. apply: nonincreasing_is_cvgn => //; exists (u_ 0%N) => _ [n _ <-]. by rewrite (le_trans _ (vu _)) // iu. by split=> //; apply/eqP; rewrite -subr_eq0 -limB //; exact/eqP/cvg_lim. @@ -799,10 +806,10 @@ Proof. by rewrite /=. Qed. Lemma harmonic_ge0 {R : numFieldType} i : 0 <= harmonic i :> R. Proof. exact/ltW/harmonic_gt0. Qed. -Lemma cvg_harmonic {R : archiFieldType} : harmonic --> (0 : R). +Lemma cvg_harmonic {R : archiFieldType} : @harmonic R @ \oo --> 0. Proof. apply/cvgrPdist_le => _/posnumP[e]; near=> i. -rewrite distrC subr0 ger0_norm//= -lef_pinv ?qualifE// invrK. +rewrite distrC subr0 ger0_norm//= -lef_pV2 ?qualifE//= invrK. rewrite (le_trans (ltW (archi_boundP _)))// ler_nat -add1n -leq_subLR. by near: i; apply: nbhs_infty_ge. Unshelve. all: by end_near. Qed. @@ -810,14 +817,14 @@ Unshelve. all: by end_near. Qed. Lemma cvge_harmonic {R : archiFieldType} : (EFin \o @harmonic R) @ \oo --> 0%E. Proof. by apply: cvg_EFin; [exact: nearW | exact: cvg_harmonic]. Qed. -Lemma dvg_harmonic (R : numFieldType) : ~ cvg (series (@harmonic R)). +Lemma dvg_harmonic (R : numFieldType) : ~ cvgn (series (@harmonic R)). Proof. have ge_half n : (0 < n)%N -> 2^-1 <= \sum_(n <= i < n.*2) harmonic i. case: n => // n _. rewrite (@le_trans _ _ (\sum_(n.+1 <= i < n.+1.*2) n.+1.*2%:R^-1)) //=. rewrite sumr_const_nat -addnn addnK addnn -mul2n natrM invfM. by rewrite -[_ *+ n.+1]mulr_natr divfK. - by apply: ler_sum_nat => i /andP[? ?]; rewrite lef_pinv ?qualifE ?ler_nat. + by apply: ler_sum_nat => i /andP[? ?]; rewrite lef_pV2 ?qualifE/= ?ler_nat. move/cvg_cauchy/cauchy_ballP => /(_ _ [gt0 of 2^-1 : R]); rewrite !near_map2. rewrite -ball_normE => /nearP_dep hcvg; near \oo => n; near \oo => m. have: `|series harmonic n - series harmonic m| < 2^-1 :> R by near: m; near: n. @@ -826,7 +833,7 @@ rewrite sub_series_geq; last by near: m; apply: nbhs_infty_ge. rewrite -addrA sub_series_geq -addnn ?leq_addr// addnn. have sh_ge0 i j : 0 <= \sum_(i <= k < j) harmonic k :> R. by rewrite ?sumr_ge0//; move=> k _; apply: harmonic_ge0. -by rewrite ger0_norm// ler_paddl// ge_half//; near: n. +by rewrite ger0_norm// ler_wpDl// ge_half//; near: n. Unshelve. all: by end_near. Qed. Definition arithmetic_mean (R : numDomainType) (u_ : R ^nat) : R ^nat := @@ -843,27 +850,28 @@ Definition root_mean_square (R : realType) (u_ : R ^nat) : R ^nat := Section cesaro. Variable R : archiFieldType. -Theorem cesaro (u_ : R ^nat) (l : R) : u_ --> l -> arithmetic_mean u_ --> l. +Theorem cesaro (u_ : R ^nat) (l : R) : u_ @ \oo --> l -> + arithmetic_mean u_ @ \oo --> l. Proof. move=> u0_cvg; have ssplit v_ m n : (m <= n)%N -> `|n%:R^-1 * series v_ n| <= n%:R^-1 * `|series v_ m| + n%:R^-1 * `|\sum_(m <= i < n) v_ i|. - move=> /subnK<-; rewrite series_addn mulrDr (le_trans (ler_norm_add _ _))//. + move=> /subnK<-; rewrite series_addn mulrDr (le_trans (ler_normD _ _))//. by rewrite !normrM ger0_norm. apply/cvgrPdist_lt=> _/posnumP[e]; near \oo => m; near=> n. have {}/ssplit -/(_ _ [sequence l - u_ n]_n) : (m.+1 <= n.+1)%nat. by near: n; exists m. rewrite !seriesEnat /= big_split/=. rewrite sumrN mulrBr sumr_const_nat -(mulr_natl l) mulKf//. -move=> /le_lt_trans->//; rewrite [e%:num]splitr ltr_add//. +move=> /le_lt_trans->//; rewrite [e%:num]splitr ltrD//. have [->|neq0] := eqVneq (\sum_(0 <= k < m.+1) (l - u_ k)) 0. by rewrite normr0 mulr0. - rewrite -ltr_pdivl_mulr ?normr_gt0//. - rewrite -ltf_pinv ?qualifE// ?mulr_gt0 ?invr_gt0 ?normr_gt0// invrK. + rewrite -ltr_pdivlMr ?normr_gt0//. + rewrite -ltf_pV2 ?qualifE//= ?mulr_gt0 ?invr_gt0 ?normr_gt0// invrK. rewrite (lt_le_trans (archi_boundP _))// ler_nat leqW//. by near: n; apply: nbhs_infty_ge. -rewrite ltr_pdivr_mull ?ltr0n // (le_lt_trans (ler_norm_sum _ _ _)) //. +rewrite ltr_pdivrMl ?ltr0n // (le_lt_trans (ler_norm_sum _ _ _)) //. rewrite (le_lt_trans (@ler_sum_nat _ _ _ _ (fun i => e%:num / 2) _))//; last first. - by rewrite sumr_const_nat mulr_natl ltr_pmuln2l// ltn_subrL. + by rewrite sumr_const_nat mulr_natl ltr_pMn2l// ltn_subrL. move=> i /andP[mi _]; move: i mi; near: m. have : \forall x \near \oo, `|l - u_ x| < e%:num / 2. by move/cvgrPdist_lt : u0_cvg; apply. @@ -877,8 +885,8 @@ Section cesaro_converse. Variable R : archiFieldType. Let cesaro_converse_off_by_one (u_ : R ^nat) : - [sequence n.+1%:R^-1 * series u_ n.+1]_ n --> (0 : R) -> - [sequence n.+1%:R^-1 * series u_ n]_ n --> (0 : R). + [sequence n.+1%:R^-1 * series u_ n.+1]_n @ \oo --> (0 : R) -> + [sequence n.+1%:R^-1 * series u_ n]_n @ \oo --> (0 : R). Proof. move=> H; apply/cvgrPdist_lt => _/posnumP[e]. move/cvgrPdist_lt : H => /(_ _ (gt0 e)) -[m _ mu]. @@ -887,17 +895,18 @@ have /andP[n0] : ((0 < n) && (m <= n.-1))%N. near: n; exists m.+1 => // k mk; rewrite (leq_trans _ mk) //=. by rewrite -(leq_add2r 1%N) !addn1 prednK // (leq_trans _ mk). move/mu => {mu}; rewrite sub0r normrN /= prednK //; apply: le_lt_trans. -rewrite !normrM ler_wpmul2r // ger0_norm // ger0_norm //. -by rewrite lef_pinv // ?ler_nat // posrE // ltr0n. +rewrite !normrM ler_wpM2r // ger0_norm // ger0_norm //. +by rewrite lef_pV2 // ?ler_nat // posrE // ltr0n. Unshelve. all: by end_near. Qed. Lemma cesaro_converse (u_ : R ^nat) (l : R) : - telescope u_ =o_\oo harmonic -> arithmetic_mean u_ --> l -> u_ --> l. + telescope u_ =o_\oo @harmonic R -> + arithmetic_mean u_ @ \oo --> l -> u_ @ \oo --> l. Proof. pose a_ := telescope u_ => a_o u_l. suff abel : forall n, u_ n - arithmetic_mean u_ n = \sum_(1 <= k < n.+1) k%:R / n.+1%:R * a_ k.-1. - suff K : u_ - arithmetic_mean u_ --> (0 : R). + suff K : u_ - arithmetic_mean u_ @ \oo --> (0 : R). rewrite -(add0r l). rewrite (_ : u_ = u_ - arithmetic_mean u_ + arithmetic_mean u_); last first. by rewrite funeqE => n; rewrite subrK. @@ -908,16 +917,16 @@ suff abel : forall n, rewrite {abel} /= (_ : (fun _ => _) = fun n => n.+1%:R^-1 * \sum_(0 <= k < n) k.+1%:R * a_ k); last first. rewrite funeqE => n; rewrite big_add1 /= /= big_distrr /=. - by apply: eq_bigr => i _; rewrite mulrCA mulrA. - have {}a_o : [sequence n.+1%:R * telescope u_ n]_n --> (0 : R). + by apply eq_bigr => i _; rewrite mulrCA mulrA. + have {}a_o : [sequence n.+1%:R * telescope u_ n]_n @ \oo --> (0 : R). apply: (@eqolim0 _ _ _ eventually_filterType). rewrite a_o. - set h := 'o_[filter of \oo] harmonic. + set h := 'o_\oo (@harmonic R). apply/eqoP => _/posnumP[e] /=. - near=> n; rewrite normr1 mulr1 normrM -ler_pdivl_mull// ?normr_gt0//. + near=> n; rewrite normr1 mulr1 normrM -ler_pdivlMl// ?normr_gt0//. rewrite mulrC -normrV ?unitfE //. near: n. - by case: (eqoP eventually_filterType harmonic h) => + _; apply. + by case: (eqoP eventually_filterType (@harmonic R) h) => Hh _; apply Hh. move: (cesaro a_o); rewrite /arithmetic_mean /series /= -/a_. exact: (@cesaro_converse_off_by_one (fun k => k.+1%:R * a_ k)). case => [|n]. @@ -964,12 +973,13 @@ End cesaro_converse. Section series_convergence. Lemma cvg_series_cvg_0 (K : numFieldType) (V : normedModType K) (u_ : V ^nat) : - cvg (series u_) -> u_ --> (0 : V). + cvgn (series u_) -> u_ @ \oo --> (0 : V). Proof. move=> cvg_series. rewrite (_ : u_ = fun n => series u_ n.+1 - series u_ n); last first. by rewrite funeqE => i; rewrite seriesSB. -by rewrite -(subrr (lim (series u_))); apply: cvgB => //; rewrite ?cvg_shiftS. +rewrite -(subrr (limn (series u_))). +by apply: cvgB => //; rewrite ?cvg_shiftS. Qed. Lemma nondecreasing_series (R : numFieldType) (u_ : R ^nat) (P : pred nat) : @@ -978,14 +988,14 @@ Lemma nondecreasing_series (R : numFieldType) (u_ : R ^nat) (P : pred nat) : Proof. move=> u_ge0; apply/nondecreasing_seqP => n. rewrite [in leRHS]big_mkcond [in leRHS]big_nat_recr//=. -by rewrite -[in leRHS]big_mkcond/= ler_addl; case: ifPn => //; exact: u_ge0. +by rewrite -[in leRHS]big_mkcond/= lerDl; case: ifPn => //; exact: u_ge0. Qed. Lemma increasing_series (R : numFieldType) (u_ : R ^nat) : (forall n, 0 < u_ n) -> increasing_seq (series u_). Proof. move=> u_ge0; apply/increasing_seqP => n. -by rewrite !seriesEord/= big_ord_recr ltr_addl. +by rewrite !seriesEord/= big_ord_recr ltrDl. Qed. End series_convergence. @@ -1003,25 +1013,25 @@ Lemma exprn_geometric (R : fieldType) : (@GRing.exp R) = geometric 1. Proof. by rewrite funeq2E => z n /=; rewrite mul1r. Qed. Lemma cvg_arithmetic (R : archiFieldType) a (z : R) : - z > 0 -> arithmetic a z --> +oo. + z > 0 -> arithmetic a z @ \oo --> +oo. Proof. move=> z_gt0; apply/cvgryPge => A; near=> n => /=. -rewrite -ler_subl_addl -mulr_natl -ler_pdivr_mulr//. +rewrite -lerBlDl -mulr_natl -ler_pdivrMr//. rewrite ler_normlW// ltW// (lt_le_trans (archi_boundP _))// ler_nat. by near: n; apply: nbhs_infty_ge. Unshelve. all: by end_near. Qed. Lemma cvg_expr (R : archiFieldType) (z : R) : - `|z| < 1 -> (GRing.exp z : R ^nat) --> (0 : R). + `|z| < 1 -> (GRing.exp z : R ^nat) @ \oo --> (0 : R). Proof. move=> Nz_lt1; apply/norm_cvg0P; pose t := (1 - `|z|). apply: (@squeeze_cvgr _ _ _ _ (cst 0) (t^-1 *: @harmonic R)); last 2 first. - exact: cvg_cst. - by rewrite -(scaler0 _ t^-1); exact: (cvgZr cvg_harmonic). -near=> n; rewrite normr_ge0 normrX/= ler_pdivl_mull ?subr_gt0//. -rewrite -(@ler_pmul2l _ n.+1%:R)// mulfV// [t * _]mulrC mulr_natl. +near=> n; rewrite normr_ge0 normrX/= ler_pdivlMl ?subr_gt0//. +rewrite -(@ler_pM2l _ n.+1%:R)// mulfV// [t * _]mulrC mulr_natl. have -> : 1 = (`|z| + t) ^+ n.+1 by rewrite addrC addrNK expr1n. -rewrite exprDn (bigD1 (inord 1)) ?inordK// subn1 expr1 bin1 ler_addl sumr_ge0//. +rewrite exprDn (bigD1 (inord 1)) ?inordK// subn1 expr1 bin1 lerDl sumr_ge0//. by move=> i; rewrite ?(mulrn_wge0, mulr_ge0, exprn_ge0, subr_ge0)// ltW. Unshelve. all: by end_near. Qed. @@ -1035,7 +1045,7 @@ by under eq_bigr do rewrite -mulrA -exprSr; rewrite telescope_sumr// opprB. Qed. Lemma cvg_geometric_series (R : archiFieldType) (a z : R) : `|z| < 1 -> - series (geometric a z) --> (a * (1 - z)^-1). + series (geometric a z) @ \oo --> (a * (1 - z)^-1). Proof. move=> Nz_lt1; rewrite geometric_seriesE ?lt_eqF 1?ltr_normlW//. have -> : a / (1 - z) = (a * (1 - 0)) / (1 - z) by rewrite subr0 mulr1. @@ -1043,7 +1053,7 @@ by apply: cvgMl; apply: cvgMr; apply: cvgB; [apply: cvg_cst|apply: cvg_expr]. Qed. Lemma cvg_geometric_series_half (R : archiFieldType) (r : R) n : - series (fun k => r / (2 ^ (k + n.+1))%:R : R^o) --> (r / 2 ^+ n : R^o). + series (fun k => r / (2 ^ (k + n.+1))%:R : R^o) @ \oo --> (r / 2 ^+ n : R^o). Proof. rewrite (_ : series _ = series (geometric (r / (2 ^ n.+1)%:R) 2^-1%R)); last first. rewrite funeqE => m; rewrite /series /=; apply: eq_bigr => k _. @@ -1063,11 +1073,11 @@ by rewrite (big_addn 0 _ m) addnC addnK; under eq_bigr do rewrite exprD mulrC. Qed. Lemma cvg_geometric (R : archiFieldType) (a z : R) : `|z| < 1 -> - geometric a z --> (0 : R). + geometric a z @ \oo --> (0 : R). Proof. by move=> /cvg_geometric_series/cvgP/cvg_series_cvg_0. Qed. Lemma is_cvg_geometric_series (R : archiFieldType) (a z : R) : `|z| < 1 -> - cvg (series (geometric a z)). + cvgn (series (geometric a z)). Proof. by move=> /cvg_geometric_series/cvgP; apply. Qed. Definition normed_series_of (K : numDomainType) (V : normedModType K) @@ -1099,7 +1109,7 @@ Unshelve. all: by end_near. Qed. Lemma series_le_cvg (R : realType) (u_ v_ : R ^nat) : (forall n, 0 <= u_ n) -> (forall n, 0 <= v_ n) -> (forall n, u_ n <= v_ n) -> - cvg (series v_) -> cvg (series u_). + cvgn (series v_) -> cvgn (series u_). Proof. move=> u_ge0 v_ge0 le_uv /cvg_seq_bounded/bounded_fun_has_ubound[M v_M]. apply: nondecreasing_is_cvgn; first exact: nondecreasing_series. @@ -1108,7 +1118,7 @@ by apply: le_trans (v_M (series v_ n) _); [apply: ler_sum | exists n]. Qed. Lemma normed_cvg {R : realType} (V : completeNormedModType R) (u_ : V ^nat) : - cvg [normed series u_] -> cvg (series u_). + cvgn [normed series u_] -> cvgn (series u_). Proof. move=> /cauchy_cvgP/cauchy_seriesP u_ncvg. apply/cauchy_cvgP/cauchy_seriesP => e /u_ncvg. @@ -1117,7 +1127,8 @@ by apply: le_lt_trans; apply: ler_norm_sum. Qed. Lemma lim_series_norm {R : realType} (V : completeNormedModType R) (f : V ^nat) : - cvg [normed series f] -> `|lim (series f)| <= lim [normed series f]. + cvgn [normed series f] -> + `|limn (series f)| <= limn [normed series f]. Proof. move=> cnf; have cf := normed_cvg cnf. rewrite -lim_norm // (ler_lim (is_cvg_norm cf) cnf) //. @@ -1127,12 +1138,12 @@ Unshelve. all: by end_near. Qed. Section series_linear. Lemma cvg_series_bounded (R : realFieldType) (f : R ^nat) : - cvg (series f) -> bounded_fun f. + cvgn (series f) -> bounded_fun f. Proof. by move/cvg_series_cvg_0 => f0; apply/cvg_seq_bounded/cvg_ex; exists 0. Qed. -Lemma cvg_to_0_linear (R : realFieldType) (f : R -> R) K k : +Lemma cvg_to_0_linear (R : realFieldType) (f : R -> R) K (k : R) : 0 < k -> (forall r, 0 < `| r | < k -> `|f r| <= K * `| r |) -> f x @[x --> 0^'] --> 0. Proof. @@ -1143,25 +1154,25 @@ move=> k0 kfK; have [K0|K0] := lerP K 0. near: x; exists (k / 2); first by rewrite /mkset divr_gt0. move=> t /=; rewrite distrC subr0 => tk2 t0. by rewrite normr_gt0 t0 (lt_trans tk2) // -[in ltLHS](add0r k) midf_lt. -- apply/eqolim0/eqoP => _/posnumP[e]; near=> x. +- apply/(@eqolim0 _ _ R (0^'))/eqoP => _/posnumP[e]; near=> x. rewrite (le_trans (kfK _ _)) //=. + near: x; exists (k / 2); first by rewrite /mkset divr_gt0. move=> t /=; rewrite distrC subr0 => tk2 t0. by rewrite normr_gt0 t0 (lt_trans tk2) // -[in ltLHS](add0r k) midf_lt. - + rewrite normr1 mulr1 mulrC -ler_pdivl_mulr //. + + rewrite normr1 mulr1 mulrC -ler_pdivlMr //. near: x; exists (e%:num / K); first by rewrite /mkset divr_gt0. by move=> t /=; rewrite distrC subr0 => /ltW. Unshelve. all: by end_near. Qed. Lemma lim_cvg_to_0_linear (R : realType) (f : nat -> R) (g : R -> nat -> R) k : - 0 < k -> cvg (series f) -> + 0 < k -> cvgn (series f) -> (forall r, 0 < `|r| < k -> forall n, `|g r n| <= f n * `| r |) -> - lim (series (g x)) @[x --> 0^'] --> 0. + limn (series (g x)) @[x --> 0^'] --> 0. Proof. move=> k_gt0 Cf Hg. -apply: (@cvg_to_0_linear _ _ (lim (series f)) k) => // h hLk; rewrite mulrC. -have Ckf := @is_cvg_seriesZ _ _ `|h| Cf. -have Cng : cvg [normed series (g h)]. +apply: (@cvg_to_0_linear _ _ (limn (series f)) k) => // h hLk; rewrite mulrC. +have Ckf : cvgn (series (`|h| *: f)) := @is_cvg_seriesZ _ _ `|h| Cf. +have Cng : cvgn [normed series (g h)]. apply: series_le_cvg (Hg _ hLk) _ => [//|?|]. exact: le_trans (Hg _ hLk _). by under eq_fun do rewrite mulrC. @@ -1197,11 +1208,11 @@ Hypothesis x0 : 0 < x. Let S0 N n := (N ^ N)%:R * \sum_(N.+1 <= i < n) (x / N%:R) ^+ i. -Let is_cvg_S0 N : x < N%:R -> cvg (S0 N). +Let is_cvg_S0 N : x < N%:R -> cvgn (S0 N). Proof. move=> xN; apply: is_cvgZr; rewrite is_cvg_series_restrict exprn_geometric. apply/is_cvg_geometric_series; rewrite normrM normfV. -by rewrite ltr_pdivr_mulr ?mul1r !ger0_norm // 1?ltW // (lt_trans x0). +by rewrite ltr_pdivrMr ?mul1r !ger0_norm // 1?ltW // (lt_trans x0). Qed. Let S0_ge0 N n : 0 <= S0 N n. @@ -1224,7 +1235,7 @@ Lemma incr_S1 N : nondecreasing_seq (S1 N). Proof. apply/nondecreasing_seqP => n; rewrite /S1. have [nN|Nn] := leqP n N; first by rewrite !big_geq // (leq_trans nN). -by rewrite big_nat_recr//= ler_addl exp_coeff_ge0 // ltW. +by rewrite big_nat_recr//= lerDl exp_coeff_ge0 // ltW. Qed. Let S1_sup N : x < N%:R -> ubound (range (S1 N)) (sup (range (S0 N))). @@ -1232,12 +1243,12 @@ Proof. move=> xN _ [n _ <-]; rewrite (le_trans _ (S0_sup n xN)) // /S0 big_distrr /=. have N_gt0 := lt_trans x0 xN; apply: ler_sum => i _. have [Ni|iN] := ltnP N i; last first. - rewrite expr_div_n mulrCA ler_pmul2l ?exprn_gt0// (@le_trans _ _ 1) //. + rewrite expr_div_n mulrCA ler_pM2l ?exprn_gt0// (@le_trans _ _ 1) //. by rewrite invf_le1// ?ler1n ?ltr0n // fact_gt0. rewrite natrX -expfB_cond ?(negPf (lt0r_neq0 N_gt0))//. by rewrite exprn_ege1 // ler1n; case: (N) xN x0; case: ltrgt0P. -rewrite /exp expr_div_n /= (fact_split Ni) mulrCA ler_pmul2l ?exprn_gt0// natrX. -rewrite -invf_div -expfB // lef_pinv ?qualifE ?exprn_gt0//; last first. +rewrite /exp expr_div_n /= (fact_split Ni) mulrCA ler_pM2l ?exprn_gt0// natrX. +rewrite -invf_div -expfB // lef_pV2 ?qualifE/= ?exprn_gt0//; last first. rewrite ltr0n muln_gt0 fact_gt0/= big_seq big_mkcond/= prodn_gt0// => j. by case: ifPn=>//; rewrite mem_index_iota => /andP[+ _]; exact: leq_ltn_trans. rewrite big_nat_rev/= -natrX ler_nat -prod_nat_const_nat big_add1 /= big_ltn //. @@ -1248,14 +1259,14 @@ move=> j; rewrite mem_index_iota => /andP[_ ji]. by rewrite -addnBA// ?leq_addr// ltnW// ltnW. Qed. -Lemma is_cvg_series_exp_coeff_pos : cvg (series (exp x)). +Lemma is_cvg_series_exp_coeff_pos : cvgn (series (exp x)). Proof. rewrite /series; near \oo => N; have xN : x < N%:R; last first. rewrite -(@is_cvg_series_restrict N.+1). by apply: (nondecreasing_is_cvgn (incr_S1 N)); eexists; apply: S1_sup. near: N; exists (absz (floor x)).+1 => // m; rewrite /mkset -(@ler_nat R). move/lt_le_trans => -> //; rewrite (lt_le_trans (lt_succ_floor x)) // -addn1. -by rewrite natrD ler_add2r -(@gez0_abs (floor x)) ?floor_ge0// ltW. +by rewrite natrD lerD2r -(@gez0_abs (floor x)) ?floor_ge0// ltW. Unshelve. all: by end_near. Qed. End exponential_series_cvg. @@ -1266,7 +1277,7 @@ rewrite funeqE => n /=; apply: eq_bigr => k _. by rewrite /exp normrM normfV normrX [`|_%:R|]@ger0_norm. Qed. -Lemma is_cvg_series_exp_coeff x : cvg (series (exp x)). +Lemma is_cvg_series_exp_coeff x : cvgn (series (exp x)). Proof. have [->|x0] := eqVneq x 0. apply/cvg_ex; exists 1; apply/cvgrPdist_lt => // => _/posnumP[e]. @@ -1277,37 +1288,37 @@ apply: normed_cvg; rewrite normed_series_exp_coeff. by apply: is_cvg_series_exp_coeff_pos; rewrite normr_gt0. Unshelve. all: by end_near. Qed. -Lemma cvg_exp_coeff x : exp x --> (0 : R). +Lemma cvg_exp_coeff x : exp x @ \oo --> (0 : R). Proof. exact: (cvg_series_cvg_0 (@is_cvg_series_exp_coeff x)). Qed. End exponential_series. (* TODO: generalize *) -Definition expR {R : realType} (x : R) : R := lim (series (exp_coeff x)). +Definition expR {R : realType} (x : R) : R := limn (series (exp_coeff x)). (** Sequences of natural numbers *) -Lemma __deprecated__nat_dvg_real (R : realType) (u_ : nat ^nat) : u_ --> \oo -> - ([sequence (u_ n)%:R : R^o]_n --> +oo)%R. +Lemma __deprecated__nat_dvg_real (R : realType) (u_ : nat ^nat) : + u_ @ \oo --> \oo -> ([sequence (u_ n)%:R : R^o]_n @ \oo --> +oo)%R. Proof. by move=> ?; apply/cvgrnyP. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgrnyP` and generalized")] Notation nat_dvg_real := __deprecated__nat_dvg_real (only parsing). Lemma __deprecated__nat_cvgPpinfty (u : nat^nat) : - u --> \oo <-> forall A, \forall n \near \oo, (A <= u n)%N. + u @ \oo --> \oo <-> forall A, \forall n \near \oo, (A <= u n)%N. Proof. exact: cvgnyPge. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="renamed to `cvgnyPge` and generalized")] Notation nat_cvgPpinfty:= __deprecated__nat_cvgPpinfty (only parsing). Lemma nat_nondecreasing_is_cvg (u_ : nat^nat) : - nondecreasing_seq u_ -> has_ubound (range u_) -> cvg u_. + nondecreasing_seq u_ -> has_ubound (range u_) -> cvgn u_. Proof. move=> u_nd [l ul]. suff [N Nu] : exists N, forall n, (n >= N)%N -> u_ n = u_ N. apply/cvg_ex; exists (u_ N); rewrite -(cvg_shiftn N). - rewrite [X in X --> _](_ : _ = cst (u_ N))//; first exact: cvg_cst. + rewrite [X in X @ \oo --> _](_ : _ = cst (u_ N))//; first exact: cvg_cst. by apply/funext => n /=; rewrite Nu// leq_addl. apply/not_existsP => hu. have {hu}/choice[f Hf] : forall x, (exists n, x <= n /\ u_ n > u_ x)%N. @@ -1330,7 +1341,7 @@ rewrite -[in X in (_ <= X)%N](subnKC ab) iotaD big_cat/= add0n. by rewrite /index_iota subn0 leq_addr. Qed. -Lemma cvg_nseries_near (u : nat^nat) : cvg (nseries u) -> +Lemma cvg_nseries_near (u : nat^nat) : cvgn (nseries u) -> \forall n \near \oo, u n = 0%N. Proof. move=> /cvg_ex[l ul]; have /ul[a _ aul] : nbhs l [set l]. @@ -1346,7 +1357,8 @@ have /bul[->|->] : (b <= n.+1)%N by rewrite leqW// (leq_trans _ abn)// leq_maxr. - by rewrite subnn. Qed. -Lemma dvg_nseries (u : nat^nat) : ~ cvg (nseries u) -> nseries u --> \oo. +Lemma dvg_nseries (u : nat^nat) : ~ cvgn (nseries u) -> + nseries u @ \oo --> \oo. Proof. move=> du; apply: contrapT => /cvgnyPgt/existsNP[l lu]; apply: du. apply: nat_nondecreasing_is_cvg => //; first exact: le_nseries. @@ -1357,13 +1369,13 @@ Unshelve. all: by end_near. Qed. (** Sequences of extended real numbers *) Notation "\big [ op / idx ]_ ( m <= i (\big[ op / idx ]_(m <= i < n | P) F))) : big_scope. + (limn (fun n => (\big[ op / idx ]_(m <= i < n | P) F))) : big_scope. Notation "\big [ op / idx ]_ ( m <= i (\big[ op / idx ]_(m <= i < n) F))) : big_scope. + (limn (fun n => (\big[ op / idx ]_(m <= i < n) F))) : big_scope. Notation "\big [ op / idx ]_ ( i (\big[ op / idx ]_(i < n | P) F))) : big_scope. + (limn (fun n => (\big[ op / idx ]_(i < n | P) F))) : big_scope. Notation "\big [ op / idx ]_ ( i (\big[ op / idx ]_(i < n) F))) : big_scope. + (limn (fun n => (\big[ op / idx ]_(i < n) F))) : big_scope. Notation "\sum_ ( m <= i nbhs 0 -> f --> 0. + abse \o f @ \oo --> 0 -> f @ \oo --> 0. Proof. by move/cvg_abse0P. Qed. Lemma __deprecated__ereal_cvg_ge0 (R : realFieldType) (f : (\bar R)^nat) (a : \bar R) : - (forall n, 0 <= f n) -> f --> a -> 0 <= a. + (forall n, 0 <= f n) -> f @ \oo --> a -> 0 <= a. Proof. by move=> f_ge0; apply: cvge_ge; apply: nearW. Qed. -Lemma __deprecated__ereal_lim_ge (R : realFieldType) x (u_ : (\bar R)^nat) : cvg u_ -> - (\forall n \near \oo, x <= u_ n) -> x <= lim u_. +Lemma __deprecated__ereal_lim_ge (R : realFieldType) x (u_ : (\bar R)^nat) : + cvgn u_ -> (\forall n \near \oo, x <= u_ n) -> x <= limn u_. Proof. exact: lime_ge. Qed. -Lemma __deprecated__ereal_lim_le (R : realFieldType) x (u_ : (\bar R)^nat) : cvg u_ -> - (\forall n \near \oo, u_ n <= x) -> lim u_ <= x. +Lemma __deprecated__ereal_lim_le (R : realFieldType) x (u_ : (\bar R)^nat) : + cvgn u_ -> (\forall n \near \oo, u_ n <= x) -> limn u_ <= x. Proof. exact: lime_le. Qed. Lemma __deprecated__dvg_ereal_cvg (R : realFieldType) (u_ : R ^nat) : - u_ --> +oo%R -> [sequence (u_ n)%:E]_n --> +oo. + u_ @ \oo --> +oo%R -> [sequence (u_ n)%:E]_n @ \oo --> +oo. Proof. by rewrite cvgeryP. Qed. Lemma __deprecated__ereal_cvg_real (R : realFieldType) (f : (\bar R)^nat) a : {near \oo, forall x, f x \is a fin_num} /\ - (fine \o f --> a) <-> f --> a%:E. + (fine \o f @ \oo --> a) <-> f @ \oo --> a%:E. Proof. by rewrite fine_cvgP. Qed. Lemma ereal_nondecreasing_cvgn (R : realType) (u_ : (\bar R)^nat) : - nondecreasing_seq u_ -> u_ --> ereal_sup (range u_). + nondecreasing_seq u_ -> u_ @ \oo --> ereal_sup (u_ @` setT). Proof. move=> nd_u_; set S := u_ @` setT; set l := ereal_sup S. have [Spoo|Spoo] := pselect (S +oo). @@ -1486,8 +1498,8 @@ have [Spoo|Spoo] := pselect (S +oo). case: Spoo => N _ uNoo; exists N => n Nn. by move: (nd_u_ _ _ Nn); rewrite uNoo leye_eq => /eqP. have -> : l = +oo by rewrite /l /ereal_sup; exact: supremum_pinfty. - rewrite -(cvg_shiftn N); set f := (X in X --> _). - rewrite (_ : f = cst +oo); first exact: cvg_cst. + rewrite -(cvg_shiftn N); set f := (X in X @ \oo --> _). + rewrite (_ : f = (fun=> +oo)); first exact: cvg_cst. by rewrite funeqE => n; rewrite /f /= Nu // leq_addl. have [/funext Snoo|Snoo] := pselect (forall n, u_ n = -oo). rewrite /l (_ : S = [set -oo]). @@ -1534,13 +1546,13 @@ apply: nondecreasing_cvgn. Unshelve. all: by end_near. Qed. Lemma ereal_nondecreasing_is_cvgn (R : realType) (u_ : (\bar R) ^nat) : - nondecreasing_seq u_ -> cvg u_. + nondecreasing_seq u_ -> cvgn u_. Proof. by move=> ?; apply/cvg_ex; eexists; exact: ereal_nondecreasing_cvgn. Qed. Lemma ereal_nonincreasing_cvgn (R : realType) (u_ : (\bar R)^nat) : - nonincreasing_seq u_ -> u_ --> ereal_inf (u_ @` setT). + nonincreasing_seq u_ -> u_ @ \oo --> ereal_inf (u_ @` setT). Proof. -move=> ni_u; rewrite [X in X --> _](_ : _ = -%E \o -%E \o u_); last first. +move=> ni_u; rewrite [X in X @ \oo --> _](_ : _ = -%E \o -%E \o u_); last first. by rewrite funeqE => n; rewrite /= oppeK. apply: cvgeN. rewrite [X in _ --> X](_ : _ = ereal_sup (range (-%E \o u_))); last first. @@ -1550,7 +1562,7 @@ by apply: ereal_nondecreasing_cvgn; rewrite ereal_nondecreasing_oppn. Qed. Lemma ereal_nonincreasing_is_cvgn (R : realType) (u_ : (\bar R) ^nat) : - nonincreasing_seq u_ -> cvg u_. + nonincreasing_seq u_ -> cvgn u_. Proof. by move=> ?; apply/cvg_ex; eexists; apply: ereal_nonincreasing_cvgn. Qed. (* NB: see also nondecreasing_series *) @@ -1559,26 +1571,30 @@ Lemma ereal_nondecreasing_series (R : realDomainType) (u_ : (\bar R)^nat) nondecreasing_seq (fun n => \sum_(0 <= i < n | P i) u_ i). Proof. by move=> u_ge0 n m nm; rewrite lee_sum_nneg_natr// => k _ /u_ge0. Qed. +Lemma congr_lim (R : numFieldType) (f g : nat -> \bar R) : + f = g -> limn f = limn g. +Proof. by move=> ->. Qed. + Lemma eseries_cond {R : numFieldType} (f : (\bar R)^nat) P N : \sum_(N <= i n /=; apply: big_nat_widenl. Qed. +Proof. by apply/congr_lim/eq_fun => n /=; apply: big_nat_widenl. Qed. Lemma eseries_mkcondl {R : numFieldType} (f : (\bar R)^nat) P Q : \sum_(i n; rewrite big_mkcondl. Qed. +Proof. by apply/congr_lim/funext => n; rewrite big_mkcondl. Qed. Lemma eseries_mkcondr {R : numFieldType} (f : (\bar R)^nat) P Q : \sum_(i n; rewrite big_mkcondr. Qed. +Proof. by apply/congr_lim/funext => n; rewrite big_mkcondr. Qed. Lemma eq_eseriesr (R : numFieldType) (f g : (\bar R)^nat) (P : pred nat) {N} : (forall i, P i -> f i = g i) -> \sum_(N <= i efg; congr (lim _); apply/funext => n; exact: eq_bigr. Qed. +Proof. by move=> efg; apply/congr_lim/funext => n; exact: eq_bigr. Qed. Lemma eq_eseriesl (R : realFieldType) (P Q : pred nat) (f : (\bar R)^nat) : P =1 Q -> \sum_(i efg; congr (lim _); apply/funext => n; exact: eq_bigl. Qed. +Proof. by move=> efg; apply/congr_lim/funext => n; apply: eq_bigl. Qed. Arguments eq_eseriesl {R P} Q. Section ereal_series. @@ -1588,14 +1604,14 @@ Implicit Types P : pred nat. Lemma ereal_series_cond k P : \sum_(k <= i n. +apply/congr_lim/funext => n. rewrite big_nat_cond (big_nat_widenl k 0%N)//= 2!big_mkord. by apply: eq_big => //= i; rewrite andbAC ltn_ord andbT andbb. Qed. Lemma ereal_series k : \sum_(k <= i n. +rewrite ereal_series_cond; congr (limn _); apply/funext => n. by apply: eq_big => // i; rewrite andbT. Qed. @@ -1635,43 +1651,43 @@ Variable (R : realType) (u_ : (\bar R)^nat). Implicit Type P : pred nat. Lemma is_cvg_ereal_nneg_natsum_cond m P : - (forall n, (m <= n)%N -> P n -> 0 <= u_ n) -> -cvg (fun n => \sum_(m <= i < n | P i) u_ i). + (forall n, (m <= n)%N -> P n -> 0 <= u_ n) -> + cvgn (fun n => \sum_(m <= i < n | P i) u_ i). Proof. by move/lee_sum_nneg_natr/ereal_nondecreasing_cvgn => cu; apply: cvgP; exact: cu. Qed. Lemma is_cvg_ereal_npos_natsum_cond m P : - (forall n, (m <= n)%N -> P n -> u_ n <= 0) -> - cvg (fun n => \sum_(m <= i < n | P i) u_ i). + (forall n, (m <= n)%N -> P n -> u_ n <= 0) -> + cvgn (fun n => \sum_(m <= i < n | P i) u_ i). Proof. by move/lee_sum_npos_natr/ereal_nonincreasing_cvgn => cu; apply: cvgP; exact: cu. Qed. Lemma is_cvg_ereal_nneg_natsum m : (forall n, (m <= n)%N -> 0 <= u_ n) -> - cvg (fun n => \sum_(m <= i < n) u_ i). + cvgn (fun n => \sum_(m <= i < n) u_ i). Proof. by move=> u_ge0; apply: is_cvg_ereal_nneg_natsum_cond => n /u_ge0. Qed. Lemma is_cvg_ereal_npos_natsum m : (forall n, (m <= n)%N -> u_ n <= 0) -> - cvg (fun n => \sum_(m <= i < n) u_ i). + cvgn (fun n => \sum_(m <= i < n) u_ i). Proof. by move=> u_le0; apply: is_cvg_ereal_npos_natsum_cond => n /u_le0. Qed. Lemma is_cvg_nneseries_cond P N : (forall n, P n -> 0 <= u_ n) -> - cvg (fun n => \sum_(N <= i < n | P i) u_ i). + cvgn (fun n => \sum_(N <= i < n | P i) u_ i). Proof. by move=> u_ge0; apply: is_cvg_ereal_nneg_natsum_cond => n _; exact: u_ge0. Qed. Lemma is_cvg_npeseries_cond P N : (forall n, P n -> u_ n <= 0) -> - cvg (fun n => \sum_(N <= i < n | P i) u_ i). + cvgn (fun n => \sum_(N <= i < n | P i) u_ i). Proof. by move=> u_le0; apply: is_cvg_ereal_npos_natsum_cond => n _ /u_le0. Qed. Lemma is_cvg_nneseries P N : (forall n, P n -> 0 <= u_ n) -> - cvg (fun n => \sum_(N <= i < n | P i) u_ i). + cvgn (fun n => \sum_(N <= i < n | P i) u_ i). Proof. by move=> ?; exact: is_cvg_nneseries_cond. Qed. Lemma is_cvg_npeseries P N : (forall n, P n -> u_ n <= 0) -> - cvg (fun n => \sum_(N <= i < n | P i) u_ i). + cvgn (fun n => \sum_(N <= i < n | P i) u_ i). Proof. by move=> ?; exact: is_cvg_npeseries_cond. Qed. Lemma nneseries_ge0 P N : (forall n, P n -> 0 <= u_ n) -> @@ -1693,12 +1709,13 @@ Arguments is_cvg_nneseries {R}. Arguments nneseries_ge0 {R u_ P} N. Lemma nnseries_is_cvg {R : realType} (u : nat -> R) : - (forall i, 0 <= u i)%R -> \sum_(k cvg (series u). + (forall i, 0 <= u i)%R -> \sum_(k + cvgn (series u). Proof. move=> ? ?; apply: nondecreasing_is_cvgn. move=> m n mn; rewrite /series/=. rewrite -(subnKC mn) {2}/index_iota subn0 iotaD big_cat/=. - by rewrite add0n -{2}(subn0 m) -/(index_iota _ _) ler_addl sumr_ge0. + by rewrite add0n -{2}(subn0 m) -/(index_iota _ _) lerDl sumr_ge0. exists (fine (\sum_(k _ [n _ <-]; rewrite -lee_fin fineK//; last first. rewrite fin_num_abs gee0_abs//; apply: nneseries_ge0 => // i _. @@ -1711,7 +1728,7 @@ Lemma nneseriesZl (R : realType) (f : nat -> \bar R) (P : pred nat) x N : (\sum_(N <= i f0; rewrite -limeMl//; last exact: is_cvg_nneseries. -by congr (lim _); apply/funext => /= n; rewrite ge0_sume_distrr. +by apply/congr_lim/funext => /= n; rewrite ge0_sume_distrr. Qed. Lemma adde_def_nneseries (R : realType) (f g : (\bar R)^nat) @@ -1725,20 +1742,20 @@ move=> f0 g0; rewrite /adde_def !negb_and; apply/andP; split; apply/orP. Qed. Lemma __deprecated__ereal_cvgPpinfty (R : realFieldType) (u_ : (\bar R)^nat) : - u_ --> +oo <-> (forall A, (0 < A)%R -> \forall n \near \oo, A%:E <= u_ n). + u_ @ \oo --> +oo <-> (forall A, (0 < A)%R -> \forall n \near \oo, A%:E <= u_ n). Proof. by split=> [/cvgeyPge//|u_ge]; apply/cvgeyPgey; near=> x; apply: u_ge. Unshelve. all: by end_near. Qed. Lemma __deprecated__ereal_cvgPninfty (R : realFieldType) (u_ : (\bar R)^nat) : - u_ --> -oo <-> (forall A, (A < 0)%R -> \forall n \near \oo, u_ n <= A%:E). + u_ @ \oo --> -oo <-> (forall A, (A < 0)%R -> \forall n \near \oo, u_ n <= A%:E). Proof. by split=> [/cvgeNyPle//|u_ge]; apply/cvgeNyPleNy; near=> x; apply: u_ge. Unshelve. all: by end_near. Qed. Lemma __deprecated__ereal_squeeze (R : realType) (f g h : (\bar R)^nat) : (\forall x \near \oo, f x <= g x <= h x) -> forall (l : \bar R), - f --> l -> h --> l -> g --> l. + f @ \oo --> l -> h @ \oo --> l -> g @ \oo --> l. Proof. by move=> ? ?; apply: squeeze_cvge. Qed. Lemma nneseries_pinfty (R : realType) (u_ : (\bar R)^nat) @@ -1773,87 +1790,88 @@ move=> u0 Puv; apply: lee_lim. Unshelve. all: by end_near. Qed. Lemma __deprecated__ereal_cvgD_pinfty_fin (R : realFieldType) (f g : (\bar R)^nat) b : - f --> +oo -> g --> b%:E -> f \+ g --> +oo. + f @ \oo --> +oo -> g @ \oo --> b%:E -> f \+ g @ \oo --> +oo. Proof. exact: cvgeD. Qed. Lemma __deprecated__ereal_cvgD_ninfty_fin (R : realFieldType) (f g : (\bar R)^nat) b : - f --> -oo -> g --> b%:E -> f \+ g --> -oo. + f @ \oo --> -oo -> g @ \oo --> b%:E -> f \+ g @ \oo --> -oo. Proof. exact: cvgeD. Qed. Lemma __deprecated__ereal_cvgD_pinfty_pinfty (R : realFieldType) (f g : (\bar R)^nat) : - f --> +oo -> g --> +oo -> f \+ g --> +oo. + f @ \oo --> +oo -> g @ \oo --> +oo -> f \+ g @ \oo --> +oo. Proof. exact: cvgeD. Qed. Lemma __deprecated__ereal_cvgD_ninfty_ninfty (R : realFieldType) (f g : (\bar R)^nat) : - f --> -oo -> g --> -oo -> f \+ g --> -oo. + f @ \oo --> -oo -> g @ \oo --> -oo -> f \+ g @ \oo --> -oo. Proof. exact: cvgeD. Qed. #[deprecated(since="mathcomp-analysis 0.6.0", note="use `cvgeD` instead")] Notation ereal_cvgD_ninfty_ninfty := __deprecated__ereal_cvgD_ninfty_ninfty (only parsing). Lemma __deprecated__ereal_cvgD (R : realFieldType) (f g : (\bar R)^nat) a b : - a +? b -> f --> a -> g --> b -> f \+ g --> a + b. + a +? b -> f @ \oo --> a -> g @ \oo --> b -> f \+ g @ \oo --> a + b. Proof. exact: cvgeD. Qed. Lemma __deprecated__ereal_cvgB (R : realFieldType) (f g : (\bar R)^nat) a b : - a +? - b -> f --> a -> g --> b -> f \- g --> a - b. + a +? - b -> f @ \oo --> a -> g @ \oo --> b -> f \- g @ \oo --> a - b. Proof. exact: cvgeB. Qed. Lemma __deprecated__ereal_is_cvgD (R : realFieldType) (u v : (\bar R)^nat) : - lim u +? lim v -> cvg u -> cvg v -> cvg (u \+ v). + limn u +? limn v -> cvgn u -> cvgn v -> cvgn (u \+ v). Proof. exact: is_cvgeD. Qed. Lemma __deprecated__ereal_cvg_sub0 (R : realFieldType) (f : (\bar R)^nat) (k : \bar R) : - k \is a fin_num -> (fun x => f x - k) --> 0 <-> f --> k. + k \is a fin_num -> (fun x => f x - k) @ \oo --> 0 <-> f @ \oo --> k. Proof. exact: cvge_sub0. Qed. Lemma __deprecated__ereal_limD (R : realFieldType) (f g : (\bar R)^nat) : - cvg f -> cvg g -> lim f +? lim g -> - lim (f \+ g) = lim f + lim g. + cvgn f -> cvgn g -> limn f +? limn g -> + limn (f \+ g) = limn f + limn g. Proof. exact: limeD. Qed. Lemma __deprecated__ereal_cvgM_gt0_pinfty (R : realFieldType) (f g : (\bar R)^nat) b : - (0 < b)%R -> f --> +oo -> g --> b%:E -> f \* g --> +oo. + (0 < b)%R -> f @ \oo --> +oo -> g @ \oo --> b%:E -> f \* g @ \oo --> +oo. Proof. move=> b_lt0 fl gl; have /= := cvgeM _ fl gl; rewrite gt0_mulye//; apply. by rewrite mule_def_infty_neq0// gt_eqF. Qed. Lemma __deprecated__ereal_cvgM_lt0_pinfty (R : realFieldType) (f g : (\bar R)^nat) b : - (b < 0)%R -> f --> +oo -> g --> b%:E -> f \* g --> -oo. + (b < 0)%R -> f @ \oo --> +oo -> g @ \oo --> b%:E -> f \* g @ \oo --> -oo. Proof. move=> b_lt0 fl gl; have /= := cvgeM _ fl gl; rewrite lt0_mulye//; apply. by rewrite mule_def_infty_neq0// lt_eqF. Qed. Lemma __deprecated__ereal_cvgM_gt0_ninfty (R : realFieldType) (f g : (\bar R)^nat) b : - (0 < b)%R -> f --> -oo -> g --> b%:E -> f \* g --> -oo. + (0 < b)%R -> f @ \oo --> -oo -> g @ \oo --> b%:E -> f \* g @ \oo --> -oo. Proof. move=> b_lt0 fl gl; have /= := cvgeM _ fl gl; rewrite gt0_mulNye//; apply. by rewrite mule_def_infty_neq0// gt_eqF. Qed. Lemma __deprecated__ereal_cvgM_lt0_ninfty (R : realFieldType) (f g : (\bar R)^nat) b : - (b < 0)%R -> f --> -oo -> g --> b%:E -> f \* g --> +oo. + (b < 0)%R -> f @ \oo --> -oo -> g @ \oo --> b%:E -> f \* g @ \oo --> +oo. Proof. move=> b_lt0 fl gl; have /= := cvgeM _ fl gl; rewrite lt0_mulNye//; apply. by rewrite mule_def_infty_neq0// lt_eqF. Qed. Lemma __deprecated__ereal_cvgM (R : realType) (f g : (\bar R) ^nat) (a b : \bar R) : - a *? b -> f --> a -> g --> b -> f \* g --> a * b. + a *? b -> f @ \oo --> a -> g @ \oo --> b -> f \* g @ \oo --> a * b. Proof. exact: cvgeM. Qed. Lemma __deprecated__ereal_lim_sum (R : realFieldType) (I : Type) (r : seq I) (f : I -> (\bar R)^nat) (l : I -> \bar R) (P : pred I) : (forall k n, P k -> 0 <= f k n) -> - (forall k, P k -> f k --> l k) -> - (fun n => \sum_(k <- r | P k) f k n) --> \sum_(k <- r | P k) l k. + (forall k, P k -> f k @ \oo --> l k) -> + (fun n => \sum_(k <- r | P k) f k n) @ \oo --> \sum_(k <- r | P k) l k. Proof. by move=> f0 ?; apply: cvg_nnesum => // ? ?; apply: nearW => ?; apply: f0. Qed. Let lim_shift_cst (R : realFieldType) (u : (\bar R) ^nat) (l : \bar R) : - cvg u -> (forall n, 0 <= u n) -> -oo < l -> lim (fun x => l + u x) = l + lim u. + cvgn u -> (forall n, 0 <= u n) -> -oo < l -> + limn (fun x => l + u x) = l + limn u. Proof. move=> cu u0 hl; apply/cvg_lim => //; apply: cvgeD (cu); last first. exact: cvg_cst. @@ -1864,9 +1882,9 @@ Qed. Section nneseries_split. Let near_eq_lim (R : realFieldType) (f g : nat -> \bar R) : - cvg g -> {near \oo, f =1 g} -> lim f = lim g. + cvgn g -> {near \oo, f =1 g} -> limn f = limn g. Proof. -move=> cg fg; suff: f --> lim g by exact/cvg_lim. +move=> cg fg; suff: f @ \oo --> limn g by exact/cvg_lim. by apply: cvg_trans cg; apply: near_eq_cvg; near do apply/esym. Unshelve. all: by end_near. Qed. @@ -1891,7 +1909,7 @@ Lemma nneseries_tail_cvg (R : realType) (f : (\bar R)^nat) : \sum_(N <= k \oo] --> 0. Proof. move=> foo f0. -have : cvg (fun n => \sum_(0 <= k < n) f k). +have : cvg (\sum_(0 <= k < n) f k @[n --> \oo]). by apply: ereal_nondecreasing_is_cvgn; exact: lee_sum_nneg_natr. move/cvg_ex => [[l fl||/cvg_lim fnoo]] /=; last 2 first. - by move/cvg_lim => fpoo; rewrite fpoo// in foo. @@ -1912,9 +1930,9 @@ Lemma nneseriesD (R : realType) (f g : nat -> \bar R) (P : pred nat) : \sum_(i f_eq0 g_eq0. -transitivity (lim (fun n => \sum_(0 <= i < n | P i) f i + +transitivity (limn (fun n => \sum_(0 <= i < n | P i) f i + \sum_(0 <= i < n | P i) g i)). - by congr (lim _); apply/funext => n; rewrite big_split. + by apply/congr_lim/funext => n; rewrite big_split. rewrite limeD /adde_def //=; do ? exact: is_cvg_nneseries. by rewrite ![_ == -oo]gt_eqF ?andbF// (@lt_le_trans _ _ 0) ?[_ < _]real0// nneseries_ge0. @@ -1928,7 +1946,7 @@ Proof. move=> f0; elim: n => [|n IHn]. by rewrite big_geq// eseries0// => i; rewrite big_geq. rewrite big_nat_recr// -IHn/= -nneseriesD//; last by move=> i; rewrite sume_ge0. -by congr (lim _); apply/funext => m; apply: eq_bigr => i _; rewrite big_nat_recr. +by apply/congr_lim/funext => m; apply: eq_bigr => i _; rewrite big_nat_recr. Qed. Lemma nneseries_sum I (r : seq I) (P : {pred I}) [R : realType] @@ -1946,7 +1964,7 @@ by apply: eq_bigr => j _; case: ifP => //; rewrite eseries0. Qed. Lemma lte_lim (R : realFieldType) (u : (\bar R)^nat) (M : R) : - nondecreasing_seq u -> cvg u -> M%:E < lim u -> + nondecreasing_seq u -> cvgn u -> M%:E < limn u -> \forall n \near \oo, M%:E <= u n. Proof. move=> ndu cu Ml; have [[n Mun]|] := pselect (exists n, M%:E <= u n). @@ -1954,12 +1972,12 @@ move=> ndu cu Ml; have [[n Mun]|] := pselect (exists n, M%:E <= u n). by near: m; exists n.+1 => // p q; apply/ndu/ltnW. move/forallNP => Mu. have {}Mu : forall x, M%:E > u x by move=> x; rewrite ltNge; apply/negP. -have : lim u <= M%:E by apply: lime_le => //; near=> m; apply/ltW/Mu. +have : limn u <= M%:E by apply lime_le => //; near=> m; apply/ltW/Mu. by move/(lt_le_trans Ml); rewrite ltxx. Unshelve. all: by end_near. Qed. Lemma lim_mkord (R : realFieldType) (P : {pred nat}) (f : (\bar R)^nat) : - lim (fun n => \sum_(k < n | P k) f k)%E = \sum_(k \sum_(k < n | P k) f k)%E = \sum_(k _) = (fun n => \sum_(0 <= k < n | P k) f k)%E) //. by rewrite funeqE => k; rewrite big_mkord. @@ -1967,7 +1985,7 @@ Qed. Lemma eseries_mkcond [R : realFieldType] [P : pred nat] (f : nat -> \bar R) : \sum_(i n /=; apply: big_mkcond. Qed. +Proof. by apply/congr_lim/eq_fun => n /=; apply: big_mkcond. Qed. End sequences_ereal. #[deprecated(since="mathcomp-analysis 0.6.0", @@ -2058,7 +2076,7 @@ Context {R : realFieldType}. Implicit Types (u : R^nat) (r : R). Lemma minr_cvg_0_cvg_0 u r : 0 < r -> (forall k, 0 <= u k) -> - minr (u n) r @[n --> \oo] --> (0:R) -> u --> (0:R). + minr (u n) r @[n --> \oo] --> 0 -> u n @[n --> \oo] --> 0. Proof. move=> r0 u0 minr_cvg; apply/cvgrPdist_lt => _ /posnumP[e]. have : 0 < minr e%:num r by rewrite lt_minr// r0 andbT. @@ -2070,12 +2088,12 @@ by rewrite le_minr u0 ltW. Unshelve. all: by end_near. Qed. Lemma maxr_cvg_0_cvg_0 u r : r < 0 -> (forall k, u k <= 0) -> - maxr (u n) r @[n --> \oo] --> (0:R) -> u --> (0:R). + maxr (u n) r @[n --> \oo] --> 0 -> u n @[n --> \oo] --> 0. Proof. -rewrite -[in r < _]oppr0 ltr_oppr => r0 u0. +rewrite -[in r < _]oppr0 ltrNr => r0 u0. under eq_fun do rewrite -(opprK (u _)) -[in maxr _ _](opprK r) -oppr_min. rewrite -[in _ --> _]oppr0 => /cvgNP/minr_cvg_0_cvg_0-/(_ r0). -have Nu0 k : 0 <= - u k by rewrite ler_oppr oppr0. +have Nu0 k : 0 <= - u k by rewrite lerNr oppr0. by move=> /(_ Nu0)/(cvgNP _ _).2; rewrite opprK oppr0. Qed. @@ -2102,7 +2120,7 @@ Unshelve. all: by end_near. Qed. Lemma mine_cvg_minr_cvg u r : (0 < r)%R -> (forall k, 0 <= u k) -> mine (u n) r%:E @[n --> \oo] --> 0 -> - minr (fine (u n)) r @[n --> \oo] --> (0:R)%R. + minr (fine (u n)) r @[n --> \oo] --> 0%R. Proof. move=> r0 u0 mine_cvg; apply: (cvg_trans _ (fine_cvg mine_cvg)). move/fine_cvgP : mine_cvg => [_ /=] /cvgrPdist_lt. @@ -2115,7 +2133,7 @@ by rewrite /= -(@fineK _ (u n)) ?ge0_fin_numE//= -fine_min. Unshelve. all: by end_near. Qed. Lemma mine_cvg_0_cvg_0 u x : 0 < x -> (forall k, 0 <= u k) -> - mine (u n) x @[n --> \oo] --> 0 -> u --> 0. + mine (u n) x @[n --> \oo] --> 0 -> u n @[n --> \oo] --> 0. Proof. move=> x0 u0 h; apply/fine_cvgP; split. exact: (mine_cvg_0_cvg_fin_num x0). @@ -2140,9 +2158,9 @@ Qed. Lemma maxe_cvg_maxr_cvg u r : (r < 0)%R -> (forall k, u k <= 0) -> maxe (u n) r%:E @[n --> \oo] --> 0 -> - maxr (fine (u n)) r @[n --> \oo] --> (0:R)%R. + maxr (fine (u n)) r @[n --> \oo] --> 0%R. Proof. -rewrite -[in (r < _)%R]oppr0 ltr_oppr => r0 u0. +rewrite -[in (r < _)%R]oppr0 ltrNr => r0 u0. under eq_fun do rewrite -(oppeK (u _)) -[in maxe _ _](oppeK r%:E) -oppe_min. rewrite -[in _ --> _]oppe0 => /cvgeNP/mine_cvg_minr_cvg-/(_ r0). have Nu0 k : 0 <= - u k by rewrite lee_oppr oppe0. @@ -2151,7 +2169,7 @@ by under eq_cvg do rewrite /GRing.opp /= oppr_min fineN !opprK. Qed. Lemma maxe_cvg_0_cvg_0 u x : x < 0 -> (forall k, u k <= 0) -> - maxe (u n) x @[n --> \oo] --> 0 -> u --> 0. + maxe (u n) x @[n --> \oo] --> 0 -> u n @[n --> \oo] --> 0. Proof. rewrite -[in x < _]oppe0 lte_oppr => x0 u0. under eq_fun do rewrite -(oppeK (u _)) -[in maxe _ _](oppeK x) -oppe_min. @@ -2219,24 +2237,23 @@ move=> u_lb; rewrite -nonincreasing_opp -supsN; apply/nonincreasing_sups. by move: u_lb => /has_lb_ubN; rewrite /comp /= image_comp. Qed. -Lemma is_cvg_sups u : cvg u -> cvg (sups u). +Lemma is_cvg_sups u : cvgn u -> cvgn (sups u). Proof. move=> cf; have [M [Mreal Mu]] := cvg_seq_bounded cf. apply: nonincreasing_is_cvgn. exact/nonincreasing_sups/bounded_fun_has_ubound/cvg_seq_bounded. exists (- (M + 1)) => _ [n _ <-]; rewrite (@le_trans _ _ (u n)) //. - by apply/lerNnormlW/Mu => //; rewrite ltr_addl. + by apply/lerNnormlW/Mu => //; rewrite ltrDl. apply: sup_ub; last by exists n => /=. exact/has_ubound_sdrop/bounded_fun_has_ubound/cvg_seq_bounded. Qed. -Lemma is_cvg_infs u : cvg u -> cvg (infs u). +Lemma is_cvg_infs u : cvgn u -> cvgn (infs u). Proof. -move/is_cvgN/is_cvg_sups; rewrite supsN. -by move/(@is_cvgN _ [normedModType R of R^o]); rewrite opprK. +by move/is_cvgN/is_cvg_sups; rewrite supsN; move/is_cvgN; rewrite opprK. Qed. -Lemma infs_le_sups u n : cvg u -> infs u n <= sups u n. +Lemma infs_le_sups u n : cvgn u -> infs u n <= sups u n. Proof. move=> cu; rewrite /infs /sups /=; set A := sdrop _ _. have [a Aa] : A !=set0 by exists (u n); rewrite /A /=; exists n => //=. @@ -2246,7 +2263,7 @@ rewrite (@le_trans _ _ a) //; [apply/inf_lb|apply/sup_ub] => //. Qed. Lemma cvg_sups_inf u : has_ubound (range u) -> has_lbound (range u) -> - sups u --> inf (range (sups u)). + sups u @ \oo --> inf (range (sups u)). Proof. move=> u_ub u_lb; apply: nonincreasing_cvgn; first exact: nonincreasing_sups. case: u_lb => M uM; exists M => _ [n _ <-]. @@ -2255,16 +2272,15 @@ by apply: sup_ub; [exact/has_ubound_sdrop|exists n => /=]. Qed. Lemma cvg_infs_sup u : has_ubound (range u) -> has_lbound (range u) -> - infs u --> sup (range (infs u)). + infs u @ \oo --> sup (range (infs u)). Proof. -move=> u_ub u_lb; have : sups (- u) --> inf (range (sups (- u))). +move=> u_ub u_lb; have : sups (- u) @ \oo --> inf (range (sups (- u))). apply: cvg_sups_inf. - by move: u_lb => /has_lb_ubN; rewrite image_comp. - by move: u_ub => /has_ub_lbN; rewrite image_comp. rewrite /inf => /(@cvg_comp _ _ _ _ (fun x => - x)). rewrite supsN /comp /= -[in X in _ -> X --> _](opprK (infs u)); apply. -rewrite image_comp /comp /= -(opprK (sup (range (infs u)))). -apply: (@cvgN _ [normedModType R of R^o]). +rewrite image_comp /comp /= -(opprK (sup (range (infs u)))); apply: cvgN. by rewrite (_ : [set _ | _ in setT] = (range (infs u))) // opprK. Qed. @@ -2325,44 +2341,43 @@ Section limn_sup_limn_inf. Variable R : realType. Implicit Types (r : R) (u v : R^o^nat). -Definition limn_sup u := lim (sups u). +Definition limn_sup u := limn (sups u). -Definition limn_inf u := lim (infs u). +Definition limn_inf u := limn (infs u). -Lemma limn_infN u : cvg u -> limn_inf (-%R \o u) = - limn_sup u. +Lemma limn_infN u : cvgn u -> limn_inf (-%R \o u) = - limn_sup u. Proof. -move=> cu_; rewrite /limn_inf infsN. -rewrite (@limN _ [normedModType R of R^o] _ _ _ (sups u)) //. -exact: is_cvg_sups. +by move=> cu_; rewrite /limn_inf infsN limN//; exact: is_cvg_sups. Qed. Lemma limn_supE u : bounded_fun u -> limn_sup u = inf (range (sups u)). Proof. -move=> ba; apply/cvg_lim; first exact: Rhausdorff. +move=> ba; apply/cvg_lim => //. by apply/cvg_sups_inf; [exact/bounded_fun_has_ubound| exact/bounded_fun_has_lbound]. Qed. Lemma limn_infE u : bounded_fun u -> limn_inf u = sup (range (infs u)). Proof. -move=> ba; apply/cvg_lim; first exact: Rhausdorff. +move=> ba; apply/cvg_lim => //. by apply/cvg_infs_sup; [exact/bounded_fun_has_ubound| exact/bounded_fun_has_lbound]. Qed. -Lemma limn_inf_sup u : cvg u -> limn_inf u <= limn_sup u. +Lemma limn_inf_sup u : cvgn u -> limn_inf u <= limn_sup u. Proof. move=> cf_; apply: ler_lim; [exact: is_cvg_infs|exact: is_cvg_sups|]. by apply: nearW => n; apply: infs_le_sups. Qed. -Lemma cvg_limn_inf_sup u l : u --> l -> (limn_inf u = l) * (limn_sup u = l). +Lemma cvg_limn_inf_sup u l : u @ \oo --> l -> (limn_inf u = l) * (limn_sup u = l). Proof. move=> ul. -have /cvg_seq_bounded [M [Mr Mu]] : cvg u by apply/cvg_ex; eexists; exact: ul. +have /cvg_seq_bounded [M [Mr Mu]] : cvg (u @ \oo) + by apply/cvg_ex; eexists; exact: ul. suff: limn_sup u <= l <= limn_inf u. move=> /andP[sul liu]. - have /limn_inf_sup iusu : cvg u by apply/cvg_ex; eexists; exact: ul. + have /limn_inf_sup iusu : cvg (u @ \oo) by apply/cvg_ex; eexists; exact: ul. split; first by apply/eqP; rewrite eq_le liu andbT (le_trans iusu). by apply/eqP; rewrite eq_le sul /= (le_trans _ iusu). apply/andP; split. @@ -2371,37 +2386,37 @@ apply/andP; split. move/cvgrPdist_lt : (ul) => /(_ _ e0) -[k _ klu]. near=> n; have kn : (k <= n)%N by near: n; exists k. apply: sup_le_ub; first by exists (u n) => /=; exists n => //=. - move=> _ /= [m nm] <-; apply/ltW/ltr_distl_addr; rewrite distrC. + move=> _ /= [m nm] <-; apply/ltW/ltr_distlDr; rewrite distrC. by apply: (klu m) => /=; rewrite (leq_trans kn). -- apply/ler_addgt0Pr => e e0; rewrite -ler_subl_addr. +- apply/ler_addgt0Pr => e e0; rewrite -lerBlDr. apply: limr_ge; first by apply: is_cvg_infs; apply/cvg_ex; exists l. move/cvgrPdist_lt : (ul) => /(_ _ e0) -[k _ klu]. - near=> n; have kn: (k <= n)%N by near: n; exists k. + near=> n; have kn : (k <= n)%N by near: n; exists k. apply: lb_le_inf; first by exists (u n) => /=; exists n => //=. - move=> _ /= [m nm] <-; apply/ltW/ltr_distl_subl. + move=> _ /= [m nm] <-; apply/ltW/ltr_distlBl. by apply: (klu m) => /=; rewrite (leq_trans kn). Unshelve. all: by end_near. Qed. -Lemma cvg_limn_infE u : cvg u -> limn_inf u = lim u. +Lemma cvg_limn_infE u : cvgn u -> limn_inf u = limn u. Proof. move=> /cvg_ex[l ul]; have [-> _] := cvg_limn_inf_sup ul. by move/cvg_lim : ul => ->. Qed. -Lemma cvg_limn_supE u : cvg u -> limn_sup u = lim u. +Lemma cvg_limn_supE u : cvgn u -> limn_sup u = limn u. Proof. move=> /cvg_ex[l ul]; have [_ ->] := cvg_limn_inf_sup ul. by move/cvg_lim : ul => ->. Qed. -Lemma cvg_sups u l : u --> l -> sups u --> (l : R^o). +Lemma cvg_sups u l : u @ \oo --> l -> sups u @ \oo --> (l : R^o). Proof. move=> ul; have [iul <-] := cvg_limn_inf_sup ul. apply/cvg_closeP; split => //; apply: is_cvg_sups. by apply/cvg_ex; eexists; apply: ul. Qed. -Lemma cvg_infs u l : u --> l -> infs u --> (l : R^o). +Lemma cvg_infs u l : u @ \oo --> l -> infs u @ \oo --> (l : R^o). Proof. move=> ul; have [<- iul] := cvg_limn_inf_sup ul. apply/cvg_closeP; split => //; apply: is_cvg_infs. @@ -2413,20 +2428,20 @@ Lemma le_limn_supD u v : bounded_fun u -> bounded_fun v -> Proof. move=> ba bb; have ab k : sups (u \+ v) k <= sups u k + sups v k. apply: sup_le_ub; first by exists ((u \+ v) k); exists k => /=. - by move=> M [n /= kn <-]; apply: ler_add; apply: sup_ub; [ + by move=> M [n /= kn <-]; apply: lerD; apply: sup_ub; [ exact/has_ubound_sdrop/bounded_fun_has_ubound; exact | exists n | exact/has_ubound_sdrop/bounded_fun_has_ubound; exact | exists n ]. -have cu : cvg (sups u). +have cu : cvgn (sups u). apply: nonincreasing_is_cvgn; last exact: bounded_fun_has_lbound_sups. exact/nonincreasing_sups/bounded_fun_has_ubound. -have cv : cvg (sups v). +have cv : cvgn (sups v). apply: nonincreasing_is_cvgn; last exact: bounded_fun_has_lbound_sups. exact/nonincreasing_sups/bounded_fun_has_ubound. -rewrite -(@limD _ [normedModType R of R^o] _ _ _ _ _ cu cv); apply: ler_lim. +rewrite -(limD cu cv); apply: ler_lim. - apply: nonincreasing_is_cvgn; last first. exact/bounded_fun_has_lbound_sups/bounded_funD. exact/nonincreasing_sups/bounded_fun_has_ubound/bounded_funD. -- exact: (@is_cvgD _ [normedModType R of R^o] _ _ _ _ _ cu cv). +- exact: is_cvgD cu cv. - exact: nearW. Qed. @@ -2435,7 +2450,7 @@ Lemma le_limn_infD u v : bounded_fun u -> bounded_fun v -> Proof. move=> ba bb; have ab k : infs u k + infs v k <= infs (u \+ v) k. apply: lb_le_inf; first by exists ((u \+ v) k); exists k => /=. - by move=> M [n /= kn <-]; apply: ler_add; apply: inf_lb; [ + by move=> M [n /= kn <-]; apply: lerD; apply: inf_lb; [ exact/has_lbound_sdrop/bounded_fun_has_lbound; exact | exists n | exact/has_lbound_sdrop/bounded_fun_has_lbound; exact | exists n ]. have cu : cvg (infs u). @@ -2452,19 +2467,19 @@ rewrite -(@limD _ [normedModType R of R^o] _ _ _ _ _ cu cv); apply: ler_lim. - exact: nearW. Qed. -Lemma limn_supD u v : cvg u -> cvg v -> +Lemma limn_supD u v : cvgn u -> cvgn v -> limn_sup (u \+ v) = limn_sup u + limn_sup v. Proof. move=> cu cv; have [ba bb] := (cvg_seq_bounded cu, cvg_seq_bounded cv). apply/eqP; rewrite eq_le le_limn_supD //=. have := @le_limn_supD _ _ (bounded_funD ba bb) (bounded_funN bb). -rewrite -ler_subl_addr; apply: le_trans. +rewrite -lerBlDr; apply: le_trans. rewrite -[_ \+ _]/(u + v - v) addrK -limn_infN; last exact: is_cvgN. rewrite /comp /=; under eq_fun do rewrite opprK. -by rewrite ler_add// cvg_limn_infE// cvg_limn_supE. +by rewrite lerD// cvg_limn_infE// cvg_limn_supE. Qed. -Lemma limn_infD u v : cvg u -> cvg v -> +Lemma limn_infD u v : cvgn u -> cvgn v -> limn_inf (u \+ v) = limn_inf u + limn_inf v. Proof. move=> cu cv; rewrite (cvg_limn_infE cu) -(cvg_limn_supE cu). @@ -2541,16 +2556,16 @@ rewrite /einfs /=; set A := sdrop _ _; have [a Aa] : A !=set0. by rewrite (@le_trans _ _ a) //; [exact/ereal_inf_lb|exact/ereal_sup_ub]. Unshelve. all: by end_near. Qed. -Lemma cvg_esups_inf u : esups u --> ereal_inf (range (esups u)). +Lemma cvg_esups_inf u : esups u @ \oo --> ereal_inf (range (esups u)). Proof. by apply: ereal_nonincreasing_cvgn => //; exact: nonincreasing_esups. Qed. -Lemma is_cvg_esups u : cvg (esups u). +Lemma is_cvg_esups u : cvgn (esups u). Proof. by apply/cvg_ex; eexists; exact/cvg_esups_inf. Qed. -Lemma cvg_einfs_sup u : einfs u --> ereal_sup (range (einfs u)). +Lemma cvg_einfs_sup u : einfs u @ \oo --> ereal_sup (range (einfs u)). Proof. by apply: ereal_nondecreasing_cvgn => //; exact: nondecreasing_einfs. Qed. -Lemma is_cvg_einfs u : cvg (einfs u). +Lemma is_cvg_einfs u : cvgn (einfs u). Proof. by apply/cvg_ex; eexists; exact/cvg_einfs_sup. Qed. Lemma esups_preimage T (a : \bar R) (f : (T -> \bar R)^nat) n : @@ -2587,7 +2602,7 @@ Definition limn_esup u := limf_esup u \oo. Definition limn_einf u := - limn_esup (\- u). -Lemma limn_esup_lim u : limn_esup u = lim (esups u). +Lemma limn_esup_lim u : limn_esup u = limn (esups u). Proof. apply/eqP; rewrite eq_le; apply/andP; split. apply: lime_ge; first exact: is_cvg_esups. @@ -2600,7 +2615,7 @@ exists n => //; apply: rA => //=; apply: leq_trans mn. by near: m; exists r. Unshelve. all: by end_near. Qed. -Lemma limn_einf_lim u : limn_einf u = lim (einfs u). +Lemma limn_einf_lim u : limn_einf u = limn (einfs u). Proof. rewrite /limn_einf limn_esup_lim esupsN -limeN//. by under eq_fun do rewrite oppeK. @@ -2617,10 +2632,11 @@ Implicit Types (u v : (\bar R)^nat) (l : \bar R). Lemma limn_einf_shift u l : l \is a fin_num -> limn_einf (fun x => l + u x) = l + limn_einf u. Proof. -move=> lfin; rewrite !limn_einf_lim; apply/cvg_lim => //. -apply: cvg_trans; last first. - by apply: (@cvgeD _ \oo _ _ (cst l) (einfs u) _ (lim (einfs u))); - [exact: fin_num_adde_defr|exact: cvg_cst|exact: is_cvg_einfs]. +move=> lfin; rewrite !limn_einf_lim; apply/cvg_lim => //; apply: cvg_trans; last first. + apply: (@cvgeD _ \oo _ _ (cst l) (einfs u) _ (limn (einfs u))). + - by rewrite fin_num_adde_defr. + - exact: cvg_cst. + - exact: is_cvg_einfs. suff : einfs (fun n => l + u n) = (fun n => l + einfs u n) by move=> ->. rewrite funeqE => n. apply/eqP; rewrite eq_le; apply/andP; split. @@ -2631,12 +2647,12 @@ apply/eqP; rewrite eq_le; apply/andP; split. by rewrite lee_add2l//; apply: ereal_inf_lb; exists m => /=. Qed. -Lemma limn_esup_le_cvg u l : - limn_esup u <= l -> (forall n, l <= u n) -> u --> l. +Lemma limn_esup_le_cvg u l : limn_esup u <= l -> (forall n, l <= u n) -> + u @ \oo --> l. Proof. move=> supul ul; have usupu n : l <= u n <= esups u n. by rewrite ul /=; apply/ereal_sup_ub; exists n => /=. -suff : esups u --> l. +suff : esups u @ \oo --> l. by apply: (@squeeze_cvge _ _ _ _ (cst l)) => //; [exact: nearW|exact: cvg_cst]. apply/cvg_closeP; split; first exact: is_cvg_esups. rewrite closeE//; apply/eqP. @@ -2659,7 +2675,7 @@ apply: lee_lim; [exact/is_cvg_einfs|exact/is_cvg_esups|]. by apply: nearW; exact: einfs_le_esups. Qed. -Lemma cvgNy_limn_einf_sup u : u --> -oo -> +Lemma cvgNy_limn_einf_sup u : u @ \oo --> -oo -> (limn_einf u = -oo) * (limn_esup u = -oo). Proof. move=> uoo; suff: limn_esup u = -oo. @@ -2670,38 +2686,38 @@ near=> n; apply: ub_ereal_sup => _ [k /= nk <-]. by apply: uM => /=; rewrite (leq_trans _ nk)//; near: n; exists m. Unshelve. all: by end_near. Qed. -Lemma cvgNy_einfs u : u --> -oo -> einfs u --> -oo. +Lemma cvgNy_einfs u : u @ \oo --> -oo -> einfs u @ \oo --> -oo. Proof. move=> /cvgNy_limn_einf_sup[uoo _]. apply/cvg_closeP; split; [exact: is_cvg_einfs|rewrite closeE//]. by rewrite -limn_einf_lim. Qed. -Lemma cvgNy_esups u : u --> -oo -> esups u --> -oo. +Lemma cvgNy_esups u : u @ \oo --> -oo -> esups u @ \oo --> -oo. Proof. move=> /cvgNy_limn_einf_sup[_ uoo]; apply/cvg_closeP. by split; [exact: is_cvg_esups|rewrite closeE// -limn_esup_lim]. Qed. -Lemma cvgy_einfs u : u --> +oo -> einfs u --> +oo. +Lemma cvgy_einfs u : u @ \oo --> +oo -> einfs u @ \oo --> +oo. Proof. move=> /cvgeN/cvgNy_esups/cvgeN; rewrite esupsN. by under eq_cvg do rewrite /= oppeK. Qed. -Lemma cvgy_esups u : u --> +oo -> esups u --> +oo. +Lemma cvgy_esups u : u @ \oo --> +oo -> esups u @ \oo --> +oo. Proof. move=> /cvgeN/cvgNy_einfs/cvgeN; rewrite einfsN. by under eq_cvg do rewrite /= oppeK. Qed. -Lemma cvg_esups u l : u --> l -> esups u --> l. +Lemma cvg_esups u l : u @ \oo --> l -> esups u @ \oo --> l. Proof. case: l => [l /fine_cvgP[u_fin_num] ul| |]; last 2 first. - exact: cvgy_esups. - exact: cvgNy_esups. have [p _ pu] := u_fin_num; apply/cvg_ballP => _/posnumP[e]. -have : EFin \o sups (fine \o u) --> l%:E. +have : EFin \o sups (fine \o u) @ \oo --> l%:E. by apply: continuous_cvg => //; apply: cvg_sups. move=> /cvg_ballP /(_ e%:num (gt0 _))[q _ qsupsu]; near=> n. have -> : esups u n = (EFin \o sups (fine \o u)) n. @@ -2718,26 +2734,27 @@ have -> : esups u n = (EFin \o sups (fine \o u)) n. by apply: qsupsu => /=; near: n; exists q. Unshelve. all: by end_near. Qed. -Lemma cvg_einfs u l : u --> l -> einfs u --> l. +Lemma cvg_einfs u l : u @ \oo --> l -> einfs u @ \oo --> l. Proof. move=> /cvgeN/cvg_esups/cvgeN; rewrite oppeK esupsN. by under eq_cvg do rewrite /= oppeK. Qed. -Lemma cvg_limn_einf_sup u l : u --> l -> (limn_einf u = l) * (limn_esup u = l). +Lemma cvg_limn_einf_sup u l : u @ \oo --> l -> + (limn_einf u = l) * (limn_esup u = l). Proof. move=> ul; rewrite limn_esup_lim limn_einf_lim; split. - by apply/cvg_lim => //; exact/cvg_einfs. - by apply/cvg_lim => //; exact/cvg_esups. Qed. -Lemma is_cvg_limn_einfE u : cvg u -> limn_einf u = lim u. +Lemma is_cvg_limn_einfE u : cvgn u -> limn_einf u = limn u. Proof. move=> /cvg_ex[l ul]; have [-> _] := cvg_limn_einf_sup ul. by move/cvg_lim : ul => ->. Qed. -Lemma is_cvg_limn_esupE u : cvg u -> limn_esup u = lim u. +Lemma is_cvg_limn_esupE u : cvgn u -> limn_esup u = limn u. Proof. move=> /cvg_ex[l ul]; have [_ ->] := cvg_limn_einf_sup ul. by move/cvg_lim : ul => ->. @@ -2790,25 +2807,25 @@ Proof. by rewrite ?(invr_ge0, mulr_ge0, subr_ge0, ltW q1). Qed. Lemma contraction_dist n m : `|y n - y (n + m)| <= C * q%:num ^+ n. Proof. have f1 k : `|y k.+1 - y k| <= q%:num ^+ k * `|f base - base|. - elim: k => [|k /(ler_wpmul2l (ge0 q))]; first by rewrite expr0 mul1r. + elim: k => [|k /(ler_wpM2l (ge0 q))]; first by rewrite expr0 mul1r. rewrite mulrA -exprS; apply: le_trans. by rewrite (@ctrfq (y k.+1, y k)); split; exact: funS. have /le_trans -> // : `| y n - y (n + m)| <= series (geometric (`|f base - base| * q%:num ^+ n) q%:num) m. elim: m => [|m ih]. by rewrite geometric_seriesE ?lt_eqF//= addn0 subrr normr0 subrr mulr0 mul0r. - rewrite (le_trans (ler_dist_add (y (n + m)%N) _ _))//. - apply: (le_trans (ler_add ih _)); first by rewrite distrC addnS; exact: f1. + rewrite (le_trans (ler_distD (y (n + m)%N) _ _))//. + apply: (le_trans (lerD ih _)); first by rewrite distrC addnS; exact: f1. rewrite [_ * `|_|]mulrC exprD mulrA geometric_seriesE ?lt_eqF//=. rewrite -!/(`1-_) (onem_PosNum ctrf.1) (onemX_NngNum (ltW ctrf.1)). - rewrite -!mulrA -mulrDr ler_pmul// -mulrDr exprSr onemM -addrA. + rewrite -!mulrA -mulrDr ler_pM// -mulrDr exprSr onemM -addrA. rewrite -[in leRHS](mulrC _ `1-(_ ^+ m)) -onemMr onemK. by rewrite [in leRHS]mulrDl mulrAC mulrV ?mul1r// unitf_gt0// onem_gt0. rewrite geometric_seriesE ?lt_eqF//= -[leRHS]mulr1 (ACl (1*4*2*3))/= -/C. -by rewrite ler_wpmul2l// 1?mulr_ge0// ler_subl_addr ler_addl. +by rewrite ler_wpM2l// 1?mulr_ge0// lerBlDr lerDl. Qed. -Lemma contraction_cvg : cvg y. +Lemma contraction_cvg : cvgn y. Proof. apply/cauchy_cvgP; apply/cauchy_ballP => _/posnumP[e]; near_simpl. have lt_min n m : `|y n - y m| <= C * q%:num ^+ minn n m. @@ -2819,7 +2836,7 @@ case: ltrgt0P C_ge0 => // [Cpos|C0] _; last first. near=> n m => /=; rewrite -ball_normE. by apply: (le_lt_trans (lt_min _ _)); rewrite C0 mul0r. near=> n; rewrite -ball_normE /= (le_lt_trans (lt_min n.1 n.2)) //. -rewrite // -ltr_pdivl_mull //. +rewrite // -ltr_pdivlMl //. suff : ball 0 (C^-1 * e%:num) (q%:num ^+ minn n.1 n.2). by rewrite /ball /= sub0r normrN ger0_norm. near: n; rewrite nbhs_simpl. @@ -2834,10 +2851,10 @@ exists ([set n | N <= n], [set n | N <= n])%N; first by split; exists N. move=> [n m] [Nn Nm]; rewrite /ball /= sub0r normrN ger0_norm /g //. apply: le_lt_trans; last by apply: (Q N) => /=. rewrite sub0r normrN ger0_norm /geometric //= mul1r. -by rewrite ler_wiexpn2l // ?ltW // leq_min Nn. +by rewrite ler_wiXn2l // ?ltW // leq_min Nn. Unshelve. all: end_near. Qed. -Lemma contraction_cvg_fixed : closed U -> lim y = f (lim y). +Lemma contraction_cvg_fixed : closed U -> limn y = f (limn y). Proof. move=> clU; apply: cvg_lim => //. apply/cvgrPdist_lt => _/posnumP[e]; near_simpl; apply: near_inftyS. diff --git a/theories/signed.v b/theories/signed.v index 29a2faa55..a8959485e 100644 --- a/theories/signed.v +++ b/theories/signed.v @@ -1,4 +1,5 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +From HB Require Import structures. From Coq Require Import ssreflect ssrfun ssrbool. From mathcomp Require Import ssrnat eqtype choice order ssralg ssrnum ssrint. From mathcomp Require Import mathcomp_extra. @@ -330,13 +331,8 @@ Export Signed.Exports. Section POrder. Variables (d : unit) (T : porderType d) (x0 : T) (nz : nullity) (cond : reality). Local Notation sT := {compare x0 & nz & cond}. -Canonical signed_subType := [subType for @Signed.r d T x0 nz cond]. -Definition signed_eqMixin := [eqMixin of sT by <:]. -Canonical signed_eqType := EqType sT signed_eqMixin. -Definition signed_choiceMixin := [choiceMixin of sT by <:]. -Canonical signed_choiceType := ChoiceType sT signed_choiceMixin. -Definition signed_porderMixin := [porderMixin of sT by <:]. -Canonical signed_porderType := POrderType d sT signed_porderMixin. +HB.instance Definition _ := [isSub for @Signed.r d T x0 nz cond]. +HB.instance Definition _ : Order.POrder d sT := [POrder of sT by <:]. End POrder. Lemma top_typ_subproof d (T : porderType d) (x0 x : T) : @@ -553,12 +549,11 @@ Section Order. Variables (R : numDomainType) (nz : nullity) (r : real). Local Notation nR := {num R & nz & r}. -Lemma signed_le_total : totalPOrderMixin [porderType of nR]. +Lemma signed_le_total : total (<=%O : rel nR). Proof. by move=> x y; apply: real_comparable => /=. Qed. -Canonical signed_latticeType := LatticeType nR signed_le_total. -Canonical signed_distrLatticeType := DistrLatticeType nR signed_le_total. -Canonical signed_orderType := OrderType nR signed_le_total. +HB.instance Definition _ := Order.POrder_isTotal.Build ring_display nR + signed_le_total. End Order. @@ -751,7 +746,7 @@ Proof. rewrite {}/rnz {}/rrl; apply/andP; split. move: xr yr xnz ynz x y => [[[]|]|] [[[]|]|] [] []//= x y; by rewrite 1?addr_ss_eq0 ?(eq0F, ge0, le0, andbF, orbT). -have addr_le0 a b : a <= 0 -> b <= 0 -> a + b <= 0. +have addr_le0 (a b : R) : a <= 0 -> b <= 0 -> a + b <= 0. by rewrite -!oppr_ge0 opprD; apply: addr_ge0. move: xr yr xnz ynz x y => [[[]|]|] [[[]|]|] [] []//= x y; do ?[by rewrite addr_ge0|by rewrite addr_le0|by rewrite -realE realD diff --git a/theories/summability.v b/theories/summability.v index d86502b9e..09915bb10 100644 --- a/theories/summability.v +++ b/theories/summability.v @@ -1,4 +1,5 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +From HB Require Import structures. Require Reals. From mathcomp Require Import all_ssreflect ssralg ssrint ssrnum finmap matrix. From mathcomp Require Import interval zmodp. @@ -26,12 +27,9 @@ Import fintype bigop finmap. Local Open Scope fset_scope. (* :TODO: when eventually is generalized to any lattice *) (* totally can just be replaced by eventually *) -Definition totally {I : choiceType} : set (set {fset I}) := +Definition totally {I : choiceType} : set_system {fset I} := filter_from setT (fun A => [set B | A `<=` B]). -Canonical totally_filter_source {I : choiceType} X := - @Filtered.Source X _ {fset I} (fun f => f @ totally). - Instance totally_filter {I : choiceType} : ProperFilter (@totally I). Proof. eapply filter_from_proper; last by move=> A _; exists A; rewrite /= fsubset_refl. @@ -43,7 +41,7 @@ Definition partial_sum {I : choiceType} {R : zmodType} (x : I -> R) (A : {fset I}) : R := \sum_(i : A) x (val i). Definition sum (I : choiceType) {K : numDomainType} {R : normedModType K} - (x : I -> R) : R := lim (partial_sum x). + (x : I -> R) : R := lim (partial_sum x @ totally). Definition summable (I : choiceType) {K : realType} {R : normedModType K} (x : I -> R) := diff --git a/theories/topology.v b/theories/topology.v index 4e95029c6..643442b76 100644 --- a/theories/topology.v +++ b/theories/topology.v @@ -1,4 +1,5 @@ (* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) +From HB Require Import structures. From mathcomp Require Import all_ssreflect all_algebra finmap generic_quotient. From mathcomp Require Import boolp classical_sets functions. From mathcomp Require Import cardinality mathcomp_extra fsbigop. @@ -295,6 +296,8 @@ Require Import reals signed. (* locally_compact A == every point in A has a compact *) (* (and closed) neighborhood *) (* discrete_space T <-> every nbhs is a principal filter *) +(* discrete_topology dscT == the discrete topology on T, provided *) +(* dscT : discrete space T *) (* finite_subset_cover D F A == the family of sets F is a cover of A *) (* for a finite number of indices in D *) (* cover_compact == set of compact sets w.r.t. the open *) @@ -391,7 +394,6 @@ Require Import reals signed. (* - matrices: matrix_pseudoMetricType *) (* - weak_pseudoMetricType (the metric space for weak topologies) *) (* - sup_pseudoMetricType *) -(* - product_pseudoMetricType *) (* *) (* ### Complete uniform spaces *) (* ``` *) @@ -530,6 +532,8 @@ Reserved Notation "[ 'cvg' F 'in' T ]" (format "[ 'cvg' F 'in' T ]"). Reserved Notation "x \is_near F" (at level 10, format "x \is_near F"). Reserved Notation "E @[ x --> F ]" (at level 60, x name, format "E @[ x --> F ]"). +Reserved Notation "E @[ x \oo ]" + (at level 60, x name, format "E @[ x \oo ]"). Reserved Notation "f @ F" (at level 60, format "f @ F"). Reserved Notation "E `@[ x --> F ]" (at level 60, x name, format "E `@[ x --> F ]"). @@ -648,101 +652,61 @@ Qed. Section Linear1. Context (R : ringType) (U : lmodType R) (V : zmodType) (s : R -> V -> V). -Canonical linear_eqType := EqType {linear U -> V | s} gen_eqMixin. -Canonical linear_choiceType := ChoiceType {linear U -> V | s} gen_choiceMixin. +HB.instance Definition _ := gen_eqMixin {linear U -> V | s}. +HB.instance Definition _ := gen_choiceMixin {linear U -> V | s}. End Linear1. Section Linear2. -Context (R : ringType) (U : lmodType R) (V : zmodType) (s : R -> V -> V) - (s_law : GRing.Scale.law s). -Canonical linear_pointedType := PointedType {linear U -> V | GRing.Scale.op s_law} - (@GRing.null_fun_linear R U V s s_law). +Context (R : ringType) (U : lmodType R) (V : zmodType) (s : GRing.Scale.law R V). +HB.instance Definition _ := + isPointed.Build {linear U -> V | GRing.Scale.Law.sort s} \0. End Linear2. -Module Filtered. +Definition set_system U := set (set U). +Identity Coercion set_system_to_set : set_system >-> set. -(* Index a family of filters on a type, one for each element of the type *) -Definition nbhs_of U T := T -> set (set U). -Record class_of U T := Class { - base : Pointed.class_of T; - nbhs_op : nbhs_of U T +HB.mixin Record isFiltered U T := { + nbhs : T -> set_system U }. -Section ClassDef. -Variable U : Type. +#[short(type="filteredType")] +HB.structure Definition Filtered (U : Type) := {T of Pointed T & isFiltered U T}. +Arguments nbhs {_ _} _ _ : simpl never. -Structure type := Pack { sort; _ : class_of U sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of U cT in c. - -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of U xT). -Local Coercion base : class_of >-> Pointed.class_of. - -Definition pack m := - fun bT b of phant_id (Pointed.class bT) b => @Pack T (Class b m). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition fpointedType := @Pointed.Pack cT xclass. +Notation "[ 'filteredType' U 'of' T ]" := (Filtered.clone U T _) + (at level 0, format "[ 'filteredType' U 'of' T ]") : form_scope. -End ClassDef. +HB.instance Definition _ T := Equality.on (set_system T). +HB.instance Definition _ T := Choice.on (set_system T). +HB.instance Definition _ T := Pointed.on (set_system T). +HB.instance Definition _ T := isFiltered.Build T (set_system T) id. -(* filter on arrow sources *) -Structure source Z Y := Source { - source_type :> Type; - _ : (source_type -> Z) -> set (set Y) -}. -Definition source_filter Z Y (F : source Z Y) : (F -> Z) -> set (set Y) := - let: Source X f := F in f. - -Module Exports. -Coercion sort : type >-> Sortclass. -Coercion base : class_of >-> Pointed.class_of. -Coercion nbhs_op : class_of >-> nbhs_of. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion fpointedType : type >-> Pointed.type. -Canonical fpointedType. -Notation filteredType := type. -Notation FilteredType U T m := (@pack U T m _ _ idfun). -Notation "[ 'filteredType' U 'of' T 'for' cT ]" := (@clone U T cT _ idfun) - (at level 0, format "[ 'filteredType' U 'of' T 'for' cT ]") : form_scope. -Notation "[ 'filteredType' U 'of' T ]" := (@clone U T _ _ id) - (at level 0, format "[ 'filteredType' U 'of' T ]") : form_scope. +Arguments nbhs {_ _} _ _ : simpl never. -(* The default filter for an arbitrary element is the one obtained *) -(* from its type *) -Canonical default_arrow_filter Y (Z : pointedType) (X : source Z Y) := - FilteredType Y (X -> Z) (@source_filter _ _ X). -Canonical source_filter_filter Y := - @Source Prop _ (_ -> Prop) (fun x : (set (set Y)) => x). -Canonical source_filter_filter' Y := - @Source Prop _ (set _) (fun x : (set (set Y)) => x). +HB.mixin Record selfFiltered T := {}. -End Exports. -End Filtered. -Export Filtered.Exports. +HB.factory Record hasNbhs T := { nbhs : T -> set_system T }. +HB.builders Context T of hasNbhs T. + HB.instance Definition _ := isFiltered.Build T T nbhs. + HB.instance Definition _ := selfFiltered.Build T. +HB.end. -Definition nbhs {U} {T : filteredType U} : T -> set (set U) := - Filtered.nbhs_op (Filtered.class T). -Arguments nbhs {U T} _ _ : simpl never. +#[short(type="nbhsType")] +HB.structure Definition Nbhs := {T of Pointed T & hasNbhs T}. -Definition filter_from {I T : Type} (D : set I) (B : I -> set T) : set (set T) := - [set P | exists2 i, D i & B i `<=` P]. +Definition filter_from {I T : Type} (D : set I) (B : I -> set T) : + set_system T := [set P | exists2 i, D i & B i `<=` P]. (* the canonical filter on matrices on X is the product of the canonical filter on X *) -Canonical matrix_filtered m n X (Z : filteredType X) : filteredType 'M[X]_(m, n) := - FilteredType 'M[X]_(m, n) 'M[Z]_(m, n) (fun mx => filter_from +HB.instance Definition _ m n X (Z : filteredType X) := + isFiltered.Build 'M[X]_(m, n) 'M[Z]_(m, n) (fun mx => filter_from [set P | forall i j, nbhs (mx i j) (P i j)] (fun P => [set my : 'M[X]_(m, n) | forall i j, P i j (my i j)])). +HB.instance Definition _ m n (X : nbhsType) := selfFiltered.Build 'M[X]_(m, n). + Definition filter_prod {T U : Type} - (F : set (set T)) (G : set (set U)) : set (set (T * U)) := + (F : set_system T) (G : set_system U) : set_system (T * U) := filter_from (fun P => F P.1 /\ G P.2) (fun P => P.1 `*` P.2). Section Near. @@ -774,58 +738,62 @@ Notation "'\near' x & y , P" := (\forall x \near x & y \near y, P) : type_scope. Arguments prop_near1 : simpl never. Arguments prop_near2 : simpl never. -Lemma nearE {T} {F : set (set T)} (P : set T) : (\forall x \near F, P x) = F P. +Lemma nearE {T} {F : set_system T} (P : set T) : + (\forall x \near F, P x) = F P. Proof. by []. Qed. -Lemma eq_near {T} {F : set (set T)} (P Q : set T) : +Lemma eq_near {T} {F : set_system T} (P Q : set T) : (forall x, P x <-> Q x) -> (\forall x \near F, P x) = (\forall x \near F, Q x). Proof. by move=> /predeqP ->. Qed. -Definition filter_of X (fX : filteredType X) (x : fX) of phantom fX x := - nbhs x. -Notation "[ 'filter' 'of' x ]" := - (@filter_of _ _ _ (Phantom _ x)) : classical_set_scope. -Arguments filter_of _ _ _ _ _ /. - -Lemma filter_of_filterE {T : Type} (F : set (set T)) : [filter of F] = F. -Proof. by []. Qed. +(* Definition filter_of X (fX : filteredType X) (x : fX) of phantom fX x := *) +(* nbhs x. *) +(* Notation "[ 'filter' 'of' x ]" := *) +(* (@filter_of _ _ _ (Phantom _ x)) : classical_set_scope. *) +(* Arguments filter_of _ _ _ _ _ /. *) -Lemma nbhs_filterE {T : Type} (F : set (set T)) : nbhs F = F. +Lemma nbhs_filterE {T : Type} (F : set_system T) : nbhs F = F. Proof. by []. Qed. Module Export NbhsFilter. -Definition nbhs_simpl := (@filter_of_filterE, @nbhs_filterE). +Definition nbhs_simpl := (@nbhs_filterE). End NbhsFilter. -Definition cvg_to {T : Type} (F G : set (set T)) := G `<=` F. +Definition cvg_to {T : Type} (F G : set_system T) := G `<=` F. Notation "F `=>` G" := (cvg_to F G) : classical_set_scope. -Lemma cvg_refl T (F : set (set T)) : F `=>` F. +Lemma cvg_refl T (F : set_system T) : F `=>` F. Proof. exact. Qed. Arguments cvg_refl {T F}. #[global] Hint Resolve cvg_refl : core. -Lemma cvg_trans T (G F H : set (set T)) : +Lemma cvg_trans T (G F H : set_system T) : (F `=>` G) -> (G `=>` H) -> (F `=>` H). Proof. by move=> FG GH P /GH /FG. Qed. -Notation "F --> G" := (cvg_to [filter of F] [filter of G]) : classical_set_scope. -Definition type_of_filter {T} (F : set (set T)) := T. +Notation "F --> G" := (cvg_to (nbhs F) (nbhs G)) : classical_set_scope. +Definition type_of_filter {T} (F : set_system T) := T. Definition lim_in {U : Type} (T : filteredType U) := - fun F : set (set U) => get (fun l : T => F --> l). -Notation "[ 'lim' F 'in' T ]" := (@lim_in _ T [filter of F]) : classical_set_scope. -Notation lim F := [lim F in [filteredType _ of @type_of_filter _ [filter of F]]]. + fun F : set_system U => get (fun l : T => F --> l). +Notation "[ 'lim' F 'in' T ]" := (@lim_in _ T (nbhs F)) : classical_set_scope. +Definition lim {T : nbhsType} (F : set_system T) := [lim F in T]. Notation "[ 'cvg' F 'in' T ]" := (F --> [lim F in T]) : classical_set_scope. -Notation cvg F := [cvg F in [filteredType _ of @type_of_filter _ [filter of F]]]. +Notation cvg F := (F --> lim F). + +(* :TODO: ultimately nat could be replaced by any lattice *) +Definition eventually := filter_from setT (fun N => [set n | (N <= n)%N]). +Notation "'\oo'" := eventually : classical_set_scope. Section FilteredTheory. -Canonical filtered_prod X1 X2 (Z1 : filteredType X1) - (Z2 : filteredType X2) : filteredType (X1 * X2) := - FilteredType (X1 * X2) (Z1 * Z2) +HB.instance Definition _ X1 X2 (Z1 : filteredType X1) (Z2 : filteredType X2) := + isFiltered.Build (X1 * X2)%type (Z1 * Z2)%type (fun x => filter_prod (nbhs x.1) (nbhs x.2)). +HB.instance Definition _ (X1 X2 : nbhsType) := + selfFiltered.Build (X1 * X2)%type. + Lemma cvg_prod T {U U' V V' : filteredType T} (x : U) (l : U') (y : V) (k : V') : x --> l -> y --> k -> (x, y) --> (l, k). Proof. @@ -833,29 +801,48 @@ move=> xl yk X [[X1 X2] /= [HX1 HX2] H]; exists (X1, X2) => //=. split; [exact: xl | exact: yk]. Qed. -Lemma cvg_ex {U : Type} (T : filteredType U) (F : set (set U)) : +Lemma cvg_in_ex {U : Type} (T : filteredType U) (F : set_system U) : [cvg F in T] <-> (exists l : T, F --> l). Proof. by split=> [cvg|/getPex//]; exists [lim F in T]. Qed. -Lemma cvgP {U : Type} (T : filteredType U) (F : set (set U)) (l : T) : +Lemma cvg_ex (T : nbhsType) (F : set_system T) : + cvg F <-> (exists l : T, F --> l). +Proof. exact: cvg_in_ex. Qed. + +Lemma cvg_inP {U : Type} (T : filteredType U) (F : set_system U) (l : T) : F --> l -> [cvg F in T]. -Proof. by move=> Fl; apply/cvg_ex; exists l. Qed. +Proof. by move=> Fl; apply/cvg_in_ex; exists l. Qed. -Lemma cvg_toP {U : Type} (T : filteredType U) (F : set (set U)) (l : T) : +Lemma cvgP (T : nbhsType) (F : set_system T) (l : T) : F --> l -> cvg F. +Proof. exact: cvg_inP. Qed. + +Lemma cvg_in_toP {U : Type} (T : filteredType U) (F : set_system U) (l : T) : [cvg F in T] -> [lim F in T] = l -> F --> l. Proof. by move=> /[swap]->. Qed. -Lemma dvgP {U : Type} (T : filteredType U) (F : set (set U)) : +Lemma cvg_toP (T : nbhsType) (F : set_system T) (l : T) : + cvg F -> lim F = l -> F --> l. +Proof. exact: cvg_in_toP. Qed. + +Lemma dvg_inP {U : Type} (T : filteredType U) (F : set_system U) : ~ [cvg F in T] -> [lim F in T] = point. Proof. by rewrite /lim_in /=; case xgetP. Qed. -Lemma cvgNpoint {U} (T : filteredType U) (F : set (set U)) : +Lemma dvgP (T : nbhsType) (F : set_system T) : ~ cvg F -> lim F = point. +Proof. exact: dvg_inP. Qed. + +Lemma cvg_inNpoint {U} (T : filteredType U) (F : set_system U) : [lim F in T] != point -> [cvg F in T]. -Proof. by apply: contra_neqP; apply: dvgP. Qed. +Proof. by apply: contra_neqP; apply: dvg_inP. Qed. + +Lemma cvgNpoint (T : nbhsType) (F : set_system T) : lim F != point -> cvg F. +Proof. exact: cvg_inNpoint. Qed. End FilteredTheory. -Arguments cvgP {U T F} l. -Arguments dvgP {U} T {F}. +Arguments cvg_inP {U T F} l. +Arguments dvg_inP {U} T {F}. +Arguments cvgP {T F} l. +Arguments dvgP {T F}. Lemma nbhs_nearE {U} {T : filteredType U} (x : T) (P : set U) : nbhs x P = \near x, P x. @@ -865,19 +852,19 @@ Lemma near_nbhs {U} {T : filteredType U} (x : T) (P : set U) : (\forall x \near nbhs x, P x) = \near x, P x. Proof. by []. Qed. -Lemma near2_curry {U V} (F : set (set U)) (G : set (set V)) (P : U -> set V) : +Lemma near2_curry {U V} (F : set_system U) (G : set_system V) (P : U -> set V) : {near F & G, forall x y, P x y} = {near (F, G), forall x, P x.1 x.2}. Proof. by []. Qed. -Lemma near2_pair {U V} (F : set (set U)) (G : set (set V)) (P : set (U * V)) : +Lemma near2_pair {U V} (F : set_system U) (G : set_system V) (P : set (U * V)) : {near F & G, forall x y, P (x, y)} = {near (F, G), forall x, P x}. Proof. by symmetry; congr (nbhs _); rewrite predeqE => -[]. Qed. Definition near2E := (@near2_curry, @near2_pair). Lemma filter_of_nearI (X : Type) (fX : filteredType X) - (x : fX) (ph : phantom fX x) : forall P, - @filter_of X fX x ph P = @prop_near1 X fX x P (inPhantom (forall x, P x)). + (x : fX) : forall P, + nbhs x P = @prop_near1 X fX x P (inPhantom (forall x, P x)). Proof. by []. Qed. Module Export NearNbhs. @@ -885,7 +872,7 @@ Definition near_simpl := (@near_nbhs, @nbhs_nearE, filter_of_nearI). Ltac near_simpl := rewrite ?near_simpl. End NearNbhs. -Lemma near_swap {U V} (F : set (set U)) (G : set (set V)) (P : U -> set V) : +Lemma near_swap {U V} (F : set_system U) (G : set_system V) (P : U -> set V) : (\forall x \near F & y \near G, P x y) = (\forall y \near G & x \near F, P x y). Proof. rewrite propeqE; split => -[[/=A B] [FA FB] ABP]; @@ -894,14 +881,14 @@ Qed. (** Filters *) -Class Filter {T : Type} (F : set (set T)) := { +Class Filter {T : Type} (F : set_system T) := { filterT : F setT ; filterI : forall P Q : set T, F P -> F Q -> F (P `&` Q) ; filterS : forall P Q : set T, P `<=` Q -> F P -> F Q }. Global Hint Mode Filter - ! : typeclass_instances. -Class ProperFilter' {T : Type} (F : set (set T)) := { +Class ProperFilter' {T : Type} (F : set_system T) := { filter_not_empty : not (F (fun _ => False)) ; filter_filter' : Filter F }. @@ -916,7 +903,7 @@ Notation ProperFilter := ProperFilter'. Lemma filter_setT (T' : Type) : Filter [set: set T']. Proof. by constructor. Qed. -Lemma filterP_strong T (F : set (set T)) {FF : Filter F} (P : set T) : +Lemma filterP_strong T (F : set_system T) {FF : Filter F} (P : set T) : (exists Q : set T, exists FQ : F Q, forall x : T, Q x -> P x) <-> F P. Proof. split; last by exists P. @@ -924,7 +911,7 @@ by move=> [Q [FQ QP]]; apply: (filterS QP). Qed. Structure filter_on T := FilterType { - filter :> (T -> Prop) -> Prop; + filter :> set_system T; _ : Filter filter }. Definition filter_class T (F : filter_on T) : Filter F := @@ -951,13 +938,11 @@ Definition PFilterType {T} (F : (T -> Prop) -> Prop) PFilterPack F (Build_ProperFilter' fN0 fF). Arguments PFilterType {T} F {fF} fN0. -Canonical filter_on_eqType T := EqType (filter_on T) gen_eqMixin. -Canonical filter_on_choiceType T := - ChoiceType (filter_on T) gen_choiceMixin. -Canonical filter_on_PointedType T := - PointedType (filter_on T) (FilterType _ (filter_setT T)). -Canonical filter_on_FilteredType T := - FilteredType T (filter_on T) (@filter T). +HB.instance Definition _ T := gen_eqMixin (filter_on T). +HB.instance Definition _ T := gen_choiceMixin (filter_on T). +HB.instance Definition _ T := isPointed.Build (filter_on T) + (FilterType _ (filter_setT T)). +HB.instance Definition _ T := isFiltered.Build T (filter_on T) (@filter T). Global Instance filter_on_Filter T (F : filter_on T) : Filter F. Proof. by case: F. Qed. @@ -980,49 +965,49 @@ by move; rewrite eqEsubset; split => // ? _; apply/sQR; rewrite QT. Qed. Canonical trivial_filter_on. -Lemma filter_nbhsT {T : Type} (F : set (set T)) : +Lemma filter_nbhsT {T : Type} (F : set_system T) : Filter F -> nbhs F setT. Proof. by move=> FF; apply: filterT. Qed. #[global] Hint Resolve filter_nbhsT : core. -Lemma nearT {T : Type} (F : set (set T)) : Filter F -> \near F, True. +Lemma nearT {T : Type} (F : set_system T) : Filter F -> \near F, True. Proof. by move=> FF; apply: filterT. Qed. #[global] Hint Resolve nearT : core. -Lemma filter_not_empty_ex {T : Type} (F : set (set T)) : +Lemma filter_not_empty_ex {T : Type} (F : set_system T) : (forall P, F P -> exists x, P x) -> ~ F set0. Proof. by move=> /(_ set0) ex /ex []. Qed. -Definition Build_ProperFilter {T : Type} (F : set (set T)) +Definition Build_ProperFilter {T : Type} (F : set_system T) (filter_ex : forall P, F P -> exists x, P x) (filter_filter : Filter F) := Build_ProperFilter' (filter_not_empty_ex filter_ex) (filter_filter). -Lemma filter_ex_subproof {T : Type} (F : set (set T)) : +Lemma filter_ex_subproof {T : Type} (F : set_system T) : ~ F set0 -> (forall P, F P -> exists x, P x). Proof. move=> NFset0 P FP; apply: contra_notP NFset0 => nex; suff <- : P = set0 by []. by rewrite funeqE => x; rewrite propeqE; split=> // Px; apply: nex; exists x. Qed. -Definition filter_ex {T : Type} (F : set (set T)) {FF : ProperFilter F} := +Definition filter_ex {T : Type} (F : set_system T) {FF : ProperFilter F} := filter_ex_subproof (filter_not_empty F). Arguments filter_ex {T F FF _}. -Lemma filter_getP {T : pointedType} (F : set (set T)) {FF : ProperFilter F} +Lemma filter_getP {T : pointedType} (F : set_system T) {FF : ProperFilter F} (P : set T) : F P -> P (get P). Proof. by move=> /filter_ex /getPex. Qed. (* Near Tactic *) -Record in_filter T (F : set (set T)) := InFilter { +Record in_filter T (F : set_system T) := InFilter { prop_in_filter_proj : T -> Prop; prop_in_filterP_proj : F prop_in_filter_proj }. (* add ball x e as a canonical instance of nbhs x *) Module Type PropInFilterSig. -Axiom t : forall (T : Type) (F : set (set T)), in_filter F -> T -> Prop. +Axiom t : forall (T : Type) (F : set_system T), in_filter F -> T -> Prop. Axiom tE : t = prop_in_filter_proj. End PropInFilterSig. Module PropInFilter : PropInFilterSig. @@ -1107,40 +1092,40 @@ Arguments have_near {U fT} x. Tactic Notation "near" constr(F) "=>" ident(x) := apply: (have_near F); near=> x. -Lemma near T (F : set (set T)) P (FP : F P) (x : T) +Lemma near T (F : set_system T) P (FP : F P) (x : T) (Px : prop_of (InFilter FP) x) : P x. Proof. by move: Px; rewrite prop_ofE. Qed. Arguments near {T F P} FP x Px. -Lemma nearW {T : Type} {F : set (set T)} (P : T -> Prop) : +Lemma nearW {T : Type} {F : set_system T} (P : T -> Prop) : Filter F -> (forall x, P x) -> (\forall x \near F, P x). Proof. by move=> FF FP; apply: filterS filterT. Qed. -Lemma filterE {T : Type} {F : set (set T)} : +Lemma filterE {T : Type} {F : set_system T} : Filter F -> forall P : set T, (forall x, P x) -> F P. Proof. by move=> [FT _ +] P fP => /(_ setT); apply. Qed. -Lemma filter_app (T : Type) (F : set (set T)) : +Lemma filter_app (T : Type) (F : set_system T) : Filter F -> forall P Q : set T, F (fun x => P x -> Q x) -> F P -> F Q. Proof. by move=> FF P Q subPQ FP; near=> x do suff: P x. Unshelve. all: by end_near. Qed. -Lemma filter_app2 (T : Type) (F : set (set T)) : +Lemma filter_app2 (T : Type) (F : set_system T) : Filter F -> forall P Q R : set T, F (fun x => P x -> Q x -> R x) -> F P -> F Q -> F R. Proof. by move=> ???? PQR FP; apply: filter_app; apply: filter_app FP. Qed. -Lemma filter_app3 (T : Type) (F : set (set T)) : +Lemma filter_app3 (T : Type) (F : set_system T) : Filter F -> forall P Q R S : set T, F (fun x => P x -> Q x -> R x -> S x) -> F P -> F Q -> F R -> F S. Proof. by move=> ????? PQR FP; apply: filter_app2; apply: filter_app FP. Qed. -Lemma filterS2 (T : Type) (F : set (set T)) : +Lemma filterS2 (T : Type) (F : set_system T) : Filter F -> forall P Q R : set T, (forall x, P x -> Q x -> R x) -> F P -> F Q -> F R. Proof. by move=> ? ? ? ? ?; apply: filter_app2; apply: filterE. Qed. -Lemma filterS3 (T : Type) (F : set (set T)) : +Lemma filterS3 (T : Type) (F : set_system T) : Filter F -> forall P Q R S : set T, (forall x, P x -> Q x -> R x -> S x) -> F P -> F Q -> F R -> F S. Proof. by move=> ? ? ? ? ? ?; apply: filter_app3; apply: filterE. Qed. @@ -1161,7 +1146,7 @@ move=> FF; split=> [H|[H1 H2]]; first by split; apply: filterS H => ? []. by apply: filterS2 H1 H2. Qed. -Lemma nearP_dep {T U} {F : set (set T)} {G : set (set U)} +Lemma nearP_dep {T U} {F : set_system T} {G : set_system U} {FF : Filter F} {FG : Filter G} (P : T -> U -> Prop) : (\forall x \near F & y \near G, P x y) -> \forall x \near F, \forall y \near G, P x y. @@ -1170,7 +1155,7 @@ move=> [[Q R] [/=FQ GR]] QRP. by apply: filterS FQ => x Q1x; apply: filterS GR => y Q2y; apply: (QRP (_, _)). Qed. -Lemma filter2P T U (F : set (set T)) (G : set (set U)) +Lemma filter2P T U (F : set_system T) (G : set_system U) {FF : Filter F} {FG : Filter G} (P : set (T * U)) : (exists2 Q : set T * set U, F Q.1 /\ G Q.2 & forall (x : T) (y : U), Q.1 x -> Q.2 y -> P (x, y)) @@ -1181,20 +1166,20 @@ split=> [][[A B] /=[FA GB] ABP]; exists (A, B) => //=. by move=> a b Aa Bb; apply: (ABP (_, _)). Qed. -Lemma filter_ex2 {T U : Type} (F : set (set T)) (G : set (set U)) +Lemma filter_ex2 {T U : Type} (F : set_system T) (G : set_system U) {FF : ProperFilter F} {FG : ProperFilter G} (P : set T) (Q : set U) : F P -> G Q -> exists x : T, exists2 y : U, P x & Q y. Proof. by move=> /filter_ex [x Px] /filter_ex [y Qy]; exists x, y. Qed. Arguments filter_ex2 {T U F G FF FG _ _}. -Lemma filter_fromP {I T : Type} (D : set I) (B : I -> set T) (F : set (set T)) : +Lemma filter_fromP {I T : Type} (D : set I) (B : I -> set T) (F : set_system T) : Filter F -> F `=>` filter_from D B <-> forall i, D i -> F (B i). Proof. split; first by move=> FB i ?; apply/FB/in_filter_from. by move=> FB P [i Di BjP]; apply: (filterS BjP); apply: FB. Qed. -Lemma filter_fromTP {I T : Type} (B : I -> set T) (F : set (set T)) : +Lemma filter_fromTP {I T : Type} (B : I -> set T) (F : set_system T) : Filter F -> F `=>` filter_from setT B <-> forall i, F (B i). Proof. by move=> FF; rewrite filter_fromP; split=> [P i|P i _]; apply: P. Qed. @@ -1228,7 +1213,7 @@ by have [x Bix] := BN0 _ Di; exists x; apply: BiP. Qed. Lemma filter_bigI T (I : choiceType) (D : {fset I}) (f : I -> set T) - (F : set (set T)) : + (F : set_system T) : Filter F -> (forall i, i \in D -> F (f i)) -> F (\bigcap_(i in [set` D]) f i). Proof. @@ -1242,7 +1227,7 @@ apply: filterI; first by apply: FfD; rewrite inE eq_refl. by apply: ihs => j sj; apply: FfD; rewrite inE sj orbC. Qed. -Lemma filter_forall T (I : finType) (f : I -> set T) (F : set (set T)) : +Lemma filter_forall T (I : finType) (f : I -> set T) (F : set_system T) : Filter F -> (forall i : I, \forall x \near F, f i x) -> \forall x \near F, forall i, f i x. Proof. @@ -1251,7 +1236,7 @@ move=> FF fIF; apply: filterS (@filter_bigI T I [fset x in I]%fset f F FF _). by move=> i; rewrite inE/= => _; apply: (fIF i). Qed. -Lemma filter_imply [T : Type] [P : Prop] [f : set T] [F : set (set T)] : +Lemma filter_imply [T : Type] [P : Prop] [f : set T] [F : set_system T] : Filter F -> (P -> \near F, f F) -> \near F, P -> f F. Proof. move=> ? PF; near do move=> /asboolP. @@ -1260,28 +1245,34 @@ Unshelve. all: by end_near. Qed. (** Limits expressed with filters *) -Definition fmap {T U : Type} (f : T -> U) (F : set (set T)) := +Definition fmap {T U : Type} (f : T -> U) (F : set_system T) : set_system U := [set P | F (f @^-1` P)]. Arguments fmap _ _ _ _ _ /. Lemma fmapE {U V : Type} (f : U -> V) - (F : set (set U)) (P : set V) : fmap f F P = F (f @^-1` P). + (F : set_system U) (P : set V) : fmap f F P = F (f @^-1` P). Proof. by []. Qed. Notation "E @[ x --> F ]" := - (fmap (fun x => E) [filter of F]) : classical_set_scope. -Notation "f @ F" := (fmap f [filter of F]) : classical_set_scope. -Global Instance fmap_filter T U (f : T -> U) (F : set (set T)) : + (fmap (fun x => E) (nbhs F)) : classical_set_scope. +Notation "E @[ x \oo ]" := + (fmap (fun x => E) \oo) : classical_set_scope. +Notation "f @ F" := (fmap f (nbhs F)) : classical_set_scope. + +Notation limn F := (lim (F @ \oo)). +Notation cvgn F := (cvg (F @ \oo)). + +Global Instance fmap_filter T U (f : T -> U) (F : set_system T) : Filter F -> Filter (f @ F). Proof. -move=> FF; constructor => [|P Q|P Q PQ]; rewrite ?fmapE ?filter_ofE //=. +move=> FF; constructor => [|P Q|P Q PQ]; rewrite ?fmapE //=. - exact: filterT. - exact: filterI. - by apply: filterS=> ?/PQ. Qed. (*Typeclasses Opaque fmap.*) -Global Instance fmap_proper_filter T U (f : T -> U) (F : set (set T)) : +Global Instance fmap_proper_filter T U (f : T -> U) (F : set_system T) : ProperFilter F -> ProperFilter (f @ F). Proof. move=> FF; apply: Build_ProperFilter'; @@ -1289,19 +1280,20 @@ by rewrite fmapE; apply: filter_not_empty. Qed. Definition fmap_proper_filter' := fmap_proper_filter. -Definition fmapi {T U : Type} (f : T -> set U) (F : set (set T)) := +Definition fmapi {T U : Type} (f : T -> set U) (F : set_system T) : + set_system _ := [set P | \forall x \near F, exists y, f x y /\ P y]. Notation "E `@[ x --> F ]" := - (fmapi (fun x => E) [filter of F]) : classical_set_scope. -Notation "f `@ F" := (fmapi f [filter of F]) : classical_set_scope. + (fmapi (fun x => E) (nbhs F)) : classical_set_scope. +Notation "f `@ F" := (fmapi f (nbhs F)) : classical_set_scope. Lemma fmapiE {U V : Type} (f : U -> set V) - (F : set (set U)) (P : set V) : + (F : set_system U) (P : set V) : fmapi f F P = \forall x \near F, exists y, f x y /\ P y. Proof. by []. Qed. -Global Instance fmapi_filter T U (f : T -> set U) (F : set (set T)) : +Global Instance fmapi_filter T U (f : T -> set U) (F : set_system T) : infer {near F, is_totalfun f} -> Filter F -> Filter (f `@ F). Proof. move=> f_totalfun FF; rewrite /fmapi; apply: Build_Filter. @@ -1318,7 +1310,7 @@ Unshelve. all: by end_near. Qed. #[global] Typeclasses Opaque fmapi. Global Instance fmapi_proper_filter - T U (f : T -> U -> Prop) (F : set (set T)) : + T U (f : T -> U -> Prop) (F : set_system T) : infer {near F, is_totalfun f} -> ProperFilter F -> ProperFilter (f `@ F). Proof. @@ -1327,7 +1319,7 @@ by move=> P; rewrite /fmapi/= => /filter_ex [x [y [??]]]; exists y. Qed. Definition filter_map_proper_filter' := fmapi_proper_filter. -Lemma cvg_id T (F : set (set T)) : x @[x --> F] --> F. +Lemma cvg_id T (F : set_system T) : x @[x --> F] --> F. Proof. exact. Qed. Arguments cvg_id {T F}. @@ -1335,49 +1327,53 @@ Lemma fmap_comp {A B C} (f : B -> C) (g : A -> B) F: Filter F -> (f \o g)%FUN @ F = f @ (g @ F). Proof. by []. Qed. -Lemma appfilter U V (f : U -> V) (F : set (set U)) : +Lemma appfilter U V (f : U -> V) (F : set_system U) : f @ F = [set P : set _ | \forall x \near F, P (f x)]. Proof. by []. Qed. -Lemma cvg_app U V (F G : set (set U)) (f : U -> V) : +Lemma cvg_app U V (F G : set_system U) (f : U -> V) : F --> G -> f @ F --> f @ G. Proof. by move=> FG P /=; exact: FG. Qed. Arguments cvg_app {U V F G} _. -Lemma cvgi_app U V (F G : set (set U)) (f : U -> set V) : +Lemma cvgi_app U V (F G : set_system U) (f : U -> set V) : F --> G -> f `@ F --> f `@ G. Proof. by move=> FG P /=; exact: FG. Qed. Lemma cvg_comp T U V (f : T -> U) (g : U -> V) - (F : set (set T)) (G : set (set U)) (H : set (set V)) : + (F : set_system T) (G : set_system U) (H : set_system V) : f @ F `=>` G -> g @ G `=>` H -> g \o f @ F `=>` H. Proof. by move=> fFG gGH; apply: cvg_trans gGH => P /fFG. Qed. Lemma cvgi_comp T U V (f : T -> U) (g : U -> set V) - (F : set (set T)) (G : set (set U)) (H : set (set V)) : + (F : set_system T) (G : set_system U) (H : set_system V) : f @ F `=>` G -> g `@ G `=>` H -> g \o f `@ F `=>` H. Proof. by move=> fFG gGH; apply: cvg_trans gGH => P /fFG. Qed. -Lemma near_eq_cvg {T U} {F : set (set T)} {FF : Filter F} (f g : T -> U) : +Lemma near_eq_cvg {T U} {F : set_system T} {FF : Filter F} (f g : T -> U) : {near F, f =1 g} -> g @ F `=>` f @ F. Proof. by move=> eq_fg P /=; apply: filterS2 eq_fg => x /= <-. Qed. -Lemma eq_cvg (T T' : Type) (F : set (set T)) (f g : T -> T') (x : set (set T')) : +Lemma eq_cvg (T T' : Type) (F : set_system T) (f g : T -> T') (x : set_system T') : f =1 g -> (f @ F --> x) = (g @ F --> x). Proof. by move=> /funext->. Qed. -Lemma eq_is_cvg (T T' : Type) (fT : filteredType T') (F : set (set T)) (f g : T -> T') : +Lemma eq_is_cvg_in (T T' : Type) (fT : filteredType T') (F : set_system T) (f g : T -> T') : f =1 g -> [cvg (f @ F) in fT] = [cvg (g @ F) in fT]. Proof. by move=> /funext->. Qed. -Lemma neari_eq_loc {T U} {F : set (set T)} {FF : Filter F} (f g : T -> set U) : +Lemma eq_is_cvg (T : Type) (T' : nbhsType) (F : set_system T) (f g : T -> T') : + f =1 g -> cvg (f @ F) = cvg (g @ F). +Proof. by move=> /funext->. Qed. + +Lemma neari_eq_loc {T U} {F : set_system T} {FF : Filter F} (f g : T -> set U) : {near F, f =2 g} -> g `@ F `=>` f `@ F. Proof. move=> eq_fg P /=; apply: filterS2 eq_fg => x eq_fg [y [fxy Py]]. by exists y; rewrite -eq_fg. Qed. -Lemma cvg_near_const (T U : Type) (f : T -> U) (F : set (set T)) (G : set (set U)) : +Lemma cvg_near_const (T U : Type) (f : T -> U) (F : set_system T) (G : set_system U) : Filter F -> ProperFilter G -> (\forall y \near G, \forall x \near F, f x = y) -> f @ F --> G. Proof. @@ -1387,7 +1383,7 @@ Unshelve. all: by end_near. Qed. (* globally filter *) -Definition globally {T : Type} (A : set T) : set (set T) := +Definition globally {T : Type} (A : set T) : set_system T := [set P : set T | forall x, A x -> P x]. Arguments globally {T} A _ /. @@ -1440,7 +1436,7 @@ End at_point. (** Filters for pairs *) -Global Instance filter_prod_filter T U (F : set (set T)) (G : set (set U)) : +Global Instance filter_prod_filter T U (F : set_system T) (G : set_system U) : Filter F -> Filter G -> Filter (filter_prod F G). Proof. move=> FF FG; apply: filter_from_filter. @@ -1463,14 +1459,14 @@ by have [[x ?] [y ?]] := (filter_ex FA, filter_ex GB); exists (x, y). Qed. Definition filter_prod_proper' := @filter_prod_proper. -Lemma filter_prod1 {T U} {F : set (set T)} {G : set (set U)} +Lemma filter_prod1 {T U} {F : set_system T} {G : set_system U} {FG : Filter G} (P : set T) : (\forall x \near F, P x) -> \forall x \near F & _ \near G, P x. Proof. move=> FP; exists (P, setT)=> //= [|[?? []//]]. by split=> //; apply: filterT. Qed. -Lemma filter_prod2 {T U} {F : set (set T)} {G : set (set U)} +Lemma filter_prod2 {T U} {F : set_system T} {G : set_system U} {FF : Filter F} (P : set U) : (\forall y \near G, P y) -> \forall _ \near F & y \near G, P y. Proof. @@ -1478,7 +1474,7 @@ move=> FP; exists (setT, P)=> //= [|[?? []//]]. by split=> //; apply: filterT. Qed. -Program Definition in_filter_prod {T U} {F : set (set T)} {G : set (set U)} +Program Definition in_filter_prod {T U} {F : set_system T} {G : set_system U} (P : in_filter F) (Q : in_filter G) : in_filter (filter_prod F G) := @InFilter _ _ (fun x => prop_of P x.1 /\ prop_of Q x.2) _. Next Obligation. @@ -1486,7 +1482,7 @@ move=> T U F G P Q. by exists (prop_of P, prop_of Q) => //=; split; apply: prop_ofP. Qed. -Lemma near_pair {T U} {F : set (set T)} {G : set (set U)} +Lemma near_pair {T U} {F : set_system T} {G : set_system U} {FF : Filter F} {FG : Filter G} (P : in_filter F) (Q : in_filter G) x : prop_of P x.1 -> prop_of Q x.2 -> prop_of (in_filter_prod P Q) x. @@ -1500,12 +1496,12 @@ Lemma cvg_snd {T U F G} {FF : Filter F} : (@snd T U) @ filter_prod F G --> G. Proof. by move=> P; apply: filter_prod2. Qed. -Lemma near_map {T U} (f : T -> U) (F : set (set T)) (P : set U) : +Lemma near_map {T U} (f : T -> U) (F : set_system T) (P : set U) : (\forall y \near f @ F, P y) = (\forall x \near F, P (f x)). Proof. by []. Qed. Lemma near_map2 {T T' U U'} (f : T -> U) (g : T' -> U') - (F : set (set T)) (G : set (set T')) (P : U -> set U') : + (F : set_system T) (G : set_system T') (P : U -> set U') : Filter F -> Filter G -> (\forall y \near f @ F & y' \near g @ G, P y y') = (\forall x \near F & x' \near G , P (f x) (g x')). @@ -1520,11 +1516,11 @@ rewrite !nbhs_simpl /fmap /=; split. by apply: filterS fGB => x Bx; exists x. Qed. -Lemma near_mapi {T U} (f : T -> set U) (F : set (set T)) (P : set U) : +Lemma near_mapi {T U} (f : T -> set U) (F : set_system T) (P : set U) : (\forall y \near f `@ F, P y) = (\forall x \near F, exists y, f x y /\ P y). Proof. by []. Qed. -Lemma filter_pair_set (T T' : Type) (F : set (set T)) (F' : set (set T')) : +Lemma filter_pair_set (T T' : Type) (F : set_system T) (F' : set_system T') : Filter F -> Filter F' -> forall (P : set T) (P' : set T') (Q : set (T * T')), (forall x x', P x -> P' x' -> Q (x, x')) -> F P /\ F' P' -> @@ -1535,7 +1531,7 @@ by move=> FF FF' P P' Q PQ [FP FP']; [apply: cvg_fst | apply: cvg_snd]. Unshelve. all: by end_near. Qed. -Lemma filter_pair_near_of (T T' : Type) (F : set (set T)) (F' : set (set T')) : +Lemma filter_pair_near_of (T T' : Type) (F : set_system T) (F' : set_system T') : Filter F -> Filter F' -> forall (P : @in_filter T F) (P' : @in_filter T' F') (Q : set (T * T')), (forall x x', prop_of P x -> prop_of P' x' -> Q (x, x')) -> @@ -1555,7 +1551,7 @@ Definition near_simpl := (@near_simpl, @near_map, @near_mapi, @near_map2). Ltac near_simpl := rewrite ?near_simpl. End NearMap. -Lemma cvg_pair {T U V F} {G : set (set U)} {H : set (set V)} +Lemma cvg_pair {T U V F} {G : set_system U} {H : set_system V} {FF : Filter F} {FG : Filter G} {FH : Filter H} (f : T -> U) (g : T -> V) : f @ F --> G -> g @ F --> H -> (f x, g x) @[x --> F] --> (G, H). @@ -1565,7 +1561,7 @@ by apply: (ABP (_, _)); split=> //=; near: x; [apply: fFG|apply: gFH]. Unshelve. all: by end_near. Qed. Lemma cvg_comp2 {T U V W} - {F : set (set T)} {G : set (set U)} {H : set (set V)} {I : set (set W)} + {F : set_system T} {G : set_system U} {H : set_system V} {I : set_system W} {FF : Filter F} {FG : Filter G} {FH : Filter H} (f : T -> U) (g : T -> V) (h : U -> V -> W) : f @ F --> G -> g @ F --> H -> @@ -1576,7 +1572,7 @@ Arguments cvg_comp2 {T U V W F G H I FF FG FH f g h} _ _ _. Definition cvg_to_comp_2 := @cvg_comp2. (* Lemma cvgi_comp_2 {T U V W} *) -(* {F : set (set T)} {G : set (set U)} {H : set (set V)} {I : set (set W)} *) +(* {F : set_system T} {G : set_system U} {H : set_system V} {I : set_system W} *) (* {FF : Filter F} *) (* (f : T -> U) (g : T -> V) (h : U -> V -> set W) : *) (* f @ F --> G -> g @ F --> H -> *) @@ -1593,9 +1589,9 @@ Definition cvg_to_comp_2 := @cvg_comp2. Section within. Context {T : Type}. -Implicit Types (D : set T) (F : set (set T)). +Implicit Types (D : set T) (F : set_system T). -Definition within D F (P : set T) := {near F, D `<=` P}. +Definition within D F : set_system T := [set P | {near F, D `<=` P}]. Arguments within : simpl never. Lemma near_withinE D F (P : set T) : @@ -1603,7 +1599,7 @@ Lemma near_withinE D F (P : set T) : Proof. by []. Qed. Lemma withinT F D : Filter F -> within D F D. -Proof. by move=> FF; rewrite /within; apply: filterE. Qed. +Proof. by move=> FF; rewrite /within/=; apply: filterE. Qed. Lemma near_withinT F D : Filter F -> \forall x \near within D F, D x. Proof. exact: withinT. Qed. @@ -1613,15 +1609,15 @@ Proof. by move=> P; apply: filterS. Qed. Lemma withinET {F} {FF : Filter F} : within setT F = F. Proof. -rewrite eqEsubset /within; split => ?; apply: filter_app; apply: nearW => //. -by move=> ?; exact. +rewrite eqEsubset /within; split => X //=; +by apply: filter_app => //=; apply: nearW => // x; apply. Qed. End within. Global Instance within_filter T D F : Filter F -> Filter (@within T D F). Proof. -move=> FF; rewrite /within; constructor. +move=> FF; rewrite /within; constructor => /=. - by apply: filterE. - by move=> P Q; apply: filterS2 => x DP DQ Dx; split; [apply: DP|apply: DQ]. - by move=> P Q subPQ; apply: filterS => x DP /DP /subPQ. @@ -1638,7 +1634,7 @@ Lemma filter_bigI_within T (I : choiceType) (D : {fset I}) (f : I -> set T) F ([set j | P j -> (\bigcap_(i in [set` D]) f i) j]). Proof. move=> FF FfD; exact: (@filter_bigI T I D f _ (within_filter P FF)). Qed. -Definition subset_filter {T} (F : set (set T)) (D : set T) := +Definition subset_filter {T} (F : set_system T) (D : set T) := [set P : set {x | D x} | F [set x | forall Dx : D x, P (exist _ x Dx)]]. Arguments subset_filter {T} F D _. @@ -1662,11 +1658,10 @@ Qed. (* For using near on sets in a filter *) Section NearSet. - Context {Y : Type}. -Context (F : set (set Y)) (PF : ProperFilter F). +Context (F : set_system Y) (PF : ProperFilter F). -Definition powerset_filter_from : set (set (set Y)) := filter_from +Definition powerset_filter_from : set_system (set Y) := filter_from [set M | [/\ M `<=` F, (forall E1 E2, M E1 -> F E2 -> E2 `<=` E1 -> M E2) & M !=set0 ] ] id. @@ -1699,7 +1694,7 @@ Lemma small_set_sub (E : set Y) : F E -> Proof. move=> entE; exists [set E' | F E' /\ E' `<=` E]; last by move=> ? []. split; [by move=> E' [] | | by exists E; split]. -by move=> E1 E2 [] ? sub ? ?; split => //; exact: subset_trans sub. +by move=> E1 E2 [] ? subE ? ?; split => //; exact: subset_trans subE. Qed. Lemma near_powerset_filter_fromP (P : set Y -> Prop) : @@ -1723,7 +1718,7 @@ Qed. End NearSet. -Lemma near_powerset_map {T U : Type} (f : T -> U) (F : set (set T)) +Lemma near_powerset_map {T U : Type} (f : T -> U) (F : set_system T) (P : set U -> Prop) : ProperFilter F -> (\forall y \near powerset_filter_from (f x @[x --> F]), P y) -> @@ -1740,7 +1735,7 @@ have : M `<=` f @^-1` D by exact: (near (small_set_sub FfD) M). by move/image_subset/subset_trans; apply; exact: image_preimage_subset. Unshelve. all: by end_near. Qed. -Lemma near_powerset_map_monoE {T U : Type} (f : T -> U) (F : set (set T)) +Lemma near_powerset_map_monoE {T U : Type} (f : T -> U) (F : set_system T) (P : set U -> Prop) : (forall X Y, X `<=` Y -> P Y -> P X) -> ProperFilter F -> @@ -1760,7 +1755,7 @@ Unshelve. all: by end_near. Qed. Section PrincipalFilters. -Definition principal_filter {X : Type} (x : X) : set (set X) := +Definition principal_filter {X : Type} (x : X) : set_system X := globally [set x]. Lemma principal_filterP {X} (x : X) (W : set X) : principal_filter x W <-> W x. @@ -1769,85 +1764,27 @@ Proof. by split=> [|? ? ->]; [exact|]. Qed. Lemma principal_filter_proper {X} (x : X) : ProperFilter (principal_filter x). Proof. exact: globally_properfilter. Qed. -Canonical bool_discrete_filter := FilteredType bool bool principal_filter. +HB.instance Definition _ := hasNbhs.Build bool principal_filter. End PrincipalFilters. (** Topological spaces *) - -Module Topological. - -Record mixin_of (T : Type) (nbhs : T -> set (set T)) := Mixin { - open : set (set T) ; - nbhs_pfilter : forall p : T, ProperFilter (nbhs p) ; - nbhsE : forall p : T, nbhs p = +HB.mixin Record Nbhs_isTopological (T : Type) of Nbhs T := { + open : set_system T; + nbhs_pfilter_subproof : forall p : T, ProperFilter (nbhs p) ; + nbhsE_subproof : forall p : T, nbhs p = [set A : set T | exists B : set T, [/\ open B, B p & B `<=` A] ] ; - openE : open = [set A : set T | A `<=` nbhs^~ A ] + openE_subproof : open = [set A : set T | A `<=` nbhs^~ A ] }. -Record class_of (T : Type) := Class { - base : Filtered.class_of T T; - mixin : mixin_of (Filtered.nbhs_op base) -}. - -Section ClassDef. - -Structure type := Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of cT in c. - -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). -Local Coercion base : class_of >-> Filtered.class_of. -Local Coercion mixin : class_of >-> mixin_of. - -Definition pack nbhs' (m : @mixin_of T nbhs') := - fun bT (b : Filtered.class_of T T) of phant_id (@Filtered.class T bT) b => - fun m' of phant_id m (m' : @mixin_of T (Filtered.nbhs_op b)) => - @Pack T (@Class _ b m'). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. - -End ClassDef. - -Module Exports. - -Coercion sort : type >-> Sortclass. -Coercion base : class_of >-> Filtered.class_of. -Coercion mixin : class_of >-> mixin_of. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Notation topologicalType := type. -Notation TopologicalType T m := (@pack T _ m _ _ idfun _ idfun). -Notation TopologicalMixin := Mixin. -Notation "[ 'topologicalType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'topologicalType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'topologicalType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'topologicalType' 'of' T ]") : form_scope. - -End Exports. - -End Topological. - -Export Topological.Exports. +#[short(type="topologicalType")] +HB.structure Definition Topological := + {T of Nbhs T & Nbhs_isTopological T}. Section Topological1. Context {T : topologicalType}. -Definition open := Topological.open (Topological.class T). - Definition open_nbhs (p : T) (A : set T) := open A /\ A p. Definition basis (B : set (set T)) := @@ -1856,7 +1793,7 @@ Definition basis (B : set (set T)) := Definition second_countable := exists2 B, countable B & basis B. Global Instance nbhs_pfilter (p : T) : ProperFilter (nbhs p). -Proof. by apply: Topological.nbhs_pfilter; case: T p => ? []. Qed. +Proof. by apply: nbhs_pfilter_subproof; case: T p => ? []. Qed. Typeclasses Opaque nbhs. Lemma nbhs_filter (p : T) : Filter (nbhs p). @@ -1868,7 +1805,7 @@ Lemma nbhsE (p : T) : nbhs p = [set A : set T | exists2 B : set T, open_nbhs p B & B `<=` A]. Proof. have -> : nbhs p = [set A : set T | exists B, [/\ open B, B p & B `<=` A] ]. - exact: Topological.nbhsE. + exact: nbhsE_subproof. by rewrite predeqE => A; split=> [[B [?]]|[B[]]]; exists B. Qed. @@ -1888,7 +1825,7 @@ by move=> p; rewrite /interior nbhsE => -[? [? ?]]; apply. Qed. Lemma openE : open = [set A : set T | A `<=` A^°]. -Proof. exact: Topological.openE. Qed. +Proof. exact: openE_subproof. Qed. Lemma nbhs_singleton (p : T) (A : set T) : nbhs p A -> A p. Proof. by rewrite nbhsE => - [? [_ ?]]; apply. Qed. @@ -1899,10 +1836,10 @@ rewrite nbhsE /open_nbhs openE => - [B [Bop Bp] sBA]. by exists B => // q Bq; apply: filterS sBA _; apply: Bop. Qed. -Lemma open0 : open set0. +Lemma open0 : open (set0 : set T). Proof. by rewrite openE. Qed. -Lemma openT : open setT. +Lemma openT : open (setT : set T). Proof. by rewrite openE => ??; apply: filterT. Qed. Lemma openI (A B : set T) : open A -> open B -> open (A `&` B). @@ -1970,9 +1907,11 @@ End Topological1. Notation "A ^°" := (interior A) : classical_set_scope. -Notation continuous f := (forall x, f%function @ x --> f%function x). +Definition continuous_at (T U : nbhsType) (x : T) (f : T -> U) := + (f%function @ x --> f%function x). +Notation continuous f := (forall x, continuous_at x f). -Lemma near_fun (T T' : topologicalType) (f : T -> T') (x : T) (P : T' -> Prop) : +Lemma near_fun (T T' : nbhsType) (f : T -> T') (x : T) (P : T' -> Prop) : {for x, continuous f} -> (\forall y \near f x, P y) -> (\near x, P (f x)). Proof. exact. Qed. @@ -1999,7 +1938,7 @@ by apply: fcont; [rewrite inE|apply: Dop]. Qed. Lemma cvg_fmap {T: topologicalType} {U : topologicalType} - (F : set (set T)) x (f : T -> U) : + (F : set_system T) x (f : T -> U) : {for x, continuous f} -> F --> x -> f @ F --> f x. Proof. by move=> cf fx P /cf /fx. Qed. @@ -2017,7 +1956,7 @@ Unshelve. all: by end_near. Qed. (* limit composition *) Lemma continuous_cvg {T : Type} {V U : topologicalType} - (F : set (set T)) (FF : Filter F) + (F : set_system T) (FF : Filter F) (f : T -> V) (h : V -> U) (a : V) : {for a, continuous h} -> f @ F --> a -> (h \o f) @ F --> h a. @@ -2026,7 +1965,7 @@ move=> h_continuous fa fb; apply: (cvg_trans _ h_continuous). exact: (@cvg_comp _ _ _ _ h _ _ _ fa). Qed. -Lemma continuous_is_cvg {T : Type} {V U : topologicalType} [F : set (set T)] +Lemma continuous_is_cvg {T : Type} {V U : topologicalType} [F : set_system T] (FF : Filter F) (f : T -> V) (h : V -> U) : (forall l, f x @[x --> F] --> l -> {for l, continuous h}) -> cvg (f x @[x --> F]) -> cvg ((h \o f) x @[x --> F]). @@ -2036,7 +1975,7 @@ by apply: continuous_cvg => //; exact: ach. Qed. Lemma continuous2_cvg {T : Type} {V W U : topologicalType} - (F : set (set T)) (FF : Filter F) + (F : set_system T) (FF : Filter F) (f : T -> V) (g : T -> W) (h : V -> W -> U) (a : V) (b : W) : h z.1 z.2 @[z --> (a, b)] --> h a b -> f @ F --> a -> g @ F --> b -> (fun x => h (f x) (g x)) @ F --> h a b. @@ -2046,7 +1985,7 @@ exact: (@cvg_comp _ _ _ _ (fun x => h x.1 x.2) _ _ _ (cvg_pair fa fb)). Qed. Lemma cvg_near_cst (T : Type) (U : topologicalType) - (l : U) (f : T -> U) (F : set (set T)) {FF : Filter F} : + (l : U) (f : T -> U) (F : set_system T) {FF : Filter F} : (\forall x \near F, f x = l) -> f @ F --> l. Proof. move=> fFl P /=; rewrite !near_simpl => Pl. @@ -2055,7 +1994,7 @@ Qed. Arguments cvg_near_cst {T U} l {f F FF}. Lemma is_cvg_near_cst (T : Type) (U : topologicalType) - (l : U) (f : T -> U) (F : set (set T)) {FF : Filter F} : + (l : U) (f : T -> U) (F : set_system T) {FF : Filter F} : (\forall x \near F, f x = l) -> cvg (f @ F). Proof. by move=> /cvg_near_cst/cvgP. Qed. Arguments is_cvg_near_cst {T U} l {f F FF}. @@ -2070,14 +2009,14 @@ Qed. Arguments near_cst_continuous {T U} l [f x]. Lemma cvg_cst (U : topologicalType) (x : U) (T : Type) - (F : set (set T)) {FF : Filter F} : + (F : set_system T) {FF : Filter F} : (fun _ : T => x) @ F --> x. Proof. by apply: cvg_near_cst; near=> x0. Unshelve. all: by end_near. Qed. Arguments cvg_cst {U} x {T F FF}. #[global] Hint Resolve cvg_cst : core. Lemma is_cvg_cst (U : topologicalType) (x : U) (T : Type) - (F : set (set T)) {FF : Filter F} : + (F : set_system T) {FF : Filter F} : cvg ((fun _ : T => x) @ F). Proof. by apply: cvgP; apply: cvg_cst. Qed. Arguments is_cvg_cst {U} x {T F FF}. @@ -2095,12 +2034,12 @@ Implicit Types B : set T. (* to be combined with lemmas such as boundedP in normedtype.v *) Lemma within_nbhsW (x : T) : A x -> within A (nbhs x) `=>` globally A. Proof. -move=> Ax P AP; rewrite /within; near=> y; apply: AP. +move=> Ax P AP; rewrite /within/=; near=> y; apply: AP. Unshelve. all: by end_near. Qed. (* [locally P] replaces a (globally A) in P by a within A (nbhs x) *) (* Can be combined with a notation taking a filter as its last argument *) -Definition locally_of (P : set (set T) -> Prop) of phantom Prop (P (globally A)) +Definition locally_of (P : set_system T -> Prop) of phantom Prop (P (globally A)) := forall x, A x -> P (within A (nbhs x)). Local Notation "[ 'locally' P ]" := (@locally_of _ _ _ (Phantom _ P)). (* e.g. [locally [bounded f x | x in A]] *) @@ -2118,7 +2057,7 @@ Qed. Lemma within_subset B F : Filter F -> A `<=` B -> within A F `=>` within B F. Proof. -move=> FF AsubB W; rewrite /within; apply: filter_app; rewrite nbhs_simpl. +move=> FF AsubB W; rewrite /within/=; apply: filter_app; rewrite nbhs_simpl. by apply: filterE => ? + ?; apply; exact: AsubB. Qed. @@ -2128,11 +2067,11 @@ Proof. move=> FF; rewrite eqEsubset; split=> U. move=> Wu; exists [set x | A x -> U x] => //. by rewrite eqEsubset; split => t [L R]; split=> //; apply: L. -move=> [V FV AU]; rewrite /within /prop_near1 nbhs_simpl; near=> w => Aw. +move=> [V FV AU]; rewrite /within /prop_near1 nbhs_simpl/=; near=> w => Aw. by have []// : (U `&` A) w; rewrite AU; split => //; apply: (near FV). Unshelve. all: by end_near. Qed. -Lemma fmap_within_eq {S : topologicalType} (F : set (set T)) (f g : T -> S) : +Lemma fmap_within_eq {S : topologicalType} (F : set_system T) (f g : T -> S) : Filter F -> {in A, f =1 g} -> f @ within A F --> g @ within A F. Proof. move=> FF feq U /=; near_simpl; apply: filter_app. @@ -2146,54 +2085,71 @@ Notation "[ 'locally' P ]" := (@locally_of _ _ _ (Phantom _ P)). (** Topology defined by a filter *) -Section TopologyOfFilter. +(* was topologyOfFilterMixin *) +HB.factory Record Nbhs_isNbhsTopological T of Nbhs T := { + nbhs_filter : forall p : T, ProperFilter (nbhs p); + nbhs_singleton : forall (p : T) (A : set T), nbhs p A -> A p; + nbhs_nbhs : forall (p : T) (A : set T), nbhs p A -> nbhs p (nbhs^~ A); +}. -Context {T : Type} {nbhs' : T -> set (set T)}. -Hypothesis (nbhs'_filter : forall p : T, ProperFilter (nbhs' p)). -Hypothesis (nbhs'_singleton : forall (p : T) (A : set T), nbhs' p A -> A p). -Hypothesis (nbhs'_nbhs' : forall (p : T) (A : set T), nbhs' p A -> nbhs' p (nbhs'^~ A)). +HB.builders Context T of Nbhs_isNbhsTopological T. -Definition open_of_nbhs := [set A : set T | A `<=` nbhs'^~ A]. +Definition open_of_nbhs := [set A : set T | A `<=` nbhs^~ A]. -Program Definition topologyOfFilterMixin : Topological.mixin_of nbhs' := - @Topological.Mixin T nbhs' open_of_nbhs _ _ _. -Next Obligation. -move=> p; rewrite predeqE => A; split=> [p_A|]; last first. - by move=> [B [Bop Bp sBA]]; apply: filterS sBA _; apply: Bop. -exists (nbhs'^~ A) ; split => //; first by move=> ?; apply: nbhs'_nbhs'. -by move=> q /nbhs'_singleton. +Lemma nbhsE_subproof (p : T) : + nbhs p = [set A | exists B, [/\ open_of_nbhs B, B p & B `<=` A] ]. +Proof. +rewrite predeqE => A; split=> [p_A|]; last first. + move=> [B [Bop Bp sBA]]; apply: filterS sBA _; last exact: Bop. + exact/filter_filter'/nbhs_filter. +exists (nbhs^~ A); split=> //; first by move=> ?; apply: nbhs_nbhs. +by move=> q /nbhs_singleton. Qed. -Next Obligation. done. Qed. -End TopologyOfFilter. +Lemma openE_subproof : open_of_nbhs = [set A : set T | A `<=` nbhs^~ A]. +Proof. by []. Qed. -(** Topology defined by open sets *) +HB.instance Definition _ := Nbhs_isTopological.Build T + nbhs_filter nbhsE_subproof openE_subproof. -Section TopologyOfOpen. +HB.end. -Variable (T : Type) (op : set T -> Prop). -Hypothesis (opT : op setT). -Hypothesis (opI : forall (A B : set T), op A -> op B -> op (A `&` B)). -Hypothesis (op_bigU : forall (I : Type) (f : I -> set T), - (forall i, op (f i)) -> op (\bigcup_i f i)). +(** Topology defined by open sets *) -Definition nbhs_of_open (p : T) (A : set T) := +Definition nbhs_of_open (T : pointedType) (op : set T -> Prop) (p : T) (A : set T) := exists B, [/\ op B, B p & B `<=` A]. -Program Definition topologyOfOpenMixin : Topological.mixin_of nbhs_of_open := - @Topological.Mixin T nbhs_of_open op _ _ _. -Next Obligation. -move=> p; apply: Build_ProperFilter. +(* was topologyOfOpenMixin *) +HB.factory Record Pointed_isOpenTopological T of Pointed T := { + op : set T -> Prop; + opT : op setT; + opI : forall (A B : set T), op A -> op B -> op (A `&` B); + op_bigU : forall (I : Type) (f : I -> set T), (forall i, op (f i)) -> + op (\bigcup_i f i); +}. + +HB.builders Context T of Pointed_isOpenTopological T. + +HB.instance Definition _ := hasNbhs.Build T (nbhs_of_open op). + +Lemma nbhs_pfilter_subproof (p : T) : ProperFilter (nbhs p). +Proof. +apply: Build_ProperFilter. by move=> A [B [_ Bp sBA]]; exists p; apply: sBA. -split; first by exists setT. +split; first by exists setT; split=> [|//|//]; exact: opT. move=> A B [C [Cop Cp sCA]] [D [Dop Dp sDB]]. - exists (C `&` D); split => //; first exact: opI. + exists (C `&` D); split=> //; first exact: opI. by move=> q [/sCA Aq /sDB Bq]. move=> A B sAB [C [Cop p_C sCA]]. by exists C; split=> //; apply: subset_trans sAB. Qed. -Next Obligation. done. Qed. -Next Obligation. + +Lemma nbhsE_subproof (p : T) : + nbhs p = [set A | exists B, [/\ op B, B p & B `<=` A] ]. +Proof. by []. Qed. + +Lemma openE_subproof : op = [set A : set T | A `<=` nbhs^~ A]. +Proof. rewrite predeqE => A; split=> [Aop p Ap|Aop]. by exists A; split=> //; split. suff -> : A = \bigcup_(B : {B : set T & op B /\ B `<=` A}) projT1 B. @@ -2202,28 +2158,34 @@ rewrite predeqE => p; split=> [|[B _ Bp]]; last by have [_] := projT2 B; apply. by move=> /Aop [B [Bop Bp sBA]]; exists (existT _ B (conj Bop sBA)). Qed. -End TopologyOfOpen. +HB.instance Definition _ := Nbhs_isTopological.Build T + nbhs_pfilter_subproof nbhsE_subproof openE_subproof. + +HB.end. (** Topology defined by a base of open sets *) -Section TopologyOfBase. +(* was topologyOfBaseMixin *) +HB.factory Record Pointed_isBaseTopological T of Pointed T := { + I : pointedType; + D : set I; + b : I -> (set T); + b_cover : \bigcup_(i in D) b i = setT; + b_join : forall i j t, D i -> D j -> b i t -> b j t -> + exists k, [/\ D k, b k t & b k `<=` b i `&` b j]; +}. -Definition open_from I T (D : set I) (b : I -> set T) := - [set \bigcup_(i in D') b i | D' in subset^~ D]. +HB.builders Context T of Pointed_isBaseTopological T. -Lemma open_fromT I T (D : set I) (b : I -> set T) : - \bigcup_(i in D) b i = setT -> open_from D b setT. -Proof. by move=> ?; exists D. Qed. +Definition open_from := [set \bigcup_(i in D') b i | D' in subset^~ D]. -Variable (I : pointedType) (T : Type) (D : set I) (b : I -> (set T)). -Hypothesis (b_cover : \bigcup_(i in D) b i = setT). -Hypothesis (b_join : forall i j t, D i -> D j -> b i t -> b j t -> - exists k, [/\ D k, b k t & b k `<=` b i `&` b j]). +Lemma open_fromT : open_from setT. +Proof. exists D => //; exact: b_cover. Qed. -Program Definition topologyOfBaseMixin := - @topologyOfOpenMixin _ (open_from D b) (open_fromT b_cover) _ _. -Next Obligation. -move=> A B [DA sDAD AeUbA] [DB sDBD BeUbB]. +Lemma open_fromI (A B : set T) : open_from A -> open_from B -> + open_from (A `&` B). +Proof. +move=> [DA sDAD AeUbA] [DB sDBD BeUbB]. have ABU : forall t, (A `&` B) t -> exists it, D it /\ b it t /\ b it `<=` A `&` B. move=> t [At Bt]. @@ -2242,8 +2204,10 @@ rewrite predeqE => t; split=> [[_ [s ABs <-] bDtst]|ABt]. by have /ABU/getPex [_ [_]] := ABs; apply. by exists (get (Dt t)); [exists t| have /ABU/getPex [? []]:= ABt]. Qed. -Next Obligation. -move=> I0 f. + +Lemma open_from_bigU (I0 : Type) (f : I0 -> set T) : + (forall i, open_from (f i)) -> open_from (\bigcup_i f i). +Proof. set fop := fun j => [set Dj | Dj `<=` D /\ f j = \bigcup_(i in Dj) b i]. exists (\bigcup_j get (fop j)). move=> i [j _ fopji]. @@ -2256,7 +2220,10 @@ have /getPex [_ ->] : exists Dj, fop j Dj by have [Dj] := H j; exists Dj. by move=> [i]; exists i => //; exists j. Qed. -End TopologyOfBase. +HB.instance Definition _ := Pointed_isOpenTopological.Build T + open_fromT open_fromI open_from_bigU. + +HB.end. Section filter_supremums. @@ -2365,14 +2332,27 @@ Proof. by rewrite filterI_iter_finI filterI_iterE. Qed. End filter_supremums. -Section TopologyOfSubbase. +(* was TopologyOfSubbase *) +HB.factory Record Pointed_isSubBaseTopological T of Pointed T := { + I : pointedType; + D : set I; + b : I -> (set T); +}. -Variable (I : pointedType) (T : Type) (D : set I) (b : I -> set T). +HB.builders Context T of Pointed_isSubBaseTopological T. -Program Definition topologyOfSubbaseMixin := - @topologyOfBaseMixin _ _ (finI_from D b) id (finI_from_cover D b) _. -Next Obligation. -move=> A B t [DA sDAD AeIbA] [DB sDBD BeIbB] At Bt. +Local Notation finI_from := (finI_from D b). + +Lemma finI_from_cover : \bigcup_(A in finI_from) A = setT. +Proof. +rewrite predeqE => t; split=> // _; exists setT => //. +by exists fset0 => //; rewrite predeqE. +Qed. + +Lemma finI_from_join A B t : finI_from A -> finI_from B -> A t -> B t -> + exists k, [/\ finI_from k, k t & k `<=` A `&` B]. +Proof. +move=> [DA sDAD AeIbA] [DB sDBD BeIbB] At Bt. exists (A `&` B); split => //. exists (DA `|` DB)%fset; first by move=> i /fsetUP [/sDAD|/sDBD]. rewrite predeqE => s; split=> [Ifs|[As Bs] i /fsetUP]. @@ -2382,7 +2362,10 @@ by move=> [DAi|DBi]; [have := As; rewrite -AeIbA; apply|have := Bs; rewrite -BeIbB; apply]. Qed. -End TopologyOfSubbase. +HB.instance Definition _ := Pointed_isBaseTopological.Build T + finI_from_cover finI_from_join. + +HB.end. (** Topology on nat *) @@ -2397,18 +2380,10 @@ Let bD : forall i j t, D i -> D j -> b i t -> b j t -> exists k, [/\ D k, b k t & b k `<=` b i `&` b j]. Proof. by move=> i j t _ _ -> ->; exists j. Qed. -Definition nat_topologicalTypeMixin := topologyOfBaseMixin bT bD. -Canonical nat_filteredType := FilteredType nat nat (nbhs_of_open (open_from D b)). -Canonical nat_topologicalType := TopologicalType nat nat_topologicalTypeMixin. +HB.instance Definition _ := Pointed_isBaseTopological.Build nat bT bD. End nat_topologicalType. -(* :TODO: ultimately nat could be replaced by any lattice *) -Definition eventually := filter_from setT (fun N => [set n | (N <= n)%N]). -Notation "'\oo'" := eventually : classical_set_scope. - -Canonical eventually_filter_source X := - @Filtered.Source X _ nat (fun f => f @ \oo). Global Instance eventually_filter : ProperFilter eventually. Proof. @@ -2433,27 +2408,27 @@ Proof. by move=> P [n _ Pn]; exists (n - N)%N => // m; rewrite /= leq_subLR => /Pn. Qed. -Lemma cvg_addnr N : addn^~ N --> \oo. +Lemma cvg_addnr N : addn^~ N @ \oo --> \oo. Proof. by under [addn^~ N]funext => n do rewrite addnC; apply: cvg_addnl. Qed. -Lemma cvg_subnr N : subn^~ N --> \oo. +Lemma cvg_subnr N : subn^~ N @ \oo --> \oo. Proof. move=> P [n _ Pn]; exists (N + n)%N => //= m le_m. by apply: Pn; rewrite /= leq_subRL// (leq_trans _ le_m)// leq_addr. Qed. -Lemma cvg_mulnl N : (N > 0)%N -> muln N --> \oo. +Lemma cvg_mulnl N : (N > 0)%N -> muln N @ \oo --> \oo. Proof. case: N => N // _ P [n _ Pn]; exists (n %/ N.+1).+1 => // m. by rewrite /= ltn_divLR// => n_lt; apply: Pn; rewrite mulnC /= ltnW. Qed. -Lemma cvg_mulnr N :(N > 0)%N -> muln^~ N --> \oo. +Lemma cvg_mulnr N :(N > 0)%N -> muln^~ N @ \oo --> \oo. Proof. by move=> N_gt0; under [muln^~ N]funext => n do rewrite mulnC; apply: cvg_mulnl. Qed. -Lemma cvg_divnr N : (N > 0)%N -> divn^~ N --> \oo. +Lemma cvg_divnr N : (N > 0)%N -> divn^~ N @ \oo --> \oo. Proof. move=> N_gt0 P [n _ Pn]; exists (n * N)%N => //= m. by rewrite /= -leq_divRL//; apply: Pn. @@ -2466,7 +2441,7 @@ Proof. case=> N _ NPS; exists (S N) => // [[]]; rewrite /= ?ltn0 //. Qed. Section infty_nat. Local Open Scope nat_scope. -Let cvgnyP {F : set (set nat)} {FF : Filter F} : [<-> +Let cvgnyP {F : set_system nat} {FF : Filter F} : [<-> (* 0 *) F --> \oo; (* 1 *) forall A, \forall x \near F, A <= x; (* 2 *) forall A, \forall x \near F, A < x; @@ -2486,7 +2461,7 @@ Unshelve. all: end_near. Qed. Section map. -Context {I : Type} {F : set (set I)} {FF : Filter F} (f : I -> nat). +Context {I : Type} {F : set_system I} {FF : Filter F} (f : I -> nat). Lemma cvgnyPge : f @ F --> \oo <-> forall A, \forall x \near F, A <= f x. @@ -2531,11 +2506,10 @@ move=> [QR [/nbhs_interior p1_Q /nbhs_interior p2_R] sQRA]. by exists (QR.1^°, QR.2^°) => // ??; exists QR. Qed. -Definition prod_topologicalTypeMixin := - topologyOfFilterMixin prod_nbhs_filter prod_nbhs_singleton prod_nbhs_nbhs. +HB.instance Definition _ := hasNbhs.Build (T * U)%type prod_nbhs. -Canonical prod_topologicalType := - TopologicalType (T * U) prod_topologicalTypeMixin. +HB.instance Definition _ := Nbhs_isNbhsTopological.Build (T * U)%type + prod_nbhs_filter prod_nbhs_singleton prod_nbhs_nbhs. End Prod_Topology. @@ -2583,31 +2557,32 @@ move=> [P M_P sPA]; exists (fun i j => (P i j)^°). by move=> ? ?; exists P. Qed. -Definition matrix_topologicalTypeMixin := - topologyOfFilterMixin mx_nbhs_filter mx_nbhs_singleton mx_nbhs_nbhs. - -Canonical matrix_topologicalType := - TopologicalType 'M[T]_(m, n) matrix_topologicalTypeMixin. +HB.instance Definition _ := Nbhs_isNbhsTopological.Build 'M[T]_(m, n) + mx_nbhs_filter mx_nbhs_singleton mx_nbhs_nbhs. End matrix_Topology. (** Weak topology by a function *) +Definition weak_topology {S : pointedType} {T : topologicalType} + (f : S -> T) : Type := S. + Section Weak_Topology. Variable (S : pointedType) (T : topologicalType) (f : S -> T). +Local Notation W := (weak_topology f). Definition wopen := [set f @^-1` A | A in open]. -Lemma wopT : wopen setT. +Lemma wopT : wopen [set: W]. Proof. by exists setT => //; apply: openT. Qed. -Lemma wopI (A B : set S) : wopen A -> wopen B -> wopen (A `&` B). +Lemma wopI (A B : set W) : wopen A -> wopen B -> wopen (A `&` B). Proof. by move=> [C Cop <-] [D Dop <-]; exists (C `&` D) => //; apply: openI. Qed. -Lemma wop_bigU (I : Type) (g : I -> set S) : +Lemma wop_bigU (I : Type) (g : I -> set W) : (forall i, wopen (g i)) -> wopen (\bigcup_i g i). Proof. move=> gop. @@ -2621,23 +2596,20 @@ rewrite predeqE => s; split=> [[i _]|[i _]]; last by rewrite g_preim; exists i. by rewrite -[_ _]/((f @^-1` _) _) -g_preim; exists i. Qed. -Definition weak_topologicalTypeMixin := topologyOfOpenMixin wopT wopI wop_bigU. - -Let S_filteredClass := Filtered.Class (Pointed.class S) (nbhs_of_open wopen). -Definition weak_topologicalType := - Topological.Pack (@Topological.Class _ S_filteredClass - weak_topologicalTypeMixin). +HB.instance Definition _ := Pointed.on W. +HB.instance Definition _ := + Pointed_isOpenTopological.Build W wopT wopI wop_bigU. -Lemma weak_continuous : continuous (f : weak_topologicalType -> T). +Lemma weak_continuous : continuous (f : W -> T). Proof. by apply/continuousP => A ?; exists A. Qed. -Lemma cvg_image (F : set (set S)) (s : S) : +Lemma cvg_image (F : set_system S) (s : S) : Filter F -> f @` setT = setT -> - F --> (s : weak_topologicalType) <-> [set f @` A | A in F] --> f s. + F --> (s : W) <-> ([set f @` A | A in F] : set_system _) --> f s. Proof. move=> FF fsurj; split=> [cvFs|cvfFfs]. move=> A /weak_continuous [B [Bop Bs sBAf]]. - have /cvFs FB : nbhs (s : weak_topologicalType) B by apply: open_nbhs_nbhs. + have /cvFs FB : nbhs (s : W) B by apply: open_nbhs_nbhs. rewrite nbhs_simpl; exists (f @^-1` A); first exact: filterS FB. exact: image_preimage. move=> A /= [_ [[B Bop <-] Bfs sBfA]]. @@ -2650,22 +2622,23 @@ End Weak_Topology. (** Supremum of a family of topologies *) +Definition sup_topology {T : pointedType} {I : Type} + (Tc : I -> Topological T) : Type := T. + Section Sup_Topology. -Variable (T : pointedType) (I : Type) (Tc : I -> Topological.class_of T). +Variable (T : pointedType) (I : Type) (Tc : I -> Topological T). +Local Notation S := (sup_topology Tc). Let TS := fun i => Topological.Pack (Tc i). -Definition sup_subbase := \bigcup_i (@open (TS i) : set (set T)). +Definition sup_subbase := \bigcup_i (@open (TS i) : set_system T). -Definition sup_topologicalTypeMixin := topologyOfSubbaseMixin sup_subbase id. +HB.instance Definition _ := Pointed.on S. +HB.instance Definition _ := Pointed_isSubBaseTopological.Build S sup_subbase id. -Definition sup_topologicalType := - Topological.Pack (@Topological.Class _ (Filtered.Class (Pointed.class T) _) - sup_topologicalTypeMixin). - -Lemma cvg_sup (F : set (set T)) (t : T) : - Filter F -> F --> (t : sup_topologicalType) <-> forall i, F --> (t : TS i). +Lemma cvg_sup (F : set_system T) (t : T) : + Filter F -> F --> (t : S) <-> forall i, F --> (t : TS i). Proof. move=> Ffilt; split=> cvFt. move=> i A /=; rewrite (@nbhsE (TS i)) => - [B [Bop Bt] sBA]. @@ -2674,7 +2647,7 @@ move=> Ffilt; split=> cvFt. move=> _ ->; exists [fset B]%fset. by move=> ?; rewrite inE inE => /eqP->; exists i. by rewrite predeqE=> ?; split=> [|??]; [apply|]; rewrite /= inE // =>/eqP->. -move=> A /=; rewrite (@nbhsE sup_topologicalType). +move=> A /=; rewrite (@nbhsE [the topologicalType of S]). move=> [_ [[B sB <-] [C BC Ct] sUBA]]. rewrite nbhs_filterE; apply: filterS sUBA _; apply: (@filterS _ _ _ C). by move=> ? ?; exists C. @@ -2689,11 +2662,16 @@ End Sup_Topology. Section Product_Topology. +Definition prod_topology {I : Type} (T : I -> Type) := forall i, T i. + Variable (I : Type) (T : I -> topologicalType). -Definition product_topologicalType := - sup_topologicalType (fun i => Topological.class - (weak_topologicalType (fun f : dep_arrow_pointedType T => f i))). +Definition product_topology_def := + sup_topology (fun i => Topological.class + (weak_topology (fun f : [the pointedType of (forall i : I, T i)] => f i))). + +HB.instance Definition _ := + Topological.copy (prod_topology T) product_topology_def. End Product_Topology. @@ -2725,14 +2703,14 @@ Canonical dnbhs_filter_on (T : topologicalType) (x : T) := FilterType x^' (dnbhs_filter _). Lemma cvg_fmap2 (T U : Type) (f : T -> U): - forall (F G : set (set T)), G `=>` F -> f @ G `=>` f @ F. + forall (F G : set_system T), G `=>` F -> f @ G `=>` f @ F. Proof. by move=> F G H A fFA ; exact: H (preimage f A) fFA. Qed. -Lemma cvg_within_filter {T U} {f : T -> U} (F : set (set T)) {FF : (Filter F) } - (G : set (set U)) : forall (D : set T), (f @ F) --> G -> (f @ within D F) --> G. +Lemma cvg_within_filter {T U} {f : T -> U} (F : set_system T) {FF : (Filter F) } + (G : set_system U) : forall (D : set T), (f @ F) --> G -> (f @ within D F) --> G. Proof. move=> ?; exact: cvg_trans (cvg_fmap2 (cvg_within _)). Qed. -Lemma cvg_app_within {T} {U : topologicalType} (f : T -> U) (F : set (set T)) +Lemma cvg_app_within {T} {U : topologicalType} (f : T -> U) (F : set_system T) (D : set T): Filter F -> cvg (f @ F) -> cvg (f @ within D F). Proof. by move => FF /cvg_ex [l H]; apply/cvg_ex; exists l; exact: cvg_within_filter. Qed. @@ -2741,14 +2719,14 @@ Proof. exact: cvg_within. Qed. (** meets *) -Lemma meets_openr {T : topologicalType} (F : set (set T)) (x : T) : +Lemma meets_openr {T : topologicalType} (F : set_system T) (x : T) : F `#` nbhs x = F `#` open_nbhs x. Proof. rewrite propeqE; split; [exact/meetsSr/open_nbhs_nbhs|]. by move=> P A B {}/P P; rewrite nbhsE => -[B' /P + sB]; apply: subsetI_neq0. Qed. -Lemma meets_openl {T : topologicalType} (F : set (set T)) (x : T) : +Lemma meets_openl {T : topologicalType} (F : set_system T) (x : T) : nbhs x `#` F = open_nbhs x `#` F. Proof. by rewrite meetsC meets_openr meetsC. Qed. @@ -2765,14 +2743,14 @@ Proof. by rewrite meetsC meets_globallyl; under eq_forall do rewrite setIC. Qed. -Lemma meetsxx T (F : set (set T)) (FF : Filter F) : F `#` F = ~ (F set0). +Lemma meetsxx T (F : set_system T) (FF : Filter F) : F `#` F = ~ (F set0). Proof. rewrite propeqE; split => [FmF F0|]; first by have [x []] := FmF _ _ F0 F0. move=> FN0 A B /filterI FAI {}/FAI FAB; apply/set0P/eqP => AB0. by rewrite AB0 in FAB. Qed. -Lemma proper_meetsxx T (F : set (set T)) (FF : ProperFilter F) : F `#` F. +Lemma proper_meetsxx T (F : set_system T) (FF : ProperFilter F) : F `#` F. Proof. by rewrite meetsxx; apply: filter_not_empty. Qed. (** Closed sets in topological spaces *) @@ -2973,7 +2951,7 @@ Section Compact. Context {T : topologicalType}. -Definition cluster (F : set (set T)) := [set p : T | F `#` nbhs p]. +Definition cluster (F : set_system T) := [set p : T | F `#` nbhs p]. Lemma cluster_nbhs t : cluster (nbhs t) t. Proof. by move=> A B /nbhs_singleton At /nbhs_singleton Bt; exists t. Qed. @@ -3023,7 +3001,7 @@ Lemma closureEcvg (E : set T): [set p | exists2 G, ProperFilter G & G --> p /\ globally E `<=` G]. Proof. by rewrite closureEcluster cluster_cvgE. Qed. -Definition compact A := forall (F : set (set T)), +Definition compact A := forall (F : set_system T), ProperFilter F -> F A -> A `&` cluster F !=set0. Lemma compact0 : compact set0. @@ -3096,7 +3074,7 @@ Section near_covering. Context {X : topologicalType}. Definition near_covering (K : set X) := - forall (I : Type) (F : set (set I)) (P : I -> X -> Prop), + forall (I : Type) (F : set_system I) (P : I -> X -> Prop), Filter F -> (forall x, K x -> \forall x' \near x & i \near F, P i x') -> \near F, K `<=` P F. @@ -3147,7 +3125,7 @@ by split; [exact: compact_near_covering| exact: near_covering_compact]. Qed. Definition near_covering_within (K : set X) := - forall (I : Type) (F : set (set I)) (P : I -> X -> Prop), + forall (I : Type) (F : set_system I) (P : I -> X -> Prop), Filter F -> (forall x, K x -> \forall x' \near x & i \near F, K x' -> P i x') -> \near F, K `<=` P F. @@ -3180,12 +3158,12 @@ Unshelve. all: by end_near. Qed. Section Tychonoff. -Class UltraFilter T (F : set (set T)) := { +Class UltraFilter T (F : set_system T) := { ultra_proper :> ProperFilter F ; - max_filter : forall G : set (set T), ProperFilter G -> F `<=` G -> G = F + max_filter : forall G : set_system T, ProperFilter G -> F `<=` G -> G = F }. -Lemma ultra_cvg_clusterE (T : topologicalType) (F : set (set T)) : +Lemma ultra_cvg_clusterE (T : topologicalType) (F : set_system T) : UltraFilter F -> cluster F = [set p | F --> p]. Proof. move=> FU; rewrite predeqE => p; split. @@ -3193,11 +3171,11 @@ move=> FU; rewrite predeqE => p; split. by move=> cvFp; rewrite cluster_cvgE; exists F; [apply: ultra_proper|split]. Qed. -Lemma ultraFilterLemma T (F : set (set T)) : +Lemma ultraFilterLemma T (F : set_system T) : ProperFilter F -> exists G, UltraFilter G /\ F `<=` G. Proof. move=> FF. -set filter_preordset := ({G : set (set T) & ProperFilter G /\ F `<=` G}). +set filter_preordset := ({G : set_system T & ProperFilter G /\ F `<=` G}). set preorder := fun G1 G2 : filter_preordset => projT1 G1 `<=` projT1 G2. suff [G Gmax] : exists G : filter_preordset, premaximal preorder G. have [GF sFG] := projT2 G; exists (projT1 G); split=> //; split=> // H HF sGH. @@ -3229,7 +3207,7 @@ exact: filterS HB. Qed. Lemma compact_ultra (T : topologicalType) : - compact = [set A | forall F : set (set T), + compact = [set A | forall F : set_system T, UltraFilter F -> F A -> A `&` [set p | F --> p] !=set0]. Proof. rewrite predeqE => A; split=> Aco F FF FA. @@ -3240,7 +3218,7 @@ rewrite /= -[_ --> p]/([set _ | _] p) -ultra_cvg_clusterE. by move=> /(cvg_cluster sFG); exists p. Qed. -Lemma filter_image (T U : Type) (f : T -> U) (F : set (set T)) : +Lemma filter_image (T U : Type) (f : T -> U) (F : set_system T) : Filter F -> f @` setT = setT -> Filter [set f @` A | A in F]. Proof. move=> FF fsurj; split. @@ -3255,7 +3233,7 @@ move=> FF fsurj; split. by apply: filterS FC => p Cp; apply: sAB; rewrite -fC_eqA; exists p. Qed. -Lemma proper_image (T U : Type) (f : T -> U) (F : set (set T)) : +Lemma proper_image (T U : Type) (f : T -> U) (F : set_system T) : ProperFilter F -> f @` setT = setT -> ProperFilter [set f @` A | A in F]. Proof. move=> FF fsurj; apply: Build_ProperFilter; last exact: filter_image. @@ -3271,7 +3249,7 @@ have /(filterI GU): G [set x] by exact/FG/principal_filterP. by rewrite setIC set1I; case: ifPn => // /[!inE]. Qed. -Lemma in_ultra_setVsetC T (F : set (set T)) (A : set T) : +Lemma in_ultra_setVsetC T (F : set_system T) (A : set T) : UltraFilter F -> F A \/ F (~` A). Proof. move=> FU; case: (pselect (F (~` A))) => [|nFnA]; first by right. @@ -3295,7 +3273,7 @@ exists (A `&` (DB `&` DC)); last by move=> ??; rewrite setIACA setIid. by right; exists (DB `&` DC) => //; apply: filterI. Qed. -Lemma ultra_image (T U : Type) (f : T -> U) (F : set (set T)) : +Lemma ultra_image (T U : Type) (f : T -> U) (F : set_system T) : UltraFilter F -> f @` setT = setT -> UltraFilter [set f @` A | A in F]. Proof. move=> FU fsurj; split; first exact: proper_image. @@ -3311,8 +3289,7 @@ Qed. Lemma tychonoff (I : eqType) (T : I -> topologicalType) (A : forall i, set (T i)) : (forall i, compact (A i)) -> - @compact (product_topologicalType T) - [set f : forall i, T i | forall i, A i (f i)]. + compact [set f : prod_topology T | forall i, A i (f i)]. Proof. move=> Aco; rewrite compact_ultra => F FU FA. set subst_coord := fun (i : I) (pi : T i) (f : forall x : I, T x) (j : I) => @@ -3326,7 +3303,7 @@ have subst_coordN i pi f j : i != j -> subst_coord i pi f j = f j. have pr_surj i : @^~ i @` [set: forall i, T i] = setT. rewrite predeqE => pi; split=> // _. by exists (subst_coord i pi (fun _ => point))=> //; rewrite subst_coordT. -set pF := fun i => [set @^~ i @` B | B in F]. +pose pF i : set_system _ := [set @^~ i @` B | B in F]. have pFultra : forall i, UltraFilter (pF i). by move=> i; apply: ultra_image (pr_surj i). have pFA : forall i, pF i (A i). @@ -3387,7 +3364,7 @@ Proof. by move=> ?; elim/big_ind : _ =>//; [exact:compact0|exact:compactU]. Qed. (* The closed condition here is neccessary to make this definition work in a *) (* non-hausdorff setting. *) -Definition compact_near (F : set (set X)) := +Definition compact_near (F : set_system X) := exists2 U, F U & compact U /\ closed U. Definition precompact (C : set X) := compact_near (globally C). @@ -3428,12 +3405,15 @@ End Precompact. Section product_spaces. Context {I : eqType} {K : I -> topologicalType}. -Let PK := product_topologicalType K. +(* This a helper function to prove products preserve hausdorff. In particular *) +(* we use its continuity turn clustering in `product_topologicalType K` to *) +(* clustering in K x for each X. *) +Definition prod_topo_apply x (f : forall i, K i) := f x. (* Note we have to give the signature explicitly because there's no canonical *) (* topology associated with `K`. This should be cleaned up after HB port. *) -Lemma proj_continuous i : continuous (proj i : PK -> K i). +Lemma proj_continuous i : continuous (proj i : prod_topology K -> K i). Proof. move=> f; have /cvg_sup/(_ i)/cvg_image : f --> f by apply: cvg_id. move=> h; apply: cvg_trans (h _) => {h}. @@ -3442,7 +3422,7 @@ rewrite eqEsubset; split => y //; exists (dfwith (fun=> point) i y) => //. by rewrite dfwithin. Qed. -Lemma dfwith_continuous g (i : I) : continuous (dfwith g _ : K i -> PK). +Lemma dfwith_continuous g (i : I) : continuous (dfwith g _ : K i -> prod_topology K). Proof. move=> z U [] P [] [] Q QfinP <- [] V JV Vpz. move/(@preimage_subset _ _ (dfwith g i))/filterS; apply. @@ -3457,7 +3437,7 @@ apply: nearW => y /=; move: Vpz. by rewrite -VL => /(_ _ LM); rewrite -NM /= ? dfwithout // eq_sym. Qed. -Lemma proj_open i (A : set PK) : open A -> open (proj i @` A). +Lemma proj_open i (A : set (prod_topology K)) : open A -> open (proj i @` A). Proof. move=> oA; rewrite openE => z [f Af <-]; rewrite openE in oA. have {oA} := oA _ Af; rewrite /interior => nAf. @@ -3468,7 +3448,7 @@ by apply: functional_extensionality_dep => ?; case: dfwithP. Qed. Lemma hausdorff_product : - (forall x, hausdorff_space (K x)) -> hausdorff_space PK. + (forall x, hausdorff_space (K x)) -> hausdorff_space (prod_topology K). Proof. move=> hsdfK p q /= clstr; apply: functional_extensionality_dep => x. apply: hsdfK; move: clstr; rewrite ?cluster_cvgE /= => -[G PG [GtoQ psubG]]. @@ -3499,7 +3479,7 @@ move=> finIf; apply: (filter_from_proper (filter_from_filter _ _)). - by move=> _ [?? <-]; apply: finIf. Qed. -Lemma filter_finI (T : pointedType) (F : set (set T)) (D : set (set T)) +Lemma filter_finI (T : pointedType) (F : set_system T) (D : set_system T) (f : set T -> set T) : ProperFilter F -> (forall A, D A -> F (f A)) -> finI D f. Proof. @@ -3749,7 +3729,7 @@ Lemma close_refl x : close x x. Proof. exact: (@cvg_close (nbhs x)). Qed. Hint Resolve close_refl : core. -Lemma close_cvg (F1 F2 : set (set T)) {FF2 : ProperFilter F2} : +Lemma close_cvg (F1 F2 : set_system T) {FF2 : ProperFilter F2} : F1 --> F2 -> F2 --> F1 -> close (lim F1) (lim F2). Proof. move=> F12 F21. @@ -3825,7 +3805,7 @@ Proof. move=> Fx Fy; rewrite -closeE //; exact: (@cvg_close F). Qed. Lemma cvg_eq x y : x --> y -> x = y. Proof. by rewrite -closeE //; apply: cvg_close. Qed. -Lemma lim_id x : lim x = x. +Lemma lim_id x : lim (nbhs x) = x. Proof. by apply/esym/cvg_eq/cvg_ex; exists x. Qed. Lemma cvg_lim {U : Type} {F} {FF : ProperFilter F} (f : U -> T) (l : T) : @@ -4101,13 +4081,9 @@ Lemma discrete_nbhs (p : X) (A : set X) : principal_filter p A -> principal_filter p (principal_filter^~ A). Proof. by move=> ?; exact/principal_filterP. Qed. -Definition discrete_topological_mixin := - topologyOfFilterMixin principal_filter_proper discrete_sing discrete_nbhs. - End DiscreteMixin. -Definition discrete_space (X : topologicalType) := - @nbhs X _ = @principal_filter X. +Definition discrete_space (X : nbhsType) := @nbhs X _ = @principal_filter X. Context {X : topologicalType} {dsc: discrete_space X}. @@ -4122,10 +4098,10 @@ Proof. by apply: open_nbhs_nbhs; split => //; exact: discrete_open. Qed. Lemma discrete_closed (A : set X) : closed A. Proof. by rewrite -[A]setCK closedC; exact: discrete_open. Qed. -Lemma discrete_cvg (F : set (set X)) (x : X) : +Lemma discrete_cvg (F : set_system X) (x : X) : Filter F -> F --> x <-> F [set x]. Proof. -rewrite /filter_of dsc nbhs_simpl; split; first by exact. +rewrite dsc nbhs_simpl; split; first by exact. by move=> Fx U /principal_filterP ?; apply: filterS Fx => ? ->. Qed. @@ -4134,10 +4110,10 @@ Proof. by move=> p q /(_ _ _ (discrete_set1 p) (discrete_set1 q))[x [] -> ->]. Qed. -Canonical bool_discrete_topology : topologicalType := - TopologicalType bool discrete_topological_mixin. +HB.instance Definition _ := Nbhs_isNbhsTopological.Build bool + principal_filter_proper discrete_sing discrete_nbhs. -Lemma discrete_bool : discrete_space bool_discrete_topology. +Lemma discrete_bool : discrete_space [the topologicalType of bool : Type]. Proof. by []. Qed. Lemma bool_compact : compact [set: bool]. @@ -4168,17 +4144,17 @@ by exists y; split => //; [exact/eqP | exact: VU]. Qed. Lemma perfect_prod {I : Type} (i : I) (K : I -> topologicalType) : - perfect_set [set: K i] -> perfect_set [set: product_topologicalType K]. + perfect_set [set: K i] -> perfect_set [set: prod_topology K]. Proof. move=> /perfectTP KPo; apply/perfectTP => f oF; apply: (KPo (f i)). rewrite (_ : [set f i] = proj i @` [set f]). - by apply: (@proj_open (classicType_choiceType I) _ i); exact: oF. + by apply: (@proj_open {classic I} _ i); exact: oF. by rewrite eqEsubset; split => ? //; [move=> -> /=; exists f | case=> g ->]. Qed. -Lemma perfect_diagonal (K : nat_topologicalType -> topologicalType) : +Lemma perfect_diagonal (K : nat -> topologicalType) : (forall i, exists (xy: K i * K i), xy.1 != xy.2) -> - perfect_set [set: product_topologicalType K]. + perfect_set [set: prod_topology K]. Proof. move=> npts; split; first exact: closedT. rewrite eqEsubset; split => f // _. @@ -4186,8 +4162,8 @@ pose distincts (i : nat) := projT1 (sigW (npts i)). pose derange (i : nat) (z : K i) := if z == (distincts i).1 then (distincts i).2 else (distincts i).1. pose g (N i : nat) := if (i < N)%nat then f i else derange _ (f i). -have gcvg : g @ \oo --> (f : product_topologicalType K). - apply/(@cvg_sup (product_topologicalType K)) => N U [V] [][W] oW <- WfN WU. +have gcvg : g @ \oo --> f. + apply/cvg_sup => N U [V] [[W] oW <-] WfN WU. by apply: (filterS WU); rewrite nbhs_simpl /g; exists N.+1 => // i /= ->. move=> A /gcvg; rewrite nbhs_simpl; case=> N _ An. exists (g N); split => //; last by apply: An; rewrite /= ?leqnn //. @@ -4223,7 +4199,7 @@ Definition zero_dimensional T := Lemma zero_dimension_prod (I : choiceType) (T : I -> topologicalType) : (forall i, zero_dimensional (T i)) -> - zero_dimensional (product_topologicalType T). + zero_dimensional (prod_topology T). Proof. move=> dctTI x y /eqP xneqy. have [i/eqP/dctTI [U [clU Ux nUy]]] : exists i, x i <> y i. @@ -4283,116 +4259,88 @@ Local Notation "A ^-1" := ([set xy | A (xy.2, xy.1)]) : classical_set_scope. Local Notation "'to_set' A x" := ([set y | A (x, y)]) (at level 0, A at level 0) : classical_set_scope. -Definition nbhs_ {T T'} (ent : set (set (T * T'))) (x : T) := +Definition nbhs_ {T T'} (ent : set_system (T * T')) (x : T) := filter_from ent (fun A => to_set A x). -Lemma nbhs_E {T T'} (ent : set (set (T * T'))) x : +Lemma nbhs_E {T T'} (ent : set_system (T * T')) x : nbhs_ ent x = filter_from ent (fun A => to_set A x). Proof. by []. Qed. -Module Uniform. +HB.mixin Record Nbhs_isUniform_mixin M of Nbhs M := { + entourage : set_system (M * M); + entourage_filter : Filter entourage; + entourage_refl_subproof : forall A, entourage A -> [set xy | xy.1 = xy.2] `<=` A; + entourage_inv_subproof : forall A, entourage A -> entourage (A^-1)%classic; + entourage_split_ex_subproof : + forall A, entourage A -> exists2 B, entourage B & B \; B `<=` A; + nbhsE_subproof : nbhs = nbhs_ entourage; +}. + +#[short(type="uniformType")] +HB.structure Definition Uniform := + {T of Topological T & Nbhs_isUniform_mixin T}. -Record mixin_of (M : Type) (nbhs : M -> set (set M)) := Mixin { - entourage : (M * M -> Prop) -> Prop ; - entourage_filter : Filter entourage ; - entourage_refl : forall A, entourage A -> [set xy | xy.1 = xy.2] `<=` A ; - entourage_inv : forall A, entourage A -> entourage (A^-1)%classic ; +HB.factory Record Nbhs_isUniform M of Nbhs M := { + entourage : set_system (M * M); + entourage_filter : Filter entourage; + entourage_refl : forall A, entourage A -> [set xy | xy.1 = xy.2] `<=` A; + entourage_inv : forall A, entourage A -> entourage (A^-1)%classic; entourage_split_ex : - forall A, entourage A -> exists2 B, entourage B & B \; B `<=` A ; - nbhsE : nbhs = nbhs_ entourage + forall A, entourage A -> exists2 B, entourage B & B \; B `<=` A; + nbhsE : nbhs = nbhs_ entourage; }. -Record class_of (M : Type) := Class { - base : Topological.class_of M; - mixin : mixin_of (Filtered.nbhs_op base) -}. +HB.builders Context M of Nbhs_isUniform M. -Section ClassDef. - -Structure type := Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of cT in c. - -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). -Local Coercion base : class_of >-> Topological.class_of. -Local Coercion mixin : class_of >-> mixin_of. - -Definition pack nbhs (m : @mixin_of T nbhs) := - fun bT (b : Topological.class_of T) of phant_id (@Topological.class bT) b => - fun m' of phant_id m (m' : @mixin_of T (Filtered.nbhs_op b)) => - @Pack T (@Class _ b m'). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. - -End ClassDef. - -Module Exports. - -Coercion sort : type >-> Sortclass. -Coercion base : class_of >-> Topological.class_of. -Coercion mixin : class_of >-> mixin_of. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Notation uniformType := type. -Notation UniformType T m := (@pack T _ m _ _ idfun _ idfun). -Notation UniformMixin := Mixin. -Notation "[ 'uniformType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'uniformType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'uniformType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'uniformType' 'of' T ]") : form_scope. - -End Exports. - -End Uniform. - -Export Uniform.Exports. - -Section UniformTopology. - -Program Definition topologyOfEntourageMixin (T : Type) - (nbhs : T -> set (set T)) (m : Uniform.mixin_of nbhs) : - Topological.mixin_of nbhs := topologyOfFilterMixin _ _ _. -Next Obligation. -move=> T nbhsT m p. -rewrite (Uniform.nbhsE m) nbhs_E; apply: filter_from_proper; last first. - by move=> A entA; exists p; apply: Uniform.entourage_refl entA _ _. +Lemma nbhs_filter (p : M) : ProperFilter (nbhs p). +Proof. +rewrite nbhsE nbhs_E; apply filter_from_proper; last first. + by move=> A entA; exists p; apply: entourage_refl entA _ _. apply: filter_from_filter. - by exists setT; apply: @filterT (Uniform.entourage_filter m). + by exists setT; apply: @filterT entourage_filter. move=> A B entA entB; exists (A `&` B) => //. -exact: (@filterI _ _ (Uniform.entourage_filter m)). +exact: (@filterI _ _ entourage_filter). Qed. -Next Obligation. -move=> T nbhsT m p A; rewrite (Uniform.nbhsE m) nbhs_E => - [B entB sBpA]. -by apply: sBpA; apply: Uniform.entourage_refl entB _ _. + +Lemma nbhs_singleton (p : M) A : nbhs p A -> A p. +Proof. +rewrite nbhsE nbhs_E => - [B entB sBpA]. +by apply: sBpA; apply: entourage_refl entB _ _. Qed. -Next Obligation. -move=> T nbhsT m p A; rewrite (Uniform.nbhsE m) nbhs_E => - [B entB sBpA]. -have /Uniform.entourage_split_ex [C entC sC2B] := entB. + +Lemma nbhs_nbhs (p : M) A : nbhs p A -> nbhs p (nbhs^~ A). +Proof. +rewrite nbhsE nbhs_E => - [B entB sBpA]. +have /entourage_split_ex[C entC sC2B] := entB. exists C => // q Cpq; rewrite nbhs_E; exists C => // r Cqr. by apply/sBpA/sC2B; exists q. Qed. -End UniformTopology. +HB.instance Definition _ := Nbhs_isNbhsTopological.Build M + nbhs_filter nbhs_singleton nbhs_nbhs. + +HB.instance Definition _ := Nbhs_isUniform_mixin.Build M + entourage_filter entourage_refl entourage_inv entourage_split_ex nbhsE. + +HB.end. -Definition entourage {M : uniformType} := Uniform.entourage (Uniform.class M). +HB.factory Record isUniform M of Pointed M := { + entourage : set_system (M * M); + entourage_filter : Filter entourage; + entourage_refl : forall A, entourage A -> [set xy | xy.1 = xy.2] `<=` A; + entourage_inv : forall A, entourage A -> entourage (A^-1)%classic; + entourage_split_ex : + forall A, entourage A -> exists2 B, entourage B & B \; B `<=` A; +}. + +HB.builders Context M of isUniform M. + HB.instance Definition _ := @hasNbhs.Build M (nbhs_ entourage). + HB.instance Definition _ := @Nbhs_isUniform.Build M entourage + entourage_filter entourage_refl entourage_inv entourage_split_ex erefl. +HB.end. Lemma nbhs_entourageE {M : uniformType} : nbhs_ (@entourage M) = nbhs. -Proof. by case: M=> [?[?[]]]. Qed. +Proof. by rewrite -Nbhs_isUniform_mixin.nbhsE_subproof. Qed. Lemma entourage_sym {X Y : Type} E (x : X) (y : Y) : E (x, y) <-> (E ^-1)%classic (y, x). @@ -4424,12 +4372,13 @@ Qed. Section uniformType1. Context {M : uniformType}. -Lemma entourage_refl (A : set (M * M)) x : entourage A -> A (x, x). -Proof. by move=> entA; apply: Uniform.entourage_refl entA _ _. Qed. +Lemma entourage_refl (A : set (M * M)) x : + entourage A -> A (x, x). +Proof. by move=> entA; apply: entourage_refl_subproof entA _ _. Qed. Global Instance entourage_pfilter : ProperFilter (@entourage M). Proof. -apply: Build_ProperFilter; last exact: Uniform.entourage_filter. +apply Build_ProperFilter; last exact: entourage_filter. by move=> A entA; exists (point, point); apply: entourage_refl. Qed. @@ -4437,11 +4386,11 @@ Lemma entourageT : entourage [set: M * M]. Proof. exact: filterT. Qed. Lemma entourage_inv (A : set (M * M)) : entourage A -> entourage (A^-1)%classic. -Proof. exact: Uniform.entourage_inv. Qed. +Proof. exact: entourage_inv_subproof. Qed. Lemma entourage_split_ex (A : set (M * M)) : entourage A -> exists2 B, entourage B & B \; B `<=` A. -Proof. exact: Uniform.entourage_split_ex. Qed. +Proof. exact: entourage_split_ex_subproof. Qed. Definition split_ent (A : set (M * M)) := get (entourage `&` [set B | B \; B `<=` A]). @@ -4512,8 +4461,7 @@ Lemma continuous_withinNx {U V : uniformType} (f : U -> V) x : {for x, continuous f} <-> f @ x^' --> f x. Proof. split=> - cfx P /= fxP. - rewrite /dnbhs !near_simpl near_withinE. - by rewrite /dnbhs; apply: cvg_within; apply: cfx. + by rewrite !near_simpl; apply: cvg_within; apply: cfx. rewrite !nbhs_nearE !near_map !near_nbhs in fxP *; have /= := cfx P fxP. rewrite !near_simpl near_withinE near_simpl => Pf; near=> y. by have [->|] := eqVneq y x; [by apply: nbhs_singleton|near: y]. @@ -4577,7 +4525,7 @@ apply: (entourage_split x) => //. by have := cxy _ (entourage_inv (entourage_split_ent entA)). Qed. -Lemma cvg_closeP (F : set (set U)) (l : U) : ProperFilter F -> +Lemma cvg_closeP (F : set_system U) (l : U) : ProperFilter F -> F --> l <-> ([cvg F in U] /\ close (lim F) l). Proof. move=> FF; split=> [Fl|[cvF]Cl]. @@ -4668,16 +4616,12 @@ move=> [zt Bzt /eqP]; rewrite !xpair_eqE andbACA -!xpair_eqE. by rewrite /= -!surjective_pairing => /eqP<-. Qed. -Definition prod_uniformType_mixin := - Uniform.Mixin prod_ent_filter prod_ent_refl prod_ent_inv prod_ent_split - prod_ent_nbhsE. +HB.instance Definition _ := Nbhs_isUniform.Build (U * V)%type + prod_ent_filter prod_ent_refl prod_ent_inv prod_ent_split prod_ent_nbhsE. End prod_Uniform. -Canonical prod_uniformType (U V : uniformType) := - UniformType (U * V) (@prod_uniformType_mixin U V). - -(** Matrices *) +(** matrices *) Section matrix_Uniform. @@ -4742,16 +4686,12 @@ move=> [B [C entC sCB] sBA]; exists (fun i j => to_set (C i j) (M i j)). by move=> N CMN; apply/sBA/sCB. Qed. -Definition matrix_uniformType_mixin := - Uniform.Mixin mx_ent_filter mx_ent_refl mx_ent_inv mx_ent_split - mx_ent_nbhsE. - -Canonical matrix_uniformType := - UniformType 'M[T]_(m, n) matrix_uniformType_mixin. +HB.instance Definition _ := Nbhs_isUniform.Build 'M[T]_(m, n) + mx_ent_filter mx_ent_refl mx_ent_inv mx_ent_split mx_ent_nbhsE. End matrix_Uniform. -Lemma cvg_mx_entourageP (T : uniformType) m n (F : set (set 'M[T]_(m,n))) +Lemma cvg_mx_entourageP (T : uniformType) m n (F : set_system 'M[T]_(m,n)) (FF : Filter F) (M : 'M[T]_(m,n)) : F --> M <-> forall A, entourage A -> \forall N \near F, @@ -4770,6 +4710,61 @@ Unshelve. all: by end_near. Qed. (** Functional metric spaces *) +Definition map_pair {S U} (f : S -> U) (x : (S * S)) : (U * U) := + (f x.1, f x.2). + +Section weak_uniform. + +Variable (pS : pointedType) (U : uniformType) (f : pS -> U). + +Let S := weak_topology f. + +Definition weak_ent : set_system (S * S) := + filter_from (@entourage U) (fun V => (map_pair f)@^-1` V). + +Lemma weak_ent_filter : Filter weak_ent. +Proof. +apply: filter_from_filter; first by exists setT; exact: entourageT. +by move=> P Q ??; (exists (P `&` Q); first exact: filterI) => ?. +Qed. + +Lemma weak_ent_refl A : weak_ent A -> [set fg | fg.1 = fg.2] `<=` A. +Proof. +by move=> [B ? sBA] [x y] /= ->; apply/sBA; exact: entourage_refl. +Qed. + +Lemma weak_ent_inv A : weak_ent A -> weak_ent (A^-1)%classic. +Proof. +move=> [B ? sBA]; exists (B^-1)%classic; first exact: entourage_inv. +by move=> ??; exact/sBA. +Qed. + +Lemma weak_ent_split A : weak_ent A -> exists2 B, weak_ent B & B \; B `<=` A. +Proof. +move=> [B entB sBA]; have : exists C, entourage C /\ C \; C `<=` B. + exact/exists2P/entourage_split_ex. +case=> C [entC CsubB]; exists ((map_pair f)@^-1` C); first by exists C. +by case=> x y [a ? ?]; apply/sBA/CsubB; exists (f a). +Qed. + +Lemma weak_ent_nbhs : nbhs = nbhs_ weak_ent. +Proof. +rewrite predeq2E => x V; split. + case=> [? [[B ? <-] ? BsubV]]; have: nbhs (f x) B by apply: open_nbhs_nbhs. + move=> /nbhsP [W ? WsubB]; exists ((map_pair f) @^-1` W); first by exists W. + by move=>??; exact/BsubV/WsubB. +case=> W [V' entV' V'subW] /filterS; apply. +have : nbhs (f x) to_set V' (f x) by apply/nbhsP; exists V'. +rewrite (@nbhsE U) => [[O [openU Ofx Osub]]]. +(exists (f @^-1` O); repeat split => //); first by exists O => //. +by move=> w ? ; apply: V'subW; exact: Osub. +Qed. + +HB.instance Definition _ := @Nbhs_isUniform.Build (weak_topology f) (*S nbhs*) + weak_ent weak_ent_filter weak_ent_refl weak_ent_inv weak_ent_split weak_ent_nbhs. + +End weak_uniform. + Section fct_Uniform. Variable (T : choiceType) (U : uniformType). @@ -4810,21 +4805,17 @@ move=> fg [h spBfh spBhg]. by apply: sBA => t; apply: entourage_split (spBfh t) (spBhg t). Qed. -Definition fct_uniformType_mixin := - UniformMixin fct_ent_filter fct_ent_refl fct_ent_inv fct_ent_split erefl. - -Definition fct_topologicalTypeMixin := - topologyOfEntourageMixin fct_uniformType_mixin. - -Canonical generic_source_filter := @Filtered.Source _ _ _ (nbhs_ fct_ent). -Canonical fct_topologicalType := - TopologicalType (T -> U) fct_topologicalTypeMixin. -Canonical fct_uniformType := UniformType (T -> U) fct_uniformType_mixin. +Definition arrow_uniform := isUniform.Build (T -> U) + fct_ent_filter fct_ent_refl fct_ent_inv fct_ent_split. End fct_Uniform. +Module Import DefaultUniformFun. +HB.instance Definition _ T U := @arrow_uniform T U. +End DefaultUniformFun. + Lemma cvg_fct_entourageP (T : choiceType) (U : uniformType) - (F : set (set (T -> U))) (FF : Filter F) (f : T -> U) : + (F : set_system (T -> U)) (FF : Filter F) (f : T -> U) : F --> f <-> forall A, entourage A -> \forall g \near F, forall t, A (f t, g t). @@ -4839,92 +4830,24 @@ Unshelve. all: by end_near. Qed. Definition entourage_set (U : uniformType) (A : set ((set U) * (set U))) := exists2 B, entourage B & forall PQ, A PQ -> forall p q, PQ.1 p -> PQ.2 q -> B (p,q). -Canonical set_filter_source (U : uniformType) := - @Filtered.Source Prop _ U (fun A => nbhs_ (@entourage_set U) A). - -(** PseudoMetric spaces defined using balls *) - -Definition entourage_ {R : numDomainType} {T T'} (ball : T -> R -> set T') := - @filter_from R _ [set x | 0 < x] (fun e => [set xy | ball xy.1 e xy.2]). - -Lemma entourage_E {R : numDomainType} {T T'} (ball : T -> R -> set T') : - entourage_ ball = - @filter_from R _ [set x | 0 < x] (fun e => [set xy | ball xy.1 e xy.2]). -Proof. by []. Qed. - -Definition map_pair {S U} (f : S -> U) (x : (S * S)) : (U * U) := - (f x.1, f x.2). - -Section weak_uniform. - -Variable (pS : pointedType) (U : uniformType) (f : pS -> U). - -Let S := weak_topologicalType f. - -Definition weak_ent : set (set (S * S)) := - filter_from (@entourage U) (fun V => (map_pair f)@^-1` V). - -Lemma weak_ent_filter : Filter weak_ent. -Proof. -apply: filter_from_filter; first by exists setT; exact: entourageT. -by move=> P Q ??; (exists (P `&` Q); first exact: filterI) => ?. -Qed. - -Lemma weak_ent_refl A : weak_ent A -> [set fg | fg.1 = fg.2] `<=` A. -Proof. -by move=> [B ? sBA] [x y] /= ->; apply/sBA; exact: entourage_refl. -Qed. - -Lemma weak_ent_inv A : weak_ent A -> weak_ent (A^-1)%classic. -Proof. -move=> [B ? sBA]; exists (B^-1)%classic; first exact: entourage_inv. -by move=> ??; exact/sBA. -Qed. - -Lemma weak_ent_split A : weak_ent A -> exists2 B, weak_ent B & B \; B `<=` A. -Proof. -move=> [B entB sBA]; have : exists C, entourage C /\ C \; C `<=` B. - exact/exists2P/entourage_split_ex. -case=> C [entC CsubB]; exists ((map_pair f)@^-1` C); first by exists C. -by case=> x y [a ? ?]; apply/sBA/CsubB; exists (f a). -Qed. - -Lemma weak_ent_nbhs : nbhs = nbhs_ weak_ent. -Proof. -rewrite predeq2E => x V; split. - case=> [? [[B ? <-] ? BsubV]]; have: nbhs (f x) B by apply: open_nbhs_nbhs. - move=> /nbhsP [W ? WsubB]; exists ((map_pair f) @^-1` W); first by exists W. - by move=>??; exact/BsubV/WsubB. -case=> W [V' entV' V'subW] /filterS; apply. -have : nbhs (f x) to_set V' (f x) by apply/nbhsP; exists V'. -rewrite (@nbhsE U) => [[O [openU Ofx Osub]]]. -(exists (f @^-1` O); repeat split => //); first by exists O => //. -by move=> w ? ; apply: V'subW; exact: Osub. -Qed. - -Definition weak_uniform_mixin := - @UniformMixin S nbhs weak_ent - weak_ent_filter weak_ent_refl weak_ent_inv weak_ent_split weak_ent_nbhs. - -Definition weak_uniformType := - UniformType S weak_uniform_mixin. - -End weak_uniform. +(* HB.instance Definition _ (U : uniformType) := isSource.Build Prop _ U *) +(* (fun A => nbhs_ (@entourage_set U) A). *) Section sup_uniform. -Variable (T : pointedType) (Ii : Type) (Tc : Ii -> Uniform.class_of T). +Variable (T : pointedType) (Ii : Type) (Tc : Ii -> Uniform T). -Let I : choiceType := classicType_choiceType Ii. +Let I : choiceType := {classic Ii}. Let TS := fun i => Uniform.Pack (Tc i). -Let Tt := @sup_topologicalType T I Tc. +Notation Tt := (sup_topology Tc). Let ent_of (p : I * set (T * T)) := `[< @entourage (TS p.1) p.2>]. -Let IEnt := ChoiceType {p : (I * set (T * T)) | ent_of p} (sig_choiceMixin _). +Let IEntType := {p : (I * set (T * T)) | ent_of p}. +Let IEnt : choiceType := IEntType. Local Lemma IEnt_pointT (i : I) : ent_of (i, setT). Proof. by apply/asboolP; exact: entourageT. Qed. -Definition sup_ent : (set (set (T * T))) := +Definition sup_ent : set_system (T * T) := filter_from (finI_from [set: IEnt] (fun p => (projT1 p).2)) id. Ltac IEntP := move=> [[ /= + + /[dup] /asboolP]]. @@ -4973,7 +4896,7 @@ Qed. Lemma sup_ent_nbhs : @nbhs Tt Tt = nbhs_ sup_ent. Proof. rewrite predeq2E => x V; split. - rewrite /nbhs_of_open => [[? [[B + <-] [W BW Wx] BV]]] => /(_ W BW) []. + move=> [/= X [[/= B + <-] [W BW Wx BV]]] => /(_ W BW) [] /=. move=> F Fsup Weq; move: Weq Wx BW => <- Fx BF. case (pselect ([set: I] = set0)) => [I0 | /eqP/set0P [i0 _]]. suff -> : V = setT by exists setT; apply: filterT; exact: sup_ent_filter. @@ -4993,7 +4916,9 @@ rewrite predeq2E => x V; split. rewrite eqEsubset; split => y + z. by move=>/(_ (projT1 (f z))) => + ?; apply; apply/imfsetP; exists z. by move=> Fgy /imfsetP [/= u uF ->]; exact: Fgy. -case=> E [D [/= F FsubEnt <-] FsubE EsubV]; apply: (filterS EsubV). +case=> E [D [/= F FsubEnt <-] FsubE EsubV]. +have F_nbhs_x: Filter (nbhs x) by typeclasses eauto. +apply: (filterS EsubV). pose f : IEnt -> set T := fun w => @interior (TS (projT1 w).1) (to_set ((projT1 w).2) (x)). exists (\bigcap_(w in [set` F]) f w); repeat split. @@ -5006,15 +4931,12 @@ exists (\bigcap_(w in [set` F]) f w); repeat split. - by move=> t /= Ifwt; apply: FsubE => it /Ifwt/interior_subset. Qed. -Definition sup_uniform_mixin:= - @UniformMixin Tt nbhs - sup_ent sup_ent_filter sup_ent_refl sup_ent_inv sup_ent_split sup_ent_nbhs. - -Definition sup_uniformType := UniformType Tt sup_uniform_mixin. +HB.instance Definition _ := @Nbhs_isUniform.Build Tt sup_ent + sup_ent_filter sup_ent_refl sup_ent_inv sup_ent_split sup_ent_nbhs. Lemma countable_sup_ent : countable [set: Ii] -> (forall n, countable_uniformity (TS n)) -> - countable_uniformity sup_uniformType. + countable_uniformity Tt. Proof. move=> Icnt countable_ent; pose f n := cid (countable_ent n). pose g (n : Ii) : set (set (T * T)) := projT1 (f n). @@ -5055,25 +4977,45 @@ Qed. End sup_uniform. -Section product_uniform. +HB.instance Definition _ (I : Type) (T : I -> uniformType) := + Uniform.copy (prod_topology T) + (sup_topology (fun i => Uniform.class + [the uniformType of weak_topology (@proj _ T i)])). -Variable (I : choiceType) (T : I -> uniformType). +(** * PseudoMetric spaces defined using balls *) -Definition product_uniformType := - sup_uniformType (fun i => Uniform.class - (weak_uniformType (fun f : dep_arrow_pointedType T => f i))). +Definition entourage_ {R : numDomainType} {T T'} (ball : T -> R -> set T') := + @filter_from R _ [set x | 0 < x] (fun e => [set xy | ball xy.1 e xy.2]). -End product_uniform. +Lemma entourage_E {R : numDomainType} {T T'} (ball : T -> R -> set T') : + entourage_ ball = + @filter_from R _ [set x | 0 < x] (fun e => [set xy | ball xy.1 e xy.2]). +Proof. by []. Qed. + +HB.mixin Record Uniform_isPseudoMetric (R : numDomainType) M of Uniform M := { + ball : M -> R -> M -> Prop ; + ball_center_subproof : forall x (e : R), 0 < e -> ball x e x ; + ball_sym_subproof : forall x y (e : R), ball x e y -> ball y e x ; + ball_triangle_subproof : + forall x y z e1 e2, ball x e1 y -> ball y e2 z -> ball x (e1 + e2) z; + entourageE_subproof : entourage = entourage_ ball +}. + +#[short(type="pseudoMetricType")] +HB.structure Definition PseudoMetric (R : numDomainType) := + {T of Uniform T & Uniform_isPseudoMetric R T}. + +Definition discrete_topology T (dsc : discrete_space T) : Type := T. Section discrete_uniform. -Context {T : topologicalType} {dsc: discrete_space T}. +Context {T : nbhsType} {dsc: discrete_space T}. Definition discrete_ent : set (set (T * T)) := globally (range (fun x => (x, x))). Program Definition discrete_uniform_mixin := - @UniformMixin T nbhs discrete_ent _ _ _ _ _. + @isUniform.Build (discrete_topology dsc) discrete_ent _ _ _ _. Next Obligation. by move=> ? + x x12; apply; exists x.1; rewrite // {2}x12 -surjective_pairing. Qed. @@ -5084,142 +5026,77 @@ Next Obligation. move=> ? dA; exists (range (fun x => (x, x))) => //. by rewrite set_compose_diag => x [i _ <-]; apply: dA; exists i. Qed. -Next Obligation. -rewrite dsc predeq2E => x V; split => []. - move=> Px; exists (range (fun x => (x, x))) => //. - by move=> z [i _] [+ <-] => ->; exact/principal_filterP. -by case=> U dV UV; apply/principal_filterP/UV/dV; exists x. -Qed. -Definition discrete_uniformType := UniformType T discrete_uniform_mixin. +HB.instance Definition _ := Choice.on (discrete_topology dsc). +HB.instance Definition _ := Pointed.on (discrete_topology dsc). +HB.instance Definition _ := discrete_uniform_mixin. End discrete_uniform. -Module PseudoMetric. - -Record mixin_of (R : numDomainType) (M : Type) - (entourage : set (set (M * M))) := Mixin { +(* was uniformityOfBallMixin *) +HB.factory Record Nbhs_isPseudoMetric (R : numFieldType) M of Nbhs M := { + ent : set_system (M * M); + nbhsE : nbhs = nbhs_ ent; ball : M -> R -> M -> Prop ; ball_center : forall x (e : R), 0 < e -> ball x e x ; ball_sym : forall x y (e : R), ball x e y -> ball y e x ; ball_triangle : forall x y z e1 e2, ball x e1 y -> ball y e2 z -> ball x (e1 + e2) z; - entourageE : entourage = entourage_ ball + entourageE : ent = entourage_ ball }. -Record class_of (R : numDomainType) (M : Type) := Class { - base : Uniform.class_of M; - mixin : mixin_of R (Uniform.entourage base) -}. +HB.builders Context R M of Nbhs_isPseudoMetric R M. -Section ClassDef. -Variable R : numDomainType. -Structure type := Pack { sort; _ : class_of R sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of R cT in c. - -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of R xT). -Local Coercion base : class_of >-> Uniform.class_of. -Local Coercion mixin : class_of >-> mixin_of. - -Definition pack ent (m : @mixin_of R T ent) := - fun bT (b : Uniform.class_of T) of phant_id (@Uniform.class bT) b => - fun m' of phant_id m (m' : @mixin_of R T (Uniform.entourage b)) => - @Pack T (@Class R _ b m'). - -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. -Definition uniformType := @Uniform.Pack cT xclass. - -End ClassDef. - -Module Exports. - -Coercion sort : type >-> Sortclass. -Coercion base : class_of >-> Uniform.class_of. -Coercion mixin : class_of >-> mixin_of. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Coercion uniformType : type >-> Uniform.type. -Canonical uniformType. -Notation pseudoMetricType := type. -Notation PseudoMetricType T m := (@pack _ T _ m _ _ idfun _ idfun). -Notation PseudoMetricMixin := Mixin. -Notation "[ 'pseudoMetricType' R 'of' T 'for' cT ]" := (@clone R T cT _ idfun) - (at level 0, format "[ 'pseudoMetricType' R 'of' T 'for' cT ]") : form_scope. -Notation "[ 'pseudoMetricType' R 'of' T ]" := (@clone R T _ _ id) - (at level 0, format "[ 'pseudoMetricType' R 'of' T ]") : form_scope. - -End Exports. - -End PseudoMetric. - -Export PseudoMetric.Exports. - -Section PseudoMetricUniformity. - -Let ball_le (R : numDomainType) (M : Type) (ent : set (set (M * M))) - (m : PseudoMetric.mixin_of R ent) : - forall (x : M), {homo PseudoMetric.ball m x : e1 e2 / e1 <= e2 >-> e1 `<=` e2}. -Proof. -move=> x e1 e2 + y xe1_y. -rewrite le_eqVlt => /predU1P[<- //|]; rewrite -subr_gt0 => lt12. -rewrite -[e2](subrK e1); apply: PseudoMetric.ball_triangle xe1_y. -suff : PseudoMetric.ball m x (PosNum lt12)%:num x by []. -exact: PseudoMetric.ball_center. -Qed. - -Program Definition uniformityOfBallMixin (R : numFieldType) (T : Type) - (ent : set (set (T * T))) (nbhs : T -> set (set T)) (nbhsE : nbhs = nbhs_ ent) - (m : PseudoMetric.mixin_of R ent) : Uniform.mixin_of nbhs := - UniformMixin _ _ _ _ nbhsE. -Next Obligation. -move=> R T ent nbhs nbhsE m; rewrite (PseudoMetric.entourageE m). -apply: filter_from_filter; first by exists 1 => /=. +Lemma ball_le x : {homo ball x : e1 e2 / e1 <= e2 >-> e1 `<=` e2}. +Proof. +move=> e1 e2 le12 y xe1_y. +move: le12; rewrite le_eqVlt => /orP [/eqP <- //|]. +rewrite -subr_gt0 => lt12. +rewrite -[e2](subrK e1); apply: ball_triangle xe1_y. +suff : ball x (PosNum lt12)%:num x by []. +exact: ball_center. +Qed. + +Lemma entourage_filter_subproof : Filter ent. +Proof. +rewrite entourageE; apply: filter_from_filter; first by exists 1 => /=. move=> _ _ /posnumP[e1] /posnumP[e2]; exists (Num.min e1 e2)%:num => //=. by rewrite subsetI; split=> ?; apply: ball_le; - rewrite -leEsub// le_minl lexx ?orbT. + rewrite num_le// le_minl lexx ?orbT. Qed. -Next Obligation. -move=> R T ent nbhs nbhsE m A; rewrite (PseudoMetric.entourageE m). -move=> [e egt0 sbeA] xy xey. -by apply: sbeA; rewrite /= xey; exact: PseudoMetric.ball_center. + +Lemma ball_sym_subproof A : ent A -> [set xy | xy.1 = xy.2] `<=` A. +Proof. +rewrite entourageE; move=> [e egt0 sbeA] xy xey. +apply: sbeA; rewrite /= xey; exact: ball_center. Qed. -Next Obligation. -move=> R T ent nbhs nbhsE m A; rewrite (PseudoMetric.entourageE m) => - [e egt0 sbeA]. -by exists e => // xy xye; apply: sbeA; apply: PseudoMetric.ball_sym. + +Lemma ball_triangle_subproof A : ent A -> ent (A^-1)%classic. +Proof. +rewrite entourageE => - [e egt0 sbeA]. +by exists e => // xy xye; apply: sbeA; apply: ball_sym. Qed. -Next Obligation. -move=> R T ent nbhs nbhsE m A; rewrite (PseudoMetric.entourageE m). -move=> [_/posnumP[e] sbeA]. -exists [set xy | PseudoMetric.ball m xy.1 (e%:num / 2) xy.2]. + +Lemma entourageE_subproof A : ent A -> exists2 B, ent B & B \; B `<=` A. +Proof. +rewrite entourageE; move=> [_/posnumP[e] sbeA]. +exists [set xy | ball xy.1 (e%:num / 2) xy.2]. by exists (e%:num / 2) => /=. move=> xy [z xzhe zyhe]; apply: sbeA. -by rewrite [e%:num]splitr; apply: PseudoMetric.ball_triangle zyhe. +by rewrite [e%:num]splitr; apply: ball_triangle zyhe. Qed. -End PseudoMetricUniformity. +HB.instance Definition _ := Nbhs_isUniform.Build M + entourage_filter_subproof ball_sym_subproof ball_triangle_subproof + entourageE_subproof nbhsE. -Definition ball {R : numDomainType} {M : pseudoMetricType R} := - PseudoMetric.ball (PseudoMetric.class M). +HB.instance Definition _ := Uniform_isPseudoMetric.Build R M + ball_center ball_sym ball_triangle entourageE. -Lemma entourage_ballE {R : numDomainType} {M : pseudoMetricType R} - : entourage_ (@ball R M) = entourage. -Proof. by case: M=> [?[?[]]]. Qed. +HB.end. + +Lemma entourage_ballE {R : numDomainType} {M : pseudoMetricType R} : entourage_ (@ball R M) = entourage. +Proof. by rewrite entourageE_subproof. Qed. Lemma entourage_from_ballE {R : numDomainType} {M : pseudoMetricType R} : @filter_from R _ [set x : R | 0 < x] @@ -5259,7 +5136,7 @@ Proof. by rewrite nbhs_simpl. Qed. Lemma ball_center {R : numDomainType} (M : pseudoMetricType R) (x : M) (e : {posnum R}) : ball x e%:num x. -Proof. exact: PseudoMetric.ball_center. Qed. +Proof. exact: ball_center_subproof. Qed. #[global] Hint Resolve ball_center : core. Section pseudoMetricType_numDomainType. @@ -5269,14 +5146,14 @@ Lemma ballxx (x : M) (e : R) : 0 < e -> ball x e x. Proof. by move=> e_gt0; apply: ball_center (PosNum e_gt0). Qed. Lemma ball_sym (x y : M) (e : R) : ball x e y -> ball y e x. -Proof. exact: PseudoMetric.ball_sym. Qed. +Proof. exact: ball_sym_subproof. Qed. Lemma ball_symE (x y : M) (e : R) : ball x e y = ball y e x. Proof. by rewrite propeqE; split; exact/ball_sym. Qed. Lemma ball_triangle (y x z : M) (e1 e2 : R) : ball x e1 y -> ball y e2 z -> ball x (e1 + e2) z. -Proof. exact: PseudoMetric.ball_triangle. Qed. +Proof. exact: ball_triangle_subproof. Qed. Lemma nbhsx_ballx (x : M) (eps : R) : 0 < eps -> nbhs x (ball x eps). Proof. by move=> e0; apply/nbhs_ballP; exists eps. Qed. @@ -5304,7 +5181,7 @@ Proof. exact: nbhsx_ballx. Qed. Lemma dnbhs_ball (a : M) (e : R) : (0 < e)%R -> a^' (ball a e `\ a). Proof. -move: e => _/posnumP[e]; rewrite /dnbhs /within; near=> r => ra. +move: e => _/posnumP[e]; rewrite /dnbhs /within /=; near=> r => ra. split => //=; last exact/eqP. by near: r; rewrite near_simpl; exact: near_ball. Unshelve. all: by end_near. Qed. @@ -5435,7 +5312,7 @@ exists (fun n => [set xy : T * T | ball xy.1 n.+1%:R^-1 xy.2]); last first. by move=> n; exact: (entourage_ball _ n.+1%:R^-1%:pos). move=> E; rewrite -entourage_ballE => -[e e0 subE]. exists `|floor e^-1|%N; apply: subset_trans subE => xy; apply: le_ball. -rewrite /= -[leRHS]invrK lef_pinv ?posrE ?invr_gt0// -natr1. +rewrite /= -[leRHS]invrK lef_pV2 ?posrE ?invr_gt0// -natr1. by rewrite natr_absz ger0_norm ?floor_ge0 ?invr_ge0// 1?ltW// lt_succ_floor. Qed. @@ -5469,13 +5346,12 @@ move=> MN MN_min; apply: sPA => i j. have /(xgetPex 1%:pos): exists e : {posnum R}, diag e `<=` P i j. by have [_/posnumP[e]] := entP i j; exists e. apply; apply: le_ball (MN_min i j). -apply: le_trans (@bigmin_le _ [orderType of {posnum R}] _ _ i _) _. +apply: le_trans (@bigmin_le _ [the orderType _ of {posnum R}] _ _ i _) _. exact: bigmin_le. Qed. -Definition matrix_pseudoMetricType_mixin := - PseudoMetric.Mixin mx_ball_center mx_ball_sym mx_ball_triangle mx_entourage. -Canonical matrix_pseudoMetricType := - PseudoMetricType 'M[T]_(m, n) matrix_pseudoMetricType_mixin. + +HB.instance Definition _ := Uniform_isPseudoMetric.Build R 'M[T]_(m, n) + mx_ball_center mx_ball_sym mx_ball_triangle mx_entourage. End matrix_PseudoMetric. (** product of two pseudoMetric spaces *) @@ -5507,26 +5383,24 @@ move=> [[_/posnumP[eA] sbA] [_/posnumP[eB] sbB] sABP]. exists (Num.min eA eB)%:num => //= -[[a b] [c d] [/= bac bbd]]. suff /sABP [] : (A `*` B) ((a, c), (b, d)) by move=> [[??] [??]] ? [<-<-<-<-]. split; [apply: sbA|apply: sbB] => /=. - by apply: le_ball bac; rewrite -leEsub le_minl lexx. -by apply: le_ball bbd; rewrite -leEsub le_minl lexx orbT. + by apply: le_ball bac; rewrite num_le le_minl lexx. +by apply: le_ball bbd; rewrite num_le le_minl lexx orbT. Qed. -Definition prod_pseudoMetricType_mixin := - PseudoMetric.Mixin prod_ball_center prod_ball_sym prod_ball_triangle prod_entourage. -End prod_PseudoMetric. -Canonical prod_pseudoMetricType (R : numDomainType) (U V : pseudoMetricType R) := - PseudoMetricType (U * V) (@prod_pseudoMetricType_mixin R U V). +HB.instance Definition _ := Uniform_isPseudoMetric.Build R (U * V)%type + prod_ball_center prod_ball_sym prod_ball_triangle prod_entourage. +End prod_PseudoMetric. Section Nbhs_fct2. Context {T : Type} {R : numDomainType} {U V : pseudoMetricType R}. -Lemma fcvg_ball2P {F : set (set U)} {G : set (set V)} +Lemma fcvg_ball2P {F : set_system U} {G : set_system V} {FF : Filter F} {FG : Filter G} (y : U) (z : V): (F, G) --> (y, z) <-> forall eps : R, eps > 0 -> \forall y' \near F & z' \near G, ball y eps y' /\ ball z eps z'. Proof. exact: fcvg_ballP. Qed. -Lemma cvg_ball2P {I J} {F : set (set I)} {G : set (set J)} +Lemma cvg_ball2P {I J} {F : set_system I} {G : set_system J} {FF : Filter F} {FG : Filter G} (f : I -> U) (g : J -> V) (y : U) (z : V): (f @ F, g @ G) --> (y, z) <-> forall eps : R, eps > 0 -> \forall i \near F & j \near G, @@ -5559,44 +5433,37 @@ rewrite predeqE => A; split; last first. move=> [P]; rewrite -entourage_ballE => -[_/posnumP[e] sbeP] sPA. by exists e%:num => //= fg fg_e; apply: sPA => t; apply: sbeP; apply: fg_e. Qed. -Definition fct_pseudoMetricType_mixin := - PseudoMetricMixin fct_ball_center fct_ball_sym fct_ball_triangle fct_entourage. -Canonical fct_pseudoMetricType := PseudoMetricType (T -> U) fct_pseudoMetricType_mixin. + +HB.instance Definition _ := Uniform_isPseudoMetric.Build R (T -> U) + fct_ball_center fct_ball_sym fct_ball_triangle fct_entourage. End fct_PseudoMetric. -Definition quotient_topology (T : topologicalType) (Q : quotType T) := Q. +Definition quotient_topology (T : topologicalType) (Q : quotType T) : Type := Q. Section quotients. Local Open Scope quotient_scope. Context {T : topologicalType} {Q0 : quotType T}. -Let Q := quotient_topology Q0. +Local Notation Q := (quotient_topology Q0). -Canonical quotient_subtype := [subType Q of T by %/]. -Canonical quotient_eq := EqType Q [eqMixin of Q by <:]. -Canonical quotient_choice := ChoiceType Q [choiceMixin of Q by <:]. -Canonical quotient_pointed := PointedType Q (\pi_Q point). +HB.instance Definition _ := Quotient.copy Q Q0. +HB.instance Definition _ := [Sub Q of T by %/]. +HB.instance Definition _ := [Choice of Q by <:]. +HB.instance Definition _ := isPointed.Build Q (\pi_Q point : Q). Definition quotient_open U := open (\pi_Q @^-1` U). Program Definition quotient_topologicalType_mixin := - @topologyOfOpenMixin Q quotient_open _ _ _. + @Pointed_isOpenTopological.Build Q quotient_open _ _ _. Next Obligation. by rewrite /quotient_open preimage_setT; exact: openT. Qed. Next Obligation. by move=> ? ? ? ?; exact: openI. Qed. Next Obligation. by move=> I f ofi; apply: bigcup_open => i _; exact: ofi. Qed. +HB.instance Definition _ := quotient_topologicalType_mixin. -Let quotient_filtered := Filtered.Class (Pointed.class quotient_pointed) - (nbhs_of_open quotient_open). - -Canonical quotient_topologicalType := @Topological.Pack Q - (@Topological.Class _ quotient_filtered quotient_topologicalType_mixin). - -Let Q' := quotient_topologicalType. - -Lemma pi_continuous : continuous (\pi_Q : T -> Q'). +Lemma pi_continuous : continuous (\pi_Q : T -> Q). Proof. exact/continuousP. Qed. -Lemma quotient_continuous {Z : topologicalType} (f : Q' -> Z) : +Lemma quotient_continuous {Z : topologicalType} (f : Q -> Z) : continuous f <-> continuous (f \o \pi_Q). Proof. split => /continuousP /= cts; apply/continuousP => A oA; last exact: cts. @@ -5604,8 +5471,8 @@ by rewrite comp_preimage; move/continuousP: pi_continuous; apply; exact: cts. Qed. Lemma repr_comp_continuous (Z : topologicalType) (g : T -> Z) : - continuous g -> {homo g : a b / a == b %[mod Q] >-> a == b} -> - continuous (g \o repr : Q' -> Z). + continuous g -> {homo g : a b / \pi_Q a == \pi_Q b :> Q >-> a == b} -> + continuous (g \o repr : Q -> Z). Proof. move=> /continuousP ctsG rgE; apply/continuousP => A oA. rewrite /open/= /quotient_open (_ : _ @^-1` _ = g @^-1` A); first exact: ctsG. @@ -5616,37 +5483,38 @@ Qed. End quotients. Section discrete_pseudoMetric. -Context {R : numDomainType} {T : topologicalType} {dsc : discrete_space T}. +Context {R : numDomainType} {T : nbhsType} {dsc : discrete_space T}. Definition discrete_ball (x : T) (eps : R) y : Prop := x = y. Lemma discrete_ball_center x (eps : R) : 0 < eps -> discrete_ball x eps x. Proof. by []. Qed. -Program Definition discrete_pseudoMetricType_mixin := - @PseudoMetric.Mixin R T discrete_ent discrete_ball _ _ _ _. +Program Definition discrete_pseudometric_mixin := + @Uniform_isPseudoMetric.Build R (discrete_topology dsc) discrete_ball + _ _ _ _. Next Obligation. by done. Qed. Next Obligation. by move=> ? ? ? ->. Qed. Next Obligation. by move=> ? ? ? ? ? -> ->. Qed. Next Obligation. -rewrite predeqE => P; split; last by case=> e _ + [a b] [i _] [-> ->]; apply. +rewrite predeqE => P; split; last first. + by case=> e _ leP; move=> [a b] [i _] [-> ->]; apply: leP. move=> entP; exists 1 => //= z z12; apply: entP; exists z.1 => //. by rewrite {2}z12 -surjective_pairing. Qed. -Definition discrete_pseudoMetricType := PseudoMetricType - (@discrete_uniformType _ dsc) discrete_pseudoMetricType_mixin. +HB.instance Definition _ := discrete_pseudometric_mixin. End discrete_pseudoMetric. Definition pseudoMetric_bool {R : realType} := - @discrete_pseudoMetricType R [topologicalType of bool] discrete_bool. + [the pseudoMetricType R of discrete_topology discrete_bool : Type]. (** Complete uniform spaces *) -Definition cauchy {T : uniformType} (F : set (set T)) := (F, F) --> entourage. +Definition cauchy {T : uniformType} (F : set_system T) := (F, F) --> entourage. -Lemma cvg_cauchy {T : uniformType} (F : set (set T)) : Filter F -> +Lemma cvg_cauchy {T : uniformType} (F : set_system T) : Filter F -> [cvg F in T] -> cauchy F. Proof. move=> FF cvF A entA; have /entourage_split_ex [B entB sB2A] := entA. @@ -5656,79 +5524,33 @@ exists (to_set ((B^-1)%classic) (lim F), to_set B (lim F)). by move=> ab [/= Balima Blimb]; apply: sB2A; exists (lim F). Qed. -Module Complete. -Definition axiom (T : uniformType) := - forall (F : set (set T)), ProperFilter F -> cauchy F -> F --> lim F. -Section ClassDef. -Record class_of (T : Type) := Class { - base : Uniform.class_of T ; - mixin : axiom (Uniform.Pack base) +HB.mixin Record Uniform_isComplete T of Uniform T := { + cauchy_cvg : + forall (F : set_system T), ProperFilter F -> cauchy F -> cvg F }. -Local Coercion base : class_of >-> Uniform.class_of. -Local Coercion mixin : class_of >-> Complete.axiom. -Structure type := Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of cT in c. -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). -Definition pack b0 (m0 : axiom (@Uniform.Pack T b0)) := - fun bT b of phant_id (@Uniform.class bT) b => - fun m of phant_id m m0 => @Pack T (@Class T b m). -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. -Definition uniformType := @Uniform.Pack cT xclass. -End ClassDef. -Module Exports. -Coercion base : class_of >-> Uniform.class_of. -Coercion mixin : class_of >-> axiom. -Coercion sort : type >-> Sortclass. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Coercion uniformType : type >-> Uniform.type. -Canonical uniformType. -Notation completeType := type. -Notation "[ 'completeType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'completeType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'completeType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'completeType' 'of' T ]") : form_scope. -Notation CompleteType T m := (@pack T _ m _ _ idfun _ idfun). -End Exports. -End Complete. -Export Complete.Exports. + +#[short(type="completeType")] +HB.structure Definition Complete := {T of Uniform T & Uniform_isComplete T}. + +#[deprecated(since="mathcomp-analysis 2.0", note="use cauchy_cvg instead")] +Notation complete_ax := cauchy_cvg (only parsing). Section completeType1. Context {T : completeType}. -Lemma cauchy_cvg (F : set (set T)) (FF : ProperFilter F) : - cauchy F -> cvg F. -Proof. by case: T F FF => [? [?]]. Qed. - -Lemma cauchy_cvgP (F : set (set T)) (FF : ProperFilter F) : cauchy F <-> cvg F. +Lemma cauchy_cvgP (F : set_system T) (FF : ProperFilter F) : cauchy F <-> cvg F. Proof. by split=> [/cauchy_cvg|/cvg_cauchy]. Qed. End completeType1. -Arguments cauchy_cvg {T} F {FF} _. +Arguments cauchy_cvg {T} F {FF} _ : rename. Arguments cauchy_cvgP {T} F {FF}. Section matrix_Complete. Variables (T : completeType) (m n : nat). -Lemma mx_complete (F : set (set 'M[T]_(m, n))) : +Lemma mx_complete (F : set_system 'M[T]_(m, n)) : ProperFilter F -> cauchy F -> cvg F. Proof. move=> FF Fc. @@ -5745,7 +5567,7 @@ move: (i) (j); near: M'; near: M; apply: nearP_dep; apply: Fc. by exists (fun _ _ => (split_ent A)^-1%classic) => ?? //; apply: entourage_inv. Unshelve. all: by end_near. Qed. -Canonical matrix_completeType := CompleteType 'M[T]_(m, n) mx_complete. +HB.instance Definition _ := Uniform_isComplete.Build 'M[T]_(m, n) mx_complete. End matrix_Complete. @@ -5753,7 +5575,7 @@ Section fun_Complete. Context {T : choiceType} {U : completeType}. -Lemma fun_complete (F : set (set (T -> U))) +Lemma fun_complete (F : set_system (T -> U)) {FF : ProperFilter F} : cauchy F -> cvg F. Proof. move=> Fc. @@ -5767,14 +5589,13 @@ move: (t); near: g; near: f; apply: nearP_dep; apply: Fc. exists ((split_ent A)^-1)%classic=> //=. Unshelve. all: by end_near. Qed. -Canonical fun_completeType := CompleteType (T -> U) fun_complete. +HB.instance Definition _ := Uniform_isComplete.Build (T -> U) fun_complete. End fun_Complete. (** Limit switching *) Section Cvg_switch. Context {T1 T2 : choiceType}. - Lemma cvg_switch_1 {U : uniformType} F1 {FF1 : ProperFilter F1} F2 {FF2 : Filter F2} (f : T1 -> T2 -> U) (g : T2 -> U) (h : T1 -> U) (l : U) : @@ -5816,21 +5637,21 @@ Lemma cvg_switch {U : completeType} exists l : U, h @ F1 --> l /\ g @ F2 --> l. Proof. move=> Hfg Hfh; have hcv := !! cvg_switch_2 Hfg Hfh. -by exists [lim h @ F1 in U]; split=> //; apply: cvg_switch_1 Hfg Hfh hcv. +by exists (lim (h @ F1)); split=> //; apply: cvg_switch_1 Hfg Hfh hcv. Qed. End Cvg_switch. (** Complete pseudoMetric spaces *) -Definition cauchy_ex {R : numDomainType} {T : pseudoMetricType R} (F : set (set T)) := +Definition cauchy_ex {R : numDomainType} {T : pseudoMetricType R} (F : set_system T) := forall eps : R, 0 < eps -> exists x, F (ball x eps). -Definition cauchy_ball {R : numDomainType} {T : pseudoMetricType R} (F : set (set T)) := +Definition cauchy_ball {R : numDomainType} {T : pseudoMetricType R} (F : set_system T) := forall e, e > 0 -> \forall x & y \near F, ball x e y. Lemma cauchy_ballP (R : numDomainType) (T : pseudoMetricType R) - (F : set (set T)) (FF : Filter F) : + (F : set_system T) (FF : Filter F) : cauchy_ball F <-> cauchy F. Proof. split=> cauchyF; last first. @@ -5841,7 +5662,7 @@ Unshelve. all: by end_near. Qed. Arguments cauchy_ballP {R T} F {FF}. Lemma cauchy_exP (R : numFieldType) (T : pseudoMetricType R) - (F : set (set T)) (FF : Filter F) : + (F : set_system T) (FF : Filter F) : cauchy_ex F -> cauchy F. Proof. move=> Fc A; rewrite !nbhs_simpl /= -entourage_ballE => -[_/posnumP[e] sdeA]. @@ -5851,7 +5672,7 @@ Unshelve. all: by end_near. Qed. Arguments cauchy_exP {R T} F {FF}. Lemma cauchyP (R : numFieldType) (T : pseudoMetricType R) - (F : set (set T)) (PF : ProperFilter F) : + (F : set_system T) (PF : ProperFilter F) : cauchy F <-> cauchy_ex F. Proof. split=> [Fcauchy _/posnumP[e] |/cauchy_exP//]. @@ -5860,7 +5681,20 @@ exact/Fcauchy/entourage_ball. Unshelve. all: by end_near. Qed. Arguments cauchyP {R T} F {PF}. -Lemma compact_cauchy_cvg {T : uniformType} (U : set T) (F : set (set T)) : +#[short(type="completePseudoMetricType")] +HB.structure Definition CompletePseudoMetric R := + {T of Complete T & PseudoMetric R T}. + +HB.instance Definition _ (R : numFieldType) (T : completePseudoMetricType R) + (m n : nat) := Uniform_isComplete.Build 'M[T]_(m, n) cauchy_cvg. + +HB.instance Definition _ (T : choiceType) (R : numFieldType) + (U : completePseudoMetricType R) := + Uniform_isComplete.Build (T -> U) cauchy_cvg. + +HB.instance Definition _ (R : zmodType) := isPointed.Build R 0. + +Lemma compact_cauchy_cvg {T : uniformType} (U : set T) (F : set_system T) : ProperFilter F -> cauchy F -> F U -> compact U -> cvg F. Proof. move=> PF cf FU /(_ F PF FU) [x [_ clFx]]; apply: (cvgP x). @@ -5872,80 +5706,6 @@ move=> /(clFx _ (to_set (split_ent E) x) FD1)[z [Dz Exz]]. by near=> t; apply/(entourage_split z entE Exz)/D1D2E; split => //; near: t. Unshelve. all: by end_near. Qed. -Module CompletePseudoMetric. -Section ClassDef. -Variable R : numDomainType. -Record class_of (T : Type) := Class { - base : PseudoMetric.class_of R T; - mixin : Complete.axiom (Uniform.Pack base) -}. -Local Coercion base : class_of >-> PseudoMetric.class_of. -Definition base2 T m := Complete.Class (@mixin T m). -Local Coercion base2 : class_of >-> Complete.class_of. - -Structure type := Pack { sort; _ : class_of sort }. -Local Coercion sort : type >-> Sortclass. -Variables (T : Type) (cT : type). -Definition class := let: Pack _ c := cT return class_of cT in c. -Definition clone c of phant_id class c := @Pack T c. -Let xT := let: Pack T _ := cT in T. -Notation xclass := (class : class_of xT). -Definition pack := - fun bT b & phant_id (@PseudoMetric.class R bT) (b : PseudoMetric.class_of R T) => - fun mT m & phant_id (Complete.class mT) (@Complete.Class T b m) => - Pack (@Class T b m). -Definition eqType := @Equality.Pack cT xclass. -Definition choiceType := @Choice.Pack cT xclass. -Definition pointedType := @Pointed.Pack cT xclass. -Definition filteredType := @Filtered.Pack cT cT xclass. -Definition topologicalType := @Topological.Pack cT xclass. -Definition uniformType := @Uniform.Pack cT xclass. -Definition completeType := @Complete.Pack cT xclass. -Definition pseudoMetricType := @PseudoMetric.Pack R cT xclass. -Definition pseudoMetric_completeType := @Complete.Pack pseudoMetricType xclass. -End ClassDef. -Module Exports. -Coercion base : class_of >-> PseudoMetric.class_of. -Coercion mixin : class_of >-> Complete.axiom. -Coercion base2 : class_of >-> Complete.class_of. -Coercion sort : type >-> Sortclass. -Coercion eqType : type >-> Equality.type. -Canonical eqType. -Coercion choiceType : type >-> Choice.type. -Canonical choiceType. -Coercion pointedType : type >-> Pointed.type. -Canonical pointedType. -Coercion filteredType : type >-> Filtered.type. -Canonical filteredType. -Coercion topologicalType : type >-> Topological.type. -Canonical topologicalType. -Coercion uniformType : type >-> Uniform.type. -Canonical uniformType. -Coercion completeType : type >-> Complete.type. -Canonical completeType. -Coercion pseudoMetricType : type >-> PseudoMetric.type. -Canonical pseudoMetricType. -Canonical pseudoMetric_completeType. -Notation completePseudoMetricType := type. -Notation "[ 'completePseudoMetricType' 'of' T 'for' cT ]" := (@clone T cT _ idfun) - (at level 0, format "[ 'completePseudoMetricType' 'of' T 'for' cT ]") : form_scope. -Notation "[ 'completePseudoMetricType' 'of' T ]" := (@clone T _ _ id) - (at level 0, format "[ 'completePseudoMetricType' 'of' T ]") : form_scope. -Notation CompletePseudoMetricType T m := (@pack _ T _ _ id _ _ id). -End Exports. -End CompletePseudoMetric. -Export CompletePseudoMetric.Exports. - -Canonical matrix_completePseudoMetricType (R : numFieldType) - (T : completePseudoMetricType R) (m n : nat) := - CompletePseudoMetricType 'M[T]_(m, n) mx_complete. - -Canonical fct_completePseudoMetricType (T : choiceType) (R : numFieldType) - (U : completePseudoMetricType R) := - CompletePseudoMetricType (T -> U) fun_complete. - -Definition pointed_of_zmodule (R : zmodType) : pointedType := PointedType R 0. - Definition ball_ (R : numDomainType) (V : zmodType) (norm : V -> R) (x : V) (e : R) := [set y | norm (x - y) < e]. @@ -5963,7 +5723,7 @@ Lemma subset_ball_prop_in_itvcc (R : realDomainType) (x : R) e P : 0 < e -> {in `[(x - e), (x + e)], forall y, P y}. Proof. move=> e_gt0 PP y; rewrite in_itv/= -ler_distlC => ye; apply: PP => /=. -by rewrite (le_lt_trans ye)// ltr_pmull// ltr1n. +by rewrite (le_lt_trans ye)// ltr_pMl// ltr1n. Qed. Global Instance ball_filter (R : realDomainType) (t : R) : Filter @@ -5980,13 +5740,8 @@ Qed. #[global] Hint Extern 0 (Filter [set P | exists2 i, _ & ball_ _ _ i `<=` P]) => (apply: ball_filter) : typeclass_instances. -Definition filtered_of_normedZmod (K : numDomainType) (R : normedZmodType K) - : filteredType R := Filtered.Pack (Filtered.Class - (@Pointed.class (pointed_of_zmodule R)) - (nbhs_ball_ (ball_ (fun x => `|x|)))). - Section pseudoMetric_of_normedDomain. -Variables (K : numDomainType) (R : normedZmodType K). +Context {K : numDomainType} {R : normedZmodType K}. Lemma ball_norm_center (x : R) (e : K) : 0 < e -> ball_ Num.norm x e x. Proof. by move=> ? /=; rewrite subrr normr0. Qed. Lemma ball_norm_symmetric (x y : R) (e : K) : @@ -5995,12 +5750,10 @@ Proof. by rewrite /= distrC. Qed. Lemma ball_norm_triangle (x y z : R) (e1 e2 : K) : ball_ Num.norm x e1 y -> ball_ Num.norm y e2 z -> ball_ Num.norm x (e1 + e2) z. Proof. -move=> /= ? ?; rewrite -(subr0 x) -(subrr y) opprD opprK (addrA x _ y) -addrA. -by rewrite (le_lt_trans (ler_norm_add _ _)) // ltr_add. +move=> /= ? ?; rewrite -(subr0 x) -(subrr y) opprD opprK addrA -(addrA _ y). +by rewrite (le_lt_trans (ler_normD _ _)) // ltrD. Qed. -Definition pseudoMetric_of_normedDomain - : PseudoMetric.mixin_of K (@entourage_ K R R (ball_ (fun x => `|x|))) - := PseudoMetricMixin ball_norm_center ball_norm_symmetric ball_norm_triangle erefl. + Lemma nbhs_ball_normE : @nbhs_ball_ K R R (ball_ Num.norm) = nbhs_ (entourage_ (ball_ Num.norm)). Proof. @@ -6011,355 +5764,36 @@ by move=> [E [e egt0 sbeE] sEA]; exists e => // ??; apply/sEA/sbeE. Qed. End pseudoMetric_of_normedDomain. -Module regular_topology. - -Section regular_topology. -Local Canonical pointedType (R : zmodType) : pointedType := - [pointedType of R^o for pointed_of_zmodule R]. -Local Canonical filteredType (R : numDomainType) : filteredType R := - [filteredType R of R^o for filtered_of_normedZmod R]. -Local Canonical topologicalType (R : numFieldType) : topologicalType := - TopologicalType R^o (topologyOfEntourageMixin (uniformityOfBallMixin - (@nbhs_ball_normE _ _) (pseudoMetric_of_normedDomain _))). -Local Canonical uniformType (R : numFieldType) : uniformType := - UniformType R^o (uniformityOfBallMixin - (@nbhs_ball_normE _ _) (pseudoMetric_of_normedDomain _)). -Local Canonical pseudoMetricType (R : numFieldType) := - PseudoMetricType R^o (@pseudoMetric_of_normedDomain R R). -End regular_topology. - -Module Exports. -Canonical pointedType. -Canonical filteredType. -Canonical topologicalType. -Canonical uniformType. -Canonical pseudoMetricType. -End Exports. - -End regular_topology. -Export regular_topology.Exports. +HB.instance Definition _ (R : zmodType) := Pointed.on R^o. + +HB.instance Definition _ (R : numDomainType) := hasNbhs.Build R^o + (nbhs_ball_ (ball_ (fun x => `|x|))). + +HB.instance Definition _ (R : numFieldType) := + Nbhs_isPseudoMetric.Build R R^o + nbhs_ball_normE ball_norm_center ball_norm_symmetric ball_norm_triangle erefl. Module numFieldTopology. -Section realType. -Variable (R : realType). -Local Canonical real_pointedType := [pointedType of R for [pointedType of R^o]]. -Local Canonical real_filteredType := - [filteredType R of R for [filteredType R of R^o]]. -Local Canonical real_topologicalType := - [topologicalType of R for [topologicalType of R^o]]. -Local Canonical real_uniformType := [uniformType of R for [uniformType of R^o]]. -Local Canonical real_pseudoMetricType := - [pseudoMetricType R of R for [pseudoMetricType R of R^o]]. -End realType. - -Section rcfType. -Variable (R : rcfType). -Local Canonical rcf_pointedType := [pointedType of R for [pointedType of R^o]]. -Local Canonical rcf_filteredType := - [filteredType R of R for [filteredType R of R^o]]. -Local Canonical rcf_topologicalType := - [topologicalType of R for [topologicalType of R^o]]. -Local Canonical rcf_uniformType := [uniformType of R for [uniformType of R^o]]. -Local Canonical rcf_pseudoMetricType := - [pseudoMetricType R of R for [pseudoMetricType R of R^o]]. -End rcfType. - -Section archiFieldType. -Variable (R : archiFieldType). -Local Canonical archiField_pointedType := - [pointedType of R for [pointedType of R^o]]. -Local Canonical archiField_filteredType := - [filteredType R of R for [filteredType R of R^o]]. -Local Canonical archiField_topologicalType := - [topologicalType of R for [topologicalType of R^o]]. -Local Canonical archiField_uniformType := - [uniformType of R for [uniformType of R^o]]. -Local Canonical archiField_pseudoMetricType := - [pseudoMetricType R of R for [pseudoMetricType R of R^o]]. -End archiFieldType. - -Section realFieldType. -Variable (R : realFieldType). -Local Canonical realField_pointedType := - [pointedType of R for [pointedType of R^o]]. -Local Canonical realField_filteredType := - [filteredType R of R for [filteredType R of R^o]]. -Local Canonical realField_topologicalType := - [topologicalType of R for [topologicalType of R^o]]. -Local Canonical realField_uniformType := - [uniformType of R for [uniformType of R^o]]. -Local Canonical realField_pseudoMetricType := - [pseudoMetricType R of R for [pseudoMetricType R of R^o]]. -Definition pointed_latticeType := [latticeType of realField_pointedType]. -Definition pointed_distrLatticeType := - [distrLatticeType of realField_pointedType]. -Definition pointed_orderType := [orderType of realField_pointedType]. -Definition pointed_realDomainType := - [realDomainType of realField_pointedType]. -Definition filtered_latticeType := [latticeType of realField_filteredType]. -Definition filtered_distrLatticeType := - [distrLatticeType of realField_filteredType]. -Definition filtered_orderType := [orderType of realField_filteredType]. -Definition filtered_realDomainType := - [realDomainType of realField_filteredType]. -Definition topological_latticeType := - [latticeType of realField_topologicalType]. -Definition topological_distrLatticeType := - [distrLatticeType of realField_topologicalType]. -Definition topological_orderType := [orderType of realField_topologicalType]. -Definition topological_realDomainType := - [realDomainType of realField_topologicalType]. -Definition uniform_latticeType := [latticeType of realField_uniformType]. -Definition uniform_distrLatticeType := - [distrLatticeType of realField_uniformType]. -Definition uniform_orderType := [orderType of realField_uniformType]. -Definition uniform_realDomainType := [realDomainType of realField_uniformType]. -Definition pseudoMetric_latticeType := - [latticeType of realField_pseudoMetricType]. -Definition pseudoMetric_distrLatticeType := - [distrLatticeType of realField_pseudoMetricType]. -Definition pseudoMetric_orderType := [orderType of realField_pseudoMetricType]. -Definition pseudoMetric_realDomainType := - [realDomainType of realField_pseudoMetricType]. -End realFieldType. - -Section numClosedFieldType. -Variable (R : numClosedFieldType). -Local Canonical numClosedField_pointedType := - [pointedType of R for [pointedType of R^o]]. -Local Canonical numClosedField_filteredType := - [filteredType R of R for [filteredType R of R^o]]. -Local Canonical numClosedField_topologicalType := - [topologicalType of R for [topologicalType of R^o]]. -Local Canonical numClosedField_uniformType := - [uniformType of R for [uniformType of R^o]]. -Local Canonical numClosedField_pseudoMetricType := - [pseudoMetricType R of R for [pseudoMetricType R of R^o]]. -Definition pointed_decFieldType := - [decFieldType of numClosedField_pointedType]. -Definition pointed_closedFieldType := - [closedFieldType of numClosedField_pointedType]. -Definition filtered_decFieldType := - [decFieldType of numClosedField_filteredType]. -Definition filtered_closedFieldType := - [closedFieldType of numClosedField_filteredType]. -Definition topological_decFieldType := - [decFieldType of numClosedField_topologicalType]. -Definition topological_closedFieldType := - [closedFieldType of numClosedField_topologicalType]. -Definition uniform_decFieldType := [decFieldType of numClosedField_uniformType]. -Definition uniform_closedFieldType := - [closedFieldType of numClosedField_uniformType]. -Definition pseudoMetric_decFieldType := - [decFieldType of numClosedField_pseudoMetricType]. -Definition pseudoMetric_closedFieldType := - [closedFieldType of numClosedField_pseudoMetricType]. -End numClosedFieldType. - -Section numFieldType. -Variable (R : numFieldType). -Local Canonical numField_pointedType := - [pointedType of R for [pointedType of R^o]]. -Local Canonical numField_filteredType := - [filteredType R of R for [filteredType R of R^o]]. -Local Canonical numField_topologicalType := - [topologicalType of R for [topologicalType of R^o]]. -Local Canonical numField_uniformType := - [uniformType of R for [uniformType of R^o]]. -Local Canonical numField_pseudoMetricType := - [pseudoMetricType R of R for [pseudoMetricType R of R^o]]. -Definition pointed_ringType := [ringType of numField_pointedType]. -Definition pointed_comRingType := [comRingType of numField_pointedType]. -Definition pointed_unitRingType := [unitRingType of numField_pointedType]. -Definition pointed_comUnitRingType := [comUnitRingType of numField_pointedType]. -Definition pointed_idomainType := [idomainType of numField_pointedType]. -Definition pointed_fieldType := [fieldType of numField_pointedType]. -Definition pointed_porderType := [porderType of numField_pointedType]. -Definition pointed_numDomainType := [numDomainType of numField_pointedType]. -Definition filtered_ringType := [ringType of numField_filteredType]. -Definition filtered_comRingType := [comRingType of numField_filteredType]. -Definition filtered_unitRingType := [unitRingType of numField_filteredType]. -Definition filtered_comUnitRingType := - [comUnitRingType of numField_filteredType]. -Definition filtered_idomainType := [idomainType of numField_filteredType]. -Definition filtered_fieldType := [fieldType of numField_filteredType]. -Definition filtered_porderType := [porderType of numField_filteredType]. -Definition filtered_numDomainType := [numDomainType of numField_filteredType]. -Definition topological_ringType := [ringType of numField_topologicalType]. -Definition topological_comRingType := [comRingType of numField_topologicalType]. -Definition topological_unitRingType := - [unitRingType of numField_topologicalType]. -Definition topological_comUnitRingType := - [comUnitRingType of numField_topologicalType]. -Definition topological_idomainType := [idomainType of numField_topologicalType]. -Definition topological_fieldType := [fieldType of numField_topologicalType]. -Definition topological_porderType := [porderType of numField_topologicalType]. -Definition topological_numDomainType := - [numDomainType of numField_topologicalType]. -Definition uniform_ringType := [ringType of numField_uniformType]. -Definition uniform_comRingType := [comRingType of numField_uniformType]. -Definition uniform_unitRingType := [unitRingType of numField_uniformType]. -Definition uniform_comUnitRingType := [comUnitRingType of numField_uniformType]. -Definition uniform_idomainType := [idomainType of numField_uniformType]. -Definition uniform_fieldType := [fieldType of numField_uniformType]. -Definition uniform_porderType := [porderType of numField_uniformType]. -Definition uniform_numDomainType := [numDomainType of numField_uniformType]. -Definition pseudoMetric_ringType := [ringType of numField_pseudoMetricType]. -Definition pseudoMetric_comRingType := - [comRingType of numField_pseudoMetricType]. -Definition pseudoMetric_unitRingType := - [unitRingType of numField_pseudoMetricType]. -Definition pseudoMetric_comUnitRingType := - [comUnitRingType of numField_pseudoMetricType]. -Definition pseudoMetric_idomainType := - [idomainType of numField_pseudoMetricType]. -Definition pseudoMetric_fieldType := [fieldType of numField_pseudoMetricType]. -Definition pseudoMetric_porderType := [porderType of numField_pseudoMetricType]. -Definition pseudoMetric_numDomainType := - [numDomainType of numField_pseudoMetricType]. -End numFieldType. - -Module Exports. -(* realType *) -Canonical real_pointedType. -Canonical real_filteredType. -Canonical real_topologicalType. -Canonical real_uniformType. -Canonical real_pseudoMetricType. -Coercion real_pointedType : realType >-> pointedType. -Coercion real_filteredType : realType >-> filteredType. -Coercion real_topologicalType : realType >-> topologicalType. -Coercion real_uniformType : realType >-> uniformType. -Coercion real_pseudoMetricType : realType >-> pseudoMetricType. -(* rcfType *) -Canonical rcf_pointedType. -Canonical rcf_filteredType. -Canonical rcf_topologicalType. -Canonical rcf_uniformType. -Canonical rcf_pseudoMetricType. -Coercion rcf_pointedType : rcfType >-> pointedType. -Coercion rcf_filteredType : rcfType >-> filteredType. -Coercion rcf_topologicalType : rcfType >-> topologicalType. -Coercion rcf_uniformType : rcfType >-> uniformType. -Coercion rcf_pseudoMetricType : rcfType >-> pseudoMetricType. -(* archiFieldType *) -Canonical archiField_pointedType. -Canonical archiField_filteredType. -Canonical archiField_topologicalType. -Canonical archiField_uniformType. -Canonical archiField_pseudoMetricType. -Coercion archiField_pointedType : archiFieldType >-> pointedType. -Coercion archiField_filteredType : archiFieldType >-> filteredType. -Coercion archiField_topologicalType : archiFieldType >-> topologicalType. -Coercion archiField_uniformType : archiFieldType >-> uniformType. -Coercion archiField_pseudoMetricType : archiFieldType >-> pseudoMetricType. -(* realFieldType *) -Canonical realField_pointedType. -Canonical realField_filteredType. -Canonical realField_topologicalType. -Canonical realField_uniformType. -Canonical realField_pseudoMetricType. -Canonical pointed_latticeType. -Canonical pointed_distrLatticeType. -Canonical pointed_orderType. -Canonical pointed_realDomainType. -Canonical filtered_latticeType. -Canonical filtered_distrLatticeType. -Canonical filtered_orderType. -Canonical filtered_realDomainType. -Canonical topological_latticeType. -Canonical topological_distrLatticeType. -Canonical topological_orderType. -Canonical topological_realDomainType. -Canonical uniform_latticeType. -Canonical uniform_distrLatticeType. -Canonical uniform_orderType. -Canonical uniform_realDomainType. -Canonical pseudoMetric_latticeType. -Canonical pseudoMetric_distrLatticeType. -Canonical pseudoMetric_orderType. -Canonical pseudoMetric_realDomainType. -Coercion realField_pointedType : realFieldType >-> pointedType. -Coercion realField_filteredType : realFieldType >-> filteredType. -Coercion realField_topologicalType : realFieldType >-> topologicalType. -Coercion realField_uniformType : realFieldType >-> uniformType. -Coercion realField_pseudoMetricType : realFieldType >-> pseudoMetricType. -(* numClosedFieldType *) -Canonical numClosedField_pointedType. -Canonical numClosedField_filteredType. -Canonical numClosedField_topologicalType. -Canonical numClosedField_uniformType. -Canonical numClosedField_pseudoMetricType. -Canonical pointed_decFieldType. -Canonical pointed_closedFieldType. -Canonical filtered_decFieldType. -Canonical filtered_closedFieldType. -Canonical topological_decFieldType. -Canonical topological_closedFieldType. -Canonical uniform_decFieldType. -Canonical uniform_closedFieldType. -Canonical pseudoMetric_decFieldType. -Canonical pseudoMetric_closedFieldType. -Coercion numClosedField_pointedType : numClosedFieldType >-> pointedType. -Coercion numClosedField_filteredType : numClosedFieldType >-> filteredType. -Coercion numClosedField_topologicalType : - numClosedFieldType >-> topologicalType. -Coercion numClosedField_uniformType : numClosedFieldType >-> uniformType. -Coercion numClosedField_pseudoMetricType : - numClosedFieldType >-> pseudoMetricType. -(* numFieldType *) -Canonical numField_pointedType. -Canonical numField_filteredType. -Canonical numField_topologicalType. -Canonical numField_uniformType. -Canonical numField_pseudoMetricType. -Canonical pointed_ringType. -Canonical pointed_comRingType. -Canonical pointed_unitRingType. -Canonical pointed_comUnitRingType. -Canonical pointed_idomainType. -Canonical pointed_fieldType. -Canonical pointed_porderType. -Canonical pointed_numDomainType. -Canonical filtered_ringType. -Canonical filtered_comRingType. -Canonical filtered_unitRingType. -Canonical filtered_comUnitRingType. -Canonical filtered_idomainType. -Canonical filtered_fieldType. -Canonical filtered_porderType. -Canonical filtered_numDomainType. -Canonical topological_ringType. -Canonical topological_comRingType. -Canonical topological_unitRingType. -Canonical topological_comUnitRingType. -Canonical topological_idomainType. -Canonical topological_fieldType. -Canonical topological_porderType. -Canonical topological_numDomainType. -Canonical uniform_ringType. -Canonical uniform_comRingType. -Canonical uniform_unitRingType. -Canonical uniform_comUnitRingType. -Canonical uniform_idomainType. -Canonical uniform_fieldType. -Canonical uniform_porderType. -Canonical uniform_numDomainType. -Canonical pseudoMetric_ringType. -Canonical pseudoMetric_comRingType. -Canonical pseudoMetric_unitRingType. -Canonical pseudoMetric_comUnitRingType. -Canonical pseudoMetric_idomainType. -Canonical pseudoMetric_fieldType. -Canonical pseudoMetric_porderType. -Canonical pseudoMetric_numDomainType. -Coercion numField_pointedType : numFieldType >-> pointedType. -Coercion numField_filteredType : numFieldType >-> filteredType. -Coercion numField_topologicalType : numFieldType >-> topologicalType. -Coercion numField_uniformType : numFieldType >-> uniformType. -Coercion numField_pseudoMetricType : numFieldType >-> pseudoMetricType. -End Exports. +#[export, non_forgetful_inheritance] +HB.instance Definition _ (R : realType) := PseudoMetric.copy R R^o. + +#[export, non_forgetful_inheritance] +HB.instance Definition _ (R : rcfType) := PseudoMetric.copy R R^o. + +#[export, non_forgetful_inheritance] +HB.instance Definition _ (R : archiFieldType) := PseudoMetric.copy R R^o. + +#[export, non_forgetful_inheritance] +HB.instance Definition _ (R : realFieldType) := PseudoMetric.copy R R^o. + +#[export, non_forgetful_inheritance] +HB.instance Definition _ (R : numClosedFieldType) := PseudoMetric.copy R R^o. + +#[export, non_forgetful_inheritance] +HB.instance Definition _ (R : numFieldType) := PseudoMetric.copy R R^o. + +Module Exports. HB.reexport. End Exports. End numFieldTopology. Import numFieldTopology.Exports. @@ -6371,14 +5805,33 @@ apply: Build_ProperFilter => A /nbhs_ballP[_/posnumP[e] Ae]. exists (x + e%:num / 2)%R; apply: Ae; last first. by rewrite eq_sym addrC -subr_eq subrr eq_sym. rewrite /ball /= opprD addrA subrr distrC subr0 ger0_norm //. -by rewrite {2}(splitr e%:num) ltr_spaddl. +by rewrite {2}(splitr e%:num) ltr_pwDl. Qed. +Definition uniform_fun {U : Type} (A : set U) (V : Type) := U -> V. + +Notation "{ 'uniform`' A -> V }" := (@uniform_fun _ A V) : type_scope. +Notation "{ 'uniform' U -> V }" := ({uniform` [set: U] -> V}) : type_scope. +Notation "{ 'uniform' A , F --> f }" := + (cvg_to F (nbhs (f : {uniform` A -> _}))) : classical_set_scope. +Notation "{ 'uniform' , F --> f }" := + (cvg_to F (nbhs (f : {uniform _ -> _}))) : classical_set_scope. + +(* BUG: + topology_Uniform__to__classical_sets_isPointed is already defined + HB did not try to give a fresh name + workaround: put a module around +*) +Module Export UniformFun. +HB.instance Definition _ (U : choiceType) (A : set U) (V : uniformType) := + Uniform.copy {uniform` A -> V} (weak_topology (@sigL _ V A)). +End UniformFun. + Lemma Rhausdorff (R : realFieldType) : hausdorff_space R. Proof. move=> x y clxy; apply/eqP; rewrite eq_le. apply/in_segment_addgt0Pr => _ /posnumP[e]. -rewrite in_itv /= -ler_distl; have he : 0 < (e%:num / 2) by []. +rewrite in_itv /= -ler_distl; have he : 0 < e%:num / 2 by []. have [z [zx_he yz_he]] := clxy _ _ (nbhsx_ballx x _ he) (nbhsx_ballx y _ he). have := ball_triangle yz_he (ball_sym zx_he). by rewrite -mulr2n -(mulr_natr (_ / _) 2) divfK// => /ltW. @@ -6387,25 +5840,7 @@ Qed. Section RestrictedUniformTopology. Context {U : choiceType} (A : set U) {V : uniformType} . -Definition fct_RestrictedUniform := let _ := A in U -> V. -Definition fct_RestrictedUniformTopology := - @weak_uniformType - ([pointedType of @fct_RestrictedUniform]) - (fct_uniformType [choiceType of { x : U | x \in A }] V) - (@sigL U V A). - -Canonical fct_RestrictUniformFilteredType:= - [filteredType fct_RestrictedUniform of - fct_RestrictedUniform for - fct_RestrictedUniformTopology]. - -Canonical fct_RestrictUniformTopologicalType := - [topologicalType of fct_RestrictedUniform for fct_RestrictedUniformTopology]. - -Canonical fct_restrictedUniformType := - [uniformType of fct_RestrictedUniform for fct_RestrictedUniformTopology]. - -Lemma uniform_nbhs (f : fct_RestrictedUniformTopology) P: +Lemma uniform_nbhs (f : {uniform` A -> V}) P: nbhs f P <-> (exists E, entourage E /\ [set h | forall y, A y -> E(f y, h y)] `<=` P). Proof. @@ -6416,7 +5851,7 @@ split=> [[Q [[/= W oW <- /=] Wf subP]]|[E [entE subP]]]. by apply: Eh => /=; rewrite -inE. near=> g; apply: subP => y /mem_set Ay; rewrite -!(sigLE A). move: (SigSub _); near: g. -have := (@cvg_image _ _ (sigL A) _ f (nbhs_filter f) +have := (@cvg_image _ _ (@sigL _ V A) _ f (nbhs_filter f) (image_sigL point)).1 cvg_id [set h | forall y, E (sigL A f y, h y)]. case; first by exists [set fg | forall y, E (fg.1 y, fg.2 y)]; [exists E|]. move=> B nbhsB rBrE; apply: (filterS _ nbhsB) => g Bg [y yA]. @@ -6424,7 +5859,7 @@ by move: rBrE; rewrite eqEsubset; case => [+ _]; apply; exists g. Unshelve. all: by end_near. Qed. Lemma uniform_entourage : - @entourage fct_restrictedUniformType = + @entourage [the uniformType of {uniform` A -> V}] = filter_from (@entourage V) (fun P => [set fg | forall t : U, A t -> P (fg.1 t, fg.2 t)]). @@ -6440,65 +5875,54 @@ Qed. End RestrictedUniformTopology. -Notation "{ 'uniform`' A -> V }" := (@fct_RestrictedUniform _ A V) : - classical_set_scope. -Notation "{ 'uniform' U -> V }" := ({uniform` [set: U] -> V}) : - classical_set_scope. - -Notation "{ 'uniform' A , F --> f }" := - (cvg_to [filter of F] - (filter_of (Phantom (fct_RestrictedUniform A) f))) - : classical_set_scope. -Notation "{ 'uniform' , F --> f }" := - (cvg_to [filter of F] - (filter_of (Phantom (fct_RestrictedUniform setT) f))) - : classical_set_scope. - (* We use this function to help coq identify the correct notation to use when printing. Otherwise you get goals like `F --> f -> F --> f` *) Lemma restricted_cvgE {U : choiceType} {V : uniformType} - (F : set (set (U -> V))) A (f : U -> V) : + (F : set_system (U -> V)) A (f : U -> V) : {uniform A, F --> f} = (F --> (f : {uniform` A -> V})). Proof. by []. Qed. -Definition fct_Pointwise U (V: topologicalType) := U -> V. - -Definition fct_PointwiseTopology (U : Type) (V : topologicalType) := - @product_topologicalType U (fun=> V). - -Canonical fct_PointwiseFilteredType (U : Type) (V : topologicalType) := - [filteredType @fct_Pointwise U V of - @fct_Pointwise U V for - @fct_PointwiseTopology U V]. - -Canonical fct_PointwiseTopologicalType (U : Type) (V : topologicalType) := - [topologicalType of - @fct_Pointwise U V for - @fct_PointwiseTopology U V]. - -Notation "{ 'ptws' U -> V }" := (@fct_Pointwise U V). - +Definition pointwise_fun (U V : Type) := U -> V. +Notation "{ 'ptws' U -> V }" := (@pointwise_fun U V) : type_scope. Notation "{ 'ptws' , F --> f }" := - (cvg_to [filter of F] (filter_of (Phantom (@fct_Pointwise _ _) f))) - : classical_set_scope. + (cvg_to F (nbhs (f : {ptws _ -> _}))) : classical_set_scope. + +Module Export PtwsFun. +HB.instance Definition _ (U : Type) (V : topologicalType) := + Topological.copy {ptws U -> V} (prod_topology (fun _ : U => V)). +End PtwsFun. Lemma pointwise_cvgE {U : Type} {V : topologicalType} - (F : set (set(U -> V))) (A : set U) (f : U -> V) : + (F : set_system(U -> V)) (A : set U) (f : U -> V) : {ptws, F --> f} = (F --> (f : {ptws U -> V})). Proof. by []. Qed. +Definition uniform_fun_family {U} V (fam : set U -> Prop) := U -> V. + +Notation "{ 'family' fam , U -> V }" := (@uniform_fun_family U V fam). +Notation "{ 'family' fam , F --> f }" := + (cvg_to F (@nbhs _ {family fam, _ -> _} f)) : type_scope. + +Module Export FamilyFun. +HB.instance Definition _ + {U : choiceType} {V : uniformType} (fam : set U -> Prop) := + Uniform.copy {family fam, U -> V} + (sup_topology (fun k : sigT fam => + Uniform.class [the uniformType of {uniform` projT1 k -> V}])). +End FamilyFun. + Section UniformCvgLemmas. Context {U : choiceType} {V : uniformType}. Lemma uniform_set1 F (f : U -> V) (x : U) : - Filter F -> {uniform [set x], F --> f} = ((g x) @[g --> F] --> f x). + Filter F -> {uniform [set x], F --> f} = (g x @[g --> F] --> f x). Proof. move=> FF; rewrite propeqE; split. - move=> + W => /(_ [set t | W (t x)]) +; rewrite /filter_of -nbhs_entourageE. + move=> + W => /(_ [set t | W (t x)]) +; rewrite -nbhs_entourageE. rewrite uniform_nbhs => + [Q entQ subW]. by apply; exists Q; split => // h Qf; exact/subW/Qf. -move=> Ff W; rewrite /filter_of uniform_nbhs => [[E] [entE subW]]. +move=> Ff W; rewrite uniform_nbhs => [[E] [entE subW]]. apply: (filterS subW); move/(nbhs_entourage (f x))/Ff: entE => //=; near_simpl. by apply: filter_app; apply: nearW=> ? ? ? ->. Qed. @@ -6518,7 +5942,7 @@ move => FF /uniform_subset_nbhs => /(_ f). by move=> nbhsF Acvg; apply: cvg_trans; [exact: Acvg|exact: nbhsF]. Qed. -Lemma pointwise_uniform_cvg (f : U -> V) (F : set (set (U -> V))) : +Lemma pointwise_uniform_cvg (f : U -> V) (F : set_system (U -> V)) : Filter F -> {uniform, F --> f} -> {ptws, F --> f}. Proof. move=> FF; rewrite cvg_sup => + i; have isubT : [set i] `<=` setT by move=> ?. @@ -6528,16 +5952,16 @@ apply: cvg_trans => W /=; rewrite nbhs_simpl; exists (@^~ i @^-1` W) => //. by rewrite image_preimage // eqEsubset; split=> // j _; exists (fun _ => j). Qed. -Lemma cvg_sigL (A : set U) (f : U -> V) (F : set (set (U -> V))) : +Lemma cvg_sigL (A : set U) (f : U -> V) (F : set_system (U -> V)) : Filter F -> {uniform A, F --> f} <-> {uniform, sigL A @ F --> sigL A f}. Proof. move=> FF; split. -- move=> cvgF P' /= /uniform_nbhs [ E [/= entE EsubP]]. +- move=> cvgF P' /uniform_nbhs [E [entE EsubP]]. apply: (filterS EsubP); apply: cvgF => /=. - apply: (filterS ( P:= [set h | forall y, A y -> E(f y, h y)])). - + by move=> h/= Eh [y ?] _; apply: Eh; rewrite -inE. + apply: (filterS (P := [set h | forall y, A y -> E(f y, h y)])). + + by move=> h/= Eh [y ?] _; apply Eh; rewrite -inE. + by (apply/uniform_nbhs; eexists; split; eauto). - move=> cvgF P' /= /uniform_nbhs [ E [/= entE EsubP]]. apply: (filterS EsubP). @@ -6568,7 +5992,7 @@ by rewrite uniform_entourage; exists X'. Qed. Lemma uniform_restrict_cvg - (F : set (set (U -> V))) (f : U -> V) A : Filter F -> + (F : set_system (U -> V)) (f : U -> V) A : Filter F -> {uniform A, F --> f} <-> {uniform, restrict A @ F --> restrict A f}. Proof. move=> FF; rewrite cvg_sigL; split. @@ -6588,7 +6012,7 @@ move=> FF; rewrite cvg_sigL; split. Qed. Lemma uniform_nbhsT (f : U -> V) : - (nbhs (f : {uniform U -> V})) = nbhs (f : fct_topologicalType U V). + (nbhs (f : {uniform U -> V})) = nbhs (f : [the topologicalType of U -> V]). Proof. rewrite eqEsubset; split=> A. case/uniform_nbhs => E [entE] /filterS; apply. @@ -6598,7 +6022,7 @@ case => J [E entE EJ] /filterS; apply; apply/uniform_nbhs; exists E. by split => // z /= Efz; apply: EJ => t /=; exact: Efz. Qed. -Lemma cvg_uniformU (f : U -> V) (F : set (set (U -> V))) A B : Filter F -> +Lemma cvg_uniformU (f : U -> V) (F : set_system (U -> V)) A B : Filter F -> {uniform A, F --> f} -> {uniform B, F --> f} -> {uniform (A `|` B), F --> f}. Proof. @@ -6615,7 +6039,7 @@ rewrite (_: [set h | (forall y : U, (A `|` B) y -> E (f y, h y))] = + by move=> [R1 R2] y [? | ?]; [apply: R1| apply: R2]. Qed. -Lemma cvg_uniform_set0 (F : set (set (U -> V))) (f : U -> V) : Filter F -> +Lemma cvg_uniform_set0 (F : set_system (U -> V)) (f : U -> V) : Filter F -> {uniform set0, F --> f}. Proof. move=> FF P /= /uniform_nbhs [E [? R]]. @@ -6624,33 +6048,7 @@ rewrite eqEsubset; split => //=. by apply: subset_trans R => g _ ?. Qed. -Definition fct_UniformFamily (fam : (set U) -> Prop) := U -> V. - -Definition family_cvg_uniformType (fam : set U -> Prop) := - @sup_uniformType _ - (sigT fam) - (fun k => Uniform.class (@fct_restrictedUniformType U (projT1 k) V)). - -Canonical fct_UniformFamilyFilteredType fam := - [filteredType fct_UniformFamily fam of - fct_UniformFamily fam for - family_cvg_uniformType fam]. - -Canonical fct_UniformFamilyTopologicalType fam := - [topologicalType of - fct_UniformFamily fam for - family_cvg_uniformType fam]. - -Canonical fct_UniformFamilyUniformType fam := - [uniformType of - fct_UniformFamily fam for - family_cvg_uniformType fam]. - -Local Notation "{ 'family' fam , F --> f }" := - (cvg_to [filter of F] (filter_of (Phantom (fct_UniformFamily fam) f))) - : classical_set_scope. - -Lemma fam_cvgP (fam : set U -> Prop) (F : set (set (U -> V))) (f : U -> V) : +Lemma fam_cvgP (fam : set U -> Prop) (F : set_system (U -> V)) (f : U -> V) : Filter F -> {family fam, F --> f} <-> (forall A : set U, fam A -> {uniform A, F --> f }). Proof. @@ -6658,7 +6056,7 @@ split; first by move=> /cvg_sup + A FA; move/(_ (existT _ _ FA)). by move=> famFf /=; apply/cvg_sup => [[? ?] FA]; apply: famFf. Qed. -Lemma family_cvg_subset (famA famB : set U -> Prop) (F : set (set (U -> V))) +Lemma family_cvg_subset (famA famB : set U -> Prop) (F : set_system (U -> V)) (f : U -> V) : Filter F -> famA `<=` famB -> {family famB, F --> f} -> {family famA, F --> f}. Proof. @@ -6666,7 +6064,7 @@ by move=> FF S /fam_cvgP famBFf; apply/fam_cvgP => A ?; apply/famBFf/S. Qed. Lemma family_cvg_finite_covers (famA famB : set U -> Prop) - (F : set (set (U -> V))) (f : U -> V) : Filter F -> + (F : set_system (U -> V)) (f : U -> V) : Filter F -> (forall P, famA P -> exists (I : choiceType) f, (forall i, famB (f i)) /\ finite_subset_cover [set: I] f P) -> @@ -6685,12 +6083,7 @@ Qed. End UniformCvgLemmas. -Notation "{ 'family' fam , U -> V }" := (@fct_UniformFamily U V fam). -Notation "{ 'family' fam , F --> f }" := - (cvg_to [filter of F] (filter_of (Phantom (fct_UniformFamily fam) f))) - : classical_set_scope. - -Lemma fam_cvgE {U : choiceType} {V : uniformType} (F : set (set (U -> V))) +Lemma fam_cvgE {U : choiceType} {V : uniformType} (F : set_system (U -> V)) (f : U -> V) fam : {family fam, F --> f} = (F --> (f : {family fam, U -> V})). Proof. by []. Qed. @@ -6752,39 +6145,46 @@ move=> P Q [fKP oP] [fKQ oQ]; exists (P `&` Q); first split. by move=> g /= gPQ; split; exact: (subset_trans gPQ). Qed. -Program Definition compact_openK_topological_mixin : - Topological.mixin_of compact_openK_nbhs := - @Topological.Mixin compact_openK compact_openK_nbhs - (@open_of_nbhs _ compact_openK_nbhs) _ _ _. -Next Obligation. -move=> f; rewrite eqEsubset; split => A /=. +HB.instance Definition _ := Pointed.on compact_openK. + +HB.instance Definition _ := hasNbhs.Build compact_openK compact_openK_nbhs. + +Definition compact_open_of_nbhs := [set A : set compact_openK | A `<=` nbhs^~ A]. + +Lemma compact_openK_nbhsE_subproof (p : compact_openK) : + compact_openK_nbhs p = + [set A | exists B : set compact_openK, + [/\ compact_open_of_nbhs B, B p & B `<=` A]]. +Proof. +rewrite eqEsubset; split => A /=. case=> B /= [fKB oB gKBA]; exists [set g | g @` K `<=` B]; split => //. by move=> h /= hKB; exists B. by case=> B [oB Bf /filterS]; apply; exact: oB. Qed. -Next Obligation. by []. Qed. -Canonical compact_openK_filter := FilteredType - compact_openK compact_openK compact_openK_nbhs. -Canonical compact_openK_topological := TopologicalType - compact_openK compact_openK_topological_mixin. +Lemma compact_openK_openE_subproof : + compact_open_of_nbhs = [set A | A `<=` compact_openK_nbhs^~ A]. +Proof. by []. Qed. + +HB.instance Definition _ := + Nbhs_isTopological.Build compact_openK compact_openK_nbhs_filter + compact_openK_nbhsE_subproof compact_openK_openE_subproof. + End compact_open_setwise. -Canonical compact_open_pointedType : pointedType := - PointedType compact_open point. +HB.instance Definition _ := Pointed.on compact_open. -Definition compact_open_topologicalType : topologicalType := - @sup_topologicalType _ (sigT (@compact T)) - (fun K => Topological.class (@compact_openK_topological (projT1 K))). +Definition compact_open_def := + sup_topology (fun i : sigT (@compact T) => + Topological.class (@compact_openK (projT1 i))). -Canonical compact_open_filtered := - [filteredType compact_open of compact_open for compact_open_topologicalType]. +HB.instance Definition _ := Nbhs.copy compact_open compact_open_def. -Canonical compact_open_topological := - [topologicalType of compact_open for compact_open_topologicalType]. +HB.instance Definition _ : Nbhs_isTopological compact_open := + Topological.copy compact_open compact_open_def. -Lemma compact_open_cvgP (F : set (set (compact_open_topological))) - (f : compact_open_topological) : +Lemma compact_open_cvgP (F : set_system compact_open) + (f : compact_open) : Filter F -> F --> f <-> forall K O, @compact T K -> @open U O -> f @` K `<=` O -> F [set g | g @` K `<=` O]. @@ -6817,14 +6217,14 @@ Qed. Notation "{ 'compact-open' , U -> V }" := (@compact_open U V). Notation "{ 'compact-open' , F --> f }" := - (F --> (f : @compact_open_topological _ _)). + (F --> (f : @compact_open _ _)). Section compact_open_uniform. Context {U : topologicalType} {V : uniformType}. Let small_ent_sub := @small_set_sub _ (@entourage V). -Lemma compact_open_fam_compactP (f : U -> V) (F : set (set (U -> V))) : +Lemma compact_open_fam_compactP (f : U -> V) (F : set_system (U -> V)) : continuous f -> Filter F -> {compact-open, F --> f} <-> {family compact, F --> f}. Proof. @@ -6871,7 +6271,7 @@ Definition compactly_in {U : topologicalType} (A : set U) := [set B | B `<=` A /\ compact B]. Lemma compact_cvg_within_compact {U : topologicalType} {V : uniformType} - (C : set U) (F : set (set (U -> V))) (f : U -> V) : + (C : set U) (F : set_system (U -> V)) (f : U -> V) : Filter F -> compact C -> {uniform C, F --> f} <-> {family compactly_in C, F --> f}. Proof. @@ -6888,7 +6288,7 @@ apply: Build_ProperFilter => A /nbhs_ballP[_/posnumP[e] Ae]. exists (x + e%:num / 2)%R; apply: Ae; last first. by rewrite eq_sym addrC -subr_eq subrr eq_sym. rewrite /ball /= opprD addrA subrr distrC subr0 ger0_norm //. -by rewrite {2}(splitr e%:num) ltr_spaddl. +by rewrite {2}(splitr e%:num) ltr_pwDl. Qed. Definition dense (T : topologicalType) (S : set T) := @@ -6905,10 +6305,10 @@ Qed. Lemma dense_rat (R : realType) : dense (@ratr R @` setT). Proof. move=> A [r Ar]; rewrite openE => /(_ _ Ar)/nbhs_ballP[_/posnumP[e] reA]. -have /rat_in_itvoo[q /itvP qre] : r < r + e%:num by rewrite ltr_addl. +have /rat_in_itvoo[q /itvP qre] : r < r + e%:num by rewrite ltrDl. exists (ratr q) => //; split; last by exists q. apply: reA; rewrite /ball /= distrC ltr_distl qre andbT. -by rewrite (@le_lt_trans _ _ r)// ?qre// ler_subl_addl ler_addr ltW. +by rewrite (@le_lt_trans _ _ r)// ?qre// lerBlDl lerDr ltW. Qed. Lemma separated_open_countable @@ -6938,18 +6338,15 @@ Section weak_pseudoMetric. Context {R : realType} (pS : pointedType) (U : pseudoMetricType R) . Variable (f : pS -> U). -Let S := weak_uniformType f. +Notation S := (weak_topology f). Definition weak_ball (x : S) (r : R) (y : S) := ball (f x) r (f y). -Program Definition weak_pseudoMetricType_mixin := - @PseudoMetric.Mixin R S entourage weak_ball - _ _ _ _. +Lemma weak_pseudo_metric_ball_center (x : S) (e : R) : 0 < e -> weak_ball x e x. +Proof. by move=> /posnumP[{}e]; exact: ball_center. Qed. -Next Obligation. by move=> ? _/posnumP[e]; exact: ball_center. Qed. -Next Obligation. by move=> ? ? ?; exact: ball_sym. Qed. -Next Obligation. move=> ? ? ? ? ?; exact: ball_triangle. Qed. -Next Obligation. +Lemma weak_pseudo_metric_entourageE : entourage = entourage_ weak_ball. +Proof. rewrite /entourage /= /weak_ent -entourage_ballE /entourage_. have -> : (fun e => [set xy | ball (f xy.1) e (f xy.2)]) = (preimage (map_pair f) \o fun e => [set xy | ball xy.1 e xy.2])%FUN. @@ -6972,11 +6369,12 @@ rewrite eqEsubset; split; apply/filter_fromP. - by move=> e ?; exists ([set xy | ball xy.1 e xy.2]) => //; by exists e => /=. Qed. -Definition weak_pseudoMetricType := - PseudoMetricType S weak_pseudoMetricType_mixin. +HB.instance Definition _ := Uniform_isPseudoMetric.Build R S + weak_pseudo_metric_ball_center (fun _ _ _ => @ball_sym _ _ _ _ _) + (fun _ _ _ _ _ => @ball_triangle _ _ _ _ _ _ _) + weak_pseudo_metric_entourageE. -Lemma weak_ballE (e : R) (x : weak_pseudoMetricType) : - f@^-1` (ball (f x) e) = ball x e. +Lemma weak_ballE (e : R) (x : S) : f@^-1` (ball (f x) e) = ball x e. Proof. by []. Qed. End weak_pseudoMetric. @@ -7025,6 +6423,7 @@ Qed. - `in metric spaces, compactness and sequential compactness agree` - infinite products of metric spaces are metrizable *) +Module countable_uniform. Section countable_uniform. Context {R : realType} {T : uniformType}. @@ -7067,7 +6466,7 @@ apply: subIset; left; apply: subIset; left; apply: subset_trans. by apply: subset_trans; last exact: split_ent_subset. Qed. -Local Lemma descendG (n m: nat) : (m <= n)%N -> g_ n `<=` g_ m. +Local Lemma descendG (n m : nat) : (m <= n)%N -> g_ n `<=` g_ m. Proof. elim: n; rewrite ?leqn0; first by move=>/eqP ->. move=> n IH; rewrite leq_eqVlt ltnS => /orP [/eqP <- //|] /IH. @@ -7124,7 +6523,7 @@ Local Lemma distN_le e1 e2 : e1 > 0 -> e1 <= e2 -> (distN e2 <= distN e1)%N. Proof. move=> e1pos e1e2; rewrite /distN; apply: lez_abs2. by rewrite floor_ge0 ltW// invr_gt0 (lt_le_trans _ e1e2). -by rewrite le_floor// lef_pinv ?invrK ?invr_gt0//; exact: (lt_le_trans _ e1e2). +by rewrite le_floor// lef_pV2 ?invrK ?invr_gt0//; exact: (lt_le_trans _ e1e2). Qed. Local Fixpoint n_step_ball n x e z := @@ -7215,7 +6614,7 @@ move: x e1 e2; elim: n. by apply: descendG; last (exact: gxy); exact: distN_le. move=> n IH x e1 e2 e1e2 z [y] [d1] [d2] [] /IH P d1pos d2pos gyz d1d2e1. have d1e1d2 : d1 = e1 - d2 by rewrite -d1d2e1 -addrA subrr addr0. -have e2d2le : e1 - d2 <= e2 - d2 by exact: ler_sub. +have e2d2le : e1 - d2 <= e2 - d2 by exact: lerB. exists y, (e2 - d2), d2; split => //. - by apply: P; apply: le_trans e2d2le; rewrite d1e1d2. - by apply: lt_le_trans e2d2le; rewrite -d1e1d2. @@ -7229,7 +6628,7 @@ Proof. by move=> e1e2 ? [n P]; exists n; exact: (n_step_ball_le e1e2). Qed. Local Lemma distN_half (n : nat) : n.+1%:R^-1 / (2:R) <= n.+2%:R^-1. Proof. rewrite -invrM //; [|exact: unitf_gt0 |exact: unitf_gt0]. -rewrite lef_pinv ?posrE // -?natrM ?ler_nat -addn1 -addn1 -addnA mulnDr. +rewrite lef_pV2 ?posrE // -?natrM ?ler_nat -addn1 -addn1 -addnA mulnDr. by rewrite muln1 leq_add2r leq_pmull. Qed. @@ -7249,25 +6648,25 @@ move: e1 e2 x z; elim: n. move=> e1d1; exists x, y, 0%N, 0%N; split. - exact: n_step_ball_center. - apply: n_step_ball_le; last exact: Oxy. - by rewrite -deE ler_addl; apply: ltW. + by rewrite -deE lerDl; apply: ltW. - apply: (@n_step_ball_le _ _ d2); last by split. - rewrite -[e2]addr0 -(subrr e1) addrA -ler_subl_addr opprK addrC. - by rewrite [e2 + _]addrC -deE; exact: ler_add. + rewrite -[e2]addr0 -(subrr e1) addrA -lerBlDr opprK addrC. + by rewrite [e2 + _]addrC -deE; exact: lerD. - by rewrite addn0. move=> /negP; rewrite -real_ltNge ?num_real //. move=> e1d1; exists y, z, 0%N, 0%N; split. - by apply: n_step_ball_le; last (exact: Oxy); exact: ltW. - rewrite -deE; apply: (@n_step_ball_le _ _ d2) => //. - by rewrite ler_addr; apply: ltW. + by rewrite lerDr; apply: ltW. - exact: n_step_ball_center. - by rewrite addn0. move=> n IH e1 e2 x z e1pos e2pos [y] [d1] [d2] [] Od1xy d1pos d2pos gd2yz deE. case: (pselect (e2 <= d2)). move=> e2d2; exists y, z, n.+1, 0%N; split. - apply: (@n_step_ball_le _ _ d1); rewrite // -[e1]addr0 -(subrr e2) addrA. - by rewrite -deE -ler_subl_addr opprK ler_add. + by rewrite -deE -lerBlDr opprK lerD. - apply: (@n_step_ball_le _ _ d2); last by split. - by rewrite -deE ler_addr; exact: ltW. + by rewrite -deE lerDr; exact: ltW. - exact: n_step_ball_center. - by rewrite addn0. have d1E' : d1 = e1 + (e2 - d2). @@ -7276,7 +6675,7 @@ move=> /negP; rewrite -?real_ltNge // ?num_real // => d2lee2. case: (IH e1 (e2 - d2) x y); rewrite ?subr_gt0 // -d1E' //. move=> t1 [t2] [c1] [c2] [] Oxy1 gt1t2 t2y <-. exists t1, t2, c1, c2.+1; split => //. - - by apply: (@n_step_ball_le _ _ d1); rewrite -?deE // ?ler_addl; exact: ltW. + - by apply: (@n_step_ball_le _ _ d1); rewrite -?deE // ?lerDl; exact: ltW. - exists y, (e2 - d2), d2; split; rewrite // ?subr_gt0//. by rewrite -addrA [-_ + _]addrC subrr addr0. - by rewrite addnS. @@ -7320,53 +6719,54 @@ apply: (subset_trans _ fN); apply: subset_trans; last apply: gsubf. by case=> x y /= N1ball; apply: (@subset_step_ball x N.+1). Qed. -(* Note these are the only non-local result from this section *) -Definition countable_uniform_pseudoMetricType_mixin := PseudoMetric.Mixin +Definition type : Type := let _ := countableBase in let _ := entF in T. + +#[export] HB.instance Definition _ := Uniform.on type. +#[export] HB.instance Definition _ := Uniform_isPseudoMetric.Build R type step_ball_center step_ball_sym step_ball_triangle step_ball_entourage. Lemma countable_uniform_bounded (x y : T) : - let U := PseudoMetricType _ countable_uniform_pseudoMetricType_mixin + let U := [the pseudoMetricType R of type] in @ball _ U x 2 y. Proof. rewrite /ball; exists O%N; rewrite /n_step_ball; split; rewrite // /distN. suff -> : @floor R 2^-1 = 0 by rewrite absz0 /=. apply/eqP; rewrite -[_ == _]negbK; rewrite floor_neq0 negb_or -?ltNge -?leNgt. -by apply/andP; split => //; rewrite invf_lt1 //= ltr_addl. +by apply/andP; split => //; rewrite invf_lt1 //= ltrDl. Qed. End countable_uniform. +Module Exports. HB.reexport. End Exports. +End countable_uniform. +Export countable_uniform.Exports. + +Notation countable_uniform := countable_uniform.type. + +Definition sup_pseudometric (R : realType) (T : pointedType) (Ii : Type) + (Tc : Ii -> PseudoMetric R T) (Icnt : countable [set: Ii]) : Type := T. Section sup_pseudometric. Variable (R : realType) (T : pointedType) (Ii : Type). -Variable (Tc : Ii -> PseudoMetric.class_of R T). +Variable (Tc : Ii -> PseudoMetric R T). Hypothesis Icnt : countable [set: Ii]. -Let I : choiceType := classicType_choiceType Ii. +Local Notation S := (sup_pseudometric Tc Icnt). + Let TS := fun i => PseudoMetric.Pack (Tc i). Definition countable_uniformityT := @countable_sup_ent T Ii Tc Icnt (fun i => @countable_uniformity_metric _ (TS i)). -Definition sup_pseudoMetric_mixin := @countable_uniform_pseudoMetricType_mixin R - (sup_uniformType Tc) countable_uniformityT. - -Definition sup_pseudoMetricType := - PseudoMetricType (sup_uniformType Tc) sup_pseudoMetric_mixin. +HB.instance Definition _ : PseudoMetric R S := + PseudoMetric.on (countable_uniform countable_uniformityT). End sup_pseudometric. -Section product_pseudometric. -Variable (R : realType) (Ii : countType) (Tc : Ii -> pseudoMetricType R). - -Hypothesis Icnt : countable [set: Ii]. - -Definition product_pseudoMetricType := - sup_pseudoMetricType (fun i => PseudoMetric.class - (weak_pseudoMetricType (fun f : dep_arrow_pointedType Tc => f i))) - Icnt. - -End product_pseudometric. +HB.instance Definition _ (R : realType) (Ii : countType) + (Tc : Ii -> pseudoMetricType R) := PseudoMetric.copy (prod_topology Tc) + (sup_pseudometric (fun i => PseudoMetric.class + [the pseudoMetricType R of weak_topology (@proj _ Tc i)]) (countableP _)). Definition subspace {T : Type} (A : set T) := T. Arguments subspace {T} _ : simpl never. @@ -7376,16 +6776,16 @@ Definition incl_subspace {T A} (x : subspace A) : T := x. Section Subspace. Context {T : topologicalType} (A : set T). -Definition nbhs_subspace (x : subspace A) : set (set (subspace A)) := +Definition nbhs_subspace (x : subspace A) : set_system (subspace A) := if x \in A then within A (nbhs x) else globally [set x]. -Variant nbhs_subspace_spec x : Prop -> Prop -> bool -> set (set T) -> Type := +Variant nbhs_subspace_spec x : Prop -> Prop -> bool -> set_system T -> Type := | WithinSubspace : A x -> nbhs_subspace_spec x True False true (within A (nbhs x)) | WithoutSubspace : ~ A x -> nbhs_subspace_spec x False True false (globally [set x]). -Lemma nbhs_subspaceP x : +Lemma nbhs_subspaceP_subproof x : nbhs_subspace_spec x (A x) (~ A x) (x \in A) (nbhs_subspace x). Proof. rewrite /nbhs_subspace; case:(boolP (x \in A)); rewrite ?(inE, notin_set) => xA. @@ -7394,41 +6794,43 @@ by rewrite (@propext (A x) False)// not_False; constructor. Qed. Lemma nbhs_subspace_in (x : T) : A x -> within A (nbhs x) = nbhs_subspace x. -Proof. by case: nbhs_subspaceP. Qed. +Proof. by case: nbhs_subspaceP_subproof. Qed. Lemma nbhs_subspace_out (x : T) : ~ A x -> globally [set x] = nbhs_subspace x. -Proof. by case: nbhs_subspaceP. Qed. +Proof. by case: nbhs_subspaceP_subproof. Qed. Lemma nbhs_subspace_filter (x : subspace A) : ProperFilter (nbhs_subspace x). Proof. -case: nbhs_subspaceP => ?; last exact: globally_properfilter. +case: nbhs_subspaceP_subproof => ?; last exact: globally_properfilter. by apply: within_nbhs_proper; apply: subset_closure. Qed. -Definition subspace_pointedType := PointedType (subspace A) point. +HB.instance Definition _ := Choice.copy (subspace A) _. -Canonical subspace_filteredType := - FilteredType (subspace A) (subspace A) nbhs_subspace. +HB.instance Definition _ := isPointed.Build (subspace A) point. -Program Definition subspace_topologicalMixin : - Topological.mixin_of (nbhs_subspace) := @topologyOfFilterMixin - (subspace A) nbhs_subspace nbhs_subspace_filter _ _. -Next Obligation. -by move=> p A0; case: nbhs_subspaceP => ? => [/nbhs_singleton|]; apply. -Qed. -Next Obligation. -move=> p A0; case: nbhs_subspaceP => [|] Ap. +HB.instance Definition _ := hasNbhs.Build (subspace A) nbhs_subspace. + +Lemma nbhs_subspaceP (x : subspace A) : + nbhs_subspace_spec x (A x) (~ A x) (x \in A) (nbhs x). +Proof. exact: nbhs_subspaceP_subproof. Qed. + +Lemma nbhs_subspace_singleton (p : subspace A) B : nbhs p B -> B p. +Proof. by case: nbhs_subspaceP => ? => [/nbhs_singleton|]; apply. Qed. + +Lemma nbhs_subspace_nbhs (p : subspace A) B : nbhs p B -> nbhs p (nbhs^~ B). +Proof. +case: nbhs_subspaceP => [|] Ap. by move=> /nbhs_interior; apply: filterS => y A0y Ay; case: nbhs_subspaceP. by move=> E x ->; case: nbhs_subspaceP. Qed. -Canonical subspace_topologicalType := - TopologicalType (subspace A) subspace_topologicalMixin. +HB.instance Definition _ := Nbhs_isNbhsTopological.Build (subspace A) + nbhs_subspace_filter nbhs_subspace_singleton nbhs_subspace_nbhs. -Lemma subspace_cvgP (F : set (set T)) (x : T) : - Filter F -> A x -> +Lemma subspace_cvgP (F : set_system T) (x : T) : Filter F -> A x -> (F --> (x : subspace A)) <-> (F --> within A (nbhs x)). -Proof. by case: (y in F --> y) / nbhs_subspaceP. Qed. +Proof. by case: _ / nbhs_subspaceP. Qed. Lemma subspace_continuousP {S : topologicalType} (f : T -> S) : continuous (f : subspace A -> S) <-> @@ -7436,7 +6838,7 @@ Lemma subspace_continuousP {S : topologicalType} (f : T -> S) : Proof. split => [ctsf x Ax W /=|wA x]. by rewrite nbhs_simpl //= nbhs_subspace_in //=; apply: ctsf. -case: (y in _ @[_ --> y]) / (nbhs_subspaceP x) => Ax. +rewrite /continuous_at; case: _ / (nbhs_subspaceP x) => Ax. exact: (cvg_trans _ (wA _ Ax)). by move=> ? /nbhs_singleton //= ?; rewrite nbhs_simpl => ? ->. Qed. @@ -7444,14 +6846,14 @@ Qed. Lemma subspace_eq_continuous {S : topologicalType} (f g : subspace A -> S) : {in A, f =1 g} -> continuous f -> continuous g. Proof. -rewrite ?subspace_continuousP=> feq L x Ax; rewrite -(feq x) ?inE //. +rewrite ?subspace_continuousP => feq L x Ax; rewrite -(feq x) ?inE //. by apply: cvg_trans _ (L x Ax); apply: fmap_within_eq=> ? ?; rewrite feq. Qed. Lemma continuous_subspace_in {U : topologicalType} (f : subspace A -> U) : continuous f = {in A, continuous f}. Proof. -rewrite propeqE in_setP subspace_continuousP/filter_of/nbhs //=; split. +rewrite propeqE in_setP subspace_continuousP /continuous_at //=; split. by move=> Q x Ax; case: (nbhs_subspaceP x) => //=; exact: Q. by move=> + x Ax => /(_ x Ax); case: (nbhs_subspaceP x) => //=; exact: Q. Qed. @@ -7513,27 +6915,32 @@ Lemma open_subspaceP (U : set T) : open (U : set (subspace A)) <-> exists V, open (V : set T) /\ V `&` A = U `&` A. Proof. -split=> [|[V [oV UV]]]; first last. - rewrite -open_subspaceIT -UV => x //= []; case: nbhs_subspaceP => //=. - rewrite withinE /= => Ax Vx _; exists V; last by rewrite -setIA setIid. - by move: oV; rewrite openE; exact. +split; first last. + case=> V [oV UV]; rewrite -open_subspaceIT -UV. + move=> x //= []; case: nbhs_subspaceP; rewrite //= withinE. + move=> ? ? _; exists V; last by rewrite -setIA setIid. + by move: oV; rewrite openE /interior; apply. rewrite -open_subspaceIT => oUA. -have oxF x : (U `&` A) x -> exists2 V, open_nbhs x V & V `&` A `<=` U `&` A. - move=> /[dup] UAx [Ux Ax]; move: (oUA _ UAx); case: nbhs_subspaceP => // _. - rewrite withinE /= => -[V nbhsV]; rewrite -setIA setIid => UV. - exists V^°; rewrite ?open_nbhsE. - - by split; [exact: open_interior|exact: nbhs_interior]. - - by rewrite UV => t [/interior_subset]. -pose f x := - if pselect ((U `&` A) x) is left e then projT1 (cid2 (oxF x e)) else set0. -exists (\bigcup_(x in U `&` A) f x); split. - apply: bigcup_open => i UAi; rewrite /f; case: pselect => // ?. - by case: (cid2 _) => //= W; rewrite open_nbhsE => -[]. -rewrite eqEsubset /f; split. - move=> t [[u UAu]] /=; case: pselect => //= ?. - by case: (cid2 _) => /= W _ + ? ?; exact. -move=> t UAt; split; last by case: UAt. -by exists t => //; case: pselect => //= -[Ut At]; case: (cid2 _) => //= W []. +have oxF : (forall (x : T), (U `&` A) x -> + exists V, (open_nbhs (x : T) V) /\ (V `&` A `<=` U `&` A)). + move=> x /[dup] UAx /= [??]; move: (oUA _ UAx); + case: nbhs_subspaceP => // ?. + rewrite withinE /= => [[V nbhsV UV]]; rewrite -setIA setIid in UV. + exists V^°; split; first rewrite open_nbhsE; first split => //. + - exact: open_interior. + - exact: nbhs_interior. + - by rewrite UV=> t [/interior_subset] ??; split. +pose f (x : T) := + if pselect ((U `&` A) x) is left e then projT1 (cid (oxF x e)) else set0. +set V := \bigcup_(x in (U `&` A)) (f x); exists V; split. + apply: bigcup_open => i UAi; rewrite /f; case: pselect => // ?; case: (cid _). + by move=> //= W; rewrite open_nbhsE=> -[[]]. +rewrite eqEsubset /V /f; split. + move=> t [[u]] UAu /=; case: pselect => //= ?. + by case: (cid _) => //= W [] _ + ? ?; apply; split. +move=> t UAt; split => //; last by case: UAt. +exists t => //; case: pselect => //= [[? ?]]. +by case: (cid _) => //= W [] [] _. Qed. Lemma closed_subspaceP (U : set T) : @@ -7581,8 +6988,9 @@ Lemma closure_subspaceW (U : set T) : U `<=` A -> closure (U : set (subspace A)) = closure (U : set T) `&` A. Proof. have /closed_subspaceP := (@closed_closure _ (U : set (subspace A))). -move=> [V] [clV VAclUA] /[dup] /(@closure_subset subspace_topologicalType). -have/closure_id <- := (closed_subspaceT) => /setIidr <-; rewrite setIC. +move=> [V] [clV VAclUA]. +move=> /[dup] /(@closure_subset [the topologicalType of subspace _]). +have /closure_id <- := closed_subspaceT => /setIidr <-; rewrite setIC. move=> UsubA; rewrite eqEsubset; split. apply: setSI; rewrite closureE; apply: smallest_sub (@subset_closure _ U). by apply: closed_subspaceW; exact: closed_closure. @@ -7592,7 +7000,7 @@ exact: (@subset_closure _ (U : set (subspace A))). Qed. Lemma subspace_hausdorff : - hausdorff_space T -> hausdorff_space [topologicalType of subspace A]. + hausdorff_space T -> hausdorff_space [the topologicalType of subspace A]. Proof. rewrite ?open_hausdorff => + x y xNy => /(_ x y xNy). move=> [[P Q]] /= [Px Qx] /= [/open_subspaceW oP /open_subspaceW oQ]. @@ -7614,7 +7022,7 @@ by apply: filterI; rewrite nbhs_simpl //; exact: Fp. Qed. Lemma clopen_connectedP : connected A <-> - (forall U, @clopen (subspace_topologicalType) U -> + (forall U, @clopen [the topologicalType of subspace A] U -> U `<=` A -> U !=set0 -> U = A). Proof. split. @@ -7639,11 +7047,10 @@ Global Instance subspace_proper_filter {T : topologicalType} (A : set T) (x : subspace A) : ProperFilter (nbhs_subspace x) := nbhs_subspace_filter x. -(*Notation "{ 'within' A , 'continuous' f }" := - (continuous (f : subspace A -> _)).*) -Notation "{ 'within' A , 'continuous' f }" := (forall x, - cvg_to [filter of fmap f (filter_of (Phantom (subspace A) x))] - [filter of f x]) : classical_set_scope. +Notation "{ 'within' A , 'continuous' f }" := + (continuous (f : subspace A -> _)) : classical_set_scope. + +Arguments nbhs_subspaceP {T} A x. Section SubspaceRelative. Context {T : topologicalType}. @@ -7652,7 +7059,7 @@ Implicit Types (U : topologicalType) (A B : set T). Lemma nbhs_subspace_subset A B (x : T) : A `<=` B -> nbhs (x : subspace B) `<=` nbhs (x : subspace A). Proof. -rewrite /nbhs //= => AB; case: (nbhs_subspaceP A); case: (nbhs_subspaceP B). +rewrite /= => AB; case: (nbhs_subspaceP A); case: (nbhs_subspaceP B). - by move=> ? ?; apply: within_subset => //=; exact: (nbhs_filter x). - by move=> ? /AB. - by move=> Bx ? W /nbhs_singleton /(_ Bx) ? ? ->. @@ -7668,7 +7075,7 @@ Qed. Lemma nbhs_subspaceT (x : T) : nbhs (x : subspace setT) = nbhs x. Proof. -rewrite {1}/nbhs //=; have [_|] := nbhs_subspaceP [set: T]; last by cbn. +have [_|] := nbhs_subspaceP [set: T]; last by cbn. rewrite eqEsubset withinE; split => [W [V nbhsV]|W ?]; last by exists W. by rewrite 2!setIT => ->. Qed. @@ -7676,10 +7083,10 @@ Qed. Lemma continuous_subspaceT_for {U} A (f : T -> U) (x : T) : A x -> {for x, continuous f} -> {for x, continuous (f : subspace A -> U)}. Proof. -rewrite /filter_of/nbhs/=/prop_for => inA ctsf. +rewrite /continuous_at /prop_for => inA ctsf. have [_|//] := nbhs_subspaceP A x. apply: (cvg_trans _ ctsf); apply: cvg_fmap2; apply: cvg_within. -by rewrite /subspace; exact: nbhs_filter. +exact: (nbhs_filter x). Qed. Lemma continuous_in_subspaceT {U} A (f : T -> U) : @@ -7701,7 +7108,7 @@ Lemma continuous_open_subspace {U} A (f : T -> U) : Proof. rewrite openE continuous_subspace_in /= => oA; rewrite propeqE ?in_setP. by split => + x /[dup] Ax /oA Aox => /(_ _ Ax); - rewrite /filter_of -(nbhs_subspace_interior Aox). + rewrite /continuous_at -(nbhs_subspace_interior Aox). Qed. Lemma continuous_inP {U} A (f : T -> U) : open A -> @@ -7740,14 +7147,14 @@ Qed. Lemma continuous_subspace0 {U} (f : T -> U) : {within set0, continuous f}. Proof. -move=> x Q; rewrite nbhs_simpl /= {2}/nbhs /=. +move=> x Q /=. by case: (nbhs_subspaceP (@set0 T) x) => // _ /nbhs_singleton /= ? ? ->. Qed. Lemma continuous_subspace1 {U} (a : T) (f : T -> U) : {within [set a], continuous f}. Proof. -move=> x Q; rewrite nbhs_simpl /= {2}/nbhs /=. +move=> x Q /=. case: (nbhs_subspaceP [set a] x); last by move=> _ /nbhs_singleton /= ? ? ->. by move=> -> /nbhs_singleton ?; apply: nearW => ? ->. Qed. @@ -7762,21 +7169,32 @@ Definition subspace_ent := filter_from (@entourage X) (fun E => [set xy | (xy.1 = xy.2) \/ (A xy.1 /\ A xy.2 /\ E xy)]). -Program Definition subspace_uniformMixin := - @Uniform.Mixin (subspace A) (@nbhs_subspace _ _) subspace_ent _ _ _ _ _. -Next Obligation. +Let Filter_subspace_ent : Filter subspace_ent. +Proof. apply: filter_from_filter; first by (exists setT; exact: filterT). move=> P Q entP entQ; exists (P `&` Q); first exact: filterI. move=> [x y] /=; case; first (by move=> ->; split=> /=; left). by move=> [Ax [Ay [Pxy Qxy]]]; split=> /=; right. Qed. -Next Obligation. by move=> ? + [x y]/= ->; case=> V entV; apply; left. Qed. -Next Obligation. + +Let subspace_uniform_entourage_refl : forall X : set (subspace A * subspace A), + subspace_ent X -> [set xy | xy.1 = xy.2] `<=` X. +Proof. +by move=> ? + [x y]/= ->; case=> V entV; apply; left. +Qed. + +Let subspace_uniform_entourage_inv : forall A : set (subspace A * subspace A), + subspace_ent A -> subspace_ent (A^-1)%classic. +Proof. move=> ?; case=> V ? Vsub; exists (V^-1)%classic; first exact: entourage_inv. move=> [x y] /= G; apply: Vsub; case: G; first by (move=> <-; left). by move=> [? [? Vxy]]; right; repeat split => //. Qed. -Next Obligation. + +Let subspace_uniform_entourage_split_ex : + forall A : set (subspace A * subspace A), + subspace_ent A -> exists2 B, subspace_ent B & B \; B `<=` A. +Proof. move=> ?; case=> E entE Esub. exists [set xy | xy.1 = xy.2 \/ A xy.1 /\ A xy.2 /\ split_ent E xy]. by exists (split_ent E). @@ -7789,8 +7207,10 @@ move=> [x y] [z /= Ez zE] /=; case: Ez; case: zE. - move=> []? []? ?[]?[]??; apply: Esub; right; repeat split => //=. by apply: subset_split_ent => //; exists z. Qed. -Next Obligation. -pose EA := [set xy | xy.1 = xy.2 \/ A xy.1 /\ A xy.2]. + +Let subspace_uniform_nbhsE : @nbhs _ (subspace A) = nbhs_ subspace_ent. +Proof. +pose EA := [set xy | xy.1 = xy.2 \/ A xy.1 /\ A xy.2]. have entEA : subspace_ent EA. exists setT; first exact: filterT. by move=> [??] /= [ ->|[?] [?]];[left|right]. @@ -7814,8 +7234,11 @@ case: (@nbhs_subspaceP X A x); rewrite propeqE; split => //=. by apply: subU; apply: subW; left. Unshelve. all: by end_near. Qed. -Canonical subspace_uniformType := - UniformType (subspace A) subspace_uniformMixin. +HB.instance Definition _ := Nbhs_isUniform_mixin.Build (subspace A) + Filter_subspace_ent subspace_uniform_entourage_refl + subspace_uniform_entourage_inv subspace_uniform_entourage_split_ex + subspace_uniform_nbhsE. + End SubspaceUniform. Section SubspacePseudoMetric. @@ -7824,26 +7247,33 @@ Context {R : numDomainType} {X : pseudoMetricType R} (A : set X). Definition subspace_ball (x : subspace A) (r : R) := if x \in A then A `&` ball (x : X) r else [set x]. -Program Definition subspace_pseudoMetricType_mixin := - @PseudoMetric.Mixin R (subspace A) (subspace_ent A) (subspace_ball) - _ _ _ _. -Next Obligation. -move=> x e; rewrite /subspace_ball; case: ifP => //= /asboolP ? ?. +Lemma subspace_pm_ball_center x (e : R) : 0 < e -> subspace_ball x e x. +Proof. +rewrite /subspace_ball; case: ifP => //= /asboolP ? ?. by split=> //; exact: ballxx. Qed. -Next Obligation. -move=> x y e; rewrite /subspace_ball; case: ifP => //= /asboolP ?. + +Lemma subspace_pm_ball_sym x y (e : R) : + subspace_ball x e y -> subspace_ball y e x. +Proof. +rewrite /subspace_ball; case: ifP => //= /asboolP ?. by move=> [] Ay /ball_sym yBx; case: ifP => /asboolP. by move=> ->; case: ifP => /asboolP. Qed. -Next Obligation. -move=> x y z e1 e2; rewrite /subspace_ball; (repeat case: ifP => /asboolP). + +Lemma subspace_pm_ball_triangle x y z e1 e2 : + subspace_ball x e1 y -> subspace_ball y e2 z -> subspace_ball x (e1 + e2) z. +Proof. +rewrite /subspace_ball; (repeat case: ifP => /asboolP). - by move=>?? [??] [??]; split => //=; apply: ball_triangle; eauto. - by move=> ?? [??] ->. - by move=> + /[swap] => /[swap] => ->. - by move=> _ _ -> ->. Qed. -Next Obligation. + +Lemma subspace_pm_entourageE : + @entourage (subspace A) = entourage_ subspace_ball. +Proof. rewrite eqEsubset; split; rewrite /subspace_ball. move=> U [W + subU]; rewrite -entourage_ballE => [[eps] nneg subW]. exists eps => //; apply: (subset_trans _ subU). @@ -7857,8 +7287,10 @@ move=> [x y] /= [->|[]Ax []Ay xBy]; apply: subE => //=. by case: ifP => /asboolP. Qed. -Canonical subspace_pseudoMetricType := - PseudoMetricType (subspace A) subspace_pseudoMetricType_mixin. +HB.instance Definition _ := + @Uniform_isPseudoMetric.Build R (subspace A) subspace_ball + subspace_pm_ball_center subspace_pm_ball_sym subspace_pm_ball_triangle + subspace_pm_entourageE. End SubspacePseudoMetric. @@ -7866,9 +7298,7 @@ Section SubspaceWeak. Context {T : topologicalType} {U : pointedType}. Variables (f : U -> T). -Let U' := weak_topologicalType f. - -Lemma weak_subspace_open (A : set U') : +Lemma weak_subspace_open (A : set (weak_topology f)) : open A -> open (f @` A : set (subspace (range f))). Proof. case=> B oB <-; apply/open_subspaceP; exists B; split => //; rewrite eqEsubset. @@ -7897,27 +7327,26 @@ Variable (f_ : forall i, T -> U_ i). Hypothesis sepf : separate_points_from_closed f_. Hypothesis ctsf : forall i, continuous (f_ i). -Let weakT := @sup_topologicalType T I - (fun i => Topological.class (weak_topologicalType (f_ i))). +Let weakT := [the topologicalType of + sup_topology (fun i => Topological.on (weak_topology (f_ i)))]. -Let PU := product_topologicalType U_. +Let PU := [the topologicalType of prod_topology U_]. Local Notation sup_open := (@open weakT). -Local Notation "'weak_open' i" := - (@open (weak_topologicalType (f_ i))) (at level 0). +Local Notation "'weak_open' i" := (@open weakT) (at level 0). Local Notation natural_open := (@open T). -Lemma weak_sep_cvg (F : set (set T)) (x : T) : +Lemma weak_sep_cvg (F : set_system T) (x : T) : Filter F -> (F --> (x : T)) <-> (F --> (x : weakT)). Proof. move=> FF; split. move=> FTx; apply/cvg_sup => i U. - have /= -> := @nbhsE (weak_topologicalType (f_ i)) x. + have /= -> := @nbhsE (weak_topology (f_ i)) x. case=> B [[C oC <- ?]] /filterS; apply; apply: FTx; rewrite /= nbhsE. by exists (f_ i @^-1` C) => //; split => //; exact: open_comp. move/cvg_sup => wiFx U; rewrite /= nbhs_simpl nbhsE => [[B [oB ?]]]. move/filterS; apply; have [//|i nclfix] := @sepf _ x (open_closedC oB). -apply: (wiFx i); have /= -> := @nbhsE (weak_topologicalType (f_ i)) x. +apply: (wiFx i); have /= -> := @nbhsE (weak_topology (f_ i)) x. exists (f_ i @^-1` (~` closure [set f_ i x | x in ~` B])); [split=>//|]. apply: open_comp; last by rewrite ?openC; last apply: closed_closure. by move=> + _; exact: (@weak_continuous _ _ (f_ i)). @@ -7945,15 +7374,14 @@ Proof. suff : continuous (join_product : weakT -> PU). by move=> cts x U => /cts; rewrite nbhs_simpl /= -weak_sep_nbhsE. move=> x; apply/cvg_sup; first exact/fmap_filter/(nbhs_filter (x : weakT)). -move=> i; move: x; apply/(@continuousP _ (weak_topologicalType _)) => A [B ? E]. +move=> i; move: x; apply/(@continuousP _ (weak_topology (@^~ i))) => A [B ? E]. rewrite -E (_ : @^~ i = proj i) //. have -> : join_product @^-1` (proj i @^-1` B) = f_ i @^-1` B by []. apply: open_comp => // + _; rewrite /cvg_to => x U. by rewrite nbhs_simpl /= -weak_sep_nbhsE; move: x U; exact: ctsf. Qed. -Local Notation prod_open := - (@open (subspace_topologicalType (range join_product))). +Local Notation prod_open := (@open (subspace (range join_product))). Lemma join_product_open (A : set T) : open A -> open ((join_product @` A) : set (subspace (range join_product))). @@ -7982,7 +7410,7 @@ by apply: subset_closure; exists y. Qed. Lemma join_product_weak : set_inj [set: T] join_product -> - @open T = @open (weak_topologicalType join_product). + @open T = @open (weak_topology join_product). Proof. move=> inj; rewrite predeqE => U; split; first last. by move=> [V ? <-]; apply: open_comp => // + _; exact: join_product_continuous. @@ -8056,7 +7484,7 @@ by rewrite predeqE => /(_ (f t)) [fcAfEb] _; apply: fcAfEb; split; exists t. Qed. Lemma uniform_limit_continuous {U : topologicalType} {V : uniformType} - (F : set (set (U -> V))) (f : U -> V) : + (F : set_system (U -> V)) (f : U -> V) : ProperFilter F -> (\forall g \near F, continuous (g : U -> V)) -> {uniform, F --> f} -> continuous f. Proof. @@ -8070,14 +7498,13 @@ by split; [exact: entourage_inv | move=> g fg; near_simpl; near=> z; exact: fg]. Unshelve. all: end_near. Qed. Lemma uniform_limit_continuous_subspace {U : topologicalType} {V : uniformType} - (K : set U) (F : set (set (U -> V))) (f : subspace K -> V) : + (K : set U) (F : set_system (U -> V)) (f : subspace K -> V) : ProperFilter F -> (\forall g \near F, continuous (g : subspace K -> V)) -> {uniform K, F --> f} -> {within K, continuous f}. Proof. move=> PF ctsF Ff; apply: (@subspace_eq_continuous _ _ _ (restrict K f)). by rewrite /restrict => ? ->. -apply: (@uniform_limit_continuous - (subspace_topologicalType K) _ (restrict K @ F) _). +apply: (@uniform_limit_continuous (subspace K) _ (restrict K @ F) _). apply: (filterS _ ctsF) => g; apply: subspace_eq_continuous. by rewrite /restrict => ? ->. by apply (@uniform_restrict_cvg _ _ F ) => //; exact: PF. @@ -8101,7 +7528,7 @@ Unshelve. end_near. Qed. Lemma totally_disconnected_prod (I : choiceType) (T : I -> topologicalType) (A : forall i, set (T i)) : (forall i, totally_disconnected (A i)) -> - @totally_disconnected (product_topologicalType T) + @totally_disconnected (prod_topology T) (fun f => forall i, A i (f i)). Proof. move=> dsctAi x /= Aix; rewrite eqEsubset; split; last first. @@ -8122,7 +7549,9 @@ Definition singletons {T : Type} := [set [set x] | x in [set: T]]. Lemma pointwise_cvg_family_singleton F (f: U -> V): Filter F -> {ptws, F --> f} = {family @singletons U, F --> f}. Proof. -move=> FF; rewrite propeqE fam_cvgP cvg_sup; split. +move=> FF; apply/propext. +rewrite (@fam_cvgP _ _ singletons). (* BUG: slowdown if no arguments *) +rewrite cvg_sup; split. move=> + A [x _ <-] => /(_ x); rewrite uniform_set1. rewrite cvg_image; last by rewrite eqEsubset; split=> v // _; exists (cst v). apply: cvg_trans => W /=; rewrite ?nbhs_simpl /fmap /= => [[W' + <-]]. @@ -8152,7 +7581,8 @@ Qed. End UniformPointwise. -Section gauges. +Module gauge. +Section gauge. Let split_sym {T : uniformType} (W : set (T * T)) := (split_ent W) `&` (split_ent W)^-1. @@ -8206,50 +7636,47 @@ apply: subset_trans EA; apply: subset_trans; first last. by case=> a c [b] [] ? ? [] ? ?; exists b. Qed. -Definition gauge_uniformType_mixin := - UniformMixin gauge_filter gauge_refl gauge_inv gauge_split erefl. - -Definition gauge_topologicalTypeMixin := - topologyOfEntourageMixin gauge_uniformType_mixin. +Let gauged : Type := T. -Definition gauge_filtered := FilteredType T T (nbhs_ gauge). -Definition gauge_topologicalType := - TopologicalType gauge_filtered gauge_topologicalTypeMixin. -Definition gauge_uniformType := UniformType - gauge_topologicalType gauge_uniformType_mixin. +HB.instance Definition _ := Pointed.on gauged. +HB.instance Definition _ := + @isUniform.Build gauged gauge gauge_filter gauge_refl gauge_inv gauge_split. -Lemma gauge_countable_uniformity : countable_uniformity gauge_uniformType. +Lemma gauge_countable_uniformity : countable_uniformity gauged. Proof. exists [set iter n split_sym (E `&` E^-1) | n in [set: nat]]. split; [exact: card_image_le | by move=> W [n] _ <-; exists n|]. by move=> D [n _ ?]; exists (iter n split_sym (E `&` E^-1)). Qed. -Definition gauge_pseudoMetric_mixin {R : realType} := - @countable_uniform_pseudoMetricType_mixin R _ gauge_countable_uniformity. +Definition type := countable_uniform.type gauge_countable_uniformity. -Definition gauge_pseudoMetricType {R : realType} := - PseudoMetricType gauge_uniformType (@gauge_pseudoMetric_mixin R). +#[export] HB.instance Definition _ := Uniform.on type. +#[export] HB.instance Definition _ {R : realType} : PseudoMetric R _ := + PseudoMetric.on type. End entourage_gauge. +End gauge. +Module Exports. HB.reexport. End Exports. +End gauge. +Export gauge.Exports. Lemma uniform_pseudometric_sup {R : realType} {T : uniformType} : @entourage T = @sup_ent T {E : set (T * T) | @entourage T E} - (fun E => Uniform.class (@gauge_pseudoMetricType T (projT1 E) (projT2 E) R)). + (fun E => Uniform.class (@gauge.type T (projT1 E) (projT2 E))). Proof. rewrite eqEsubset; split => [E entE|E]. exists E => //=. pose pe : {classic {E0 : set (T * T) | _}} * _ := (exist _ E entE, E). - have entPE : `[< @entourage (gauge_uniformType entE) E >]. + have entPE : `[< @entourage (gauge.type entE) E >]. by apply/asboolP; exists 0%N => // ? []. exists (fset1 (exist _ pe entPE)) => //=; first by move=> ?; rewrite in_setE. by rewrite set_fset1 bigcap_set1. case=> W /= [/= J] _ <- /filterS; apply; apply: filter_bigI => -[] [] [] /= D. move=> entD G /[dup] /asboolP [n _ + _ _] => /filterS; apply. -exact: iter_split_ent. +exact: gauge.iter_split_ent. Qed. -End gauges. Section ArzelaAscoli. Context {X : topologicalType}. Context {Y : uniformType}. @@ -8323,7 +7750,7 @@ exact: hausdorff_product. Qed. Lemma uniform_pointwise_compact (W : set (X -> Y)) : - compact (W : set (@fct_UniformFamily X Y compact)) -> + compact (W : set (@uniform_fun_family X Y compact)) -> compact (W : set {ptws X -> Y}). Proof. rewrite [x in x _ -> _]compact_ultra [x in _ -> x _]compact_ultra. @@ -8367,7 +7794,7 @@ Unshelve. all: by end_near. Qed. Definition small_ent_sub := @small_set_sub _ (@entourage Y). -Lemma pointwise_compact_cvg (F : set (set (X -> Y))) f : +Lemma pointwise_compact_cvg (F : set_system {ptws X -> Y}) (f : {ptws X -> Y}) : ProperFilter F -> (\forall W \near powerset_filter_from F, equicontinuous W id) -> {ptws, F --> f} <-> {family compact, F --> f}. @@ -8509,7 +7936,7 @@ Qed. Section currying. Local Notation "U '~>' V" := - ({compact-open, [topologicalType of U] -> [topologicalType of V]}) + ({compact-open, [the topologicalType of U] -> [the topologicalType of V]}) (at level 99, right associativity). Section cartesian_closed. @@ -8533,7 +7960,7 @@ Context {U V W : topologicalType}. So the category of locally compact regular spaces is cartesian closed. *) -Lemma continuous_curry (f : U * V ~> W) : +Lemma continuous_curry (f : (U * V)%type ~> W) : continuous f -> continuous (curry f : U ~> V ~> W) /\ forall u, continuous (curry f u). Proof. @@ -8550,7 +7977,7 @@ Unshelve. all: by end_near. Qed. Lemma continuous_uncurry_regular (f : U ~> V ~> W) : locally_compact [set: V] -> @regular_space V -> continuous f -> - (forall u, continuous (f u)) -> continuous (uncurry f : U * V ~> W). + (forall u, continuous (f u)) -> continuous (uncurry f : (U * V)%type ~> W). Proof. move=> lcV reg cf cfp /= [u v] D; rewrite /= nbhsE => -[O [oO Ofuv]] /filterS. apply; have [B] := @lcV v I; rewrite withinET => Bv [cptB clB]. @@ -8569,15 +7996,15 @@ Qed. Lemma continuous_uncurry (f : U ~> V ~> W) : locally_compact [set: V] -> hausdorff_space V -> continuous f -> (forall u, continuous (f u)) -> - continuous ((uncurry : (U ~> V ~> W) -> (U * V ~> W)) f). + continuous ((uncurry : (U ~> V ~> W) -> ((U * V)%type ~> W)) f). Proof. move=> lcV hsdf ctsf cf; apply: continuous_uncurry_regular => //. move=> v; have [B] := @lcV v I; rewrite withinET => Bv [cptB clB]. by move=> z; exact: (@compact_regular V hsdf v B). Qed. -Lemma curry_continuous (f : U * V ~> W) : continuous f -> @regular_space U -> - {for f, continuous (curry : (U * V ~> W) -> (U ~> V ~> W))}. +Lemma curry_continuous (f : (U * V)%type ~> W) : continuous f -> @regular_space U -> + {for f, continuous (curry : ((U * V)%type ~> W) -> (U ~> V ~> W))}. Proof. move=> ctsf regU; apply/compact_open_cvgP. by apply: fmap_filter; exact: nbhs_filter. @@ -8615,7 +8042,7 @@ Unshelve. all: by end_near. Qed. Lemma uncurry_continuous (f : U ~> V ~> W) : locally_compact [set: V] -> @regular_space V -> @regular_space U -> continuous f -> (forall u, continuous (f u)) -> - {for f, continuous (uncurry : (U ~> V ~> W) -> (U * V ~> W))}. + {for f, continuous (uncurry : (U ~> V ~> W) -> ((U * V)%type ~> W))}. Proof. move=> lcV regV regU ctsf ctsfp; apply/compact_open_cvgP. by apply: fmap_filter; exact:nbhs_filter. diff --git a/theories/trigo.v b/theories/trigo.v index e540c5733..709eabf1f 100644 --- a/theories/trigo.v +++ b/theories/trigo.v @@ -72,8 +72,8 @@ Qed. (* /NB: backport to mathcomp in progress *) Lemma cvg_series_cvg_series_group (R : realFieldType) (f : R ^nat) k : - cvg (series f) -> (0 < k)%N -> - [series \sum_(n * k <= i < n.+1 * k) f i]_n --> lim (series f). + cvg (series f @ \oo) -> (0 < k)%N -> + [series \sum_(n * k <= i < n.+1 * k) f i]_n @ \oo --> lim (series f @ \oo). Proof. move=> /cvg_ballP cf k0; apply/cvg_ballP => _/posnumP[e]. have := !! cf _ (gt0 e) => -[n _ nl]; near=> m. @@ -83,9 +83,10 @@ have /nl : (n <= m * k)%N. by rewrite /ball /= distrC. Unshelve. all: by end_near. Qed. -Lemma lt_sum_lim_series (R : realFieldType) (f : R ^nat) n : cvg (series f) -> +Lemma lt_sum_lim_series (R : realFieldType) (f : R ^nat) n : + cvg (series f @ \oo) -> (forall d, 0 < f (n + d.*2)%N + f (n + d.*2.+1)%N) -> - \sum_(0 <= i < n) f i < lim (series f). + \sum_(0 <= i < n) f i < lim (series f @ \oo). Proof. move=> /cvg_ballP cf fn. have fn0 : 0 < f n + f n.+1 by have := fn 0%N; rewrite double0 addn0 addn1. @@ -93,14 +94,14 @@ rewrite ltNge; apply: contraPN cf => ffn /(_ _ fn0). have nf_ub N : \sum_(0 <= i < n.+2) f i <= \sum_(0 <= i < N.+1.*2 + n) f i. elim: N => // N /le_trans ->//; rewrite -(addn1 (N.+1)) doubleD addnAC. rewrite [in leRHS]/index_iota subn0 iotaD big_cat. - rewrite -[in X in _ <= X + _](subn0 (N.+1.*2 + n)%N) ler_addl /= add0n. + rewrite -[in X in _ <= X + _](subn0 (N.+1.*2 + n)%N) lerDl /= add0n. by rewrite 2!big_cons big_nil addr0 -(addnC n) ltW// -addnS fn. -case=> N _ Nfn; have /Nfn/ltr_distlC_addr : (N.+1.*2 + n >= N)%N. +case=> N _ Nfn; have /Nfn/ltr_distlCDr : (N.+1.*2 + n >= N)%N. by rewrite doubleS -addn2 -addnn -2!addnA leq_addr. rewrite addrA => ffnfn. -have : lim (series f) + f n + f n.+1 <= \sum_(0 <= i < N.+1.*2 + n) f i. +have : lim (series f @ \oo) + f n + f n.+1 <= \sum_(0 <= i < N.+1.*2 + n) f i. apply: (le_trans _ (nf_ub N)). - by do 2 rewrite big_nat_recr //=; by rewrite -2!addrA ler_add2r. + by do 2 rewrite big_nat_recr //=; by rewrite -2!addrA lerD2r. by move/(lt_le_trans ffnfn); rewrite ltxx. Qed. @@ -145,7 +146,7 @@ Proof. by apply/funext => i; rewrite /sin_coeff /= -!mulrA [_ / _]mulrC. Qed. Lemma sin_coeff_even n x : sin_coeff x n.*2 = 0. Proof. by rewrite /sin_coeff /= odd_double /= !mul0r. Qed. -Lemma is_cvg_series_sin_coeff x : cvg (series (sin_coeff x)). +Lemma is_cvg_series_sin_coeff x : cvg (series (sin_coeff x) @ \oo). Proof. apply: normed_cvg. apply: series_le_cvg; last exact: (@is_cvg_series_exp_coeff _ `|x|). @@ -156,10 +157,10 @@ apply: series_le_cvg; last exact: (@is_cvg_series_exp_coeff _ `|x|). by case: odd; [rewrite mul1r| rewrite !mul0r]. Qed. -Definition sin x : R := lim (series (sin_coeff x)). +Definition sin x : R := lim (series (sin_coeff x) @ \oo). Lemma sinE : sin = fun x => - lim (pseries (fun n => (odd n)%:R * (-1) ^+ n.-1./2 * (n`!%:R)^-1) x). + lim (pseries (fun n => (odd n)%:R * (-1) ^+ n.-1./2 * (n`!%:R)^-1) x @ \oo). Proof. by apply/funext => x; rewrite /pseries -sin_coeffE. Qed. Definition sin_coeff' x (n : nat) := (-1)^n * x ^+ n.*2.+1 / n.*2.+1`!%:R. @@ -169,12 +170,12 @@ Proof. by rewrite /sin_coeff' /sin_coeff /= odd_double mul1r -2!mulrA doubleK. Qed. -Lemma cvg_sin_coeff' x : series (sin_coeff' x) --> sin x. +Lemma cvg_sin_coeff' x : series (sin_coeff' x) @ \oo --> sin x. Proof. have /(@cvg_series_cvg_series_group _ _ 2) := @is_cvg_series_sin_coeff x. move=> /(_ isT); apply: cvg_trans. -rewrite [X in _ --> series X](_ : _ = (fun n => sin_coeff x n.*2.+1)). - rewrite [X in series X --> _](_ : _ = (fun n => sin_coeff x n.*2.+1)) //. +rewrite [X in _ --> series X @ \oo](_ : _ = (fun n => sin_coeff x n.*2.+1)). + rewrite [X in series X @ \oo --> _](_ : _ = (fun n => sin_coeff x n.*2.+1)) //. by rewrite funeqE => n; exact: sin_coeff'E. rewrite funeqE=> n; rewrite /= 2!muln2 big_nat_recl //= sin_coeff_even add0r. by rewrite big_nat_recl // big_geq // addr0. @@ -228,7 +229,7 @@ Proof. by apply/funext => i; rewrite /cos_coeff /= -!mulrA [_ / _]mulrC. Qed. -Lemma is_cvg_series_cos_coeff x : cvg (series (cos_coeff x)). +Lemma is_cvg_series_cos_coeff x : cvg (series (cos_coeff x) @ \oo). Proof. apply: normed_cvg. apply: series_le_cvg; last exact: (@is_cvg_series_exp_coeff _ `|x|). @@ -239,12 +240,12 @@ apply: series_le_cvg; last exact: (@is_cvg_series_exp_coeff _ `|x|). by case: odd; [rewrite !mul0r | rewrite mul1r]. Qed. -Definition cos x : R := lim (series (cos_coeff x)). +Definition cos x : R := lim (series (cos_coeff x) @ \oo). Lemma cosE : cos = fun x => lim (series (fun n => (fun n => (~~(odd n))%:R * (-1)^+ n./2 * (n`!%:R)^-1) n - * x ^+ n)). + * x ^+ n) @ \oo). Proof. by apply/funext => x; rewrite -cos_coeffE. Qed. Definition cos_coeff' x (n : nat) := (-1)^n * x ^+ n.*2 / n.*2`!%:R. @@ -255,14 +256,14 @@ rewrite /cos_coeff' /cos_coeff /= odd_double /= mul1r -2!mulrA; congr (_ * _). by rewrite (half_bit_double n false). Qed. -Lemma cvg_cos_coeff' x : series (cos_coeff' x) --> cos x. +Lemma cvg_cos_coeff' x : series (cos_coeff' x) @ \oo --> cos x. Proof. have /(@cvg_series_cvg_series_group _ _ 2) := @is_cvg_series_cos_coeff x. move=> /(_ isT); apply: cvg_trans. -rewrite [X in _ --> series X](_ : _ = (fun n => cos_coeff x n.*2)); last first. +rewrite [X in _ --> series X @ \oo](_ : _ = (fun n => cos_coeff x n.*2)); last first. rewrite funeqE=> n; rewrite /= 2!muln2 big_nat_recr //= cos_coeff_odd addr0. by rewrite big_nat_recl//= /index_iota subnn big_nil addr0. -rewrite [X in series X --> _](_ : _ = (fun n => cos_coeff x n.*2)) //. +rewrite [X in series X @ \oo --> _](_ : _ = (fun n => cos_coeff x n.*2)) //. by rewrite funeqE => n; exact: cos_coeff'E. Qed. @@ -360,11 +361,11 @@ Qed. Lemma cos_max x : `| cos x | <= 1. Proof. rewrite -(expr_le1 (_ : 0 < 2)%nat) // -normrX ger0_norm ?exprn_even_ge0 //. -by rewrite -(cos2Dsin2 x) ler_addl ?sqr_ge0. +by rewrite -(cos2Dsin2 x) lerDl ?sqr_ge0. Qed. Lemma cos_geN1 x : -1 <= cos x. -Proof. by rewrite ler_oppl; have /ler_normlP[] := cos_max x. Qed. +Proof. by rewrite lerNl; have /ler_normlP[] := cos_max x. Qed. Lemma cos_le1 x : cos x <= 1. Proof. by have /ler_normlP[] := cos_max x. Qed. @@ -372,11 +373,11 @@ Proof. by have /ler_normlP[] := cos_max x. Qed. Lemma sin_max x : `| sin x | <= 1. Proof. rewrite -(expr_le1 (_ : 0 < 2)%nat) // -normrX ger0_norm ?exprn_even_ge0 //. -by rewrite -(cos2Dsin2 x) ler_addr ?sqr_ge0. +by rewrite -(cos2Dsin2 x) lerDr ?sqr_ge0. Qed. Lemma sin_geN1 x : -1 <= sin x. -Proof. by rewrite ler_oppl; have /ler_normlP[] := sin_max x. Qed. +Proof. by rewrite lerNl; have /ler_normlP[] := sin_max x. Qed. Lemma sin_le1 x : sin x <= 1. Proof. by have /ler_normlP[] := sin_max x. Qed. @@ -489,7 +490,7 @@ Implicit Types (x y : R) (n k : nat). Definition pi : R := get [set x | 0 <= x <= 2 /\ cos x = 0] *+ 2. Lemma pihalfE : pi / 2 = get [set x | 0 <= x <= 2 /\ cos x = 0]. -Proof. by rewrite /pi -(mulr_natr (get _)) -mulrA divff ?mulr1. Qed. +Proof. by rewrite /pi -[_ *+ 2]mulr_natr -mulrA divff ?mulr1. Qed. Lemma cos2_lt0 : cos 2 < 0 :> R. Proof. @@ -509,10 +510,10 @@ rewrite (_ : 4 = 2 * 2)%N // -(exprnP _ (2 * 2)) (exprM (-1)) sqrr_sign. rewrite mul1r [(-1) ^ 3](_ : _ = -1) ?mulN1r ?mulNr ?opprK; last first. by rewrite -exprnP 2!exprS expr1 mulrN1 opprK mulr1. rewrite subr_gt0. -rewrite addnS doubleS -[X in 2 ^+ X]addn2 exprD -mulrA ltr_pmul2l//. +rewrite addnS doubleS -[X in 2 ^+ X]addn2 exprD -mulrA ltr_pM2l//. rewrite factS factS 2!natrM mulrA invfM !mulrA. -rewrite ltr_pdivr_mulr ?ltr0n ?fact_gt0// mulVf ?pnatr_eq0 ?gtn_eqF ?fact_gt0//. -rewrite ltr_pdivr_mulr ?mul1r //. +rewrite ltr_pdivrMr ?ltr0n ?fact_gt0// mulVf ?pnatr_eq0 ?gtn_eqF ?fact_gt0//. +rewrite ltr_pdivrMr ?mul1r //. by rewrite expr2 -!natrM ltr_nat !mulSn !add2n mul0n !addnS. Qed. @@ -523,7 +524,7 @@ have sinx := @cvg_sin_coeff' _ x. rewrite -(cvg_lim (@Rhausdorff R) sinx). rewrite [ltLHS](_ : 0 = \sum_(0 <= i < 0) sin_coeff' x i :> R); last first. by rewrite big_nil. -rewrite lt_sum_lim_series //; first by move/cvgP in sinx. +apply: lt_sum_lim_series; first by move/cvgP in sinx. move=> d. rewrite /sin_coeff' 2!exprzD_nat (exprSz _ d.*2) -[in (-1) ^ d.*2](muln2 d). rewrite -(exprnP _ (d * 2)) (exprM (-1)) sqrr_sign 2!mulr1 -exprSzr. @@ -537,9 +538,9 @@ rewrite -[X in _ < X - _]mul1r !mulrA -mulrBl divr_gt0 //; last first. rewrite subr_gt0. set v := _ ^_ _; rewrite -[ltRHS](divff (_ : v%:R != 0)); last first. by rewrite lt0r_neq0 // (ltr_nat _ 0) ffact_gt0 leq_addl. -rewrite ltr_pmul2r; last by rewrite invr_gt0 (ltr_nat _ 0) ffact_gt0 leq_addl. +rewrite ltr_pM2r; last by rewrite invr_gt0 (ltr_nat _ 0) ffact_gt0 leq_addl. rewrite {}/v !addnS addn0 !ffactnS ffactn0 muln1 /= natrM. -by rewrite (ltr_pmul (ltW _ ) (ltW _)) // (lt_le_trans x_lt2) // ler_nat. +by rewrite (ltr_pM (ltW _ ) (ltW _)) // (lt_le_trans x_lt2) // ler_nat. Qed. Lemma cos1_gt0 : cos 1 > 0 :> R. @@ -548,12 +549,12 @@ have h := @cvg_cos_coeff' R 1; rewrite -(cvg_lim (@Rhausdorff R) h). apply: (@lt_trans _ _ (\sum_(0 <= i < 2) cos_coeff' 1 i)). rewrite big_nat_recr//= big_nat_recr//= big_nil add0r. rewrite /cos_coeff' expr0z expr1n fact0 !mul1r expr1n expr1z. - by rewrite !mulNr subr_gt0 mul1r div1r ltf_pinv ?posrE ?ltr0n// ltr_nat. -rewrite lt_sum_lim_series //; [by move/cvgP in h|move=> d]. + by rewrite !mulNr subr_gt0 mul1r div1r ltf_pV2 ?posrE ?ltr0n// ltr_nat. +apply: lt_sum_lim_series; [by move/cvgP in h|move=> d]. rewrite /cos_coeff' !(expr1n,mulr1). rewrite -muln2 -mulSn muln2 -exprnP -signr_odd odd_double expr0. rewrite -exprnP -signr_odd oddD/= muln2 odd_double/= expr1 add2n. -rewrite mulNr subr_gt0 2!div1r ltf_pinv ?posrE ?ltr0n ?fact_gt0//. +rewrite mulNr subr_gt0 2!div1r ltf_pV2 ?posrE ?ltr0n ?fact_gt0//. by rewrite ltr_nat ltn_pfact//ltn_double doubleS. Qed. @@ -619,7 +620,7 @@ Lemma pihalf_lt2 : pi / 2 < 2. Proof. by have /andP[] := pihalf_12. Qed. Lemma pi_ge2 : 2 <= pi. -Proof. by have := pihalf_ge1; rewrite ler_pdivl_mulr// mul1r. Qed. +Proof. by have := pihalf_ge1; rewrite ler_pdivlMr// mul1r. Qed. Lemma pi_gt0 : 0 < pi. Proof. by rewrite (lt_le_trans _ pi_ge2). Qed. @@ -635,7 +636,7 @@ Lemma cos_gt0_pihalf x : -(pi / 2) < x < pi / 2 -> 0 < cos x. Proof. wlog : x / 0 <= x => [Hw|x_ge0]. case: (leP 0 x) => [/Hw//| x_lt_0]. - rewrite -{-1}[x]opprK ltr_oppl andbC [-- _ < _]ltr_oppl cosN. + rewrite -{-1}[x]opprK ltrNl andbC [-- _ < _]ltrNl cosN. by apply: Hw => //; rewrite oppr_cp0 ltW. move=> /andP[x_gt0 xLpi2]; case: (ler0P (cos x)) => // cx_le0. have /IVT[]// : minr (cos 0) (cos x) <= 0 <= maxr (cos 0) (cos x). @@ -677,8 +678,7 @@ Qed. Lemma sinpi : sin pi = 0. Proof. -have := sinD (pi / 2) (pi / 2); rewrite cos_pihalf mulr0 mul0r. -by rewrite -mulrDl -mulr2n -mulr_natr -mulrA divff// mulr1 addr0. +by have := sinD (pi / 2) (pi / 2); rewrite cos_pihalf mulr0 mul0r -splitr addr0. Qed. Lemma cos2pi : cos (pi *+ 2) = 1. @@ -714,13 +714,13 @@ Proof. by rewrite sinB cos_pihalf mulr0 add0r sin_pihalf mulr1. Qed. Lemma sin_ge0_pi x : 0 <= x <= pi -> 0 <= sin x. Proof. move=> xI; rewrite -cosBpihalf cos_ge0_pihalf //. -by rewrite ler_subr_addl subrr ler_sub_addr -mulr2n -[_ *+ 2]mulr_natr divfK. +by rewrite lerBrDl subrr lerBDr -mulr2n -[_ *+ 2]mulr_natr divfK. Qed. Lemma sin_gt0_pi x : 0 < x < pi -> 0 < sin x. Proof. move=> xI; rewrite -cosBpihalf cos_gt0_pihalf //. -by rewrite ltr_subr_addl subrr ltr_sub_addr -mulr2n -[_ *+ 2]mulr_natr divfK. +by rewrite ltrBrDl subrr ltrBDr -mulr2n -[_ *+ 2]mulr_natr divfK. Qed. Lemma ltr_cos : {in `[0, pi] &, {mono cos : x y /~ y < x}}. @@ -764,10 +764,10 @@ Qed. Lemma ltr_sin : {in `[ (- (pi/2)), pi/2] &, {mono sin : x y / x < y}}. Proof. -move=> x y /itvP xpi /itvP ypi; rewrite -[sin x]opprK ltr_oppl. -rewrite -!cosDpihalf -[x < y](ltr_add2r (pi /2)) ltr_cos// !in_itv/=. -- by rewrite -ler_subl_addr sub0r xpi/= [leRHS]splitr ler_add2r xpi. -- by rewrite -ler_subl_addr sub0r ypi/= [leRHS]splitr ler_add2r ypi. +move=> x y /itvP xpi /itvP ypi; rewrite -[sin x]opprK ltrNl. +rewrite -!cosDpihalf -[x < y](ltrD2r (pi /2)) ltr_cos// !in_itv/=. +- by rewrite -lerBlDr sub0r xpi/= [leRHS]splitr lerD2r xpi. +- by rewrite -lerBlDr sub0r ypi/= [leRHS]splitr lerD2r ypi. Qed. Lemma cos_inj : {in `[0,pi] &, injective (@cos R)}. @@ -781,8 +781,8 @@ Lemma sin_inj : {in `[(- (pi/2)), (pi/2)] &, injective sin}. Proof. move=> x y /itvP xpi /itvP ypi sinE; have : - sin x = - sin y by rewrite sinE. rewrite -!cosDpihalf => /cos_inj h; apply/(addIr (pi/2))/h; rewrite !in_itv/=. -- by rewrite -ler_subl_addr sub0r xpi/= [leRHS]splitr ler_add2r xpi. -- by rewrite -ler_subl_addr sub0r ypi/= [leRHS]splitr ler_add2r ypi. +- by rewrite -lerBlDr sub0r xpi/= [leRHS]splitr lerD2r xpi. +- by rewrite -lerBlDr sub0r ypi/= [leRHS]splitr lerD2r ypi. Qed. End Pi. @@ -841,7 +841,7 @@ Lemma tan_piquarter : tan (pi / 4%:R) = 1. Proof. rewrite /tan -cosBpihalf (splitr (pi / 2)) opprD addrA -mulrA -invfM -natrM. rewrite subrr sub0r cosN divff// gt_eqF// cos_gt0_pihalf//. -rewrite ltr_pmul2l ?pi_gt0// ltf_pinv ?qualifE// ltr_nat andbT. +rewrite ltr_pM2l ?pi_gt0// ltf_pV2 ?qualifE//= ltr_nat andbT. by rewrite (@lt_trans _ _ 0)// ?oppr_lt0 ?divr_gt0 ?pi_gt0. Qed. @@ -910,7 +910,7 @@ Proof. move=> xB; rewrite /acos; case: xgetP => //= He. pose f y := cos y - x. have /(IVT (@pi_ge0 _))[] // : minr (f 0) (f pi) <= 0 <= maxr (f 0) (f pi). - rewrite /f cos0 cospi /minr /maxr ltr_add2r -subr_lt0 opprK (_ : 1 + 1 = 2)//. + rewrite /f cos0 cospi /minr /maxr ltrD2r -subr_lt0 opprK (_ : 1 + 1 = 2)//. by rewrite ltrn0 subr_le0 subr_ge0. - move=> y y0pi. by apply: continuousB; apply/continuous_in_subspaceT => ? ?; @@ -961,14 +961,14 @@ Lemma acos0 : acos (0 : R) = pi / 2%:R. Proof. have := @cosK (pi / 2%:R). rewrite cos_pihalf => -> //; rewrite in_itv//= divr_ge0 ?ler0n ?pi_ge0//=. -by rewrite ler_pdivr_mulr ?ltr0n// ler_pemulr ?pi_ge0// ler1n. +by rewrite ler_pdivrMr ?ltr0n// ler_peMr ?pi_ge0// ler1n. Qed. Lemma acosN a : -1 <= a <= 1 -> acos (- a) = pi - acos a. Proof. -move=> a1; have ? : -1 <= - a <= 1 by rewrite ler_oppl opprK ler_oppl andbC. +move=> a1; have ? : -1 <= - a <= 1 by rewrite lerNl opprK lerNl andbC. apply: cos_inj; first by rewrite in_itv/= acos_ge0//= acos_lepi. -- by rewrite in_itv/= subr_ge0 acos_lepi//= ler_subl_addl ler_addr acos_ge0. +- by rewrite in_itv/= subr_ge0 acos_lepi//= lerBlDl lerDr acos_ge0. - by rewrite addrC cosDpi cosN !acosK. Qed. @@ -977,7 +977,7 @@ Proof. by rewrite acosN ?acos1 ?subr0 ?lexx// -subr_ge0 opprK addr_ge0. Qed. Lemma cosKN a : - pi <= a <= 0 -> acos (cos a) = - a. Proof. -by move=> pia0; rewrite -(cosN a) cosK// in_itv/= ler_oppr oppr0 ler_oppl andbC. +by move=> pia0; rewrite -(cosN a) cosK// in_itv/= lerNr oppr0 lerNl andbC. Qed. Lemma sin_acos x : -1 <= x <= 1 -> sin (acos x) = Num.sqrt (1 - x^+2). @@ -1015,7 +1015,7 @@ apply: (@is_derive_inverse R cos). by near: z. - by near=> z; apply: continuous_cos. - rewrite oppr_eq0 sin_acos ?ltW // sqrtr_eq0 // -ltNge subr_gt0. - rewrite -real_normK ?qualifE; last by case: ltrgt0P. + rewrite -real_normK ?qualifE/=; last by case: ltrgt0P. by rewrite exprn_cp1 // ltr_norml x_gtN1. Unshelve. all: by end_near. Qed. @@ -1036,7 +1036,7 @@ move=> xB; rewrite /asin; case: xgetP => //= He. pose f y := sin y - x. have /IVT[] // : minr (f (-(pi/2))) (f (pi/2)) <= 0 <= maxr (f (-(pi/2))) (f (pi/2)). - rewrite /f sinN sin_pihalf /minr /maxr ltr_add2r -subr_gt0 opprK. + rewrite /f sinN sin_pihalf /minr /maxr ltrD2r -subr_gt0 opprK. by rewrite (_ : 1 + 1 = 2)// ltr0n/= subr_le0 subr_ge0. - by rewrite -subr_ge0 opprK -splitr pi_ge0. - by move=> *; apply: continuousB; apply/continuous_in_subspaceT => ? ?; @@ -1114,7 +1114,7 @@ apply: (@is_derive_inverse R sin). by near: z. - by near=> z; exact: continuous_sin. - rewrite cos_asin ?ltW // sqrtr_eq0 // -ltNge subr_gt0. - rewrite -real_normK ?qualifE; last by case: ltrgt0P. + rewrite -real_normK ?qualifE/=; last by case: ltrgt0P. by rewrite exprn_cp1 // ltr_norml x_gtN1. Unshelve. all: by end_near. Qed. @@ -1135,11 +1135,11 @@ Proof. rewrite /atan; case: xgetP => //= He. pose x1 := Num.sqrt (1 + x^+ 2) ^-1. have ox2_gt0 : 0 < 1 + x^2. - by apply: lt_le_trans (_ : 1 <= _); rewrite ?ler_addl ?sqr_ge0. + by apply: lt_le_trans (_ : 1 <= _); rewrite ?lerDl ?sqr_ge0. have ox2_ge0 : 0 <= 1 + x^2 by rewrite ltW. have x1B : -1 <= x1 <= 1. rewrite -ler_norml /x1 ger0_norm ?sqrtr_ge0 // -[leRHS]sqrtr1. - by rewrite ler_psqrt ?qualifE ?invr_gte0 //= invf_cp1 // ler_addl sqr_ge0. + by rewrite ler_psqrt ?qualifE/= ?invr_gte0 //= invf_cp1 // lerDl sqr_ge0. case: (He (Num.sg x * acos x1)); split; last first. case: (x =P 0) => [->|/eqP xD0]; first by rewrite /tan sgr0 mul0r sin0 mul0r. rewrite /tan sin_sg cos_sg // acosK ?sin_acos //. @@ -1156,7 +1156,7 @@ case: (x =P 0) => [->|/eqP xD0]; first by rewrite sgr0 normr0 mul0r. rewrite normr_sg xD0 mul1r ltr_norml. rewrite (@lt_le_trans _ _ 0) ?acos_ge0 ?oppr_cp0 //=. rewrite -ltr_cos ?in_itv/= ?acos_ge0/= ?acos_lepi//; last first. - by rewrite divr_ge0 ?pi_ge0//= ler_pdivr_mulr// ler_pmulr ?pi_gt0// ler1n. + by rewrite divr_ge0 ?pi_ge0//= ler_pdivrMr// ler_pMr ?pi_gt0// ler1n. by rewrite cos_pihalf acosK // ?sqrtr_gt0 ?invr_gt0. Qed. @@ -1184,14 +1184,14 @@ apply: tan_inj; first 2 last. rewrite in_itv/= -mulNr (lt_trans _ (_ : 0 < _ )) /=; last 2 first. by rewrite mulNr oppr_cp0 divr_gt0 // pi_gt0. by rewrite divr_gt0 ?pi_gt0 // ltr0n. -rewrite ltr_pdivr_mulr// -mulrA ltr_pmulr// ?pi_gt0//. +rewrite ltr_pdivrMr// -mulrA ltr_pMr// ?pi_gt0//. by rewrite (natrM _ 2 2) mulrA mulVf// mul1r ltr1n. Qed. Lemma atanN x : atan (- x) = - atan x. Proof. apply: tan_inj; first by rewrite in_itv/= atan_ltpi2 atan_gtNpi2. -- by rewrite in_itv/= ltr_oppl opprK ltr_oppl andbC atan_ltpi2 atan_gtNpi2. +- by rewrite in_itv/= ltrNl opprK ltrNl andbC atan_ltpi2 atan_gtNpi2. - by rewrite tanN !atanK. Qed. @@ -1236,7 +1236,7 @@ apply: (@is_derive_inverse R tan). - by near=> z; apply: tanK; near: z. - by near=> z; apply/continuous_tan/lt0r_neq0/cos_gt0_pihalf; near: z. - by rewrite -[X in 1 + X ^+ 2]atanK -cos2_tan2 //; exact: is_derive_tan. -by apply/lt0r_neq0/(@lt_le_trans _ _ 1) => //; rewrite ler_addl sqr_ge0. +by apply/lt0r_neq0/(@lt_le_trans _ _ 1) => //; rewrite lerDl sqr_ge0. Unshelve. all: by end_near. Qed. End Atan.