-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from inpefess/add-example
Add example
- Loading branch information
Showing
10 changed files
with
209 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
.. | ||
Copyright 2021 Boris Shminke | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
.. _usage-example: | ||
|
||
Basic usage example | ||
==================== | ||
|
||
Let's suppose that Isabelle binary is on our ``PATH`` and we started an Isabelle server in working directory with the following command:: | ||
|
||
isabelle server > server.pid | ||
|
||
Now we can get an instance of Isabelle client to talk to this server from Python in a very simple way:: | ||
|
||
from isabelle_client import get_isabelle_client_from_server_info | ||
isabelle = get_isabelle_client_from_server_info("server.pid") | ||
|
||
It might be useful to log all replies from the server somewhere, e.g.:: | ||
|
||
import logging | ||
import sys | ||
|
||
logger = logging.getLogger() | ||
logger.addHandler(logging.StreamHandler(sys.stdout)) | ||
logger.setLevel(logging.INFO) | ||
isabelle.logger = logger | ||
|
||
This client has several methods implemented to communicate with the server Python-style, e.g.:: | ||
|
||
isabelle.use_theories(theories=["dummy"], master_dir=".") | ||
|
||
One can also issue a free-form command, e.g.:: | ||
|
||
isabelle.execute_command("echo 42", asynchronous=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
theory dummy | ||
imports HOL.Nitpick | ||
begin | ||
lemma "1 ~= 0" | ||
oops | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Copyright 2021 Boris Shminke | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
import logging | ||
import sys | ||
|
||
from isabelle_client import get_isabelle_client_from_server_info | ||
|
||
|
||
def main(): | ||
""" using ``isabelle`` client """ | ||
# first, run Isabelle server in the same directory as this script: | ||
# isabelle server > server.pid | ||
isabelle = get_isabelle_client_from_server_info("server.pid") | ||
# we will log all the messages from the server to stdout | ||
logger = logging.getLogger() | ||
logger.addHandler(logging.StreamHandler(sys.stdout)) | ||
logger.setLevel(logging.INFO) | ||
isabelle.logger = logger | ||
# now we can send a theory file from this directory to the server | ||
# and get a response | ||
isabelle.use_theories(theories=["dummy"], master_dir=".") | ||
isabelle.execute_command("echo 42", asynchronous=False) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.