-
Notifications
You must be signed in to change notification settings - Fork 250
Remove uses of Data.Nat.Solver
from a number of places
#2337
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
13 commits
Select commit
Hold shift + click to select a range
e79c190
tighten imports in some files, and make imports explicit in others. D…
JacquesCarette 2bba1e5
more tightening of imports
JacquesCarette c8cbf7f
and even more tightening of imports
JacquesCarette 50e0873
some explicit for precision
JacquesCarette b3093fc
Merge branch 'TightenImports' into TightenImports2
JacquesCarette 8d31638
new Nat Lemmas to use instead of Solve in Data.Integer.Properties
JacquesCarette 2b454b6
use direct proofs instead of solver for all Nat proofs in these files
JacquesCarette 1e5a534
two more uses of Data.Nat.Solver for rather simple proofs, now made d…
JacquesCarette 165bbb8
fix whitespace violations
JacquesCarette 1efc5c3
Merge branch 'master' into TightenImports2
JacquesCarette 63c4b40
remove some unneeded parens
JacquesCarette a3bb065
minor fixups based on review
JacquesCarette 61de9d3
Merge branch 'master' into TightenImports2
JacquesCarette 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
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,69 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Some extra lemmas about natural numbers only needed for | ||
-- Data.Integer.Properties (for distributivity) | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
module Data.Integer.Properties.NatLemmas where | ||
|
||
open import Data.Nat.Base using (ℕ; _+_; _*_; suc) | ||
open import Data.Nat.Properties | ||
using (*-distribʳ-+; *-assoc; +-assoc; +-comm; +-suc) | ||
open import Function.Base using (_∘_) | ||
open import Relation.Binary.PropositionalEquality | ||
using (_≡_; cong; cong₂; sym; module ≡-Reasoning) | ||
|
||
open ≡-Reasoning | ||
|
||
inner-assoc : ∀ m n o → o + (n + m * suc n) * suc o | ||
≡ o + n * suc o + m * suc (o + n * suc o) | ||
inner-assoc m n o = begin | ||
o + (n + m * suc n) * suc o ≡⟨ cong (o +_) (begin | ||
(n + m * suc n) * suc o ≡⟨ *-distribʳ-+ (suc o) n (m * suc n) ⟩ | ||
n * suc o + m * suc n * suc o ≡⟨ cong (n * suc o +_) (*-assoc m (suc n) (suc o)) ⟩ | ||
n * suc o + m * suc (o + n * suc o) ∎) ⟩ | ||
o + (n * suc o + m * suc (o + n * suc o)) ≡⟨ +-assoc o _ _ ⟨ | ||
o + n * suc o + m * suc (o + n * suc o) ∎ | ||
|
||
private | ||
assoc-comm : ∀ a b c d → a + b + c + d ≡ (a + c) + (b + d) | ||
assoc-comm a b c d = begin | ||
a + b + c + d ≡⟨ cong (_+ d) (+-assoc a b c) ⟩ | ||
a + (b + c) + d ≡⟨ cong (λ z → a + z + d) (+-comm b c) ⟩ | ||
a + (c + b) + d ≡⟨ cong (_+ d) (+-assoc a c b) ⟨ | ||
(a + c) + b + d ≡⟨ +-assoc (a + c) b d ⟩ | ||
(a + c) + (b + d) ∎ | ||
|
||
assoc-comm′ : ∀ a b c d → a + (b + (c + d)) ≡ a + c + (b + d) | ||
assoc-comm′ a b c d = begin | ||
a + (b + (c + d)) ≡⟨ cong (a +_) (+-assoc b c d) ⟨ | ||
a + (b + c + d) ≡⟨ cong (λ z → a + (z + d)) (+-comm b c) ⟩ | ||
a + (c + b + d) ≡⟨ cong (a +_) (+-assoc c b d) ⟩ | ||
a + (c + (b + d)) ≡⟨ +-assoc a c _ ⟨ | ||
a + c + (b + d) ∎ | ||
|
||
assoc₁ : ∀ m n o → (2 + n + o) * (1 + m) ≡ (1 + n) * (1 + m) + (1 + o) * (1 + m) | ||
assoc₁ m n o = begin | ||
(2 + n + o) * (1 + m) ≡⟨ cong (_* (1 + m)) (assoc-comm 1 1 n o) ⟩ | ||
((1 + n) + (1 + o)) * (1 + m) ≡⟨ *-distribʳ-+ (1 + m) (1 + n) (1 + o) ⟩ | ||
(1 + n) * (1 + m) + (1 + o) * (1 + m) ∎ | ||
|
||
assoc₂ : ∀ m n o → (1 + n + (1 + o)) * (1 + m) ≡ (1 + n) * (1 + m) + (1 + o) * (1 + m) | ||
assoc₂ m n o = *-distribʳ-+ (1 + m) (1 + n) (1 + o) | ||
|
||
assoc₃ : ∀ m n o → m + (n + (1 + o)) * (1 + m) ≡ (1 + n) * (1 + m) + (m + o * (1 + m)) | ||
assoc₃ m n o = begin | ||
m + (n + (1 + o)) * (1 + m) ≡⟨ cong (m +_) (*-distribʳ-+ (1 + m) n (1 + o)) ⟩ | ||
m + (n * (1 + m) + (1 + o) * (1 + m)) ≡⟨ +-assoc m _ _ ⟨ | ||
(m + n * (1 + m)) + (1 + o) * (1 + m) ≡⟨ +-suc _ _ ⟩ | ||
(1 + n) * (1 + m) + (m + o * (1 + m)) ∎ | ||
|
||
assoc₄ : ∀ m n o → m + (1 + m + (n + o) * (1 + m)) ≡ (1 + n) * (1 + m) + (m + o * (1 + m)) | ||
assoc₄ m n o = begin | ||
m + (1 + m + (n + o) * (1 + m)) ≡⟨ +-suc _ _ ⟩ | ||
1 + m + (m + (n + o) * (1 + m)) ≡⟨ cong (λ z → suc (m + (m + z))) (*-distribʳ-+ (suc m) n o) ⟩ | ||
1 + m + (m + (n * (1 + m) + o * (1 + m))) ≡⟨ cong suc (assoc-comm′ m m _ _) ⟩ | ||
(1 + n) * (1 + m) + (m + o * (1 + m)) ∎ |
Oops, something went wrong.
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.