Skip to content

Commit b089a75

Browse files
committed
feat: positivity extension for algebraMap (#9961)
1 parent 08f7e99 commit b089a75

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Mathlib/Algebra/Order/Module/Algebra.lean

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,43 @@ variable [SMulPosReflectLT α β]
7070

7171
end SMulPosStrictMono
7272
end StrictOrderedSemiring
73+
74+
namespace Mathlib.Meta.Positivity
75+
open Lean Meta Qq Function
76+
77+
/-- Extension for `algebraMap`. -/
78+
@[positivity algebraMap _ _ _]
79+
def evalAlgebraMap : PositivityExt where eval {u β} _zβ _pβ e := do
80+
let ~q(@algebraMap $α _ $instα $instβ $instαβ $a) := e | throwError "not `algebraMap`"
81+
let pα ← synthInstanceQ (q(PartialOrder $α) : Q(Type u_1))
82+
match ← core q(inferInstance) pα a with
83+
| .positive pa =>
84+
let _instαring ← synthInstanceQ q(OrderedCommSemiring $α)
85+
try
86+
let _instβring ← synthInstanceQ q(StrictOrderedSemiring $β)
87+
let _instαβsmul ← synthInstanceQ q(SMulPosStrictMono $α $β)
88+
assertInstancesCommute
89+
return .positive q(algebraMap_pos $β $pa)
90+
catch _ =>
91+
let _instβring ← synthInstanceQ q(OrderedSemiring $β)
92+
let _instαβsmul ← synthInstanceQ q(SMulPosMono $α $β)
93+
assertInstancesCommute
94+
return .nonnegative q(algebraMap_nonneg $β $ le_of_lt $pa)
95+
| .nonnegative pa =>
96+
let _instαring ← synthInstanceQ q(OrderedCommSemiring $α)
97+
let _instβring ← synthInstanceQ q(OrderedSemiring $β)
98+
let _instαβsmul ← synthInstanceQ q(SMulPosMono $α $β)
99+
assertInstancesCommute
100+
return .nonnegative q(algebraMap_nonneg $β $pa)
101+
| _ => pure .none
102+
103+
example [OrderedSemiring β] [Algebra α β] [SMulPosMono α β] {a : α} (ha : 0 ≤ a) :
104+
0 ≤ algebraMap α β a := by positivity
105+
106+
example [OrderedSemiring β] [Algebra α β] [SMulPosMono α β] {a : α} (ha : 0 < a) :
107+
0 ≤ algebraMap α β a := by positivity
108+
109+
example [StrictOrderedSemiring β] [Algebra α β] [SMulPosStrictMono α β] {a : α} (ha : 0 < a) :
110+
0 < algebraMap α β a := by positivity
111+
112+
end Mathlib.Meta.Positivity

0 commit comments

Comments
 (0)