Skip to content

Commit 31f7b0e

Browse files
authored
Merge pull request #1 from eric-wieser/tensors
Add handlers for tensor products and direct sums
2 parents 73d12d7 + c428a3d commit 31f7b0e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

LeanTeXMathlib/Basic.lean

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,27 @@ latex_pp_app_rules (const := Finset.range)
130130
| _, #[hi] => do
131131
let hi ← latexPP hi
132132
return "[0, " ++ hi ++ ")" |>.resetBP .Infinity .Infinity
133+
134+
latex_pp_app_rules (const := DirectSum)
135+
| _, #[ι, β, _inst] => do
136+
let pι ← withExtraSmallness 2 <| latexPP ι
137+
withBindingBodyUnusedName' β `i fun name body => do
138+
let pbody ← latexPP body
139+
let psum := (← (LatexData.atomString "\\bigoplus" |>.bigger 1).sub (s!"{name.toLatex} \\in " ++ pι) |>.maybeWithTooltip "DirectSum") ++ pbody
140+
return psum |>.resetBP (rbp := .NonAssoc 0)
141+
142+
latex_pp_app_rules (const := TensorProduct)
143+
| _, #[R, _, M, N, _, _, _, _] => do
144+
let pR ← latexPP R
145+
let pM ← latexPP M
146+
let pN ← latexPP N
147+
return pM.protectRight 100 ++ (LatexData.atomString "\\otimes" |>.sub pR) ++ pN.protectLeft 100
148+
149+
latex_pp_app_rules (const := PiTensorProduct)
150+
| _, #[ι, R, _, s, _, _] => do
151+
let pι ← latexPP ι
152+
let _pR ← latexPP R
153+
withBindingBodyUnusedName' s `i fun name body => do
154+
let pbody ← latexPP body
155+
let psum := (← (LatexData.atomString "\\bigotimes" |>.bigger 1).sub (s!"{name.toLatex} \\in " ++ pι) |>.maybeWithTooltip "PiTensorProduct") ++ pbody
156+
return psum |>.resetBP (rbp := .NonAssoc 0)

test/basic.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ latex_pp_app_rules (kind := any) (paramKinds := params)
6060

6161
#texify Real.arcsin (Real.cos 2)
6262

63+
open scoped DirectSum
64+
65+
#texify ⨁ i, (Fin i → ℝ)
66+
#texify (⨁ i, Fin (i + 1)) → ℝ
67+
6368
end
6469

6570
-- https://github.com/ldct/LeanGT/blob/main/LeanGT/TexifyDemo.lean

0 commit comments

Comments
 (0)