Skip to content

Conversation

@vadimkantorov
Copy link

@vadimkantorov vadimkantorov commented Apr 30, 2025

No docs yet for the new arguments

import os
from lean_interact import LeanREPLConfig, LeanServer, Command

# config = LeanREPLConfig(verbose=True) # download and build Lean REPL
config = LeanREPLConfig(
    lean_version = '',
    setup = False,
    lake_env_repl_path = 'repl',
    lake_command = 'exe',
    lake_path = os.path.expanduser('~/.elan/bin/lake'),
    working_dir = os.path.expanduser('~/mathlib4')
)

server = LeanServer(config)
print(server.run(Command(cmd="theorem ex (n : Nat) : n = 5 → n = 5 := id")))

if verbose:
logger.info("Sending query: %s", json_query)
self._proc.stdin.write(json_query + "\n\n")
self._proc.stdin.write(json_query + "\n\n\n\n")
Copy link
Author

@vadimkantorov vadimkantorov May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without "\n\n\n\n" I was getting hangs with my existing installation of REPL

or maybe it's because "\r\n\r\n" is needed in input as well, as was discussed in leanprover-community/repl#5 (comment) ?

leanprover-community/repl#5 (comment) suggests that "\r\n" is part of JSON-RPC standard

@augustepoiroux I also noticed that you are using universal_newlines=True which seems the deprecated version of text=True, according to https://docs.python.org/3/library/subprocess.html

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I am on vacation now and won't have time to have a proper look into this before a week.

It seems that the REPL has changed since the PR you mention and the version you are using, hence "\n\n" is now enough. It is possible that "\n\n\n\n" or "\r\n\r\n" will not work with current REPL versions.

@augustepoiroux I also noticed that you are using universal_newlines=True which seems the deprecated version of text=True, according to https://docs.python.org/3/library/subprocess.html

If I am not mistaken, we are using text=True in Leaninteract and not universal_newlines=True.

Copy link
Author

@vadimkantorov vadimkantorov May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(You are right, sorry about universal_newlines - I confused it with something else)

@augustepoiroux
Copy link
Owner

Solved by #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants