Repository navigation
chore(Combinatorics/SimpleGraph): avoid structure relation predicates - #37878
YaelDillies wants to merge 14 commits into
Conversation
PR summary 96df3354baImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
Can you elaborate on the issue with relation classes? I thought the only issue was that I didn't know we can write Also @Vierkantor said that |
|
You can see from the diff that the predicate is largely more often unfolded than its API is used. Empirically, it is useful for the fields to be universal quantifiers, as then the variables can be introduced with I get your point about I am teaching a Lean course in six months, which is why I am caring about usability and discoverability more now. |
| Adj : V → V → Prop | ||
| symm : Symmetric Adj := by aesop_graph | ||
| loopless : Std.Irrefl Adj := by aesop_graph | ||
| loopless (v : V) : ¬ Adj v v := by aesop_graph |
There was a problem hiding this comment.
So one apparent advantage of your change is you can close goals with the autoparams. But if we declare attribute [aesop_graph norm] Std.irrefl_iff then aesop_graph would have the same capabilities, so I don't believe it's a very strong argument.
There was a problem hiding this comment.
Sure, my point is mostly to improve usability when providing a manual proof
There was a problem hiding this comment.
Then how about a custom constructor? This sounds to me like the best of both worlds
SimpleGraph.fromIrreflSymmRel to match the existing SimpleGraph.fromRel?
There was a problem hiding this comment.
Custom constructors suffer even worse usability
There was a problem hiding this comment.
I agree, but OTOH I don't see the usability issue with typing loopless.irrefl/symm.symm instead of loopless/symm. Is the issue the discoverability of those when using the code-action that generates a structure scaffolding?
Vierkantor
left a comment
There was a problem hiding this comment.
I'm not so convinced by this change. It seems like code churn that maybe makes things available at a lower level of understanding, but then we lose all the advantages of working at high levels. I wouldn't be able to recognize (v : V) : ¬ Adj v v at a glance as irreflexivity, but I would be able to do so if it said : Irrefl Adj.
The API for Std.Irrefl is underdeveloped, I agree, and this makes proofs somewhat verbose. But why not instead write better API?
For transitivity, we also have the issue there are multiple non-defeq ways to state the bare proposition. To prevent issues with e.g. the hypotheses getting reordered, we should standardize on one, which is Std.Transitive.
On the other hand, I am not a combinatorics maintainer, so if combinatorics maintainers agree this PR has concrete benefits, then I am not going to block it.
| theorem bot_isCompleteMultipartite : (⊥ : SimpleGraph α).IsCompleteMultipartite := by | ||
| simp [IsCompleteMultipartite] |
There was a problem hiding this comment.
I don't really see this as much of an upgrade: we still need to unfold IsCompleteMultipartite but here we don't see the constructor which marks the abstraction boundaries.
There was a problem hiding this comment.
Unfolding the new definition with simp is another standard way to mark the abstraction boundary, so I don't really see the issue
|
This pull request has conflicts, please merge |
|
This PR/issue depends on: |
7569397 to
7070c99
Compare
|
This pull request has conflicts, please merge |
…ates Relation predicates used to be `def`s over a `forall`, which was optimal for usability in fields of other structures. This changed in leanprover-community#35591 and leanprover-community#35192 as a byproduct of reducing apparent code duplication. Unfortunately, the usability issue was overlooked. This PR restores usability by dropping the use of those relation classes that are `structure`s, ie `Std.Irrefl` and `Std.Transitive`. It also uses more widely the `simp` auto-param on `SimpleGraph.loopless`.
7070c99 to
bfcad97
Compare
|
This pull request has conflicts, please merge |
|
This pull request has conflicts, please merge |
|
This pull request has conflicts, please merge |
|
For clarity, I agree with all of Anne's comments above. |
|
While keeping in mind this PR, and structure SimpleGraph' (V : Type*) extends Digraph V, Std.Symm Adj, Std.Irrefl Adj where
example (V) : SimpleGraph' V where
Adj := Ne
toSymm := inferInstance
irrefl _ := Ne.irrefl
-- with `aesop_graph`:
structure SimpleGraph'' (V : Type*) extends Digraph V, Std.Symm Adj, Std.Irrefl Adj where
symm := by aesop_graph
irrefl := by aesop_graph
example (V) : SimpleGraph'' V where
Adj := NeNote that this means that there's no |
|
This sounds reasonable to me, but @Jun2M's plans will likely conflict with this vision anyway. |
|
This pull request has conflicts, please merge |
|
This pull request has conflicts, please merge |
Relation predicates used to be
defs over aforall, which was optimal for usability in fields of other structures. This changed in #35591 and #35192 as a byproduct of reducing apparent code duplication. Unfortunately, the usability issue was overlooked.This PR restores usability by dropping the use of those relation classes that are
structures, ieStd.IrreflandStd.Transitive.looplessmore #38554I would also be happy to revert #35591 and #35192 since this demonstrates a good use case for the
defversions of the relation predicates.