Skip to content

Add divisibility properties of exponentials#2940

Merged
jamesmckinna merged 4 commits intomasterfrom
exp-divisiblity
Feb 11, 2026
Merged

Add divisibility properties of exponentials#2940
jamesmckinna merged 4 commits intomasterfrom
exp-divisiblity

Conversation

@Taneb
Copy link
Member

@Taneb Taneb commented Feb 10, 2026

No description provided.

Copy link
Collaborator

@jamesmckinna jamesmckinna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to approve, but I think that each lemma can be improved, as indicated.

Comment on lines 267 to 269
n≤o⇒m^n∣m^o : ∀ m {n o} → n ≤ o → m ^ n ∣ m ^ o
n≤o⇒m^n∣m^o m z≤n = 1∣ _
n≤o⇒m^n∣m^o m (s≤s n≤o) = *-monoʳ-∣ m (n≤o⇒m^n∣m^o m n≤o)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usual remark applies here: n ≤ o can (and should!) be marked irrelevant, at the (again: usual) cost of expanding the bindings on n and o:

Suggested change
n≤o⇒m^n∣m^o : m {n o} n ≤ o m ^ n ∣ m ^ o
n≤o⇒m^n∣m^o m z≤n = 1∣ _
n≤o⇒m^n∣m^o m (s≤s n≤o) = *-monoʳ-∣ m (n≤o⇒m^n∣m^o m n≤o)
n≤o⇒m^n∣m^o : m {n o} n ≤ o m ^ n ∣ m ^ o
n≤o⇒m^n∣m^o m {n = zero} _ = 1∣ _
n≤o⇒m^n∣m^o m {n = suc _} {o = suc _} n≤o = *-monoʳ-∣ m (n≤o⇒m^n∣m^o m (s≤s⁻¹ n≤o))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #2939 (comment) for a counter view?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made it irrelevant, but just after I pushed, I noticed something further that could be done (assuming #2941) :

n≤o⇒m^n∣m^o :  m {n o}  .(n ≤ o)  m ^ n ∣ m ^ o
n≤o⇒m^n∣m^o m {n} {o} n≤o = divides (m ^ (o ∸ n)) $ begin-equality
  m ^ o               ≡⟨ cong (m ^_) (m∸n+n≡m n≤o) ⟨
  m ^ (o ∸ n + n)     ≡⟨ ^-distribˡ-+-* m (o ∸ n) n ⟩
  m ^ (o ∸ n) * m ^ n ∎
  where open ∣-Reasoning

This has the advantage of making the quotient usefully defined using Data.Nat.Base's operations, rather than a hidden and obscure recursive term. But it's a lot more code for such a small advantage!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well...

All of that said... it's nice to see the commonality between the two proofs, delegating to various instances of distributivity laws. But... for another time, perhaps!?

CHANGELOG.md Outdated
* In `Data.Nat.Divisiblity`:
```agad
m∣n⇒m^o∣n^o : ∀ o → m ∣ n → m ^ o ∣ n ^ o
n≤o⇒m^n∣m^o : ∀ m → n ≤ o → m ^ n ∣ m ^ o
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So:

Suggested change
n≤o⇒m^n∣m^o : ∀ m → n ≤ o → m ^ n ∣ m ^ o
n≤o⇒m^n∣m^o : ∀ m → .(n ≤ o) → m ^ n ∣ m ^ o

@Taneb Taneb requested a review from jamesmckinna February 11, 2026 10:17
Copy link
Collaborator

@jamesmckinna jamesmckinna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look altogether better, very nicely done.

-- Properties of _∣_ and _^_

m∣n⇒m^o∣n^o : ∀ {m n} o → m ∣ n → m ^ o ∣ n ^ o
m∣n⇒m^o∣n^o o (divides-refl m/n) = divides (m/n ^ o) (^-distribʳ-* o m/n _)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... now I'm home again, i realise I was too hasty: the proof has m/n where better we would have n/m.
Potayto, potahto...

@jamesmckinna jamesmckinna added this pull request to the merge queue Feb 11, 2026
Merged via the queue into master with commit 81db5a3 Feb 11, 2026
12 checks passed
@Taneb Taneb deleted the exp-divisiblity branch February 11, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants