Questions tagged [lean]

Lean is an open source theorem prover being developed at Microsoft Research, with a monolothic standard library developed collaboratively. The Lean Theorem Prover aims to bridge the gap between interactive and automated theorem proving. There are two main versions available; Lean 3 and Lean 4, with similar designs but different syntax.

Resources:

169 questions
2
votes
1 answer

Lean: define product of R-ideal and R-module

I am trying to learn Lean and I am trying to figure out how one would create a new R-module I*M = {i*m | i in I, m in M} from an ideal I and an R-module M. So my attempt was to define first a map ideal_mult that would create a new R-module and then…
Snow bunting
  • 1,120
  • 8
  • 28
2
votes
1 answer

Definition of choice in Lean

In Lean, the axiom choice is implemented as follows: axiom choice {α : Sort u} : nonempty α → α Given only the assertion h that α is nonempty, choice h magically produces an element of α. Now if I read literature (Jech) on set theory and the…
Jens Wagemaker
  • 354
  • 3
  • 13
2
votes
3 answers

How to eliminate parenthesis in algebraic expressions using Lean

I am trying to prove one algebraic theorem using Lean. My code is import algebra.group import algebra.ring open algebra variable {A : Type} variables [s : ring A] (a b c : A) include s theorem clown (a b c d e : A) : (a + b + e) * ( c + d) = …
Juan Ospina
  • 1,317
  • 1
  • 7
  • 15
2
votes
1 answer

Using sets in lean

I'd like to do some work in topology using lean. As a good start, I wanted to prove a couple of simple lemmas about sets in lean. For example def inter_to_union (H : a ∈ set.inter A B) : a ∈ set.union A B := sorry or def set_deMorgan : a ∈…
Adam Kurkiewicz
  • 1,526
  • 1
  • 15
  • 34
2
votes
2 answers

lean : eq.subst chokes on h:(n=0)

Using Lean, the computer proof checking system. The first of these proofs succeeds, the second does not. variables n m : nat theorem works (h1 : n = m) (h2 : 0 < n) : (0 < m) := eq.subst h1 h2 theorem nowrk (h3 : n = 0) (h4 : 0 < n) : (0 < 0)…
Kevin Buzzard
  • 537
  • 4
  • 11
2
votes
0 answers

Appending nil to a dependently typed length indexed vector in Lean

Assume the following definition: def app {α : Type} : Π{m n : ℕ}, vector α m → vector α n → vector α (n + m) | 0 _ [] v := by simp [add_zero]; assumption | (nat.succ _) _ (h :: t) v' := begin apply vector.cons, …
ScarletAmaranth
  • 5,065
  • 2
  • 23
  • 34
2
votes
1 answer

How to propogate an assumption when pattern matching in Lean

I'm trying to prove in Lean that if an item is less than the head of a sorted list, it's not a member of the list. theorem not_in_greater {α: Type} [d: decidable_linear_order α] {x h: α} (t: list α) (Hs: is_sorted (h::t)) (Hlt: x < h) : x ∉ (h::t)…
LogicChains
  • 4,332
  • 2
  • 18
  • 27
2
votes
1 answer

Why does Lean enforce recursive type arguments to appear after non-recursive ones?

The following definition is rejected by Lean: inductive natlist | nil : natlist | cons: natlist → ℕ → natlist with the error message "arg #2 of 'natlist.cons' is not recursive, but it occurs after recursive arguments" And the following definition…
2
votes
1 answer

What constitutes a valid type in lean?

I've done the first 3 chapters of the lean tutorial, and I've already done a few proofs in propositional logic. Now I'm trying to go back a bit and ask myself dumb questions. My understanding is that: Terms can have types: constant A : Type. A is a…
Adam Kurkiewicz
  • 1,526
  • 1
  • 15
  • 34
2
votes
1 answer

Use obtain in tactic mode in Lean theorem prover

How do I use a hypothesis of the shape H : exists x, P x in tactic mode? In term mode I would use obtain x Hx, from H,
user3078439
  • 305
  • 1
  • 10
2
votes
2 answers

Lean complains it can't see that a statement is decidable

I'm trying to define the following quantity partn: variable pi : nat -> Prop variable (Hdecp : ∀ p, decidable (pi p)) definition partn (n : nat) : nat := ∏ p ∈ (prime_factors n), (if pi p then p^(mult p n) else 1) but get the error error: failed…
user3078439
  • 305
  • 1
  • 10
1
vote
0 answers

How to prove this matrix identity in lean

I am trying to formalize the proof of the following fact in lean: $$ \begin{matrix}1 & 1 & 1 \ 0 & 1 & 1\ 0 & 0 & 1\end{matrix}^n = \begin{matrix}1 & n & \frac{n(n+1)}{2} \ 0 & 1 & n\ 0 & 0 & 1\end{matrix} $$ The proof is almost immediately using…
Gaussian97
  • 137
  • 1
  • 9
1
vote
2 answers

Trace tauto, finish

Is there a way to trace tauto, finish tactics (or others that don't fall into simp) in Lean? E.g. example (P Q : Prop) : a → b ↔ ¬a ∨ b := by tauto I'd like to see the neccesary rewritings or theorems that are applied to the terms to prove the…
n-0
  • 309
  • 2
  • 8
1
vote
1 answer

disjunction commutativity in Lean 4

I see theorem And.comm : a ∧ b ↔ b ∧ a := by constructor <;> intro ⟨h₁, h₂⟩ <;> exact ⟨h₂, h₁⟩ in Core.lean but there is no Or.comm to be seen. Where can I find it?
alagris
  • 1,838
  • 16
  • 31
1
vote
2 answers

Difference between let and have keywords in lean 4

I noticed that both #eval have x : Nat := 3 ; x*2 and #eval let x : Nat := 3 ; x*2 work in the same way. Same goes when proving theorems. Are those equivalent? What is the difference between them?
alagris
  • 1,838
  • 16
  • 31