-
Notifications
You must be signed in to change notification settings - Fork 257
Proofs of some linearity axioms. #1767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
27746d8
Temporary check-in.
capn-freako 65989fd
Last linearity axiom proved.
capn-freako c057439
Merge branch 'master' of https://github.com/agda/agda-stdlib
capn-freako 2d7abea
Final edits before initial pull request.
capn-freako b6c7519
Second attempt at PR1767.
capn-freako 7c205f9
Removed some unneeded `public`s.
capn-freako ea73683
Shifted to proof-local reasoning module openning, as per Jacques.
capn-freako c9c8798
Eliminated unneccesary `x`, as per Jacques.
capn-freako c18c68a
Reverted to `f` from semantic brackets, as per Jacques.
capn-freako caabb3a
Switched to `A.<op>` notation, as per Jacques.
capn-freako 3c11956
Changes requested by Matthew Daggitt.
capn-freako 88e5c2a
Temporary check-in only!
capn-freako d2da8f0
Changes, as per Matthew Daggitt, re: PR #1767
capn-freako c5de4d1
Responding to Jacques feedback.
capn-freako 2c17a8d
Merge branch 'master' of https://github.com/agda/agda-stdlib
capn-freako b790ffb
Clean-up after merging in upstream master.
capn-freako 8b0a487
Responding to Matthew`s requests.
capn-freako aec2203
Responding to additional requests from Matthew.
capn-freako b6da4e9
Responding to Matthew`s final requests.
capn-freako be44f32
Tweak to CHANGELOG
MatthewDaggitt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Properties of linear maps. | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --without-K --safe #-} | ||
|
||
import Algebra.Module.Properties as ModuleProperties | ||
import Algebra.Module.Morphism.Structures as MorphismStructures | ||
|
||
open import Algebra using (CommutativeRing) | ||
open import Algebra.Module using (Module) | ||
open import Level using (Level) | ||
|
||
module Algebra.Module.Morphism.ModuleHomomorphism | ||
{r ℓr m ℓm : Level} | ||
{ring : CommutativeRing r ℓr} | ||
(modA modB : Module ring m ℓm) | ||
(open Module modA using () renaming (Carrierᴹ to A)) | ||
(open Module modB using () renaming (Carrierᴹ to B)) | ||
{f : A → B} | ||
(open MorphismStructures.ModuleMorphisms modA modB) | ||
(isModuleHomomorphism : IsModuleHomomorphism f) | ||
where | ||
|
||
open import Axiom.DoubleNegationElimination | ||
open import Data.Product | ||
open import Relation.Binary.Reasoning.MultiSetoid | ||
open import Relation.Nullary using (¬_) | ||
open import Relation.Nullary.Negation using (contraposition) | ||
|
||
module A = Module modA | ||
module B = Module modB | ||
module PA = ModuleProperties modA | ||
module PB = ModuleProperties modB | ||
open CommutativeRing ring renaming (Carrier to S) | ||
|
||
open IsModuleHomomorphism isModuleHomomorphism | ||
|
||
-- Some of the lemmas below only hold for continously scalable, | ||
-- non-trivial functions, i.e., f x = f (s y) and f ≠ const 0. | ||
-- This is a handy abbreviation for that rather verbose term. | ||
NonTrivial : A → Set (r Level.⊔ m Level.⊔ ℓm) | ||
NonTrivial x = ∃₂ λ s y → (s A.*ₗ x A.≈ᴹ y) × (f y B.≉ᴹ B.0ᴹ) | ||
|
||
x≈0⇒fx≈0 : ∀ {x} → x A.≈ᴹ A.0ᴹ → f x B.≈ᴹ B.0ᴹ | ||
x≈0⇒fx≈0 {x} x≈0 = begin⟨ B.≈ᴹ-setoid ⟩ | ||
f x ≈⟨ ⟦⟧-cong x≈0 ⟩ | ||
f A.0ᴹ ≈⟨ 0ᴹ-homo ⟩ | ||
B.0ᴹ ∎ | ||
|
||
fx≉0⇒x≉0 : ∀ {x} → f x B.≉ᴹ B.0ᴹ → x A.≉ᴹ A.0ᴹ | ||
fx≉0⇒x≉0 = contraposition x≈0⇒fx≈0 | ||
|
||
-- Zero is a unique output of non-trivial (i.e. - ≉ `const 0`) linear map. | ||
x≉0⇒f[x]≉0 : ∀ {x} → NonTrivial x → x A.≉ᴹ A.0ᴹ → f x B.≉ᴹ B.0ᴹ | ||
x≉0⇒f[x]≉0 {x} (s , y , s·x≈y , fy≉0) x≉0 = | ||
PB.x*y≉0⇒y≉0 ( λ s·fx≈0 → fy≉0 ( begin⟨ B.≈ᴹ-setoid ⟩ | ||
f y ≈⟨ ⟦⟧-cong (A.≈ᴹ-sym s·x≈y) ⟩ | ||
f (s A.*ₗ x) ≈⟨ *ₗ-homo s x ⟩ | ||
s B.*ₗ f x ≈⟨ s·fx≈0 ⟩ | ||
B.0ᴹ ∎ ) | ||
) | ||
|
||
-- f is odd (i.e. - f (-x) ≈ - (f x)). | ||
fx+f[-x]≈0 : (x : A) → f x B.+ᴹ f (A.-ᴹ x) B.≈ᴹ B.0ᴹ | ||
fx+f[-x]≈0 x = begin⟨ B.≈ᴹ-setoid ⟩ | ||
f x B.+ᴹ f (A.-ᴹ x) ≈⟨ B.≈ᴹ-sym (+ᴹ-homo x (A.-ᴹ x)) ⟩ | ||
f (x A.+ᴹ (A.-ᴹ x)) ≈⟨ ⟦⟧-cong (A.-ᴹ‿inverseʳ x) ⟩ | ||
f A.0ᴹ ≈⟨ 0ᴹ-homo ⟩ | ||
B.0ᴹ ∎ | ||
|
||
f[-x]≈-fx : (x : A) → f (A.-ᴹ x) B.≈ᴹ B.-ᴹ f x | ||
f[-x]≈-fx x = B.uniqueʳ‿-ᴹ (f x) (f (A.-ᴹ x)) (fx+f[-x]≈0 x) | ||
|
||
-- A non-trivial linear function is injective. | ||
fx≈fy⇒fx-fy≈0 : ∀ {x y} → f x B.≈ᴹ f y → f x B.+ᴹ (B.-ᴹ f y) B.≈ᴹ B.0ᴹ | ||
fx≈fy⇒fx-fy≈0 {x} {y} fx≈fy = begin⟨ B.≈ᴹ-setoid ⟩ | ||
f x B.+ᴹ (B.-ᴹ f y) ≈⟨ B.+ᴹ-congˡ (B.-ᴹ‿cong (B.≈ᴹ-sym fx≈fy)) ⟩ | ||
f x B.+ᴹ (B.-ᴹ f x) ≈⟨ B.-ᴹ‿inverseʳ (f x) ⟩ | ||
B.0ᴹ ∎ | ||
|
||
fx≈fy⇒f[x-y]≈0 : ∀ {x y} → f x B.≈ᴹ f y → f (x A.+ᴹ (A.-ᴹ y)) B.≈ᴹ B.0ᴹ | ||
fx≈fy⇒f[x-y]≈0 {x} {y} fx≈fy = begin⟨ B.≈ᴹ-setoid ⟩ | ||
f (x A.+ᴹ (A.-ᴹ y)) ≈⟨ +ᴹ-homo x (A.-ᴹ y) ⟩ | ||
f x B.+ᴹ f (A.-ᴹ y) ≈⟨ B.+ᴹ-congˡ (f[-x]≈-fx y) ⟩ | ||
f x B.+ᴹ (B.-ᴹ f y) ≈⟨ fx≈fy⇒fx-fy≈0 fx≈fy ⟩ | ||
B.0ᴹ ∎ | ||
|
||
module _ {dne : DoubleNegationElimination _} where | ||
|
||
fx≈0⇒x≈0 : ∀ {x} → NonTrivial x → f x B.≈ᴹ B.0ᴹ → x A.≈ᴹ A.0ᴹ | ||
fx≈0⇒x≈0 {x} (s , y , s·x≈y , fy≉0) fx≈0 = | ||
dne ¬x≉0 | ||
where | ||
¬x≉0 : ¬ (x A.≉ᴹ A.0ᴹ) | ||
¬x≉0 = λ x≉0 → x≉0⇒f[x]≉0 (s , y , s·x≈y , fy≉0) x≉0 fx≈0 | ||
|
||
inj-lm : ∀ {x y} → | ||
(∃₂ λ s z → ((s A.*ₗ (x A.+ᴹ A.-ᴹ y) A.≈ᴹ z) × (f z B.≉ᴹ B.0ᴹ))) → | ||
f x B.≈ᴹ f y → x A.≈ᴹ y | ||
inj-lm {x} {y} (s , z , s·[x-y]≈z , fz≉0) fx≈fy = | ||
begin⟨ A.≈ᴹ-setoid ⟩ | ||
x ≈⟨ x≈--y ⟩ | ||
A.-ᴹ (A.-ᴹ y) ≈⟨ PA.-ᴹ-involutive y ⟩ | ||
y ∎ | ||
where | ||
x-y≈0 : x A.+ᴹ (A.-ᴹ y) A.≈ᴹ A.0ᴹ | ||
x-y≈0 = fx≈0⇒x≈0 (s , z , s·[x-y]≈z , fz≉0) (fx≈fy⇒f[x-y]≈0 fx≈fy) | ||
x≈--y : x A.≈ᴹ A.-ᴹ (A.-ᴹ y) | ||
x≈--y = A.uniqueʳ‿-ᴹ (A.-ᴹ y) x | ||
( begin⟨ A.≈ᴹ-setoid ⟩ | ||
A.-ᴹ y A.+ᴹ x ≈⟨ A.+ᴹ-comm (A.-ᴹ y) x ⟩ | ||
x A.+ᴹ A.-ᴹ y ≈⟨ x-y≈0 ⟩ | ||
A.0ᴹ ∎ | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Properties of modules. | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --without-K --safe #-} | ||
|
||
open import Algebra using (CommutativeRing; Involutive) | ||
open import Algebra.Module.Bundles using (Module) | ||
open import Level using (Level) | ||
|
||
module Algebra.Module.Properties | ||
{r ℓr m ℓm : Level} | ||
{ring : CommutativeRing r ℓr} | ||
(mod : Module ring m ℓm) | ||
where | ||
|
||
open Module mod | ||
open import Algebra.Module.Properties.Semimodule semimodule public | ||
open import Algebra.Properties.Group using (⁻¹-involutive) | ||
|
||
-ᴹ-involutive : Involutive _≈ᴹ_ -ᴹ_ | ||
-ᴹ-involutive = ⁻¹-involutive +ᴹ-group |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Properties of semimodules. | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --without-K --safe #-} | ||
|
||
open import Algebra using (CommutativeSemiring) | ||
open import Algebra.Module.Bundles using (Semimodule) | ||
open import Level using (Level) | ||
|
||
module Algebra.Module.Properties.Semimodule | ||
{r ℓr m ℓm : Level} | ||
{semiring : CommutativeSemiring r ℓr} | ||
(semimod : Semimodule semiring m ℓm) | ||
where | ||
|
||
open CommutativeSemiring semiring | ||
open Semimodule semimod | ||
open import Relation.Nullary.Negation using (contraposition) | ||
open import Relation.Binary.Reasoning.Setoid ≈ᴹ-setoid | ||
|
||
x≈0⇒x*y≈0 : ∀ {x y} → x ≈ 0# → x *ₗ y ≈ᴹ 0ᴹ | ||
x≈0⇒x*y≈0 {x} {y} x≈0 = begin | ||
x *ₗ y ≈⟨ *ₗ-congʳ x≈0 ⟩ | ||
0# *ₗ y ≈⟨ *ₗ-zeroˡ y ⟩ | ||
0ᴹ ∎ | ||
|
||
y≈0⇒x*y≈0 : ∀ {x y} → y ≈ᴹ 0ᴹ → x *ₗ y ≈ᴹ 0ᴹ | ||
y≈0⇒x*y≈0 {x} {y} y≈0 = begin | ||
x *ₗ y ≈⟨ *ₗ-congˡ y≈0 ⟩ | ||
x *ₗ 0ᴹ ≈⟨ *ₗ-zeroʳ x ⟩ | ||
0ᴹ ∎ | ||
|
||
x*y≉0⇒x≉0 : ∀ {x y} → x *ₗ y ≉ᴹ 0ᴹ → x ≉ 0# | ||
x*y≉0⇒x≉0 = contraposition x≈0⇒x*y≈0 | ||
|
||
x*y≉0⇒y≉0 : ∀ {x y} → x *ₗ y ≉ᴹ 0ᴹ → y ≉ᴹ 0ᴹ | ||
x*y≉0⇒y≉0 = contraposition y≈0⇒x*y≈0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.