Zulip Chat Archive

Stream: general

Topic: Using rw and simp for theorems of my PSBP library


Luc Duponcheel (Aug 19 2025 at 12:06):

Hello all,

Thanks to Robin Arnez I am becoming more and more a
"proficient equality theorem prover", even up to the point
that writing theorems becomes "tedious" and I would like
Lean to take over the job for me.

I looked at the rw and simp documentation and looked at a few examples. So I tried to use rw and simp for my proofs but failed to
use them correctly.

I get messages similar to "simp could not proceed".

The code below contains the PSBP type classes,
corresponding "lawful" classes and a few theorems.
Especially the last theorem becomes very large and complex.
I also needed to add type annotations.

I would really appreciate if some member of the community
could get me started with rw and simp by replacing my
proofs by proofs using rw and simp similar to the
LawfulMonad proofs.

Thanks

By the way also using grind failed.

Thanks

Code listing

Robin Arnez (Aug 19 2025 at 12:38):

The last proof can be replaced by simp [applyAtFirst, asProgram, product, first, second]. You need to tell it to unfold everything in order for it to see the real definitions.

Robin Arnez (Aug 19 2025 at 12:42):

Alternatively, you can unfold definitions entirely yourself and then let simp do the rest:

  change
    fun x : α × γ => pure Prod.mk <*> (pure x.fst >>= fun a => pure (αfβ a)) <*> pure x.snd =
    (fun x : α × γ => pure (αfβ x.fst, x.snd) : FromComputationValuedFunction computation _ _)
  simp

Kenny Lau (Aug 19 2025 at 13:13):

alternatively you can mark those definitions as @[simp] to tell simp to always unfold those definitions

Robin Arnez (Aug 19 2025 at 13:20):

I don't that's the goal though in the same way you won't unfold + or >>= by default

Luc Duponcheel (Aug 19 2025 at 14:19):

OK, gonna give it a try, you're my hero, Robin!

Luc Duponcheel (Aug 19 2025 at 14:34):

Lean is an amazing system, and this community really rocks!

On the one hand I am glad that I could calculate complex proofs myself, but, let's face it, those manual proofs are complex "getting the types right puzzles" that a system like Lean should be able to do (and can do (!)) for us.

Note that I used "complex" (as opposed to "simple") and not "difficult" as opposed to "easy". Human beings can only deal with a limited amount of complexity. Very complex things can become difficult for us. Computers can deal with unlimited complexity (there are memory and CPU limitations). Our task is to let them deal with difficulty as well. Systems like Lean are a big step forwards in order to accomplish that task.

Thanks so much all of you!

Luc Duponcheel (Aug 19 2025 at 14:50):

You may wonder why I do this PSBP (Program Description Based Programming) project. Just like computations (monads) are effectful expression specifications, (what I call) programs are effectful function specifications. 32 years ago I worked on the fundaments of computations and computation transformers at the University of Utrecht. Computations (monads) are mainstream now in many programming language libraries. Now that I am retired, I think that programs are the way to go. Why? Well because computations (and expression) are operational artifacts, while programs (and functions) are denotational artifacts (they have a meaning and can be given a meaningful name). For example, the associativity law of computations is an operational law (and difficult to remember). The associativity law of programs is a denotational law (and easy to remember).


Last updated: Dec 20 2025 at 21:32 UTC