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

Is it possible to convert all higher-order logic and dependent type in Lean/Isabelle/Coq into first-order logic?

More specially, given arbitrary Lean proof/theorem, is it possible to express it solely using first-order logic? If so, is it practical, i.e. the generated FOL will not be enormously large? I have seen…
ch271828n
  • 15,854
  • 5
  • 53
  • 88
2
votes
1 answer

How to do function composition in Lean 4?

If I have two functions f and g, in Haskell I can compose them by writing g.f. How do I do the same thing in Lean 4?
eyelash
  • 3,197
  • 25
  • 33
2
votes
0 answers

Comparing equal types in a definition

I'm fairly new to Lean, so apologies if this is obvious. I'm trying to learn Lean and category theory, by doing some category theory exercises in Lean. I have these definitions for arrows and categories: variable {α : Type u} inductive Arrow : α →…
David Legg
  • 271
  • 1
  • 4
  • 12
2
votes
1 answer

Loops in Lean programming language

I'm starting to learn about Lean programming language https://leanprover.github.io I've found out that there are functions, structures, if/else, and other common programming commands. However, I haven't found anything to deal with loops. Is there a…
FelipeCruzV10
  • 426
  • 6
  • 13
2
votes
1 answer

Resolving a "diamond inheritance" class in lean

I have a pretty basic construction of loops in mind for lean. I construct a class for magmata, a class for quasigroups (cancellative magmata), and a class for unital magmata. From there a loop is just something that is both a quasigroup and a…
Wheat Wizard
  • 3,982
  • 14
  • 34
2
votes
2 answers

How to prove that x < y → x ≤ y - 2 if both are odd or both are even in Lean?

I'm working my way through tutorials and also formalizing mathematics course and trying to solve other problems I find interesting. There is surprisingly little examples with inequalities. How one can prove that if two ℤ numbers are both even or…
lonelyelk
  • 598
  • 9
  • 25
2
votes
2 answers

Proving A → ¬ (¬ A ∧ B) in Lean

I am having a hard time proving A → ¬ (¬ A ∧ B) with the Lean theorem prover. I set it up like this: example : A → ¬ (¬ A ∧ B) := assume h1: ¬ (¬ A ∧ B), assume h2: A, assume h3: B, show false, from sorry I was unable to find examples to prove this…
2
votes
2 answers

How do I prove this in Lean? p ∨ ¬p

I have a theorem to prove on lean, theorem T (h : ¬ A) : ¬ (A ∨ B) ∨ (¬ A ∧ B) For which to prove, I guess, I need to use, or.elim (B ∨ ¬B) (assume b: B, ...) (assume nb:¬B, ...) For which, again, I have to prove B v ¬B So, how do I proceed with…
2
votes
1 answer

Does lean enhance proof surveyability?

By proof-surveyability I understand the fact that a human user could "trace" all the details of a proof. There are things that are not easily traceable. For instance, an SMT proof is based on specific heuristics that are then translated into the…
user1868607
  • 2,558
  • 1
  • 17
  • 38
2
votes
1 answer

Proving that two strings are different in Lean

As I was carrying out my normal course of lean theorem proving, I realized my current file was taking an awfully long time to compile. I then narrowed down the issue to the part where I was attempting to prove that two strings were distinct: lemma…
Sven Williamson
  • 1,094
  • 1
  • 10
  • 19
2
votes
2 answers

How do I easily rewrite nat.succ (nat.succ 0) as 2?

Say my proof goal includes nat.succ (nat.succ 0), and I want to quickly rewrite it to say 2; I can define a whole new theorem: theorem succ_succ_zero_eq_two : nat.succ (nat.succ 0) = 2 := rfl then use that theorem with rw, but this seems very…
ahelwer
  • 1,441
  • 13
  • 29
2
votes
1 answer

How can one prove (¬ ∀ x, p x) → (∃ x, ¬ p x) from first principles in LEAN?

The proof of this basic implication from first principles, an exercise in "Theorem proving in Lean" 4.4, beats all my attempts so far: open classical variables (α : Type) (p q : α → Prop) variable a : α local attribute [instance]…
Vox
  • 173
  • 1
  • 8
2
votes
1 answer

Induction issue

I have defined a type of trees, together with a fusion operation as follows: open nat inductive tree : Type | lf : tree | nd : tree -> nat -> tree -> tree open tree def fusion : tree -> tree -> tree | lf t2 := t2 | (nd l1 x1 r1) lf := (nd l1 x1…
Oblivier
  • 89
  • 5
2
votes
1 answer

Simple refl-based proof problem in Lean (but not in Agda)

In an attempt to define skew heaps in Lean and prove some results, I have defined a type for trees together with a fusion operation: inductive tree : Type | lf : tree | nd : tree -> nat -> tree -> tree def fusion : tree -> tree -> tree | lf t2 :=…
Oblivier
  • 89
  • 5
2
votes
1 answer

Defining a function to a subset of the codomain

I am trying to define the image restriction of a function f : A → B as f': A → f[A], where f'(a) = f(a) . However, I am not sure how to define it in a lean. In my opinion, the most intuitive way to define it is: def fun_to_image {A B:…
1 2
3
11 12