Zulip Chat Archive

Stream: maths

Topic: Pfaffians?


Darij Grinberg (Oct 12 2025 at 13:31):

Does Mathlib know about Pfaffians? perfect matchings of [2n] and their enumeration? what is the easiest way to find out?

Riccardo Brasca (Oct 12 2025 at 13:42):

"pfaffian" does not appear anywhere in mathlib (nor in the code nor in docstrings) so the answer is probably that we don't have anything about it.

Bryan Wang (Oct 12 2025 at 13:47):

Darij Grinberg said:

what is the easiest way to find out?

I usually start with https://leanprover-community.github.io/mathlib-overview.html, though this is not always most updated (but the links there bring you to the docs, which are updated)

Darij Grinberg (Oct 12 2025 at 13:48):

@Bryan Wang thanks, but I'm not sure where to look for this... logically should be in linear algebra but could be wherever it is used

Darij Grinberg (Oct 12 2025 at 13:48):

thanks @Riccardo Brasca

Adrian Marti (Oct 12 2025 at 13:48):

I also tried searching with leanexplore, which also returned no hits.

Bryan Wang (Oct 12 2025 at 13:49):

but as of now the easiest way is usually to ask here :rolling_on_the_floor_laughing:

Darij Grinberg (Oct 12 2025 at 13:50):

thanks @Adrian Marti !
i feel like i should also have the source somewhere on my computer to grep, but i have no idea where VS Code has put it :blushing:

Kenny Lau (Oct 12 2025 at 13:51):

github has a search feature already, https://github.com/search?q=repo%3Aleanprover-community%2Fmathlib4%20pfaffian&type=code

Darij Grinberg (Oct 12 2025 at 13:53):

oooh nice

Bryan Wang (Oct 12 2025 at 13:53):

Darij Grinberg said:

Bryan Wang thanks, but I'm not sure where to look for this... logically should be in linear algebra but could be wherever it is used

There's also a section on enumerative combinatorics further down

Kenny Lau (Oct 12 2025 at 13:58):

loogle also has search by string feature, https://loogle.lean-lang.org/?q=%22pfaff%22

Kenny Lau (Oct 12 2025 at 13:59):

in contrast with leanexplore, loogle does not use LLM

Adrian Marti (Oct 12 2025 at 14:01):

I struggle with effectively using loogle, but that's probably because I don't really understand how to use it :joy: :joy:

Kenny Lau (Oct 12 2025 at 14:02):

@Adrian Marti it matches either parts of the statement or parts of the name of the theorem

Kenny Lau (Oct 12 2025 at 14:03):

for example if you know that a theorem talks about the Nat.card of something then you can use Nat.card as one of the search inputs

Kenny Lau (Oct 12 2025 at 14:03):

the inputs are separated by commas

Kenny Lau (Oct 12 2025 at 14:03):

e.g. if you want to find all theorems that talk about when a cosine is zero, you would do Real.cos _ = 0

Kenny Lau (Oct 12 2025 at 14:03):

https://loogle.lean-lang.org/?q=Real.cos+_+%3D+0

Adrian Marti (Oct 12 2025 at 14:06):

So let's say I want to extend a function Fin n -> X to a function Fin (n + 1) -> X given an a: X. Can I search this with loogle?

Darij Grinberg (Oct 12 2025 at 14:06):

i don't get loogle either, but searching for a word is probably the easiest way of using it :)

Riccardo Brasca (Oct 12 2025 at 14:06):

Adrian Marti said:

So let's say I want to extend a function Fin n -> X to a function Fin (n + 1) -> X given an a: X. Can I search this with loogle?

You can see if there is a literal way of doing it in mathlib, let's see.

Adrian Marti (Oct 12 2025 at 14:07):

Yeah I asked ChatGPT which gave me the answer haha, but can we do this with loogle?

Adrian Marti (Oct 12 2025 at 14:09):

Darij Grinberg said:

i don't get loogle either, but searching for a word is probably the easiest way of using it :)

True

Darij Grinberg (Oct 12 2025 at 14:09):

how well does GPT speak lean4 by now?

Adrian Marti (Oct 12 2025 at 14:10):

I just asked it to browse the mathlib 4 docs, which it apparently can. But it can't browse zulip.

Kenny Lau (Oct 12 2025 at 14:11):

Adrian Marti said:

So let's say I want to extend a function Fin n -> X to a function Fin (n + 1) -> X given an a: X. Can I search this with loogle?

I did (Fin ?n → _) → (Fin (?n+1) → _) which didn't find it directly, but I did see Fin.cons and Fin.snoc mentioned, which are the functions you want, but they didn't show up because those are actually dependent functions, i.e. the return type is not constant

Riccardo Brasca (Oct 12 2025 at 14:11):

Yeah, I also just noticed the same

Riccardo Brasca (Oct 12 2025 at 14:11):

It's a bit unfortunate

Adrian Marti (Oct 12 2025 at 14:12):

I see the problem

Kenny Lau (Oct 12 2025 at 14:13):

setting them as dependent functions actually was successful, (∀ x : Fin ?n, ?a x) → (∀ x : Fin (?n + 1), ?a x) returns those two functions in addition to Fin.lastCases and Fin.cases!

Kenny Lau (Oct 12 2025 at 14:13):

and even more, it also reveals Fin.succAboveCases

Kenny Lau (Oct 12 2025 at 14:14):

i mean, what am i saying, all 10 of those results are valid

Kenny Lau (Oct 12 2025 at 14:14):

@Adrian Marti i hope this demonstrates to you the power of loogle :upside_down:

Riccardo Brasca (Oct 12 2025 at 14:15):

Does exact? work?

Riccardo Brasca (Oct 12 2025 at 14:15):

Or does it find like the constant function?

Riccardo Brasca (Oct 12 2025 at 14:16):

It finds the constant function :(

Riccardo Brasca (Oct 12 2025 at 14:17):

What is the syntax of exact? using?

Adrian Marti (Oct 12 2025 at 14:19):

Kenny Lau said:

Adrian Marti i hope this demonstrates to you the power of loogle :upside_down:

It's definitely something that can be explored :slight_smile:


Last updated: Dec 20 2025 at 21:32 UTC