Zulip Chat Archive
Stream: new members
Topic: State three vectors are linearly dependent
Abdullah Uyu (Mar 05 2024 at 08:48):
How can I rewrite my collinearity relation with the existing linear dependence in LinearAlgebra.LinearIndependent?
import Mathlib.LinearAlgebra.Projectivization.Basic
import Mathlib.LinearAlgebra.Projectivization.Independence
class ProjectiveGeometry (point : Type u) where
ell : point → point → point → Prop
l1 : ∀ a b, ell a b a
l2 : ∀ a b p q, ell a p q → ell b p q → p ≠ q → ell a b p
l3 : ∀ a b c d p, ell p a b → ell p c d → ∃ q : point, ell q a c ∧ ell q b d
instance : ProjectiveGeometry (Projectivization K V) :=
⟨
fun X Y Z => ∃ k1 k2 k3 : K, ¬(k1 = 0 ∧ k2 = 0 ∧ k3 = 0) ∧
k1•X.rep + k2•Y.rep + k3•Z.rep = 0, -- This function should be rewritten.
sorry,
sorry,
sorry
⟩
Abdullah Uyu (Mar 05 2024 at 19:02):
import Mathlib.LinearAlgebra.Projectivization.Basic
import Mathlib.LinearAlgebra.Projectivization.Independence
class ProjectiveGeometry (point : Type u) where
ell : point → point → point → Prop
l1 : ∀ a b, ell a b a
l2 : ∀ a b p q, ell a p q → ell b p q → p ≠ q → ell a b p
l3 : ∀ a b c d p, ell p a b → ell p c d → ∃ q : point, ell q a c ∧ ell q b d
instance : ProjectiveGeometry (Projectivization K V) :=
⟨
fun X Y Z => ¬ LinearIndependent K ![X.rep, Y.rep, Z.rep],
sorry,
sorry,
sorry
⟩
I think I figured it out, but there are some parts I don't quite get. I don't understand indexing types, and I couldn't find an explicit example of it. By mimicking the library, I wrote the above, but it does not work without !
.
- Why is that?
- Also, does this state what I am intending?
Ruben Van de Velde (Mar 05 2024 at 19:11):
What do you mean by "work without !"?
Abdullah Uyu (Mar 05 2024 at 19:13):
Ruben Van de Velde said:
What do you mean by "work without !"?
Sorry, just realizing the sentence is a bit awkward (: I initially didn't put the exclamation mark before the list, and it didn't work.
Abdullah Uyu (Mar 05 2024 at 19:16):
Ruben Van de Velde said:
What do you mean by "work without !"?
But if you ask the error, it's
typeclass instance problem is stuck, it is often due to metavariables
Module K (?m.2765 X Y Z)
Eric Wieser (Mar 05 2024 at 19:44):
[x, y, z]
is a List _
, ![x, y, z]
is a Fin 3 -> _
. They're completely different to Lean, which is why you can't just expect it to work without the !
Abdullah Uyu (Mar 06 2024 at 11:10):
Eric Wieser said:
[x, y, z]
is aList _
,![x, y, z]
is aFin 3 -> _
. They're completely different to Lean, which is why you can't just expect it to work without the!
OK understood. Now I realize I can actually directly use the collinearity condition Projectivization.Independent instead of LinearIndependent. But the following does not type check:
fun X Y Z => ¬ Projectivization.Independent ![X, Y, Z],
it gives:
error: (deterministic) timeout at 'isDefEq', maximum number of heartbeats (200000) has been reached (use 'set_option maxHeartbeats <num>' to set the limit)
Abdullah Uyu (Mar 06 2024 at 15:26):
Meahwhile I am trying to write the proper indexing function instead of using the converter !
.
Abdullah Uyu (Mar 06 2024 at 15:44):
I think there is another problem here, because I get the same error above with the following indexing function:
def index (X Y Z : Projectivization K V) : Fin 3 → Projectivization K V :=
fun i : Fin 3 => match i with
| 0 => X
| 1 => Y
| 2 => Z
Abdullah Uyu (Mar 06 2024 at 15:45):
I use the indexing function above like this:
fun X Y Z => ¬ Projectivization.Independent (index X Y Z),
Eric Wieser (Mar 06 2024 at 15:56):
Can you make a mwe?
Abdullah Uyu (Mar 06 2024 at 15:56):
Of course, give me a second.
Abdullah Uyu (Mar 06 2024 at 15:58):
import Mathlib.LinearAlgebra.Projectivization.Basic
import Mathlib.LinearAlgebra.Projectivization.Independence
variable [DivisionRing K] [AddCommGroup V] [Module K V]
def index (X Y Z : Projectivization K V) : Fin 3 → Projectivization K V :=
fun i : Fin 3 => match i with
| 0 => X
| 1 => Y
| 2 => Z
class ProjectiveGeometry (point : Type u) where
ell : point → point → point → Prop
l1 : ∀ a b, ell a b a
l2 : ∀ a b p q, ell a p q → ell b p q → p ≠ q → ell a b p
l3 : ∀ a b c d p, ell p a b → ell p c d → ∃ q : point, ell q a c ∧ ell q b d
instance : ProjectiveGeometry (Projectivization K V) :=
⟨
fun X Y Z => ¬ Projectivization.Independent (index X Y Z),
sorry,
sorry,
sorry
⟩
Here @Eric Wieser
Abdullah Uyu (Mar 06 2024 at 21:07):
Eric Wieser said:
Can you make a mwe?
Sorry, I actually get the following error, not the one above; I though it's the same:
error: (deterministic) timeout at 'whnf', maximum number of heartbeats (200000) has been reached (use 'set_option maxHeartbeats <num>' to set the
limit)
Abdullah Uyu (Mar 06 2024 at 21:08):
The former is complaining about isDefEq
, the latter whnf
.
Eric Wieser (Mar 06 2024 at 21:25):
The error message is super unhelpful, but the problem is that docs#Projectivization.Independent needs K
to be a Field
Eric Wieser (Mar 06 2024 at 21:25):
I found this out by adding (K := K)
before (index X Y Z)
Eric Wieser (Mar 06 2024 at 21:26):
Lean is concluding that you must be talking about some other field, and so goes on a wild goose chase trying to find out which one before timing out. If you remind it you definitely want K
then it fails quickly
Abdullah Uyu (Mar 06 2024 at 21:30):
Eric Wieser said:
I found this out by adding
(K := K)
before(index X Y Z)
Do you mean like this?
fun X Y Z => ¬ Projectivization.Independent (K := K) (index X Y Z),
This gives me the same error, do you also change the definition of index
?
Abdullah Uyu (Mar 06 2024 at 21:31):
Eric Wieser said:
Lean is concluding that you must be talking about some other field, and so goes on a wild goose chase trying to find out which one before timing out. If you remind it you definitely want
K
then it fails quickly
This is funny :big_smile:
Abdullah Uyu (Mar 06 2024 at 21:39):
But in any case, I may abandon DivisionRing
and use Field
. The other option may be to generalize Independent
for DivisionRing
.
Abdullah Uyu (Mar 06 2024 at 21:42):
@Michael Blyth Why is Projectivization.Independent
for Field
but not generally for DivisionRing
? Would it be hard to generalize?
Abdullah Uyu (Mar 06 2024 at 22:14):
Eric Wieser said:
Lean is concluding that you must be talking about some other field, and so goes on a wild goose chase trying to find out which one before timing out. If you remind it you definitely want
K
then it fails quickly
I changed Field
to DivisionRing
in Projectivization.Independence
and it compiled. That was too easy, am I missing something here? :smiley:
Eric Wieser (Mar 06 2024 at 23:41):
I was going to suggest you try that and see what happened :)
Notification Bot (Mar 07 2024 at 09:44):
Abdullah Uyu has marked this topic as resolved.
Eric Wieser (Mar 07 2024 at 09:50):
@Abdullah Uyu, can you make a PR with that change?
Abdullah Uyu (Mar 07 2024 at 09:52):
Eric Wieser said:
Abdullah Uyu, can you make a PR with that change?
Sure, will look into it when I get a chance to sit before my laptop.
Eric Wieser (Mar 07 2024 at 09:54):
Would it be hard to generalize?
One thing to watch out for is that sometimes a Lean generalization is meaningless mathematically, even if it compiles; for example, docs#BilinForm does not need the ring to be commutative, but in practice the definition is only the right one when it is.
Abdullah Uyu (Mar 07 2024 at 16:19):
That is interesting.
Eric Wieser said:
Would it be hard to generalize?
One thing to watch out for is that sometimes a Lean generalization is meaningless mathematically, even if it compiles; for example, docs#BilinForm does not need the ring to be commutative, but in practice the definition is only the right one when it is.
Abdullah Uyu (Mar 07 2024 at 19:25):
Eric Wieser said:
Abdullah Uyu, can you make a PR with that change?
Alright, I should follow this https://leanprover-community.github.io/contribute/index.html right? It talks about some permission, do I need it?
Abdullah Uyu (Mar 07 2024 at 19:39):
I guess that is the procedure. My github username is oneofvalts.
Notification Bot (Mar 07 2024 at 19:57):
Abdullah Uyu has marked this topic as unresolved.
Eric Wieser (Mar 07 2024 at 20:19):
Abdullah Uyu said:
I guess that is the procedure. My github username is oneofvalts.
Invite sent!
Abdullah Uyu (Mar 07 2024 at 21:01):
Eric Wieser said:
Abdullah Uyu said:
I guess that is the procedure. My github username is oneofvalts.
Invite sent!
Thank you, just created the PR. I am fairly new to this procedure, so I hope it is OK.
Last updated: May 02 2025 at 03:31 UTC