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
3
votes
0 answers

Dealing with Laws of Excluded Middle in Lean

section open classical example : ¬ (A ↔ ¬ A) := have hn : (A ∨ ¬ A), from sorry, assume h : (A ↔ ¬ A), show false, from or.elim hn (assume h1 : A, h.mp h1 h1) (assume h2 : ¬ A, h2 (h.mpr h2)) end I am studying Lean with Jeremy Avigad's…
SU Lee
  • 131
  • 4
3
votes
2 answers

How to use the summation sign in lean?

In lean, there exists a notation for the summation sign (Σ, large Sigma) to write sums with many terms. Sadly, neither the mathlib documentation nor the reference manual seem to provide much information about how it can be used. What imports are…
502E532E
  • 431
  • 2
  • 11
3
votes
2 answers

How to use sockets in Lean?

How do I create a TCP socket in Lean 4 and accept an incoming connection or connect to a remote address? In other words, how do I implement a TCP server or client in Lean 4?
eyelash
  • 3,197
  • 25
  • 33
3
votes
1 answer

how can I prove (∀ x, ¬ A x) → ¬ ∃ x, A x from principles in lean?

I know that to prove : (¬ ∀ x, p x) → (∃ x, ¬ p x) the proof is: theorem : (¬ ∀ x, p x) → (∃ x, ¬ p x) := begin intro nAxpx, by_contradiction nExnpx, apply nAxpx, assume a, by_contradiction hnpa, apply nExnpx, existsi…
3
votes
1 answer

turn proofs for nat into proofs for non-negative ints

I proved some fairly trivial lemma lemma two_ne_four_mul_any (n:ℕ) : 2 ≠ 2 * 2 * n Obviously, the same should hold for non-negative Integers, Rationals, Reals, etc.: lemma two_ne_four_mul_any (z:ℤ) (nonneg: 0 ≤ z): 2 ≠ 2 * 2 * z In general, if we…
Ingo
  • 36,037
  • 5
  • 53
  • 100
3
votes
1 answer

Is there a tactic for solving such trivial goals (lean theorem proving)?

I'm a beginner and I'm stuck with the following: import tactic.linarith import tactic.suggest noncomputable theory open_locale classical lemma two_ne_four_mul_any (n:ℕ) : 2 ≠ 2 * 2 * n := begin cases n, linarith, rw mul_assoc, ??? end The…
Ingo
  • 36,037
  • 5
  • 53
  • 100
3
votes
1 answer

Lean Mergesort using increasing well founded relation

I am trying to create the mergesort definition in Lean and have created the following code: def mergesort (a: ℕ): list ℕ → list ℕ | [] := [] | [a] := [a] | (x::xs) := merge (mergesort (fhalf xs)) (mergesort (sndhalf…
Kjell
  • 432
  • 4
  • 11
3
votes
0 answers

What is the difference between Type and Type*?

I have seen some instance of Type* in this project. Running #check Type* gives Type u_1 : Type (u_1+1) and #check Type gives Type : Type 1. Performing a search over the language reference and Ctrl-Fing the Expressions chapter doesn't seem to give…
Dair
  • 15,910
  • 9
  • 62
  • 107
3
votes
0 answers

Lean proof of successor over modulo

I am trying to prove lemma mod_pres_succ {m n} (h : (m + 1) % n ≠ 0) : m % n + 1 = (m + 1) % n. I have started with cases (@trichotomous _ (<) _ m n) with h₁ h₂, where I can show m < n and m = n. However, in the m > n case (where modulus is…
MaggHa
  • 31
  • 1
3
votes
2 answers

Beginner, cannot import in Lean

I am an absolute beginner, not a programmer, trying to learn formal verification with Logic and Proof. I cannot import anything in Lean. I extract the tar file for the binary to /tmp then do /tmp/lean-3.4.1-linux/bin/./lean /tmp/test.lean It works…
Michael I.
  • 51
  • 4
3
votes
1 answer

Dependently typed bounded range in Lean

Suppose I would like to create a bounded integer Z with bounds a b. def zbound (x₁ x₂ : ℤ) := { n : ℤ // x₁ ≤ n ∧ n ≤ x₂ } Is this a reasonable representation of a bounded integer? Now I would like to create a range of numbers from a to b. def…
ScarletAmaranth
  • 5,065
  • 2
  • 23
  • 34
3
votes
1 answer

Why do Leans `Prop`ositions get special treatment?

A question is nagging me since I began going through the interactive Lean tutorial: What is the purpose of the separate Prop hierarchy within Type? As I understand it now, we have the following universe hierarchy in place: Type (n+1) | \ | …
Sebastian Graf
  • 3,602
  • 3
  • 27
  • 38
3
votes
1 answer

Idempotents of a commutatitive ring in Lean proof assistant

Hi I am trying to do some mathematics in the Lean proof assistant to see how it works. I decided that it should be fun to play with idempotents of a commutative ring. Here's what I tried: variables (A : Type) (R : comm_ring A) definition KR : Type…
Jonathan Gallagher
  • 2,115
  • 2
  • 17
  • 31
2
votes
1 answer

Assume in lean 4

A lot of proofs in Lean 3 were structured via the assume syntax e.g. theorem WetTheorem : forall Rain Hydrant Wet: Prop, (Rain ∨ Hydrant) → -- raining or hydrant on; (Rain → Wet) → -- if raining then wet; (Hydrant → Wet) → -- if…
n-0
  • 309
  • 2
  • 8
2
votes
1 answer

Go to type class instance definition in Lean 4

I'm using Lean4 in VS Code and it has the essential feature of showing me definition of anything I select. Is there some way to also find instances of type class definitions? For example if I write #check IsCommutative.comm Or ∨ and hold Cmd key…
alagris
  • 1,838
  • 16
  • 31
1
2
3
11 12