How do I convert “thm conjI” to an ASCII string I can save to a file?

user3317019

From The Isabelle Cookbook, pages 11 and 12, I found some beginning information related to what I'm trying to do.

Representative of what I'm trying to do is this ML statement:

val syntax_str = Syntax.string_of_term @{context} (prop_of @{thm conjI});

I want to save the theorem conjI to a file as an ASCII string, and have it look like this:

P \<Longrightarrow> Q \<Longrightarrow> P \<and> Q

Below, I show some of the ML commands I experimented with from src/Pure/General/pretty.ML and src/Pure/Syntax/syntax.ML.

I can get a string, but it's not good for saving to a file. I don't know how to get the string as what's saved to a THY file.

ML‹Syntax.pretty_term›
ML‹Syntax.pretty_term @{context} (prop_of @{thm conjI})›
ML‹Pretty.writeln (Syntax.pretty_term @{context} (prop_of @{thm conjI}))›
ML‹Pretty.string_of (Syntax.pretty_term @{context} (prop_of @{thm conjI}))›
ML‹Pretty.symbolic_output (Syntax.pretty_term @{context} (prop_of @{thm conjI}))›
ML‹Pretty.symbolic_string_of (Syntax.pretty_term @{context} (prop_of @{thm conjI}))›
ML‹Pretty.str_of (Syntax.pretty_term @{context} (prop_of @{thm conjI}))›

ML‹
  val syntax_str = Syntax.string_of_term @{context} (prop_of @{thm conjI});
  writeln syntax_str;
  File.write (Path.explode (
    File.platform_path(Resources.master_directory @{theory}) ^ 
    "/syntax_str.txt")) syntax_str;
› 
ML‹
  val pretty_str = Pretty.str_of (
    Syntax.pretty_term @{context} (prop_of @{thm conjI}));
  writeln pretty_str;
  File.write (Path.explode (
    File.platform_path(Resources.master_directory @{theory}) ^ 
    "/pretty_str.txt")) pretty_str;
›

Thanks.

davidg

I am not sure if this is the best way, but you could try:

fun render_thm ctxt thm =
  Print_Mode.setmp ["xsymbols"]
    (fn _ => Display.pretty_thm ctxt thm
             |> Pretty.str_of
             |> YXML.parse_body
             |> XML.content_of) ()

Now, if you run:

ML {* render_thm @{context} @{thm iffI} *}

you will get a string that displays in Isabelle/jEdit as:

⟦?P ⟹ ?Q; ?Q ⟹ ?P⟧ ⟹ ?P = ?Q

but internally is actually:

\<lbrakk>?P \<Longrightarrow> ?Q; ?Q \<Longrightarrow> ?P\<rbrakk> \<Longrightarrow> ?P = ?Q

This latter version is what you will get if you save the string to a file using File.write.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I convert “thm conjI” to an ASCII string I can save to a file?

From Dev

in C# how do I convert what I think is a string of hex ascii to something i can read?

From Dev

How can I convert a String into ASCII and then back in Haskell?

From Dev

How do I convert Encoding.ASCII.GetBytes to string

From Dev

How can I convert ASCII tablature into a MIDI file?

From Dev

How can I convert a String in ASCII(Unicode Escaped) to Unicode(UTF-8) if I am reading from a file?

From Dev

How do i convert from ASCII to Decimal

From Dev

How can I add new lines to a string and save it to a file in bash?

From Dev

How can I convert a string to a file handle in perl?

From Dev

How do I convert result from opening gzip file to string

From Dev

How do I force recv() in Socket to NOT convert my hex values into ASCII if it can (python)

From Dev

How do I convert a UserDefault value from AnyObject? to an Int so I can save it

From Dev

How to convert i32 to a string representing the ASCII character

From Dev

How can I save ArrayList<String> in savedInstanceState

From Dev

how can i save the name of UIButton in string?

From Dev

How can I save listbox items into a string

From Dev

How can I save a file in the current directory?

From Dev

How can I save or share a jsfiddle file?

From Dev

How can I save a list of dictionaries to a file?

From Dev

How can I save the last command to a file?

From Dev

How can I save coordinates to a text file?

From Dev

How can I save image jpeg file?

From Dev

How can I save an ArrayList<MyObject> to a file?

From Dev

How can I convert a binary value to text or ascii in python 3?

From Dev

How do I serialize or save to a file a Thunk?

From Dev

How do I save the file name in the database

From Dev

How do I save terminal output to a file?

From Dev

How do I save a file to a subdirectory in InternalStorage

From Dev

How do I save the output of a script to a file?

Related Related

  1. 1

    How do I convert “thm conjI” to an ASCII string I can save to a file?

  2. 2

    in C# how do I convert what I think is a string of hex ascii to something i can read?

  3. 3

    How can I convert a String into ASCII and then back in Haskell?

  4. 4

    How do I convert Encoding.ASCII.GetBytes to string

  5. 5

    How can I convert ASCII tablature into a MIDI file?

  6. 6

    How can I convert a String in ASCII(Unicode Escaped) to Unicode(UTF-8) if I am reading from a file?

  7. 7

    How do i convert from ASCII to Decimal

  8. 8

    How can I add new lines to a string and save it to a file in bash?

  9. 9

    How can I convert a string to a file handle in perl?

  10. 10

    How do I convert result from opening gzip file to string

  11. 11

    How do I force recv() in Socket to NOT convert my hex values into ASCII if it can (python)

  12. 12

    How do I convert a UserDefault value from AnyObject? to an Int so I can save it

  13. 13

    How to convert i32 to a string representing the ASCII character

  14. 14

    How can I save ArrayList<String> in savedInstanceState

  15. 15

    how can i save the name of UIButton in string?

  16. 16

    How can I save listbox items into a string

  17. 17

    How can I save a file in the current directory?

  18. 18

    How can I save or share a jsfiddle file?

  19. 19

    How can I save a list of dictionaries to a file?

  20. 20

    How can I save the last command to a file?

  21. 21

    How can I save coordinates to a text file?

  22. 22

    How can I save image jpeg file?

  23. 23

    How can I save an ArrayList<MyObject> to a file?

  24. 24

    How can I convert a binary value to text or ascii in python 3?

  25. 25

    How do I serialize or save to a file a Thunk?

  26. 26

    How do I save the file name in the database

  27. 27

    How do I save terminal output to a file?

  28. 28

    How do I save a file to a subdirectory in InternalStorage

  29. 29

    How do I save the output of a script to a file?

HotTag

Archive