Skip to content

Commit

Permalink
feat(Algebra/Free): add length_pos lemma for free magmas (#11783)
Browse files Browse the repository at this point in the history
This adds a `length_pos` lemma for multiplicative and additive free magmas. 

Indeed, it sometimes happens in proofs that we need to know that the length of any element is indeed strictly positive.
  • Loading branch information
frederic-marbach committed Mar 30, 2024
1 parent 956f433 commit a77f553
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Mathlib/Algebra/Free.lean
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ def FreeAddMagma.length {α : Type u} : FreeAddMagma α → ℕ

attribute [to_additive existing (attr := simp)] FreeMagma.length

/-- The length of an element of a free magma is positive. -/
@[to_additive "The length of an element of a free additive magma is positive."]
lemma FreeMagma.length_pos {α : Type u} (x : FreeMagma α) : 0 < x.length :=
match x with
| FreeMagma.of _ => Nat.succ_pos 0
| mul y z => Nat.add_pos_left (length_pos y) z.length

/-- Associativity relations for an additive magma. -/
inductive AddMagma.AssocRel (α : Type u) [Add α] : α → α → Prop
| intro : ∀ x y z, AddMagma.AssocRel α (x + y + z) (x + (y + z))
Expand Down

0 comments on commit a77f553

Please sign in to comment.